This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/2] Don't query stub if the pid is faked


Even with the previous patch applied, we still see an error from GDBserver,
in the reply to 'qAttached'.

Sending packet: $QNonStop:0#8c...Packet received: OK
Sending packet: $?#3f...Packet received: T0505:00000000;04:00f0ffbf;08:b0c2e44c;thread:p35eb.35eb;core:0;
Sending packet: $Hc-1#09...Packet received: E01
Sending packet: $qC#b4...Packet received:
Sending packet: $qAttached:a410#bf...Packet received: E01
Packet qAttached (query-attached) is supported
warning: Remote failure reply: E01

If the stub doesn't support "qC", the 'inferior_ptid' in GDB is
'magic_null_ptid'.  Then GDB will query the stub of pid of
'magic_null_ptid', so the stub doesn't know it and reports error.

This patch fixes this problem by skipping query to the stub is the
pid is faked.

P.S. even with this patch, function inferior_appeared is still called
in remote_add_inferior with the faked PID.  So if we start GDBserver
with --disable-qC and start GDB in MI mode, we can see that the wrong
"pid" is sent to MI front-end, as shown below.

target remote :1234
&"target remote :1234\n"
~"Remote debugging using :1234\n"
=thread-group-started,id="i1",pid="42000" <----
=thread-created,id="1",group-id="i1"
=library-loaded,id="/lib/ld-linux.so.2",target-name="/lib/ld-linux.so.2",host-name="/lib/ld-linux.so.2",symbols-loaded="0",thread-group="i1"
~"Reading symbols from /lib/ld-linux.so.2..."
~"(no debugging symbols found)...done.\n"
~"Loaded symbols for /lib/ld-linux.so.2\n"
~"[Switching to Thread 1445]\n"
~"0x4ce4c2b0 in _start () from /lib/ld-linux.so.2\n"
*stopped,frame={addr="0x4ce4c2b0",func="_start",args=[],from="/lib/ld-linux.so.2"},thread-id="1",stopped-threads="all",core="2"

I tried to fix it, however looks GDB is unable to get the real pid
until the stop reply arrives and my change reorders the MI
notification "=thread-group-started" and "=thread-created".  So I give
up on it.

gdb:

2013-01-22  Yao Qi  <yao@codesourcery.com>

	* remote.c (remote_add_inferior): Don't call remote_query_attached
	if 'fake_pid_p' is true.
---
 gdb/remote.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 3271ca0..07410a3 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1463,8 +1463,9 @@ remote_add_inferior (int fake_pid_p, int pid, int attached)
 
   /* Check whether this process we're learning about is to be
      considered attached, or if is to be considered to have been
-     spawned by the stub.  */
-  if (attached == -1)
+     spawned by the stub.  Don't bother the stub if the PID is
+     faked.  */
+  if (attached == -1 && !fake_pid_p)
     attached = remote_query_attached (pid);
 
   if (gdbarch_has_global_solist (target_gdbarch ()))
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]