{ 0, 0, 0, 0, 0, 0, 0, },
};
-/*
- * usage
- */
-static void usage(FILE *ofp, const char *cmd_str)
-{
- fprintf(ofp, "usage: lttng %s [-k|-u] [OPTIONS]\n", cmd_str);
- fprintf(ofp, "\n");
- fprintf(ofp, "If no session is given (-s), the context is added to\n");
- fprintf(ofp, "the current sesssion. Exactly one domain (-k or -u)\n");
- fprintf(ofp, "must be specified.\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "Options:\n");
- fprintf(ofp, " -h, --help Show this help.\n");
- fprintf(ofp, " --list-options Simple listing of options.\n");
- fprintf(ofp, " -s, --session NAME Apply to session name.\n");
- fprintf(ofp, " -k, --kernel Apply to the kernel tracer.\n");
- fprintf(ofp, " -u, --userspace Apply to the user-space tracer.\n");
- fprintf(ofp, " -p, --pid [PID] Process ID tracker. Leave PID empty when used with --all.\n");
- fprintf(ofp, " -a, --all All PIDs (use with --pid).\n");
- fprintf(ofp, "\n");
-}
-
static
int parse_pid_string(const char *_pid_string,
int all, int **_pid_list, int *nr_pids)
goto error;
}
if (all) {
- pid_list = zmalloc(sizeof(*_pid_list));
+ pid_list = zmalloc(sizeof(*pid_list));
if (!pid_list) {
ERR("Out of memory");
retval = CMD_ERROR;
goto error;
}
- /* Copy */
+ /* Reparse string and populate the pid list. */
count = 0;
one_pid_str = strtok_r(pid_string, ",", &iter);
while (one_pid_str != NULL) {
ret = parse_pid_string(pid_string, all, &pid_list, &nr_pids);
if (ret != CMD_SUCCESS) {
ERR("Error parsing PID string");
- usage(stderr, cmd_str);
retval = CMD_ERROR;
goto end;
}
struct mi_writer *writer = NULL;
if (argc < 1) {
- usage(stderr, cmd_str);
command_ret = CMD_ERROR;
goto end;
}
opt_pid = 1;
break;
default:
- usage(stderr, cmd_str);
command_ret = CMD_UNDEFINED;
goto end;
}
/* Currently only PID tracker is supported */
if (!opt_pid) {
ERR("Please specify at least one tracker with its expected arguments");
- usage(stderr, cmd_str);
command_ret = CMD_ERROR;
goto end;
}