Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Upload TSVs in extend-remote mode
@ 2013-06-19 10:40 Yao Qi
  2013-06-20 18:36 ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Yao Qi @ 2013-06-19 10:40 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-06-25 14:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-19 10:40 [PATCH] Upload TSVs in extend-remote mode Yao Qi
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox