comment synchronize_sched()
[ust.git] / hello / hello.c
index 44aa882bc1def1efa6cb5db6cb59237c5cc4b266..102b7db258ce566daff95bc2ce540c629a75d1f8 100644 (file)
@@ -1,71 +1,79 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
 
-#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;
This page took 0.024929 seconds and 4 git commands to generate.