Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Markus Metzger <markus.t.metzger@intel.com>
To: jan.kratochvil@redhat.com
Cc: gdb-patches@sourceware.org, Eli Zaretskii <eliz@gnu.org>,
	       Christian Himpel <christian.himpel@intel.com>
Subject: [PATCH 06/15] record-btrace: make ranges include begin and end
Date: Thu, 02 May 2013 12:03:00 -0000	[thread overview]
Message-ID: <1367496216-21217-7-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1367496216-21217-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>
CC: Christian Himpel  <christian.himpel@intel.com>
2013-05-02  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                                |   29 +++++++++++++++-----
 gdb/testsuite/gdb.btrace/function_call_history.exp |    4 +-
 gdb/testsuite/gdb.btrace/instruction_history.exp   |    6 ++--
 4 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 99af587..8175927 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6344,8 +6344,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.
@@ -6415,8 +6414,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 9d73286..ebb26ad 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -370,10 +370,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);
@@ -389,6 +396,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)
     {
@@ -397,12 +406,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)
@@ -672,8 +681,12 @@ record_btrace_call_history_range (ULONGEST from, ULONGEST to, int flags)
   if (begin == NULL)
     error (_("Range out of bounds."));
 
-  /* Silently truncate the range, if necessary.  */
   end = btrace_find_function_by_number (btinfo, high);
+  /* We want both begin and end to be inclusive.  */
+  if (end != NULL)
+    end = end->flow.next;
+
+  /* Silently truncate the range, if necessary.  */
   if (end == NULL)
     end = btinfo->end;
 
@@ -691,6 +704,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)
     {
@@ -699,12 +714,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 e528625..86f2c21 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 "3\tinc\r
 9\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,9" $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 9,-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 c1a61b7..147c2ef 100644
--- a/gdb/testsuite/gdb.btrace/instruction_history.exp
+++ b/gdb/testsuite/gdb.btrace/instruction_history.exp
@@ -65,7 +65,7 @@ if { $traced != 7 } {
 }
 
 # test that we see the expected instructions
-gdb_test "record instruction-history 1,6" "
+gdb_test "record instruction-history 1,5" "
 1\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
 2\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax\r
 3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
@@ -79,14 +79,14 @@ gdb_test "record instruction-history /f 1,+5" "
 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\]+ <loop\\+\[0-9\]+>\r"
 
-gdb_test "record instruction-history /p 6,-5" "
+gdb_test "record instruction-history /p 5,-5" "
 1\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
 2\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax\r
 3\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
 4\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax\r
 5\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r"
 
-gdb_test "record instruction-history /pf 1,6" "
+gdb_test "record instruction-history /pf 1,5" "
 1\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
 2\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax\r
 3\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r
-- 
1.7.1


  parent reply	other threads:[~2013-05-02 12:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-02 12:03 [PATCH 00/15] record-btrace: goto support Markus Metzger
2013-05-02 12:03 ` [PATCH 10/15] frame, backtrace: allow targets to supply a frame unwinder Markus Metzger
2013-05-02 12:03 ` [PATCH 14/15] record-btrace: add record goto target methods Markus Metzger
2013-05-02 17:11   ` Eli Zaretskii
2013-05-02 12:03 ` [PATCH 09/15] record-btrace: supply register " Markus Metzger
2013-05-02 12:03 ` Markus Metzger [this message]
2013-05-02 15:51   ` [PATCH 06/15] record-btrace: make ranges include begin and end Eli Zaretskii
2013-05-02 12:03 ` [PATCH 08/15] target: add ops parameter to to_prepare_to_store method Markus Metzger
2013-05-02 12:03 ` [PATCH 12/15] record-btrace: provide xfer_partial target method Markus Metzger
2013-05-02 12:03 ` [PATCH 01/15] gdbarch: add instruction predicate methods Markus Metzger
2013-05-13 15:23   ` Jan Kratochvil
2013-05-02 12:03 ` [PATCH 03/15] record-btrace: fix insn range in function call history Markus Metzger
2013-05-02 12:03 ` [PATCH 07/15] btrace: add replay position to btrace thread info Markus Metzger
2013-05-02 12:04 ` [PATCH 05/15] record-btrace: optionally indent function call history Markus Metzger
2013-05-02 17:10   ` Eli Zaretskii
2013-05-02 12:04 ` [PATCH 11/15] record-btrace, frame: supply target-specific unwinder Markus Metzger
2013-05-02 12:04 ` [PATCH 04/15] btrace: increase buffer size Markus Metzger
2013-05-02 12:04 ` [PATCH 13/15] record-btrace: add to_wait and to_resume target methods Markus Metzger
2013-05-02 12:04 ` [PATCH 15/15] record-btrace: extend unwinder Markus Metzger
2013-05-02 15:52   ` Eli Zaretskii
2013-05-02 12:04 ` [PATCH 02/15] btrace: change branch trace data structure Markus Metzger
2013-05-13 15:25   ` Jan Kratochvil
2013-05-14 15:27     ` Metzger, Markus T
2013-05-14 16:11       ` Doug Evans

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=1367496216-21217-7-git-send-email-markus.t.metzger@intel.com \
    --to=markus.t.metzger@intel.com \
    --cc=christian.himpel@intel.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@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