X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=hello%2Fhello.c;h=3bbb2bd94961523bb7721fae991ef5a5740e423a;hb=d0b5f2b948ed0da3f8acd10817f85f5200749121;hp=44aa882bc1def1efa6cb5db6cb59237c5cc4b266;hpb=5f54827b88b093974e4bf58f67490036718644c7;p=lttng-ust.git diff --git a/hello/hello.c b/hello/hello.c index 44aa882b..3bbb2bd9 100644 --- a/hello/hello.c +++ b/hello/hello.c @@ -1,10 +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, @@ -13,59 +21,57 @@ void probe(const struct marker *mdata, printf("In probe\n"); } -//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// } +void inthandler(int sig) +{ + printf("in handler\n"); + exit(0); +} -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"); - - 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