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] Upload TSVs in extend-remote mode
Date: Wed, 19 Jun 2013 10:40:00 -0000	[thread overview]
Message-ID: <1371636174-9822-1-git-send-email-yao@codesourcery.com> (raw)

Hi,
In extended-remote, when GDB connects the target, but target is not
running, the TSVs are not uploaded (because remote_start_remote
returns earlier when the reply to packet '?' is either 'X' or 'W').

However, GDBserver has some builtin or predefined TSVs to upload, such
as $trace_timestamp.  This bug causes $trace_timestamp is never uploaded.

The fix to this problem is to upload TSV in
extended_remote_create_inferior_1.

Another fix could be that move the code uploading TSVs earlier in
remote_start_remote before sending packet '?'.  I don't choose this
approach because I'd like GDB to upload TSVs when inferior starts run,
instead of when GDB connects to the stub.

The patch to gdb.trace/tsv.exp can expose this bug by checking 'info
tvariables' after connect to the remote.  If only test part of this
patch is applied, we can get a fail,

  $ make check RUNTESTFLAGS="--target_board=native-extended-gdbserver tsv.exp"
  FAIL: gdb.trace/tsv.exp: check uploaded tsv (pattern 1)

With the whole patch applied, the fail goes away.

I notice that TSV "$trace_timestamp" is not a documented TSV, so stubs
other than GDBserver may not have it.  If it is a concern, I am OK to
drop the tsv.exp part from this patch.

Regression tested on x86_64-linux with board file
native-extended-gdbserver and native-gdbserver.  Is it OK?

gdb:

2013-06-19  Yao Qi  <yao@codesourcery.com>

	* remote.c (extended_remote_create_inferior_1): Upload TSVs from
	the remote stub.

gdb/testsuite:

2013-06-19  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/tsv.exp: Test TSV is uploaded.
---
 gdb/remote.c                    |    9 +++++++++
 gdb/testsuite/gdb.trace/tsv.exp |    6 ++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index be9186b..9f38d8d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8076,6 +8076,15 @@ extended_remote_create_inferior_1 (char *exec_file, char *args,
 
   /* Get updated offsets, if the stub uses qOffsets.  */
   get_offsets ();
+
+  /* Upload the TSVs from the remote stub.  */
+  if (remote_get_trace_status (current_trace_status ()) != -1)
+    {
+      struct uploaded_tsv *uploaded_tsvs = NULL;
+
+      remote_upload_trace_state_variables (&uploaded_tsvs);
+      merge_uploaded_trace_state_variables (&uploaded_tsvs);
+    }
 }
 
 static void
diff --git a/gdb/testsuite/gdb.trace/tsv.exp b/gdb/testsuite/gdb.trace/tsv.exp
index 4177d13..302bcef 100644
--- a/gdb/testsuite/gdb.trace/tsv.exp
+++ b/gdb/testsuite/gdb.trace/tsv.exp
@@ -118,6 +118,12 @@ if { $trcpt1 <= 0 } then {
     return
 }
 
+# Test predefined TSVs are uploaded.
+gdb_test_sequence "info tvariables" "check uploaded tsv" {
+    "\[\r\n\]+Name\[\t \]+Initial\[\t \]+Current"
+    "\[\r\n\]+\\\$trace_timestamp 0"
+}
+
 gdb_test "tvariable \$tvar5 = 15" \
   "Trace state variable \\\$tvar5 created, with initial value 15." \
   "Create a trace state variable tvar5"
-- 
1.7.7.6


             reply	other threads:[~2013-06-19 10:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-19 10:40 Yao Qi [this message]
2013-06-20 18:36 ` Pedro Alves
2013-06-22 11:23   ` Yao Qi
2013-06-24 15:50     ` Pedro Alves
2013-06-25 13:57       ` Yao Qi
2013-06-25 14:21         ` 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=1371636174-9822-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