int ret;
FILE *fp;
char *cmdline = NULL;
- char path[24]; /* Can't go bigger than /proc/65535/cmdline */
+ char path[20]; /* Can't go bigger than /proc/65535/cmdline */
snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
fp = fopen(path, "r");
}
/* 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");
}
}
+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 " <<TYPE UNKN>>";
+ }
+}
+
/*
* Pretty print single 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),
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);
goto error_channels;
}
- if (channel_name == NULL) {
+ if (count) {
MSG("Channels:\n-------------");
}
goto end;
}
- if (opt_kernel) {
+ if (opt_kernel || opt_userspace) {
/* Channel listing */
ret = list_channels(opt_channel);
if (ret < 0) {