#include <poll.h>
#include <regex.h>
-#include <urcu.h>
+#include <urcu-bp.h>
#include "marker.h"
#include "tracer.h"
/* 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;
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\"\n", iter.marker->channel, iter.marker->name, (int)imv_read(iter.marker->state), iter.marker->format);
marker_iter_next(&iter);
}
unlock_markers();
}
}
-int have_listener = 0;
+volatile sig_atomic_t have_listener = 0;
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;
void sighandler(int sig)
{
- static char have_listener = 0;
DBG("sighandler");
if(!have_listener) {
create_listener();
- have_listener = 1;
}
}
}
-static void __attribute__((constructor(1000))) init()
+static void __attribute__((constructor)) init()
{
int result;
char* autoprobe_val = NULL;
return;
}
- inform_consumer_daemon(trace_name);
-
result = ltt_trace_start(trace_name);
if(result < 0) {
ERR("ltt_trace_start failed");
return;
}
+
+ /* Do this after the trace is started in order to avoid creating confusion
+ * if the trace fails to start. */
+ inform_consumer_daemon(trace_name);
}
{
trace_mark(ust, potential_exec, MARK_NOARGS);
+ DBG("test");
+
keepalive();
}