This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] New test case for static tracepoint


Here is a new test case for static tracepoint.  The test case is
compiled with UST 0.11, the latest release with GDB support.

OK for mainline?

-- 
Yao (éå)
gdb/testsuite/

2011-12-12  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/strace.c: New
	* gdb.trace/strace.exp: New.
---
 gdb/testsuite/gdb.trace/strace.c   |   32 ++++++++++
 gdb/testsuite/gdb.trace/strace.exp |  118 ++++++++++++++++++++++++++++++++++++
 2 files changed, 150 insertions(+), 0 deletions(-)
 create mode 100644 gdb/testsuite/gdb.trace/strace.c
 create mode 100644 gdb/testsuite/gdb.trace/strace.exp

diff --git a/gdb/testsuite/gdb.trace/strace.c b/gdb/testsuite/gdb.trace/strace.c
new file mode 100644
index 0000000..cec4c14
--- /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 <http://www.gnu.org/licenses/>.  */
+
+#include <ust/marker.h>
+
+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 0000000..51a9f56
--- /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 <http://www.gnu.org/licenses/>.
+
+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
-- 
1.7.0.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]