From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28614 invoked by alias); 3 Jul 2013 09:14:43 -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 28552 invoked by uid 89); 3 Jul 2013 09:14:42 -0000 X-Spam-SWARE-Status: No, score=-6.7 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 mga03.intel.com (HELO mga03.intel.com) (143.182.124.21) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 03 Jul 2013 09:14:41 +0000 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga101.ch.intel.com with ESMTP; 03 Jul 2013 02:14:39 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by AZSMGA002.ch.intel.com with ESMTP; 03 Jul 2013 02:14:38 -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 r639EbQl009807; Wed, 3 Jul 2013 10:14:37 +0100 Received: from ulslx001.iul.intel.com (localhost [127.0.0.1]) by ulslx001.iul.intel.com with ESMTP id r639Eb9v029265; Wed, 3 Jul 2013 11:14:37 +0200 Received: (from mmetzger@localhost) by ulslx001.iul.intel.com with id r639Ea35029261; Wed, 3 Jul 2013 11:14:36 +0200 From: Markus Metzger To: jan.kratochvil@redhat.com Cc: gdb-patches@sourceware.org, Christian Himpel Subject: [patch v4 08/24] record-btrace: make ranges include begin and end Date: Wed, 03 Jul 2013 09:14:00 -0000 Message-Id: <1372842874-28951-9-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/msg00121.txt.bz2 The "record function-call-history" and "record instruction-history" commands accept a range "begin, end". End is not included in both cases. Include it. Reviewed-by: Eli Zaretskii CC: Christian Himpel 2013-07-03 Markus Metzger * record-btrace.c (record_btrace_insn_history_range): Include end. (record_btrace_insn_history_from): Adjust range. (record_btrace_call_history_range): Include end. (record_btrace_call_history_from): Adjust range. testsuite/ * gdb.btrace/function_call_history.exp: Update tests. * gdb.btrace/instruction_history.exp: Update tests. doc/ * gdb.texinfo (Process Record and Replay): Update documentation. --- gdb/doc/gdb.texinfo | 6 +-- gdb/record-btrace.c | 34 +++++++++++++++----- gdb/testsuite/gdb.btrace/function_call_history.exp | 4 +- gdb/testsuite/gdb.btrace/instruction_history.exp | 6 ++-- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 2cfc20b..eb4896f 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -6393,8 +6393,7 @@ Disassembles ten more instructions before the last disassembly. @item record instruction-history @var{begin} @var{end} Disassembles instructions beginning with instruction number -@var{begin} until instruction number @var{end}. The instruction -number @var{end} is not included. +@var{begin} until instruction number @var{end}. @end table This command may not be available for all recording methods. @@ -6464,8 +6463,7 @@ Prints ten more functions before the last ten-line print. @item record function-call-history @var{begin} @var{end} Prints functions beginning with function number @var{begin} until -function number @var{end}. The function number @var{end} is not -included. +function number @var{end}. @end table This command may not be available for all recording methods. diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 99dc046..c7d6e9f 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -377,10 +377,17 @@ record_btrace_insn_history_range (ULONGEST from, ULONGEST to, int flags) if (found == 0) error (_("Range out of bounds.")); - /* Silently truncate the range, if necessary. */ found = btrace_find_insn_by_number (&end, btinfo, high); if (found == 0) - btrace_insn_end (&end, btinfo); + { + /* Silently truncate the range. */ + btrace_insn_end (&end, btinfo); + } + else + { + /* We want both begin and end to be inclusive. */ + btrace_insn_next (&end, 1); + } btrace_insn_history (uiout, &begin, &end, flags); btrace_set_insn_history (btinfo, &begin, &end); @@ -396,6 +403,8 @@ record_btrace_insn_history_from (ULONGEST from, int size, int flags) ULONGEST begin, end, context; context = abs (size); + if (context == 0) + error (_("Bad record instruction-history-size.")); if (size < 0) { @@ -404,12 +413,12 @@ record_btrace_insn_history_from (ULONGEST from, int size, int flags) if (from < context) begin = 0; else - begin = from - context; + begin = from - context + 1; } else { begin = from; - end = from + context; + end = from + context - 1; /* Check for wrap-around. */ if (end < begin) @@ -629,10 +638,17 @@ record_btrace_call_history_range (ULONGEST from, ULONGEST to, int flags) if (found == 0) error (_("Range out of bounds.")); - /* Silently truncate the range, if necessary. */ found = btrace_find_call_by_number (&end, btinfo, high); if (found == 0) - btrace_call_end (&end, btinfo); + { + /* Silently truncate the range. */ + btrace_call_end (&end, btinfo); + } + else + { + /* We want both begin and end to be inclusive. */ + btrace_call_next (&end, 1); + } btrace_call_history (uiout, btinfo, &begin, &end, flags); btrace_set_call_history (btinfo, &begin, &end); @@ -648,6 +664,8 @@ record_btrace_call_history_from (ULONGEST from, int size, int flags) ULONGEST begin, end, context; context = abs (size); + if (context == 0) + error (_("Bad record function-call-history-size.")); if (size < 0) { @@ -656,12 +674,12 @@ record_btrace_call_history_from (ULONGEST from, int size, int flags) if (from < context) begin = 0; else - begin = from - context; + begin = from - context + 1; } else { begin = from; - end = from + context; + end = from + context - 1; /* Check for wrap-around. */ if (end < begin) diff --git a/gdb/testsuite/gdb.btrace/function_call_history.exp b/gdb/testsuite/gdb.btrace/function_call_history.exp index 754cbbe..901e487 100644 --- a/gdb/testsuite/gdb.btrace/function_call_history.exp +++ b/gdb/testsuite/gdb.btrace/function_call_history.exp @@ -222,9 +222,9 @@ set expected_range "4\tinc\r 10\tinc\r" # show functions in instruction range -gdb_test "record function-call-history 4,11" $expected_range "absolute instruction range" +gdb_test "record function-call-history 4,10" $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" +gdb_test "record function-call-history 10,-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] diff --git a/gdb/testsuite/gdb.btrace/instruction_history.exp b/gdb/testsuite/gdb.btrace/instruction_history.exp index df2728b..e7a0e8e 100644 --- a/gdb/testsuite/gdb.btrace/instruction_history.exp +++ b/gdb/testsuite/gdb.btrace/instruction_history.exp @@ -65,7 +65,7 @@ if { $traced != 6 } { } # test that we see the expected instructions -gdb_test "record instruction-history 2,7" " +gdb_test "record instruction-history 2,6" " 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 @@ -79,14 +79,14 @@ gdb_test "record instruction-history /f 2,+5" " 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" " +gdb_test "record instruction-history /p 6,-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" " +gdb_test "record instruction-history /pf 2,6" " 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 -- 1.7.1