}
}
- /* Close pid, domain, domains */
+ /* Close pids, domain, domains */
ret = mi_lttng_close_multi_element(writer, 3);
end:
return ret;
return ret;
}
+static const char *get_tracker_str(enum lttng_tracker_type tracker_type)
+{
+ switch (tracker_type) {
+ case LTTNG_TRACKER_PID:
+ return "PID";
+ case LTTNG_TRACKER_VPID:
+ return "VPID";
+ case LTTNG_TRACKER_UID:
+ return "UID";
+ case LTTNG_TRACKER_VUID:
+ return "VUID";
+ case LTTNG_TRACKER_GID:
+ return "GID";
+ case LTTNG_TRACKER_VGID:
+ return "VGID";
+ }
+ return NULL;
+}
+
/*
- * List tracker PID(s) of session and domain.
+ * List tracker ID(s) of session and domain.
*/
-static int list_tracker_pids(void)
+static int list_tracker_ids(enum lttng_tracker_type tracker_type)
{
int ret = 0;
- int enabled;
- int *pids = NULL;
- size_t nr_pids;
+ int enabled = 1;
+ struct lttng_tracker_id *ids = NULL;
+ size_t nr_ids, i;
- ret = lttng_list_tracker_pids(handle,
- &enabled, &pids, &nr_pids);
+ ret = lttng_list_tracker_ids(handle, tracker_type, &ids, &nr_ids);
if (ret) {
return ret;
}
+ if (nr_ids == 1 && ids[0].type == LTTNG_ID_ALL) {
+ enabled = 0;
+ }
if (enabled) {
- int i;
- _MSG("PID tracker: [");
+ _MSG("%s tracker: [", get_tracker_str(tracker_type));
- /* Mi tracker_pid element*/
+ /* Mi tracker_id element */
if (writer) {
- /* Open tracker_pid and targets elements */
- ret = mi_lttng_pid_tracker_open(writer);
+ /* Open tracker_id and targets elements */
+ ret = mi_lttng_id_tracker_open(writer, tracker_type);
if (ret) {
goto end;
}
}
- for (i = 0; i < nr_pids; i++) {
+ for (i = 0; i < nr_ids; i++) {
+ struct lttng_tracker_id *id = &ids[i];
+
if (i) {
_MSG(",");
}
- _MSG(" %d", pids[i]);
+ switch (id->type) {
+ case LTTNG_ID_ALL:
+ _MSG(" *");
+ break;
+ case LTTNG_ID_VALUE:
+ _MSG(" %d", ids[i].value);
+ break;
+ case LTTNG_ID_STRING:
+ _MSG(" %s", ids[i].string);
+ break;
+ case LTTNG_ID_UNKNOWN:
+ return CMD_ERROR;
+ }
/* Mi */
if (writer) {
- ret = mi_lttng_pid_target(writer, pids[i], 0);
+ ret = mi_lttng_id_target(
+ writer, tracker_type, id, 0);
if (ret) {
goto end;
}
}
_MSG(" ]\n\n");
- /* Mi close tracker_pid and targets */
+ /* Mi close tracker_id and targets */
if (writer) {
- ret = mi_lttng_close_multi_element(writer,2);
+ ret = mi_lttng_close_multi_element(writer, 2);
if (ret) {
goto end;
}
}
}
end:
- free(pids);
+ for (i = 0; i < nr_ids; i++) {
+ free(ids[i].string);
+ }
+ free(ids);
return ret;
-
}
/*
- * List all tracker of a domain
+ * List all trackers of a domain
*/
-static int list_trackers(void)
+static int list_trackers(const struct lttng_domain *domain)
{
int ret;
}
}
- /* pid tracker */
- ret = list_tracker_pids();
- if (ret) {
- goto end;
+ switch (domain->type) {
+ case LTTNG_DOMAIN_KERNEL:
+ /* pid tracker */
+ ret = list_tracker_ids(LTTNG_TRACKER_PID);
+ if (ret) {
+ goto end;
+ }
+ /* vpid tracker */
+ ret = list_tracker_ids(LTTNG_TRACKER_VPID);
+ if (ret) {
+ goto end;
+ }
+ /* uid tracker */
+ ret = list_tracker_ids(LTTNG_TRACKER_UID);
+ if (ret) {
+ goto end;
+ }
+ /* vuid tracker */
+ ret = list_tracker_ids(LTTNG_TRACKER_VUID);
+ if (ret) {
+ goto end;
+ }
+ /* gid tracker */
+ ret = list_tracker_ids(LTTNG_TRACKER_GID);
+ if (ret) {
+ goto end;
+ }
+ /* vgid tracker */
+ ret = list_tracker_ids(LTTNG_TRACKER_VGID);
+ if (ret) {
+ goto end;
+ }
+ break;
+ case LTTNG_DOMAIN_UST:
+ /* vpid tracker */
+ ret = list_tracker_ids(LTTNG_TRACKER_VPID);
+ if (ret) {
+ goto end;
+ }
+ /* vuid tracker */
+ ret = list_tracker_ids(LTTNG_TRACKER_VUID);
+ if (ret) {
+ goto end;
+ }
+ /* vgid tracker */
+ ret = list_tracker_ids(LTTNG_TRACKER_VGID);
+ if (ret) {
+ goto end;
+ }
+ break;
+ default:
+ break;
}
-
if (lttng_opt_mi) {
/* Close trackers element */
ret = mi_lttng_writer_close_element(writer);
/* Trackers */
- ret = list_trackers();
+ ret = list_trackers(&domain);
if (ret) {
goto end;
}
switch (domains[i].type) {
case LTTNG_DOMAIN_KERNEL:
case LTTNG_DOMAIN_UST:
- ret = list_trackers();
+ ret = list_trackers(&domains[i]);
if (ret) {
goto end;
}
CMD_UNTRACK,
};
+enum tracker_type_state {
+ STATE_NONE = 0,
+ STATE_PID,
+ STATE_VPID,
+ STATE_UID,
+ STATE_VUID,
+ STATE_GID,
+ STATE_VGID,
+};
+
+struct opt_type {
+ int used;
+ int all;
+ char *string;
+};
+
+struct id_list {
+ size_t nr;
+ struct lttng_tracker_id *array;
+};
+
static char *opt_session_name;
static int opt_kernel;
static int opt_userspace;
-static int opt_all;
-static char *opt_pid_string;
-static int opt_pid;
+
+static struct opt_type opt_pid, opt_vpid, opt_uid, opt_vuid, opt_gid, opt_vgid;
+
+static enum tracker_type_state type_state;
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
OPT_SESSION,
OPT_PID,
+ OPT_VPID,
+ OPT_UID,
+ OPT_VUID,
+ OPT_GID,
+ OPT_VGID,
+ OPT_ALL,
};
static struct poptOption long_options[] = {
{ "session", 's', POPT_ARG_STRING, &opt_session_name, OPT_SESSION, 0, 0, },
{ "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0, },
{ "userspace", 'u', POPT_ARG_VAL, &opt_userspace, 1, 0, 0, },
- { "pid", 'p', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_pid_string, OPT_PID, 0, 0, },
- { "all", 'a', POPT_ARG_VAL, &opt_all, 1, 0, 0, },
+ { "pid", 'p', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_pid.string, OPT_PID, 0, 0, },
+ { "vpid", 0, POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_vpid.string, OPT_VPID, 0, 0, },
+ { "uid", 0, POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_uid.string, OPT_UID, 0, 0, },
+ { "vuid", 0, POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_vuid.string, OPT_VUID, 0, 0, },
+ { "gid", 0, POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_gid.string, OPT_GID, 0, 0, },
+ { "vgid", 0, POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_vgid.string, OPT_VGID, 0, 0, },
+ { "all", 'a', POPT_ARG_NONE, 0, OPT_ALL, 0, 0, },
{ "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, 0, 0, },
{ 0, 0, 0, 0, 0, 0, 0, },
};
-static
-int parse_pid_string(const char *_pid_string,
- int all, int **_pid_list, int *nr_pids)
+static struct id_list *alloc_id_list(size_t nr_items)
{
- const char *one_pid_str;
+ struct id_list *id_list;
+ struct lttng_tracker_id *items;
+
+ id_list = zmalloc(sizeof(*id_list));
+ if (!id_list) {
+ goto error;
+ }
+ items = zmalloc(nr_items * sizeof(*items));
+ if (!items) {
+ goto error;
+ }
+ id_list->nr = nr_items;
+ id_list->array = items;
+ return id_list;
+error:
+ free(id_list);
+ return NULL;
+}
+
+static void free_id_list(struct id_list *list)
+{
+ size_t nr_items;
+ int i;
+
+ if (!list) {
+ return;
+ }
+ nr_items = list->nr;
+ for (i = 0; i < nr_items; i++) {
+ struct lttng_tracker_id *item = &list->array[i];
+
+ free(item->string);
+ }
+ free(list);
+}
+
+static int parse_id_string(
+ const char *_id_string, int all, struct id_list **_id_list)
+{
+ const char *one_id_str;
char *iter;
int retval = CMD_SUCCESS;
int count = 0;
- int *pid_list = NULL;
- char *pid_string = NULL;
+ struct id_list *id_list = NULL;
+ char *id_string = NULL;
char *endptr;
- if (all && _pid_string) {
- ERR("An empty PID string is expected with --all");
+ if (all && _id_string) {
+ ERR("An empty ID string is expected with --all");
retval = CMD_ERROR;
goto error;
}
- if (!all && !_pid_string) {
- ERR("Please specify --all with an empty PID string");
+ if (!all && !_id_string) {
+ ERR("An ID string is expected");
retval = CMD_ERROR;
goto error;
}
if (all) {
- pid_list = zmalloc(sizeof(*pid_list));
- if (!pid_list) {
+ /* Empty ID string means all IDs */
+ id_list = alloc_id_list(1);
+ if (!id_list) {
ERR("Out of memory");
retval = CMD_ERROR;
goto error;
}
- /* Empty PID string means all PIDs */
- count = 1;
- pid_list[0] = -1;
+ id_list->array[0].type = LTTNG_ID_ALL;
goto assign;
}
- pid_string = strdup(_pid_string);
- if (!pid_string) {
+ id_string = strdup(_id_string);
+ if (!id_string) {
ERR("Out of memory");
retval = CMD_ERROR;
goto error;
}
/* Count */
- one_pid_str = strtok_r(pid_string, ",", &iter);
- while (one_pid_str != NULL) {
+ one_id_str = strtok_r(id_string, ",", &iter);
+ while (one_id_str != NULL) {
unsigned long v;
- errno = 0;
- v = strtoul(one_pid_str, &endptr, 10);
- if ((v == 0 && errno == EINVAL)
- || (v == ULONG_MAX && errno == ERANGE)
- || (*one_pid_str != '\0' && *endptr != '\0')){
- ERR("Error parsing PID %s", one_pid_str);
- retval = CMD_ERROR;
- goto error;
- }
+ if (isdigit(one_id_str[0])) {
+ errno = 0;
+ v = strtoul(one_id_str, &endptr, 10);
+ if ((v == 0 && errno == EINVAL) ||
+ (v == ULONG_MAX && errno == ERANGE) ||
+ (*one_id_str != '\0' &&
+ *endptr != '\0')) {
+ ERR("Error parsing ID %s", one_id_str);
+ retval = CMD_ERROR;
+ goto error;
+ }
- if ((long) v > INT_MAX || (int) v < 0) {
- ERR("Invalid PID value %ld", (long) v);
- retval = CMD_ERROR;
- goto error;
+ if ((long) v > INT_MAX || (int) v < 0) {
+ ERR("Invalid ID value %ld", (long) v);
+ retval = CMD_ERROR;
+ goto error;
+ }
}
count++;
/* For next loop */
- one_pid_str = strtok_r(NULL, ",", &iter);
+ one_id_str = strtok_r(NULL, ",", &iter);
}
if (count == 0) {
ERR("Fatal error occurred when parsing pid string");
goto error;
}
- free(pid_string);
+ free(id_string);
/* Identity of delimiter has been lost in first pass. */
- pid_string = strdup(_pid_string);
- if (!pid_string) {
+ id_string = strdup(_id_string);
+ if (!id_string) {
ERR("Out of memory");
retval = CMD_ERROR;
goto error;
}
/* Allocate */
- pid_list = zmalloc(count * sizeof(*pid_list));
- if (!pid_list) {
+ id_list = alloc_id_list(count);
+ if (!id_list) {
ERR("Out of memory");
retval = CMD_ERROR;
goto error;
}
- /* Reparse string and populate the pid list. */
+ /* Reparse string and populate the id list. */
count = 0;
- one_pid_str = strtok_r(pid_string, ",", &iter);
- while (one_pid_str != NULL) {
- unsigned long v;
+ one_id_str = strtok_r(id_string, ",", &iter);
+ while (one_id_str != NULL) {
+ struct lttng_tracker_id *item;
- v = strtoul(one_pid_str, NULL, 10);
- pid_list[count++] = (int) v;
+ item = &id_list->array[count++];
+ if (isdigit(one_id_str[0])) {
+ unsigned long v;
+
+ v = strtoul(one_id_str, NULL, 10);
+ item->type = LTTNG_ID_VALUE;
+ item->value = (int) v;
+ } else {
+ item->type = LTTNG_ID_STRING;
+ item->string = strdup(one_id_str);
+ if (!item->string) {
+ PERROR("Failed to allocate ID string");
+ retval = CMD_ERROR;
+ goto error;
+ }
+ }
/* For next loop */
- one_pid_str = strtok_r(NULL, ",", &iter);
+ one_id_str = strtok_r(NULL, ",", &iter);
}
assign:
- *nr_pids = count;
- *_pid_list = pid_list;
+ *_id_list = id_list;
goto end; /* SUCCESS */
/* ERROR */
error:
- free(pid_list);
+ free_id_list(id_list);
end:
- free(pid_string);
+ free(id_string);
return retval;
}
-static
-enum cmd_error_code track_untrack_pid(enum cmd_type cmd_type, const char *cmd_str,
- const char *session_name, const char *pid_string,
- int all, struct mi_writer *writer)
+static const char *get_tracker_str(enum lttng_tracker_type tracker_type)
+{
+ switch (tracker_type) {
+ case LTTNG_TRACKER_PID:
+ return "PID";
+ case LTTNG_TRACKER_VPID:
+ return "VPID";
+ case LTTNG_TRACKER_UID:
+ return "UID";
+ case LTTNG_TRACKER_VUID:
+ return "VUID";
+ case LTTNG_TRACKER_GID:
+ return "GID";
+ case LTTNG_TRACKER_VGID:
+ return "VGID";
+ default:
+ return NULL;
+ }
+ return NULL;
+}
+
+static enum cmd_error_code track_untrack_id(enum cmd_type cmd_type,
+ const char *cmd_str,
+ const char *session_name,
+ const char *id_string,
+ int all,
+ struct mi_writer *writer,
+ enum lttng_tracker_type tracker_type)
{
int ret, success = 1 , i;
enum cmd_error_code retval = CMD_SUCCESS;
- int *pid_list = NULL;
- int nr_pids;
+ struct id_list *id_list = NULL;
struct lttng_domain dom;
struct lttng_handle *handle = NULL;
- int (*cmd_func)(struct lttng_handle *handle, int pid);
+ int (*cmd_func)(struct lttng_handle *handle,
+ enum lttng_tracker_type tracker_type,
+ const struct lttng_tracker_id *id);
+ const char *tracker_str;
switch (cmd_type) {
case CMD_TRACK:
- cmd_func = lttng_track_pid;
+ cmd_func = lttng_track_id;
break;
case CMD_UNTRACK:
- cmd_func = lttng_untrack_pid;
+ cmd_func = lttng_untrack_id;
break;
default:
ERR("Unknown command");
retval = CMD_ERROR;
goto end;
}
-
memset(&dom, 0, sizeof(dom));
if (opt_kernel) {
dom.type = LTTNG_DOMAIN_KERNEL;
} else if (opt_userspace) {
dom.type = LTTNG_DOMAIN_UST;
+ if (tracker_type == LTTNG_TRACKER_PID) {
+ tracker_type = LTTNG_TRACKER_VPID;
+ }
} else {
/* Checked by the caller. */
assert(0);
}
-
- ret = parse_pid_string(pid_string, all, &pid_list, &nr_pids);
+ tracker_str = get_tracker_str(tracker_type);
+ if (!tracker_str) {
+ ERR("Unknown tracker type");
+ retval = CMD_ERROR;
+ goto end;
+ }
+ ret = parse_id_string(id_string, all, &id_list);
if (ret != CMD_SUCCESS) {
- ERR("Error parsing PID string");
+ ERR("Error parsing %s string", tracker_str);
retval = CMD_ERROR;
goto end;
}
}
if (writer) {
- /* Open process element */
- ret = mi_lttng_targets_open(writer);
+ /* Open tracker_id and targets elements */
+ ret = mi_lttng_id_tracker_open(writer, tracker_type);
if (ret) {
- retval = CMD_ERROR;
goto end;
}
}
- for (i = 0; i < nr_pids; i++) {
- DBG("%s PID %d", cmd_str, pid_list[i]);
- ret = cmd_func(handle, pid_list[i]);
+ for (i = 0; i < id_list->nr; i++) {
+ struct lttng_tracker_id *item = &id_list->array[i];
+
+ switch (item->type) {
+ case LTTNG_ID_ALL:
+ DBG("%s all IDs", cmd_str);
+ break;
+ case LTTNG_ID_VALUE:
+ DBG("%s ID %d", cmd_str, item->value);
+ break;
+ case LTTNG_ID_STRING:
+ DBG("%s ID '%s'", cmd_str, item->string);
+ break;
+ default:
+ retval = CMD_ERROR;
+ goto end;
+ }
+ ret = cmd_func(handle, tracker_type, item);
if (ret) {
+ char *msg = NULL;
+
switch (-ret) {
- case LTTNG_ERR_PID_TRACKED:
- WARN("PID %i already tracked in session %s",
- pid_list[i], session_name);
+ case LTTNG_ERR_ID_TRACKED:
+ msg = "already tracked";
success = 1;
retval = CMD_SUCCESS;
break;
- case LTTNG_ERR_PID_NOT_TRACKED:
- WARN("PID %i not tracked in session %s",
- pid_list[i], session_name);
+ case LTTNG_ERR_ID_NOT_TRACKED:
+ msg = "already not tracked";
success = 1;
retval = CMD_SUCCESS;
break;
retval = CMD_ERROR;
break;
}
+ if (msg) {
+ switch (item->type) {
+ case LTTNG_ID_ALL:
+ WARN("All %ss %s in session %s",
+ tracker_str, msg,
+ session_name);
+ break;
+ case LTTNG_ID_VALUE:
+ WARN("%s %i %s in session %s",
+ tracker_str,
+ item->value, msg,
+ session_name);
+ break;
+ case LTTNG_ID_STRING:
+ WARN("%s '%s' %s in session %s",
+ tracker_str,
+ item->string, msg,
+ session_name);
+ break;
+ default:
+ retval = CMD_ERROR;
+ goto end;
+ }
+ }
} else {
- if (pid_list[i] != -1) {
- MSG("PID %i %sed in session %s",
- pid_list[i], cmd_str,
- session_name);
- } else {
- MSG("All PIDs %sed in session %s",
+ switch (item->type) {
+ case LTTNG_ID_ALL:
+ MSG("All %ss %sed in session %s", tracker_str,
cmd_str, session_name);
+ break;
+ case LTTNG_ID_VALUE:
+ MSG("%s %i %sed in session %s", tracker_str,
+ item->value, cmd_str,
+ session_name);
+ break;
+ case LTTNG_ID_STRING:
+ MSG("%s '%s' %sed in session %s", tracker_str,
+ item->string, cmd_str,
+ session_name);
+ break;
+ default:
+ retval = CMD_ERROR;
+ goto end;
}
success = 1;
}
/* Mi */
if (writer) {
- ret = mi_lttng_pid_target(writer, pid_list[i], 1);
+ ret = mi_lttng_id_target(writer, tracker_type, item, 1);
if (ret) {
retval = CMD_ERROR;
goto end;
}
if (writer) {
- /* Close targets element */
- ret = mi_lttng_writer_close_element(writer);
+ /* Close targets and tracker_id elements */
+ ret = mi_lttng_close_multi_element(writer, 2);
if (ret) {
retval = CMD_ERROR;
goto end;
if (handle) {
lttng_destroy_handle(handle);
}
- free(pid_list);
+ free_id_list(id_list);
return retval;
}
}
}
+static void print_err_duplicate(const char *type)
+{
+ ERR("The --%s option can only be used once. A list of comma-separated values can be specified.",
+ type);
+}
+
/*
* Add/remove tracker to/from session.
*/
list_cmd_options(stdout, long_options);
goto end;
case OPT_SESSION:
+ break;
case OPT_PID:
- opt_pid = 1;
+ if (opt_pid.used) {
+ print_err_duplicate("pid");
+ command_ret = CMD_ERROR;
+ goto end;
+ }
+ opt_pid.used = 1;
+ type_state = STATE_PID;
+ break;
+ case OPT_VPID:
+ if (opt_vpid.used) {
+ print_err_duplicate("vpid");
+ command_ret = CMD_ERROR;
+ goto end;
+ }
+ opt_vpid.used = 1;
+ type_state = STATE_VPID;
+ break;
+ case OPT_UID:
+ if (opt_uid.used) {
+ print_err_duplicate("uid");
+ command_ret = CMD_ERROR;
+ goto end;
+ }
+ opt_uid.used = 1;
+ type_state = STATE_UID;
+ break;
+ case OPT_VUID:
+ if (opt_vuid.used) {
+ print_err_duplicate("vuid");
+ command_ret = CMD_ERROR;
+ goto end;
+ }
+ opt_vuid.used = 1;
+ type_state = STATE_VUID;
+ break;
+ case OPT_GID:
+ if (opt_gid.used) {
+ print_err_duplicate("gid");
+ command_ret = CMD_ERROR;
+ goto end;
+ }
+ opt_gid.used = 1;
+ type_state = STATE_GID;
+ break;
+ case OPT_VGID:
+ if (opt_vgid.used) {
+ print_err_duplicate("vgid");
+ command_ret = CMD_ERROR;
+ goto end;
+ }
+ opt_vgid.used = 1;
+ type_state = STATE_VGID;
+ break;
+ case OPT_ALL:
+ switch (type_state) {
+ case STATE_PID:
+ opt_pid.all = 1;
+ break;
+ case STATE_VPID:
+ opt_vpid.all = 1;
+ break;
+ case STATE_UID:
+ opt_uid.all = 1;
+ break;
+ case STATE_VUID:
+ opt_vuid.all = 1;
+ break;
+ case STATE_GID:
+ opt_gid.all = 1;
+ break;
+ case STATE_VGID:
+ opt_vgid.all = 1;
+ break;
+ default:
+ command_ret = CMD_ERROR;
+ goto end;
+ }
break;
default:
command_ret = CMD_UNDEFINED;
session_name = opt_session_name;
}
- /* Currently only PID tracker is supported */
- if (!opt_pid) {
- ERR("Please specify at least one tracker with its expected arguments");
- command_ret = CMD_ERROR;
- goto end;
- }
-
/* Mi check */
if (lttng_opt_mi) {
writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
command_ret = CMD_ERROR;
goto end;
}
+
+ ret = mi_lttng_trackers_open(writer);
+ if (ret) {
+ goto end;
+ }
}
- command_ret = track_untrack_pid(cmd_type,
- cmd_str, session_name, opt_pid_string,
- opt_all, writer);
- if (command_ret != CMD_SUCCESS) {
- success = 0;
+ if (opt_pid.used) {
+ command_ret = track_untrack_id(cmd_type, cmd_str, session_name,
+ opt_pid.string, opt_pid.all, writer,
+ LTTNG_TRACKER_PID);
+ if (command_ret != CMD_SUCCESS) {
+ success = 0;
+ }
+ }
+ if (opt_vpid.used) {
+ command_ret = track_untrack_id(cmd_type, cmd_str, session_name,
+ opt_vpid.string, opt_vpid.all, writer,
+ LTTNG_TRACKER_VPID);
+ if (command_ret != CMD_SUCCESS) {
+ success = 0;
+ }
+ }
+ if (opt_uid.used) {
+ command_ret = track_untrack_id(cmd_type, cmd_str, session_name,
+ opt_uid.string, opt_uid.all, writer,
+ LTTNG_TRACKER_UID);
+ if (command_ret != CMD_SUCCESS) {
+ success = 0;
+ }
+ }
+ if (opt_vuid.used) {
+ command_ret = track_untrack_id(cmd_type, cmd_str, session_name,
+ opt_vuid.string, opt_vuid.all, writer,
+ LTTNG_TRACKER_VUID);
+ if (command_ret != CMD_SUCCESS) {
+ success = 0;
+ }
+ }
+ if (opt_gid.used) {
+ command_ret = track_untrack_id(cmd_type, cmd_str, session_name,
+ opt_gid.string, opt_gid.all, writer,
+ LTTNG_TRACKER_GID);
+ if (command_ret != CMD_SUCCESS) {
+ success = 0;
+ }
+ }
+ if (opt_vgid.used) {
+ command_ret = track_untrack_id(cmd_type, cmd_str, session_name,
+ opt_vgid.string, opt_vgid.all, writer,
+ LTTNG_TRACKER_VGID);
+ if (command_ret != CMD_SUCCESS) {
+ success = 0;
+ }
}
/* Mi closing */
if (writer) {
- /* Close output element */
- ret = mi_lttng_writer_close_element(writer);
+ /* Close trackers and output elements */
+ ret = mi_lttng_close_multi_element(writer, 2);
if (ret) {
command_ret = CMD_ERROR;
goto end;
</xs:sequence>
</xs:complexType>
+ <xs:simpleType name="tracker_target_type">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="ALL" />
+ <xs:enumeration value="NONE" />
+ <xs:enumeration value="LIST" />
+ </xs:restriction>
+ </xs:simpleType>
+
<xs:simpleType name="pidbyint">
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
- <xs:simpleType name="pidwildcard">
- <xs:restriction base="xs:string">
- <xs:enumeration value="*"/>
- </xs:restriction>
- </xs:simpleType>
+ <xs:complexType name="pid_target_type_choice">
+ <xs:choice>
+ <xs:element name="id" type="tns:pidbyint" />
+ <xs:element name="name" type="xs:string" />
+ <xs:element name="all" type="xs:boolean" />
+ </xs:choice>
+ </xs:complexType>
<xs:complexType name="pid_target_type">
<xs:all>
- <xs:element name="pid">
- <xs:simpleType>
- <xs:union memberTypes="tns:pidbyint tns:pidwildcard" />
- </xs:simpleType>
- </xs:element>
+ <xs:element name="type" type="tns:pid_target_type_choice" />
<xs:element name="success" type="xs:boolean" default="false" minOccurs="0" />
</xs:all>
</xs:complexType>
<!-- Maps to a list of pid_targets-->
- <xs:complexType name="targets_type">
+ <xs:complexType name="pid_targets_type">
<xs:sequence>
- <xs:choice>
- <xs:element name="pid_target" type="tns:pid_target_type" minOccurs="0" maxOccurs="unbounded"/>
- </xs:choice>
+ <xs:element name="pid_target" type="tns:pid_target_type" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<!-- Maps to a pid_tracker-->
<xs:complexType name="pid_tracker_type">
<xs:all>
- <xs:element name="targets" type="tns:targets_type" />
+ <xs:element name="target_type" type="tns:tracker_target_type" minOccurs="0" maxOccurs="1" />
+ <xs:element name="targets" type="tns:pid_targets_type" minOccurs="0" />
+ </xs:all>
+ </xs:complexType>
+
+ <xs:simpleType name="vpidbyint">
+ <xs:restriction base="xs:integer">
+ <xs:minInclusive value="0"/>
+ <xs:maxInclusive value="4294967295" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:complexType name="vpid_target_type_choice">
+ <xs:choice>
+ <xs:element name="id" type="tns:vpidbyint" />
+ <xs:element name="name" type="xs:string" />
+ <xs:element name="all" type="xs:boolean" />
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="vpid_target_type">
+ <xs:all>
+ <xs:element name="type" type="tns:vpid_target_type_choice" minOccurs="0" maxOccurs="1" />
+ <xs:element name="success" type="xs:boolean" default="false" minOccurs="0" />
+ </xs:all>
+ </xs:complexType>
+
+ <!-- Maps to a list of vpid_targets-->
+ <xs:complexType name="vpid_targets_type">
+ <xs:sequence>
+ <xs:element name="vpid_target" type="tns:vpid_target_type" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Maps to a vpid_tracker-->
+ <xs:complexType name="vpid_tracker_type">
+ <xs:all>
+ <xs:element name="target_type" type="tns:tracker_target_type" minOccurs="0" maxOccurs="1" />
+ <xs:element name="targets" type="tns:vpid_targets_type" minOccurs="0" />
+ </xs:all>
+ </xs:complexType>
+
+ <xs:simpleType name="uidbyint">
+ <xs:restriction base="xs:integer">
+ <xs:minInclusive value="0"/>
+ <xs:maxInclusive value="4294967295" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:complexType name="uid_target_type_choice">
+ <xs:choice>
+ <xs:element name="id" type="tns:uidbyint" />
+ <xs:element name="name" type="xs:string" />
+ <xs:element name="all" type="xs:boolean" />
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="uid_target_type">
+ <xs:all>
+ <xs:element name="type" type="tns:uid_target_type_choice" minOccurs="0" maxOccurs="1" />
+ <xs:element name="success" type="xs:boolean" default="false" minOccurs="0" />
+ </xs:all>
+ </xs:complexType>
+
+ <!-- Maps to a list of uid_targets-->
+ <xs:complexType name="uid_targets_type">
+ <xs:sequence>
+ <xs:element name="uid_target" type="tns:uid_target_type" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Maps to a uid_tracker-->
+ <xs:complexType name="uid_tracker_type">
+ <xs:all>
+ <xs:element name="target_type" type="tns:tracker_target_type" minOccurs="0" maxOccurs="1" />
+ <xs:element name="targets" type="tns:uid_targets_type" minOccurs="0" />
+ </xs:all>
+ </xs:complexType>
+
+ <xs:simpleType name="vuidbyint">
+ <xs:restriction base="xs:integer">
+ <xs:minInclusive value="0"/>
+ <xs:maxInclusive value="4294967295" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:complexType name="vuid_target_type_choice">
+ <xs:choice>
+ <xs:element name="id" type="tns:vuidbyint" />
+ <xs:element name="name" type="xs:string" />
+ <xs:element name="all" type="xs:boolean" />
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="vuid_target_type">
+ <xs:all>
+ <xs:element name="type" type="tns:vuid_target_type_choice" minOccurs="0" maxOccurs="1" />
+ <xs:element name="success" type="xs:boolean" default="false" minOccurs="0" />
+ </xs:all>
+ </xs:complexType>
+
+ <!-- Maps to a list of vuid_targets-->
+ <xs:complexType name="vuid_targets_type">
+ <xs:sequence>
+ <xs:element name="vuid_target" type="tns:vuid_target_type" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Maps to a vuid_tracker-->
+ <xs:complexType name="vuid_tracker_type">
+ <xs:all>
+ <xs:element name="target_type" type="tns:tracker_target_type" minOccurs="0" maxOccurs="1" />
+ <xs:element name="targets" type="tns:vuid_targets_type" minOccurs="0" />
+ </xs:all>
+ </xs:complexType>
+
+ <xs:simpleType name="gidbyint">
+ <xs:restriction base="xs:integer">
+ <xs:minInclusive value="0"/>
+ <xs:maxInclusive value="4294967295" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:complexType name="gid_target_type_choice">
+ <xs:choice>
+ <xs:element name="id" type="tns:gidbyint" />
+ <xs:element name="name" type="xs:string" />
+ <xs:element name="all" type="xs:boolean" />
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="gid_target_type">
+ <xs:all>
+ <xs:element name="type" type="tns:gid_target_type_choice" minOccurs="0" maxOccurs="1" />
+ <xs:element name="success" type="xs:boolean" default="false" minOccurs="0" />
+ </xs:all>
+ </xs:complexType>
+
+ <!-- Maps to a list of gid_targets-->
+ <xs:complexType name="gid_targets_type">
+ <xs:sequence>
+ <xs:element name="gid_target" type="tns:gid_target_type" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Maps to a gid_tracker-->
+ <xs:complexType name="gid_tracker_type">
+ <xs:all>
+ <xs:element name="target_type" type="tns:tracker_target_type" minOccurs="0" maxOccurs="1" />
+ <xs:element name="targets" type="tns:gid_targets_type" minOccurs="0" />
+ </xs:all>
+ </xs:complexType>
+
+ <xs:simpleType name="vgidbyint">
+ <xs:restriction base="xs:integer">
+ <xs:minInclusive value="0"/>
+ <xs:maxInclusive value="4294967295" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:complexType name="vgid_target_type_choice">
+ <xs:choice>
+ <xs:element name="id" type="tns:vgidbyint" />
+ <xs:element name="name" type="xs:string" />
+ <xs:element name="all" type="xs:boolean" />
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="vgid_target_type">
+ <xs:all>
+ <xs:element name="type" type="tns:vgid_target_type_choice" minOccurs="0" maxOccurs="1" />
+ <xs:element name="success" type="xs:boolean" default="false" minOccurs="0" />
+ </xs:all>
+ </xs:complexType>
+
+ <!-- Maps to a list of vgid_targets-->
+ <xs:complexType name="vgid_targets_type">
+ <xs:sequence>
+ <xs:element name="vgid_target" type="tns:vgid_target_type" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Maps to a vgid_tracker-->
+ <xs:complexType name="vgid_tracker_type">
+ <xs:all>
+ <xs:element name="target_type" type="tns:tracker_target_type" minOccurs="0" maxOccurs="1" />
+ <xs:element name="targets" type="tns:vgid_targets_type" minOccurs="0" />
</xs:all>
</xs:complexType>
<!-- Maps to a list of trackers-->
<xs:complexType name="trackers_type">
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element name="pid_tracker" type="tns:pid_tracker_type" maxOccurs="1" />
+ <xs:sequence>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="pid_tracker" type="tns:pid_tracker_type" maxOccurs="1" />
+ <xs:element name="vpid_tracker" type="tns:vpid_tracker_type" maxOccurs="1" />
+ <xs:element name="uid_tracker" type="tns:uid_tracker_type" maxOccurs="1" />
+ <xs:element name="vuid_tracker" type="tns:vuid_tracker_type" maxOccurs="1" />
+ <xs:element name="gid_tracker" type="tns:gid_tracker_type" maxOccurs="1" />
+ <xs:element name="vgid_tracker" type="tns:vgid_tracker_type" maxOccurs="1" />
+ </xs:choice>
</xs:sequence>
</xs:complexType>
<xs:element name="channels" type="tns:channels_type" minOccurs="0" />
<xs:element name="events" type="tns:event_list_type" minOccurs="0" />
<xs:element name="channel" type="tns:channel_type" minOccurs="0" />
- <xs:element name="targets" type="tns:targets_type" minOccurs="0" />
+ <xs:element name="trackers" type="tns:trackers_type" minOccurs="0" />
<xs:element name="metadata_action" type="tns:metadata_cmd_type" minOccurs="0" />
<xs:element name="regenerate_action" type="tns:regenerate_cmd_type" minOccurs="0" />
<xs:element name="rotation" type="tns:rotate_type" minOccurs="0" />
return mi_lttng_writer_open_element(writer, config_element_trackers);
}
+static int get_tracker_elements(enum lttng_tracker_type tracker_type,
+ const char **element_id_tracker,
+ const char **element_target_id)
+{
+ int ret = 0;
+
+ switch (tracker_type) {
+ case LTTNG_TRACKER_PID:
+ *element_id_tracker = config_element_pid_tracker;
+ *element_target_id = config_element_target_pid;
+ break;
+ case LTTNG_TRACKER_VPID:
+ *element_id_tracker = config_element_vpid_tracker;
+ *element_target_id = config_element_target_vpid;
+ break;
+ case LTTNG_TRACKER_UID:
+ *element_id_tracker = config_element_uid_tracker;
+ *element_target_id = config_element_target_uid;
+ break;
+ case LTTNG_TRACKER_VUID:
+ *element_id_tracker = config_element_vuid_tracker;
+ *element_target_id = config_element_target_vuid;
+ break;
+ case LTTNG_TRACKER_GID:
+ *element_id_tracker = config_element_gid_tracker;
+ *element_target_id = config_element_target_gid;
+ break;
+ case LTTNG_TRACKER_VGID:
+ *element_id_tracker = config_element_vgid_tracker;
+ *element_target_id = config_element_target_vgid;
+ break;
+ default:
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ }
+ return ret;
+}
+
LTTNG_HIDDEN
-int mi_lttng_pid_tracker_open(struct mi_writer *writer)
+int mi_lttng_id_tracker_open(
+ struct mi_writer *writer, enum lttng_tracker_type tracker_type)
{
int ret;
+ const char *element_id_tracker, *element_target_id;
+
+ ret = get_tracker_elements(
+ tracker_type, &element_id_tracker, &element_target_id);
+ if (ret) {
+ return ret;
+ }
- /* Open element pid_tracker */
- ret = mi_lttng_writer_open_element(writer, config_element_pid_tracker);
+ /* Open element $id_tracker */
+ ret = mi_lttng_writer_open_element(writer, element_id_tracker);
if (ret) {
goto end;
}
* mi api bump. The use of process element break the mi api.
*/
LTTNG_HIDDEN
-int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *name,
+int mi_lttng_pid(struct mi_writer *writer,
+ pid_t pid,
+ const char *name,
int is_open)
{
int ret;
}
LTTNG_HIDDEN
-int mi_lttng_pid_target(struct mi_writer *writer, pid_t pid, int is_open)
+int mi_lttng_id_target(struct mi_writer *writer,
+ enum lttng_tracker_type tracker_type,
+ struct lttng_tracker_id *id,
+ int is_open)
{
int ret;
+ const char *element_id_tracker, *element_target_id;
- ret = mi_lttng_writer_open_element(writer,
- config_element_target_pid);
+ ret = get_tracker_elements(
+ tracker_type, &element_id_tracker, &element_target_id);
if (ret) {
- goto end;
+ return ret;
}
- /* Writing pid number
- * Special case for element all on track untrack command
- * All pid is represented as wildcard *
- */
- if ((int) pid == -1) {
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_pid,
- mi_lttng_element_track_untrack_all_wildcard);
- } else {
- ret = mi_lttng_writer_write_element_signed_int(writer,
- config_element_pid, (int) pid);
+ switch (id->type) {
+ case LTTNG_ID_ALL:
+ ret = mi_lttng_writer_open_element(writer, element_target_id);
+ if (ret) {
+ goto end;
+ }
+ ret = mi_lttng_writer_open_element(writer, config_element_type);
+ if (ret) {
+ goto end;
+ }
+ ret = mi_lttng_writer_write_element_bool(
+ writer, config_element_all, 1);
+ if (ret) {
+ goto end;
+ }
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ goto end;
+ }
+ break;
+ case LTTNG_ID_VALUE:
+ ret = mi_lttng_writer_open_element(writer, element_target_id);
+ if (ret) {
+ goto end;
+ }
+ ret = mi_lttng_writer_open_element(writer, config_element_type);
+ if (ret) {
+ goto end;
+ }
+ ret = mi_lttng_writer_write_element_signed_int(
+ writer, config_element_id, id->value);
+ if (ret) {
+ goto end;
+ }
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ goto end;
+ }
+ break;
+ case LTTNG_ID_STRING:
+ ret = mi_lttng_writer_open_element(writer, element_target_id);
+ if (ret) {
+ goto end;
+ }
+ ret = mi_lttng_writer_open_element(writer, config_element_type);
+ if (ret) {
+ goto end;
+ }
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_name, id->string);
+ if (ret) {
+ goto end;
+ }
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ goto end;
+ }
+ break;
+ case LTTNG_ID_UNKNOWN:
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
}
if (ret) {
goto end;
int mi_lttng_trackers_open(struct mi_writer *writer);
/*
- * Machine interface: open a pid_tracker element.
+ * Machine interface: open a id tracker element.
*
* writer An instance of a machine interface writer.
*
*
* Note: A targets element is also opened for each tracker definition
*/
-int mi_lttng_pid_tracker_open(struct mi_writer *writer);
+int mi_lttng_id_tracker_open(
+ struct mi_writer *writer, enum lttng_tracker_type tracker_type);
/*
* Machine interface: open a PIDs element.
int mi_lttng_targets_open(struct mi_writer *writer);
/*
- * Machine interface for track/untrack a pid_target
+ * Machine interface for track/untrack an id_target
*
* writer An instance of a machine interface writer.
*
* Returns zero if the element's value could be written.
* Negative values indicate an error.
*/
-int mi_lttng_pid_target(struct mi_writer *writer, pid_t pid, int is_open);
+int mi_lttng_id_target(struct mi_writer *writer,
+ enum lttng_tracker_type tracker_type,
+ struct lttng_tracker_id *id,
+ int is_open);
/*
* Machine interface of a context.
* node;b;
* node;c;
*/
-#include <stdlib.h>
+#include <assert.h>
+#include <stdbool.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <assert.h>
#include <unistd.h>
#include <libxml/tree.h>
#if defined(LIBXML_XPATH_ENABLED)
-
-int opt_verbose;
-int node_exist;
+static int opt_verbose;
+static int node_exist;
+static bool result = false;
/**
* print_xpath_nodes:
node_child_value_string = xmlNodeListGetString(doc,
cur->children, 1);
if (node_exist) {
- fprintf(output, "true\n");
+ result = true;
} else if (opt_verbose) {
fprintf(output, "%s;%s;\n", cur->name,
node_child_value_string);
} else {
/* We don't want to print non-final element */
if (node_exist) {
- fprintf(output, "true\n");
+ result = true;
} else {
fprintf(stderr, "ERR:%s\n",
"Xpath expression return non-final xml element");
}
} else {
if (node_exist) {
- fprintf(output, "true\n");
+ result = true;
} else {
/* We don't want to print non-final element */
fprintf(stderr, "ERR:%s\n",
} else {
cur = nodes->nodeTab[i];
if (node_exist) {
- fprintf(output, "true\n");
+ result = true;
} else if (opt_verbose) {
fprintf(output, "%s;%s;\n", cur->parent->name, cur->content);
} else {
xmlFreeDoc(doc);
return -1;
}
+ if (node_exist && result) {
+ fprintf(stdout, "true\n");
+ }
/* Cleanup */
xmlXPathFreeObject(xpathObj);
XPATH_SNAPSHOT_ADD_SNAPSHOT="$XPATH_CMD_OUTPUT/lttng:snapshot_action[./lttng:name = 'add-output']/lttng:output"
XPATH_SNAPSHOT_LIST="$XPATH_CMD_OUTPUT/lttng:snapshot_action[./lttng:name = 'list-output']/lttng:output"
XPATH_SNAPSHOT_DEL="$XPATH_CMD_OUTPUT/lttng:snapshot_action[./lttng:name = 'del-output']/lttng:output"
-XPATH_TRACK_UNTRACK_PID="$XPATH_CMD_OUTPUT/lttng:targets/lttng:pid_target"
-XPATH_PID_TRACKER="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:trackers/lttng:pid_tracker"
+XPATH_TRACK_UNTRACK_VPID="$XPATH_CMD_OUTPUT/lttng:trackers/lttng:vpid_tracker/lttng:targets/lttng:vpid_target/lttng:type"
+XPATH_VPID_TRACKER="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:trackers/lttng:vpid_tracker"
DEVNULL=/dev/null 2>&1
ok $? "Mi test: track pid is a success"
#Verify that there is 3 process
- extract_xml $OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
+ extract_xml $OUTPUT_DEST $XPATH_TRACK_UNTRACK_VPID"/lttng:id" result
num=$(echo "$result" | wc -l)
test "$num" -eq "3"
ok $? "Mi test: track pid expecting 3 processes got $num"
ok $? "Mi test: session list with pid_tracker validate"
#Check the good count
- extract_xml $OUTPUT_DEST $XPATH_PID_TRACKER"/lttng:targets/lttng:pid_target/lttng:pid" result
+ extract_xml $OUTPUT_DEST $XPATH_VPID_TRACKER"/lttng:targets/lttng:vpid_target/lttng:type/lttng:id" result
num=$(echo "$result" | wc -l)
test "$num" -eq "3"
ok $? "Mi test: tracker pid listing expecting 3 target got $num"
ok $? "Mi test: untrack pid is a success"
#Verify that there is 2 untracked pids
- extract_xml $OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
+ extract_xml $OUTPUT_DEST $XPATH_TRACK_UNTRACK_VPID"/lttng:id" result
num=$(echo "$result" | wc -l)
test "$num" -eq "2"
ok $? "Mi test: untrack pid expecting 2 process got $num"
ok $? "Mi test: session list with pid_tracker validate"
#Check the good count
- extract_xml $OUTPUT_DEST $XPATH_PID_TRACKER"/lttng:targets/lttng:pid_target/lttng:pid" result
+ extract_xml $OUTPUT_DEST $XPATH_VPID_TRACKER"/lttng:targets/lttng:vpid_target/lttng:type/lttng:pid" result
num=$(echo "$result" | wc -l)
test "$num" -eq "1"
ok $? "Mi test: tracker pid listing expecting 1 process got $num"
ok $? "Mi test: untrack all pid is a success"
#Verify that there is 1 untracked pid
- extract_xml $OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
+ extract_xml $OUTPUT_DEST $XPATH_TRACK_UNTRACK_VPID"/lttng:all" result
num=$(echo "$result" | wc -l)
test "$num" -eq "1"
ok $? "Mi test: untrack pid expecting 1 process got $num"
- #Test if the id is * which represent the all argument
- test "$result" = "*"
- ok $? "Mi test: pid expected is * got $result"
+ #Test if type "all" is "true" which represent the all argument
+ test "$result" = "true"
+ ok $? "Mi test: pid expected is true got $result"
#Test if pid_tracker is enabled as definied by pid_tracker
#behavior. If all pid are untrack than the pid_tracker is still
ok $? "Mi test: session list with pid_tracker validate"
#Check the good count
- extract_xml $OUTPUT_DEST $XPATH_PID_TRACKER"/lttng:targets/lttng:pid_target/lttng:pid" result
+ extract_xml $OUTPUT_DEST $XPATH_VPID_TRACKER"/lttng:targets/lttng:vpid_target/lttng:type/lttng:pid" result
num=$(echo -n "$result" | wc -l)
test "$num" -eq "0"
ok $? "Mi test: tracker pid listing expecting 0 process got $num"
ok $? "Mi test: track all pid is a success"
#Verify that there is 1 tracked process
- extract_xml $OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
+ extract_xml $OUTPUT_DEST $XPATH_TRACK_UNTRACK_VPID"/lttng:all" result
num=$(echo "$result" | wc -l)
test "$num" -eq "1"
ok $? "Mi test: track pid expecting 1 process got $num"
- #Test if the id is * wich represent the all argument
- test "$result" = "*"
- ok $? "Mi test: pid expected is * got $result"
+ #Test if the id is true wich represent the all argument
+ test "$result" = "true"
+ ok $? "Mi test: pid expected is true got $result"
#Test if pid_tracker is enabled as definied by pid_tracker
#behavior. If all pid are untrack thant the pid_tracker is
$XML_VALIDATE $OUTPUT_DEST
ok $? "Mi test: session list with pid_tracker validate"
- node_check_xml $OUTPUT_DEST $XPATH_PID_TRACKER result
+ node_check_xml $OUTPUT_DEST $XPATH_VPID_TRACKER result
test "$result" = ""
- ok $? "Mi test: Pid_tracker node is absent as defined"
+ ok $? "Mi test: VPID_tracker node is absent as defined"
OUTPUT_DEST=$DEVNULL
destroy_lttng_sessions
</channel>
</channels>
<trackers>
+ <vpid_tracker>
+ <targets>
+ <vpid_target>
+ <id>666</id>
+ </vpid_target>
+ </targets>
+ </vpid_tracker>
+ <vuid_tracker>
+ <targets>
+ <vuid_target>
+ <id>777</id>
+ </vuid_target>
+ </targets>
+ </vuid_tracker>
+ <vgid_tracker>
+ <targets>
+ <vgid_target>
+ <id>888</id>
+ </vgid_target>
+ </targets>
+ </vgid_tracker>
<pid_tracker>
<targets>
<pid_target>
- <pid>666</pid>
+ <pid>999</pid>
</pid_target>
</targets>
</pid_tracker>
DIR=$(readlink -f $TESTDIR)
-NUM_TESTS=67
+NUM_TESTS=72
source $TESTDIR/utils/utils.sh
break;
fi
$TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME-trackers" > $mi_output_file
- mi_result=$($CURDIR/../mi/extract_xml -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:trackers/lttng:pid_tracker/lttng:targets/lttng:pid_target")
+ mi_result=$($CURDIR/../mi/extract_xml -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:trackers/lttng:vpid_tracker/lttng:targets/lttng:vpid_target")
if [[ $mi_result = "true" ]]; then
- ok 0 "Pid target is present"
+ ok 0 "VPID target is present"
else
- fail "Pid target missing"
+ fail "VPID target missing"
+ fi
+
+ mi_result=$($CURDIR/../mi/extract_xml -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:trackers/lttng:vuid_tracker/lttng:targets/lttng:vuid_target")
+ if [[ $mi_result = "true" ]]; then
+ ok 0 "VUID target is present"
+ else
+ fail "VUID target missing"
+ fi
+
+ mi_result=$($CURDIR/../mi/extract_xml -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:trackers/lttng:vgid_tracker/lttng:targets/lttng:vgid_target")
+ if [[ $mi_result = "true" ]]; then
+ ok 0 "VGID target is present"
+ else
+ fail "VGID target missing"
fi
# Test to remove the target just to make sure
- lttng_untrack_ok "-p 666 -u -s $SESSION_NAME-trackers"
- rm $mi_output_file
+ lttng_untrack_ok "--vpid 666 -u -s $SESSION_NAME-trackers"
+ lttng_untrack_ok "--vuid 777 -u -s $SESSION_NAME-trackers"
+ lttng_untrack_ok "--vgid 888 -u -s $SESSION_NAME-trackers"
+ # Actually using vpid (backward compat)
+ lttng_untrack_ok "--pid 999 -u -s $SESSION_NAME-trackers"
destroy_lttng_session_ok "$SESSION_NAME-trackers"
- rm -rf ${mi_output_file}
+ rm -f ${mi_output_file}
}
function test_override_url_normal()