aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2008-11-24 16:53:44 +0000
committerDaniel Jacobowitz <drow@false.org>2008-11-24 16:53:44 +0000
commitd962ef8246f50ac5726c6b82881074ccab47f822 (patch)
tree465f139b88a26b74e6b52247654dbc6936b14b6e
parent88828b324a37d01871fc622152d7351a4d97e4d2 (diff)
downloadgdb-d962ef8246f50ac5726c6b82881074ccab47f822.zip
gdb-d962ef8246f50ac5726c6b82881074ccab47f822.tar.gz
gdb-d962ef8246f50ac5726c6b82881074ccab47f822.tar.bz2
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.
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/remote.c46
2 files changed, 50 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 14dce03..c8d4039 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2008-11-24 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.
+
2008-11-24 Jerome Guitton <guitton@adacore.com>
* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Use
diff --git a/gdb/remote.c b/gdb/remote.c
index 4580c77..06ab783 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -234,6 +234,8 @@ static void remote_async_get_pending_events_handler (gdb_client_data);
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 *uiout, void *opaque)
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 *uiout, void *opaque)
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, struct target_ops *target, int extended
}
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 gdbarch *gdbarch, int bytes,
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;