Merge branch 'for-pierre-marc' of git://git.infradead.org/users/jblunck/ust
[ust.git] / libust / tracectl.c
index faa471461c71c901b9399682ac019f0cb8fe1c13..e28b3159d73c1408b58b072850f2bb89a45d59eb 100644 (file)
 #include <poll.h>
 #include <regex.h>
 
-#include <urcu.h>
+#include <urcu-bp.h>
 
-#include "marker.h"
+#include <ust/marker.h>
 #include "tracer.h"
-#include "localerr.h"
+#include "usterr.h"
 #include "ustcomm.h"
 #include "relay.h" /* FIXME: remove */
 #include "marker-control.h"
@@ -63,10 +63,6 @@ struct tracecmd { /* no padding */
 /* volatile because shared between the listener and the main thread */
 volatile sig_atomic_t buffers_to_export = 0;
 
-//struct listener_arg {
-//     int pipe_fd;
-//};
-
 struct trctl_msg {
        /* size: the size of all the fields except size itself */
        uint32_t size;
@@ -121,7 +117,7 @@ static void print_markers(FILE *fp)
        marker_iter_start(&iter);
 
        while(iter.marker) {
-               fprintf(fp, "marker: %s/%s %d \"%s\"\n", iter.marker->channel, iter.marker->name, (int)imv_read(iter.marker->state), iter.marker->format);
+               fprintf(fp, "marker: %s/%s %d \"%s\" %p\n", iter.marker->channel, iter.marker->name, (int)imv_read(iter.marker->state), iter.marker->format, iter.marker->location);
                marker_iter_next(&iter);
        }
        unlock_markers();
@@ -778,15 +774,18 @@ void create_listener(void)
 {
 #ifdef USE_CLONE
        static char listener_stack[16384];
+       int result;
 #else
        pthread_t thread;
 #endif
 
-       if(have_listener)
+       if(have_listener) {
+               WARN("not creating listener because we already had one");
                return;
+       }
 
 #ifdef USE_CLONE
-       result = clone(listener_main, listener_stack+sizeof(listener_stack)-1, CLONE_FS | CLONE_FILES | CLONE_VM | CLONE_SIGHAND | CLONE_THREAD, NULL);
+       result = clone((int (*)(void *)) listener_main, listener_stack+sizeof(listener_stack)-1, CLONE_FS | CLONE_FILES | CLONE_VM | CLONE_SIGHAND | CLONE_THREAD, NULL);
        if(result == -1) {
                perror("clone");
                return;
@@ -799,61 +798,11 @@ void create_listener(void)
        have_listener = 1;
 }
 
-/* The signal handler itself. Signals must be setup so there cannot be
-   nested signals. */
-
-void sighandler(int sig)
-{
-       DBG("sighandler");
-
-       if(!have_listener) {
-               create_listener();
-       }
-}
-
-/* Called by the app signal handler to chain it to us. */
-
-void chain_signal(void)
-{
-       sighandler(USTSIGNAL);
-}
-
 static int init_socket(void)
 {
        return ustcomm_init_app(getpid(), &ustcomm_app);
 }
 
-static int init_signal_handler(void)
-{
-       /* Attempt to handler SIGIO. If the main program wants to
-        * handle it, fine, it'll override us. They it'll have to
-        * use the chaining function.
-        */
-
-       int result;
-       struct sigaction act;
-
-       result = sigemptyset(&act.sa_mask);
-       if(result == -1) {
-               PERROR("sigemptyset");
-               return -1;
-       }
-
-       act.sa_handler = sighandler;
-       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(SIGIO, &act, NULL);
-       if(result == -1) {
-               PERROR("sigaction");
-               return -1;
-       }
-
-       return 0;
-}
-
 #define AUTOPROBE_DISABLED      0
 #define AUTOPROBE_ENABLE_ALL    1
 #define AUTOPROBE_ENABLE_REGEX  2
@@ -888,11 +837,11 @@ static void auto_probe_connect(struct marker *m)
        if(result && result != -EEXIST)
                ERR("ltt_marker_connect (marker = %s/%s, errno = %d)", m->channel, m->name, -result);
 
-       DBG("auto connected marker %s %s to probe default", m->channel, m->name);
+       DBG("auto connected marker %s (addr: %p) %s to probe default", m->channel, m, m->name);
 
 }
 
-static void __attribute__((constructor(1000))) init()
+static void __attribute__((constructor)) init()
 {
        int result;
        char* autoprobe_val = NULL;
@@ -917,11 +866,8 @@ static void __attribute__((constructor(1000))) init()
                ERR("init_socket error");
                return;
        }
-       result = init_signal_handler();
-       if(result == -1) {
-               ERR("init_signal_handler error");
-               return;
-       }
+
+       create_listener();
 
        autoprobe_val = getenv("UST_AUTOPROBE");
        if(autoprobe_val) {
@@ -1132,6 +1078,8 @@ void ust_potential_exec(void)
 {
        trace_mark(ust, potential_exec, MARK_NOARGS);
 
+       DBG("test");
+
        keepalive();
 }
 
This page took 0.024013 seconds and 4 git commands to generate.