This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[mi] organize possible exec async mi oc command reasons


Hi,

I am going to attempt to organize the possible MI exec async output
commands. The current problem is that it is not easy to understand the
possible number of 'exec async output commands' that GDB/MI can return
to the FE. I would like to simply this, and eventually add a testcase
for each case. This is a start at enumerating all of the case's and
giving the user a minimal amount of information.

The design is to have mi-common.h be the interface to the rest of 
GDB. Also, MI developers can have a place to look at to determine all
possible supported command types.

Eli, if you can think of a better way for me to add to the doco, let me
know.

BTW, someone please tell me if the testsuite diff is OK, for some reason
there are minor differences between a fresh checkout and my patched
tree, although, I think it has nothing to do with my changes.

I've attached the added files and the testsuite diff. The patch is
below.

2005-03-24  Bob Rossi  <bob@brasko.net>
        * Makefile.in (SUBDIR_MI_OBS, SUBDIR_MI_SRCS): Add mi-common
        (gdb/mi/ headers): Add mi_common_h
        (breakpoint.o, infrun.o): Add dependencies mi_common_h
        * breakpoint.c (include): Add include 'mi/mi-common.h'
        (print_it_typical): Use async_reason_lookup
        (watchpoint_check): ditto
        * infrun.c (include): Add include 'mi/mi-common.h'
        (print_stop_reason): Use async_reason_lookup

2005-03-24  Bob Rossi  <bob@brasko.net>

        * gdb.texinfo (GDB/MI Out-of-band Records): Add bullet enumerating
        the possible reasons why an exec async record would be returned to FE.

Thanks,
Bob Rossi

Index: src/gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.707
diff -w -u -r1.707 Makefile.in
--- src/gdb/Makefile.in	18 Mar 2005 21:03:38 -0000	1.707
+++ src/gdb/Makefile.in	24 Mar 2005 03:11:05 -0000
@@ -171,14 +171,14 @@
 	mi-cmds.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
 	mi-cmd-file.o mi-cmd-disas.o mi-symbol-cmds.o \
 	mi-interp.o \
-	mi-main.o mi-parse.o mi-getopt.o
+	mi-main.o mi-parse.o mi-getopt.o mi-common.o
 SUBDIR_MI_SRCS = \
 	mi/mi-out.c mi/mi-console.c \
 	mi/mi-cmds.c mi/mi-cmd-env.c \
 	mi/mi-cmd-var.c mi/mi-cmd-break.c mi/mi-cmd-stack.c \
 	mi/mi-cmd-file.c mi/mi-cmd-disas.c mi/mi-symbol-cmds.c \
 	mi/mi-interp.c \
-	mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
+	mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c mi/mi-common.c
 SUBDIR_MI_DEPS =
 SUBDIR_MI_LDFLAGS=
 SUBDIR_MI_CFLAGS= \
@@ -824,6 +824,7 @@
 mi_main_h = $(srcdir)/mi/mi-main.h
 mi_out_h = $(srcdir)/mi/mi-out.h
 mi_parse_h = $(srcdir)/mi/mi-parse.h
+mi_common_h = $(srcdir)/mi/mi-common.h
 
 #
 # gdb/tui/ headers
@@ -1773,7 +1774,7 @@
 	$(gdb_string_h) $(demangle_h) $(annotate_h) $(symfile_h) \
 	$(objfiles_h) $(source_h) $(linespec_h) $(completer_h) $(gdb_h) \
 	$(ui_out_h) $(cli_script_h) $(gdb_assert_h) $(block_h) $(solist_h) \
-	$(observer_h) $(exceptions_h) $(gdb_events_h)
+	$(observer_h) $(exceptions_h) $(gdb_events_h) $(mi_common_h)
 bsd-kvm.o: bsd-kvm.c $(defs_h) $(cli_cmds_h) $(command_h) $(frame_h) \
 	$(regcache_h) $(target_h) $(value_h) $(gdbcore_h) $(gdb_assert_h) \
 	$(readline_h) $(bsd_kvm_h)
