diff options
author | Alan Hayward <alan.hayward@arm.com> | 2019-02-07 14:36:34 +0000 |
---|---|---|
committer | Alan Hayward <alan.hayward@arm.com> | 2019-02-07 14:37:45 +0000 |
commit | df0da8a2b80315485330c03c18b704b8d7b3e9c2 (patch) | |
tree | 52e46df8286bc7bb660d43987950022d407d9442 /gdb/gdbserver | |
parent | 2012bf013b2ce507b181c0d9049ad946b2a59d8a (diff) | |
download | gdb-df0da8a2b80315485330c03c18b704b8d7b3e9c2.zip gdb-df0da8a2b80315485330c03c18b704b8d7b3e9c2.tar.gz gdb-df0da8a2b80315485330c03c18b704b8d7b3e9c2.tar.bz2 |
gdbserver: When attaching, add process before lwps
The recent BP/WP changes for AArch64 swapping the order in add_lwp()
so that the process was added before the lwp. This was due to the lwp
creation requiring the process data.
This also needs changing in linux_attach().
Also add additional checks to make sure cannot attach to the same
process twice. Add test case for this - do this by splitting
attach.exp into distinct pass and error case sections.
Fixes gdb.server/ext-attach.exp on Aarch64.
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_attach): Add process before lwp.
* server.c (attach_inferior): Check if already attached.
gdb/testsuite/ChangeLog:
* gdb.base/attach.exp: Add double attach test.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/gdbserver/linux-low.c | 7 | ||||
-rw-r--r-- | gdb/gdbserver/server.c | 3 |
3 files changed, 12 insertions, 3 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 17593cb..e9fe5ab 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,8 @@ +2019-02-07 Alan Hayward <alan.hayward@arm.com> + + * linux-low.c (linux_attach): Add process before lwp. + * server.c (attach_inferior): Check if already attached. + 2019-02-07 Tom Tromey <tom@tromey.com> * x86-tdesc.h: Rename include guard. diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 44016d2..8c5a51f 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -1188,18 +1188,19 @@ linux_attach (unsigned long pid) ptid_t ptid = ptid_t (pid, pid, 0); int err; + proc = linux_add_process (pid, 1); + /* Attach to PID. We will check for other threads soon. */ err = linux_attach_lwp (ptid); if (err != 0) { - std::string reason = linux_ptrace_attach_fail_reason_string (ptid, err); + remove_process (proc); + std::string reason = linux_ptrace_attach_fail_reason_string (ptid, err); error ("Cannot attach to process %ld: %s", pid, reason.c_str ()); } - proc = linux_add_process (pid, 1); - /* Don't ignore the initial SIGSTOP if we just attached to this process. It will be collected by wait shortly. */ initial_thread = find_thread_ptid (ptid_t (pid, pid, 0)); diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index f9bfdd7..e960c10 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -295,6 +295,9 @@ attach_inferior (int pid) /* myattach should return -1 if attaching is unsupported, 0 if it succeeded, and call error() otherwise. */ + if (find_process_pid (pid) != nullptr) + error ("Already attached to process %d\n", pid); + if (myattach (pid) != 0) return -1; |