aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/remote-utils.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-08-24 19:58:31 +0100
committerPedro Alves <palves@redhat.com>2015-08-24 19:58:31 +0100
commit3d40fbb53b4478d94b6fa5abad0796cec5d5db49 (patch)
treeb1f26e12ccd56508e42196293e671abf05b0f7a0 /gdb/gdbserver/remote-utils.c
parent73b8c1fda9f3759874a9a1a7e7402276da057153 (diff)
downloadbinutils-3d40fbb53b4478d94b6fa5abad0796cec5d5db49.zip
binutils-3d40fbb53b4478d94b6fa5abad0796cec5d5db49.tar.gz
binutils-3d40fbb53b4478d94b6fa5abad0796cec5d5db49.tar.bz2
gdbserver crashes when multiprocess extensions aren't supported
Ref: https://sourceware.org/ml/gdb-patches/2015-08/msg00675.html If multiprocess extensions are off (because specific gdbserver port doesn't support them), then when gdbserver doesn't have a thread selected yet, and GDB sends Hg packet to select one, gdbserver crashes. That's because extracting the desired thread id out of the packet that GDB sent depends on the current thread to fill in the missing process id ... Fix this by getting the process id from the first (and only) process in the processes list instead. The GNU/Linux port doesn't trip on this because it always runs with multiprocess extensions enabled. To make it easier to catch such regressions going forward, this commit also adds a new smoke test that spawns gdbserver, connects to it and runs to main with the multiprocess extensions force-disabled. gdb/gdbserver/ChangeLog: 2015-08-24 Pedro Alves <palves@redhat.com> * inferiors.c (get_first_process): New function. * inferiors.h (get_first_process): New declaration. * remote-utils.c (read_ptid): Default to the first process in the list, instead of to the current thread's process. gdb/testsuite/ChangeLog: 2015-08-24 Pedro Alves <palves@redhat.com> * gdb.server/connect-without-multi-process.c: New file. * gdb.server/connect-without-multi-process.exp: New file.
Diffstat (limited to 'gdb/gdbserver/remote-utils.c')
-rw-r--r--gdb/gdbserver/remote-utils.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 586ced8..c6c516c 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -573,9 +573,10 @@ read_ptid (char *buf, char **obuf)
/* No multi-process. Just a tid. */
tid = hex_or_minus_one (p, &pp);
- /* Since the stub is not sending a process id, then default to
- what's in the current inferior. */
- pid = ptid_get_pid (current_ptid);
+ /* Since GDB is not sending a process id (multi-process extensions
+ are off), then there's only one process. Default to the first in
+ the list. */
+ pid = pid_of (get_first_process ());
if (obuf)
*obuf = pp;