From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16828 invoked by alias); 14 Jan 2014 08:05:24 -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 16380 invoked by uid 89); 14 Jan 2014 08:05:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 Jan 2014 08:05:19 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 14 Jan 2014 00:01:09 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 14 Jan 2014 00:04:41 -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 s0E84elt013298; Tue, 14 Jan 2014 08:04:40 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id s0E84eKN009387; Tue, 14 Jan 2014 09:04:40 +0100 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id s0E84etT009383; Tue, 14 Jan 2014 09:04:40 +0100 From: Markus Metzger To: jan.kratochvil@redhat.com, palves@redhat.com Cc: gdb-patches@sourceware.org Subject: [PATCH v10 11/28] record-btrace: make ranges include begin and end Date: Tue, 14 Jan 2014 08:05:00 -0000 Message-Id: <1389686678-9039-12-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1389686678-9039-1-git-send-email-markus.t.metzger@intel.com> References: <1389686678-9039-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2014-01/txt/msg00411.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 2014-01-14 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/NEWS | 3 ++ gdb/doc/gdb.texinfo | 5 ++- gdb/record-btrace.c | 38 ++++++++++++++++------ gdb/target.h | 4 +-- gdb/testsuite/gdb.btrace/function_call_history.exp | 5 +-- gdb/testsuite/gdb.btrace/instruction_history.exp | 8 +++-- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 8f0e6e6..94e7a98 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -51,6 +51,9 @@ Both ranges are now printed as ', ' to allow copy&paste to the "record instruction-history" and "list" commands. +* The ranges given as arguments to the 'record function-call-history' and + 'record instruction-history' commands are now inclusive. + * Python scripting ** Frame filters and frame decorators have been added. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 3e76cca..4367028 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -6465,7 +6465,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. +number @var{end} is included. @end table This command may not be available for all recording methods. @@ -6536,8 +6536,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}. The function number @var{end} is included. @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 7fe7cb2..5c390b8 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -368,7 +368,7 @@ record_btrace_insn_history_range (ULONGEST from, ULONGEST to, int flags) if (low != from || high != to) error (_("Bad range.")); - if (high <= low) + if (high < low) error (_("Bad range.")); btinfo = require_btrace (); @@ -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) @@ -619,7 +628,7 @@ record_btrace_call_history_range (ULONGEST from, ULONGEST to, int flags) if (low != from || high != to) error (_("Bad range.")); - if (high <= low) + if (high < low) error (_("Bad range.")); btinfo = require_btrace (); @@ -628,10 +637,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); @@ -647,6 +663,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) { @@ -655,12 +673,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/target.h b/gdb/target.h index ab985e4..7e14075 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -873,7 +873,7 @@ struct target_ops void (*to_insn_history_from) (ULONGEST from, int size, int flags); /* Disassemble a section of the recorded execution trace from instruction - BEGIN (inclusive) to instruction END (exclusive). */ + BEGIN (inclusive) to instruction END (inclusive). */ void (*to_insn_history_range) (ULONGEST begin, ULONGEST end, int flags); /* Print a function trace of the recorded execution trace. @@ -888,7 +888,7 @@ struct target_ops void (*to_call_history_from) (ULONGEST begin, int size, int flags); /* Print a function trace of an execution trace section from function BEGIN - (inclusive) to function END (exclusive). */ + (inclusive) to function END (inclusive). */ void (*to_call_history_range) (ULONGEST begin, ULONGEST end, int flags); /* Nonzero if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a diff --git a/gdb/testsuite/gdb.btrace/function_call_history.exp b/gdb/testsuite/gdb.btrace/function_call_history.exp index f7a9233..935fc22 100644 --- a/gdb/testsuite/gdb.btrace/function_call_history.exp +++ b/gdb/testsuite/gdb.btrace/function_call_history.exp @@ -183,9 +183,10 @@ set expected_range [join [list \ "10\tinc"] "\r\n"] # show functions in instruction range -gdb_test "record function-call-history 4,11" $expected_range +gdb_test "record function-call-history 4,10" $expected_range gdb_test "record function-call-history 4,+7" $expected_range -gdb_test "record function-call-history 11,-7" $expected_range +gdb_test "record function-call-history 10,-7" $expected_range +gdb_test "record function-call-history 4,4" "4\tinc\r" # 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 46ef65e..5769345 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" [join [list \ +gdb_test "record instruction-history 2,6" [join [list \ "2\t 0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ " \ "3\t 0x\[0-9a-f\]+ :\tdec %eax" \ "4\t 0x\[0-9a-f\]+ :\tjmp 0x\[0-9a-f\]+ " \ @@ -81,7 +81,7 @@ gdb_test "record instruction-history /f 2,+5" [join [list \ "6\t 0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ \r" \ ] "\r\n"] -gdb_test "record instruction-history /p 7,-5" [join [list \ +gdb_test "record instruction-history /p 6,-5" [join [list \ "2\t0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ " \ "3\t0x\[0-9a-f\]+ :\tdec %eax" \ "4\t0x\[0-9a-f\]+ :\tjmp 0x\[0-9a-f\]+ " \ @@ -89,7 +89,7 @@ gdb_test "record instruction-history /p 7,-5" [join [list \ "6\t0x\[0-9a-f\]+ :\tje 0x\[0-9a-f\]+ \r" \ ] "\r\n"] -gdb_test "record instruction-history /pf 2,7" [join [list \ +gdb_test "record instruction-history /pf 2,6" [join [list \ "2\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ " \ "3\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax" \ "4\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ " \ @@ -97,6 +97,8 @@ gdb_test "record instruction-history /pf 2,7" [join [list \ "6\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ \r" \ ] "\r\n"] +gdb_test "record instruction-history 2,2" "2\t 0x\[0-9a-f\]+ :\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 # were printed during command execution. -- 1.8.3.1