Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 1/2] Fix error when GDB connects to GDBserver with qC disabled
Date: Wed, 23 Jan 2013 08:36:00 -0000	[thread overview]
Message-ID: <1358930116-29038-1-git-send-email-yao@codesourcery.com> (raw)

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  <yao@codesourcery.com>

	* 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


             reply	other threads:[~2013-01-23  8:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-23  8:36 Yao Qi [this message]
2013-01-23  8:36 ` [PATCH 2/2] Don't query stub if the pid is faked Yao Qi
2013-01-24 17:23   ` Pedro Alves
2013-01-24 17:05 ` [PATCH 1/2] Fix error when GDB connects to GDBserver with qC disabled Pedro Alves
2013-01-25 10:44   ` Yao Qi
2013-01-25 17:30     ` Pedro Alves
2013-01-25 17:41       ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358930116-29038-1-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox