* [3/3] RFC: fix PR mi/8444 @ 2011-11-16 20:28 Tom Tromey 2011-11-16 21:31 ` Pedro Alves 2011-11-17 4:03 ` [3/3] RFC: fix PR mi/8444 Eli Zaretskii 0 siblings, 2 replies; 13+ messages in thread From: Tom Tromey @ 2011-11-16 20:28 UTC (permalink / raw) To: gdb-patches This patch actually fixes the PR. It at least needs a doc review. I noticed several stop reasons which were not emitted. This patch fixes them all. I documented all the new reasons. Most of the patch is changing various print_it methods to use uiout. I made the various new reasons also emit other fields that seemed appropriate. I added a test case which covers the specific case in the PR (solib events), but I didn't try to cover every case. The test case uses "run" instead of "-exec-run" in order to also test the previous patch. Tom 2011-11-16 Tom Tromey <tromey@redhat.com> PR mi/8444: * mi/mi-common.h (EXEC_ASYNC_SOLIB_EVENT, EXEC_ASYNC_FORK) (EXEC_ASYNC_VFORK, EXEC_ASYNC_SYSCALL_ENTRY) (EXEC_ASYNC_SYSCALL_RETURN, EXEC_ASYNC_EXEC): New constants. * mi/mi-common.c (async_reason_string_lookup): Add new reasons. * breakpoint.c (print_it_catch_fork, print_it_catch_vfork) (print_it_catch_syscall, print_it_catch_exec) (internal_bkpt_print_it): Use ui_out. Emit stop reason. 2011-11-16 Tom Tromey <tromey@redhat.com> * gdb.texinfo (GDB/MI Async Records): Document new *stopped reasons. 2011-11-16 Tom Tromey <tromey@redhat.com> * lib/mi-support.exp (mi_run_cmd_full): Rename from mi_run_cmd. Add "use_mi_command" argument. (mi_run_cmd, mi_run_with_cli): New procs. * gdb.mi/solib-lib.c: New file. * gdb.mi/solib-main.c: New file. * gdb.mi/mi-solib.exp: New file. From f9ccf49896650cd458c4e6e2561d2e9cc48c788d Mon Sep 17 00:00:00 2001 From: Tom Tromey <tromey@redhat.com> Date: Wed, 16 Nov 2011 08:31:11 -0700 Subject: [PATCH 3/3] fix PR 8444 --- gdb/ChangeLog | 11 +++++ gdb/breakpoint.c | 90 +++++++++++++++++++++++++++++------- gdb/doc/ChangeLog | 5 ++ gdb/doc/gdb.texinfo | 19 ++++++++ gdb/mi/mi-common.c | 6 +++ gdb/mi/mi-common.h | 6 +++ gdb/testsuite/ChangeLog | 9 ++++ gdb/testsuite/gdb.mi/mi-solib.exp | 55 ++++++++++++++++++++++ gdb/testsuite/gdb.mi/solib-lib.c | 20 ++++++++ gdb/testsuite/gdb.mi/solib-main.c | 24 ++++++++++ gdb/testsuite/lib/mi-support.exp | 26 +++++++++-- 11 files changed, 248 insertions(+), 23 deletions(-) create mode 100644 gdb/testsuite/gdb.mi/mi-solib.exp create mode 100644 gdb/testsuite/gdb.mi/solib-lib.c create mode 100644 gdb/testsuite/gdb.mi/solib-main.c diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8f09296..3eed4b2 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -6176,12 +6176,25 @@ breakpoint_hit_catch_fork (const struct bp_location *bl, static enum print_stop_action print_it_catch_fork (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b = bs->breakpoint_at; struct fork_catchpoint *c = (struct fork_catchpoint *) bs->breakpoint_at; annotate_catchpoint (b->number); - printf_filtered (_("\nCatchpoint %d (forked process %d), "), - b->number, ptid_get_pid (c->forked_inferior_pid)); + if (b->disposition == disp_del) + ui_out_text (uiout, "\nTemporary catchpoint "); + else + ui_out_text (uiout, "\nCatchpoint "); + if (ui_out_is_mi_like_p (uiout)) + { + ui_out_field_string (uiout, "reason", + async_reason_lookup (EXEC_ASYNC_FORK)); + ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + } + ui_out_field_int (uiout, "bkptno", b->number); + ui_out_text (uiout, " (forked process "); + ui_out_field_int (uiout, "newpid", ptid_get_pid (c->forked_inferior_pid)); + ui_out_text (uiout, "), "); return PRINT_SRC_AND_LOC; } @@ -6272,12 +6285,25 @@ breakpoint_hit_catch_vfork (const struct bp_location *bl, static enum print_stop_action print_it_catch_vfork (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b = bs->breakpoint_at; struct fork_catchpoint *c = (struct fork_catchpoint *) b; annotate_catchpoint (b->number); - printf_filtered (_("\nCatchpoint %d (vforked process %d), "), - b->number, ptid_get_pid (c->forked_inferior_pid)); + if (b->disposition == disp_del) + ui_out_text (uiout, "\nTemporary catchpoint "); + else + ui_out_text (uiout, "\nCatchpoint "); + if (ui_out_is_mi_like_p (uiout)) + { + ui_out_field_string (uiout, "reason", + async_reason_lookup (EXEC_ASYNC_VFORK)); + ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + } + ui_out_field_int (uiout, "bkptno", b->number); + ui_out_text (uiout, " (vforked process "); + ui_out_field_int (uiout, "newpid", ptid_get_pid (c->forked_inferior_pid)); + ui_out_text (uiout, "), "); return PRINT_SRC_AND_LOC; } @@ -6486,6 +6512,7 @@ breakpoint_hit_catch_syscall (const struct bp_location *bl, static enum print_stop_action print_it_catch_syscall (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b = bs->breakpoint_at; /* These are needed because we want to know in which state a syscall is. It can be in the TARGET_WAITKIND_SYSCALL_ENTRY @@ -6494,7 +6521,6 @@ print_it_catch_syscall (bpstat bs) ptid_t ptid; struct target_waitstatus last; struct syscall s; - struct cleanup *old_chain; char *syscall_id; get_last_target_status (&ptid, &last); @@ -6503,21 +6529,31 @@ print_it_catch_syscall (bpstat bs) annotate_catchpoint (b->number); - if (s.name == NULL) - syscall_id = xstrprintf ("%d", last.value.syscall_number); + if (b->disposition == disp_del) + ui_out_text (uiout, "\nTemporary catchpoint "); else - syscall_id = xstrprintf ("'%s'", s.name); - - old_chain = make_cleanup (xfree, syscall_id); + ui_out_text (uiout, "\nCatchpoint "); + if (ui_out_is_mi_like_p (uiout)) + { + ui_out_field_string (uiout, "reason", + async_reason_lookup (last.kind == TARGET_WAITKIND_SYSCALL_ENTRY + ? EXEC_ASYNC_SYSCALL_ENTRY + : EXEC_ASYNC_SYSCALL_RETURN)); + ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + } + ui_out_field_int (uiout, "bkptno", b->number); if (last.kind == TARGET_WAITKIND_SYSCALL_ENTRY) - printf_filtered (_("\nCatchpoint %d (call to syscall %s), "), - b->number, syscall_id); - else if (last.kind == TARGET_WAITKIND_SYSCALL_RETURN) - printf_filtered (_("\nCatchpoint %d (returned from syscall %s), "), - b->number, syscall_id); + ui_out_text (uiout, " (call to syscall "); + else + ui_out_text (uiout, " (returned from syscall "); - do_cleanups (old_chain); + if (s.name == NULL || ui_out_is_mi_like_p (uiout)) + ui_out_field_int (uiout, "syscall-number", last.value.syscall_number); + if (s.name != NULL) + ui_out_field_string (uiout, "syscall-name", s.name); + + ui_out_text (uiout, "), "); return PRINT_SRC_AND_LOC; } @@ -6760,12 +6796,26 @@ breakpoint_hit_catch_exec (const struct bp_location *bl, static enum print_stop_action print_it_catch_exec (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b = bs->breakpoint_at; struct exec_catchpoint *c = (struct exec_catchpoint *) b; annotate_catchpoint (b->number); - printf_filtered (_("\nCatchpoint %d (exec'd %s), "), b->number, - c->exec_pathname); + if (b->disposition == disp_del) + ui_out_text (uiout, "\nTemporary catchpoint "); + else + ui_out_text (uiout, "\nCatchpoint "); + if (ui_out_is_mi_like_p (uiout)) + { + ui_out_field_string (uiout, "reason", + async_reason_lookup (EXEC_ASYNC_EXEC)); + ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + } + ui_out_field_int (uiout, "bkptno", b->number); + ui_out_text (uiout, " (exec'd "); + ui_out_field_string (uiout, "new-exec", c->exec_pathname); + ui_out_text (uiout, "), "); + return PRINT_SRC_AND_LOC; } @@ -11133,6 +11183,7 @@ internal_bkpt_check_status (bpstat bs) static enum print_stop_action internal_bkpt_print_it (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b; b = bs->breakpoint_at; @@ -11144,6 +11195,9 @@ internal_bkpt_print_it (bpstat bs) variable? (If so, we report this as a generic, "Stopped due to shlib event" message.) */ printf_filtered (_("Stopped due to shared library event\n")); + if (ui_out_is_mi_like_p (uiout)) + ui_out_field_string (uiout, "reason", + async_reason_lookup (EXEC_ASYNC_SOLIB_EVENT)); break; case bp_thread_event: diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index f4f7f1e..c13cd62 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -26130,6 +26130,25 @@ The inferior exited. The inferior exited normally. @item signal-received A signal was received by the inferior. +@item solib-event +The inferior has stopped due to a library being loaded or unloaded. +This can only happen when @code{stop-on-solib-events} (@pxref{Files}) +is set. +@item fork +The inferior has forked. This is reported when @code{catch fork} +(@pxref{Set Catchpoints}) has been used. +@item vfork +The inferior has vforked. This is reported in when @code{catch vfork} +(@pxref{Set Catchpoints}) has been used. +@item syscall-entry +The inferior entered a system call. This is reported when @code{catch +syscall} (@pxref{Set Catchpoints}) has been used. +@item syscall-entry +The inferior returned from a system call. This is reported when +@code{catch syscall} (@pxref{Set Catchpoints}) has been used. +@item exec +The inferior called @code{exec}. This is reported when @code{catch exec} +(@pxref{Set Catchpoints}) has been used. @end table The @var{id} field identifies the thread that directly caused the stop diff --git a/gdb/mi/mi-common.c b/gdb/mi/mi-common.c index e7dd3c4..8fb9799 100644 --- a/gdb/mi/mi-common.c +++ b/gdb/mi/mi-common.c @@ -35,6 +35,12 @@ static const char * const async_reason_string_lookup[] = "exited", "exited-normally", "signal-received", + "solib-event", + "fork", + "vfork", + "syscall-entry", + "syscall-return", + "exec", NULL }; diff --git a/gdb/mi/mi-common.h b/gdb/mi/mi-common.h index dc5fc8e..9ecc5a1 100644 --- a/gdb/mi/mi-common.h +++ b/gdb/mi/mi-common.h @@ -37,6 +37,12 @@ enum async_reply_reason EXEC_ASYNC_EXITED, EXEC_ASYNC_EXITED_NORMALLY, EXEC_ASYNC_SIGNAL_RECEIVED, + EXEC_ASYNC_SOLIB_EVENT, + EXEC_ASYNC_FORK, + EXEC_ASYNC_VFORK, + EXEC_ASYNC_SYSCALL_ENTRY, + EXEC_ASYNC_SYSCALL_RETURN, + EXEC_ASYNC_EXEC, /* This is here only to represent the number of enums. */ EXEC_ASYNC_LAST }; diff --git a/gdb/testsuite/gdb.mi/mi-solib.exp b/gdb/testsuite/gdb.mi/mi-solib.exp new file mode 100644 index 0000000..a8ef84c --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-solib.exp @@ -0,0 +1,55 @@ +# Copyright 2011 Free Software Foundation, Inc. + +# 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 3 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, see <http://www.gnu.org/licenses/>. + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set libname "solib-lib" +set srcfile_lib ${srcdir}/${subdir}/${libname}.c +set binfile_lib ${objdir}/${subdir}/${libname}.so +set lib_flags [list debug ldflags=-Wl,-Bsymbolic] + +set testfile "solib-main" +set srcfile ${srcdir}/${subdir}/${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +set bin_flags [list debug shlib=${binfile_lib}] + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != "" + || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } { + untested "Could not compile $binfile_lib or $binfile." + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_gdb_test "777-gdb-set stop-on-solib-events 1" "777\\^done" \ + "set stop-on-solib-events" + +# We use "run" rather than "-exec-run" here in order to test that CLI +# commands still cause the correct MI output to be generated. +mi_run_with_cli +mi_expect_stop solib-event .* .* .* .* .* "check for solib event" diff --git a/gdb/testsuite/gdb.mi/solib-lib.c b/gdb/testsuite/gdb.mi/solib-lib.c new file mode 100644 index 0000000..00a1595 --- /dev/null +++ b/gdb/testsuite/gdb.mi/solib-lib.c @@ -0,0 +1,20 @@ +/* Copyright 2011 Free Software Foundation, Inc. + + 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 3 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, see <http://www.gnu.org/licenses/>. +*/ +#include <stdio.h> + +void solibfunction(void) +{ +} diff --git a/gdb/testsuite/gdb.mi/solib-main.c b/gdb/testsuite/gdb.mi/solib-main.c new file mode 100644 index 0000000..df58efc --- /dev/null +++ b/gdb/testsuite/gdb.mi/solib-main.c @@ -0,0 +1,24 @@ +/* Copyright 2011 Free Software Foundation, Inc. + + 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 3 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, see <http://www.gnu.org/licenses/>. +*/ +#include <stdio.h> + +extern void solibfunction(void); + +int main () +{ + solibfunction (); + return 0; +} diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 63097cb..e07562d 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -788,7 +788,7 @@ proc mi_gdb_test { args } { # In patterns, the newline sequence ``\r\n'' is matched explicitly as # ``.*$'' could swallow up output that we attempt to match elsewhere. -proc mi_run_cmd {args} { +proc mi_run_cmd_full {use_mi_command args} { global suppress_flag if { $suppress_flag } { return -1 @@ -797,6 +797,14 @@ proc mi_run_cmd {args} { global thread_selected_re global library_loaded_re + if {$use_mi_command} { + set run_prefix "220-exec-" + set run_match "220" + } else { + set run_prefix "" + set run_match "" + } + if [target_info exists gdb_init_command] { send_gdb "[target_info gdb_init_command]\n"; gdb_expect 30 { @@ -814,9 +822,9 @@ proc mi_run_cmd {args} { if [target_info exists use_gdb_stub] { if [target_info exists gdb,do_reload_on_run] { - send_gdb "220-exec-continue\n"; + send_gdb "${run_prefix}continue\n"; gdb_expect 60 { - -re "220\\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\r\n$mi_gdb_prompt" {} + -re "${run_match}\\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\r\n$mi_gdb_prompt" {} default {} } return 0; @@ -835,9 +843,9 @@ proc mi_run_cmd {args} { return 0 } - send_gdb "220-exec-run $args\n" + send_gdb "${run_prefix}run $args\n" gdb_expect { - -re "220\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${library_loaded_re})*(${thread_selected_re})?${mi_gdb_prompt}" { + -re "${run_match}\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${library_loaded_re})*(${thread_selected_re})?${mi_gdb_prompt}" { } -re "\\^error,msg=\"The target does not support running in non-stop mode.\"" { unsupported "Non-stop mode not supported" @@ -853,6 +861,14 @@ proc mi_run_cmd {args} { return 0 } +proc mi_run_cmd {args} { + return [eval mi_run_cmd_full 1 $args] +} + +proc mi_run_with_cli {args} { + return [eval mi_run_cmd_full 0 $args] +} + # # Just like run-to-main but works with the MI interface # -- 1.7.6.4 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [3/3] RFC: fix PR mi/8444 2011-11-16 20:28 [3/3] RFC: fix PR mi/8444 Tom Tromey @ 2011-11-16 21:31 ` Pedro Alves 2011-11-17 16:41 ` Tom Tromey 2011-11-17 4:03 ` [3/3] RFC: fix PR mi/8444 Eli Zaretskii 1 sibling, 1 reply; 13+ messages in thread From: Pedro Alves @ 2011-11-16 21:31 UTC (permalink / raw) To: gdb-patches; +Cc: Tom Tromey On Wednesday 16 November 2011 20:04:29, Tom Tromey wrote: > @@ -11144,6 +11195,9 @@ internal_bkpt_print_it (bpstat bs) > variable? (If so, we report this as a generic, "Stopped due > to shlib event" message.) */ > printf_filtered (_("Stopped due to shared library event\n")); > + if (ui_out_is_mi_like_p (uiout)) > + ui_out_field_string (uiout, "reason", > + async_reason_lookup (EXEC_ASYNC_SOLIB_EVENT)); TARGET_WAITKIND_LOADED targets print this elsewhere, as they don't use a shared library event breakpoint. See infrun.c:normal_stop. Can you give that the same treatment? -- Pedro Alves ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [3/3] RFC: fix PR mi/8444 2011-11-16 21:31 ` Pedro Alves @ 2011-11-17 16:41 ` Tom Tromey 2011-11-22 14:55 ` Pedro Alves 0 siblings, 1 reply; 13+ messages in thread From: Tom Tromey @ 2011-11-17 16:41 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches >>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes: Pedro> TARGET_WAITKIND_LOADED targets print this elsewhere, as Pedro> they don't use a shared library event breakpoint. See Pedro> infrun.c:normal_stop. Can you give that the same treatment? What do you think of the appended? I don't think I have access to a TARGET_WAITKIND_LOADED target, so I can't test this. I added a 'kind' argument to bpstat_print, to centralize the printing. I wasn't sure if this is a good idea or not; I think the centralization idea is fine, but I wasn't sure if this addition is violating some abstraction boundary. Tom 2011-11-17 Tom Tromey <tromey@redhat.com> PR mi/8444: * mi/mi-common.h (EXEC_ASYNC_SOLIB_EVENT, EXEC_ASYNC_FORK) (EXEC_ASYNC_VFORK, EXEC_ASYNC_SYSCALL_ENTRY) (EXEC_ASYNC_SYSCALL_RETURN, EXEC_ASYNC_EXEC): New constants. * mi/mi-common.c (async_reason_string_lookup): Add new reasons. * breakpoint.c (print_it_catch_fork, print_it_catch_vfork) (print_it_catch_syscall, print_it_catch_exec) (internal_bkpt_print_it): Use ui_out. Emit stop reason. (bpstat_print): Add 'kind' argument. Handle TARGET_WAITKIND_LOADED. * infrun.c (normal_stop): Update for bpstat_print change. Don't handle TARGET_WAITKIND_LOADED here. * breakpoint.h (bpstat_print): Update. 2011-11-16 Tom Tromey <tromey@redhat.com> * gdb.texinfo (GDB/MI Async Records): Document new *stopped reasons. 2011-11-16 Tom Tromey <tromey@redhat.com> * lib/mi-support.exp (mi_run_cmd_full): Rename from mi_run_cmd. Add "use_mi_command" argument. (mi_run_cmd, mi_run_with_cli): New procs. * gdb.mi/solib-lib.c: New file. * gdb.mi/solib-main.c: New file. * gdb.mi/mi-solib.exp: New file. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8f09296..588a58c 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3446,7 +3446,8 @@ print_bp_stop_message (bpstat bs) /* Print a message indicating what happened. This is called from normal_stop(). The input to this routine is the head of the bpstat - list - a list of the eventpoints that caused this stop. This + list - a list of the eventpoints that caused this stop. KIND is + the target_waitkind for the stopping event. This routine calls the generic print routine for printing a message about reasons for stopping. This will print (for example) the "Breakpoint n," part of the output. The return value of this @@ -3465,7 +3466,7 @@ print_bp_stop_message (bpstat bs) further info to be printed. */ enum print_stop_action -bpstat_print (bpstat bs) +bpstat_print (bpstat bs, int kind) { int val; @@ -3482,6 +3483,18 @@ bpstat_print (bpstat bs) return val; } + /* If we had hit a shared library event breakpoint, + print_bp_stop_message would print out this message. If we hit an + OS-level shared library event, do the same thing. */ + if (kind == TARGET_WAITKIND_LOADED) + { + printf_filtered (_("Stopped due to shared library event\n")); + if (ui_out_is_mi_like_p (current_uiout)) + ui_out_field_string (current_uiout, "reason", + async_reason_lookup (EXEC_ASYNC_SOLIB_EVENT)); + return PRINT_NOTHING; + } + /* We reached the end of the chain, or we got a null BS to start with and nothing was printed. */ return PRINT_UNKNOWN; @@ -6176,12 +6189,25 @@ breakpoint_hit_catch_fork (const struct bp_location *bl, static enum print_stop_action print_it_catch_fork (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b = bs->breakpoint_at; struct fork_catchpoint *c = (struct fork_catchpoint *) bs->breakpoint_at; annotate_catchpoint (b->number); - printf_filtered (_("\nCatchpoint %d (forked process %d), "), - b->number, ptid_get_pid (c->forked_inferior_pid)); + if (b->disposition == disp_del) + ui_out_text (uiout, "\nTemporary catchpoint "); + else + ui_out_text (uiout, "\nCatchpoint "); + if (ui_out_is_mi_like_p (uiout)) + { + ui_out_field_string (uiout, "reason", + async_reason_lookup (EXEC_ASYNC_FORK)); + ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + } + ui_out_field_int (uiout, "bkptno", b->number); + ui_out_text (uiout, " (forked process "); + ui_out_field_int (uiout, "newpid", ptid_get_pid (c->forked_inferior_pid)); + ui_out_text (uiout, "), "); return PRINT_SRC_AND_LOC; } @@ -6272,12 +6298,25 @@ breakpoint_hit_catch_vfork (const struct bp_location *bl, static enum print_stop_action print_it_catch_vfork (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b = bs->breakpoint_at; struct fork_catchpoint *c = (struct fork_catchpoint *) b; annotate_catchpoint (b->number); - printf_filtered (_("\nCatchpoint %d (vforked process %d), "), - b->number, ptid_get_pid (c->forked_inferior_pid)); + if (b->disposition == disp_del) + ui_out_text (uiout, "\nTemporary catchpoint "); + else + ui_out_text (uiout, "\nCatchpoint "); + if (ui_out_is_mi_like_p (uiout)) + { + ui_out_field_string (uiout, "reason", + async_reason_lookup (EXEC_ASYNC_VFORK)); + ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + } + ui_out_field_int (uiout, "bkptno", b->number); + ui_out_text (uiout, " (vforked process "); + ui_out_field_int (uiout, "newpid", ptid_get_pid (c->forked_inferior_pid)); + ui_out_text (uiout, "), "); return PRINT_SRC_AND_LOC; } @@ -6486,6 +6525,7 @@ breakpoint_hit_catch_syscall (const struct bp_location *bl, static enum print_stop_action print_it_catch_syscall (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b = bs->breakpoint_at; /* These are needed because we want to know in which state a syscall is. It can be in the TARGET_WAITKIND_SYSCALL_ENTRY @@ -6494,7 +6534,6 @@ print_it_catch_syscall (bpstat bs) ptid_t ptid; struct target_waitstatus last; struct syscall s; - struct cleanup *old_chain; char *syscall_id; get_last_target_status (&ptid, &last); @@ -6503,21 +6542,31 @@ print_it_catch_syscall (bpstat bs) annotate_catchpoint (b->number); - if (s.name == NULL) - syscall_id = xstrprintf ("%d", last.value.syscall_number); + if (b->disposition == disp_del) + ui_out_text (uiout, "\nTemporary catchpoint "); else - syscall_id = xstrprintf ("'%s'", s.name); - - old_chain = make_cleanup (xfree, syscall_id); + ui_out_text (uiout, "\nCatchpoint "); + if (ui_out_is_mi_like_p (uiout)) + { + ui_out_field_string (uiout, "reason", + async_reason_lookup (last.kind == TARGET_WAITKIND_SYSCALL_ENTRY + ? EXEC_ASYNC_SYSCALL_ENTRY + : EXEC_ASYNC_SYSCALL_RETURN)); + ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + } + ui_out_field_int (uiout, "bkptno", b->number); if (last.kind == TARGET_WAITKIND_SYSCALL_ENTRY) - printf_filtered (_("\nCatchpoint %d (call to syscall %s), "), - b->number, syscall_id); - else if (last.kind == TARGET_WAITKIND_SYSCALL_RETURN) - printf_filtered (_("\nCatchpoint %d (returned from syscall %s), "), - b->number, syscall_id); + ui_out_text (uiout, " (call to syscall "); + else + ui_out_text (uiout, " (returned from syscall "); - do_cleanups (old_chain); + if (s.name == NULL || ui_out_is_mi_like_p (uiout)) + ui_out_field_int (uiout, "syscall-number", last.value.syscall_number); + if (s.name != NULL) + ui_out_field_string (uiout, "syscall-name", s.name); + + ui_out_text (uiout, "), "); return PRINT_SRC_AND_LOC; } @@ -6760,12 +6809,26 @@ breakpoint_hit_catch_exec (const struct bp_location *bl, static enum print_stop_action print_it_catch_exec (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b = bs->breakpoint_at; struct exec_catchpoint *c = (struct exec_catchpoint *) b; annotate_catchpoint (b->number); - printf_filtered (_("\nCatchpoint %d (exec'd %s), "), b->number, - c->exec_pathname); + if (b->disposition == disp_del) + ui_out_text (uiout, "\nTemporary catchpoint "); + else + ui_out_text (uiout, "\nCatchpoint "); + if (ui_out_is_mi_like_p (uiout)) + { + ui_out_field_string (uiout, "reason", + async_reason_lookup (EXEC_ASYNC_EXEC)); + ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + } + ui_out_field_int (uiout, "bkptno", b->number); + ui_out_text (uiout, " (exec'd "); + ui_out_field_string (uiout, "new-exec", c->exec_pathname); + ui_out_text (uiout, "), "); + return PRINT_SRC_AND_LOC; } @@ -11133,6 +11196,7 @@ internal_bkpt_check_status (bpstat bs) static enum print_stop_action internal_bkpt_print_it (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b; b = bs->breakpoint_at; @@ -11144,6 +11208,9 @@ internal_bkpt_print_it (bpstat bs) variable? (If so, we report this as a generic, "Stopped due to shlib event" message.) */ printf_filtered (_("Stopped due to shared library event\n")); + if (ui_out_is_mi_like_p (uiout)) + ui_out_field_string (uiout, "reason", + async_reason_lookup (EXEC_ASYNC_SOLIB_EVENT)); break; case bp_thread_event: diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 506ae80..8a7287d 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -880,7 +880,7 @@ extern int bpstat_should_step (void); /* Print a message indicating what happened. Returns nonzero to say that only the source line should be printed after this (zero return means print the frame as well as the source line). */ -extern enum print_stop_action bpstat_print (bpstat); +extern enum print_stop_action bpstat_print (bpstat, int); /* Put in *NUM the breakpoint number of the first breakpoint we are stopped at. *BSP upon return is a bpstat which points to the diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index f4f7f1e..c13cd62 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -26130,6 +26130,25 @@ The inferior exited. The inferior exited normally. @item signal-received A signal was received by the inferior. +@item solib-event +The inferior has stopped due to a library being loaded or unloaded. +This can only happen when @code{stop-on-solib-events} (@pxref{Files}) +is set. +@item fork +The inferior has forked. This is reported when @code{catch fork} +(@pxref{Set Catchpoints}) has been used. +@item vfork +The inferior has vforked. This is reported in when @code{catch vfork} +(@pxref{Set Catchpoints}) has been used. +@item syscall-entry +The inferior entered a system call. This is reported when @code{catch +syscall} (@pxref{Set Catchpoints}) has been used. +@item syscall-entry +The inferior returned from a system call. This is reported when +@code{catch syscall} (@pxref{Set Catchpoints}) has been used. +@item exec +The inferior called @code{exec}. This is reported when @code{catch exec} +(@pxref{Set Catchpoints}) has been used. @end table The @var{id} field identifies the thread that directly caused the stop diff --git a/gdb/infrun.c b/gdb/infrun.c index 3361926..5a0f1d2 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -5971,22 +5971,10 @@ normal_stop (void) int do_frame_printing = 1; struct thread_info *tp = inferior_thread (); - bpstat_ret = bpstat_print (tp->control.stop_bpstat); + bpstat_ret = bpstat_print (tp->control.stop_bpstat, last.kind); switch (bpstat_ret) { case PRINT_UNKNOWN: - /* If we had hit a shared library event breakpoint, - bpstat_print would print out this message. If we hit - an OS-level shared library event, do the same - thing. */ - if (last.kind == TARGET_WAITKIND_LOADED) - { - printf_filtered (_("Stopped due to shared library event\n")); - source_flag = SRC_LINE; /* something bogus */ - do_frame_printing = 0; - break; - } - /* FIXME: cagney/2002-12-01: Given that a frame ID does (or should) carry around the function and does (or should) use that when doing a frame comparison. */ diff --git a/gdb/mi/mi-common.c b/gdb/mi/mi-common.c index e7dd3c4..8fb9799 100644 --- a/gdb/mi/mi-common.c +++ b/gdb/mi/mi-common.c @@ -35,6 +35,12 @@ static const char * const async_reason_string_lookup[] = "exited", "exited-normally", "signal-received", + "solib-event", + "fork", + "vfork", + "syscall-entry", + "syscall-return", + "exec", NULL }; diff --git a/gdb/mi/mi-common.h b/gdb/mi/mi-common.h index dc5fc8e..9ecc5a1 100644 --- a/gdb/mi/mi-common.h +++ b/gdb/mi/mi-common.h @@ -37,6 +37,12 @@ enum async_reply_reason EXEC_ASYNC_EXITED, EXEC_ASYNC_EXITED_NORMALLY, EXEC_ASYNC_SIGNAL_RECEIVED, + EXEC_ASYNC_SOLIB_EVENT, + EXEC_ASYNC_FORK, + EXEC_ASYNC_VFORK, + EXEC_ASYNC_SYSCALL_ENTRY, + EXEC_ASYNC_SYSCALL_RETURN, + EXEC_ASYNC_EXEC, /* This is here only to represent the number of enums. */ EXEC_ASYNC_LAST }; diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 2aec1c7..b075e33 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -427,9 +427,14 @@ mi_on_normal_stop (struct bpstats *bs, int print_frame) the frame again. In practice, this can only happen when running a CLI command in MI. */ struct ui_out *saved_uiout = current_uiout; + struct target_waitstatus last; + ptid_t last_ptid; current_uiout = mi_uiout; - bpstat_print (bs); + + get_last_target_status (&last_ptid, &last); + bpstat_print (bs, last.kind); + print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC); current_uiout = saved_uiout; } diff --git a/gdb/testsuite/gdb.mi/mi-solib.exp b/gdb/testsuite/gdb.mi/mi-solib.exp new file mode 100644 index 0000000..a8ef84c --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-solib.exp @@ -0,0 +1,55 @@ +# Copyright 2011 Free Software Foundation, Inc. + +# 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 3 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, see <http://www.gnu.org/licenses/>. + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set libname "solib-lib" +set srcfile_lib ${srcdir}/${subdir}/${libname}.c +set binfile_lib ${objdir}/${subdir}/${libname}.so +set lib_flags [list debug ldflags=-Wl,-Bsymbolic] + +set testfile "solib-main" +set srcfile ${srcdir}/${subdir}/${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +set bin_flags [list debug shlib=${binfile_lib}] + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != "" + || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } { + untested "Could not compile $binfile_lib or $binfile." + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_gdb_test "777-gdb-set stop-on-solib-events 1" "777\\^done" \ + "set stop-on-solib-events" + +# We use "run" rather than "-exec-run" here in order to test that CLI +# commands still cause the correct MI output to be generated. +mi_run_with_cli +mi_expect_stop solib-event .* .* .* .* .* "check for solib event" diff --git a/gdb/testsuite/gdb.mi/solib-lib.c b/gdb/testsuite/gdb.mi/solib-lib.c new file mode 100644 index 0000000..00a1595 --- /dev/null +++ b/gdb/testsuite/gdb.mi/solib-lib.c @@ -0,0 +1,20 @@ +/* Copyright 2011 Free Software Foundation, Inc. + + 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 3 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, see <http://www.gnu.org/licenses/>. +*/ +#include <stdio.h> + +void solibfunction(void) +{ +} diff --git a/gdb/testsuite/gdb.mi/solib-main.c b/gdb/testsuite/gdb.mi/solib-main.c new file mode 100644 index 0000000..df58efc --- /dev/null +++ b/gdb/testsuite/gdb.mi/solib-main.c @@ -0,0 +1,24 @@ +/* Copyright 2011 Free Software Foundation, Inc. + + 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 3 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, see <http://www.gnu.org/licenses/>. +*/ +#include <stdio.h> + +extern void solibfunction(void); + +int main () +{ + solibfunction (); + return 0; +} diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 63097cb..e07562d 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -788,7 +788,7 @@ proc mi_gdb_test { args } { # In patterns, the newline sequence ``\r\n'' is matched explicitly as # ``.*$'' could swallow up output that we attempt to match elsewhere. -proc mi_run_cmd {args} { +proc mi_run_cmd_full {use_mi_command args} { global suppress_flag if { $suppress_flag } { return -1 @@ -797,6 +797,14 @@ proc mi_run_cmd {args} { global thread_selected_re global library_loaded_re + if {$use_mi_command} { + set run_prefix "220-exec-" + set run_match "220" + } else { + set run_prefix "" + set run_match "" + } + if [target_info exists gdb_init_command] { send_gdb "[target_info gdb_init_command]\n"; gdb_expect 30 { @@ -814,9 +822,9 @@ proc mi_run_cmd {args} { if [target_info exists use_gdb_stub] { if [target_info exists gdb,do_reload_on_run] { - send_gdb "220-exec-continue\n"; + send_gdb "${run_prefix}continue\n"; gdb_expect 60 { - -re "220\\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\r\n$mi_gdb_prompt" {} + -re "${run_match}\\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\r\n$mi_gdb_prompt" {} default {} } return 0; @@ -835,9 +843,9 @@ proc mi_run_cmd {args} { return 0 } - send_gdb "220-exec-run $args\n" + send_gdb "${run_prefix}run $args\n" gdb_expect { - -re "220\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${library_loaded_re})*(${thread_selected_re})?${mi_gdb_prompt}" { + -re "${run_match}\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${library_loaded_re})*(${thread_selected_re})?${mi_gdb_prompt}" { } -re "\\^error,msg=\"The target does not support running in non-stop mode.\"" { unsupported "Non-stop mode not supported" @@ -853,6 +861,14 @@ proc mi_run_cmd {args} { return 0 } +proc mi_run_cmd {args} { + return [eval mi_run_cmd_full 1 $args] +} + +proc mi_run_with_cli {args} { + return [eval mi_run_cmd_full 0 $args] +} + # # Just like run-to-main but works with the MI interface # ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [3/3] RFC: fix PR mi/8444 2011-11-17 16:41 ` Tom Tromey @ 2011-11-22 14:55 ` Pedro Alves 2011-11-22 21:22 ` Tom Tromey 0 siblings, 1 reply; 13+ messages in thread From: Pedro Alves @ 2011-11-22 14:55 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches On Thursday 17 November 2011 16:41:13, Tom Tromey wrote: > >>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes: > > Pedro> TARGET_WAITKIND_LOADED targets print this elsewhere, as > Pedro> they don't use a shared library event breakpoint. See > Pedro> infrun.c:normal_stop. Can you give that the same treatment? > > What do you think of the appended? > > I don't think I have access to a TARGET_WAITKIND_LOADED target, so I > can't test this. > > I added a 'kind' argument to bpstat_print, to centralize the printing. > I wasn't sure if this is a good idea or not; I think the centralization > idea is fine, but I wasn't sure if this addition is violating some > abstraction boundary. Yeah, looks fine. This should probably be a catchpoint anyway. > --- /dev/null > +++ b/gdb/testsuite/gdb.mi/mi-solib.exp > @@ -0,0 +1,55 @@ > +load_lib mi-support.exp > +set MIFLAGS "-i=mi2" The test uses shared libs -- it should be skipped if skip_shlib_tests. > + > +gdb_exit > +if [mi_gdb_start] { > + continue > +} > + > +set libname "solib-lib" > +set srcfile_lib ${srcdir}/${subdir}/${libname}.c > +set binfile_lib ${objdir}/${subdir}/${libname}.so > +set lib_flags [list debug ldflags=-Wl,-Bsymbolic] Is -Bsymbolic necessary? > + > +set testfile "solib-main" > +set srcfile ${srcdir}/${subdir}/${testfile}.c > +set binfile ${objdir}/${subdir}/${testfile} > +set bin_flags [list debug shlib=${binfile_lib}] > + > +if [get_compiler_info ${binfile}] { > + return -1 > +} > + > +if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != "" > + || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } { > + untested "Could not compile $binfile_lib or $binfile." > + return -1 > +} > + > +mi_delete_breakpoints > +mi_gdb_reinitialize_dir $srcdir/$subdir > +mi_gdb_reinitialize_dir $srcdir/$subdir > +mi_gdb_load ${binfile} gdb_load_shlibs missing. > --- /dev/null > +++ b/gdb/testsuite/gdb.mi/solib-lib.c > +#include <stdio.h> Unnecessary header. > --- /dev/null > +++ b/gdb/testsuite/gdb.mi/solib-main.c > +*/ > +#include <stdio.h> Ditto. > > +proc mi_run_cmd {args} { > + return [eval mi_run_cmd_full 1 $args] > +} > + > +proc mi_run_with_cli {args} { > + return [eval mi_run_cmd_full 0 $args] > +} Describing comments would be nice. Otherwise looks good to me. -- Pedro Alves ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [3/3] RFC: fix PR mi/8444 2011-11-22 14:55 ` Pedro Alves @ 2011-11-22 21:22 ` Tom Tromey 2011-11-25 16:08 ` Ulrich Weigand 0 siblings, 1 reply; 13+ messages in thread From: Tom Tromey @ 2011-11-22 21:22 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches >>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes: Pedro> The test uses shared libs -- it should be skipped if skip_shlib_tests. Thanks Pedro> Is -Bsymbolic necessary? Nope, I removed it. Pedro> gdb_load_shlibs missing. Added. Pedro> Unnecessary header. Pedro> Ditto. Removed. Pedro> Describing comments would be nice. Added. I also changed two places to use ui_out_text rather than printf_filtered, as discussed in the other thread. I'm checking this version in. Tom 2011-11-17 Tom Tromey <tromey@redhat.com> PR mi/8444: * mi/mi-common.h (EXEC_ASYNC_SOLIB_EVENT, EXEC_ASYNC_FORK) (EXEC_ASYNC_VFORK, EXEC_ASYNC_SYSCALL_ENTRY) (EXEC_ASYNC_SYSCALL_RETURN, EXEC_ASYNC_EXEC): New constants. * mi/mi-common.c (async_reason_string_lookup): Add new reasons. * breakpoint.c (print_it_catch_fork, print_it_catch_vfork) (print_it_catch_syscall, print_it_catch_exec) (internal_bkpt_print_it): Use ui_out. Emit stop reason. (bpstat_print): Add 'kind' argument. Handle TARGET_WAITKIND_LOADED. * infrun.c (normal_stop): Update for bpstat_print change. Don't handle TARGET_WAITKIND_LOADED here. * breakpoint.h (bpstat_print): Update. 2011-11-16 Tom Tromey <tromey@redhat.com> * gdb.texinfo (GDB/MI Async Records): Document new *stopped reasons. 2011-11-16 Tom Tromey <tromey@redhat.com> * lib/mi-support.exp (mi_run_cmd_full): Rename from mi_run_cmd. Add "use_mi_command" argument. (mi_run_cmd, mi_run_with_cli): New procs. * gdb.mi/solib-lib.c: New file. * gdb.mi/solib-main.c: New file. * gdb.mi/mi-solib.exp: New file. From be0ab16c33db2900e643f155bb7ec3f7420e2328 Mon Sep 17 00:00:00 2001 From: Tom Tromey <tromey@redhat.com> Date: Wed, 16 Nov 2011 08:31:11 -0700 Subject: [PATCH 3/3] fix PR 8444 --- gdb/ChangeLog | 16 ++++++ gdb/breakpoint.c | 109 ++++++++++++++++++++++++++++++------- gdb/breakpoint.h | 2 +- gdb/doc/ChangeLog | 5 ++ gdb/doc/gdb.texinfo | 19 +++++++ gdb/infrun.c | 14 +----- gdb/mi/mi-common.c | 6 ++ gdb/mi/mi-common.h | 6 ++ gdb/mi/mi-interp.c | 7 ++- gdb/testsuite/ChangeLog | 9 +++ gdb/testsuite/gdb.mi/mi-solib.exp | 62 +++++++++++++++++++++ gdb/testsuite/gdb.mi/solib-lib.c | 19 +++++++ gdb/testsuite/gdb.mi/solib-main.c | 23 ++++++++ gdb/testsuite/lib/mi-support.exp | 32 +++++++++-- 14 files changed, 288 insertions(+), 41 deletions(-) create mode 100644 gdb/testsuite/gdb.mi/mi-solib.exp create mode 100644 gdb/testsuite/gdb.mi/solib-lib.c create mode 100644 gdb/testsuite/gdb.mi/solib-main.c diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8f09296..d8586ce 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3446,7 +3446,8 @@ print_bp_stop_message (bpstat bs) /* Print a message indicating what happened. This is called from normal_stop(). The input to this routine is the head of the bpstat - list - a list of the eventpoints that caused this stop. This + list - a list of the eventpoints that caused this stop. KIND is + the target_waitkind for the stopping event. This routine calls the generic print routine for printing a message about reasons for stopping. This will print (for example) the "Breakpoint n," part of the output. The return value of this @@ -3465,7 +3466,7 @@ print_bp_stop_message (bpstat bs) further info to be printed. */ enum print_stop_action -bpstat_print (bpstat bs) +bpstat_print (bpstat bs, int kind) { int val; @@ -3482,6 +3483,18 @@ bpstat_print (bpstat bs) return val; } + /* If we had hit a shared library event breakpoint, + print_bp_stop_message would print out this message. If we hit an + OS-level shared library event, do the same thing. */ + if (kind == TARGET_WAITKIND_LOADED) + { + ui_out_text (current_uiout, _("Stopped due to shared library event\n")); + if (ui_out_is_mi_like_p (current_uiout)) + ui_out_field_string (current_uiout, "reason", + async_reason_lookup (EXEC_ASYNC_SOLIB_EVENT)); + return PRINT_NOTHING; + } + /* We reached the end of the chain, or we got a null BS to start with and nothing was printed. */ return PRINT_UNKNOWN; @@ -6176,12 +6189,25 @@ breakpoint_hit_catch_fork (const struct bp_location *bl, static enum print_stop_action print_it_catch_fork (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b = bs->breakpoint_at; struct fork_catchpoint *c = (struct fork_catchpoint *) bs->breakpoint_at; annotate_catchpoint (b->number); - printf_filtered (_("\nCatchpoint %d (forked process %d), "), - b->number, ptid_get_pid (c->forked_inferior_pid)); + if (b->disposition == disp_del) + ui_out_text (uiout, "\nTemporary catchpoint "); + else + ui_out_text (uiout, "\nCatchpoint "); + if (ui_out_is_mi_like_p (uiout)) + { + ui_out_field_string (uiout, "reason", + async_reason_lookup (EXEC_ASYNC_FORK)); + ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + } + ui_out_field_int (uiout, "bkptno", b->number); + ui_out_text (uiout, " (forked process "); + ui_out_field_int (uiout, "newpid", ptid_get_pid (c->forked_inferior_pid)); + ui_out_text (uiout, "), "); return PRINT_SRC_AND_LOC; } @@ -6272,12 +6298,25 @@ breakpoint_hit_catch_vfork (const struct bp_location *bl, static enum print_stop_action print_it_catch_vfork (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b = bs->breakpoint_at; struct fork_catchpoint *c = (struct fork_catchpoint *) b; annotate_catchpoint (b->number); - printf_filtered (_("\nCatchpoint %d (vforked process %d), "), - b->number, ptid_get_pid (c->forked_inferior_pid)); + if (b->disposition == disp_del) + ui_out_text (uiout, "\nTemporary catchpoint "); + else + ui_out_text (uiout, "\nCatchpoint "); + if (ui_out_is_mi_like_p (uiout)) + { + ui_out_field_string (uiout, "reason", + async_reason_lookup (EXEC_ASYNC_VFORK)); + ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + } + ui_out_field_int (uiout, "bkptno", b->number); + ui_out_text (uiout, " (vforked process "); + ui_out_field_int (uiout, "newpid", ptid_get_pid (c->forked_inferior_pid)); + ui_out_text (uiout, "), "); return PRINT_SRC_AND_LOC; } @@ -6486,6 +6525,7 @@ breakpoint_hit_catch_syscall (const struct bp_location *bl, static enum print_stop_action print_it_catch_syscall (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b = bs->breakpoint_at; /* These are needed because we want to know in which state a syscall is. It can be in the TARGET_WAITKIND_SYSCALL_ENTRY @@ -6494,7 +6534,6 @@ print_it_catch_syscall (bpstat bs) ptid_t ptid; struct target_waitstatus last; struct syscall s; - struct cleanup *old_chain; char *syscall_id; get_last_target_status (&ptid, &last); @@ -6503,21 +6542,31 @@ print_it_catch_syscall (bpstat bs) annotate_catchpoint (b->number); - if (s.name == NULL) - syscall_id = xstrprintf ("%d", last.value.syscall_number); + if (b->disposition == disp_del) + ui_out_text (uiout, "\nTemporary catchpoint "); else - syscall_id = xstrprintf ("'%s'", s.name); - - old_chain = make_cleanup (xfree, syscall_id); + ui_out_text (uiout, "\nCatchpoint "); + if (ui_out_is_mi_like_p (uiout)) + { + ui_out_field_string (uiout, "reason", + async_reason_lookup (last.kind == TARGET_WAITKIND_SYSCALL_ENTRY + ? EXEC_ASYNC_SYSCALL_ENTRY + : EXEC_ASYNC_SYSCALL_RETURN)); + ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + } + ui_out_field_int (uiout, "bkptno", b->number); if (last.kind == TARGET_WAITKIND_SYSCALL_ENTRY) - printf_filtered (_("\nCatchpoint %d (call to syscall %s), "), - b->number, syscall_id); - else if (last.kind == TARGET_WAITKIND_SYSCALL_RETURN) - printf_filtered (_("\nCatchpoint %d (returned from syscall %s), "), - b->number, syscall_id); + ui_out_text (uiout, " (call to syscall "); + else + ui_out_text (uiout, " (returned from syscall "); - do_cleanups (old_chain); + if (s.name == NULL || ui_out_is_mi_like_p (uiout)) + ui_out_field_int (uiout, "syscall-number", last.value.syscall_number); + if (s.name != NULL) + ui_out_field_string (uiout, "syscall-name", s.name); + + ui_out_text (uiout, "), "); return PRINT_SRC_AND_LOC; } @@ -6760,12 +6809,26 @@ breakpoint_hit_catch_exec (const struct bp_location *bl, static enum print_stop_action print_it_catch_exec (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b = bs->breakpoint_at; struct exec_catchpoint *c = (struct exec_catchpoint *) b; annotate_catchpoint (b->number); - printf_filtered (_("\nCatchpoint %d (exec'd %s), "), b->number, - c->exec_pathname); + if (b->disposition == disp_del) + ui_out_text (uiout, "\nTemporary catchpoint "); + else + ui_out_text (uiout, "\nCatchpoint "); + if (ui_out_is_mi_like_p (uiout)) + { + ui_out_field_string (uiout, "reason", + async_reason_lookup (EXEC_ASYNC_EXEC)); + ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + } + ui_out_field_int (uiout, "bkptno", b->number); + ui_out_text (uiout, " (exec'd "); + ui_out_field_string (uiout, "new-exec", c->exec_pathname); + ui_out_text (uiout, "), "); + return PRINT_SRC_AND_LOC; } @@ -11133,6 +11196,7 @@ internal_bkpt_check_status (bpstat bs) static enum print_stop_action internal_bkpt_print_it (bpstat bs) { + struct ui_out *uiout = current_uiout; struct breakpoint *b; b = bs->breakpoint_at; @@ -11143,7 +11207,10 @@ internal_bkpt_print_it (bpstat bs) /* Did we stop because the user set the stop_on_solib_events variable? (If so, we report this as a generic, "Stopped due to shlib event" message.) */ - printf_filtered (_("Stopped due to shared library event\n")); + ui_out_text (uiout, _("Stopped due to shared library event\n")); + if (ui_out_is_mi_like_p (uiout)) + ui_out_field_string (uiout, "reason", + async_reason_lookup (EXEC_ASYNC_SOLIB_EVENT)); break; case bp_thread_event: diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 506ae80..8a7287d 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -880,7 +880,7 @@ extern int bpstat_should_step (void); /* Print a message indicating what happened. Returns nonzero to say that only the source line should be printed after this (zero return means print the frame as well as the source line). */ -extern enum print_stop_action bpstat_print (bpstat); +extern enum print_stop_action bpstat_print (bpstat, int); /* Put in *NUM the breakpoint number of the first breakpoint we are stopped at. *BSP upon return is a bpstat which points to the diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index f4f7f1e..c13cd62 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -26130,6 +26130,25 @@ The inferior exited. The inferior exited normally. @item signal-received A signal was received by the inferior. +@item solib-event +The inferior has stopped due to a library being loaded or unloaded. +This can only happen when @code{stop-on-solib-events} (@pxref{Files}) +is set. +@item fork +The inferior has forked. This is reported when @code{catch fork} +(@pxref{Set Catchpoints}) has been used. +@item vfork +The inferior has vforked. This is reported in when @code{catch vfork} +(@pxref{Set Catchpoints}) has been used. +@item syscall-entry +The inferior entered a system call. This is reported when @code{catch +syscall} (@pxref{Set Catchpoints}) has been used. +@item syscall-entry +The inferior returned from a system call. This is reported when +@code{catch syscall} (@pxref{Set Catchpoints}) has been used. +@item exec +The inferior called @code{exec}. This is reported when @code{catch exec} +(@pxref{Set Catchpoints}) has been used. @end table The @var{id} field identifies the thread that directly caused the stop diff --git a/gdb/infrun.c b/gdb/infrun.c index 3361926..5a0f1d2 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -5971,22 +5971,10 @@ normal_stop (void) int do_frame_printing = 1; struct thread_info *tp = inferior_thread (); - bpstat_ret = bpstat_print (tp->control.stop_bpstat); + bpstat_ret = bpstat_print (tp->control.stop_bpstat, last.kind); switch (bpstat_ret) { case PRINT_UNKNOWN: - /* If we had hit a shared library event breakpoint, - bpstat_print would print out this message. If we hit - an OS-level shared library event, do the same - thing. */ - if (last.kind == TARGET_WAITKIND_LOADED) - { - printf_filtered (_("Stopped due to shared library event\n")); - source_flag = SRC_LINE; /* something bogus */ - do_frame_printing = 0; - break; - } - /* FIXME: cagney/2002-12-01: Given that a frame ID does (or should) carry around the function and does (or should) use that when doing a frame comparison. */ diff --git a/gdb/mi/mi-common.c b/gdb/mi/mi-common.c index e7dd3c4..8fb9799 100644 --- a/gdb/mi/mi-common.c +++ b/gdb/mi/mi-common.c @@ -35,6 +35,12 @@ static const char * const async_reason_string_lookup[] = "exited", "exited-normally", "signal-received", + "solib-event", + "fork", + "vfork", + "syscall-entry", + "syscall-return", + "exec", NULL }; diff --git a/gdb/mi/mi-common.h b/gdb/mi/mi-common.h index dc5fc8e..9ecc5a1 100644 --- a/gdb/mi/mi-common.h +++ b/gdb/mi/mi-common.h @@ -37,6 +37,12 @@ enum async_reply_reason EXEC_ASYNC_EXITED, EXEC_ASYNC_EXITED_NORMALLY, EXEC_ASYNC_SIGNAL_RECEIVED, + EXEC_ASYNC_SOLIB_EVENT, + EXEC_ASYNC_FORK, + EXEC_ASYNC_VFORK, + EXEC_ASYNC_SYSCALL_ENTRY, + EXEC_ASYNC_SYSCALL_RETURN, + EXEC_ASYNC_EXEC, /* This is here only to represent the number of enums. */ EXEC_ASYNC_LAST }; diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 2aec1c7..b075e33 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -427,9 +427,14 @@ mi_on_normal_stop (struct bpstats *bs, int print_frame) the frame again. In practice, this can only happen when running a CLI command in MI. */ struct ui_out *saved_uiout = current_uiout; + struct target_waitstatus last; + ptid_t last_ptid; current_uiout = mi_uiout; - bpstat_print (bs); + + get_last_target_status (&last_ptid, &last); + bpstat_print (bs, last.kind); + print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC); current_uiout = saved_uiout; } diff --git a/gdb/testsuite/gdb.mi/mi-solib.exp b/gdb/testsuite/gdb.mi/mi-solib.exp new file mode 100644 index 0000000..4344f96 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-solib.exp @@ -0,0 +1,62 @@ +# Copyright 2011 Free Software Foundation, Inc. + +# 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 3 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, see <http://www.gnu.org/licenses/>. + +load_lib mi-support.exp +set MIFLAGS "-i=mi2" + +if {[skip_shlib_tests]} { + untested mi-solib.exp + return -1 +} + +gdb_exit +if [mi_gdb_start] { + continue +} + +set libname "solib-lib" +set srcfile_lib ${srcdir}/${subdir}/${libname}.c +set binfile_lib ${objdir}/${subdir}/${libname}.so +set lib_flags [list debug] + +set testfile "solib-main" +set srcfile ${srcdir}/${subdir}/${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +set bin_flags [list debug shlib=${binfile_lib}] + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != "" + || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } { + untested "Could not compile $binfile_lib or $binfile." + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +gdb_load_shlibs $binfile_lib + +mi_gdb_test "777-gdb-set stop-on-solib-events 1" "777\\^done" \ + "set stop-on-solib-events" + +# We use "run" rather than "-exec-run" here in order to test that CLI +# commands still cause the correct MI output to be generated. +mi_run_with_cli +mi_expect_stop solib-event .* .* .* .* .* "check for solib event" diff --git a/gdb/testsuite/gdb.mi/solib-lib.c b/gdb/testsuite/gdb.mi/solib-lib.c new file mode 100644 index 0000000..e30ce83 --- /dev/null +++ b/gdb/testsuite/gdb.mi/solib-lib.c @@ -0,0 +1,19 @@ +/* Copyright 2011 Free Software Foundation, Inc. + + 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 3 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, see <http://www.gnu.org/licenses/>. +*/ + +void solibfunction(void) +{ +} diff --git a/gdb/testsuite/gdb.mi/solib-main.c b/gdb/testsuite/gdb.mi/solib-main.c new file mode 100644 index 0000000..eff210f --- /dev/null +++ b/gdb/testsuite/gdb.mi/solib-main.c @@ -0,0 +1,23 @@ +/* Copyright 2011 Free Software Foundation, Inc. + + 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 3 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, see <http://www.gnu.org/licenses/>. +*/ + +extern void solibfunction(void); + +int main () +{ + solibfunction (); + return 0; +} diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 63097cb..dc1717b 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -788,7 +788,7 @@ proc mi_gdb_test { args } { # In patterns, the newline sequence ``\r\n'' is matched explicitly as # ``.*$'' could swallow up output that we attempt to match elsewhere. -proc mi_run_cmd {args} { +proc mi_run_cmd_full {use_mi_command args} { global suppress_flag if { $suppress_flag } { return -1 @@ -797,6 +797,14 @@ proc mi_run_cmd {args} { global thread_selected_re global library_loaded_re + if {$use_mi_command} { + set run_prefix "220-exec-" + set run_match "220" + } else { + set run_prefix "" + set run_match "" + } + if [target_info exists gdb_init_command] { send_gdb "[target_info gdb_init_command]\n"; gdb_expect 30 { @@ -814,9 +822,9 @@ proc mi_run_cmd {args} { if [target_info exists use_gdb_stub] { if [target_info exists gdb,do_reload_on_run] { - send_gdb "220-exec-continue\n"; + send_gdb "${run_prefix}continue\n"; gdb_expect 60 { - -re "220\\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\r\n$mi_gdb_prompt" {} + -re "${run_match}\\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\r\n$mi_gdb_prompt" {} default {} } return 0; @@ -835,9 +843,9 @@ proc mi_run_cmd {args} { return 0 } - send_gdb "220-exec-run $args\n" + send_gdb "${run_prefix}run $args\n" gdb_expect { - -re "220\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${library_loaded_re})*(${thread_selected_re})?${mi_gdb_prompt}" { + -re "${run_match}\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${library_loaded_re})*(${thread_selected_re})?${mi_gdb_prompt}" { } -re "\\^error,msg=\"The target does not support running in non-stop mode.\"" { unsupported "Non-stop mode not supported" @@ -853,6 +861,20 @@ proc mi_run_cmd {args} { return 0 } +# A wrapper for mi_run_cmd_full which uses -exec-run and +# -exec-continue, as appropriate. ARGS are passed verbatim to +# mi_run_cmd_full. +proc mi_run_cmd {args} { + return [eval mi_run_cmd_full 1 $args] +} + +# A wrapper for mi_run_cmd_full which uses the CLI commands 'run' and +# 'continue', as appropriate. ARGS are passed verbatim to +# mi_run_cmd_full. +proc mi_run_with_cli {args} { + return [eval mi_run_cmd_full 0 $args] +} + # # Just like run-to-main but works with the MI interface # -- 1.7.6.4 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [3/3] RFC: fix PR mi/8444 2011-11-22 21:22 ` Tom Tromey @ 2011-11-25 16:08 ` Ulrich Weigand 2011-12-02 1:18 ` [patch] testsuite: Fix mi-solib.exp without debuginfos [Re: [3/3] RFC: fix PR mi/8444] Jan Kratochvil 0 siblings, 1 reply; 13+ messages in thread From: Ulrich Weigand @ 2011-11-25 16:08 UTC (permalink / raw) To: Tom Tromey; +Cc: Pedro Alves, gdb-patches Tom Tromey wrote: > * gdb.mi/mi-solib.exp: New file. > +mi_expect_stop solib-event .* .* .* .* .* "check for solib event" This causes spurious failures for me, since that routine expects output in this form: mi_expect_stop: expecting: \*stopped,reason="solib-event",frame={addr="0x[0-9A-Fa-f]+",func=".*",args=\[.*\],file="[^ ]*.*",fullname="(/[^\n]*/|\\\\[^\\]+\\[^\n]+\\|\\[^\\][^\n]*\\|[a-zA-Z]:[^\n]*\\).*",line=".*"}.*,thread-id="[0-9]+",stopped-threads=[^ ]* but we actually get *stopped,reason="solib-event",frame={addr="0x7dfef93c",func="_dl_debug_state",args=[],from="/lib/ld.so.1"},thread-id="1",stopped-threads="all",core="4" The difference is that we only see a "from=" instead of "file="/"fullname="/"line=" as the PC is in a system library, and I don't have debug info installed for those ... Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 13+ messages in thread
* [patch] testsuite: Fix mi-solib.exp without debuginfos [Re: [3/3] RFC: fix PR mi/8444] 2011-11-25 16:08 ` Ulrich Weigand @ 2011-12-02 1:18 ` Jan Kratochvil 2011-12-02 16:17 ` Tom Tromey 2011-12-09 21:26 ` Tom Tromey 0 siblings, 2 replies; 13+ messages in thread From: Jan Kratochvil @ 2011-12-02 1:18 UTC (permalink / raw) To: Tom Tromey; +Cc: Pedro Alves, gdb-patches, Ulrich Weigand On Fri, 25 Nov 2011 17:08:01 +0100, Ulrich Weigand wrote: > The difference is that we only see a "from=" instead of > "file="/"fullname="/"line=" as the PC is in a system library, and I don't > have debug info installed for those ... What about this patch? I have checked the result of mi_expect_stop is not used anywhere so it is questionable what it should return. No regressions on {x86_64,x86_64-m32,i686}-fedora16-linux-gnu. Thanks, Jan gdb/testsuite/ 2011-12-02 Jan Kratochvil <jan.kratochvil@redhat.com> Fix gdb.mi/mi-solib.exp without system debug info installed. * lib/mi-support.exp (mi_expect_stop): Accept FILE also for `from' expect attribute, return 0 for it. Update comments. --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -981,9 +981,10 @@ proc mi_detect_async {} { # Wait for MI *stopped notification to appear. # The REASON, FUNC, ARGS, FILE and LINE are regular expressions -# to match against whatever is output in *stopped. ARGS should -# not include [] the list of argument is enclosed in, and other -# regular expressions should not include quotes. +# to match against whatever is output in *stopped. FILE may also match +# filename of a file without debug info. ARGS should not include [] the +# list of argument is enclosed in, and other regular expressions should +# not include quotes. # If EXTRA is a list of one element, it's the regular expression # for output expected right after *stopped, and before GDB prompt. # If EXTRA is a list of two elements, the first element is for @@ -991,9 +992,10 @@ proc mi_detect_async {} { # right after reason field. The regex after reason should not include # the comma separating it from the following fields. # -# When we fail to match output at all, -1 is returned. Otherwise, -# the line at which we stop is returned. This is useful when exact -# line is not possible to specify for some reason -- one can pass +# When we fail to match output at all, -1 is returned. If FILE does +# match and the target system has no debug info for FILE return 0. +# Otherwise, the line at which we stop is returned. This is useful when +# exact line is not possible to specify for some reason -- one can pass # the .* or "\[0-9\]*" regexps for line, and then check the line # programmatically. # @@ -1067,11 +1069,15 @@ proc mi_expect_stop { reason func args file line extra test } { set any "\[^\n\]*" - verbose -log "mi_expect_stop: expecting: \\*stopped,${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\"$any$file\",fullname=\"${fullname_syntax}$file\",line=\"$line\"\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n($thread_selected_re|$breakpoint_re)*$prompt_re" + verbose -log "mi_expect_stop: expecting: \\*stopped,${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$func\",args=$args,(?:file=\"$any$file\",fullname=\"${fullname_syntax}$file\",line=\"$line\"|from=\"$file\")\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n($thread_selected_re|$breakpoint_re)*$prompt_re" gdb_expect { - -re "\\*stopped,${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\"$any$file\",fullname=\"${fullname_syntax}$file\",line=\"($line)\"\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n($thread_selected_re|$breakpoint_re)*$prompt_re" { + -re "\\*stopped,${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$func\",args=$args,(?:file=\"$any$file\",fullname=\"${fullname_syntax}$file\",line=\"($line)\"|from=\"$file\")\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n($thread_selected_re|$breakpoint_re)*$prompt_re" { pass "$test" - return $expect_out(2,string) + if {[array names expect_out "2,string"] != ""} { + return $expect_out(2,string) + } + # No debug info available but $file does match. + return 0 } -re "\\*stopped,${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$any\",args=\[\\\[\{\]$any\[\\\]\}\],file=\"$any\",fullname=\"${fullname_syntax}$any\",line=\"\[0-9\]*\"\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n($thread_selected_re|$breakpoint_re)*$prompt_re" { verbose -log "got $expect_out(buffer)" ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] testsuite: Fix mi-solib.exp without debuginfos [Re: [3/3] RFC: fix PR mi/8444] 2011-12-02 1:18 ` [patch] testsuite: Fix mi-solib.exp without debuginfos [Re: [3/3] RFC: fix PR mi/8444] Jan Kratochvil @ 2011-12-02 16:17 ` Tom Tromey 2011-12-02 22:36 ` [commit] " Jan Kratochvil 2011-12-09 21:26 ` Tom Tromey 1 sibling, 1 reply; 13+ messages in thread From: Tom Tromey @ 2011-12-02 16:17 UTC (permalink / raw) To: Jan Kratochvil; +Cc: Pedro Alves, gdb-patches, Ulrich Weigand >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes: Jan> What about this patch? Thanks for doing this, and sorry I didn't get to it sooner. Jan> I have checked the result of mi_expect_stop is not used anywhere so it is Jan> questionable what it should return. I think it is fine to change it as you like. Tom ^ permalink raw reply [flat|nested] 13+ messages in thread
* [commit] [patch] testsuite: Fix mi-solib.exp without debuginfos [Re: [3/3] RFC: fix PR mi/8444] 2011-12-02 16:17 ` Tom Tromey @ 2011-12-02 22:36 ` Jan Kratochvil 0 siblings, 0 replies; 13+ messages in thread From: Jan Kratochvil @ 2011-12-02 22:36 UTC (permalink / raw) To: Tom Tromey; +Cc: Pedro Alves, gdb-patches, Ulrich Weigand On Fri, 02 Dec 2011 17:16:48 +0100, Tom Tromey wrote: > >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes: > > Jan> What about this patch? > > Thanks for doing this, and sorry I didn't get to it sooner. Thanks, checked in: http://sourceware.org/ml/gdb-cvs/2011-12/msg00013.html Regards, Jan ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] testsuite: Fix mi-solib.exp without debuginfos [Re: [3/3] RFC: fix PR mi/8444] 2011-12-02 1:18 ` [patch] testsuite: Fix mi-solib.exp without debuginfos [Re: [3/3] RFC: fix PR mi/8444] Jan Kratochvil 2011-12-02 16:17 ` Tom Tromey @ 2011-12-09 21:26 ` Tom Tromey 2011-12-09 21:54 ` Jan Kratochvil 1 sibling, 1 reply; 13+ messages in thread From: Tom Tromey @ 2011-12-09 21:26 UTC (permalink / raw) To: Jan Kratochvil; +Cc: Pedro Alves, gdb-patches, Ulrich Weigand >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes: Jan> I have checked the result of mi_expect_stop is not used anywhere so it is Jan> questionable what it should return. Unfortunately, a Tcl proc returns its last computed value if there is no explicit return. So, this caused: ERROR: tcl error sourcing ../../../archer/gdb/testsuite/gdb.ada/mi_catch_ex.exp. ERROR: missing operand at _@_ in expression "!_@_" (parsing expression "!") invoked from within "if ![mi_run_to_main] then { fail "Cannot run to main, testcase aborted" return 0 }" (file "../../../archer/gdb/testsuite/gdb.ada/mi_catch_ex.exp" line 109) invoked from within "source ../../../archer/gdb/testsuite/gdb.ada/mi_catch_ex.exp" ("uplevel" body line 1) invoked from within "uplevel #0 source ../../../archer/gdb/testsuite/gdb.ada/mi_catch_ex.exp" invoked from within "catch "uplevel #0 source $test_file_name"" Tom ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] testsuite: Fix mi-solib.exp without debuginfos [Re: [3/3] RFC: fix PR mi/8444] 2011-12-09 21:26 ` Tom Tromey @ 2011-12-09 21:54 ` Jan Kratochvil 2011-12-09 21:56 ` Tom Tromey 0 siblings, 1 reply; 13+ messages in thread From: Jan Kratochvil @ 2011-12-09 21:54 UTC (permalink / raw) To: Tom Tromey; +Cc: Pedro Alves, gdb-patches, Ulrich Weigand On Fri, 09 Dec 2011 22:00:01 +0100, Tom Tromey wrote: > Unfortunately, a Tcl proc returns its last computed value if there is no > explicit return. So, this caused: With the patch of mine it either returns the same value as before or it returns value 0. And I do not have the problem reproducible, where to reproduce it? Thanks, Jan ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] testsuite: Fix mi-solib.exp without debuginfos [Re: [3/3] RFC: fix PR mi/8444] 2011-12-09 21:54 ` Jan Kratochvil @ 2011-12-09 21:56 ` Tom Tromey 0 siblings, 0 replies; 13+ messages in thread From: Tom Tromey @ 2011-12-09 21:56 UTC (permalink / raw) To: Jan Kratochvil; +Cc: Pedro Alves, gdb-patches, Ulrich Weigand >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes: Jan> On Fri, 09 Dec 2011 22:00:01 +0100, Tom Tromey wrote: >> Unfortunately, a Tcl proc returns its last computed value if there is no >> explicit return. So, this caused: Jan> With the patch of mine it either returns the same value as before or it Jan> returns value 0. And I do not have the problem reproducible, where to Jan> reproduce it? I will look at it on Monday. Sorry for not investigating more before sending the email. Tom ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [3/3] RFC: fix PR mi/8444 2011-11-16 20:28 [3/3] RFC: fix PR mi/8444 Tom Tromey 2011-11-16 21:31 ` Pedro Alves @ 2011-11-17 4:03 ` Eli Zaretskii 1 sibling, 0 replies; 13+ messages in thread From: Eli Zaretskii @ 2011-11-17 4:03 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches > From: Tom Tromey <tromey@redhat.com> > Date: Wed, 16 Nov 2011 13:04:29 -0700 > > This patch actually fixes the PR. > > It at least needs a doc review. The doc part is okay, although I wonder if we can do with less pxref's to the same node in several successive lines. Thanks. ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2011-12-09 21:55 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-11-16 20:28 [3/3] RFC: fix PR mi/8444 Tom Tromey 2011-11-16 21:31 ` Pedro Alves 2011-11-17 16:41 ` Tom Tromey 2011-11-22 14:55 ` Pedro Alves 2011-11-22 21:22 ` Tom Tromey 2011-11-25 16:08 ` Ulrich Weigand 2011-12-02 1:18 ` [patch] testsuite: Fix mi-solib.exp without debuginfos [Re: [3/3] RFC: fix PR mi/8444] Jan Kratochvil 2011-12-02 16:17 ` Tom Tromey 2011-12-02 22:36 ` [commit] " Jan Kratochvil 2011-12-09 21:26 ` Tom Tromey 2011-12-09 21:54 ` Jan Kratochvil 2011-12-09 21:56 ` Tom Tromey 2011-11-17 4:03 ` [3/3] RFC: fix PR mi/8444 Eli Zaretskii
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox