Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/sdt_notes.exp

raw
1 set test "sdt_notes"
2
3 # Test layout of .note.stapsdt section and interaction with eu-readelf and gdb
4
5 set exeflags [sdt_includes]
6 set exeflags "$exeflags additional_flags=-O2"
7
8 set res [target_compile $srcdir/$subdir/sdt_types.c \
9 sdt_types.x executable $exeflags]
10 if { $res != "" } {
11 verbose "target_compile failed: $res" 2
12 untested "$test compiling types"
13 } else {
14 pass "$test compiling types"
15 }
16
17 set elfutils_ok 0
18 # Does elfutils support stapsdt notes?
19 eval spawn "rpm -q elfutils"
20 expect {
21 -re {elfutils-0.17} { incr elfutils_ok }
22 -re {elfutils-0.18} { incr elfutils_ok }
23 -re {elfutils-0.19} { incr elfutils_ok }
24 }
25
26 if { $elfutils_ok > 0 } {
27 set ok 0
28 # not all eu-readelf versions support --notes=.note.stapsdt
29 set cmd "bash -c {eu-readelf --notes ./sdt_types.x |& grep '\@' |& sed 's/.\[0-9\]\@/\\n&/g'}"
30 eval spawn $cmd
31 expect {
32 -timeout 180
33 -re {[1248]@} { incr ok; exp_continue }
34 eof { }
35 }
36 if { $ok == 106} {
37 pass "$test eu-readelf"
38 } else {
39 fail "$test eu-readelf $ok"
40 }
41 # $elfutils_ok
42 } else {
43 untested "$test eu-readelf (failed elfutils version check)"
44 }
45
46 # Does gdb support -probe-stap?
47 set gdb_ok 0
48 eval spawn "rpm -q gdb"
49 expect {
50 -re {gdb-7.[3456789]} { incr gdb_ok }
51 -re {gdb-8} { incr gdb_ok }
52 -re {gdb-1[0-9]} { incr gdb_ok }
53 }
54
55 if { $gdb_ok > 0 } {
56 set ok 0
57 set cmd "gdb -batch -q -ex \"info probes stap provider ptr_int_var\" -ex \"b -probe-stap provider:ptr_int_var\" -ex run -ex \"print/x {\\\$_probe_arg2}\" ./sdt_types.x"
58 eval spawn $cmd
59 expect {
60 -timeout 180
61 -re {1 = .0x7fffffff} { incr ok; exp_continue }
62 eof { }
63 }
64 if { $ok == 0} {
65 fail "$test gdb probe-stap"
66 } else {
67 pass "$test gdb probe-stap"
68 }
69 # $gdb_ok
70 } else {
71 untested "$test gdb (failed gdb version check)"
72 }
73