From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13025 invoked by alias); 23 Jan 2013 08:36:39 -0000 Received: (qmail 12938 invoked by uid 22791); 23 Jan 2013 08:36:38 -0000 X-SWARE-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_EG 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:31 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Txvos-0003YZ-Bh from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Wed, 23 Jan 2013 00:36:30 -0800 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 23 Jan 2013 00:36:29 -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:29 -0800 From: Yao Qi To: Subject: [PATCH 1/2] Fix error when GDB connects to GDBserver with qC disabled Date: Wed, 23 Jan 2013 08:36:00 -0000 Message-ID: <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/msg00541.txt.bz2 GDB gets an internal error when it connects to GDBserver started with '--disable-packet=qC'. Sending packet: $QNonStop:0#8c...Packet received: OK Sending packet: $?#3f...Packet received: T0505:00000000;04:00f0ffbf;08:b0c2e44c;thread:p4255.4255;core:1; 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 Sending packet: $qOffsets#4b...Packet received: ../../../git/gdb/target.c:3248: internal-error: Can't determine the current address space of thread Thread 16981 When start remote, the call chain is as follows, remote_start_remote add_current_inferior_and_thread <--[1] ... start_remote wait_for_inferior remote_wait_as process_stop_reply get_thread_arch_regcache <--[2] remote_notice_new_inferior <--[3] GDB sends packet "qC" in [1] and adds the thread/inferior if the remote stubs understands "qC". In [2], GDB looks for the inferior to build a regcache, and notices a new inferior in [3]. As we can see, GDB assumes that the inferior can be found in [2]. Once the remote stub doesn't support "qC", GDB can't look for the inferior in [2], and emits an internal error. This patch fix this internal error by exchanging the order of [2] and [3]. gdb: 2013-01-22 Yao Qi * remote.c (process_stop_reply): Call remote_notice_new_inferior earlier. --- gdb/remote.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index 7ea9597..3271ca0 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5690,11 +5690,18 @@ process_stop_reply (struct stop_reply *stop_reply, /* Expedited registers. */ if (stop_reply->regcache) { - struct regcache *regcache - = get_thread_arch_regcache (ptid, target_gdbarch ()); + struct regcache *regcache; cached_reg_t *reg; int ix; + /* Add the inferior earlier, because the following + 'get_thread_arch_regcache' calls + 'target_thread_address_space', which requires the + inferior should be found in the inferior list. */ + remote_notice_new_inferior (ptid, 0); + + regcache = get_thread_arch_regcache (ptid, + target_gdbarch ()); for (ix = 0; VEC_iterate(cached_reg_t, stop_reply->regcache, ix, reg); ix++) @@ -5705,7 +5712,6 @@ process_stop_reply (struct stop_reply *stop_reply, remote_stopped_by_watchpoint_p = stop_reply->stopped_by_watchpoint_p; remote_watch_data_address = stop_reply->watch_data_address; - remote_notice_new_inferior (ptid, 0); demand_private_info (ptid)->core = stop_reply->core; } -- 1.7.7.6