From: Markus Metzger <markus.t.metzger@intel.com>
To: jan.kratochvil@redhat.com, palves@redhat.com
Cc: gdb-patches@sourceware.org, Eli Zaretskii <eliz@gnu.org>
Subject: [PATCH v9 12/29] record-btrace: make ranges include begin and end
Date: Thu, 19 Dec 2013 16:45:00 -0000 [thread overview]
Message-ID: <1387471499-29444-13-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1387471499-29444-1-git-send-email-markus.t.metzger@intel.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.
CC: Eli Zaretskii <eliz@gnu.org>
2013-12-19 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/NEWS | 3 ++
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 | 8 +++--
6 files changed, 43 insertions(+), 21 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 12c424d..da7f97b 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -45,6 +45,9 @@
The instruction range is now prefixed with 'insn'.
The source line range is now prefixed with 'at'.
+* 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 effc73d..5c3f548 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 5b9b34d..1cbf567 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 f149757..c576004 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 195fe72..1b06574 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\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
"3\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec %eax" \
"4\t 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
@@ -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\]+ <loop\\+\[0-9\]+>\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\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
"3\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec %eax" \
"4\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
@@ -89,7 +89,7 @@ gdb_test "record instruction-history /p 7,-5" [join [list \
"6\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\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\]+ <loop\\+\[0-9\]+>" \
"3\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec %eax" \
"4\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp 0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
@@ -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\]+ <loop\\+\[0-9\]+>\r" \
] "\r\n"]
+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
next prev parent reply other threads:[~2013-12-19 16:45 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-19 16:45 [PATCH v9 00/29] record-btrace: reverse Markus Metzger
2013-12-19 16:45 ` [PATCH v9 16/29] frame, backtrace: allow targets to supply a frame unwinder Markus Metzger
2013-12-19 18:41 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 08/29] record-btrace: fix insn range in function call history Markus Metzger
2013-12-19 16:45 ` [PATCH v9 11/29] record-btrace: optionally indent " Markus Metzger
2013-12-19 18:23 ` Pedro Alves
2013-12-20 12:54 ` Metzger, Markus T
2013-12-20 16:47 ` Pedro Alves
2013-12-19 16:45 ` Markus Metzger [this message]
2013-12-19 17:29 ` [PATCH v9 12/29] record-btrace: make ranges include begin and end Eli Zaretskii
2013-12-19 16:45 ` [PATCH v9 09/29] record-btrace: start counting at one Markus Metzger
2013-12-19 17:27 ` Eli Zaretskii
2013-12-19 16:45 ` [PATCH v9 04/29] gdbarch: add instruction predicate methods Markus Metzger
2013-12-19 20:19 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 21/29] record-btrace: provide xfer_partial target method Markus Metzger
2013-12-19 19:13 ` Pedro Alves
2013-12-20 13:37 ` Metzger, Markus T
2013-12-20 13:54 ` Metzger, Markus T
2013-12-20 15:56 ` Pedro Alves
2013-12-20 16:02 ` Pedro Alves
2014-01-13 17:11 ` Pedro Alves
2014-01-13 12:36 ` Metzger, Markus T
2014-01-13 16:47 ` Pedro Alves
2013-12-19 19:26 ` Pedro Alves
2013-12-20 13:32 ` Metzger, Markus T
2013-12-20 15:36 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 03/29] btrace: uppercase btrace_read_type Markus Metzger
2013-12-19 16:45 ` [PATCH v9 28/29] target: allow decr_pc_after_break to be defined by the target Markus Metzger
2013-12-19 19:51 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 22/29] record-btrace: add to_wait and to_resume target methods Markus Metzger
2013-12-19 16:45 ` [PATCH v9 25/29] record-btrace: extend unwinder Markus Metzger
2013-12-19 16:45 ` [PATCH v9 10/29] btrace: increase buffer size Markus Metzger
2013-12-19 16:45 ` [PATCH v9 24/29] record-btrace: add record goto target methods Markus Metzger
2013-12-19 16:45 ` [PATCH v9 29/29] record-btrace: add (reverse-)stepping support Markus Metzger
2013-12-19 17:31 ` Eli Zaretskii
2013-12-19 20:10 ` Pedro Alves
2013-12-20 14:37 ` Metzger, Markus T
2013-12-20 14:47 ` Metzger, Markus T
2013-12-20 16:31 ` Pedro Alves
2013-12-20 16:07 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 13/29] btrace: add replay position to btrace thread info Markus Metzger
2013-12-19 16:45 ` [PATCH v9 23/29] record-btrace: provide target_find_new_threads method Markus Metzger
2013-12-19 19:32 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 26/29] btrace, gdbserver: read branch trace incrementally Markus Metzger
2013-12-19 16:45 ` [PATCH v9 15/29] record-btrace: supply register target methods Markus Metzger
2013-12-19 16:45 ` [PATCH v9 20/29] target, breakpoint: allow insert/remove breakpoint to be forwarded Markus Metzger
2013-12-19 19:08 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 07/29] btrace: change branch trace data structure Markus Metzger
2013-12-19 16:45 ` [PATCH v9 02/29] btrace, linux: fix memory leak when reading branch trace Markus Metzger
2013-12-19 16:45 ` [PATCH v9 06/29] frame: add frame_id_build_unavailable_stack_special Markus Metzger
2013-12-19 18:12 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 14/29] target: add ops parameter to to_prepare_to_store method Markus Metzger
2013-12-19 18:30 ` Pedro Alves
2013-12-19 21:13 ` Tom Tromey
2013-12-20 13:07 ` Metzger, Markus T
2013-12-20 15:13 ` Tom Tromey
2013-12-20 17:23 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 17/29] frame, cfa: check unwind stop reason first Markus Metzger
2013-12-19 16:45 ` [PATCH v9 19/29] record-btrace, frame: supply target-specific unwinder Markus Metzger
2013-12-19 16:45 ` [PATCH v9 27/29] record-btrace: show trace from enable location Markus Metzger
2013-12-19 16:45 ` [PATCH v9 01/29] btrace, test: fix multi-line btrace tests Markus Metzger
2013-12-19 18:01 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 05/29] frame: add frame_is_tailcall function Markus Metzger
2013-12-19 20:19 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 18/29] frame: do not assume unwinding will succeed Markus Metzger
2013-12-19 20:23 ` [PATCH v9 00/29] record-btrace: reverse Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1387471499-29444-13-git-send-email-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).