X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=hello%2Fhello.c;h=821bed33ea436ed081bb19c0e8f012be9daab9f1;hb=1f8b0dffac11b11fa7b582b6274c6b4cadf57bb3;hp=44aa882bc1def1efa6cb5db6cb59237c5cc4b266;hpb=5f54827b88b093974e4bf58f67490036718644c7;p=ust.git diff --git a/hello/hello.c b/hello/hello.c index 44aa882..821bed3 100644 --- a/hello/hello.c +++ b/hello/hello.c @@ -1,71 +1,78 @@ #include #include #include +#include +#include +#include +#include -#include "../libmarkers/marker.h" +#include "marker.h" #include "usterr.h" #include "tracer.h" +#include "marker-control.h" +#include "relay.h" +#include "tp.h" -void probe(const struct marker *mdata, - void *probe_private, void *call_private, - const char *fmt, va_list *args) + +void inthandler(int sig) { - printf("In probe\n"); + printf("in handler\n"); + exit(0); } -//ust// void try_map() -//ust// { -//ust// char *m; -//ust// -//ust// /* maybe add MAP_LOCKED */ -//ust// m = mmap(NULL, 4096, PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE , -1, 0); -//ust// if(m == (char*)-1) { -//ust// perror("mmap"); -//ust// return; -//ust// } -//ust// -//ust// printf("The mapping is at %p.\n", m); -//ust// strcpy(m, "Hello, Mapping!"); -//ust// } - -int main() +int init_int_handler(void) { int result; + struct sigaction act; - init_ustrelay_transport(); - - char trace_name[] = "theusttrace"; - char trace_type[] = "usttrace"; + result = sigemptyset(&act.sa_mask); + if(result == -1) { + PERROR("sigemptyset"); + return -1; + } - marker_probe_register("abc", "testmark", "", probe, NULL); - marker_probe_register("metadata", "core_marker_id", "channel %s name %s event_id %hu int #1u%zu long #1u%zu pointer #1u%zu size_t #1u%zu alignment #1u%u", probe, NULL); + act.sa_handler = inthandler; + act.sa_flags = SA_RESTART; - result = ltt_trace_setup(trace_name); - if(result < 0) { - ERR("ltt_trace_setup failed"); - return 1; + /* 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; } -//ust// result = ltt_trace_set_type(trace_name, trace_type); -//ust// if(result < 0) { -//ust// ERR("ltt_trace_set_type failed"); -//ust// return 1; -//ust// } + return 0; +} - result = ltt_trace_alloc(trace_name); - if(result < 0) { - ERR("ltt_trace_alloc failed"); - return 1; - } +int main() +{ + int result; + int i; -// try_map(); + 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); + } - trace_mark(abc, testmark, "", MARK_NOARGS); + scanf("%*s"); + + ltt_trace_stop("auto"); + ltt_trace_destroy("auto"); + DBG("TRACE STOPPED"); scanf("%*s"); return 0; } + +MARKER_LIB; +TRACEPOINT_LIB;