public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Markus Metzger <markus.t.metzger@intel.com>
To: jan.kratochvil@redhat.com, palves@redhat.com
Cc: gdb-patches@sourceware.org
Subject: [PATCH v9 27/29] record-btrace: show trace from enable location
Date: Thu, 19 Dec 2013 16:45:00 -0000	[thread overview]
Message-ID: <1387471499-29444-28-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1387471499-29444-1-git-send-email-markus.t.metzger@intel.com>

The btrace record target shows the branch trace from the location of the first
branch destination.  This is the first BTS records.

After adding incremental updates, we can now add a dummy record for the current
PC when we enable tracing so we show the trace from the location where branch
tracing has been enabled.

2013-12-19  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.c: Include regcache.h.
	(btrace_add_pc): New.
	(btrace_enable): Call btrace_add_pc.
	(btrace_is_empty): New.
	* btrace.h (btrace_is_empty): New.
	* record-btrace.c (require_btrace, record_btrace_info): Call
	btrace_is_empty.

testsuite/
	* gdb.btrace/Makefile.in (EXECUTABLES): Add delta.
	* gdb.btrace/exception.exp: Update.
	* gdb.btrace/instruction_history.exp: Update.
	* gdb.btrace/record_goto.exp: Update.
	* gdb.btrace/tailcall.exp: Update.
	* gdb.btrace/unknown_functions.exp: Update.
	* gdb.btrace/delta.exp: New.


---
 gdb/btrace.c                                     | 51 +++++++++++++
 gdb/btrace.h                                     |  4 +
 gdb/record-btrace.c                              |  8 +-
 gdb/testsuite/gdb.btrace/Makefile.in             |  2 +-
 gdb/testsuite/gdb.btrace/delta.exp               | 68 +++++++++++++++++
 gdb/testsuite/gdb.btrace/exception.exp           | 20 ++---
 gdb/testsuite/gdb.btrace/instruction_history.exp | 68 ++++++++---------
 gdb/testsuite/gdb.btrace/record_goto.exp         | 97 ++++++++++++------------
 gdb/testsuite/gdb.btrace/tailcall.exp            | 16 ++--
 gdb/testsuite/gdb.btrace/unknown_functions.exp   | 22 +++---
 10 files changed, 239 insertions(+), 117 deletions(-)
 create mode 100644 gdb/testsuite/gdb.btrace/delta.exp

diff --git a/gdb/btrace.c b/gdb/btrace.c
index c86a866..87ddf56 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -30,6 +30,7 @@
 #include "source.h"
 #include "filenames.h"
 #include "xml-support.h"
+#include "regcache.h"
 
 /* Print a record debug message.  Use do ... while (0) to avoid ambiguities
    when used in if statements.  */
@@ -663,6 +664,32 @@ btrace_compute_ftrace (struct btrace_thread_info *btinfo,
   btinfo->level = -level;
 }
 
+/* Add an entry for the current PC.  */
+
+static void
+btrace_add_pc (struct thread_info *tp)
+{
+  VEC (btrace_block_s) *btrace;
+  struct btrace_block *block;
+  struct regcache *regcache;
+  struct cleanup *cleanup;
+  CORE_ADDR pc;
+
+  regcache = get_thread_regcache (tp->ptid);
+  pc = regcache_read_pc (regcache);
+
+  btrace = NULL;
+  cleanup = make_cleanup (VEC_cleanup (btrace_block_s), &btrace);
+
+  block = VEC_safe_push (btrace_block_s, btrace, NULL);
+  block->begin = pc;
+  block->end = pc;
+
+  btrace_compute_ftrace (&tp->btrace, btrace);
+
+  do_cleanups (cleanup);
+}
+
 /* See btrace.h.  */
 
 void
@@ -677,6 +704,11 @@ btrace_enable (struct thread_info *tp)
   DEBUG ("enable thread %d (%s)", tp->num, target_pid_to_str (tp->ptid));
 
   tp->btrace.target = target_enable_btrace (tp->ptid);
+
+  /* Add an entry for the current PC so we start tracing from where we
+     enabled it.  */
+  if (tp->btrace.target != NULL)
+    btrace_add_pc (tp);
 }
 
 /* See btrace.h.  */
@@ -1464,3 +1496,22 @@ btrace_is_replaying (struct thread_info *tp)
 {
   return tp->btrace.replay != NULL;
 }
