Debian Codegraph @

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

raw
1 set test "pthread_stacks"
2
3 if {![installtest_p]} { untested $test; return }
4 if {![uprobes_p]} { untested $test; return }
5
6 set exepath "[pwd]/pthread_stacks.x"
7 set flags "additional_flags=-pthread additional_flags=-g"
8
9 set res [target_compile $srcdir/$subdir/pthread_stacks.c $exepath executable $flags]
10 if { $res != "" } {
11 fail "$test compiling"
12 return
13 } else {
14 pass "$test compiling"
15 }
16
17 # For ppc64, 0x10000 is too small. For x86_64, 0x20000 is invalid. So,
18 # we'll default to 0x10000 unless we're on ppc64.
19 if {[string match ppc* $::tcl_platform(machine)]} {
20 set new_stack_size 0x20000
21 } else {
22 set new_stack_size 0x10000
23 }
24
25 # This test won't work if we don't have glibc's debuginfo
26 # installed. So, try to compile threadstacks.stp first to see if we've
27 # got glibc debuginfo. Note that on multilib systems like x86_64, you
28 # only need the "native" glibc debuginfo installed for this test,
29 # since we're only compiling for the "native" arch.
30 set test "pthread_stacks debuginfo check"
31 spawn stap -gp4 $srcdir/systemtap.examples/process/threadstacks.stp \
32 -Gsize=${new_stack_size} -d $exepath
33 set compile_errors 0
34 expect {
35 -timeout 60
36 -re {^parse error[^\r\n]*\r\n} { incr compile_errors 1; exp_continue }
37 -re {^[^\r\n]*compilation failed[^\r\n]*\r\n} {
38 incr compile_errors 1; exp_continue }
39 -re {^semantic error[^\r\n]*\r\n} { incr compile_errors 1; exp_continue }
40 timeout { fail "$test timeout" }
41 eof { }
42 }
43 catch { close }
44 set res [wait -i $spawn_id]
45 set res [lindex $res 3]
46 if { $res != 0 || $compile_errors > 0 } {
47 fail $test
48 untested "pthread_stacks"
49 catch {exec rm -f $exepath}
50 return
51 }
52 pass $test
53
54 set test "pthread_stacks no -Gsize"
55 spawn stap -w -g $srcdir/systemtap.examples/process/threadstacks.stp -c "$exepath 1024 0" -d $exepath
56 set ok 0
57 set ko 0
58 expect {
59 -re {^stacksize=[0-9]*\r\n} { incr ok; exp_continue }
60 -re {^WARNING[^\r\n]*\r\n} { incr ko; exp_continue }
61 timeout { fail "$test timeout" }
62 eof { }
63 }
64 catch { close }
65 catch { wait }
66 if { $ok == 1 } then { pass $test } else { fail "$test ($ok $ko)" }
67
68
69 set test "pthread_stacks -Gsize"
70 spawn stap -g $srcdir/systemtap.examples/process/threadstacks.stp -Gsize=${new_stack_size} -c "$exepath 1024 0" -d $exepath
71 set ok 0
72 set ko 0
73 expect {
74 -re {^stacksize=[0-9]*\r\n} { incr ok; exp_continue }
75 -re {^pthread_stacks[^\r\n]*overwrote[^\r\n]*\r\n} { incr ok; exp_continue }
76 -re {^WARNING[^\r\n]*\r\n} { incr ko; exp_continue }
77 timeout { fail "$test timeout" }
78 eof { }
79 }
80 catch { close }
81 catch { wait }
82 if { $ok == 2 } then { pass $test } else { fail "$test ($ok $ko)" }
83
84 catch {exec rm -f $exepath}