From 7394aafa8f9126521c12e3a822666f75906059a3 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 1 Feb 2018 17:11:43 +0000 Subject: [PATCH] inferior-events --- gdb/infrun.c | 4 +-- gdb/testsuite/gdb.base/fork-detach-info.exp | 51 +++++++++++++++++------------ 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 4ac5bde3035..85feedf6d4e 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -597,12 +597,12 @@ holding the child stopped. Try \"set detach-on-fork\" or \ if (print_inferior_events) { /* Ensure that we have a process ptid. */ - ptid_t process_ptid = pid_to_ptid (ptid_get_pid (child_ptid)); + ptid_t process_ptid = pid_to_ptid (ptid_get_pid (parent_ptid)); target_terminal::ours_for_output (); fprintf_filtered (gdb_stdlog, _("[Detaching after fork from " - "child %s.]\n"), + "parent %s.]\n"), target_pid_to_str (process_ptid)); } diff --git a/gdb/testsuite/gdb.base/fork-detach-info.exp b/gdb/testsuite/gdb.base/fork-detach-info.exp index aa9a85c0d5d..bc4aa5edcdd 100644 --- a/gdb/testsuite/gdb.base/fork-detach-info.exp +++ b/gdb/testsuite/gdb.base/fork-detach-info.exp @@ -29,38 +29,47 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } { # This is the expected output for each of the test combinations # below. The order here is important: # -# follow-fork: child; detach-on-fork: on; inferior-events: on -# follow-fork: child; detach-on-fork: on; inferior-events: off -# follow-fork: child; detach-on-fork: off; inferior-events: on -# follow-fork: child; detach-on-fork: off; inferior-events: off -# follow-fork: parent; detach-on-fork: on; inferior-events: on -# follow-fork: parent; detach-on-fork: on; inferior-events: off -# follow-fork: parent; detach-on-fork: off; inferior-events: on -# follow-fork: parent; detach-on-fork: off; inferior-events: off +# inferior-events: on; follow-fork: child; detach-on-fork: on +# inferior-events: on; follow-fork: child; detach-on-fork: off +# inferior-events: on; follow-fork: parent; detach-on-fork: on +# inferior-events: on; follow-fork: parent; detach-on-fork: off +# inferior-events: off; follow-fork: child; detach-on-fork: on +# inferior-events: off; follow-fork: child; detach-on-fork: off +# inferior-events: off; follow-fork: parent; detach-on-fork: on +# inferior-events: off; follow-fork: parent; detach-on-fork: off + +set exited_normally_re "\\\[Inferior $decimal \\(process $decimal\\) exited normally\\\]" +set attach_child_re "\\\[Attaching after process $decimal fork to child process $decimal\\.\\\]\r\n" +set detach_child_re "\\\[Detaching after fork from child process $decimal\\.\\\]\r\n" +set detach_parent_re "\\\[Detaching after fork from parent process $decimal\\.\\\]\r\n" +set new_inf_re "\\\[New inferior $decimal\\\]\r\n" +set inf_detached_re "\\\[Inferior $decimal detached\\\]\r\n" + set expected_output [list \ - "\\\[Attaching after process $decimal fork to child process $decimal\\.\\\]\r\n\\\[New inferior $decimal\\\]\r\n\\\[Detaching after fork from child process $decimal\\.\\\]\r\n\\\[Inferior $decimal detached\\\]\r\n\\\[Inferior $decimal \\(process $decimal\\) exited normally\\\]" \ - "\\\[Inferior $decimal \\(process $decimal\\) exited normally\\\]" \ - "\\\[Attaching after process $decimal fork to child process $decimal\\.\\\]\r\n\\\[New inferior $decimal\\\]\r\n\\\[Inferior $decimal \\(process $decimal\\) exited normally\\\]" \ - "\\\[Inferior $decimal \\(process $decimal\\) exited normally\\\]" \ - "\\\[Detaching after fork from child process $decimal\\.\\\]\r\n\\\[Inferior $decimal \\(process $decimal\\) exited normally\\\]" \ - "\\\[Inferior $decimal \\(process $decimal\\) exited normally\\\]" \ - "\\\[New inferior $decimal\\\]\r\n\\\[Inferior $decimal \\(process $decimal\\) exited normally\\\]" \ - "\\\[Inferior $decimal \\(process $decimal\\) exited normally\\\]"] + "${attach_child_re}${new_inf_re}${detach_parent_re}${inf_detached_re}" \ + "${attach_child_re}${new_inf_re}" \ + "${detach_child_re}" \ + "${new_inf_re}" \ + "" \ + "" \ + "" \ + "" \ + ] set i 0 -foreach_with_prefix follow_fork_mode { "child" "parent" } { - foreach_with_prefix detach_on_fork { "on" "off" } { - foreach_with_prefix print_inferior_events { "on" "off" } { +foreach_with_prefix print_inferior_events { "on" "off" } { + foreach_with_prefix follow_fork_mode { "child" "parent" } { + foreach_with_prefix detach_on_fork { "on" "off" } { clean_restart $binfile + gdb_test_no_output "set print inferior-events $print_inferior_events" gdb_test_no_output "set follow-fork-mode $follow_fork_mode" gdb_test_no_output "set detach-on-fork $detach_on_fork" - gdb_test_no_output "set print inferior-events $print_inferior_events" set output [lindex $expected_output $i] # Always add the "Starting program..." string so that we # match exactly the lines we want. - set output "Starting program: $binfile\\s*\r\n$output" + set output "Starting program: $binfile\\s*\r\n$output${exited_normally_re}" set i [expr $i + 1] gdb_test "run" $output } -- 2.14.3