* @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);
}
/**