diff options
author | Pedro Alves <pedro@palves.net> | 2024-02-07 18:48:16 +0000 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2024-02-09 11:58:40 +0000 |
commit | 38065394e9646db0aff89b58d1d09f94bb1f626e (patch) | |
tree | 97d62159d064ba91fa51f39757db9c3cd7c69934 /gdbserver | |
parent | 41e115853eef32304e3e6fcd7feb4ec116090ee0 (diff) | |
download | fsf-binutils-gdb-38065394e9646db0aff89b58d1d09f94bb1f626e.zip fsf-binutils-gdb-38065394e9646db0aff89b58d1d09f94bb1f626e.tar.gz fsf-binutils-gdb-38065394e9646db0aff89b58d1d09f94bb1f626e.tar.bz2 |
Fix crash in aarch64-linux gdbserver
Since commit 393a6b5947d0 ("Thread options & clone events (Linux
GDBserver)"), aarch64-linux gdbserver crashes when the inferior
vforks. This happens in aarch64_get_debug_reg_state:
struct process_info *proc = find_process_pid (pid);
return &proc->priv->arch_private->debug_reg_state;
Here, find_process_pid returns nullptr -- the new inferior hasn't yet
been created in linux_process_target::handle_extended_wait.
This patch fixes the problem by having
linux_process_target::handle_extended_wait create the child process
earlier, before the child LWP is created. This is what the function
did before it was reorganized by the commit referred above.
Change-Id: Ib8b3a2e6048c3ad2b91a92ea4430da507db03c50
Co-Authored-By: Tom Tromey <tromey@adacore.com>
Diffstat (limited to 'gdbserver')
-rw-r--r-- | gdbserver/linux-low.cc | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 444eebc..9d5a624 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -555,6 +555,16 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp, ? ptid_t (new_pid, new_pid) : ptid_t (ptid_of (event_thr).pid (), new_pid)); + process_info *child_proc = nullptr; + + if (event != PTRACE_EVENT_CLONE) + { + /* Add the new process to the tables before we add the LWP. + We need to do this even if the new process will be + detached. See breakpoint cloning code further below. */ + child_proc = add_linux_process (new_pid, 0); + } + lwp_info *child_lwp = add_lwp (child_ptid); gdb_assert (child_lwp != NULL); child_lwp->stopped = 1; @@ -588,12 +598,11 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp, if (event != PTRACE_EVENT_CLONE) { - /* Add the new process to the tables and clone the breakpoint - lists of the parent. We need to do this even if the new process - will be detached, since we will need the process object and the - breakpoints to remove any breakpoints from memory when we - detach, and the client side will access registers. */ - process_info *child_proc = add_linux_process (new_pid, 0); + /* Clone the breakpoint lists of the parent. We need to do + this even if the new process will be detached, since we + will need the process object and the breakpoints to + remove any breakpoints from memory when we detach, and + the client side will access registers. */ gdb_assert (child_proc != NULL); process_info *parent_proc = get_thread_process (event_thr); |