File: global_var.exp

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (85 lines) | stat: -rw-r--r-- 2,787 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
set test "global_var"
set testpath "$srcdir/$subdir"

# Check each "global" value picks up the right one.
# See GCC PR51410 and Systemtap PR10622
set ::result_string {main value@main: 42
getdistance value: 60
getdistance value@main: 42
getdistance value@speed: 6
getdistance value@distance: 60
getspeed value: 6
getspeed value@main: 42
getspeed value@speed: 6
getspeed value@distance: 60
compare value: 42
compare value@main: 42
compare value@speed: 6
compare value@distance: 60
main return value@main: 42}

# Only run on make installcheck and uprobes present.
if {! [installtest_p]} { untested "$test"; return }

proc dyninst_kfails {index} {
  # The dyninst runtime isn't multi-arch, it only works on the
  # native architecture. PR14490.
  if {! [all_compile_flag_native_p $index]} {
    setup_kfail 14490 "*-*-*"
  }
}

set compiled_objs {}
for {set i 0} {$i < [all_compile_flags]} {incr i} {
  set extra_flag [all_compile_flag $i]
  set extra_name [all_compile_flag_name $i]

  # Compile our object files separately, then combine with main.
  set oname "${test}_speed"
  set res [target_compile ${testpath}/${oname}.c ${oname}_${extra_name}.o object "$extra_flag additional_flags=-g"]
  if { $res != "" } {
      verbose "target_compile for ${oname} failed: $res" 2
      fail "unable to compile ${oname} $extra_name"
      continue
  }
  lappend compiled_objs ${oname}_${extra_name}.o

  set oname2 "${test}_distance"
  set res [target_compile ${testpath}/${oname2}.c ${oname2}_${extra_name}.o object "$extra_flag additional_flags=-g"]
  if { $res != "" } {
      verbose "target_compile for ${oname2} failed: $res" 2
      fail "unable to compile ${oname2} $extra_name"
      continue
  }
  lappend compiled_objs ${oname2}_${extra_name}.o

  set mname "${test}_main"
  set res [target_compile "${testpath}/${mname}.c ${oname}_${extra_name}.o ${oname2}_${extra_name}.o" ${mname}_${extra_name} executable "$extra_flag additional_flags=-g"]
  if { $res != "" } {
      verbose "target_compile failed: $res" 2
      fail "unable to compile ${mname} $extra_name"
      continue
  }
  lappend compiled_objs ${mname}_${extra_name}

  foreach runtime [get_runtime_list] {
    if {$runtime != ""} {
      if {[info procs ${runtime}_kfails] ne ""} { ${runtime}_kfails $i }
      stap_run3 $test-$extra_name-$runtime $srcdir/$subdir/$test.stp \
	-c ./${mname}_${extra_name} --runtime=$runtime
    } elseif {[uretprobes_p]} {
      stap_run3 $test-$extra_name $srcdir/$subdir/$test.stp \
	-c ./${mname}_${extra_name}
    } else {
      untested "$test-$extra_name"
    }
  }
}

# Cleanup. Note we remove objects individually to avoid the command
# line getting too long.
if { $verbose == 0 && [llength compiled_objs] > 0 } {
  foreach obj $compiled_objs {
    catch { exec rm -f $obj }
  }
}