From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30018 invoked by alias); 29 May 2005 02:53:58 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 29974 invoked by uid 22791); 29 May 2005 02:53:51 -0000 Received: from lakermmtao03.cox.net (HELO lakermmtao03.cox.net) (68.230.240.36) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Sun, 29 May 2005 02:53:51 +0000 Received: from white ([68.9.64.121]) by lakermmtao03.cox.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050529025348.SHMZ18229.lakermmtao03.cox.net@white> for ; Sat, 28 May 2005 22:53:48 -0400 Received: from bob by white with local (Exim 3.35 #1 (Debian)) id 1DcDvx-0002ao-00 for ; Sat, 28 May 2005 22:53:49 -0400 Date: Sun, 29 May 2005 02:55:00 -0000 From: Bob Rossi To: gdb-patches@sources.redhat.com Subject: Re: [mi] organize possible exec async mi oc command reasons Message-ID: <20050529025349.GA9122@white> Mail-Followup-To: gdb-patches@sources.redhat.com References: <20050324154602.GA10558@white> <20050324160653.GB29185@nevyn.them.org> <20050324212036.GB10808@white> <20050430193220.GG7009@nevyn.them.org> <20050518040011.GD20928@white> <20050528185302.GG26806@nevyn.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050528185302.GG26806@nevyn.them.org> User-Agent: Mutt/1.3.28i X-SW-Source: 2005-05/txt/msg00602.txt.bz2 On Sat, May 28, 2005 at 02:53:02PM -0400, Daniel Jacobowitz wrote: > On Wed, May 18, 2005 at 12:00:11AM -0400, Bob Rossi wrote: > > I have a feeling that I messed up the internal_error coding style > > function call in _initialize_gdb_mi_common, but I have no idea how to > > fix it. The constant char* error message is longer than 80 char's. Any > > ideas? (I even ran gdb_indent on it, but it didn't help) > > There's lots of ways to do this. You have: > > if (async_reason_string_lookup[EXEC_ASYNC_LAST] != NULL) > internal_error (__FILE__, __LINE__, > _("_initialize_gdb_mi_common: async_reason_string_lookup[] is inconsistent")); > > You could do: > > if (async_reason_string_lookup[EXEC_ASYNC_LAST] != NULL) > internal_error (__FILE__, __LINE__, _("\ > _initialize_gdb_mi_common: async_reason_string_lookup[] is inconsistent")); > > Or: > if (async_reason_string_lookup[EXEC_ASYNC_LAST] != NULL) > internal_error (__FILE__, __LINE__, > _("_initialize_gdb_mi_common: " > "async_reason_string_lookup[] is inconsistent")); > > Or: > if (async_reason_string_lookup[EXEC_ASYNC_LAST] != NULL) > internal_error > (__FILE__, __LINE__, > _("_initialize_gdb_mi_common: async_reason_string_lookup[] is inconsistent")); > > Except that last one is still past 80 chars. > > Or, you could do this: > if (async_reason_string_lookup[EXEC_ASYNC_LAST] != NULL) > internal_error (__FILE__, __LINE__, > _("async_reason_string_lookup[] is inconsistent")); > > Or my personal favorite of the bunch: > if (ARRAY_SIZE (async_reason_string_lookup) != EXEC_ASYNC_LAST + 1) > internal_error (__FILE__, __LINE__, > _("async_reason_string_lookup is inconsistent")); OK, I choose the last one. Seems good to me. Honestly, seeing all of the choices above really helps me understand a bit better the GNU coding standard. Thanks for taking the time to show some options. > > - ui_out_field_string (uiout, "reason", "watchpoint-trigger"); > > + ui_out_field_string (uiout, "reason", > > + async_reason_lookup > > + (EXEC_ASYNC_WATCHPOINT_TRIGGER)); > > This is fine, but if the indentation bugs you, here's an alternative: > > ui_out_field_string > (uiout, "reason", > async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER)); Yes, I didn't like the way it looked. I've changed it in the revised patch. > > > > +@item read-watchpoint-trigger > > +A read watchpoint was triggered > > This one lost a trailing period. Done. > > /* 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! */ > > In general stray line breaks in comments will get eaten by > gdb_indent.sh. You can just put the NOTE on the same line. Also, > "asynchronous" with an h. Done. > > /* This is here only to represent the number of enum's */ > > "the number of enums. " Done. The patch below should contain all of the changes. Thank you again for all your help. The more I do this, the more reliable my patches should become. At least as the GNU coding standard is concerned. RCS file: /cvs/src/src/gdb/ChangeLog,v + * 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. + * mi/mi-common.h: New file. + * mi/mi-common.c: Ditto. RCS file: /cvs/src/src/gdb/doc/ChangeLog,v + * 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: gdb/Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.733 diff -w -u -r1.733 Makefile.in --- gdb/Makefile.in 22 May 2005 20:36:18 -0000 1.733 +++ gdb/Makefile.in 29 May 2005 02:45:29 -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 @@ -1778,7 +1779,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) $(solib_h) \ - $(solist_h) $(observer_h) $(exceptions_h) $(gdb_events_h) + $(solist_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) @@ -2129,7 +2130,8 @@ $(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) $(solib_h) $(gdb_assert_h) + $(value_h) $(observer_h) $(language_h) $(solib_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) @@ -3000,6 +3002,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: gdb/breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.216 diff -w -u -r1.216 breakpoint.c --- gdb/breakpoint.c 26 May 2005 20:48:56 -0000 1.216 +++ gdb/breakpoint.c 29 May 2005 02:45:33 -0000 @@ -55,6 +55,7 @@ #include "exceptions.h" #include "gdb-events.h" +#include "mi/mi-common.h" /* Prototypes for local functions. */ @@ -2114,7 +2115,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; @@ -2249,7 +2251,9 @@ { 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 = "); @@ -2269,7 +2273,9 @@ 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 = "); @@ -2285,7 +2291,9 @@ { 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 = "); @@ -2299,7 +2307,9 @@ { 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 = "); } @@ -2315,7 +2325,9 @@ 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; @@ -2545,7 +2557,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: gdb/infrun.c =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.201 diff -w -u -r1.201 infrun.c --- gdb/infrun.c 12 May 2005 20:21:17 -0000 1.201 +++ gdb/infrun.c 29 May 2005 02:45:35 -0000 @@ -48,6 +48,7 @@ #include "solib.h" #include "gdb_assert.h" +#include "mi/mi-common.h" /* Prototypes for local functions */ @@ -2876,7 +2877,9 @@ 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. */ @@ -2886,7 +2889,9 @@ /* 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", @@ -2906,7 +2911,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); @@ -2915,7 +2921,9 @@ 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; @@ -2926,7 +2934,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: gdb/doc/gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.257 diff -w -u -r1.257 gdb.texinfo --- gdb/doc/gdb.texinfo 26 May 2005 19:28:23 -0000 1.257 +++ gdb/doc/gdb.texinfo 29 May 2005 02:45:51 -0000 @@ -16969,9 +16969,40 @@ target activity (e.g., target stopped). The following is a preliminary list of possible out-of-band records. +In particular, the @var{exec-async-output} records. @table @code -@item "*" "stop" +@item *stopped,reason="@var{reason}" +@end table + +@var{reason} can be one of the following: + +@table @code +@item breakpoint-hit +A breakpoint was reached. +@item watchpoint-trigger +A watchpoint was triggered. +@item read-watchpoint-trigger +A read watchpoint was triggered. +@item access-watchpoint-trigger +An access watchpoint was triggered. +@item function-finished +An -exec-finish or similar CLI command was accomplished. +@item location-reached +An -exec-until or similar CLI command was accomplished. +@item watchpoint-scope +A watchpoint has gone out of scope. +@item end-stepping-range +An -exec-next, -exec-next-instruction, -exec-step, -exec-step-instruction or +similar CLI command was accomplished. +@item exited-signalled +The inferior exited because of a signal. +@item exited +The inferior exited. +@item exited-normally +The inferior exited normally. +@item signal-received +A signal was received by the inferior. @end table