};
extern pid_t *ustcmd_get_online_pids(void);
-extern int ustcmd_set_marker_state(const char *channel, const char *marker,
-int state, pid_t pid);
-extern int ustcmd_set_subbuf_size(const char *channel, unsigned int subbuf_size,
+extern int ustcmd_set_marker_state(const char *trace, const char *channel,
+ const char *marker, int state, pid_t pid);
+extern int ustcmd_set_subbuf_size(const char *trace, const char *channel,
+ unsigned int subbuf_size, pid_t pid);
+extern int ustcmd_set_subbuf_num(const char *trace, const char *channel,
+ unsigned int num, pid_t pid);
+extern int ustcmd_get_subbuf_size(const char *trace, const char *channel,
pid_t pid);
-extern int ustcmd_set_subbuf_num(const char *channel, unsigned int num,
+extern int ustcmd_get_subbuf_num(const char *trace, const char *channel,
pid_t pid);
-extern int ustcmd_get_subbuf_size(const char *channel, pid_t pid);
-extern int ustcmd_get_subbuf_num(const char *channel, pid_t pid);
-extern int ustcmd_destroy_trace(pid_t pid);
-extern int ustcmd_setup_and_start(pid_t pid);
-extern int ustcmd_stop_trace(pid_t pid);
-extern int ustcmd_create_trace(pid_t pid);
-extern int ustcmd_start_trace(pid_t pid);
-extern int ustcmd_alloc_trace(pid_t pid);
+extern int ustcmd_destroy_trace(const char *trace, pid_t pid);
+extern int ustcmd_setup_and_start(const char *trace, pid_t pid);
+extern int ustcmd_stop_trace(const char *trace, pid_t pid);
+extern int ustcmd_create_trace(const char *trace, pid_t pid);
+extern int ustcmd_start_trace(const char *trace, pid_t pid);
+extern int ustcmd_alloc_trace(const char *trace, pid_t pid);
extern int ustcmd_free_cmsf(struct marker_status *);
extern unsigned int ustcmd_count_nl(const char *);
extern int ustcmd_get_cmsf(struct marker_status **, pid_t);
struct buffer_info {
char *name;
+ char *trace;
char *channel;
int channel_cpu;
static void request_buffer_consumer(int sock,
- const char *channel,
- int cpu)
+ const char *trace,
+ const char *channel,
+ int cpu)
{
struct ustcomm_header send_header, recv_header;
struct ustcomm_buffer_info buf_inf;
result = ustcomm_pack_buffer_info(&send_header,
&buf_inf,
+ trace,
channel,
cpu);
/* iterate on all cpus */
for (j=0; j<trace->channels[i].n_cpus; j++) {
ch_name = trace->channels[i].channel_name;
- request_buffer_consumer(sock, ch_name, j);
+ request_buffer_consumer(sock, trace_name,
+ ch_name, j);
STORE_SHARED(buffers_to_export,
LOAD_SHARED(buffers_to_export)+1);
}
/* Simple commands are those which need only respond with a return value. */
static int process_simple_client_cmd(int command, char *recv_buf)
{
- int result;
- char trace_type[] = "ustrelay";
- char trace_name[] = "auto";
-
switch(command) {
case SET_SOCK_PATH:
{
}
return setenv("UST_DAEMON_SOCKET", sock_msg->sock_path, 1);
}
+
+ case FORCE_SUBBUF_SWITCH:
+ /* FIXME: return codes? */
+ force_subbuf_switch();
+
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+
+static int process_trace_cmd(int command, char *trace_name)
+{
+ int result;
+ char trace_type[] = "ustrelay";
+
+ switch(command) {
case START:
/* start is an operation that setups the trace, allocates it and starts it */
result = ltt_trace_setup(trace_name);
return result;
}
return 0;
- case FORCE_SUBBUF_SWITCH:
- /* FIXME: return codes? */
- force_subbuf_switch();
-
- break;
-
- default:
- return -EINVAL;
}
return 0;
}
+
static void process_channel_cmd(int sock, int command,
struct ustcomm_channel_info *ch_inf)
{
struct ustcomm_header *reply_header = &_reply_header;
struct ustcomm_channel_info *reply_msg =
(struct ustcomm_channel_info *)send_buffer;
- char trace_name[] = "auto";
int result, offset = 0, num, size;
memset(reply_header, 0, sizeof(*reply_header));
switch (command) {
case GET_SUBBUF_NUM_SIZE:
- result = get_subbuf_num_size(trace_name,
+ result = get_subbuf_num_size(ch_inf->trace,
ch_inf->channel,
&num, &size);
if (result < 0) {
break;
case SET_SUBBUF_NUM:
- reply_header->result = set_subbuf_num(trace_name,
+ reply_header->result = set_subbuf_num(ch_inf->trace,
ch_inf->channel,
ch_inf->subbuf_num);
break;
case SET_SUBBUF_SIZE:
- reply_header->result = set_subbuf_size(trace_name,
+ reply_header->result = set_subbuf_size(ch_inf->trace,
ch_inf->channel,
ch_inf->subbuf_size);
struct ustcomm_header *reply_header = &_reply_header;
struct ustcomm_buffer_info *reply_msg =
(struct ustcomm_buffer_info *)send_buffer;
- char trace_name[] = "auto";
int result, offset = 0, buf_shmid, buf_struct_shmid, buf_pipe_fd;
long consumed_old;
switch (command) {
case GET_BUF_SHMID_PIPE_FD:
- result = get_buffer_shmid_pipe_fd(trace_name, buf_inf->channel,
+ result = get_buffer_shmid_pipe_fd(buf_inf->trace,
+ buf_inf->channel,
buf_inf->ch_cpu,
&buf_shmid,
&buf_struct_shmid,
case NOTIFY_BUF_MAPPED:
reply_header->result =
- notify_buffer_mapped(trace_name,
+ notify_buffer_mapped(buf_inf->trace,
buf_inf->channel,
buf_inf->ch_cpu);
break;
case GET_SUBBUFFER:
- result = get_subbuffer(trace_name, buf_inf->channel,
+ result = get_subbuffer(buf_inf->trace, buf_inf->channel,
buf_inf->ch_cpu, &consumed_old);
if (result < 0) {
reply_header->result = result;
break;
case PUT_SUBBUFFER:
- result = put_subbuffer(trace_name, buf_inf->channel,
+ result = put_subbuffer(buf_inf->trace, buf_inf->channel,
buf_inf->ch_cpu,
buf_inf->consumed_old);
reply_header->result = result;
goto send_response;
}
+ case START:
+ case SETUP_TRACE:
+ case ALLOC_TRACE:
+ case CREATE_TRACE:
+ case START_TRACE:
+ case STOP_TRACE:
+ case DESTROY_TRACE:
+ {
+ struct ustcomm_trace_info *trace_inf =
+ (struct ustcomm_trace_info *)recv_buf;
+
+ result = ustcomm_unpack_trace_info(trace_inf);
+ if (result < 0) {
+ ERR("couldn't unpack trace info");
+ reply_header->result = -EINVAL;
+ goto send_response;
+ }
+
+ reply_header->result =
+ process_trace_cmd(recv_header->command,
+ trace_inf->trace);
+ goto send_response;
+
+ }
default:
reply_header->result =
process_simple_client_cmd(recv_header->command,
* @param pid Traced process ID
* @return 0 if successful, or errors {USTCMD_ERR_GEN, USTCMD_ERR_ARG}
*/
-int ustcmd_set_marker_state(const char *channel, const char *marker,
- int state, pid_t pid)
+int ustcmd_set_marker_state(const char *trace, const char *channel,
+ const char *marker, int state, pid_t pid)
{
struct ustcomm_header req_header, res_header;
struct ustcomm_marker_info marker_inf;
result = ustcomm_pack_marker_info(&req_header,
&marker_inf,
+ trace,
channel,
marker);
if (result < 0) {
* @param pid Traced process ID
* @return 0 if successful, or error
*/
-int ustcmd_set_subbuf_size(const char *channel, unsigned int subbuf_size,
- pid_t pid)
+int ustcmd_set_subbuf_size(const char *trace, const char *channel,
+ unsigned int subbuf_size, pid_t pid)
{
struct ustcomm_header req_header, res_header;
struct ustcomm_channel_info ch_inf;
result = ustcomm_pack_channel_info(&req_header,
&ch_inf,
+ trace,
channel);
if (result < 0) {
errno = -result;
* @param pid Traced process ID
* @return 0 if successful, or error
*/
-int ustcmd_set_subbuf_num(const char *channel, unsigned int num,
- pid_t pid)
+int ustcmd_set_subbuf_num(const char *trace, const char *channel,
+ unsigned int num, pid_t pid)
{
struct ustcomm_header req_header, res_header;
struct ustcomm_channel_info ch_inf;
result = ustcomm_pack_channel_info(&req_header,
&ch_inf,
+ trace,
channel);
if (result < 0) {
errno = -result;
}
-static int ustcmd_get_subbuf_num_size(const char *channel, pid_t pid,
- int *num, int *size)
+static int ustcmd_get_subbuf_num_size(const char *trace, const char *channel,
+ pid_t pid, int *num, int *size)
{
struct ustcomm_header req_header, res_header;
struct ustcomm_channel_info ch_inf, *ch_inf_res;
result = ustcomm_pack_channel_info(&req_header,
&ch_inf,
+ trace,
channel);
if (result < 0) {
errno = -result;
* @param pid Traced process ID
* @return subbuf cnf if successful, or error
*/
-int ustcmd_get_subbuf_num(const char *channel, pid_t pid)
+int ustcmd_get_subbuf_num(const char *trace, const char *channel, pid_t pid)
{
int num, size, result;
- result = ustcmd_get_subbuf_num_size(channel, pid,
+ result = ustcmd_get_subbuf_num_size(trace, channel, pid,
&num, &size);
if (result < 0) {
errno = -result;
* @param pid Traced process ID
* @return subbuf size if successful, or error
*/
-int ustcmd_get_subbuf_size(const char *channel, pid_t pid)
+int ustcmd_get_subbuf_size(const char *trace, const char *channel, pid_t pid)
{
int num, size, result;
- result = ustcmd_get_subbuf_num_size(channel, pid,
+ result = ustcmd_get_subbuf_num_size(trace, channel, pid,
&num, &size);
if (result < 0) {
errno = -result;
return size;
}
+
+static int do_trace_cmd(const char *trace, pid_t pid, int command)
+{
+ struct ustcomm_header req_header, res_header;
+ struct ustcomm_trace_info trace_inf;
+ int result;
+
+ result = ustcomm_pack_trace_info(&req_header,
+ &trace_inf,
+ trace);
+ if (result < 0) {
+ errno = -result;
+ return -1;
+ }
+
+ req_header.command = command;
+
+ return do_cmd(pid, &req_header, (char *)&trace_inf, &res_header, NULL);
+}
+
/**
* Destroys an UST trace according to a PID.
*
* @param pid Traced process ID
* @return 0 if successful, or error USTCMD_ERR_GEN
*/
-int ustcmd_destroy_trace(pid_t pid)
+int ustcmd_destroy_trace(const char *trace, pid_t pid)
{
- struct ustcomm_header req_header, res_header;
-
- req_header.command = DESTROY_TRACE;
- req_header.size = 0;
-
- return do_cmd(pid, &req_header, NULL, &res_header, NULL);
+ return do_trace_cmd(trace, pid, DESTROY_TRACE);
}
/**
* @param pid Traced process ID
* @return 0 if successful, or error USTCMD_ERR_GEN
*/
-int ustcmd_setup_and_start(pid_t pid)
+int ustcmd_setup_and_start(const char *trace, pid_t pid)
{
- struct ustcomm_header req_header, res_header;
-
- req_header.command = START;
- req_header.size = 0;
-
- return do_cmd(pid, &req_header, NULL, &res_header, NULL);
+ return do_trace_cmd(trace, pid, START);
}
/**
* @param pid Traced process ID
* @return 0 if successful, or error USTCMD_ERR_GEN
*/
-int ustcmd_create_trace(pid_t pid)
+int ustcmd_create_trace(const char *trace, pid_t pid)
{
- struct ustcomm_header req_header, res_header;
-
- req_header.command = CREATE_TRACE;
- req_header.size = 0;
-
- return do_cmd(pid, &req_header, NULL, &res_header, NULL);
+ return do_trace_cmd(trace, pid, CREATE_TRACE);
}
/**
* @param pid Traced process ID
* @return 0 if successful, or error USTCMD_ERR_GEN
*/
-int ustcmd_start_trace(pid_t pid)
+int ustcmd_start_trace(const char *trace, pid_t pid)
{
- struct ustcomm_header req_header, res_header;
-
- req_header.command = START_TRACE;
- req_header.size = 0;
-
- return do_cmd(pid, &req_header, NULL, &res_header, NULL);
+ return do_trace_cmd(trace, pid, START_TRACE);
}
/**
* @param pid Traced process ID
* @return 0 if successful, or error USTCMD_ERR_GEN
*/
-int ustcmd_alloc_trace(pid_t pid)
+int ustcmd_alloc_trace(const char *trace, pid_t pid)
{
- struct ustcomm_header req_header, res_header;
-
- req_header.command = ALLOC_TRACE;
- req_header.size = 0;
-
- return do_cmd(pid, &req_header, NULL, &res_header, NULL);
+ return do_trace_cmd(trace, pid, ALLOC_TRACE);
}
/**
* @param pid Traced process ID
* @return 0 if successful, or error USTCMD_ERR_GEN
*/
-int ustcmd_stop_trace(pid_t pid)
+int ustcmd_stop_trace(const char *trace, pid_t pid)
{
- struct ustcomm_header req_header, res_header;
-
- req_header.command = STOP_TRACE;
- req_header.size = 0;
-
- return do_cmd(pid, &req_header, NULL, &res_header, NULL);
+ return do_trace_cmd(trace, pid, STOP_TRACE);
}
/**
int ustcomm_pack_channel_info(struct ustcomm_header *header,
struct ustcomm_channel_info *ch_inf,
+ const char *trace,
const char *channel)
{
int offset = 0;
+ ch_inf->trace = ustcomm_print_data(ch_inf->data,
+ sizeof(ch_inf->data),
+ &offset,
+ trace);
+
+ if (ch_inf->trace == USTCOMM_POISON_PTR) {
+ return -ENOMEM;
+ }
+
ch_inf->channel = ustcomm_print_data(ch_inf->data,
sizeof(ch_inf->data),
&offset,
int ustcomm_unpack_channel_info(struct ustcomm_channel_info *ch_inf)
{
+ ch_inf->trace = ustcomm_restore_ptr(ch_inf->trace,
+ ch_inf->data,
+ sizeof(ch_inf->data));
+ if (!ch_inf->trace) {
+ return -EINVAL;
+ }
+
ch_inf->channel = ustcomm_restore_ptr(ch_inf->channel,
ch_inf->data,
sizeof(ch_inf->data));
int ustcomm_pack_buffer_info(struct ustcomm_header *header,
struct ustcomm_buffer_info *buf_inf,
+ const char *trace,
const char *channel,
int channel_cpu)
{
int offset = 0;
+ buf_inf->trace = ustcomm_print_data(buf_inf->data,
+ sizeof(buf_inf->data),
+ &offset,
+ trace);
+
+ if (buf_inf->trace == USTCOMM_POISON_PTR) {
+ return -ENOMEM;
+ }
+
buf_inf->channel = ustcomm_print_data(buf_inf->data,
sizeof(buf_inf->data),
&offset,
int ustcomm_unpack_buffer_info(struct ustcomm_buffer_info *buf_inf)
{
+ buf_inf->trace = ustcomm_restore_ptr(buf_inf->trace,
+ buf_inf->data,
+ sizeof(buf_inf->data));
+ if (!buf_inf->trace) {
+ return -EINVAL;
+ }
+
buf_inf->channel = ustcomm_restore_ptr(buf_inf->channel,
buf_inf->data,
sizeof(buf_inf->data));
int ustcomm_pack_marker_info(struct ustcomm_header *header,
struct ustcomm_marker_info *marker_inf,
+ const char *trace,
const char *channel,
const char *marker)
{
int offset = 0;
+ marker_inf->trace = ustcomm_print_data(marker_inf->data,
+ sizeof(marker_inf->data),
+ &offset,
+ trace);
+
+ if (marker_inf->trace == USTCOMM_POISON_PTR) {
+ return -ENOMEM;
+ }
+
+
marker_inf->channel = ustcomm_print_data(marker_inf->data,
sizeof(marker_inf->data),
&offset,
int ustcomm_unpack_marker_info(struct ustcomm_marker_info *marker_inf)
{
+ marker_inf->trace = ustcomm_restore_ptr(marker_inf->trace,
+ marker_inf->data,
+ sizeof(marker_inf->data));
+ if (!marker_inf->trace) {
+ return -EINVAL;
+ }
+
marker_inf->channel = ustcomm_restore_ptr(marker_inf->channel,
marker_inf->data,
sizeof(marker_inf->data));
};
struct ustcomm_channel_info {
+ char *trace;
char *channel;
unsigned int subbuf_size;
unsigned int subbuf_num;
};
struct ustcomm_buffer_info {
+ char *trace;
char *channel;
int ch_cpu;
pid_t pid;
};
struct ustcomm_marker_info {
+ char *trace;
char *channel;
char *marker;
char data[USTCOMM_DATA_SIZE];
extern int ustcomm_pack_channel_info(struct ustcomm_header *header,
struct ustcomm_channel_info *ch_inf,
+ const char *trace,
const char *channel);
extern int ustcomm_unpack_channel_info(struct ustcomm_channel_info *ch_inf);
extern int ustcomm_pack_buffer_info(struct ustcomm_header *header,
struct ustcomm_buffer_info *buf_inf,
+ const char *trace,
const char *channel,
int channel_cpu);
extern int ustcomm_pack_marker_info(struct ustcomm_header *header,
struct ustcomm_marker_info *marker_inf,
+ const char *trace,
const char *channel,
const char *marker);
send_msg = &_send_msg;
recv_msg = &_recv_msg;
- result = ustcomm_pack_buffer_info(send_hdr, send_msg,
+ result = ustcomm_pack_buffer_info(send_hdr, send_msg, buf->trace,
buf->channel, buf->channel_cpu);
if (result < 0) {
return result;
recv_hdr = &_recv_hdr;
send_msg = &_send_msg;
- result = ustcomm_pack_buffer_info(send_hdr, send_msg,
+ result = ustcomm_pack_buffer_info(send_hdr, send_msg, buf->trace,
buf->channel, buf->channel_cpu);
if (result < 0) {
return result;
send_msg = &_send_msg;
recv_msg = &_recv_msg;
- result = ustcomm_pack_buffer_info(send_hdr, send_msg,
+ result = ustcomm_pack_buffer_info(send_hdr, send_msg, buf->trace,
buf->channel, buf->channel_cpu);
if (result < 0) {
ERR("Failed to pack buffer info");
send_msg = &_send_msg;
recv_msg = &_recv_msg;
- result = ustcomm_pack_channel_info(send_hdr, send_msg,
+ result = ustcomm_pack_channel_info(send_hdr, send_msg, buf->trace,
buf->channel);
if (result < 0) {
return result;
recv_hdr = &_recv_hdr;
send_msg = &_send_msg;
- result = ustcomm_pack_buffer_info(send_hdr, send_msg,
+ result = ustcomm_pack_buffer_info(send_hdr, send_msg, buf->trace,
buf->channel, buf->channel_cpu);
if (result < 0) {
return result;
struct buffer_info *connect_buffer(struct libustd_instance *instance, pid_t pid,
- const char *channel, int channel_cpu)
+ const char *trace, const char *channel,
+ int channel_cpu)
{
struct buffer_info *buf;
int result;
return NULL;
}
+ buf->trace = strdup(trace);
+ if (!buf->trace) {
+ goto free_buf;
+ }
+
buf->channel = strdup(channel);
if (!buf->channel) {
- goto free_buf;
+ goto free_buf_trace;
}
result = asprintf(&buf->name, "%s_%d", channel, channel_cpu);
free_buf_channel:
free(buf->channel);
+free_buf_trace:
+ free(buf->trace);
+
free_buf:
free(buf);
return NULL;
struct consumer_thread_args {
pid_t pid;
+ const char *trace;
const char *channel;
int channel_cpu;
struct libustd_instance *instance;
goto end;
}
- buf = connect_buffer(args->instance, args->pid,
+ buf = connect_buffer(args->instance, args->pid, args->trace,
args->channel, args->channel_cpu);
if(buf == NULL) {
ERR("failed to connect to buffer");
}
int start_consuming_buffer(struct libustd_instance *instance, pid_t pid,
- const char *channel, int channel_cpu)
+ const char *trace, const char *channel,
+ int channel_cpu)
{
pthread_t thr;
struct consumer_thread_args *args;
}
args->pid = pid;
+ args->trace = strdup(trace);
args->channel = strdup(channel);
args->channel_cpu = channel_cpu;
args->instance = instance;
- DBG("beginning2 of start_consuming_buffer: args: pid %d bufname %s_%d",
- args->pid, args->channel, args->channel_cpu);
+ DBG("beginning2 of start_consuming_buffer: args: pid %d trace %s"
+ " bufname %s_%d", args->pid, args->channel, args->channel_cpu);
result = pthread_create(&thr, NULL, consumer_thread, args);
if(result == -1) {
ERR("pthread_detach failed");
return -1;
}
- DBG("end of start_consuming_buffer: args: pid %d bufname %s_%d",
- args->pid, args->channel, args->channel_cpu);
+ DBG("end of start_consuming_buffer: args: pid %d trace %s "
+ "bufname %s_%d", args->pid, args->channel, args->channel_cpu);
return 0;
}
return;
}
- DBG("Going to consume buffer %s_%d in process %d",
- buf_inf->channel, buf_inf->ch_cpu, buf_inf->pid);
+ DBG("Going to consume trace %s buffer %s_%d in process %d",
+ buf_inf->trace, buf_inf->channel, buf_inf->ch_cpu,
+ buf_inf->pid);
result = start_consuming_buffer(instance, buf_inf->pid,
+ buf_inf->trace,
buf_inf->channel,
buf_inf->ch_cpu);
if (result < 0) {
struct marker_status *marker_status, *ms_ptr;
char *old_socket_path, *new_socket_path;
char *tmp_ustd_socket = "/tmp/tmp_ustd_socket";
+ char *trace = "auto";
printf("Connecting to pid %d\n", pid);
free(old_socket_path);
/* Enable, disable markers */
- tap_ok(!ustcmd_set_marker_state("ust", "bar", 1, pid),
+ tap_ok(!ustcmd_set_marker_state(trace, "ust", "bar", 1, pid),
"ustcmd_set_marker_state - existing marker ust bar");
/* Create and allocate a trace */
- tap_ok(!ustcmd_create_trace(pid), "ustcmd_create_trace");
+ tap_ok(!ustcmd_create_trace(trace, pid), "ustcmd_create_trace");
- tap_ok(!ustcmd_alloc_trace(pid), "ustcmd_alloc_trace");
+ tap_ok(!ustcmd_alloc_trace(trace, pid), "ustcmd_alloc_trace");
/* Get subbuf size and number */
- subbuf_num = ustcmd_get_subbuf_num("ust", pid);
+ subbuf_num = ustcmd_get_subbuf_num(trace, "ust", pid);
tap_ok(subbuf_num > 0, "ustcmd_get_subbuf_num - %d sub-buffers",
subbuf_num);
- subbuf_size = ustcmd_get_subbuf_size("ust", pid);
+ subbuf_size = ustcmd_get_subbuf_size(trace, "ust", pid);
tap_ok(subbuf_size, "ustcmd_get_subbuf_size - sub-buffer size is %d",
subbuf_size);
/* Start the trace */
- tap_ok(!ustcmd_start_trace(pid), "ustcmd_start_trace");
+ tap_ok(!ustcmd_start_trace(trace, pid), "ustcmd_start_trace");
/* Stop the trace and destroy it*/
- tap_ok(!ustcmd_stop_trace(pid), "ustcmd_stop_trace");
+ tap_ok(!ustcmd_stop_trace(trace, pid), "ustcmd_stop_trace");
- tap_ok(!ustcmd_destroy_trace(pid), "ustcmd_destroy_trace");
+ tap_ok(!ustcmd_destroy_trace(trace, pid), "ustcmd_destroy_trace");
/* Create a new trace */
- tap_ok(!ustcmd_create_trace(pid), "ustcmd_create_trace - create a new trace");
+ tap_ok(!ustcmd_create_trace(trace, pid), "ustcmd_create_trace - create a new trace");
printf("Setting new subbufer number and sizes (doubling)\n");
new_subbuf_num = 2 * subbuf_num;
new_subbuf_size = 2 * subbuf_size;
- tap_ok(!ustcmd_set_subbuf_num("ust", new_subbuf_num, pid),
+ tap_ok(!ustcmd_set_subbuf_num(trace, "ust", new_subbuf_num, pid),
"ustcmd_set_subbuf_num");
- tap_ok(!ustcmd_set_subbuf_size("ust", new_subbuf_size, pid),
+ tap_ok(!ustcmd_set_subbuf_size(trace, "ust", new_subbuf_size, pid),
"ustcmd_set_subbuf_size");
/* Allocate the new trace */
- tap_ok(!ustcmd_alloc_trace(pid), "ustcmd_alloc_trace - allocate the new trace");
+ tap_ok(!ustcmd_alloc_trace(trace, pid), "ustcmd_alloc_trace - allocate the new trace");
/* Get subbuf size and number and compare with what was set */
- subbuf_num = ustcmd_get_subbuf_num("ust", pid);
+ subbuf_num = ustcmd_get_subbuf_num(trace, "ust", pid);
- subbuf_size = ustcmd_get_subbuf_size("ust", pid);
+ subbuf_size = ustcmd_get_subbuf_size(trace, "ust", pid);
tap_ok(subbuf_num == new_subbuf_num, "Set a new subbuf number, %d == %d",
subbuf_num, new_subbuf_num);
- result = ustcmd_get_subbuf_size("ust", pid);
+ result = ustcmd_get_subbuf_size(trace, "ust", pid);
tap_ok(subbuf_size == new_subbuf_size, "Set a new subbuf size, %d == %d",
subbuf_size, new_subbuf_size);
- tap_ok(!ustcmd_destroy_trace(pid), "ustcmd_destroy_trace - without ever starting");
+ tap_ok(!ustcmd_destroy_trace(trace, pid), "ustcmd_destroy_trace - without ever starting");
printf("##### Tests that definetly should work are completed #####\n");
printf("############## Start expected failure cases ##############\n");
- tap_ok(ustcmd_set_marker_state("ust","bar", 1, pid),
+ tap_ok(ustcmd_set_marker_state(trace, "ust","bar", 1, pid),
"Enable already enabled marker ust/bar");
- tap_ok(ustcmd_set_marker_state("ustl", "blar", 1, pid),
+ tap_ok(ustcmd_set_marker_state(trace, "ustl", "blar", 1, pid),
"Enable non-existent marker ustl blar");
- tap_ok(ustcmd_start_trace(pid),
+ tap_ok(ustcmd_start_trace(trace, pid),
"Start a non-existent trace");
- tap_ok(ustcmd_destroy_trace(pid),
+ tap_ok(ustcmd_destroy_trace(trace, pid),
"Destroy non-existent trace");
exit(tap_status() ? EXIT_FAILURE : EXIT_SUCCESS);
}
}
+char *trace = "auto";
+
int main(int argc, char *argv[])
{
pid_t *pidit;
while(*pidit != -1) {
switch (opts.cmd) {
case CREATE_TRACE:
- result = ustcmd_create_trace(*pidit);
+ result = ustcmd_create_trace(trace, *pidit);
if (result) {
ERR("error while trying to create trace with PID %u\n", (unsigned int) *pidit);
retval = EXIT_FAILURE;
break;
case START_TRACE:
- result = ustcmd_start_trace(*pidit);
+ result = ustcmd_start_trace(trace, *pidit);
if (result) {
ERR("error while trying to for trace with PID %u\n", (unsigned int) *pidit);
retval = EXIT_FAILURE;
break;
case STOP_TRACE:
- result = ustcmd_stop_trace(*pidit);
+ result = ustcmd_stop_trace(trace, *pidit);
if (result) {
ERR("error while trying to stop trace for PID %u\n", (unsigned int) *pidit);
retval = EXIT_FAILURE;
break;
case DESTROY_TRACE:
- result = ustcmd_destroy_trace(*pidit);
+ result = ustcmd_destroy_trace(trace, *pidit);
if (result) {
ERR("error while trying to destroy trace with PID %u\n", (unsigned int) *pidit);
retval = EXIT_FAILURE;
retval = EXIT_FAILURE;
break;
}
- if (ustcmd_set_marker_state(channel, marker, 1, *pidit)) {
+ if (ustcmd_set_marker_state(trace, channel, marker, 1, *pidit)) {
PERROR("error while trying to enable marker %s with PID %u",
opts.regex, (unsigned int) *pidit);
retval = EXIT_FAILURE;
retval = EXIT_FAILURE;
break;
}
- if (ustcmd_set_marker_state(channel, marker, 0, *pidit)) {
+ if (ustcmd_set_marker_state(trace, channel, marker, 0, *pidit)) {
ERR("error while trying to disable marker %s with PID %u\n",
opts.regex, (unsigned int) *pidit);
retval = EXIT_FAILURE;
break;
}
- if (ustcmd_set_subbuf_size(channel, size, *pidit)) {
+ if (ustcmd_set_subbuf_size(trace, channel, size, *pidit)) {
ERR("error while trying to set the size of subbuffers with PID %u\n",
(unsigned int) *pidit);
retval = EXIT_FAILURE;
retval = EXIT_FAILURE;
break;
}
- if (ustcmd_set_subbuf_num(channel, num, *pidit)) {
+ if (ustcmd_set_subbuf_num(trace, channel, num, *pidit)) {
ERR("error while trying to set the number of subbuffers with PID %u\n",
(unsigned int) *pidit);
retval = EXIT_FAILURE;
break;
case GET_SUBBUF_SIZE:
- result = ustcmd_get_subbuf_size(opts.regex, *pidit);
+ result = ustcmd_get_subbuf_size(trace, opts.regex, *pidit);
if (result == -1) {
ERR("error while trying to get_subuf_size with PID %u\n", (unsigned int) *pidit);
retval = EXIT_FAILURE;
break;
case GET_SUBBUF_NUM:
- result = ustcmd_get_subbuf_num(opts.regex, *pidit);
+ result = ustcmd_get_subbuf_num(trace, opts.regex, *pidit);
if (result == -1) {
ERR("error while trying to get_subuf_num with PID %u\n", (unsigned int) *pidit);
retval = EXIT_FAILURE;
break;
case ALLOC_TRACE:
- result = ustcmd_alloc_trace(*pidit);
+ result = ustcmd_alloc_trace(trace, *pidit);
if (result) {
ERR("error while trying to alloc trace with PID %u\n", (unsigned int) *pidit);
retval = EXIT_FAILURE;