*/
static void usage(FILE *ofp)
{
- fprintf(ofp, "usage: lttng list [OPTIONS] [SESSION [<OPTIONS>]]\n");
+ fprintf(ofp, "usage: lttng list [OPTIONS] [SESSION [SESSION OPTIONS]]\n");
fprintf(ofp, "\n");
fprintf(ofp, "With no arguments, list available tracing session(s)\n");
fprintf(ofp, "\n");
const char *active_string(int value)
{
switch (value) {
- case 0: return " [inactive]";
- case 1: return " [active]";
+ case 0: return "inactive";
+ case 1: return "active";
case -1: return "";
default: return NULL;
}
}
+static const char *snapshot_string(int value)
+{
+ switch (value) {
+ case 1:
+ return " snapshot";
+ default:
+ return "";
+ }
+}
+
static
const char *enabled_string(int value)
{
}
}
+static
+const char *filter_string(int value)
+{
+ switch (value) {
+ case 1: return " [with filter]";
+ default: return "";
+ }
+}
+
static const char *loglevel_string(int value)
{
switch (value) {
case LTTNG_EVENT_TRACEPOINT:
{
if (event->loglevel != -1) {
- MSG("%s%s (loglevel: %s (%d)) (type: tracepoint)%s",
+ MSG("%s%s (loglevel: %s (%d)) (type: tracepoint)%s%s",
indent6,
event->name,
loglevel_string(event->loglevel),
event->loglevel,
- enabled_string(event->enabled));
+ enabled_string(event->enabled),
+ filter_string(event->filter));
} else {
- MSG("%s%s (type: tracepoint)%s",
+ MSG("%s%s (type: tracepoint)%s%s",
indent6,
event->name,
- enabled_string(event->enabled));
+ enabled_string(event->enabled),
+ filter_string(event->filter));
}
break;
}
+ case LTTNG_EVENT_FUNCTION:
+ MSG("%s%s (type: function)%s%s", indent6,
+ event->name, enabled_string(event->enabled),
+ filter_string(event->filter));
+ if (event->attr.probe.addr != 0) {
+ MSG("%saddr: 0x%" PRIx64, indent8, event->attr.probe.addr);
+ } else {
+ MSG("%soffset: 0x%" PRIx64, indent8, event->attr.probe.offset);
+ MSG("%ssymbol: %s", indent8, event->attr.probe.symbol_name);
+ }
+ break;
case LTTNG_EVENT_PROBE:
- MSG("%s%s (type: probe)%s", indent6,
- event->name, enabled_string(event->enabled));
+ MSG("%s%s (type: probe)%s%s", indent6,
+ event->name, enabled_string(event->enabled),
+ filter_string(event->filter));
if (event->attr.probe.addr != 0) {
MSG("%saddr: 0x%" PRIx64, indent8, event->attr.probe.addr);
} else {
MSG("%ssymbol: %s", indent8, event->attr.probe.symbol_name);
}
break;
- case LTTNG_EVENT_FUNCTION:
case LTTNG_EVENT_FUNCTION_ENTRY:
- MSG("%s%s (type: function)%s", indent6,
- event->name, enabled_string(event->enabled));
+ MSG("%s%s (type: function)%s%s", indent6,
+ event->name, enabled_string(event->enabled),
+ filter_string(event->filter));
MSG("%ssymbol: \"%s\"", indent8, event->attr.ftrace.symbol_name);
break;
case LTTNG_EVENT_SYSCALL:
- MSG("%ssyscalls (type: syscall)%s", indent6,
- enabled_string(event->enabled));
+ MSG("%ssyscalls (type: syscall)%s%s", indent6,
+ enabled_string(event->enabled),
+ filter_string(event->filter));
break;
case LTTNG_EVENT_NOOP:
- MSG("%s (type: noop)%s", indent6,
- enabled_string(event->enabled));
+ MSG("%s (type: noop)%s%s", indent6,
+ enabled_string(event->enabled),
+ filter_string(event->filter));
break;
case LTTNG_EVENT_ALL:
/* We should never have "all" events in list. */
if (!field->field_name[0]) {
return;
}
- MSG("%sfield: %s (%s)", indent8, field->field_name,
- field_type(field));
+ MSG("%sfield: %s (%s)%s", indent8, field->field_name,
+ field_type(field), field->nowrite ? " [no write]" : "");
}
/*
struct lttng_handle *handle;
struct lttng_event *event_list;
pid_t cur_pid = 0;
+ char *cmdline = NULL;
memset(&domain, 0, sizeof(domain));
size = lttng_list_tracepoints(handle, &event_list);
if (size < 0) {
- ERR("Unable to list UST events");
+ ERR("Unable to list UST events: %s", lttng_strerror(size));
lttng_destroy_handle(handle);
return size;
}
for (i = 0; i < size; i++) {
if (cur_pid != event_list[i].pid) {
cur_pid = event_list[i].pid;
- MSG("\nPID: %d - Name: %s", cur_pid, get_cmdline_by_pid(cur_pid));
+ cmdline = get_cmdline_by_pid(cur_pid);
+ MSG("\nPID: %d - Name: %s", cur_pid, cmdline);
+ free(cmdline);
}
print_events(&event_list[i]);
}
struct lttng_handle *handle;
struct lttng_event_field *event_field_list;
pid_t cur_pid = 0;
+ char *cmdline = NULL;
+
struct lttng_event cur_event;
memset(&domain, 0, sizeof(domain));
size = lttng_list_tracepoint_fields(handle, &event_field_list);
if (size < 0) {
- ERR("Unable to list UST event fields");
+ ERR("Unable to list UST event fields: %s", lttng_strerror(size));
lttng_destroy_handle(handle);
return size;
}
for (i = 0; i < size; i++) {
if (cur_pid != event_field_list[i].event.pid) {
cur_pid = event_field_list[i].event.pid;
- MSG("\nPID: %d - Name: %s", cur_pid, get_cmdline_by_pid(cur_pid));
+ cmdline = get_cmdline_by_pid(cur_pid);
+ MSG("\nPID: %d - Name: %s", cur_pid, cmdline);
+ free(cmdline);
}
if (strcmp(cur_event.name, event_field_list[i].event.name) != 0) {
print_events(&event_field_list[i].event);
size = lttng_list_tracepoints(handle, &event_list);
if (size < 0) {
- ERR("Unable to list kernel events");
+ ERR("Unable to list kernel events: %s", lttng_strerror(size));
lttng_destroy_handle(handle);
return size;
}
count = lttng_list_events(handle, channel_name, &events);
if (count < 0) {
ret = count;
+ ERR("%s", lttng_strerror(ret));
goto error;
}
MSG("");
end:
- if (events) {
- free(events);
- }
+ free(events);
ret = CMD_SUCCESS;
error:
count = lttng_list_channels(handle, &channels);
if (count < 0) {
- ret = count;
+ switch (-count) {
+ case LTTNG_ERR_KERN_CHAN_NOT_FOUND:
+ ret = CMD_SUCCESS;
+ WARN("No kernel channel");
+ break;
+ default:
+ /* We had a real error */
+ ret = count;
+ ERR("%s", lttng_strerror(ret));
+ break;
+ }
goto error_channels;
- } else if (count == 0) {
- ERR("Channel %s not found", channel_name);
- goto error;
}
if (channel_name == NULL) {
/* Listing events per channel */
ret = list_events(channels[i].name);
if (ret < 0) {
- MSG("%s", lttng_strerror(ret));
+ ERR("%s", lttng_strerror(ret));
}
if (chan_found) {
DBG("Session count %d", count);
if (count < 0) {
ret = count;
+ ERR("%s", lttng_strerror(ret));
goto error;
} else if (count == 0) {
MSG("Currently no available tracing session");
if (session_name != NULL) {
if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) {
session_found = 1;
- MSG("Tracing session %s:%s", session_name, active_string(sessions[i].enabled));
+ MSG("Tracing session %s: [%s%s]", session_name,
+ active_string(sessions[i].enabled),
+ snapshot_string(sessions[i].snapshot_mode));
MSG("%sTrace path: %s\n", indent4, sessions[i].path);
break;
}
- continue;
- }
-
- MSG(" %d) %s (%s)%s", i + 1, sessions[i].name, sessions[i].path,
- active_string(sessions[i].enabled));
-
- if (session_found) {
- break;
+ } else {
+ MSG(" %d) %s (%s) [%s%s]", i + 1, sessions[i].name, sessions[i].path,
+ active_string(sessions[i].enabled),
+ snapshot_string(sessions[i].snapshot_mode));
}
}
count = lttng_list_domains(session_name, &domains);
if (count < 0) {
ret = count;
+ ERR("%s", lttng_strerror(ret));
goto error;
} else if (count == 0) {
MSG(" None");
*/
int cmd_list(int argc, const char **argv)
{
- int opt, i, ret = CMD_SUCCESS;
- int nb_domain;
+ int opt, ret = CMD_SUCCESS;
const char *session_name;
static poptContext pc;
struct lttng_domain domain;
if (opt_kernel) {
ret = list_kernel_events();
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
}
ret = list_ust_events();
}
if (ret < 0) {
+ ret = CMD_ERROR;
goto end;
}
}
goto end;
}
} else {
+ int i, nb_domain;
+
/* We want all domain(s) */
nb_domain = lttng_list_domains(session_name, &domains);
if (nb_domain < 0) {
ret = nb_domain;
+ ERR("%s", lttng_strerror(ret));
goto end;
}
break;
case LTTNG_DOMAIN_UST:
MSG("=== Domain: UST global ===\n");
+ MSG("Buffer type: %s\n",
+ domains[i].buf_type ==
+ LTTNG_BUFFER_PER_PID ? "per PID" : "per UID");
break;
default:
MSG("=== Domain: Unimplemented ===\n");
}
end:
- if (domains) {
- free(domains);
- }
+ free(domains);
if (handle) {
lttng_destroy_handle(handle);
}