aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.trace/stap-trace.exp
diff options
context:
space:
mode:
authorSergio Durigan Junior <sergiodj@redhat.com>2012-04-27 20:52:06 +0000
committerSergio Durigan Junior <sergiodj@redhat.com>2012-04-27 20:52:06 +0000
commit62e5f89c34f8c206917617978d156da4efb750df (patch)
tree03e070649e0436121c7549c6666363eb77df25dd /gdb/testsuite/gdb.trace/stap-trace.exp
parent28106bc2feb5553aede17c93fcb01c08bf935ad1 (diff)
downloadgdb-62e5f89c34f8c206917617978d156da4efb750df.zip
gdb-62e5f89c34f8c206917617978d156da4efb750df.tar.gz
gdb-62e5f89c34f8c206917617978d156da4efb750df.tar.bz2
gdb/doc/ChangeLog:
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> * gdb.texinfo (Static Probe Points): New entry, explaining SystemTap and generic static probe support on GDB. gdb/testsuite/ChangeLog: 2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> * gdb.base/default.exp: Add `$_probe_arg*' convenience variables. * gdb.base/stap-probe.c: New file. * gdb.base/stap-probe.exp: New file. * gdb.trace/stap-trace.c: New file. * gdb.trace/stap-trace.exp: New file. * gdb.cp/nextoverthrow.exp: Add check for SystemTap probe in libgcc's unwinder.
Diffstat (limited to 'gdb/testsuite/gdb.trace/stap-trace.exp')
-rw-r--r--gdb/testsuite/gdb.trace/stap-trace.exp128
1 files changed, 128 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.trace/stap-trace.exp b/gdb/testsuite/gdb.trace/stap-trace.exp
new file mode 100644
index 0000000..562eec4
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/stap-trace.exp
@@ -0,0 +1,128 @@
+# Copyright 2012 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 <http://www.gnu.org/licenses/>.
+
+load_lib "trace-support.exp"
+
+set testfile "stap-trace"
+set srcfile ${testfile}.c
+set executable ""
+set binfile_dir $objdir/$subdir
+
+set ws "\[\r\n\t \]+"
+set cr "\[\r\n\]+"
+
+# Only x86 and x86_64 targets are supported for now.
+
+if { ![istarget "x86_64-*"] && ![istarget "i?86-*"] } {
+ continue
+}
+
+proc compile_stap_bin {exec_name {arg ""}} {
+ global srcfile
+ global binfile_dir
+ global srcdir
+ global subdir
+ global executable
+
+ if { $arg != "" } {
+ set arg "additional_flags=$arg"
+ }
+
+ set executable ${exec_name}
+
+ if { [gdb_compile "$srcdir/$subdir/$srcfile" \
+ "$binfile_dir/$exec_name" \
+ executable [concat $arg debug nowarnings]] != "" } {
+ untested "Could not compile ${srcfile}"
+ return -1
+ }
+}
+
+proc prepare_for_trace_test {} {
+ global executable
+
+ clean_restart $executable
+
+ if { ![runto_main] } {
+ perror "Could not run to `main'."
+ continue
+ }
+
+ gdb_breakpoint [gdb_get_line_number "end-here"]
+}
+
+proc run_trace_experiment { test_probe msg } {
+ global gdb_prompt
+
+ set test "collect $msg: start trace experiment"
+ gdb_test_multiple "tstart" "$test" {
+ -re "^tstart\r\n$gdb_prompt $" {
+ pass "$test"
+ }
+ }
+
+ gdb_test "continue" \
+ "Continuing.*Breakpoint \[0-9\]+.*" \
+ "collect $msg: run trace experiment"
+ gdb_test "tstop" \
+ "\[\r\n\]+" \
+ "collect $msg: stop trace experiment"
+ gdb_test "tfind start" \
+ "#0 .*" \
+ "collect $msg: tfind test frame"
+}
+
+proc gdb_collect_probe_arg { msg probe val_arg0 } {
+ global gdb_prompt
+ global cr
+
+ prepare_for_trace_test
+
+ gdb_test "trace $probe" \
+ "Tracepoint \[0-9\]+ at .*" \
+ "collect $msg: set tracepoint"
+ gdb_trace_setactions "collect $msg: define actions" \
+ "" \
+ "collect \$_probe_arg0" "^$"
+
+ # Begin the test.
+ run_trace_experiment $msg $probe
+
+ gdb_test "print \$_probe_arg0" \
+ "\\$\[0-9\]+ = $val_arg0$cr" \
+ "collect $msg: collected probe arg0"
+}
+
+compile_stap_bin "stap-probe-nosem"
+
+clean_restart $executable
+if { ![runto_main] } {
+ perror "Could not run to `main'."
+ continue
+}
+
+if { ![gdb_target_supports_trace] } {
+ # Test cannot run on this target.
+ return 1;
+}
+
+gdb_collect_probe_arg "probe args without semaphore" "-probe-stap user" "23"
+gdb_exit
+
+compile_stap_bin "stap-probe-sem" "-DUSE_PROBES"
+gdb_collect_probe_arg "probe args with semaphore" "-probe-stap two" "46"
+
+# Finished!
+gdb_test "tfind none" ".*" ""