X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.c;h=e2cf4df5047f802925f71d043d545059fed9bea8;hb=65167fc080cc312f646d145fa52c5e1269ea5907;hp=6a54279f912fa9984d7419a06fbe64c6f64fabaf;hpb=4634f12e972571bf8ab9cb3892e1d472aa7e0ddc;p=lttng-tools.git diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 6a54279f9..e2cf4df50 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -23,6 +23,7 @@ #include #include +#include #include "../command.h" static int opt_userspace; @@ -107,7 +108,8 @@ static char *get_cmdline_by_pid(pid_t pid) int ret; FILE *fp; char *cmdline = NULL; - char path[24]; /* Can't go bigger than /proc/65535/cmdline */ + /* Can't go bigger than /proc/LTTNG_MAX_PID/cmdline */ + char path[sizeof("/proc//cmdline") + sizeof(LTTNG_MAX_PID_STR) - 1]; snprintf(path, sizeof(path), "/proc/%d/cmdline", pid); fp = fopen(path, "r"); @@ -116,7 +118,11 @@ static char *get_cmdline_by_pid(pid_t pid) } /* Caller must free() *cmdline */ - cmdline = malloc(PATH_MAX); + cmdline = zmalloc(PATH_MAX); + if (!cmdline) { + perror("malloc cmdline"); + goto end; + } ret = fread(cmdline, 1, PATH_MAX, fp); if (ret < 0) { perror("fread proc list"); @@ -177,6 +183,34 @@ const char *exclusion_string(int value) } } +static const char *loglevel_jul_string(int value) +{ + switch (value) { + case -1: + return ""; + case LTTNG_LOGLEVEL_JUL_OFF: + return "JUL_OFF"; + case LTTNG_LOGLEVEL_JUL_SEVERE: + return "JUL_SEVERE"; + case LTTNG_LOGLEVEL_JUL_WARNING: + return "JUL_WARNING"; + case LTTNG_LOGLEVEL_JUL_INFO: + return "JUL_INFO"; + case LTTNG_LOGLEVEL_JUL_CONFIG: + return "JUL_CONFIG"; + case LTTNG_LOGLEVEL_JUL_FINE: + return "JUL_FINE"; + case LTTNG_LOGLEVEL_JUL_FINER: + return "JUL_FINER"; + case LTTNG_LOGLEVEL_JUL_FINEST: + return "JUL_FINEST"; + case LTTNG_LOGLEVEL_JUL_ALL: + return "JUL_ALL"; + default: + return "<>"; + } +} + static const char *loglevel_string(int value) { switch (value) { @@ -217,6 +251,20 @@ static const char *loglevel_string(int value) } } +static const char *logleveltype_string(enum lttng_loglevel_type value) +{ + switch (value) { + case LTTNG_EVENT_LOGLEVEL_ALL: + return ":"; + case LTTNG_EVENT_LOGLEVEL_RANGE: + return " <="; + case LTTNG_EVENT_LOGLEVEL_SINGLE: + return " =="; + default: + return " <>"; + } +} + /* * Pretty print single event. */ @@ -226,9 +274,10 @@ static void print_events(struct lttng_event *event) case LTTNG_EVENT_TRACEPOINT: { if (event->loglevel != -1) { - MSG("%s%s (loglevel: %s (%d)) (type: tracepoint)%s%s%s", + MSG("%s%s (loglevel%s %s (%d)) (type: tracepoint)%s%s%s", indent6, event->name, + logleveltype_string(event->loglevel_type), loglevel_string(event->loglevel), event->loglevel, enabled_string(event->enabled), @@ -323,7 +372,7 @@ static int list_jul_events(void) int i, size; struct lttng_domain domain; struct lttng_handle *handle; - struct lttng_event *event_list; + struct lttng_event *event_list = NULL; pid_t cur_pid = 0; char *cmdline = NULL; @@ -475,6 +524,8 @@ static int list_ust_event_fields(void) cmdline = get_cmdline_by_pid(cur_pid); MSG("\nPID: %d - Name: %s", cur_pid, cmdline); free(cmdline); + /* Wipe current event since we are about to print a new PID. */ + memset(&cur_event, 0, sizeof(cur_event)); } if (strcmp(cur_event.name, event_field_list[i].event.name) != 0) { print_events(&event_field_list[i].event); @@ -566,8 +617,10 @@ static int list_session_jul_events(void) } for (i = 0; i < count; i++) { - MSG("%s- %s%s", indent4, events[i].name, - enabled_string(events[i].enabled)); + MSG("%s- %s%s (loglevel%s %s)", indent4, events[i].name, + enabled_string(events[i].enabled), + logleveltype_string(events[i].loglevel_type), + loglevel_jul_string(events[i].loglevel)); } MSG(""); @@ -628,6 +681,8 @@ static void print_channel(struct lttng_channel *channel) MSG("%snumber of subbufers: %" PRIu64, indent6, channel->attr.num_subbuf); MSG("%sswitch timer interval: %u", indent6, channel->attr.switch_timer_interval); MSG("%sread timer interval: %u", indent6, channel->attr.read_timer_interval); + MSG("%strace file count: %" PRIu64, indent6, channel->attr.tracefile_count); + MSG("%strace file size (bytes): %" PRIu64, indent6, channel->attr.tracefile_size); switch (channel->attr.output) { case LTTNG_EVENT_SPLICE: MSG("%soutput: splice()", indent6); @@ -667,7 +722,7 @@ static int list_channels(const char *channel_name) goto error_channels; } - if (channel_name == NULL) { + if (count) { MSG("Channels:\n-------------"); } @@ -739,7 +794,9 @@ static int list_sessions(const char *session_name) 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); + MSG("%sTrace path: %s", indent4, sessions[i].path); + MSG("%sLive timer interval (usec): %u\n", indent4, + sessions[i].live_timer_interval); break; } } else { @@ -918,7 +975,7 @@ int cmd_list(int argc, const char **argv) goto end; } - if (opt_kernel) { + if (opt_kernel || opt_userspace) { /* Channel listing */ ret = list_channels(opt_channel); if (ret < 0) {