This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch/rfc] mi_version() method
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 29 Sep 2002 14:27:06 -0400
- Subject: [patch/rfc] mi_version() method
Hello,
The attached adds an mi_version() method. It's there so that MI code
can test the currently selected version and output commands accordingly.
For reference, a change like:
-command
^done,result={1,2,3}
to
-command
^done,result=[1,2,3]
should be selected based on mi_version() (the syntax of the output
changed). However a change like:
-command
^done,result=[1,2,3]
to
-command
+event
+event
^done,result=[1,2,3],nnoise={"noise"}
should not (assuming I've got the event syntax right). This is because
an MI parser is expected to be tolerant to additional, syntaticly
correct, information.
--
I'm also going to bug-report a change-request to ui_out_data() so that,
like gdbarch's data object, it takes an additional handle parameter. At
present it isn't possible for a function like mi_version() to check that
it's being applied to an mi_out object.
Andrew
2002-09-29 Andrew Cagney <ac131313@redhat.com>
* mi-out.c (mi_version): New function.
* mi-out.h (mi_version): Declare.
Index: mi/mi-out.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-out.c,v
retrieving revision 1.23
diff -u -r1.23 mi-out.c
--- mi/mi-out.c 19 Mar 2002 02:51:08 -0000 1.23
+++ mi/mi-out.c 29 Sep 2002 18:15:50 -0000
@@ -428,6 +428,15 @@
ui_file_rewind (data->buffer);
}
+/* Current MI version. */
+
+int
+mi_version (struct ui_out *uiout)
+{
+ struct ui_out_data *data = ui_out_data (uiout);
+ return data->mi_version;
+}
+
/* initalize private members at startup */
struct ui_out *
Index: mi/mi-out.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-out.h,v
retrieving revision 1.6
diff -u -r1.6 mi-out.h
--- mi/mi-out.h 18 Jun 2001 17:57:41 -0000 1.6
+++ mi/mi-out.h 29 Sep 2002 18:15:50 -0000
@@ -30,4 +30,7 @@
extern void mi_out_rewind (struct ui_out *uiout);
extern void mi_out_buffered (struct ui_out *uiout, char *string);
+/* Return the version number of the current MI. */
+extern int mi_version (struct ui_out *uiout);
+
#endif /* MI_OUT_H */