From: Pedro Alves Date: Wed, 11 Jul 2018 22:31:44 +0000 (+0100) Subject: GDB: Work around D;PID handling bug in older GDBservers (PR gdb/23377) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4c7333b308f5178813745f40e641231efb1cb763;p=binutils-gdb.git 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 PR gdb/23377 * remote.c (remote_target::remote_detach_pid): Call set_current_process. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c82c37ed387..9b920c4bce6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2018-07-11 Pedro Alves + + PR gdb/23377 + * remote.c (remote_target::remote_detach_pid): Call + set_current_process. + 2018-07-11 Pedro Alves * h8300-tdep.c (h8300_gdbarch_init): Remove diff --git a/gdb/remote.c b/gdb/remote.c index 297c198ed69..a81d67e5ede 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