+
+/* See btrace.h.  */
+
+int
+btrace_is_empty (struct thread_info *tp)
+{
+  struct btrace_insn_iterator begin, end;
+  struct btrace_thread_info *btinfo;
+
+  btinfo = &tp->btrace;
+
+  if (btinfo->begin == NULL)
+    return 1;
+
+  btrace_insn_begin (&begin, btinfo);
+  btrace_insn_end (&end, btinfo);
+
+  return btrace_insn_cmp (&begin, &end) == 0;
+}
diff --git a/gdb/btrace.h b/gdb/btrace.h
index 0a48253..548ebba 100644
--- a/gdb/btrace.h
+++ b/gdb/btrace.h
@@ -314,4 +314,8 @@ extern void btrace_set_call_history (struct btrace_thread_info *,
 /* Determine if branch tracing is currently replaying TP.  */
 extern int btrace_is_replaying (struct thread_info *tp);
 
+/* Return non-zero if the branch trace for TP is empty; zero otherwise.  */
+extern int btrace_is_empty (struct thread_info *tp);
+
+
 #endif /* BTRACE_H */
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 8e27f0f..22eb7e5 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -68,7 +68,6 @@ static struct thread_info *
 require_btrace_thread (void)
 {
   struct thread_info *tp;
-  struct btrace_thread_info *btinfo;
 
   DEBUG ("require");
 
@@ -78,9 +77,7 @@ require_btrace_thread (void)
 
   btrace_fetch (tp);
 
-  btinfo = &tp->btrace;
-
-  if (btinfo->begin == NULL)
+  if (btrace_is_empty (tp))
     error (_("No trace."));
 
   return tp;
@@ -242,7 +239,8 @@ record_btrace_info (void)
   calls = 0;
 
   btinfo = &tp->btrace;
-  if (btinfo->begin != NULL)
+
+  if (!btrace_is_empty (tp))
     {
       struct btrace_call_iterator call;
       struct btrace_insn_iterator insn;
diff --git a/gdb/testsuite/gdb.btrace/Makefile.in b/gdb/testsuite/gdb.btrace/Makefile.in
index 8311cba..2ae673a 100644
--- a/gdb/testsuite/gdb.btrace/Makefile.in
+++ b/gdb/testsuite/gdb.btrace/Makefile.in
@@ -2,7 +2,7 @@ VPATH = @srcdir@
 srcdir = @srcdir@
 
 EXECUTABLES   = enable function_call_history instruction_history tailcall \
-  exception unknown_functions record_goto
+  exception unknown_functions record_goto delta
 
 MISCELLANEOUS =
 
diff --git a/gdb/testsuite/gdb.btrace/delta.exp b/gdb/testsuite/gdb.btrace/delta.exp
new file mode 100644
index 0000000..e606751
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/delta.exp
@@ -0,0 +1,68 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <markus.t.metzger@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# start inferior
+standard_testfile x86-record_goto.S
+if [prepare_for_testing delta.exp $testfile $srcfile] {
+    return -1
+}
+if ![runto_main] {
+    return -1
+}
+
+# proceed to some sequential code
+gdb_test "next"
+
+# start tracing
+gdb_test_no_output "record btrace"
+
+# we start without trace
+with_test_prefix "no trace" {
+  gdb_test "info record" [join [list \
+    "Active record target: record-btrace" \
+    "Recorded 0 instructions in 0 functions for .*" \
+    ] "\r\n"]
+  gdb_test "record instruction-history" "No trace\."
+  gdb_test "record function-call-history" "No trace\."
+}
+
+# we record each single-step, even if we have not seen a branch, yet.
+gdb_test "stepi"
+
+proc check_trace {} {
+  gdb_test "info record" [join [list \
+    "Active record target: record-btrace" \
+    "Recorded 1 instructions in 1 functions for .*" \
+    ] "\r\n"]
+  gdb_test "record instruction-history /f 1" \
+    "1\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tmov *\\\$0x0,%eax\r"
+  gdb_test "record function-call-history /c 1" "1\tmain"
+}
+
+# make sure we don't extend the trace when we ask twice.
+with_test_prefix "once" {
+  check_trace
+}
+
+with_test_prefix "twice" {
+  check_trace
+}
diff --git a/gdb/testsuite/gdb.btrace/exception.exp b/gdb/testsuite/gdb.btrace/exception.exp
index 5a0d625..5854a22 100755
--- a/gdb/testsuite/gdb.btrace/exception.exp
+++ b/gdb/testsuite/gdb.btrace/exception.exp
@@ -47,10 +47,11 @@ gdb_continue_to_breakpoint "cont to bp.2" ".*$srcfile:$bp_2\r\n.*"
 send_gdb "record function-call-history 1\n"
 gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \
   [join [list \
-    "1\ttest\\(\\)" \
-    "2\tfoo\\(\\)" \
-    "3\tbar\\(\\)" \
-    "4\tbad\\(\\)" \
+    "1\tmain\\(\\)" \
+    "2\ttest\\(\\)" \
+    "3\tfoo\\(\\)" \
+    "4\tbar\\(\\)" \
+    "5\tbad\\(\\)\r" \
   ] "\r\n"] \
   "" \
   "\[0-9\]*\ttest\\(\\)"]
@@ -62,10 +63,11 @@ gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \
 send_gdb "record function-call-history /c 1\n"
 gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \
   [join [list \
-    "1\t  test\\(\\)" \
-    "2\t    foo\\(\\)" \
-    "3\t      bar\\(\\)" \
-    "4\t        bad\\(\\)\r" \
-    ] "\r\n"] \
+    "1\tmain\\(\\)" \
+  "2\t  test\\(\\)" \
+  "3\t    foo\\(\\)" \
+  "4\t      bar\\(\\)" \
+  "5\t        bad\\(\\)\r" \
+  ] "\r\n"] \
   "" \
   "\[0-9\]*\t  test\\(\\)"]
