#include <urcu/uatomic_arch.h>
#include <ust/marker.h>
+#include <ust/tracepoint.h>
#include <ust/tracectl.h>
#include "tracer.h"
#include "usterr.h"
unlock_markers();
}
+static void print_trace_events(FILE *fp)
+{
+ struct trace_event_iter iter;
+
+ lock_trace_events();
+ trace_event_iter_reset(&iter);
+ trace_event_iter_start(&iter);
+
+ while(iter.trace_event) {
+ fprintf(fp, "trace_event: %s\n", iter.trace_event->name);
+ trace_event_iter_next(&iter);
+ }
+ unlock_trace_events();
+}
+
static int init_socket(void);
/* Ask the daemon to collect a trace called trace_name and being
channel_and_cpu = nth_token(recvbuf, 1);
if(channel_and_cpu == NULL) {
ERR("cannot parse channel");
+ retval = -1;
goto end;
}
seperate_channel_cpu(channel_and_cpu, &ch_name, &ch_cpu);
if(ch_cpu == -1) {
ERR("problem parsing channel name");
+ retval = -1;
goto free_short_chan_name;
}
channel_and_cpu = nth_token(recvbuf, 1);
if(channel_and_cpu == NULL) {
ERR("cannot parse channel");
+ retval = -1;
goto end;
}
seperate_channel_cpu(channel_and_cpu, &ch_name, &ch_cpu);
if(ch_cpu == -1) {
ERR("problem parsing channel name");
+ retval = -1;
goto free_short_chan_name;
}
channel_and_cpu = nth_token(recvbuf, 1);
if(channel_and_cpu == NULL) {
ERR("cannot parse channel");
+ retval = -1;
goto end;
}
seperate_channel_cpu(channel_and_cpu, &ch_name, &ch_cpu);
if(ch_cpu == -1) {
ERR("problem parsing channel name");
+ retval = -1;
goto free_short_chan_name;
}
if(ch_name == NULL) {
ERR("cannot parse channel");
+ retval = -1;
goto end;
}
if(ch_name == NULL) {
ERR("cannot parse channel");
+ retval = -1;
goto end;
}
if (num < 2) {
ERR("subbuffer count should be greater than 2");
+ retval = -1;
goto end;
}
channel_and_cpu = nth_token(recvbuf, 1);
if(channel_and_cpu == NULL) {
ERR("cannot parse channel");
+ retval = -1;
goto end;
}
seperate_channel_cpu(channel_and_cpu, &ch_name, &ch_cpu);
if(ch_cpu == -1) {
ERR("problem parsing channel name");
+ retval = -1;
goto free_short_chan_name;
}
found = 1;
- bc = (struct blocked_consumer *) malloc(sizeof(struct blocked_consumer));
+ bc = (struct blocked_consumer *) zmalloc(sizeof(struct blocked_consumer));
if(bc == NULL) {
- ERR("malloc returned NULL");
+ ERR("zmalloc returned NULL");
goto unlock_traces;
}
bc->fd_consumer = src->fd;
result = ustcomm_send_reply(&ustcomm_app.server, ptr, src);
free(ptr);
- }
- else if(!strcmp(recvbuf, "start")) {
+ } else if (!strcmp(recvbuf, "print_trace_events")) {
+ print_trace_events(stderr);
+
+ } else if(!strcmp(recvbuf, "list_trace_events")) {
+ char *ptr;
+ size_t size;
+ FILE *fp;
+
+ fp = open_memstream(&ptr, &size);
+ if (fp == NULL) {
+ ERR("opening memstream failed");
+ return -1;
+ }
+ print_trace_events(fp);
+ fclose(fp);
+
+ result = ustcomm_send_reply(&ustcomm_app.server, ptr, src);
+ if (result < 0) {
+ ERR("list_trace_events failed");
+ return -1;
+ }
+ free(ptr);
+ } else if(!strcmp(recvbuf, "start")) {
/* start is an operation that setups the trace, allocates it and starts it */
result = ltt_trace_setup(trace_name);
if(result < 0) {
result = sscanf(channel_slash_name, "%a[^/]/%as", &channel_name, &marker_name);
- if(marker_name == NULL) {
+ if(channel_name == NULL || marker_name == NULL) {
+ WARN("invalid marker name");
+ goto next_cmd;
}
result = ltt_marker_disconnect(channel_name, marker_name, "default");