From: markus.t.metzger@intel.com
To: gdb-patches@sourceware.org
Cc: markus.t.metzger@gmail.com, jan.kratochvil@redhat.com,
palves@redhat.com, tromey@redhat.com, kettenis@gnu.org,
Markus Metzger <markus.t.metzger@intel.com>
Subject: [patch v4 11/13] test, btrace: add branch tracing tests
Date: Tue, 27 Nov 2012 10:50:00 -0000 [thread overview]
Message-ID: <1354013351-14791-12-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1354013351-14791-1-git-send-email-markus.t.metzger@intel.com>
From: Markus Metzger <markus.t.metzger@intel.com>
Add tests covering btrace enable/disable/auto and btrace list.
2012-11-27 Markus Metzger <markus.t.metzger@intel.com>
testsuite/
* configure.ac: Add gdb.btrace makefile.
* configure: Regenerated.
* lib/btrace.exp: New file.
* gdb.btrace/Makefile.in: New file.
* gdb.btrace/enable.exp: New file.
* gdb.btrace/list.exp: New file.
* gdb.btrace/x86-list.S: New file.
---
gdb/testsuite/Makefile.in | 3 +-
gdb/testsuite/configure | 3 +-
gdb/testsuite/configure.ac | 2 +-
gdb/testsuite/gdb.btrace/Makefile.in | 13 ++
gdb/testsuite/gdb.btrace/dec.c | 23 ++++
gdb/testsuite/gdb.btrace/enable.exp | 94 +++++++++++++++
gdb/testsuite/gdb.btrace/inc.c | 23 ++++
gdb/testsuite/gdb.btrace/list.exp | 175 ++++++++++++++++++++++++++++
gdb/testsuite/gdb.btrace/list_function.c | 31 +++++
gdb/testsuite/gdb.btrace/list_function.exp | 50 ++++++++
gdb/testsuite/gdb.btrace/x86-list.S | 70 +++++++++++
gdb/testsuite/lib/btrace.exp | 78 ++++++++++++
12 files changed, 562 insertions(+), 3 deletions(-)
create mode 100755 gdb/testsuite/gdb.btrace/Makefile.in
create mode 100644 gdb/testsuite/gdb.btrace/dec.c
create mode 100644 gdb/testsuite/gdb.btrace/enable.exp
create mode 100644 gdb/testsuite/gdb.btrace/inc.c
create mode 100644 gdb/testsuite/gdb.btrace/list.exp
create mode 100644 gdb/testsuite/gdb.btrace/list_function.c
create mode 100644 gdb/testsuite/gdb.btrace/list_function.exp
create mode 100644 gdb/testsuite/gdb.btrace/x86-list.S
create mode 100644 gdb/testsuite/lib/btrace.exp
diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in
index fab124e..62fcd1f 100644
--- a/gdb/testsuite/Makefile.in
+++ b/gdb/testsuite/Makefile.in
@@ -33,7 +33,8 @@ SHELL = @SHELL@
EXEEXT = @EXEEXT@
SUBDIRS = @subdirs@
RPATH_ENVVAR = @RPATH_ENVVAR@
-ALL_SUBDIRS = gdb.ada gdb.arch gdb.asm gdb.base gdb.cell gdb.cp gdb.disasm \
+ALL_SUBDIRS = gdb.ada gdb.arch gdb.asm gdb.base gdb.btrace gdb.cell \
+ gdb.cp gdb.disasm \
gdb.dwarf2 gdb.fortran gdb.gdb gdb.hp \
gdb.java gdb.linespec gdb.mi gdb.modula2 gdb.multi \
gdb.objc gdb.opencl gdb.opt gdb.pascal gdb.python gdb.server \
diff --git a/gdb/testsuite/configure b/gdb/testsuite/configure
index 0c8c344..a40c144 100755
--- a/gdb/testsuite/configure
+++ b/gdb/testsuite/configure
@@ -3448,7 +3448,7 @@ done
-ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.go/Makefile gdb.server/Makefile gdb.java/Makefile gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile gdb.hp/gdb.defects/Makefile gdb.linespec/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
+ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.btrace/Makefile gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.go/Makefile gdb.server/Makefile gdb.java/Makefile gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile gdb.hp/gdb.defects/Makefile gdb.linespec/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -4153,6 +4153,7 @@ do
"gdb.arch/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.arch/Makefile" ;;
"gdb.asm/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.asm/Makefile" ;;
"gdb.base/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.base/Makefile" ;;
+ "gdb.btrace/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.btrace/Makefile" ;;
"gdb.cell/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.cell/Makefile" ;;
"gdb.cp/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.cp/Makefile" ;;
"gdb.disasm/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.disasm/Makefile" ;;
diff --git a/gdb/testsuite/configure.ac b/gdb/testsuite/configure.ac
index d9ab9f7..1884b64 100644
--- a/gdb/testsuite/configure.ac
+++ b/gdb/testsuite/configure.ac
@@ -89,7 +89,7 @@ AC_EXEEXT
AC_OUTPUT([Makefile \
gdb.ada/Makefile \
- gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile \
+ gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.btrace/Makefile \
gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile \
gdb.fortran/Makefile gdb.go/Makefile gdb.server/Makefile gdb.java/Makefile \
gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile \
diff --git a/gdb/testsuite/gdb.btrace/Makefile.in b/gdb/testsuite/gdb.btrace/Makefile.in
new file mode 100755
index 0000000..16afe0a
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/Makefile.in
@@ -0,0 +1,13 @@
+VPATH = @srcdir@
+srcdir = @srcdir@
+
+.PHONY: all clean mostlyclean distclean realclean
+
+all info install-info dvi install uninstall installcheck check:
+ @echo "Nothing to be done for $@..."
+
+clean mostlyclean:
+ -rm -f *.o *.x *.diff *~ *.bad core
+
+distclean maintainer-clean realclean: clean
+ -rm -f Makefile config.status config.log gdb.log gdb.sum
diff --git a/gdb/testsuite/gdb.btrace/dec.c b/gdb/testsuite/gdb.btrace/dec.c
new file mode 100644
index 0000000..5b9187e
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/dec.c
@@ -0,0 +1,23 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright (C) 2012 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/>. */
+
+extern int dec (int x)
+{
+ return x - 1;
+}
diff --git a/gdb/testsuite/gdb.btrace/enable.exp b/gdb/testsuite/gdb.btrace/enable.exp
new file mode 100644
index 0000000..ab4bd0e
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/enable.exp
@@ -0,0 +1,94 @@
+# Copyright 2012 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/>.
+
+if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
+ verbose "Tests ignored for all but x86 based targets."
+ return
+}
+
+load_lib btrace.exp
+
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+
+# automatic enabling can be turned on without an inferior
+gdb_test_no_output "btrace enable auto" "btrace enable 1.0"
+
+# we cannot enable it twice
+gdb_test "btrace enable auto" "Automatic branch trace enabling already on." "btrace enable 1.1"
+
+# but we can disable it
+gdb_test_no_output "btrace disable auto" "btrace enable 1.2"
+
+# we cannot disable it twice
+gdb_test "btrace disable auto" "Automatic branch trace enabling already off." "btrace enable 1.3"
+
+# we cannot enable/disable trace without a thread
+gdb_test "btrace enable" "Couldn't enable branch tracing: no inferior thread." "btrace enable 2.0"
+gdb_test "btrace disable" "Couldn't disable branch tracing: no inferior thread." "btrace enable 2.1"
+
+# we don't have trace, yet
+gdb_test "btrace" "No thread\." "btrace enable 2.2"
+gdb_test "btrace /m" "No thread\." "btrace enable 2.3"
+gdb_test "btrace list /fal" "No thread\." "btrace enable 2.4"
+gdb_test "btrace list /t" "No thread\." "btrace enable 2.5"
+
+set testfile "x86-list"
+
+# start a debuggee program
+if { [set binfile [btrace_assemble ${testfile}]] == "" } {
+ untested ${testfile}.exp
+ return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+# automatic enabling is off.
+if ![runto test_1] {
+ fail "runto test function, 1"
+ return -1
+}
+
+# since we support btrace, we should be able to enable it
+gdb_test_no_output "btrace enable" "btrace enable 3.0"
+
+# btrace is now enabled; we should not be able to enable it twice
+gdb_test "btrace enable" "Branch tracing already enabled.*" "btrace enable 3.1"
+
+# btrace is still enabled; we should be able to disable it
+gdb_test_no_output "btrace disable" "btrace enable 3.2"
+
+# btrace is now disabled; we should not be able to disable it twice
+gdb_test "btrace disable" "Branch tracing not enabled.*" "btrace enable 3.3"
+
+# rerun with automatic enabling on
+gdb_test_no_output "btrace enable auto"
+if ![runto test_1] {
+ fail "runto test function, 2"
+ return -1
+}
+
+# btrace is implicitly enabled; we should not be able to enable it twice
+gdb_test "btrace enable" "Branch tracing already enabled.*" "btrace enable 4.0"
+
+return 0
diff --git a/gdb/testsuite/gdb.btrace/inc.c b/gdb/testsuite/gdb.btrace/inc.c
new file mode 100644
index 0000000..a012268
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/inc.c
@@ -0,0 +1,23 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright (C) 2012 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/>. */
+
+extern int inc (int x)
+{
+ return x + 1;
+}
diff --git a/gdb/testsuite/gdb.btrace/list.exp b/gdb/testsuite/gdb.btrace/list.exp
new file mode 100644
index 0000000..169764c
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/list.exp
@@ -0,0 +1,175 @@
+# Copyright 2012 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/>.
+
+if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
+ verbose "Tests ignored for all but x86 based targets."
+ return
+}
+
+load_lib btrace.exp
+
+set testfile "x86-list"
+
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+if { [set binfile [btrace_assemble ${testfile}]] == "" } {
+ untested ${testfile}.exp
+ return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+# Automatically enable branch tracing.
+gdb_test_no_output "btr enable auto"
+
+# Make sure we don't die when enabling trace for a newly created thread.
+if ![runto test_1] {
+ fail "runto test function, 1"
+ return -1
+}
+
+# we expect some trace at this point, but we don't really know how much or how
+# it would look like. Ignore it.
+
+# Reset branch trace so we get predictable output.
+btrace_reset_trace
+
+gdb_test "stepi" "0x0*400200 in test_1_sub.*" ""
+
+gdb_test "btr list /af" "
+1 *0x0*400200 - 0x0*400200 in test_1_sub \\(\\)" "btrace list 1.1"
+
+# We assume 5 bytes for call.
+gdb_test "stepi" "0x0*400215 in test_1.*" ""
+
+# We assume 5 bytes for call.
+gdb_test "btr list /af" "
+1 *0x0*400215 - 0x0*400215 in test_1 \\(\\)\r
+2 *0x0*400200 - 0x0*400200 in test_1_sub \\(\\)" "btrace list 1.2"
+
+gdb_test "stepi" "0x0*400200 in test_1_sub.*" ""
+gdb_test "stepi" "0x0*40021a in test_1.*" ""
+
+# We assume 5 bytes for call.
+gdb_test "btr list /af" "
+1 *0x0*40021a - 0x0*40021a in test_1 \\(\\)\r
+2 *0x0*400200 - 0x0*400200 in test_1_sub \\(\\)\r
+3 *0x0*400215 - 0x0*400215 in test_1 \\(\\)\r
+4 *0x0*400200 - 0x0*400200 in test_1_sub \\(\\)" "btrace list 1.3"
+
+# List a single block.
+gdb_test "btr list /af 2" "
+2 *0x0*400200 - 0x0*400200 in test_1_sub \\(\\)" "btrace list 1.4"
+
+# List a range of blocks.
+gdb_test "btr list /af 2-4" "
+2 *0x0*400200 - 0x0*400200 in test_1_sub \\(\\)\r
+3 *0x0*400215 - 0x0*400215 in test_1 \\(\\)\r
+4 *0x0*400200 - 0x0*400200 in test_1_sub \\(\\)" "btrace list 1.5"
+
+# We ignore too big upper bounds.
+gdb_test "btr list /af 3-9" "
+3 *0x0*400215 - 0x0*400215 in test_1 \\(\\)\r
+4 *0x0*400200 - 0x0*400200 in test_1_sub \\(\\)" "btrace list 1.6"
+
+# If the entire range is out of bounds, the list is empty.
+gdb_test "btr list /a 9-18" "" "btrace list 1.7"
+
+# Check modifiers individually
+gdb_test "btr list /a 2" "
+2 *0x0*400200 - 0x0*400200" "btrace list 1.8"
+
+gdb_test "btr list /f 2" "
+2 *in test_1_sub \\(\\)" "btrace list 1.9"
+
+# Check order of modifiers
+gdb_test "btr list /fa 2" "
+2 *0x0*400200 - 0x0*400200 in test_1_sub \\(\\)" "btrace list 1.10"
+
+gdb_test "btr list /f /a 2" "
+2 *0x0*400200 - 0x0*400200 in test_1_sub \\(\\)" "btrace list 1.11"
+
+gdb_test "btr list /a /f 2" "
+2 *0x0*400200 - 0x0*400200 in test_1_sub \\(\\)" "btrace list 1.12"
+
+
+# Proceed to the next test.
+gdb_breakpoint "test_2"
+gdb_continue_to_breakpoint "proceed to test 2" ".*test_2.*"
+
+# Reset branch trace so we get predictable output.
+btrace_reset_trace
+
+# We assume 1 byte for nop.
+gdb_test "stepi" "0x0*400231 in test_2.*" ""
+
+# We have not seen a branch, yet, so there is no trace.
+gdb_test "btr list" "No trace\." "btrace list 2.1"
+
+gdb_test "stepi" "0x0*400220 in test_2_sub.*" ""
+
+gdb_test "btr list /af" "
+1 *0x0*400220 - 0x0*400220 in test_2_sub \\(\\)" "btrace list 2.2"
+
+# We assume 1 byte for nop.
+gdb_test "stepi" "0x0*400221 in test_2_sub.*" ""
+
+# We assume 1 byte for nop.
+gdb_test "btr list /af" "
+1 *0x0*400220 - 0x0*400221 in test_2_sub \\(\\)" "btrace list 2.3"
+
+# We assume 1 byte for nop.
+gdb_test "stepi" "0x0*400222 in test_2_sub.*" ""
+
+# We assume 1 byte for nop.
+gdb_test "btr list /af" "
+1 *0x0*400220 - 0x0*400222 in test_2_sub \\(\\)" "btrace list 2.4"
+
+
+# Proceed to the next test.
+gdb_breakpoint "test_3"
+gdb_continue_to_breakpoint "proceed to test 3" ".*test_3.*"
+
+# Reset branch trace so we get predictable output.
+btrace_reset_trace
+
+gdb_test "stepi" "0x0*400260 in test_3.*" ""
+
+gdb_test "btr list /af" "
+1 *0x0*400260 - 0x0*400260 in test_3 \\(\\)" "btrace list 3.1"
+
+gdb_test "stepi" "0x0*400250 in test_3.*" ""
+
+gdb_test "btr list /af" "
+1 *0x0*400250 - 0x0*400250 in test_3 \\(\\)\r
+2 *0x0*400260 - 0x0*400260 in test_3 \\(\\)" "btrace list 3.2"
+
+# We assume 1 byte for nop.
+gdb_test "stepi" "0x0*400251 in test_3.*" ""
+
+# We assume 1 byte for nop.
+gdb_test "btr list /af" "
+1 *0x0*400250 - 0x0*400251 in test_3 \\(\\)\r
+2 *0x0*400260 - 0x0*400260 in test_3 \\(\\)" "btrace list 3.3"
+
+return 0
diff --git a/gdb/testsuite/gdb.btrace/list_function.c b/gdb/testsuite/gdb.btrace/list_function.c
new file mode 100644
index 0000000..b10ab34
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/list_function.c
@@ -0,0 +1,31 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright (C) 2012 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/>. */
+
+extern int inc (int);
+extern int dec (int);
+
+extern int main (void)
+{
+ int x = 0;
+
+ x = inc (x);
+ x = dec (x);
+
+ return x; /* bp.1 */
+}
diff --git a/gdb/testsuite/gdb.btrace/list_function.exp b/gdb/testsuite/gdb.btrace/list_function.exp
new file mode 100644
index 0000000..c108b13
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/list_function.exp
@@ -0,0 +1,50 @@
+# Copyright 2012 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/>.
+
+load_lib btrace.exp
+
+set testfile "list_function"
+set sources [list $testfile.c inc.c dec.c]
+
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+if [prepare_for_testing list_function.exp $testfile.x $sources {debug}] {
+ untested list_function.exp
+ return -1
+}
+
+if ![runto_main] then {
+ fail "runto test function, 1"
+ return -1
+}
+
+set bp_location [gdb_get_line_number "bp.1" $testfile.c]
+
+gdb_breakpoint $bp_location
+
+gdb_test_no_output "btr enable"
+
+gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*"
+
+gdb_test "btr list /f" "
+1 *in main \\(\\)\r
+2 *in dec \\(\\)\r
+3 *in main \\(\\)\r
+4 *in inc \\(\\)" "btrace list function 1.0"
+
+return 0
diff --git a/gdb/testsuite/gdb.btrace/x86-list.S b/gdb/testsuite/gdb.btrace/x86-list.S
new file mode 100644
index 0000000..7956db2
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/x86-list.S
@@ -0,0 +1,70 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2012 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/>.
+
+ .text
+ .globl _start
+ .globl main
+ .globl test_1
+ .globl test_2
+ .globl test_3
+ .align 0x100 # 0x400100
+_start:
+ call main
+ hlt
+
+ .align 0x10 # 0x400110
+main:
+ call test_1
+ call test_2
+ call test_3
+ ret
+
+ .align 0x100 # 0x400200
+test_1_sub:
+ ret
+
+ .align 0x10 # 0x400210
+test_1:
+ call test_1_sub
+ call test_1_sub
+ nop
+ ret
+
+ .align 0x10 # 0x400220
+test_2_sub:
+ nop
+ nop
+ ret
+
+ .align 0x10 # 0x400230
+test_2:
+ nop
+ call test_2_sub
+ ret
+
+ .align 0x10 # 0x400240
+test_3:
+ jmp .L3.1
+ .align 0x10 # 0x400250
+.L3.2:
+ nop
+ ret
+ .align 0x10 # 0x400260
+.L3.1:
+ jmp .L3.2
diff --git a/gdb/testsuite/lib/btrace.exp b/gdb/testsuite/lib/btrace.exp
new file mode 100644
index 0000000..eb516fa
--- /dev/null
+++ b/gdb/testsuite/lib/btrace.exp
@@ -0,0 +1,78 @@
+# Copyright 2012 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/>.
+
+proc btrace_assemble { testfile } {
+ global srcdir
+ global objdir
+ global subdir
+
+ set srcfile ${srcdir}/${subdir}/${testfile}.S
+ set objfile ${objdir}/${subdir}/${testfile}.o
+ set binfile ${objdir}/${subdir}/${testfile}.x
+
+ if {[target_assemble ${srcfile} ${objfile} ""] != ""} { return "" }
+
+ if {[target_link ${objfile} ${binfile} "-Ttext 0x400100"] != ""} { return "" }
+
+ return ${binfile}
+}
+
+proc skip_btrace_tests {} {
+ global gdb_prompt
+
+ set testfile "x86-list"
+ set skip 0
+
+ if { [set binfile [btrace_assemble ${testfile}]] == "" } {
+ return 1
+ }
+
+ gdb_exit
+ gdb_start
+ gdb_load $binfile
+
+ runto main
+
+ gdb_test_multiple "btrace enable" "check btrace support" {
+ -re "You can't do that when your target is.*\r\n$gdb_prompt $" {
+ xfail "check btrace support"
+ set skip 1
+ }
+ -re "Target does not support branch tracing.*\r\n$gdb_prompt $" {
+ xfail "check btrace support"
+ set skip 1
+ }
+ -re "Could not enable branch tracing.*\r\n$gdb_prompt $" {
+ xfail "check btrace support"
+ set skip 1
+ }
+ -re "$gdb_prompt $" {
+ pass "check btrace support"
+ }
+ }
+ gdb_exit
+ remote_file build delete $testfile
+
+ return $skip
+}
+
+proc btrace_reset_trace {} {
+ gdb_test_no_output "btr disable"
+ gdb_test_no_output "btr enable"
+
+ gdb_test "btr list" "No trace." "reset btrace"
+}
--
1.7.1
next prev parent reply other threads:[~2012-11-27 10:50 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-27 10:50 [patch v4 00/13] branch tracing support for Atom markus.t.metzger
2012-11-27 10:49 ` [patch v4 03/13] cli, btrace: add btrace cli markus.t.metzger
2012-11-27 21:53 ` Tom Tromey
2012-11-30 15:09 ` Metzger, Markus T
2012-11-30 15:16 ` Jan Kratochvil
2012-11-30 15:23 ` Metzger, Markus T
2012-11-27 10:49 ` [patch v4 01/13] disas: add precise instructions flag markus.t.metzger
2012-11-27 16:49 ` Pedro Alves
2012-11-27 16:52 ` Jan Kratochvil
2012-11-27 16:56 ` Pedro Alves
2012-11-27 17:26 ` Metzger, Markus T
2012-11-27 17:33 ` Pedro Alves
2012-11-28 14:44 ` Metzger, Markus T
2012-11-27 10:50 ` [patch v4 12/13] test, btrace: more branch tracing tests markus.t.metzger
2012-11-27 10:50 ` [patch v4 07/13] xml, btrace: define btrace xml document style markus.t.metzger
2012-11-28 18:53 ` Pedro Alves
2012-12-04 10:35 ` Metzger, Markus T
2012-11-27 10:50 ` [patch v4 04/13] configure: add check for perf_event header markus.t.metzger
2012-11-28 10:11 ` Pedro Alves
2012-11-28 14:52 ` Metzger, Markus T
2012-11-28 14:55 ` Pedro Alves
2012-11-27 10:50 ` [patch v4 08/13] remote, btrace: add branch trace remote ops markus.t.metzger
2012-11-28 19:23 ` Pedro Alves
2012-12-04 12:47 ` Metzger, Markus T
2012-11-27 10:50 ` [patch v4 06/13] linux, i386, amd64: enable btrace for 32bit and 64bit linux native markus.t.metzger
2012-11-28 18:40 ` Pedro Alves
2012-12-03 16:24 ` Metzger, Markus T
2012-11-27 10:50 ` [patch v4 13/13] btrace, x86: restrict to Atom markus.t.metzger
2012-11-27 11:19 ` Mark Kettenis
2012-11-27 11:49 ` Metzger, Markus T
2012-11-27 14:42 ` Mark Kettenis
2012-11-27 15:14 ` Metzger, Markus T
2012-11-27 15:32 ` Pedro Alves
2012-11-27 13:05 ` Jan Kratochvil
2012-11-27 14:04 ` Metzger, Markus T
2012-11-27 14:29 ` Jan Kratochvil
2012-11-27 15:14 ` Metzger, Markus T
2012-11-27 15:50 ` Pedro Alves
2012-11-27 15:54 ` Metzger, Markus T
2012-12-06 10:15 ` Metzger, Markus T
2012-11-27 10:50 ` markus.t.metzger [this message]
2012-11-27 10:50 ` [patch v4 05/13] linux, btrace: perf_event based branch tracing markus.t.metzger
2012-11-28 17:31 ` Pedro Alves
2012-12-03 14:38 ` Metzger, Markus T
2012-11-27 10:50 ` [patch v4 09/13] gdbserver, btrace: add generic btrace support markus.t.metzger
2012-11-28 20:32 ` Pedro Alves
2012-12-04 14:50 ` Metzger, Markus T
2012-11-27 10:50 ` [patch v4 10/13] gdbserver, linux, btrace: add btrace support for linux-low markus.t.metzger
2012-11-28 20:44 ` Pedro Alves
2012-12-05 9:27 ` Metzger, Markus T
2012-11-27 10:50 ` [patch v4 02/13] thread, btrace: add generic branch trace support markus.t.metzger
2012-11-27 18:32 ` Pedro Alves
2012-11-27 18:38 ` Pedro Alves
2012-11-28 0:41 ` Pedro Alves
2012-11-29 16:39 ` Metzger, Markus T
2012-11-27 13:11 ` [patch v4 00/13] branch tracing support for Atom Jan Kratochvil
2012-11-27 14:26 ` Metzger, Markus T
2012-11-27 14:32 ` Jan Kratochvil
2012-11-27 14:40 ` Metzger, Markus T
2012-11-27 15:36 ` Jan Kratochvil
2012-11-27 16:17 ` Metzger, Markus T
2012-11-27 16:28 ` Jan Kratochvil
2012-11-27 17:30 ` Metzger, Markus T
2012-11-27 18:31 ` Jan Kratochvil
2012-11-27 18:56 ` Markus Metzger
2012-11-28 19:01 ` Jan Kratochvil
2012-11-29 9:13 ` Metzger, Markus T
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=1354013351-14791-12-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=kettenis@gnu.org \
--cc=markus.t.metzger@gmail.com \
--cc=palves@redhat.com \
--cc=tromey@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