This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/2] GDB: Workaround D;PID handling bug in older GDBservers (PR gdb/23377)
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 10 Jul 2018 20:06:23 +0100
- Subject: [PATCH 2/2] GDB: Workaround D;PID handling bug in older GDBservers (PR gdb/23377)
- References: <20180710190623.13540-1-palves@redhat.com>
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:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
PR gdb/23377
* remote.c (remote_target::remote_detach_pid): Call
set_current_process.
---
gdb/remote.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/gdb/remote.c b/gdb/remote.c
index 297c198ed6..a81d67e5ed 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5661,6 +5661,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
--
2.14.4