| 1 |
#! stap -p2 |
| 2 |
|
| 3 |
|
| 4 |
@define STUFF %( |
| 5 |
// precheck, it should work with @cast |
| 6 |
if (!@defined(@task(0)->mm)) { |
| 7 |
println($cast_failed_mm) |
| 8 |
} |
| 9 |
if (@defined(@task(0)->systemtap)) { |
| 10 |
println($cast_succeeded_systemtap) |
| 11 |
} |
| 12 |
|
| 13 |
// Test that autocast values can be checked by @defined |
| 14 |
if (!@defined(task_current()->mm)) { |
| 15 |
println($autocast_failed_mm) |
| 16 |
} |
| 17 |
if (@defined(task_current()->systemtap)) { |
| 18 |
println($autocast_succeeded_systemtap) |
| 19 |
} |
| 20 |
|
| 21 |
// Test that autocast can resolve on the results of @defined |
| 22 |
mm1 = @choose_defined($nonsense, task_current())->mm; |
| 23 |
mm2 = @choose_defined(task_current(), $nonsense)->mm; |
| 24 |
println(mm1 == mm2) |
| 25 |
|
| 26 |
// Test an even deeper level of @defined |
| 27 |
if (!@defined(mm1->mmap) || !@defined(mm2->mmap)) { |
| 28 |
println($autocast_failed_mm_mmap) |
| 29 |
} |
| 30 |
if (@defined(mm1->systemtap) || @defined(mm2->systemtap)) { |
| 31 |
println($autocast_succeeded_mm_systemtap) |
| 32 |
} |
| 33 |
|
| 34 |
// Test that autocast can resolve through nested @defined |
| 35 |
// (especially that the ternary isn't automatically "defined") |
| 36 |
mm3 = @choose_defined(@choose_defined($nonsense, $wut), task_current())->mm; |
| 37 |
mm4 = @choose_defined(@choose_defined($nonsense, task_current()), $wut)->mm; |
| 38 |
mm5 = @choose_defined(@choose_defined(task_current(), $nonsense), $wut)->mm; |
| 39 |
println(mm3 == mm4 && mm4 == mm5) |
| 40 |
%) |
| 41 |
|
| 42 |
|
| 43 |
probe oneshot |
| 44 |
{ |
| 45 |
@STUFF |
| 46 |
foo() // from a function too, to test PR18079 function processing |
| 47 |
} |
| 48 |
|
| 49 |
function foo () |
| 50 |
{ |
| 51 |
@STUFF |
| 52 |
} |