summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-11-17 18:59:47 -0800
committerJosh Stone <jistone@redhat.com>2009-11-17 19:08:05 -0800
commit2e66901da2ffed2261784f458a2fc57d6f059725 (patch)
treee70baeadf0dbc09c879c81a381a8ab4560994731 /testsuite/systemtap.base
parent1b0350b522d4fe24ed1922602a60eab6f96c305d (diff)
downloadsystemtap-steved-2e66901da2ffed2261784f458a2fc57d6f059725.tar.gz
systemtap-steved-2e66901da2ffed2261784f458a2fc57d6f059725.tar.xz
systemtap-steved-2e66901da2ffed2261784f458a2fc57d6f059725.zip
Test cross-CU type discovery
Check that we can dereference a type declaration that is defined in a separate CU from the function.
Diffstat (limited to 'testsuite/systemtap.base')
-rw-r--r--testsuite/systemtap.base/cu-decl-1.c17
-rw-r--r--testsuite/systemtap.base/cu-decl-2.c10
-rw-r--r--testsuite/systemtap.base/cu-decl.exp23
3 files changed, 50 insertions, 0 deletions
diff --git a/testsuite/systemtap.base/cu-decl-1.c b/testsuite/systemtap.base/cu-decl-1.c
new file mode 100644
index 00000000..9743d298
--- /dev/null
+++ b/testsuite/systemtap.base/cu-decl-1.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+struct foo;
+struct foo* get_foo(void);
+
+void
+print(struct foo* f)
+{
+ printf("%p\n", f);
+}
+
+int
+main()
+{
+ print(get_foo());
+ return 0;
+}
diff --git a/testsuite/systemtap.base/cu-decl-2.c b/testsuite/systemtap.base/cu-decl-2.c
new file mode 100644
index 00000000..46503251
--- /dev/null
+++ b/testsuite/systemtap.base/cu-decl-2.c
@@ -0,0 +1,10 @@
+struct foo {
+ int x, y;
+};
+
+struct foo*
+get_foo()
+{
+ static struct foo f = { 6, 7 };
+ return &f;
+}
diff --git a/testsuite/systemtap.base/cu-decl.exp b/testsuite/systemtap.base/cu-decl.exp
new file mode 100644
index 00000000..42e683cb
--- /dev/null
+++ b/testsuite/systemtap.base/cu-decl.exp
@@ -0,0 +1,23 @@
+# Check that we can dereference a type declaration that is
+# defined in a separate CU from the function.
+set test "cu-decl"
+
+set script {
+ probe process("cu-decl").function("print") {
+ println($f->x * $f->y)
+ }
+}
+
+set sources "$srcdir/$subdir/$test-1.c $srcdir/$subdir/$test-2.c"
+set res [target_compile $sources $test executable "additional_flags=-g"]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "$test target compilation"
+ untested "$test"
+} else {
+ pass "$test target compilation"
+}
+
+stap_compile $test 1 "{$script}"
+
+catch {exec rm $test}