@@ -2121,7 +2122,7 @@
 	$(inferior_h) $(exceptions_h) $(breakpoint_h) $(gdb_wait_h) \
 	$(gdbcore_h) $(gdbcmd_h) $(cli_script_h) $(target_h) $(gdbthread_h) \
 	$(annotate_h) $(symfile_h) $(top_h) $(inf_loop_h) $(regcache_h) \
-	$(value_h) $(observer_h) $(language_h) $(gdb_assert_h)
+	$(value_h) $(observer_h) $(language_h) $(gdb_assert_h) $(mi_common_h)
 inftarg.o: inftarg.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
 	$(gdbcore_h) $(command_h) $(gdb_stat_h) $(observer_h) $(gdb_wait_h) \
 	$(inflow_h)
@@ -2990,6 +2991,8 @@
 mi-symbol-cmds.o: $(srcdir)/mi/mi-symbol-cmds.c $(defs_h) $(mi_cmds_h) \
 	$(symtab_h) $(ui_out_h)
 	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-symbol-cmds.c
+mi-common.o: $(srcdir)/mi/mi-common.c $(mi_common_h)
+	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-common.c
 
 #
 # rdi-share sub-directory
Index: src/gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.212
diff -w -u -r1.212 breakpoint.c
--- src/gdb/breakpoint.c	24 Feb 2005 13:51:30 -0000	1.212
+++ src/gdb/breakpoint.c	24 Mar 2005 03:11:09 -0000
@@ -54,6 +54,7 @@
 #include "exceptions.h"
 
 #include "gdb-events.h"
+#include "mi/mi-common.h"
 
 /* Prototypes for local functions. */
 
@@ -2108,7 +2109,8 @@
       annotate_breakpoint (bs->breakpoint_at->number);
       ui_out_text (uiout, "\nBreakpoint ");
       if (ui_out_is_mi_like_p (uiout))
-	ui_out_field_string (uiout, "reason", "breakpoint-hit");
+	ui_out_field_string (uiout, "reason", 
+                             async_reason_lookup(EXEC_ASYNC_BREAKPOINT_HIT));
       ui_out_field_int (uiout, "bkptno", bs->breakpoint_at->number);
       ui_out_text (uiout, ", ");
       return PRINT_SRC_AND_LOC;
