X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=hello%2Fhello.c;h=3bbb2bd94961523bb7721fae991ef5a5740e423a;hb=3847c3bab100bfb6b01b5654c2429a5d0d162ff5;hp=0735fd6b6004a518d2c37f11c11623c2d97f2d3f;hpb=59b161cdfcaad93fee295add37090a3d991e7aa8;p=lttng-ust.git diff --git a/hello/hello.c b/hello/hello.c index 0735fd6b..3bbb2bd9 100644 --- a/hello/hello.c +++ b/hello/hello.c @@ -1,7 +1,18 @@ #include #include +#include +#include +#include +#include +#include #include "../libmarkers/marker.h" +#include "usterr.h" +#include "tracer.h" +#include "marker-control.h" +#include "relay.h" + + void probe(const struct marker *mdata, void *probe_private, void *call_private, @@ -10,15 +21,57 @@ void probe(const struct marker *mdata, printf("In probe\n"); } +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() { - printf("Hello, World!\n"); + int result; + int i; + + init_int_handler(); - marker_probe_register("abc", "testmark", "", probe, NULL); + printf("Hello, World!\n"); - trace_mark(abc, testmark, "", MARK_NOARGS); + sleep(1); + for(i=0; i<5000; i++) { + trace_mark(ust, bar, "str %s", "FOOBAZ"); + trace_mark(ust, bar2, "number1 %d number2 %d", 53, 9800); + usleep(100000); + } scanf("%*s"); return 0; } + +MARKER_LIB