From 034dad6fa14741c4392485c2e64120bef895c4ee Mon Sep 17 00:00:00 2001 From: Bob Rossi Date: Sun, 29 May 2005 03:13:19 +0000 Subject: [PATCH] This is a cleanup change. It is the beggining of allowing GDB/MI to be better understood (internally). --- gdb/ChangeLog | 12 ++++++++++ gdb/Makefile.in | 12 ++++++---- gdb/breakpoint.c | 27 +++++++++++++++++------ gdb/doc/ChangeLog | 5 +++++ gdb/doc/gdb.texinfo | 33 +++++++++++++++++++++++++++- gdb/infrun.c | 19 +++++++++++----- gdb/mi/mi-common.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ gdb/mi/mi-common.h | 46 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 190 insertions(+), 17 deletions(-) create mode 100644 gdb/mi/mi-common.c create mode 100644 gdb/mi/mi-common.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 02105c4eb47..0e83bc78bd6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2005-05-28 Bob Rossi + * 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. + 2005-05-29 Joel Brobecker * alpha-tdep.c (alpha_next_pc): Use correct register number diff --git a/gdb/Makefile.in b/gdb/Makefile.in index eea8b146e8f..2d281cb5163 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -171,14 +171,14 @@ SUBDIR_MI_OBS = \ 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_getopt_h = $(srcdir)/mi/mi-getopt.h 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 @@ breakpoint.o: breakpoint.c $(defs_h) $(symtab_h) $(frame_h) $(breakpoint_h) \ $(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 @@ infrun.o: infrun.c $(defs_h) $(gdb_string_h) $(symtab_h) $(frame_h) \ $(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-parse.o: $(srcdir)/mi/mi-parse.c $(defs_h) $(mi_cmds_h) $(mi_parse_h) \ 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 diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 76c73d7b9c3..c8e15d91554 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -55,6 +55,7 @@ #include "exceptions.h" #include "gdb-events.h" +#include "mi/mi-common.h" /* Prototypes for local functions. */ @@ -2114,7 +2115,8 @@ print_it_typical (bpstat bs) 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 @@ print_it_typical (bpstat bs) { 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 @@ print_it_typical (bpstat bs) 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 @@ print_it_typical (bpstat bs) { 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 @@ print_it_typical (bpstat bs) { 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 @@ print_it_typical (bpstat bs) 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 @@ watchpoint_check (void *p) 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\ diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 7ff998d4cf2..ff4c191ac86 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2005-05-28 Bob Rossi + + * 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-26 Andrew Cagney * gdb.texinfo: Note that Elena Zannoni, Fernando Nasser, and diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 809ce4d2801..f642ab70fa6 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -16969,9 +16969,40 @@ consequence of @sc{gdb/mi} (e.g., a breakpoint modified) or a result of 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 diff --git a/gdb/infrun.c b/gdb/infrun.c index 19a8d2554f2..f0a3a5d61a1 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -48,6 +48,7 @@ #include "solib.h" #include "gdb_assert.h" +#include "mi/mi-common.h" /* Prototypes for local functions */ @@ -2876,7 +2877,9 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info) 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 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info) /* 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 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info) 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 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info) 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 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info) 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 (); diff --git a/gdb/mi/mi-common.c b/gdb/mi/mi-common.c new file mode 100644 index 00000000000..e8760bbffa4 --- /dev/null +++ b/gdb/mi/mi-common.c @@ -0,0 +1,53 @@ +/* Interface for common GDB/MI data + Copyright 2005 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. */ + +#include "defs.h" +#include "mi-common.h" + +static const char * const async_reason_string_lookup[] = +{ + "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", + NULL +}; + +const char * +async_reason_lookup (enum async_reply_reason reason) +{ + return async_reason_string_lookup[reason]; +} + +void +_initialize_gdb_mi_common (void) +{ + if (ARRAY_SIZE (async_reason_string_lookup) != EXEC_ASYNC_LAST + 1) + internal_error (__FILE__, __LINE__, + _("async_reason_string_lookup is inconsistent")); +} diff --git a/gdb/mi/mi-common.h b/gdb/mi/mi-common.h new file mode 100644 index 00000000000..df719c006fb --- /dev/null +++ b/gdb/mi/mi-common.h @@ -0,0 +1,46 @@ +/* Interface for common GDB/MI data + Copyright 2005 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 asynchronous 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 enums. */ + EXEC_ASYNC_LAST +}; + +const char *async_reason_lookup (enum async_reply_reason reason); + +#endif -- 2.30.2