Re: [mi] organize possible exec async mi oc command reasons

Bob Rossi
2005-05-25T23:54:16Z

1 Week Ping. (finger's crossed)

Bob Rossi

On Wed, May 18, 2005 at 12:00:11AM -0400, Bob Rossi wrote:
> On Sat, Apr 30, 2005 at 03:32:20PM -0400, Daniel Jacobowitz wrote:
> > On Thu, Mar 24, 2005 at 04:20:36PM -0500, Bob Rossi wrote:
> > > > I don't have much comment about the patch; it seems like a plausible
> > > > idea. However, please pay attention to the coding and formatting
> > > > standards:
> > > >
> > > > - ChangeLog entries are capitalized and end with periods.
> > > > - Function definitions have the function name in the first column.
> > > > - Function braces are in the first column.
> > > > - There's a space before function argument lists.
> > > > - Function argument lists have to be indented normally; an argument
> > > > on a new line goes at the same depth as the first argument on the
> > > > previous line.
> > > > - Comments don't use multiple leading *s.
> > > >
> > > > and so forth.
> > > >
> > > > I sometimes consider myself the pedantic guardian of GDB's source code
> > > > formatting :-)
> > >
> > > Very sorry for not getting the formatting correct. I respect the rules,
> > > I just have a hard time formatting everything perfectly, I'm sure I can
> > > do better!
> >
> > You're still having a bit of trouble with those pesky spaces before
> > function argument lists. You've also got spaces in the first column;
> > please don't start lines with eight spaces, make sure you use tabs
> > appropriately instead.
> >
> > For example:
> > ui_out_field_string (uiout, "reason",
> > async_reason_lookup(EXEC_ASYNC_BREAKPOINT_HIT));
> >
> > Needs to be:
> > ui_out_field_string (uiout, "reason",
> > async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT));
>
> OK, fixed, thanks.
>
> > > 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
> >
> > NULL, please.
>
> OK, done.
>
> > A couple of other places in GDB have similar idioms, for instance
> > osabi.c/osabi.h. If you use [] for the array, you can create an
> > _initialize_mi_common function which verifies that the array has the
> > correct number of entries and issues an internal error if they get out
> > of step.
>
> Done.
>
> > The documentation had a couple of comma-separated lists with missing
> > spaces, i.e. "-exec-step,-exec-next" should be "-exec-step, -exec-next".
>
> Done.
>
> > Would you mind reposting the patch with these fixes, and the latest
> > revision of the documentation?
>
> Not at all. Thanks for taking the time to review my patches, even though
> I'm still learning some of the basics (ie. GNU coding standard).
>
> 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)
>
> 2005-05-17 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.
> * mi/mi-common.h: New file.
> * mi/mi-common.c: Ditto.
>
> Thanks,
> Bob Rossi
>
> Index: src/gdb/Makefile.in
> ===================================================================
> RCS file: /cvs/src/src/gdb/Makefile.in,v
> retrieving revision 1.731
> diff -w -u -r1.731 Makefile.in
> --- src/gdb/Makefile.in 15 May 2005 18:19:43 -0000 1.731
> +++ src/gdb/Makefile.in 18 May 2005 03:53:58 -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
> @@ -1777,7 +1778,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)
> @@ -2128,7 +2129,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)
> @@ -2995,6 +2997,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.214
> diff -w -u -r1.214 breakpoint.c
> --- src/gdb/breakpoint.c 12 May 2005 20:21:16 -0000 1.214
> +++ src/gdb/breakpoint.c 18 May 2005 03:54:02 -0000
> @@ -55,6 +55,7 @@
> #include "exceptions.h"
>
> #include "gdb-events.h"
> +#include "mi/mi-common.h"
>
> /* Prototypes for local functions. */
>
> @@ -2113,7 +2114,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;
> @@ -2248,7 +2250,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 = ");
> @@ -2268,7 +2272,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 = ");
> @@ -2284,7 +2290,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 = ");
> @@ -2298,7 +2306,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 = ");
> }
> @@ -2314,7 +2324,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;
>
> @@ -2544,7 +2556,9 @@
> 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.201
> diff -w -u -r1.201 infrun.c
> --- src/gdb/infrun.c 12 May 2005 20:21:17 -0000 1.201
> +++ src/gdb/infrun.c 18 May 2005 03:54:04 -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,9 @@
> 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/ChangeLog
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/ChangeLog,v
> retrieving revision 1.494
> diff -w -u -r1.494 ChangeLog
> --- src/gdb/doc/ChangeLog 12 May 2005 09:05:45 -0000 1.494
> +++ src/gdb/doc/ChangeLog 18 May 2005 03:54:07 -0000
> @@ -1,3 +1,8 @@
> +2005-05-17 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.
> +
> 2005-05-12 Eli Zaretskii <eliz@gnu.org>
>
> * gdb.texinfo (Startup): Fix last change. Treat gdb.ini like we
> Index: src/gdb/doc/gdb.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
> retrieving revision 1.253
> diff -w -u -r1.253 gdb.texinfo
> --- src/gdb/doc/gdb.texinfo 12 May 2005 09:05:42 -0000 1.253
> +++ src/gdb/doc/gdb.texinfo 18 May 2005 03:54:20 -0000
> @@ -16953,9 +16953,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
>
>