| 1 |
#include "sys/sdt.h" |
| 2 |
#include <stdio.h> |
| 3 |
#include <unistd.h> |
| 4 |
#ifdef LISTING_MODE_MAIN |
| 5 |
/* NB: line numbers in this file are carefully calibrated to .exp test-case contents. */ |
| 6 |
int globalvar = 1; |
| 7 |
|
| 8 |
extern int libfoo(int lf); |
| 9 |
|
| 10 |
__attribute__((always_inline)) |
| 11 |
inline int inln(int i) { |
| 12 |
|
| 13 |
return i % 5; |
| 14 |
} |
| 15 |
|
| 16 |
int bar(int b) { |
| 17 |
|
| 18 |
int i = inln(b); |
| 19 |
printf("inln returned %d\n", i); |
| 20 |
return i * 3; |
| 21 |
} |
| 22 |
|
| 23 |
int foo(int f) { |
| 24 |
|
| 25 |
int b = bar(f); |
| 26 |
return b * 2; |
| 27 |
} |
| 28 |
|
| 29 |
int main(void) { |
| 30 |
|
| 31 |
globalvar = foo(globalvar); |
| 32 |
globalvar = libfoo(globalvar); |
| 33 |
main_label: |
| 34 |
STAP_PROBE1(main, mark, globalvar); |
| 35 |
while (1) {sleep(5000);} |
| 36 |
return 0; |
| 37 |
if (0) goto main_label; |
| 38 |
} |
| 39 |
|
| 40 |
#elif LISTING_MODE_LIB |
| 41 |
|
| 42 |
__attribute__((always_inline)) |
| 43 |
inline int libinln(int i) { |
| 44 |
|
| 45 |
return i % 5; |
| 46 |
} |
| 47 |
|
| 48 |
int libbar(int lb) { |
| 49 |
|
| 50 |
int i = libinln(lb); |
| 51 |
printf("inln returned %d\n", i); |
| 52 |
return i * 3; |
| 53 |
} |
| 54 |
|
| 55 |
int libfoo(int lf) { |
| 56 |
|
| 57 |
int lb = libbar(lf); |
| 58 |
lib_label: |
| 59 |
STAP_PROBE1(lib, mark, lb); |
| 60 |
return lb * 2; |
| 61 |
} |
| 62 |
|
| 63 |
#else |
| 64 |
#error must define LISTING_MODE_MAIN or LISTING_MODE_LIB |
| 65 |
#endif |