summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2009-10-05 09:14:49 +0200
committerMark Wielaard <mjw@redhat.com>2009-10-05 09:14:49 +0200
commit3e9565715db9be1dd1719a33aa7d341c930aadda (patch)
tree66d7af3df0f564f894b26b4e047f309284c987f8 /testsuite/systemtap.base
parent03ba05b65a2c555d3057006ef490d958bbf07df5 (diff)
downloadsystemtap-steved-3e9565715db9be1dd1719a33aa7d341c930aadda.tar.gz
systemtap-steved-3e9565715db9be1dd1719a33aa7d341c930aadda.tar.xz
systemtap-steved-3e9565715db9be1dd1719a33aa7d341c930aadda.zip
Add tescase for DW_AT_const_value location descriptions.
* testsuite/systemtap.base/const_value.c: New test. * testsuite/systemtap.base/const_value.exp: Likewise. * testsuite/systemtap.base/const_value.stp: Likewise.
Diffstat (limited to 'testsuite/systemtap.base')
-rw-r--r--testsuite/systemtap.base/const_value.c31
-rw-r--r--testsuite/systemtap.base/const_value.exp34
-rw-r--r--testsuite/systemtap.base/const_value.stp6
3 files changed, 71 insertions, 0 deletions
diff --git a/testsuite/systemtap.base/const_value.c b/testsuite/systemtap.base/const_value.c
new file mode 100644
index 00000000..4ff82161
--- /dev/null
+++ b/testsuite/systemtap.base/const_value.c
@@ -0,0 +1,31 @@
+#include "sdt.h"
+
+struct foo
+{
+ const int i;
+ const long j;
+};
+
+typedef struct foo fooer;
+
+static int
+bar (const int i, const long j)
+{
+ return i * j;
+}
+
+// Because of PR10726 we don't want to get this function inlined.
+// We do need -O2 to get the const_value encodings in dwarf.
+static __attribute__((__noinline__)) int
+func (int (*f) ())
+{
+ const fooer baz = { .i = 2, .j = 21 };
+ STAP_PROBE (test, constvalues);
+ return f(baz.i, baz.j);
+}
+
+int
+main (int argc, char *argv[], char *envp[])
+{
+ return func (&bar) - 42;
+}
diff --git a/testsuite/systemtap.base/const_value.exp b/testsuite/systemtap.base/const_value.exp
new file mode 100644
index 00000000..5d5ceaee
--- /dev/null
+++ b/testsuite/systemtap.base/const_value.exp
@@ -0,0 +1,34 @@
+set test "const_value"
+set ::result_string {f: bar
+i: 2
+j: 21}
+
+set test_flags "additional_flags=-g"
+# We need -O2 to get const_value encodings in dwarf.
+set test_flags "$test_flags additional_flags=-O2"
+set test_flags "$test_flags additional_flags=-I$srcdir/../includes/sys"
+
+set res [target_compile $srcdir/$subdir/$test.c $test.exe executable "$test_flags"]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "$test.c compile"
+ untested "$test"
+ return
+} else {
+ pass "$test.c compile"
+}
+
+# Test only when we are running an install test (can execute) and when gcc
+# vta generated DW_AT_const_values for us. We are interested in both blocks
+# and pure constant addresses (technically only the second was added by vta).
+if {[installtest_p] && [uprobes_p]} {
+ set dw_at_c {DW_AT_const_value}
+ if {![catch {exec readelf --debug-dump=info $test.exe | grep "$dw_at_c"}]} {
+ stap_run2 $srcdir/$subdir/$test.stp -c ./$test.exe
+ } {
+ untested "$test (no-gcc-vta)"
+ }
+} else {
+ untested "$test"
+}
+catch {exec rm -f $test.exe}
diff --git a/testsuite/systemtap.base/const_value.stp b/testsuite/systemtap.base/const_value.stp
new file mode 100644
index 00000000..109d3d46
--- /dev/null
+++ b/testsuite/systemtap.base/const_value.stp
@@ -0,0 +1,6 @@
+probe process("const_value.exe").mark("constvalues")
+{
+ printf("f: %s\n", usymname($f));
+ printf("i: %d\n", $baz->i);
+ printf("j: %d\n", $baz->j);
+} \ No newline at end of file