Debian Codegraph @

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

raw
1 set test "global_var"
2 set testpath "$srcdir/$subdir"
3
4 # Check each "global" value picks up the right one.
5 # See GCC PR51410 and Systemtap PR10622
6 set ::result_string {main value@main: 42
7 getdistance value: 60
8 getdistance value@main: 42
9 getdistance value@speed: 6
10 getdistance value@distance: 60
11 getspeed value: 6
12 getspeed value@main: 42
13 getspeed value@speed: 6
14 getspeed value@distance: 60
15 compare value: 42
16 compare value@main: 42
17 compare value@speed: 6
18 compare value@distance: 60
19 main return value@main: 42}
20
21 # Only run on make installcheck and uprobes present.
22 if {! [installtest_p]} { untested "$test"; return }
23
24 proc dyninst_kfails {index} {
25 # The dyninst runtime isn't multi-arch, it only works on the
26 # native architecture. PR14490.
27 if {! [all_compile_flag_native_p $index]} {
28 setup_kfail 14490 "*-*-*"
29 }
30 }
31
32 set compiled_objs {}
33 for {set i 0} {$i < [all_compile_flags]} {incr i} {
34 set extra_flag [all_compile_flag $i]
35 set extra_name [all_compile_flag_name $i]
36
37 # Compile our object files separately, then combine with main.
38 set oname "${test}_speed"
39 set res [target_compile ${testpath}/${oname}.c ${oname}_${extra_name}.o object "$extra_flag additional_flags=-g"]
40 if { $res != "" } {
41 verbose "target_compile for ${oname} failed: $res" 2
42 fail "unable to compile ${oname} $extra_name"
43 continue
44 }
45 lappend compiled_objs ${oname}_${extra_name}.o
46
47 set oname2 "${test}_distance"
48 set res [target_compile ${testpath}/${oname2}.c ${oname2}_${extra_name}.o object "$extra_flag additional_flags=-g"]
49 if { $res != "" } {
50 verbose "target_compile for ${oname2} failed: $res" 2
51 fail "unable to compile ${oname2} $extra_name"
52 continue
53 }
54 lappend compiled_objs ${oname2}_${extra_name}.o
55
56 set mname "${test}_main"
57 set res [target_compile "${testpath}/${mname}.c ${oname}_${extra_name}.o ${oname2}_${extra_name}.o" ${mname}_${extra_name} executable "$extra_flag additional_flags=-g"]
58 if { $res != "" } {
59 verbose "target_compile failed: $res" 2
60 fail "unable to compile ${mname} $extra_name"
61 continue
62 }
63 lappend compiled_objs ${mname}_${extra_name}
64
65 foreach runtime [get_runtime_list] {
66 if {$runtime != ""} {
67 if {[info procs ${runtime}_kfails] ne ""} { ${runtime}_kfails $i }
68 stap_run3 $test-$extra_name-$runtime $srcdir/$subdir/$test.stp \
69 -c ./${mname}_${extra_name} --runtime=$runtime
70 } elseif {[uretprobes_p]} {
71 stap_run3 $test-$extra_name $srcdir/$subdir/$test.stp \
72 -c ./${mname}_${extra_name}
73 } else {
74 untested "$test-$extra_name"
75 }
76 }
77 }
78
79 # Cleanup. Note we remove objects individually to avoid the command
80 # line getting too long.
81 if { $verbose == 0 && [llength compiled_objs] > 0 } {
82 foreach obj $compiled_objs {
83 catch { exec rm -f $obj }
84 }
85 }