X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fhello%2Fhello.c;fp=tests%2Fhello%2Fhello.c;h=102b7db258ce566daff95bc2ce540c629a75d1f8;hb=6dd969b5dd702909b8eb827e850c851053774055;hp=0000000000000000000000000000000000000000;hpb=270c6b98e626861fece078f57a85462fd6cb020c;p=ust.git diff --git a/tests/hello/hello.c b/tests/hello/hello.c new file mode 100644 index 0000000..102b7db --- /dev/null +++ b/tests/hello/hello.c @@ -0,0 +1,79 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "marker.h" +#include "usterr.h" +#include "tracer.h" +#include "marker-control.h" +#include "relay.h" +#include "tp.h" + + +void inthandler(int sig) +{ + printf("in handler\n"); + exit(0); +} + +int init_int_handler(void) +{ + int result; + struct sigaction act; + + result = sigemptyset(&act.sa_mask); + if(result == -1) { + PERROR("sigemptyset"); + return -1; + } + + act.sa_handler = inthandler; + act.sa_flags = SA_RESTART; + + /* Only defer ourselves. Also, try to restart interrupted + * syscalls to disturb the traced program as little as possible. + */ + result = sigaction(SIGINT, &act, NULL); + if(result == -1) { + PERROR("sigaction"); + return -1; + } + + return 0; +} + +int main() +{ + int result; + int i; + + init_int_handler(); + + printf("Hello, World!\n"); + + sleep(1); + for(i=0; i<50; i++) { + trace_mark(ust, bar, "str %s", "FOOBAZ"); + trace_mark(ust, bar2, "number1 %d number2 %d", 53, 9800); + trace_hello_tptest(i); + usleep(100000); + } + + scanf("%*s"); + + ltt_trace_stop("auto"); + ltt_trace_destroy("auto"); + + DBG("TRACE STOPPED"); + scanf("%*s"); + + return 0; +} + +MARKER_LIB; +TRACEPOINT_LIB;