Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org, dgraham@nortel.com
Subject: Re: RFC: Do not try g-packet-guess algorithm on exited targets
Date: Mon, 24 Nov 2008 19:06:00 -0000	[thread overview]
Message-ID: <20081124144821.GA27882@caradoc.them.org> (raw)
In-Reply-To: <200811232211.59013.pedro@codesourcery.com>

On Sun, Nov 23, 2008 at 10:11:58PM +0000, Pedro Alves wrote:
> If we change the logic around to:
> 
>  /* Assume that the target is not running, unless we learn
>      otherwise.  */
>   if (extended_p)
>     target_mark_exited (target);
> 
> Then would this in remote_read_description work instead of a
> new flag?

Like the attached?  It works in my testing and is much nicer.

I did have a question while looking at this.  We call
wait_for_inferior via start_remote when connecting to an all-stop
target, but not when connecting to a non-stop target.  Does this
work because non-stop is always async, and we push the stop replies to
be noticed by the main event loop?

-- 
Daniel Jacobowitz
CodeSourcery

2008-11-23  Daniel Jacobowitz  <dan@codesourcery.com>

	PR gdb/2474
	* remote.c (remote_read_description_p): New function.
	(remote_start_remote): Try to fetch the target description
	before adding shared libraries.  Try again later if the
	target is running but stopped.
	(remote_open_1): Mark extended targets as exited by default.
	(remote_read_description): Check target_has_execution.

Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.329
diff -u -p -r1.329 remote.c
--- remote.c	19 Nov 2008 14:45:09 -0000	1.329
+++ remote.c	24 Nov 2008 14:40:47 -0000
@@ -234,6 +234,8 @@ static void remote_async_get_pending_eve
 
 static void remote_terminal_ours (void);
 
+static int remote_read_description_p (struct target_ops *target);
+
 /* The non-stop remote protocol provisions for one pending stop reply.
    This is where we keep it until it is acknowledged.  */
 
@@ -2549,15 +2551,15 @@ remote_start_remote (struct ui_out *uiou
       getpkt (&rs->buf, &rs->buf_size, 0);
     }
 
+  /* Next, if the target can specify a description, read it.  We do
+     this before anything involving memory or registers.  */
+  target_find_description ();
+
   /* On OSs where the list of libraries is global to all
      processes, we fetch them early.  */
   if (gdbarch_has_global_solist (target_gdbarch))
     solib_add (NULL, args->from_tty, args->target, auto_solib_add);
 
-  /* Next, if the target can specify a description, read it.  We do
-     this before anything involving memory or registers.  */
-  target_find_description ();
-
   if (non_stop)
     {
       if (!rs->non_stop_aware)
@@ -2643,6 +2645,17 @@ remote_start_remote (struct ui_out *uiou
 
       get_offsets ();		/* Get text, data & bss offsets.  */
 
+      /* If we could not find a description using qXfer, and we know
+	 how to do it some other way, try again.  This is not
+	 supported for non-stop; it could be, but it is tricky if
+	 there are no stopped threads when we connect.  */
+      if (remote_read_description_p (args->target)
+	  && gdbarch_target_desc (target_gdbarch) == NULL)
+	{
+	  target_clear_description ();
+	  target_find_description ();
+	}
+
       /* Use the previously fetched status.  */
       gdb_assert (wait_status != NULL);
       strcpy (rs->buf, wait_status);
@@ -3163,8 +3176,9 @@ remote_open_1 (char *name, int from_tty,
     }
   push_target (target);		/* Switch to using remote target now.  */
 
-  /* Assume that the target is running, unless we learn otherwise.  */
-  target_mark_running (target);
+  /* Assume that the target is not running, until we learn otherwise.  */
+  if (extended_p)
+    target_mark_exited (target);
 
   /* Register extra event sources in the event loop.  */
   remote_async_inferior_event_token
@@ -7852,12 +7866,32 @@ register_remote_g_packet_guess (struct g
   VEC_safe_push (remote_g_packet_guess_s, data->guesses, &new_guess);
 }
 
+/* Return 1 if remote_read_description would do anything on this target
+   and architecture, 0 otherwise.  */
+
+static int
+remote_read_description_p (struct target_ops *target)
+{
+  struct remote_g_packet_data *data
+    = gdbarch_data (target_gdbarch, remote_g_packet_data_handle);
+
+  if (!VEC_empty (remote_g_packet_guess_s, data->guesses))
+    return 1;
+
+  return 0;
+}
+
 static const struct target_desc *
 remote_read_description (struct target_ops *target)
 {
   struct remote_g_packet_data *data
     = gdbarch_data (target_gdbarch, remote_g_packet_data_handle);
 
+  /* Do not try this during initial connection, when we do not know
+     whether there is a running but stopped thread.  */
+  if (!target_has_execution || ptid_equal (inferior_ptid, null_ptid))
+    return NULL;
+
   if (!VEC_empty (remote_g_packet_guess_s, data->guesses))
     {
       struct remote_g_packet_guess *guess;


  parent reply	other threads:[~2008-11-24 14:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-24 13:53 Daniel Jacobowitz
2008-11-24 14:49 ` Pedro Alves
2008-11-24 14:49   ` Daniel Jacobowitz
2008-11-24 19:06   ` Daniel Jacobowitz [this message]
2008-11-24 19:17     ` Pedro Alves
2008-11-24 20:11       ` Daniel Jacobowitz
2008-12-01 22:10 ` Michael Snyder
2008-12-01 22:18   ` Daniel Jacobowitz

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=20081124144821.GA27882@caradoc.them.org \
    --to=drow@false.org \
    --cc=dgraham@nortel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /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