@@ -2243,7 +2245,8 @@
 	{
 	  annotate_watchpoint (bs->breakpoint_at->number);
 	  if (ui_out_is_mi_like_p (uiout))
-	    ui_out_field_string (uiout, "reason", "watchpoint-trigger");
+	    ui_out_field_string (uiout, "reason", 
+              async_reason_lookup(EXEC_ASYNC_WATCHPOINT_TRIGGER));
 	  mention (bs->breakpoint_at);
 	  ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
 	  ui_out_text (uiout, "\nOld value = ");
@@ -2263,7 +2266,8 @@
 
     case bp_read_watchpoint:
       if (ui_out_is_mi_like_p (uiout))
-	ui_out_field_string (uiout, "reason", "read-watchpoint-trigger");
+	ui_out_field_string (uiout, "reason", 
+                async_reason_lookup(EXEC_ASYNC_READ_WATCHPOINT_TRIGGER));
       mention (bs->breakpoint_at);
       ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
       ui_out_text (uiout, "\nValue = ");
@@ -2279,7 +2283,8 @@
 	{
 	  annotate_watchpoint (bs->breakpoint_at->number);
 	  if (ui_out_is_mi_like_p (uiout))
-	    ui_out_field_string (uiout, "reason", "access-watchpoint-trigger");
+	    ui_out_field_string (uiout, "reason", 
+                    async_reason_lookup(EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER));
 	  mention (bs->breakpoint_at);
 	  ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
 	  ui_out_text (uiout, "\nOld value = ");
@@ -2293,7 +2298,8 @@
 	{
 	  mention (bs->breakpoint_at);
 	  if (ui_out_is_mi_like_p (uiout))
-	    ui_out_field_string (uiout, "reason", "access-watchpoint-trigger");
+	    ui_out_field_string (uiout, "reason", 
+                    async_reason_lookup(EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER));
 	  ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
 	  ui_out_text (uiout, "\nValue = ");
 	}
@@ -2309,7 +2315,8 @@
 
     case bp_finish:
       if (ui_out_is_mi_like_p (uiout))
-	ui_out_field_string (uiout, "reason", "function-finished");
+	ui_out_field_string (uiout, "reason", 
+                async_reason_lookup(EXEC_ASYNC_FUNCTION_FINISHED));
       return PRINT_UNKNOWN;
       break;
 
@@ -2539,7 +2546,8 @@
 	 will be deleted already. So we have no choice but print the
 	 information here. */
       if (ui_out_is_mi_like_p (uiout))
-	ui_out_field_string (uiout, "reason", "watchpoint-scope");
+	ui_out_field_string (uiout, "reason", 
+                async_reason_lookup(EXEC_ASYNC_WATCHPOINT_SCOPE));
       ui_out_text (uiout, "\nWatchpoint ");
       ui_out_field_int (uiout, "wpnum", bs->breakpoint_at->number);
       ui_out_text (uiout, " deleted because the program has left the block in\n\
Index: src/gdb/infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.199
diff -w -u -r1.199 infrun.c
--- src/gdb/infrun.c	24 Feb 2005 13:51:32 -0000	1.199
+++ src/gdb/infrun.c	24 Mar 2005 03:11:11 -0000
@@ -46,6 +46,7 @@
 #include "observer.h"
 #include "language.h"
 #include "gdb_assert.h"
+#include "mi/mi-common.h"
 
 /* Prototypes for local functions */
 
@@ -2866,7 +2867,8 @@
          operation for n > 1 */
       if (!step_multi || !stop_step)
 	if (ui_out_is_mi_like_p (uiout))
-	  ui_out_field_string (uiout, "reason", "end-stepping-range");
+	  ui_out_field_string (uiout, "reason", 
+                  async_reason_lookup(EXEC_ASYNC_END_STEPPING_RANGE));
       break;
     case BREAKPOINT_HIT:
       /* We found a breakpoint. */
@@ -2876,7 +2878,8 @@
       /* The inferior was terminated by a signal. */
       annotate_signalled ();
       if (ui_out_is_mi_like_p (uiout))
-	ui_out_field_string (uiout, "reason", "exited-signalled");
+	ui_out_field_string (uiout, "reason", 
+                async_reason_lookup(EXEC_ASYNC_EXITED_SIGNALLED));
       ui_out_text (uiout, "\nProgram terminated with signal ");
       annotate_signal_name ();
       ui_out_field_string (uiout, "signal-name",
@@ -2896,7 +2899,8 @@
       if (stop_info)
 	{
 	  if (ui_out_is_mi_like_p (uiout))
-	    ui_out_field_string (uiout, "reason", "exited");
+	    ui_out_field_string (uiout, "reason", 
+                    async_reason_lookup(EXEC_ASYNC_EXITED));
 	  ui_out_text (uiout, "\nProgram exited with code ");
 	  ui_out_field_fmt (uiout, "exit-code", "0%o",
 			    (unsigned int) stop_info);
@@ -2905,7 +2909,8 @@
       else
 	{
 	  if (ui_out_is_mi_like_p (uiout))
-	    ui_out_field_string (uiout, "reason", "exited-normally");
+	    ui_out_field_string (uiout, "reason", 
+                    async_reason_lookup(EXEC_ASYNC_EXITED_NORMALLY));
 	  ui_out_text (uiout, "\nProgram exited normally.\n");
 	}
       break;
@@ -2916,7 +2921,8 @@
       ui_out_text (uiout, "\nProgram received signal ");
       annotate_signal_name ();
       if (ui_out_is_mi_like_p (uiout))
-	ui_out_field_string (uiout, "reason", "signal-received");
+	ui_out_field_string (uiout, "reason", 
+                async_reason_lookup(EXEC_ASYNC_SIGNAL_RECEIVED));
       ui_out_field_string (uiout, "signal-name",
 			   target_signal_to_name (stop_info));
       annotate_signal_name_end ();
Index: src/gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.233
diff -w -u -r1.233 gdb.texinfo
--- src/gdb/doc/gdb.texinfo	10 Mar 2005 13:12:33 -0000	1.233
+++ src/gdb/doc/gdb.texinfo	24 Mar 2005 03:11:23 -0000
@@ -15418,9 +15418,50 @@
 The following is a preliminary list of possible out-of-band records.
 
 @table @code
-@item "*" "stop"
+@item "*" "stopped"
 @end table
 
+The following enumerates the current set of reasons why @sc{gdb/mi} would
+return with *stopped (exec-async-output).  
+
+@itemize @bullet
+@item
+A breakpoint was reached, "breakpoint-hit"
+
+@item
+A watchpoint was triggered, "watchpoint-trigger"
+
+@item
+A read watchpoint was triggered, "read-watchpoint-trigger"
+
+@item
+An access watchpoint was triggered, "access-watchpoint-trigger"
+
+@item
+A function finished, "function-finished"
+
+@item
+A location was reached, "location-reached"
+
+@item
+A watchpoint scope, "watchpoint-scope"
+
+@item
+end stepping range, "end-stepping-range"
+
+@item
+inferior exited because of a signal, "exited-signalled"
+
+@item
+inferior exited, "exited"
+
+@item
+inferior exited normally, "exited-normally"
+
+@item
+a signal was received by the inferior, "signal-received"
+@end itemize
+
 
 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 @node GDB/MI Command Description Format
/* List lines of source files for GDB, the GNU debugger.
   Copyright 1999 Free Software Foundation, Inc.

   This file is part of GDB.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

#ifndef MI_COMMON_H
#define MI_COMMON_H

/* Represents the reason why GDB is sending an asyncronous command to the
 * front end 
 *
 * NOTE: When modifing this, don't forget to update gdb.texinfo! */
enum async_reply_reason 
  {
    EXEC_ASYNC_BREAKPOINT_HIT = 0,
    EXEC_ASYNC_WATCHPOINT_TRIGGER,
    EXEC_ASYNC_READ_WATCHPOINT_TRIGGER,
    EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER,
    EXEC_ASYNC_FUNCTION_FINISHED,
    EXEC_ASYNC_LOCATION_REACHED,
    EXEC_ASYNC_WATCHPOINT_SCOPE,
    EXEC_ASYNC_END_STEPPING_RANGE,
    EXEC_ASYNC_EXITED_SIGNALLED,
    EXEC_ASYNC_EXITED,
    EXEC_ASYNC_EXITED_NORMALLY,
    EXEC_ASYNC_SIGNAL_RECEIVED,
    /* This is here only to represent the number of enum's */
    EXEC_ASYNC_LAST
  };

const char *async_reason_lookup (enum async_reply_reason reason);

#endif
#include "mi-common.h"

static const char *async_reason_string_lookup[EXEC_ASYNC_LAST+1] = 
  {
    "breakpoint-hit",
    "watchpoint-trigger",
    "read-watchpoint-trigger",
    "access-watchpoint-trigger",
    "function-finished",
    "location-reached",
    "watchpoint-scope",
    "end-stepping-range",
    "exited-signalled",
    "exited",
    "exited-normally",
    "signal-received",
    (char*)0
  };

const char *async_reason_lookup (enum async_reply_reason reason)
  {
    return async_reason_string_lookup[reason];
  }

Attachment: mi-common-ts.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]