From: Yao Qi Date: Thu, 15 Dec 2011 12:43:03 +0000 (+0000) Subject: gdb/testsuite/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1576bd00ee92a0d0ebd9191ac84a12fd9dde757d;p=binutils-gdb.git gdb/testsuite/ * gdb.trace/strace.c: New * gdb.trace/strace.exp: New. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4db009e4447..c432e2b539d 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-12-15 Yao Qi + + * gdb.trace/strace.c: New + * gdb.trace/strace.exp: New. + 2011-12-14 Tom Tromey * gdb.dwarf2/dw2-inline-param.exp: Log the objcopy command. diff --git a/gdb/testsuite/gdb.trace/strace.c b/gdb/testsuite/gdb.trace/strace.c new file mode 100644 index 00000000000..cec4c14d347 --- /dev/null +++ b/gdb/testsuite/gdb.trace/strace.c @@ -0,0 +1,32 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011 Free Software Foundation, Inc. + + 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 . */ + +#include + +static void +end (void) +{} + +int +main (void) +{ + trace_mark(ust, bar, "str %s", "FOOBAZ"); + trace_mark(ust, bar2, "number1 %d number2 %d", 53, 9800); + + end (); + return 0; +} diff --git a/gdb/testsuite/gdb.trace/strace.exp b/gdb/testsuite/gdb.trace/strace.exp new file mode 100644 index 00000000000..51a9f5666cc --- /dev/null +++ b/gdb/testsuite/gdb.trace/strace.exp @@ -0,0 +1,118 @@ +# Copyright 2011 Free Software Foundation, Inc. +# 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 "trace-support.exp"; + +if $tracelevel then { + strace $tracelevel +} + +if {[skip_shlib_tests]} { + return 0 +} + +set testfile "strace" +set srcfile $testfile.c +set binfile $objdir/$subdir/$testfile +set executable $testfile + +set libipa $objdir/../gdbserver/libinproctrace.so + +set lib_opts debug + +if [get_compiler_info ${binfile}] { + return -1 +} + +set additional_flags [list debug shlib=$libipa shlib_load "additional_flags=-lust -lurcu-bp" ] + +if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags] != ""} { + untested "UST library or headers are not installed" + return -1 +} + +clean_restart $executable + +if ![runto_main] { + fail "Can't run to main to check for trace support" + return -1 +} + +if { ![gdb_target_supports_trace] } then { + unsupported "Current target does not support trace" + return -1; +} + +gdb_load_shlibs $libipa + +proc strace_info_marker { } { + global executable + global pf_prefix + + set old_pf_prefix $pf_prefix + lappend pf_prefix "info_marker" + + # Restart with a fresh gdb. + clean_restart $executable + if ![runto_main] { + fail "Can't run to main" + set pf_prefix $old_pf_prefix + return -1 + } + + # List the markers in program. They should be disabled. + gdb_test "info static-tracepoint-markers" \ + ".*ust/bar\[\t \]+n\[\t \]+.*ust/bar2\[\t \]+n\[\t \]+.*" + + set pf_prefix $old_pf_prefix +} + +proc strace_probe_marker { } { + global executable + global pf_prefix + global expect_out + global gdb_prompt + global hex + + set old_pf_prefix $pf_prefix + lappend pf_prefix "probe_marker" + + # Restart with a fresh gdb. + clean_restart $executable + if ![runto_main] { + fail "Can't run to main" + set pf_prefix $old_pf_prefix + return -1 + } + + gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*" + gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*" + # Two trace markers should be enabled. + gdb_test "info static-tracepoint-markers" "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*" + + gdb_test "break end" "Breakpoint \[0-9\]+ at.*" + + gdb_test_no_output "tstart" + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" + gdb_test_no_output "tstop" + + gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0" + gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1" + gdb_test "tfind" "Target failed to find requested trace frame\\..*" + + set pf_prefix $old_pf_prefix +} + +strace_info_marker +strace_probe_marker