Commit | Line | Data |
---|---|---|
68c1021b PMF |
1 | #include <stdio.h> |
2 | #include <unistd.h> | |
b6bf28ec | 3 | #include <sys/mman.h> |
9c67dc50 PMF |
4 | #include <stdarg.h> |
5 | #include <sys/types.h> | |
6 | #include <sys/stat.h> | |
7 | #include <fcntl.h> | |
4486e566 | 8 | #include <signal.h> |
68c1021b | 9 | |
93d0f2ea | 10 | #include <ust/marker.h> |
fbca6b62 | 11 | #include "usterr.h" |
474d745f | 12 | #include "tp.h" |
b5b073e2 | 13 | #include "tracer.h" |
59b161cd | 14 | |
8d938dbd PMF |
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 | ||
5f54827b | 47 | int main() |
b6bf28ec | 48 | { |
98963de4 | 49 | int i; |
5f54827b | 50 | |
8d938dbd PMF |
51 | init_int_handler(); |
52 | ||
68c1021b | 53 | printf("Hello, World!\n"); |
59b161cd | 54 | |
9c67dc50 | 55 | sleep(1); |
688760ef | 56 | for(i=0; i<50; i++) { |
20b37a31 PMF |
57 | trace_mark(ust, bar, "str %s", "FOOBAZ"); |
58 | trace_mark(ust, bar2, "number1 %d number2 %d", 53, 9800); | |
474d745f | 59 | trace_hello_tptest(i); |
9c67dc50 | 60 | usleep(100000); |
8d938dbd | 61 | } |
59b161cd | 62 | |
68c1021b PMF |
63 | scanf("%*s"); |
64 | ||
688760ef | 65 | ltt_trace_stop("auto"); |
31d392f1 | 66 | ltt_trace_destroy("auto", 0); |
688760ef PMF |
67 | |
68 | DBG("TRACE STOPPED"); | |
69 | scanf("%*s"); | |
70 | ||
68c1021b PMF |
71 | return 0; |
72 | } |