From 3e9565715db9be1dd1719a33aa7d341c930aadda Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 5 Oct 2009 09:14:49 +0200 Subject: 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. --- testsuite/systemtap.base/const_value.c | 31 +++++++++++++++++++++++++++++ testsuite/systemtap.base/const_value.exp | 34 ++++++++++++++++++++++++++++++++ testsuite/systemtap.base/const_value.stp | 6 ++++++ 3 files changed, 71 insertions(+) create mode 100644 testsuite/systemtap.base/const_value.c create mode 100644 testsuite/systemtap.base/const_value.exp create mode 100644 testsuite/systemtap.base/const_value.stp (limited to 'testsuite/systemtap.base') 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 -- cgit From 5aa987f2edc5c60b61d66fc0e5b7e0fb33423586 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 6 Oct 2009 15:22:21 +0200 Subject: PR10739 testcase. Split const_value test in two. Absolute const addr fails. * testsuite/systemtap.base/const_value.exp: Handle both const_value blocks and address separately. XFAIL second test as PR10739. * testsuite/systemtap.base/const_value.stp: Only query baz const value. * testsuite/systemtap.base/const_value_func.c: New test for bar address. * testsuite/systemtap.base/const_value_func.stp: Likewise. --- testsuite/systemtap.base/const_value.exp | 48 +++++++++++++++++++++++---- testsuite/systemtap.base/const_value.stp | 1 - testsuite/systemtap.base/const_value_func.c | 22 ++++++++++++ testsuite/systemtap.base/const_value_func.stp | 4 +++ 4 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 testsuite/systemtap.base/const_value_func.c create mode 100644 testsuite/systemtap.base/const_value_func.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/const_value.exp b/testsuite/systemtap.base/const_value.exp index 5d5ceaee..afffebca 100644 --- a/testsuite/systemtap.base/const_value.exp +++ b/testsuite/systemtap.base/const_value.exp @@ -1,6 +1,6 @@ +# DW_AT_const_value (blocks). set test "const_value" -set ::result_string {f: bar -i: 2 +set ::result_string {i: 2 j: 21} set test_flags "additional_flags=-g" @@ -18,17 +18,53 @@ if { $res != "" } { 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). +# Test only when we are running an install test (can execute) and when +# gcc generated DW_AT_const_values for us. We are interested in block +# constant values. 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)" + untested "$test (no-const-value)" } } else { untested "$test" } catch {exec rm -f $test.exe} + + +# DW_AT_const_value (address). +set test "const_value_func" +set ::result_string {f: bar} + +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 generated DW_AT_const_values for us. We are interested in pure +# constant addresses. +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"}]} { + setup_xfail 10739 "*-*-*" + stap_run2 $srcdir/$subdir/$test.stp -c ./$test.exe + } { + untested "$test (no-const-value)" + } +} else { + untested "$test" +} +catch {exec rm -f $test.exe} \ No newline at end of file diff --git a/testsuite/systemtap.base/const_value.stp b/testsuite/systemtap.base/const_value.stp index 109d3d46..7aded0f2 100644 --- a/testsuite/systemtap.base/const_value.stp +++ b/testsuite/systemtap.base/const_value.stp @@ -1,6 +1,5 @@ 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 diff --git a/testsuite/systemtap.base/const_value_func.c b/testsuite/systemtap.base/const_value_func.c new file mode 100644 index 00000000..23f2f0bc --- /dev/null +++ b/testsuite/systemtap.base/const_value_func.c @@ -0,0 +1,22 @@ +#include "sdt.h" + +static int +bar (int i, long j) +{ + return i * j; +} + +static int +func (int (*f) ()) +{ + volatile int i = 2; + volatile long j = 21; + STAP_PROBE (test, constvalues); + return f(i, j); +} + +int +main (int argc, char *argv[], char *envp[]) +{ + return func (&bar) - 42; +} diff --git a/testsuite/systemtap.base/const_value_func.stp b/testsuite/systemtap.base/const_value_func.stp new file mode 100644 index 00000000..9dad9150 --- /dev/null +++ b/testsuite/systemtap.base/const_value_func.stp @@ -0,0 +1,4 @@ +probe process("const_value_func.exe").mark("constvalues") +{ + printf("f: %s\n", usymname($f)); +} \ No newline at end of file -- cgit From e82cb6e94e5028637bdf0eedc0f6035139629a90 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 6 Oct 2009 15:26:58 +0200 Subject: PR10726 remove testcase workaround. * testsuite/systemtap.base/const_value.c: Allow inlining since PR10726 was fixed. --- testsuite/systemtap.base/const_value.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/const_value.c b/testsuite/systemtap.base/const_value.c index 4ff82161..2ed0f5c4 100644 --- a/testsuite/systemtap.base/const_value.c +++ b/testsuite/systemtap.base/const_value.c @@ -14,9 +14,7 @@ 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 +static int func (int (*f) ()) { const fooer baz = { .i = 2, .j = 21 }; -- cgit