Debian Codegraph @

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

raw
1 set test "implicitptr"
2 set ::result_string {foo: 22 22 22 22
3 changed foo (99): 99 99 99 99
4 p = { { &100, 200 }, { &100, 200 } }
5 *a->x=200, a->y=400, *b->x=100, b->y=200
6 *a->x=100, a->y=200, *b->x=100, b->y=200
7 p = { { &200, 400 }, { &100, 200 } }
8 *a->x=300, a->y=600, *b->x=200, b->y=200
9 *a->x=200, a->y=200, *b->x=200, b->y=200
10 p = { { &300, 600 }, { &200, 200 } }}
11
12 set listspec "process(\"$test.exe\").statement(\"foo@*:17\")"
13
14 proc exe_uses_implicit_ptr {exe} {
15 if {[catch {exec readelf --debug-dump=info,loc $exe | \
16 grep -E -q {implicit_pointer| f2 .*User defined location op}} \
17 results]} {
18 verbose -log "exe_uses_implicit_ptr caught: $results"
19 return 0
20 } else {
21 verbose -log "exe_uses_implicit_ptr ran: {$results}"
22 if {$results == ""} {
23 return 1
24 } else {
25 return 0
26 }
27 }
28 }
29
30 for {set i 0} {$i < [all_compile_flags]} {incr i} {
31 set extra_flag [all_compile_flag $i]
32 set extra_name [all_compile_flag_name $i]
33
34 set test_flags "additional_flags=-g $extra_flag"
35 set test_flags "$test_flags [sdt_includes]"
36
37 set res [target_compile $srcdir/$subdir/$test.c $test.exe executable "$test_flags"]
38 if {$res != ""} {
39 verbose -log "target_compile failed: $res" 2
40 fail "$test.c compile $extra_name"
41 untested "probe listing $test-$extra_name"
42 untested "$test-$extra_name"
43 continue
44 } else {
45 pass "$test.c compile $extra_name"
46 }
47
48 set listing ""
49 catch {set listing [exec stap -L $listspec 2>@1]}
50 verbose -log "stap -L $listspec reports: $listing"
51 set listing [lsort [lrange [split $listing] 1 end]]
52 if {$listing == {{$i:int}}} {
53 set avail 0
54 pass "probe listing $test-$extra_name (i)"
55 } elseif {$listing == {{$i:int} {$j:int*} {$k:int**} {$l:int***}}} {
56 set avail 1
57 pass "probe listing $test-$extra_name (ijkl)"
58 } else {
59 verbose -log "listified: $listing"
60 if {[exe_uses_implicit_ptr $test.exe]} {
61 fail "probe listing $test-$extra_name"
62 set avail -1
63 } else {
64 untested "probe listing $test-$extra_name"
65 set avail 0
66 }
67 }
68
69 if {$avail} {
70 if {[installtest_p] && [uprobes_p]} {
71 stap_run3 "$test-$extra_name" $srcdir/$subdir/$test.stp \
72 -g -c ./$test.exe $test.exe
73 } else {
74 untested "$test-$extra_name"
75 }
76 } elseif {[exe_uses_implicit_ptr $test.exe]} {
77 verbose -log "$test-$extra_name uses implicit_ptr but -L missed it"
78 fail "$test-$extra_name"
79 } else {
80 verbose -log "$test-$extra_name did not use implicit_ptr, skipping"
81 untested "$test-$extra_name"
82 }
83
84 catch {exec rm -f $test.exe}
85 }