File: pthread_stacks.exp

package info (click to toggle)
systemtap 5.1-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 47,964 kB
  • sloc: cpp: 80,838; ansic: 54,757; xml: 49,725; exp: 43,665; sh: 11,527; 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 (84 lines) | stat: -rw-r--r-- 2,661 bytes parent folder | download | duplicates (6)
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
set test "pthread_stacks"

if {![installtest_p]} { untested $test; return }
if {![uprobes_p]} { untested $test; return }

set exepath "[pwd]/pthread_stacks.x"
set flags "additional_flags=-pthread additional_flags=-g"

set res [target_compile $srcdir/$subdir/pthread_stacks.c $exepath executable $flags]
if { $res != "" } {
    fail "$test compiling"
    return
} else {
    pass "$test compiling"
}

# For ppc64, 0x10000 is too small. For x86_64, 0x20000 is invalid. So,
# we'll default to 0x10000 unless we're on ppc64.
if {[string match ppc* $::tcl_platform(machine)]} {
    set new_stack_size 0x20000
} else {
    set new_stack_size 0x10000
}

# This test won't work if we don't have glibc's debuginfo
# installed. So, try to compile threadstacks.stp first to see if we've
# got glibc debuginfo. Note that on multilib systems like x86_64, you
# only need the "native" glibc debuginfo installed for this test,
# since we're only compiling for the "native" arch.
set test "pthread_stacks debuginfo check"
spawn stap -gp4 $srcdir/systemtap.examples/process/threadstacks.stp \
    -Gsize=${new_stack_size} -d $exepath
set compile_errors 0
expect {
    -timeout 60
    -re {^parse error[^\r\n]*\r\n} { incr compile_errors 1; exp_continue }
    -re {^[^\r\n]*compilation failed[^\r\n]*\r\n} {
	incr compile_errors 1; exp_continue }
    -re {^semantic error[^\r\n]*\r\n} { incr compile_errors 1; exp_continue }
    timeout { fail "$test timeout" }
    eof { }
}
catch { close }
set res [wait -i $spawn_id]
set res [lindex $res 3]
if { $res != 0 || $compile_errors > 0 } {
    fail $test
    untested "pthread_stacks"
    catch {exec rm -f $exepath}
    return
}
pass $test

set test "pthread_stacks no -Gsize"
spawn stap -w -g $srcdir/systemtap.examples/process/threadstacks.stp -c "$exepath 1024 0" -d $exepath
set ok 0
set ko 0
expect {
    -re {^stacksize=[0-9]*\r\n} { incr ok; exp_continue }
    -re {^WARNING[^\r\n]*\r\n} { incr ko; exp_continue }
    timeout { fail "$test timeout" }
    eof { }
}
catch { close }
catch { wait }
if { $ok == 1 } then { pass $test } else { fail "$test ($ok $ko)" }


set test "pthread_stacks -Gsize"
spawn stap -g $srcdir/systemtap.examples/process/threadstacks.stp -Gsize=${new_stack_size} -c "$exepath 1024 0" -d $exepath
set ok 0
set ko 0
expect {
    -re {^stacksize=[0-9]*\r\n} { incr ok; exp_continue }
    -re {^pthread_stacks[^\r\n]*overwrote[^\r\n]*\r\n} { incr ok; exp_continue }
    -re {^WARNING[^\r\n]*\r\n} { incr ko; exp_continue }
    timeout { fail "$test timeout" }
    eof { }
}
catch { close }
catch { wait }
if { $ok == 2 } then { pass $test } else { fail "$test ($ok $ko)" }

catch {exec rm -f $exepath}