Upload tsv earlier in remote_start_remote
authorYao Qi <yao@codesourcery.com>
Tue, 25 Jun 2013 13:01:28 +0000 (13:01 +0000)
committerYao Qi <yao@codesourcery.com>
Tue, 25 Jun 2013 13:01:28 +0000 (13:01 +0000)
In extended-remote, when GDB connects the target, but target is not
running, the TSVs are not uploaded.  When GDB attaches to a process,
the TSVs are not uploaded either.  However, GDBserver has some
builtin or predefined TSV to upload, such as $trace_timestamp.  This
bug causes $trace_timestamp is never uploaded.

gdb/

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

        * remote.c (remote_start_remote): Move code to upload tsv
        earlier.

gdb/testsuite/

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

* boards/native-extended-gdbserver.exp: Set board_info
'gdb,predefined_tsv'.
* boards/native-gdbserver.exp: Likewise.
* boards/native-stdio-gdbserver.exp: Likewise.
* gdb.server/ext-attach.exp: Load trace-support.exp.  Check
uploaded TSVs if target supports tracing.
* gdb.trace/tsv.exp: Check uploaded TSVs if target supports
tracing and target has predefined tsv.

gdb/doc/

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

* gdbint.texinfo (Testsuite): Document 'gdb,predefined_tsv'.

gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/gdbint.texinfo
gdb/remote.c
gdb/testsuite/ChangeLog
gdb/testsuite/boards/native-extended-gdbserver.exp
gdb/testsuite/boards/native-gdbserver.exp
gdb/testsuite/boards/native-stdio-gdbserver.exp
gdb/testsuite/gdb.server/ext-attach.exp
gdb/testsuite/gdb.trace/tsv.exp

index e5905c58882985782c774becf28a1f6b770991a2..7687f678232f654eb14d59918a4168c4bb4b9f70 100644 (file)
@@ -1,3 +1,8 @@
+2013-06-25  Yao Qi  <yao@codesourcery.com>
+
+       * remote.c (remote_start_remote): Move code to upload tsv
+       earlier.
+
 2013-06-25  Yao Qi  <yao@codesourcery.com>
            Hui Zhu  <hui@codesourcery.com>
            Pedro Alves  <palves@redhat.com>
index 96d1a26455b700af7570e1c62892df2200d4d415..41ccea2ee82d249bd20b1a07ac2134444ae7cd6b 100644 (file)
@@ -1,3 +1,7 @@
+2013-06-25  Yao Qi  <yao@codesourcery.com>
+
+       * gdbint.texinfo (Testsuite): Document 'gdb,predefined_tsv'.
+
 2013-06-24  Tom Tromey  <tromey@redhat.com>
 
        * Makefile.in (POD2MAN1, POD2MAN5): Use version.subst.
index 7f1f49ffc59e34208420e3eb8f8c36415d04c68f..e7caabe1add8866e2bdb302ff6e95d6ea94153b5 100644 (file)
@@ -7983,6 +7983,9 @@ The board does not support type @code{long long}.
 @c NEED DOCUMENT.
 @item use_gdb_stub
 The tests are running with gdb stub.
+@item gdb,predefined_tsv
+The predefined trace state variables the board has.
+
 @end table
 
 @node Hints
index 080d04859c9b9c9320d318487390545e8876398b..7928f5723c82ab71fa08983de423f902996303aa 100644 (file)
@@ -3452,6 +3452,17 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
        error (_("Remote refused setting all-stop mode with: %s"), rs->buf);
     }
 
+  /* Upload TSVs regardless of whether the target is running or not.  The
+     remote stub, such as GDBserver, may have some predefined or builtin
+     TSVs, even if the target is not running.  */
+  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);
+    }
+
   /* Check whether the target is running now.  */
   putpkt ("?");
   getpkt (&rs->buf, &rs->buf_size, 0);
