File: implicitptr.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,574 bytes parent folder | download | duplicates (2)
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 "implicitptr"
set ::result_string {foo: 22 22 22 22
changed foo (99): 99 99 99 99
p = { { &100, 200 }, { &100, 200 } }
*a->x=200, a->y=400, *b->x=100, b->y=200
*a->x=100, a->y=200, *b->x=100, b->y=200
p = { { &200, 400 }, { &100, 200 } }
*a->x=300, a->y=600, *b->x=200, b->y=200
*a->x=200, a->y=200, *b->x=200, b->y=200
p = { { &300, 600 }, { &200, 200 } }}

set listspec "process(\"$test.exe\").statement(\"foo@*:17\")"

proc exe_uses_implicit_ptr {exe} {
  if {[catch {exec readelf --debug-dump=info,loc $exe | \
		  grep -E -q {implicit_pointer| f2 .*User defined location op}} \
	   results]} {
    verbose -log "exe_uses_implicit_ptr caught: $results"
    return 0
  } else {
    verbose -log "exe_uses_implicit_ptr ran: {$results}"
    if {$results == ""} {
      return 1
    } else {
      return 0
    }
  }
}

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]

  set test_flags "additional_flags=-g $extra_flag"
  set test_flags "$test_flags [sdt_includes]"

  set res [target_compile $srcdir/$subdir/$test.c $test.exe executable "$test_flags"]
  if {$res != ""} {
    verbose -log "target_compile failed: $res" 2
    fail "$test.c compile $extra_name"
    untested "probe listing $test-$extra_name"
    untested "$test-$extra_name"
    continue
  } else {
    pass "$test.c compile $extra_name"
  }

  set listing ""
  catch {set listing [exec stap -L $listspec 2>@1]}
  verbose -log "stap -L $listspec reports: $listing"
  set listing [lsort [lrange [split $listing] 1 end]]
  if {$listing == {{$i:int}}} {
    set avail 0
    pass "probe listing $test-$extra_name (i)"
  } elseif {$listing == {{$i:int} {$j:int*} {$k:int**} {$l:int***}}} {
    set avail 1
    pass "probe listing $test-$extra_name (ijkl)"
  } else {
    verbose -log "listified: $listing"
    if {[exe_uses_implicit_ptr $test.exe]} {
      fail "probe listing $test-$extra_name"
      set avail -1
    } else {
      untested "probe listing $test-$extra_name"
      set avail 0
    }
  }

  if {$avail} {
    if {[installtest_p] && [uprobes_p]} {
      stap_run3 "$test-$extra_name" $srcdir/$subdir/$test.stp \
	  -g -c ./$test.exe $test.exe
    } else {
      untested "$test-$extra_name"
    }
  } elseif {[exe_uses_implicit_ptr $test.exe]} {
    verbose -log "$test-$extra_name uses implicit_ptr but -L missed it"
    fail "$test-$extra_name"
  } else {
    verbose -log "$test-$extra_name did not use implicit_ptr, skipping"
    untested "$test-$extra_name"
  }

  catch {exec rm -f $test.exe}
}