This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Upload TSVs in extend-remote mode
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Wed, 19 Jun 2013 18:02:54 +0800
- Subject: [PATCH] Upload TSVs in extend-remote mode
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