From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2200 invoked by alias); 19 Jun 2013 10:03:14 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 2182 invoked by uid 89); 19 Jun 2013 10:03:13 -0000 X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL autolearn=ham version=3.3.1 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 19 Jun 2013 10:03:13 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1UpFEN-0006D4-QS from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Wed, 19 Jun 2013 03:03:11 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 19 Jun 2013 03:03:11 -0700 Received: from qiyao.dyndns.org.dyndns.org (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.2.247.3; Wed, 19 Jun 2013 03:03:11 -0700 From: Yao Qi To: Subject: [PATCH] Upload TSVs in extend-remote mode Date: Wed, 19 Jun 2013 10:40:00 -0000 Message-ID: <1371636174-9822-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-06/txt/msg00480.txt.bz2 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 * remote.c (extended_remote_create_inferior_1): Upload TSVs from the remote stub. gdb/testsuite: 2013-06-19 Yao Qi * 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