This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb/gdb-8.2-branch] GDB: Work around D; PID handling bug in older GDBservers (PR gdb/23377)
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 11 Jul 2018 22:54:05 -0000
- Subject: [binutils-gdb/gdb-8.2-branch] GDB: Work around D; PID handling bug in older GDBservers (PR gdb/23377)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=49b000dc5686e016f05b717f18d2c8f865eb3617
commit 49b000dc5686e016f05b717f18d2c8f865eb3617
Author: Pedro Alves <palves@redhat.com>
Date: Wed Jul 11 23:40:51 2018 +0100
GDB: Work around D;PID handling bug in older GDBservers (PR gdb/23377)
This commit adds a GDB workaround for the GDBserver bug exposed by
commit f2ffa92bbce9 ("gdb: Eliminate the 'stop_pc' global"), so that
newer GDBs can continue working with older GDBservers.
gdb/ChangeLog:
2018-07-11 Pedro Alves <palves@redhat.com>
PR gdb/23377
* remote.c (remote_target::remote_detach_pid): Call
set_current_process.
Diff:
---
gdb/ChangeLog | 6 ++++++
gdb/remote.c | 8 ++++++++
2 files changed, 14 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f36edde..7b77e87 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2018-07-11 Pedro Alves <palves@redhat.com>
+
+ PR gdb/23377
+ * remote.c (remote_target::remote_detach_pid): Call
+ set_current_process.
+
2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com>
PR c++/23373
diff --git a/gdb/remote.c b/gdb/remote.c
index d5accc6..9a5286d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5628,6 +5628,14 @@ remote_target::remote_detach_pid (int pid)
{
struct remote_state *rs = get_remote_state ();
+ /* This should not be necessary, but the handling for D;PID in
+ GDBserver versions prior to 8.2 incorrectly assumes that the
+ selected process points to the same process we're detaching,
+ leading to misbehavior (and possibly GDBserver crashing) when it
+ does not. Since it's easy and cheap, work around it by forcing
+ GDBserver to select GDB's current process. */
+ set_general_process ();
+
if (remote_multi_process_p (rs))
xsnprintf (rs->buf, get_remote_packet_size (), "D;%x", pid);
else