| 1 |
set test "uprobe_nd_params" |
| 2 |
|
| 3 |
if {! [uprobes_p]} { |
| 4 |
untested "$test (no uprobes support)" |
| 5 |
return |
| 6 |
} |
| 7 |
|
| 8 |
set test_srcpath "[pwd]/test.c" |
| 9 |
set test_exepath "[pwd]/test" |
| 10 |
set test_stppath "[pwd]/test.stp" |
| 11 |
|
| 12 |
set test_fp [open $test_srcpath "w"] |
| 13 |
puts $test_fp " |
| 14 |
#include <limits.h> |
| 15 |
|
| 16 |
int fc1(int arg1, int arg2) { return 0; } |
| 17 |
int fc2(unsigned int arg1, unsigned int arg2) { return 0; } |
| 18 |
int fc3(long arg1, long arg2) { return 0; } |
| 19 |
int fc4(unsigned long arg1, unsigned long arg2) { return 0; } |
| 20 |
int fc5(long long arg1, long long arg2) { return 0; } |
| 21 |
int fc6(int *arg1, int *arg2) { return 0; } |
| 22 |
|
| 23 |
int main() |
| 24 |
{ |
| 25 |
int i = 7; |
| 26 |
fc1(INT_MAX, -1); |
| 27 |
fc2(UINT_MAX, -1); |
| 28 |
fc3(LONG_MAX, -1); |
| 29 |
fc4(ULONG_MAX, -1); |
| 30 |
fc5(0x12345678deadbeefLL, (long long)-1); |
| 31 |
fc6(&i, (int *)-1); |
| 32 |
return 0; |
| 33 |
} |
| 34 |
" |
| 35 |
close $test_fp |
| 36 |
|
| 37 |
set script_fp [open $test_stppath "w"] |
| 38 |
puts $script_fp " |
| 39 |
probe process(\"$test_exepath\").function(\"fc1\") { |
| 40 |
printf(\"%s;%d;%d;\\n\", ppfunc(), int_arg(1), s32_arg(1)) |
| 41 |
} |
| 42 |
probe process(\"$test_exepath\").function(\"fc2\") { |
| 43 |
printf(\"%s;%u;%u;\\n\", ppfunc(), uint_arg(1), u32_arg(1)) |
| 44 |
} |
| 45 |
probe process(\"$test_exepath\").function(\"fc3\") { |
| 46 |
printf(\"%s;%d;%d\\n\", ppfunc(), long_arg(1), long_arg(2)) |
| 47 |
} |
| 48 |
probe process(\"$test_exepath\").function(\"fc4\") { |
| 49 |
printf(\"%s;%u;%u;\\n\", ppfunc(), ulong_arg(1), ulong_arg(2)) |
| 50 |
} |
| 51 |
probe process(\"$test_exepath\").function(\"fc5\") { |
| 52 |
%( CONFIG_64BIT == \"y\" %? |
| 53 |
if(probing_32bit_app()) { |
| 54 |
printf(\"%s;%x;%x;%x;%x;\\n\", ppfunc(), longlong_arg(1), ulonglong_arg(1), |
| 55 |
s64_arg(1), u64_arg(1)) |
| 56 |
} else { |
| 57 |
printf(\"%s;%x;%x;%x;%x;\\n\", ppfunc(), longlong_arg(1), ulonglong_arg(1), |
| 58 |
s64_arg(1), u64_arg(1)) |
| 59 |
} |
| 60 |
%: |
| 61 |
printf(\"%s;%x;%x;%x;%x;\\n\", ppfunc(), longlong_arg(1), ulonglong_arg(1), |
| 62 |
s64_arg(1), u64_arg(1)) |
| 63 |
%) |
| 64 |
} |
| 65 |
probe process(\"$test_exepath\").function(\"fc6\") { |
| 66 |
printf(\"%s;%p;%p\\n\", ppfunc(), pointer_arg(1), pointer_arg(2)) |
| 67 |
} |
| 68 |
" |
| 69 |
close $script_fp |
| 70 |
|
| 71 |
for {set i 0} {$i < [arch_compile_flags]} {incr i} { |
| 72 |
set test_flags "compiler=gcc [arch_compile_flag $i]" |
| 73 |
set res [target_compile $test_srcpath $test_exepath executable $test_flags] |
| 74 |
if { $res != "" } { |
| 75 |
fail "compiling test.c $test_flags" |
| 76 |
catch {exec rm -f $test_srcpath} |
| 77 |
return |
| 78 |
} else { |
| 79 |
pass "compiling test.c $test_flags" |
| 80 |
} |
| 81 |
|
| 82 |
set ok 0 |
| 83 |
spawn stap $test_stppath -c $test_exepath |
| 84 |
expect { |
| 85 |
-timeout 120 |
| 86 |
-re {fc1;(2147483647;){2}} { incr ok; exp_continue } |
| 87 |
-re {fc2;(4294967295;){2}} { incr ok; exp_continue } |
| 88 |
-re {fc3;(2147483647|9223372036854775807);-1} { incr ok; exp_continue } |
| 89 |
-re {fc4;(4294967295;|18446744073709551615;){2}} { incr ok; exp_continue } |
| 90 |
-re {fc5;(12345678deadbeef;){4}} { incr ok; exp_continue } |
| 91 |
-re {fc6;0x[a-f0-9]+;0x[7]?[f]+} { incr ok; exp_continue } |
| 92 |
timeout { fail "$test (timeout)" } |
| 93 |
eof { } |
| 94 |
} |
| 95 |
catch { close }; catch { wait } |
| 96 |
if {$ok == 6} { pass "$test" } { fail "$test" } |
| 97 |
} |
| 98 |
|
| 99 |
catch {exec rm -f $test_srcpath $test_exepath $test_stppath} |
| 100 |
|