@@ -3591,18 +3602,10 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
   if (remote_get_trace_status (current_trace_status ()) != -1)
     {
       struct uploaded_tp *uploaded_tps = NULL;
-      struct uploaded_tsv *uploaded_tsvs = NULL;
 
       if (current_trace_status ()->running)
        printf_filtered (_("Trace is already running on the target.\n"));
 
-      /* Get trace state variables first, they may be checked when
-        parsing uploaded commands.  */
-
-      remote_upload_trace_state_variables (&uploaded_tsvs);
-
-      merge_uploaded_trace_state_variables (&uploaded_tsvs);
-
       remote_upload_tracepoints (&uploaded_tps);
 
       merge_uploaded_tracepoints (&uploaded_tps);
index 04fadb2fe238a4ddec58c51ab5cca9322ce31d6f..6eb3ac6d7a236aa4687581cfbc2996eebd7c0949 100644 (file)
@@ -1,3 +1,14 @@
+2013-06-25  Yao Qi  <yao@codesourcery.com>
+
+       * boards/native-extended-gdbserver.exp: Set board_info
+       'gdb,predefined_tsv'.
+       * boards/native-gdbserver.exp: Likewise.
+       * boards/native-stdio-gdbserver.exp: Likewise.
+       * gdb.server/ext-attach.exp: Load trace-support.exp.  Check
+       uploaded TSVs if target supports tracing.
+       * gdb.trace/tsv.exp: Check uploaded TSVs if target supports
+       tracing and target has predefined tsv.
+
 2013-06-25  Yao Qi  <yao@codesourcery.com>
            Hui Zhu  <hui@codesourcery.com>
            Pedro Alves  <palves@redhat.com>
index bf363c74198af3735e303b40c63abf39759cdeaf..e9b29984c642feec6769e74869f2880a37a38dc1 100644 (file)
@@ -148,3 +148,6 @@ proc ${board}_file { dest op args } {
     }
     return [eval [list standard_file $dest $op] $args]
 }
+
+# The predefined TSVs in GDBserver.
+set_board_info gdb,predefined_tsv "\\\$trace_timestamp"
index 8034a48f54e30826c02f9620ca464bc7cc174d33..f32a37ecd9a48ab01c4e2fd9fc3b413336915347 100644 (file)
@@ -90,3 +90,6 @@ proc ${board}_file { dest op args } {
     }
     return [eval [list standard_file $dest $op] $args]
 }
+
+# The predefined TSVs in GDBserver.
+set_board_info gdb,predefined_tsv "\\\$trace_timestamp"
index 7e74970806714dc58cc6fdee62ba7e5ce3f8209f..d4983a63279fcbfd64427c6a153dc2f5889c534f 100644 (file)
@@ -152,3 +152,6 @@ proc ${board}_file { dest op args } {
     }
     return [eval [list standard_file $dest $op] $args]
 }
+
+# The predefined TSVs in GDBserver.
+set_board_info gdb,predefined_tsv "\\\$trace_timestamp"
index 1a2b539ef8c17b8df8bc01d5adc436f084d5f31e..61f93c132fe9a6f8ff402a02d997708efa39eb61 100644 (file)
@@ -18,6 +18,7 @@
 # Test attaching to already-running programs using extended-remote.
 
 load_lib gdbserver-support.exp
+load_lib trace-support.exp
 
 standard_testfile
 
@@ -56,6 +57,15 @@ if { [istarget "*-*-cygwin*"] } {
 gdb_test "attach $testpid" \
     "Attaching to program: .*, process $testpid.*(in|at).*" \
     "attach to remote program 1"
+
+if { [gdb_target_supports_trace] } then {
+    # 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 "backtrace" ".*main.*" "backtrace 1"
 
 gdb_test "detach" "Detaching from program.*process.*"
index 4177d137ded308d087b9669ba39ce0be5bf0899b..cd0b36b832d094b398ccfd89d38000c26e0e164d 100644 (file)
@@ -188,3 +188,25 @@ gdb_test_multiple "target ctf ${tracefile}.ctf" "" {
        check_tsv "ctf"
     }
 }
+
+# Restart.
+clean_restart ${binfile}
+
+if ![runto_main] then {
+    fail "Can't run to main"
+    return
+}
+
+# If there are predefined TSVs, test these predefined TSVs are correctly
+# uploaded.
+if [target_info exists gdb,predefined_tsv] {
+    set tsv [target_info gdb,predefined_tsv]
+
+    # Test predefined TSVs are uploaded.
+    gdb_test "info tvariables" ".*${tsv}.*" "predefined tsvs are uploaded"
+} else {
+    # Otherwise (the predefined TSVs are not defined in the board file),
+    # test there is no TSVs in GDB.
+    gdb_test "info tvariables" "No trace state variables\." \
+       "no predefined tsvs"
+}