diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2022-01-15 23:25:59 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2022-02-10 20:10:12 -0500 |
commit | a288518611dbda5cfae8894d532cf1040cb1b6c2 (patch) | |
tree | 8a08bcc229f42cc2f6e64f2045d5225dcaabb06b /gdb/linux-nat.c | |
parent | a9dce16586c147c024b49604aa0603d772372f31 (diff) | |
download | gdb-a288518611dbda5cfae8894d532cf1040cb1b6c2.zip gdb-a288518611dbda5cfae8894d532cf1040cb1b6c2.tar.gz gdb-a288518611dbda5cfae8894d532cf1040cb1b6c2.tar.bz2 |
gdb/linux: remove ptrace support check for exec, fork, vfork, vforkdone, clone, sysgood
I think it's safe to remove checking support for these ptrace features,
they have all been added in what is now ancient times (around the
beginning of Linux 2.6). This allows removing a bit of complexity in
linux-nat.c and nat/linux-ptrace.c.
It also allows saving one extra fork every time we start debugging on
Linux: linux_check_ptrace_features forks a child process to test if some
ptrace features are supported. That child process forks a grand-child,
to test whether ptrace reports an event for the fork by the child. This
is no longer needed, if we assume the kernel supports reporting forks.
PTRACE_O_TRACEVFORKDONE was introduced in Linux in this change, in 2003:
https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=45c1a159b85b3b30afd26a77b4be312226bba416
PTRACE_O_TRACESYSGOOD was supported at least as of this change, in 2002:
https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=acc7088569c8eef04eeed0eff51d23bb5bcff964
PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK, PTRACE_O_TRACEEXEC and
PTRACE_O_TRACECLONE were introduced in this change, in 2002:
https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=a0691b116f6a4473f0fa264210ab9b95771a2b46
Change-Id: Iffb906549a89cc6b619427f976ec044706ab1e8d
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r-- | gdb/linux-nat.c | 77 |
1 files changed, 8 insertions, 69 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 0cc6923..936250c 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -535,70 +535,12 @@ linux_nat_target::follow_fork (inferior *child_inf, ptid_t child_ptid, if (has_vforked) { - struct lwp_info *parent_lp; + lwp_info *parent_lp = find_lwp_pid (parent_ptid); + linux_nat_debug_printf ("waiting for VFORK_DONE on %d", parent_pid); + parent_lp->stopped = 1; - parent_lp = find_lwp_pid (parent_ptid); - gdb_assert (linux_supports_tracefork () >= 0); - - if (linux_supports_tracevforkdone ()) - { - linux_nat_debug_printf ("waiting for VFORK_DONE on %d", - parent_pid); - parent_lp->stopped = 1; - - /* We'll handle the VFORK_DONE event like any other - event, in target_wait. */ - } - else - { - /* We can't insert breakpoints until the child has - finished with the shared memory region. We need to - wait until that happens. Ideal would be to just - call: - - ptrace (PTRACE_SYSCALL, parent_pid, 0, 0); - - waitpid (parent_pid, &status, __WALL); - However, most architectures can't handle a syscall - being traced on the way out if it wasn't traced on - the way in. - - We might also think to loop, continuing the child - until it exits or gets a SIGTRAP. One problem is - that the child might call ptrace with PTRACE_TRACEME. - - There's no simple and reliable way to figure out when - the vforked child will be done with its copy of the - shared memory. We could step it out of the syscall, - two instructions, let it go, and then single-step the - parent once. When we have hardware single-step, this - would work; with software single-step it could still - be made to work but we'd have to be able to insert - single-step breakpoints in the child, and we'd have - to insert -just- the single-step breakpoint in the - parent. Very awkward. - - In the end, the best we can do is to make sure it - runs for a little while. Hopefully it will be out of - range of any breakpoints we reinsert. Usually this - is only the single-step breakpoint at vfork's return - point. */ - - linux_nat_debug_printf ("no VFORK_DONE support, sleeping a bit"); - - usleep (10000); - - /* Pretend we've seen a PTRACE_EVENT_VFORK_DONE event, - and leave it pending. The next linux_nat_resume call - will notice a pending event, and bypasses actually - resuming the inferior. */ - parent_lp->status = 0; - parent_lp->waitstatus.set_vfork_done (); - parent_lp->stopped = 1; - - /* If we're in async mode, need to tell the event loop - there's something here to process. */ - if (target_is_async_p ()) - async_file_mark (); - } + /* We'll handle the VFORK_DONE event like any other + event, in target_wait. */ } } else @@ -615,7 +557,7 @@ linux_nat_target::follow_fork (inferior *child_inf, ptid_t child_ptid, int linux_nat_target::insert_fork_catchpoint (int pid) { - return !linux_supports_tracefork (); + return 0; } int @@ -627,7 +569,7 @@ linux_nat_target::remove_fork_catchpoint (int pid) int linux_nat_target::insert_vfork_catchpoint (int pid) { - return !linux_supports_tracefork (); + return 0; } int @@ -639,7 +581,7 @@ linux_nat_target::remove_vfork_catchpoint (int pid) int linux_nat_target::insert_exec_catchpoint (int pid) { - return !linux_supports_tracefork (); + return 0; } int @@ -652,9 +594,6 @@ int linux_nat_target::set_syscall_catchpoint (int pid, bool needed, int any_count, gdb::array_view<const int> syscall_counts) { - if (!linux_supports_tracesysgood ()) - return 1; - /* On GNU/Linux, we ignore the arguments. It means that we only enable the syscall catchpoints, but do not disable them. |