diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/inf-child.c | 18 | ||||
-rw-r--r-- | gdb/inf-child.h | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/foll-exec-mode.exp | 14 |
4 files changed, 39 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ad6f308..48a0e37 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2021-05-13 Simon Marchi <simon.marchi@efficios.com> + * inf-child.h (inf_child_target) <follow_exec>: New. + * inf-child.c (inf_child_target::follow_exec): New. + +2021-05-13 Simon Marchi <simon.marchi@efficios.com> + * target.h (struct target_ops) <follow_exec>: Add ptid_t parameter. (target_follow_exec): Likewise. diff --git a/gdb/inf-child.c b/gdb/inf-child.c index 0e68a40..f690aa7 100644 --- a/gdb/inf-child.c +++ b/gdb/inf-child.c @@ -409,6 +409,24 @@ inf_child_target::can_use_agent () return agent_loaded_p (); } +void +inf_child_target::follow_exec (inferior *follow_inf, ptid_t ptid, + const char *execd_pathname) +{ + inferior *orig_inf = current_inferior (); + + process_stratum_target::follow_exec (follow_inf, ptid, execd_pathname); + + if (orig_inf != follow_inf) + { + /* If the target was implicitly push in the original inferior, unpush + it. */ + scoped_restore_current_thread restore_thread; + switch_to_inferior_no_thread (orig_inf); + maybe_unpush_target (); + } +} + /* See inf-child.h. */ void diff --git a/gdb/inf-child.h b/gdb/inf-child.h index d697a39..aa33c53 100644 --- a/gdb/inf-child.h +++ b/gdb/inf-child.h @@ -57,6 +57,9 @@ public: void post_startup_inferior (ptid_t) override; + void follow_exec (inferior *follow_inf, ptid_t ptid, + const char *execd_pathname) override; + void mourn_inferior () override; bool can_run () override; diff --git a/gdb/testsuite/gdb.base/foll-exec-mode.exp b/gdb/testsuite/gdb.base/foll-exec-mode.exp index 7d7b660..9087c8b 100644 --- a/gdb/testsuite/gdb.base/foll-exec-mode.exp +++ b/gdb/testsuite/gdb.base/foll-exec-mode.exp @@ -113,6 +113,8 @@ proc do_follow_exec_mode_tests { mode cmd infswitch } { return } + set target_is_native [gdb_is_target_native] + # Set the follow-exec mode. # gdb_test_no_output "set follow-exec-mode $mode" @@ -147,8 +149,18 @@ proc do_follow_exec_mode_tests { mode cmd infswitch } { # if {$mode == "same"} { set expected_re "\\* 1.*process.*" + } elseif { $mode == "new" } { + # If using the native target, we want to specifically check that the + # process target, which was automatically pushed when running, was + # automatically unpushed from inferior 1 on exec. Use a + # different regexp that verifies the Connection field is empty. + if { $target_is_native } { + set expected_re " 1.*<null> +[string_to_regexp $binfile].*\r\n\\* 2.*process.*$testfile2 .*" + } else { + set expected_re " 1.*null.*$testfile.*\r\n\\* 2.*process.*$testfile2 .*" + } } else { - set expected_re " 1.*null.*$testfile.*\r\n\\* 2.*process.*$testfile2 .*" + error "Invalid mode: $mode" } # Check that the inferior list is correct: |