| 1 |
// tests user_long_error and others |
| 2 |
|
| 3 |
global found_basic = 0 |
| 4 |
global found_signext = 0 |
| 5 |
|
| 6 |
probe begin { |
| 7 |
printf("BEGIN\n") |
| 8 |
} |
| 9 |
|
| 10 |
probe process("a.out").function("main") { |
| 11 |
printf("main(): i,j,k = %d,%d,%d\n", @var("i"), @var("j"), @var("k")) |
| 12 |
} |
| 13 |
|
| 14 |
// test basic |
| 15 |
probe process("a.out").function("foo") { |
| 16 |
a = user_long_error($b) |
| 17 |
printf("foo(): b, *b = %p, %lx\n", $b, a) |
| 18 |
if (a == 4) found_basic = 1 |
| 19 |
} |
| 20 |
|
| 21 |
// test sign extension |
| 22 |
probe process("a.out").function("bar") { |
| 23 |
b = user_int_error($b) |
| 24 |
c = user_short_error($c) |
| 25 |
d = user_char_error($d) |
| 26 |
|
| 27 |
printf("bar(): i = *b = [mem %lx] ulong %lx, int %d\n", user_ulong_error($b), b, b) |
| 28 |
// XXX exceeds register allocator capacity |
| 29 |
//printf("bar(): j = *c = [mem %x] ushort %x, short %d\n", user_ulong_error($c), user_ushort_error($c), c) |
| 30 |
printf("bar(): j = *c = [mem %lx] ushort %lx, short %d\n", user_ulong_error($c), c, c) |
| 31 |
printf("bar(): k = *d = [mem %lx] ulong %lx, char %d\n", user_ulong_error($d), d, d) |
| 32 |
if (b == -3 && c == -2 && d == -1) found_signext = 1 |
| 33 |
} |
| 34 |
|
| 35 |
probe end { |
| 36 |
if (!found_basic) |
| 37 |
printf("failed basic\nEND FAIL\n") |
| 38 |
else if (!found_signext) |
| 39 |
printf("failed signext\nEND FAIL\n") |
| 40 |
else |
| 41 |
printf("END PASS\n") |
| 42 |
} |