From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13150 invoked by alias); 23 Jan 2013 08:36:40 -0000 Received: (qmail 13036 invoked by uid 22791); 23 Jan 2013 08:36:39 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Jan 2013 08:36:32 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1Txvot-0003Yd-UP from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Wed, 23 Jan 2013 00:36:31 -0800 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 23 Jan 2013 00:36:31 -0800 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.1.289.1; Wed, 23 Jan 2013 00:36:30 -0800 From: Yao Qi To: Subject: [PATCH 2/2] Don't query stub if the pid is faked Date: Wed, 23 Jan 2013 08:36:00 -0000 Message-ID: <1358930116-29038-2-git-send-email-yao@codesourcery.com> In-Reply-To: <1358930116-29038-1-git-send-email-yao@codesourcery.com> References: <1358930116-29038-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00542.txt.bz2 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 * 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