From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14226 invoked by alias); 17 Dec 2012 16:02:32 -0000 Received: (qmail 14138 invoked by uid 22791); 17 Dec 2012 16:02:28 -0000 X-SWARE-Spam-Status: No, hits=-7.8 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 17 Dec 2012 16:02:13 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 17 Dec 2012 08:02:12 -0800 X-ExtLoop1: 1 Received: from swsutil001.isw.intel.com ([10.237.237.11]) by fmsmga002.fm.intel.com with ESMTP; 17 Dec 2012 08:01:57 -0800 Received: from ulslx001.iul.intel.com (ulslx001.iul.intel.com [172.28.207.63]) by swsutil001.isw.intel.com (8.13.6/8.13.6/MailSET/Hub) with ESMTP id qBHG1uWX019718; Mon, 17 Dec 2012 16:01:56 GMT Received: from ulslx001.iul.intel.com (localhost [127.0.0.1]) by ulslx001.iul.intel.com with ESMTP id qBHG1uS1026546; Mon, 17 Dec 2012 17:01:56 +0100 Received: (from mmetzger@localhost) by ulslx001.iul.intel.com with id qBHG1uCi026542; Mon, 17 Dec 2012 17:01:56 +0100 From: markus.t.metzger@intel.com To: jan.kratochvil@redhat.com, palves@redhat.com, tromey@redhat.com, kettenis@gnu.org Cc: gdb-patches@sourceware.org, markus.t.metzger@gmail.com, Markus Metzger Subject: [patch v6 10/12] test, btrace: add branch tracing tests Date: Mon, 17 Dec 2012 16:03:00 -0000 Message-Id: <1355760101-26237-11-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1355760101-26237-1-git-send-email-markus.t.metzger@intel.com> References: <1355760101-26237-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-12/txt/msg00567.txt.bz2 From: Markus Metzger Add tests covering btrace enable/disable/auto and btrace list. 2012-12-17 Markus Metzger 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 | 89 ++++++++++++++ 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, 557 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. . + + 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 . */ + +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..3ddaf2c --- /dev/null +++ b/gdb/testsuite/gdb.btrace/enable.exp @@ -0,0 +1,89 @@ +# Copyright 2012 Free Software Foundation, Inc. +# +# Contributed by Intel Corp. +# +# 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 . + +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" + +# enabling is idempotent +gdb_test_no_output "btrace enable auto" "btrace enable 1.1" + +# we can disable it +gdb_test_no_output "btrace disable auto" "btrace enable 1.2" + +# disabling is also idempotent +gdb_test_no_output "btrace disable auto" "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" + +# enabling is idempotent +gdb_test_no_output "btrace enable" "btrace enable 3.1" + +# we should be able to disable it +gdb_test_no_output "btrace disable" "btrace enable 3.2" + +# disabling is idempotent, as well +gdb_test_no_output "btrace disable" "btrace enable 3.3" + +# we don't have trace, yet +gdb_test "btrace" "No trace\." "btrace enable 3.0" +gdb_test "btrace /m" "No trace\." "btrace enable 3.1" +gdb_test "btrace list" "No trace\." "btrace enable 3.2" + +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. . + + 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 . */ + +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..0e88f8b --- /dev/null +++ b/gdb/testsuite/gdb.btrace/list.exp @@ -0,0 +1,175 @@ +# Copyright 2012 Free Software Foundation, Inc. +# +# Contributed by Intel Corp. +# +# 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 . + +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. . + + 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 . */ + +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..180273f --- /dev/null +++ b/gdb/testsuite/gdb.btrace/list_function.exp @@ -0,0 +1,50 @@ +# Copyright 2012 Free Software Foundation, Inc. +# +# Contributed by Intel Corp. +# +# 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 . + +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. +# +# 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 . + + .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. +# +# 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 . + +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.6.5