| 1 | #include <stdio.h> |
| 2 | #include <unistd.h> |
| 3 | #include <sys/mman.h> |
| 4 | #include <stdarg.h> |
| 5 | #include <sys/types.h> |
| 6 | #include <sys/stat.h> |
| 7 | #include <fcntl.h> |
| 8 | #include <signal.h> |
| 9 | |
| 10 | #include <ust/marker.h> |
| 11 | #include "usterr.h" |
| 12 | #include "tp.h" |
| 13 | |
| 14 | |
| 15 | void inthandler(int sig) |
| 16 | { |
| 17 | printf("in handler\n"); |
| 18 | exit(0); |
| 19 | } |
| 20 | |
| 21 | int init_int_handler(void) |
| 22 | { |
| 23 | int result; |
| 24 | struct sigaction act; |
| 25 | |
| 26 | result = sigemptyset(&act.sa_mask); |
| 27 | if(result == -1) { |
| 28 | PERROR("sigemptyset"); |
| 29 | return -1; |
| 30 | } |
| 31 | |
| 32 | act.sa_handler = inthandler; |
| 33 | act.sa_flags = SA_RESTART; |
| 34 | |
| 35 | /* Only defer ourselves. Also, try to restart interrupted |
| 36 | * syscalls to disturb the traced program as little as possible. |
| 37 | */ |
| 38 | result = sigaction(SIGINT, &act, NULL); |
| 39 | if(result == -1) { |
| 40 | PERROR("sigaction"); |
| 41 | return -1; |
| 42 | } |
| 43 | |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | int main() |
| 48 | { |
| 49 | int i; |
| 50 | |
| 51 | init_int_handler(); |
| 52 | |
| 53 | printf("Hello, World!\n"); |
| 54 | |
| 55 | sleep(1); |
| 56 | for(i=0; i<50; i++) { |
| 57 | trace_mark(ust, bar, "str %s", "FOOBAZ"); |
| 58 | trace_mark(ust, bar2, "number1 %d number2 %d", 53, 9800); |
| 59 | trace_hello_tptest(i); |
| 60 | usleep(100000); |
| 61 | } |
| 62 | |
| 63 | scanf("%*s"); |
| 64 | |
| 65 | ltt_trace_stop("auto"); |
| 66 | ltt_trace_destroy("auto"); |
| 67 | |
| 68 | DBG("TRACE STOPPED"); |
| 69 | scanf("%*s"); |
| 70 | |
| 71 | return 0; |
| 72 | } |