From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28583 invoked by alias); 29 Nov 2013 14:38:44 -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 28546 invoked by uid 89); 29 Nov 2013 14:38:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_50,RDNS_NONE,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mga14.intel.com Received: from Unknown (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 29 Nov 2013 14:38:42 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by azsmga102.ch.intel.com with ESMTP; 29 Nov 2013 06:38:23 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 29 Nov 2013 06:38:22 -0800 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id rATEcKkC012336; Fri, 29 Nov 2013 14:38:21 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id rATEcKAh012793; Fri, 29 Nov 2013 15:38:20 +0100 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id rATEcKCw012789; Fri, 29 Nov 2013 15:38:20 +0100 From: Markus Metzger To: jan.kratochvil@redhat.com Cc: gdb-patches@sourceware.org Subject: [patch v7 08/24] record-btrace: start counting at one Date: Fri, 29 Nov 2013 14:38:00 -0000 Message-Id: <1385735899-12481-9-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1385735899-12481-1-git-send-email-markus.t.metzger@intel.com> References: <1385735899-12481-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00913.txt.bz2 The record instruction-history and record-function-call-history commands start counting instructions at zero. This is somewhat unintuitive when we start navigating in the recorded instruction history. Start at one, instead. Approved-by: Jan Kratochvil 2013-11-29 Markus Metzger * btrace.c (ftrace_new_function): Start counting at one. testsuite/ * gdb.btrace/instruction_history.exp: Update. * gdb.btrace/function_call_history.exp: Update. --- gdb/btrace.c | 8 +- gdb/record-btrace.c | 4 +- gdb/testsuite/gdb.btrace/function_call_history.exp | 198 ++++++++++----------- gdb/testsuite/gdb.btrace/instruction_history.exp | 60 +++---- 4 files changed, 138 insertions(+), 132 deletions(-) diff --git a/gdb/btrace.c b/gdb/btrace.c index 975b60c..d391ad5 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -208,7 +208,13 @@ ftrace_new_function (struct btrace_function *prev, bfun->lbegin = INT_MAX; bfun->lend = INT_MIN; - if (prev != NULL) + if (prev == NULL) + { + /* Start counting at one. */ + bfun->number = 1; + bfun->insn_offset = 1; + } + else { gdb_assert (prev->flow.next == NULL); prev->flow.next = bfun; diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 0888c6b..466aef2 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -227,11 +227,11 @@ record_btrace_info (void) btrace_call_end (&call, btinfo); btrace_call_prev (&call, 1); - calls = btrace_call_number (&call) + 1; + calls = btrace_call_number (&call); btrace_insn_end (&insn, btinfo); btrace_insn_prev (&insn, 1); - insns = btrace_insn_number (&insn) + 1; + insns = btrace_insn_number (&insn); } printf_unfiltered (_("Recorded %u instructions in %u functions for thread " diff --git a/gdb/testsuite/gdb.btrace/function_call_history.exp b/gdb/testsuite/gdb.btrace/function_call_history.exp index 7658637..d694d5c 100644 --- a/gdb/testsuite/gdb.btrace/function_call_history.exp +++ b/gdb/testsuite/gdb.btrace/function_call_history.exp @@ -40,81 +40,81 @@ gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*" # show function call history with unlimited size, we expect to see all 21 entries gdb_test_no_output "set record function-call-history-size 0" gdb_test "record function-call-history" " -0\tmain\r -1\tinc\r -2\tmain\r -3\tinc\r -4\tmain\r -5\tinc\r -6\tmain\r -7\tinc\r -8\tmain\r -9\tinc\r -10\tmain\r -11\tinc\r -12\tmain\r -13\tinc\r -14\tmain\r -15\tinc\r -16\tmain\r -17\tinc\r -18\tmain\r -19\tinc\r -20\tmain\r" "record function-call-history - with size unlimited" +1\tmain\r +2\tinc\r +3\tmain\r +4\tinc\r +5\tmain\r +6\tinc\r +7\tmain\r +8\tinc\r +9\tmain\r +10\tinc\r +11\tmain\r +12\tinc\r +13\tmain\r +14\tinc\r +15\tmain\r +16\tinc\r +17\tmain\r +18\tinc\r +19\tmain\r +20\tinc\r +21\tmain\r" "record function-call-history - with size unlimited" # show function call history with size of 21, we expect to see all 21 entries gdb_test_no_output "set record function-call-history-size 21" # show function call history -gdb_test "record function-call-history 0" " -0\tmain\r -1\tinc\r -2\tmain\r -3\tinc\r -4\tmain\r -5\tinc\r -6\tmain\r -7\tinc\r -8\tmain\r -9\tinc\r -10\tmain\r -11\tinc\r -12\tmain\r -13\tinc\r -14\tmain\r -15\tinc\r -16\tmain\r -17\tinc\r -18\tmain\r -19\tinc\r -20\tmain\r" "record function-call-history - show all 21 entries" +gdb_test "record function-call-history 1" " +1\tmain\r +2\tinc\r +3\tmain\r +4\tinc\r +5\tmain\r +6\tinc\r +7\tmain\r +8\tinc\r +9\tmain\r +10\tinc\r +11\tmain\r +12\tinc\r +13\tmain\r +14\tinc\r +15\tmain\r +16\tinc\r +17\tmain\r +18\tinc\r +19\tmain\r +20\tinc\r +21\tmain\r" "record function-call-history - show all 21 entries" # show first 15 entries gdb_test_no_output "set record function-call-history-size 15" -gdb_test "record function-call-history 0" " -0\tmain\r -1\tinc\r -2\tmain\r -3\tinc\r -4\tmain\r -5\tinc\r -6\tmain\r -7\tinc\r -8\tmain\r -9\tinc\r -10\tmain\r -11\tinc\r -12\tmain\r -13\tinc\r -14\tmain\r" "record function-call-history - show first 15 entries" +gdb_test "record function-call-history 1" " +1\tmain\r +2\tinc\r +3\tmain\r +4\tinc\r +5\tmain\r +6\tinc\r +7\tmain\r +8\tinc\r +9\tmain\r +10\tinc\r +11\tmain\r +12\tinc\r +13\tmain\r +14\tinc\r +15\tmain\r" "record function-call-history - show first 15 entries" # show last 6 entries gdb_test "record function-call-history +" " -15\tinc\r -16\tmain\r -17\tinc\r -18\tmain\r -19\tinc\r -20\tmain\r" "record function-call-history - show last 6 entries" +16\tinc\r +17\tmain\r +18\tinc\r +19\tmain\r +20\tinc\r +21\tmain\r" "record function-call-history - show last 6 entries" # moving further should not work gdb_test "record function-call-history +" "At the end of the branch trace record\\." "record function-call-history - at the end (1)" @@ -124,30 +124,30 @@ gdb_test "record function-call-history +" "At the end of the branch trace record # moving back showing the latest 15 function calls gdb_test "record function-call-history -" " -6\tmain\r -7\tinc\r -8\tmain\r -9\tinc\r -10\tmain\r -11\tinc\r -12\tmain\r -13\tinc\r -14\tmain\r -15\tinc\r -16\tmain\r -17\tinc\r -18\tmain\r -19\tinc\r -20\tmain\r" "record function-call-history - show last 15 entries" +7\tmain\r +8\tinc\r +9\tmain\r +10\tinc\r +11\tmain\r +12\tinc\r +13\tmain\r +14\tinc\r +15\tmain\r +16\tinc\r +17\tmain\r +18\tinc\r +19\tmain\r +20\tinc\r +21\tmain\r" "record function-call-history - show last 15 entries" # moving further back shows the 6 first function calls gdb_test "record function-call-history -" " -0\tmain\r -1\tinc\r -2\tmain\r -3\tinc\r -4\tmain\r -5\tinc\r" "record function-call-history - show first 6 entries" +1\tmain\r +2\tinc\r +3\tmain\r +4\tinc\r +5\tmain\r +6\tinc\r" "record function-call-history - show first 6 entries" # moving further back shouldn't work gdb_test "record function-call-history -" "At the start of the branch trace record\\." "record function-call-history - at the start (1)" @@ -186,18 +186,18 @@ gdb_test "record function-call-history /l +" " gdb_test "record function-call-history /l +" "At the end of the branch trace record\\." "record function-call-history /l - at the end (1)" gdb_test "record function-call-history /l" "At the end of the branch trace record\\." "record function-call-history /l - at the end (2)" -set expected_range "3\tinc\r -4\tmain\r -5\tinc\r -6\tmain\r -7\tinc\r -8\tmain\r -9\tinc\r" +set expected_range "4\tinc\r +5\tmain\r +6\tinc\r +7\tmain\r +8\tinc\r +9\tmain\r +10\tinc\r" # show functions in instruction range -gdb_test "record function-call-history 3,10" $expected_range "absolute instruction range" -gdb_test "record function-call-history 3,+7" $expected_range "relative positive instruction range" -gdb_test "record function-call-history 10,-7" $expected_range "relative negative instruction range" +gdb_test "record function-call-history 4,11" $expected_range "absolute instruction range" +gdb_test "record function-call-history 4,+7" $expected_range "relative positive instruction range" +gdb_test "record function-call-history 11,-7" $expected_range "relative negative instruction range" # set bp after fib recursion and continue set bp_location [gdb_get_line_number "bp.2" $testfile.c] @@ -208,8 +208,7 @@ gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*" # so we limit the output to only show the latest 11 function calls gdb_test_no_output "set record function-call-history-size 11" gdb_test "record function-call-history" " -20\tmain\r -21\tfib\r +21\tmain\r 22\tfib\r 23\tfib\r 24\tfib\r @@ -218,4 +217,5 @@ gdb_test "record function-call-history" " 27\tfib\r 28\tfib\r 29\tfib\r -30\tmain" "show recursive function call history" +30\tfib\r +31\tmain" "show recursive function call history" diff --git a/gdb/testsuite/gdb.btrace/instruction_history.exp b/gdb/testsuite/gdb.btrace/instruction_history.exp index 377dca1..6878d27 100644 --- a/gdb/testsuite/gdb.btrace/instruction_history.exp +++ b/gdb/testsuite/gdb.btrace/instruction_history.exp @@ -65,33 +65,33 @@ if { $traced != 6 } { } # test that we see the expected instructions -gdb_test "record instruction-history 1,6" " -1\t 0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ \r -2\t 0x\[0-9a-f\]+ :\tdec %eax\r -3\t 0x\[0-9a-f\]+ :\tjmp 0x\[0-9a-f\]+ \r -4\t 0x\[0-9a-f\]+ :\tcmp \\\$0x0,%eax\r -5\t 0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ \r" - -gdb_test "record instruction-history /f 1,+5" " -1\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ \r -2\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax\r -3\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ \r -4\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp \\\$0x0,%eax\r -5\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ \r" - -gdb_test "record instruction-history /p 6,-5" " -1\t0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ \r -2\t0x\[0-9a-f\]+ :\tdec %eax\r -3\t0x\[0-9a-f\]+ :\tjmp 0x\[0-9a-f\]+ \r -4\t0x\[0-9a-f\]+ :\tcmp \\\$0x0,%eax\r -5\t0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ \r" - -gdb_test "record instruction-history /pf 1,6" " -1\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ \r -2\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax\r -3\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ \r -4\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp \\\$0x0,%eax\r -5\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ \r" +gdb_test "record instruction-history 2,7" " +2\t 0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ \r +3\t 0x\[0-9a-f\]+ :\tdec %eax\r +4\t 0x\[0-9a-f\]+ :\tjmp 0x\[0-9a-f\]+ \r +5\t 0x\[0-9a-f\]+ :\tcmp \\\$0x0,%eax\r +6\t 0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ \r" + +gdb_test "record instruction-history /f 2,+5" " +2\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ \r +3\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax\r +4\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ \r +5\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp \\\$0x0,%eax\r +6\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ \r" + +gdb_test "record instruction-history /p 7,-5" " +2\t0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ \r +3\t0x\[0-9a-f\]+ :\tdec %eax\r +4\t0x\[0-9a-f\]+ :\tjmp 0x\[0-9a-f\]+ \r +5\t0x\[0-9a-f\]+ :\tcmp \\\$0x0,%eax\r +6\t0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ \r" + +gdb_test "record instruction-history /pf 2,7" " +2\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ \r +3\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax\r +4\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ \r +5\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp \\\$0x0,%eax\r +6\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ \r" # the following tests are checking the iterators # to avoid lots of regexps, we just check the number of lines that @@ -117,7 +117,7 @@ proc test_lines_length { command message } { # all $traced instructions gdb_test_no_output "set record instruction-history-size 0" set message "record instruction-history - unlimited" -set lines [test_lines_length "record instruction-history 0" $message] +set lines [test_lines_length "record instruction-history 1" $message] if { $traced != $lines } { fail $message } else { @@ -126,7 +126,7 @@ if { $traced != $lines } { gdb_test_no_output "set record instruction-history-size $traced" set message "record instruction-history - traced" -set lines [test_lines_length "record instruction-history 0" $message] +set lines [test_lines_length "record instruction-history 1" $message] if { $traced != $lines } { fail $message } else { @@ -137,7 +137,7 @@ if { $traced != $lines } { set history_size 3 gdb_test_no_output "set record instruction-history-size $history_size" set message "browse history forward start" -set lines [test_lines_length "record instruction-history 0" $message] +set lines [test_lines_length "record instruction-history 1" $message] if { $lines != $history_size } { fail $message } else { -- 1.8.3.1