This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch v8 11/24] record-btrace: make ranges include begin and end
- From: Markus Metzger <markus dot t dot metzger at intel dot com>
- To: jan dot kratochvil at redhat dot com
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 12 Dec 2013 10:15:34 +0100
- Subject: [patch v8 11/24] record-btrace: make ranges include begin and end
- Authentication-results: sourceware.org; auth=none
- References: <1386839747-8860-1-git-send-email-markus dot t dot metzger at intel dot com>
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
2013-12-12 Markus Metzger <markus.t.metzger@intel.com>
* 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 | 38 ++++++++++++++++------
gdb/target.h | 4 +--
gdb/testsuite/gdb.btrace/function_call_history.exp | 5 +--
gdb/testsuite/gdb.btrace/instruction_history.exp | 9 +++--
5 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index a469709..684053a 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6456,8 +6456,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.
@@ -6527,8 +6526,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 9470d85..45d5e4a 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 f22e5c6..1e1467e 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -869,7 +869,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.
@@ -884,7 +884,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 a5f072c..1dfb5e3 100644
--- a/gdb/testsuite/gdb.btrace/function_call_history.exp
+++ b/gdb/testsuite/gdb.btrace/function_call_history.exp
@@ -222,9 +222,10 @@ 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"
+gdb_test "record function-call-history 4,4" "4\tinc\r" "single entry"
# 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 6878d27..edf529c 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\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
3\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec %eax\r
4\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
@@ -79,20 +79,23 @@ 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\]+ <loop\\+\[0-9\]+>\r"
-gdb_test "record instruction-history /p 7,-5" "
+gdb_test "record instruction-history /p 6,-5" "
2\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
3\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec %eax\r
4\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
5\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp \\\$0x0,%eax\r
6\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\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\]+ <loop\\+\[0-9\]+>\r
3\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax\r
4\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
5\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp \\\$0x0,%eax\r
6\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r"
+gdb_test "record instruction-history 2,2" "
+2\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\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