X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=hello%2Fhello.c;h=88087dff3a1a6d36488310f0135e4eba7e58e76e;hb=a584bc4edb73e3f4c0023c42f2fdbc816fb6eab0;hp=51979861e28b0e37003c1ec7fb6600887701bb7a;hpb=b6bf28ecd4c07e7865d340f1600a35d6edc05ec8;p=lttng-ust.git diff --git a/hello/hello.c b/hello/hello.c index 51979861..88087dff 100644 --- a/hello/hello.c +++ b/hello/hello.c @@ -1,8 +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, @@ -11,34 +21,57 @@ void probe(const struct marker *mdata, printf("In probe\n"); } -void try_map() +void inthandler(int sig) +{ + printf("in handler\n"); + exit(0); +} + +int init_int_handler(void) { - char *m; + 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; - /* maybe add MAP_LOCKED */ - m = mmap(NULL, 4096, PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE , -1, 0); - if(m == (char*)-1) { - perror("mmap"); - return; + /* 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; } - printf("The mapping is at %p.\n", m); - strcpy(m, "Hello, Mapping!"); + return 0; } int main() { - //ltt_trace_create(); + int result; + int i; - try_map(); + init_int_handler(); printf("Hello, World!\n"); - marker_probe_register("abc", "testmark", "", probe, NULL); - - trace_mark(abc, testmark, "", MARK_NOARGS); + 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); + usleep(100000); + } scanf("%*s"); return 0; } + +MARKER_LIB