| 1 |
# Test various array operations on a kernel variable. |
| 2 |
# This is a pretty direct translation of the C source code of |
| 3 |
# kernel/kallsyms.c (kallsyms_expand_symbol). |
| 4 |
|
| 5 |
global symbols = 0; |
| 6 |
|
| 7 |
probe kernel.function("kallsyms_expand_symbol") |
| 8 |
{ |
| 9 |
/* We are only interested in the head -10 symbols for comparison. */ |
| 10 |
if (target() != pid()) next; |
| 11 |
|
| 12 |
skipped_first = 0; |
| 13 |
|
| 14 |
/* Get the compressed symbol length from the first symbol byte. */ |
| 15 |
data = &$kallsyms_names[$off]; |
| 16 |
len = kernel_char(data) & 0xff; |
| 17 |
data++; |
| 18 |
|
| 19 |
/* |
| 20 |
* Update the offset to return the offset for the next symbol on |
| 21 |
* the compressed stream. |
| 22 |
*/ |
| 23 |
off += len + 1; |
| 24 |
|
| 25 |
/* |
| 26 |
* For every byte on the compressed symbol data, copy the table |
| 27 |
* entry for that byte. |
| 28 |
*/ |
| 29 |
while (len) |
| 30 |
{ |
| 31 |
idx = kernel_char(data) & 0xff; |
| 32 |
tptr = &$kallsyms_token_table[$kallsyms_token_index[idx]]; |
| 33 |
data++; |
| 34 |
len--; |
| 35 |
|
| 36 |
t = kernel_char(tptr) & 0xff; |
| 37 |
while (t) |
| 38 |
{ |
| 39 |
if (skipped_first) |
| 40 |
{ |
| 41 |
printf("%c", t); |
| 42 |
} |
| 43 |
else |
| 44 |
skipped_first = 1; |
| 45 |
tptr++; |
| 46 |
t = kernel_char(tptr) & 0xff; |
| 47 |
} |
| 48 |
} |
| 49 |
printf("\n"); |
| 50 |
|
| 51 |
/* Are we done yet? */ |
| 52 |
symbols++; |
| 53 |
if (symbols == 10) exit(); |
| 54 |
} |