diff --git a/gdb/testsuite/gdb.btrace/instruction_history.exp b/gdb/testsuite/gdb.btrace/instruction_history.exp
index 1b06574..0092aa4 100644
--- a/gdb/testsuite/gdb.btrace/instruction_history.exp
+++ b/gdb/testsuite/gdb.btrace/instruction_history.exp
@@ -56,48 +56,48 @@ gdb_test_multiple "info record" $testname {
     }
 }
 
-# we have exactly 6 instructions here
-set message "exactly 6 instructions"
-if { $traced != 6 } {
+# we have exactly 11 instructions here
+set message "exactly 11 instructions"
+if { $traced != 11 } {
     fail $message
 } else {
     pass $message
 }
 
 # test that we see the expected instructions
-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\]+>" \
-  "5\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
-  "6\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
+gdb_test "record instruction-history 3,7" [join [list \
+  "3\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+  "4\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax" \
+  "5\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+  "6\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
+  "7\t   0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
   ] "\r\n"]
 
-gdb_test "record instruction-history /f 2,+5" [join [list \
-  "2\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  "3\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
-  "4\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
-  "5\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
-  "6\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
+gdb_test "record instruction-history /f 3,+5" [join [list \
+  "3\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+  "4\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
+  "5\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+  "6\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
+  "7\t   0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
   ] "\r\n"]
 
-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\]+>" \
-  "5\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
-  "6\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
+gdb_test "record instruction-history /p 7,-5" [join [list \
+  "3\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+  "4\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tdec    %eax" \
+  "5\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+  "6\t0x\[0-9a-f\]+ <loop\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
+  "7\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,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\]+>" \
-  "5\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
-  "6\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>\r" \
+gdb_test "record instruction-history /pf 3,7" [join [list \
+  "3\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tje     0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+  "4\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tdec    %eax" \
+  "5\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tjmp    0x\[0-9a-f\]+ <loop\\+\[0-9\]+>" \
+  "6\t0x\[0-9a-f\]+ <\\+\[0-9\]+>:\tcmp    \\\$0x0,%eax" \
+  "7\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"
+gdb_test "record instruction-history 3,3" "3\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
@@ -140,7 +140,7 @@ if { $traced != $lines } {
 }
 
 # test that the iterator works
-set history_size 3
+set history_size 4
 gdb_test_no_output "set record instruction-history-size $history_size"
 set message "browse history forward start"
 set lines [test_lines_length "record instruction-history 1" $message]
@@ -150,8 +150,6 @@ if { $lines != $history_size } {
     pass $message
 }
 
-set history_size 2
-gdb_test_no_output "set record instruction-history-size $history_size"
 set message "browse history forward middle"
 set lines [test_lines_length "record instruction-history +" $message]
 if { $lines != $history_size } {
@@ -162,7 +160,7 @@ if { $lines != $history_size } {
 
 set message "browse history forward last"
 set lines [test_lines_length "record instruction-history +" $message]
-if { $lines != 1 } {
+if { $lines != 3 } {
     fail $message
 } else {
     pass $message
@@ -173,8 +171,6 @@ gdb_test "record instruction-history" "At the end of the branch trace record\\."
 # make sure we cannot move further
 gdb_test "record instruction-history" "At the end of the branch trace record\\." "browse history forward beyond 2"
 
-set history_size 3
-gdb_test_no_output "set record instruction-history-size $history_size"
 set message "browse history backward last"
 set lines [test_lines_length "record instruction-history -" $message]
 if { $lines != $history_size } {
@@ -183,8 +179,6 @@ if { $lines != $history_size } {
     pass $message
 }
 
-set history_size 2
-gdb_test_no_output "set record instruction-history-size $history_size"
 set message "browse history backward middle"
 set lines [test_lines_length "record instruction-history -" $message]
 if { $lines != $history_size } {
@@ -195,7 +189,7 @@ if { $lines != $history_size } {
 
 set message "browse history backward first"
 set lines [test_lines_length "record instruction-history -" $message]
-if { $lines != 1 } {
+if { $lines != 3 } {
     fail $message
 } else {
     pass $message
diff --git a/gdb/testsuite/gdb.btrace/record_goto.exp b/gdb/testsuite/gdb.btrace/record_goto.exp
index f8a7dda..43028f4 100644
--- a/gdb/testsuite/gdb.btrace/record_goto.exp
+++ b/gdb/testsuite/gdb.btrace/record_goto.exp
@@ -50,42 +50,43 @@ gdb_test "next"
 
 # start by listing all functions
 gdb_test "record function-call-history /ci 1, +20" [join [list \
-  "1\t  fun4\tinst 1,3" \
-  "2\t    fun1\tinst 4,7" \
-  "3\t  fun4\tinst 8,8" \
-  "4\t    fun2\tinst 9,11" \
-  "5\t      fun1\tinst 12,15" \
-  "6\t    fun2\tinst 16,17" \
-  "7\t  fun4\tinst 18,18" \
-  "8\t    fun3\tinst 19,21" \
-  "9\t      fun1\tinst 22,25" \
-  "10\t    fun3\tinst 26,26" \
-  "11\t      fun2\tinst 27,29" \
-  "12\t        fun1\tinst 30,33" \
-  "13\t      fun2\tinst 34,35" \
-  "14\t    fun3\tinst 36,37" \
-  "15\t  fun4\tinst 38,39" \
+  "1\tmain\tinst 1,1" \
+  "2\t  fun4\tinst 2,4" \
+  "3\t    fun1\tinst 5,8" \
+  "4\t  fun4\tinst 9,9" \
+  "5\t    fun2\tinst 10,12" \
+  "6\t      fun1\tinst 13,16" \
+  "7\t    fun2\tinst 17,18" \
+  "8\t  fun4\tinst 19,19" \
+  "9\t    fun3\tinst 20,22" \
+  "10\t      fun1\tinst 23,26" \
+  "11\t    fun3\tinst 27,27" \
+  "12\t      fun2\tinst 28,30" \
+  "13\t        fun1\tinst 31,34" \
+  "14\t      fun2\tinst 35,36" \
+  "15\t    fun3\tinst 37,38" \
+  "16\t  fun4\tinst 39,40" \
   ] "\r\n"]
 
 # let's see if we can go back in history
-gdb_test "record goto 18" ".*fun4 \\(\\) at record_goto.c:43.*"
+gdb_test "record goto 19" ".*fun4 \\(\\) at record_goto.c:43.*"
 
 # the function call history should start at the new location
 gdb_test "record function-call-history /ci" [join [list \
-  "7\t  fun4\tinst 18,18" \
-  "8\t    fun3\tinst 19,21" \
-  "9\t      fun1\tinst 22,25" \
-  ] "\r\n"] "function-call-history from 18 forwards"
+  "8\t  fun4\tinst 19,19" \
+  "9\t    fun3\tinst 20,22" \
+  "10\t      fun1\tinst 23,26" \
+  ] "\r\n"] "function-call-history from 19 forwards"
 
 # the instruction history should start at the new location
 gdb_test "record instruction-history" [join [list \
-  "18.*" \
   "19.*" \
   "20.*" \
-  ] "\r\n"] "instruction-history from 18 forwards"
+  "21.*" \
+  ] "\r\n"] "instruction-history from 19 forwards"
 
 # let's go to another place in the history
-gdb_test "record goto 26" ".*fun3 \\(\\) at record_goto.c:35.*"
+gdb_test "record goto 27" ".*fun3 \\(\\) at record_goto.c:35.*"
 
 # check the back trace at that location
 gdb_test "backtrace" [join [list \
@@ -101,26 +102,26 @@ gdb_test "up" ".*main.*at record_goto.c:49.*" "up to main"
 
 # the function call history should start at the new location
 gdb_test "record function-call-history /ci -" [join [list \
-  "8\t    fun3\tinst 19,21" \
-  "9\t      fun1\tinst 22,25" \
-  "10\t    fun3\tinst 26,26\r" \
-  ] "\r\n"] "function-call-history from 26 backwards"
+  "9\t    fun3\tinst 20,22" \
+  "10\t      fun1\tinst 23,26" \
+  "11\t    fun3\tinst 27,27" \
+  ] "\r\n"] "function-call-history from 27 backwards"
 
 # the instruction history should start at the new location
 gdb_test "record instruction-history -" [join [list \
-  "24.*" \
   "25.*" \
-  "26.*\r" \
-  ] "\r\n"] "instruction-history from 26 backwards"
+  "26.*" \
+  "27.*" \
+  ] "\r\n"] "instruction-history from 27 backwards"
 
 # test that we can go to the begin of the trace
-gdb_test "record goto begin" ".*fun4 \\(\\) at record_goto.c:40.*"
+gdb_test "record goto begin" ".*main \\(\\) at record_goto.c:49.*"
 
 # check that we're filling up the context correctly
 gdb_test "record function-call-history /ci -" [join [list \
-  "1\t  fun4\tinst 1,3" \
-  "2\t    fun1\tinst 4,7" \
-  "3\t  fun4\tinst 8,8" \
+  "1\tmain\tinst 1,1" \
+  "2\t  fun4\tinst 2,4" \
+  "3\t    fun1\tinst 5,8" \
   ] "\r\n"] "function-call-history from begin backwards"
 
 # check that we're filling up the context correctly
@@ -135,9 +136,9 @@ gdb_test "record goto 2" ".*fun4 \\(\\) at record_goto.c:40.*"
 
 # check that we're filling up the context correctly
 gdb_test "record function-call-history /ci -" [join [list \
-  "1\t  fun4\tinst 1,3" \
-  "2\t    fun1\tinst 4,7" \
-  "3\t  fun4\tinst 8,8" \
+  "1\tmain\tinst 1,1" \
+  "2\t  fun4\tinst 2,4" \
+  "3\t    fun1\tinst 5,8\r" \
   ] "\r\n"] "function-call-history from 2 backwards"
 
 # check that we're filling up the context correctly
@@ -152,31 +153,31 @@ gdb_test "record goto end" ".*main \\(\\) at record_goto.c:50.*"
 
 # check that we're filling up the context correctly
 gdb_test "record function-call-history /ci" [join [list \
-  "13\t      fun2\tinst 34,35" \
-  "14\t    fun3\tinst 36,37" \
-  "15\t  fun4\tinst 38,39" \
+  "14\t      fun2\tinst 35,36" \
+  "15\t    fun3\tinst 37,38" \
+  "16\t  fun4\tinst 39,40" \
   ] "\r\n"] "function-call-history from end forwards"
 
 # check that we're filling up the context correctly
 gdb_test "record instruction-history" [join [list \
-  "37.*" \
   "38.*" \
   "39.*" \
+  "40.*\r" \
   ] "\r\n"] "instruction-history from end forwards"
 
 # we should get the exact same history from the second to last instruction
-gdb_test "record goto 38" ".*fun4 \\(\\) at record_goto.c:44.*"
+gdb_test "record goto 39" ".*fun4 \\(\\) at record_goto.c:44.*"
 
 # check that we're filling up the context correctly
 gdb_test "record function-call-history /ci" [join [list \
-  "13\t      fun2\tinst 34,35" \
-  "14\t    fun3\tinst 36,37" \
-  "15\t  fun4\tinst 38,39" \
-  ] "\r\n"] "function-call-history from 38 forwards"
+  "14\t      fun2\tinst 35,36" \
+  "15\t    fun3\tinst 37,38" \
+  "16\t  fun4\tinst 39,40\r" \
+  ] "\r\n"] "function-call-history from 39 forwards"
 
 # check that we're filling up the context correctly
 gdb_test "record instruction-history" [join [list \
-  "37.*" \
   "38.*" \
   "39.*" \
-  ] "\r\n"] "instruction-history from 38 forwards"
+  "40.*\r" \
+  ] "\r\n"] "instruction-history from 39 forwards"
diff --git a/gdb/testsuite/gdb.btrace/tailcall.exp b/gdb/testsuite/gdb.btrace/tailcall.exp
index a001783..23988f2 100644
--- a/gdb/testsuite/gdb.btrace/tailcall.exp
+++ b/gdb/testsuite/gdb.btrace/tailcall.exp
@@ -49,20 +49,22 @@ gdb_test "next"
 
 # show the flat branch trace
 gdb_test "record function-call-history 1" [join [list \
-  "1\tfoo" \
-  "2\tbar" \
-  "3\tmain" \
+  "1\tmain" \
+  "2\tfoo" \
+  "3\tbar" \
+  "4\tmain" \
   ] "\r\n"] "flat"
 
 # show the branch trace with calls indented
 gdb_test "record function-call-history /c 1" [join [list \
-  "1\t  foo" \
-  "2\t    bar" \
-  "3\tmain" \
+  "1\tmain" \
+  "2\t  foo" \
+  "3\t    bar" \
+  "4\tmain" \
   ] "\r\n"] "indented"
 
 # go into bar
-gdb_test "record goto 3" ".*bar \\(\\) at .*x86-tailcall.c:24\r\n.*"
+gdb_test "record goto 4" ".*bar \\(\\) at .*x86-tailcall.c:24\r\n.*"
 
 # check the backtrace
 gdb_test "backtrace" [join [list \
diff --git a/gdb/testsuite/gdb.btrace/unknown_functions.exp b/gdb/testsuite/gdb.btrace/unknown_functions.exp
index f678358..44aa712 100644
--- a/gdb/testsuite/gdb.btrace/unknown_functions.exp
+++ b/gdb/testsuite/gdb.btrace/unknown_functions.exp
@@ -41,20 +41,22 @@ gdb_continue_to_breakpoint "cont to test" ".*test.*"
 
 # show the flat branch trace
 gdb_test "record function-call-history 1" [join [list \
-  "1\t\\\?\\\?" \
+  "1\ttest" \
   "2\t\\\?\\\?" \
   "3\t\\\?\\\?" \
-  "4\ttest" \
-  "5\tmain" \
-  "6\ttest" \
+  "4\t\\\?\\\?" \
+  "5\ttest" \
+  "6\tmain" \
+  "7\ttest" \
   ] "\r\n"] "flat"
 
 # show the branch trace with calls indented
 gdb_test "record function-call-history /c 1" [join [list \
-  "1\t    \\\?\\\?" \
-  "2\t      \\\?\\\?" \
-  "3\t    \\\?\\\?" \
-  "4\t  test" \
-  "5\tmain" \
-  "6\t  test" \
+  "1\t  test" \
+  "2\t    \\\?\\\?" \
+  "3\t      \\\?\\\?" \
+  "4\t    \\\?\\\?" \
+  "5\t  test" \
+  "6\tmain" \
+  "7\t  test" \
   ] "\r\n"] "indented"
-- 
1.8.3.1

  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 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 13/29] btrace: add replay position to btrace thread info 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 24/29] record-btrace: add record goto target methods Markus Metzger
2013-12-19 16:45 ` [PATCH v9 10/29] btrace: increase buffer size Markus Metzger
2013-12-19 16:45 ` [PATCH v9 25/29] record-btrace: extend unwinder Markus Metzger
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 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 03/29] btrace: uppercase btrace_read_type Markus Metzger
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 04/29] gdbarch: add instruction predicate methods Markus Metzger
2013-12-19 20:19   ` Pedro Alves
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 11/29] record-btrace: optionally indent function call history 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 ` [PATCH v9 12/29] record-btrace: make ranges include begin and end Markus Metzger
2013-12-19 17:29   ` Eli Zaretskii
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 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 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 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 ` Markus Metzger [this message]
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 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 02/29] btrace, linux: fix memory leak when reading branch trace Markus Metzger
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 07/29] btrace: change branch trace data structure 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 15/29] record-btrace: supply register target methods Markus Metzger
2013-12-19 16:45 ` [PATCH v9 26/29] btrace, gdbserver: read branch trace incrementally 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-28-git-send-email-markus.t.metzger@intel.com \
    --to=markus.t.metzger@intel.com \
    --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).