| 1 |
#! stap |
| 2 |
# Usage: set $1 to supply test address; -DMAXERRORS=<many> |
| 3 |
# |
| 4 |
# Note that each test has to be in a separate probe, since an error |
| 5 |
# aborts the current probe, but others will continue. |
| 6 |
|
| 7 |
global hits |
| 8 |
|
| 9 |
@define fire_once(probeno, body) %( |
| 10 |
probe timer.profile { |
| 11 |
probeno = @probeno |
| 12 |
if (hits[probeno] == 0) { |
| 13 |
hits[probeno] = 1 |
| 14 |
@body |
| 15 |
} |
| 16 |
} |
| 17 |
%) |
| 18 |
|
| 19 |
# call after checks that should abort the probe |
| 20 |
@define unreachable %( |
| 21 |
printf("REACHED_UNREACHABLE(%p,%d) at %s\n", $1, probeno, pp()); |
| 22 |
%) |
| 23 |
|
| 24 |
# Call after lines that should continue execution |
| 25 |
@define noerr %( |
| 26 |
printf("NOERR(%p,%d) at %s\n", $1, probeno, pp()); |
| 27 |
%) |
| 28 |
|
| 29 |
@fire_once(0, println (kernel_string ($1)); @unreachable) |
| 30 |
@fire_once(1, println (kernel_long ($1)); @noerr) |
| 31 |
@fire_once(2, println (kernel_int($1)); @noerr) |
| 32 |
@fire_once(3, println (kernel_short ($1)); @noerr) |
| 33 |
@fire_once(4, println (kernel_char ($1)); @noerr) |
| 34 |
@fire_once(7, printf ("%m\n", $1); @unreachable) |
| 35 |
@fire_once(8, str = sprintf("%m", $1); printf ("%s\n", str); @unreachable) |
| 36 |
@fire_once(9, printf ("%M\n", $1); @unreachable) |
| 37 |
@fire_once(10, str = sprintf("%M", $1); printf ("%s\n", str); @unreachable) |
| 38 |
@fire_once(11, println (user_string ($1)); @noerr) |
| 39 |
@fire_once(12, println (user_string ($1,"<only suspected, not known>")); @noerr) |
| 40 |
@fire_once(13, println (user_string_warn ($1)); @noerr) |
| 41 |
@fire_once(14, println (user_string_warn ($1, "<only suspected, not known>")); @noerr) |
| 42 |
@fire_once(15, println (user_string_quoted ($1)); @noerr) |
| 43 |
@fire_once(16, println (user_string_n ($1, 5)); @unreachable) |
| 44 |
@fire_once(17, println (user_string_n ($1, 5, "<only suspected, not known>")); @noerr) |
| 45 |
@fire_once(18, println (user_string_n_warn ($1, 5)); @noerr) |
| 46 |
@fire_once(19, println (user_string_n_warn ($1, 5, "<only suspected, not known>")); @noerr) |
| 47 |
@fire_once(20, println (user_string_n_quoted ($1, 5)); @noerr) |
| 48 |
@fire_once(21, println (user_short ($1)); @noerr) |
| 49 |
@fire_once(22, println (user_short_warn ($1)); @noerr) |
| 50 |
@fire_once(23, println (user_int ($1)); @noerr) |
| 51 |
@fire_once(24, println (user_int_warn ($1)); @noerr) |
| 52 |
@fire_once(25, println (user_long ($1)); @noerr) |
| 53 |
@fire_once(26, println (user_long_warn ($1)); @noerr) |
| 54 |
@fire_once(27, println (user_char ($1)); @noerr) |
| 55 |
@fire_once(28, println (user_char_warn ($1)); @noerr) |
| 56 |
@fire_once(29, println (kernel_buffer_quoted($1, 5, 20)); @noerr) |
| 57 |
@fire_once(30, println (kernel_buffer_quoted_error($1, 5, 20)); @unreachable) |
| 58 |
@fire_once(33, println (user_buffer_quoted($1, 5, 20)); @noerr) |
| 59 |
@fire_once(34, println (user_buffer_quoted_error($1, 5, 20)); @unreachable) |
| 60 |
|
| 61 |
# Assume that by 3 seconds, all the above probes have been hit. |
| 62 |
probe timer.s(3) { print ("\n") exit () } |