From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30818 invoked by alias); 3 Jul 2013 09:14:54 -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 30570 invoked by uid 89); 3 Jul 2013 09:14:52 -0000 X-Spam-SWARE-Status: No, score=-6.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 03 Jul 2013 09:14:50 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 03 Jul 2013 02:14:44 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 03 Jul 2013 02:14:37 -0700 Received: from ulslx001.iul.intel.com (ulslx001.iul.intel.com [172.28.207.63]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id r639Eabx009796; Wed, 3 Jul 2013 10:14:36 +0100 Received: from ulslx001.iul.intel.com (localhost [127.0.0.1]) by ulslx001.iul.intel.com with ESMTP id r639Eaku029241; Wed, 3 Jul 2013 11:14:36 +0200 Received: (from mmetzger@localhost) by ulslx001.iul.intel.com with id r639Eap3029237; Wed, 3 Jul 2013 11:14:36 +0200 From: Markus Metzger To: jan.kratochvil@redhat.com Cc: gdb-patches@sourceware.org Subject: [patch v4 05/24] record-btrace: start counting at one Date: Wed, 03 Jul 2013 09:14:00 -0000 Message-Id: <1372842874-28951-6-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1372842874-28951-1-git-send-email-markus.t.metzger@intel.com> References: <1372842874-28951-1-git-send-email-markus.t.metzger@intel.com> X-SW-Source: 2013-07/txt/msg00119.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. 2013-07-03 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 53549db..006deaa 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -212,7 +212,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 d9a2ba7..df69a41 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 bd25404..df2728b 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.7.1