X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.c;h=c96d27c2aad8bada8657687993412f8f9d25bfc8;hb=27babd3a0a164f71d4dc02884ef20099ddfc6755;hp=eced2b7165f1836098e415aad4768c772a581240;hpb=d8fbe2a9cc6ace367bfb5428df3e7649ac012f32;p=lttng-tools.git diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index eced2b716..c96d27c2a 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -220,6 +220,17 @@ static void print_events(struct lttng_event *event) } 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%s", indent6, event->name, enabled_string(event->enabled), @@ -231,7 +242,6 @@ static void print_events(struct lttng_event *event) 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%s", indent6, event->name, enabled_string(event->enabled), @@ -281,7 +291,7 @@ static void print_event_field(struct lttng_event_field *field) return; } MSG("%sfield: %s (%s)%s", indent8, field->field_name, - field_type(field), field->written ? "" : " [no write]"); + field_type(field), field->nowrite ? " [no write]" : ""); } /* @@ -294,6 +304,7 @@ static int list_ust_events(void) struct lttng_handle *handle; struct lttng_event *event_list; pid_t cur_pid = 0; + char *cmdline = NULL; memset(&domain, 0, sizeof(domain)); @@ -308,7 +319,7 @@ static int list_ust_events(void) 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; } @@ -322,7 +333,9 @@ static int list_ust_events(void) 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]); } @@ -349,6 +362,8 @@ static int list_ust_event_fields(void) 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)); @@ -365,7 +380,7 @@ static int list_ust_event_fields(void) 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; } @@ -379,7 +394,9 @@ static int list_ust_event_fields(void) 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); @@ -424,7 +441,7 @@ static int list_kernel_events(void) 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; } @@ -458,6 +475,7 @@ static int list_events(const char *channel_name) count = lttng_list_events(handle, channel_name, &events); if (count < 0) { ret = count; + ERR("%s", lttng_strerror(ret)); goto error; } @@ -474,9 +492,7 @@ static int list_events(const char *channel_name) MSG(""); end: - if (events) { - free(events); - } + free(events); ret = CMD_SUCCESS; error: @@ -521,11 +537,18 @@ static int list_channels(const char *channel_name) 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) { @@ -545,7 +568,7 @@ static int list_channels(const char *channel_name) /* 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) { @@ -582,6 +605,7 @@ static int list_sessions(const char *session_name) 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"); @@ -600,14 +624,9 @@ static int list_sessions(const char *session_name) 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", i + 1, sessions[i].name, sessions[i].path, + active_string(sessions[i].enabled)); } } @@ -643,6 +662,7 @@ static int list_domains(const char *session_name) 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"); @@ -674,8 +694,7 @@ error: */ 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; @@ -739,6 +758,7 @@ int cmd_list(int argc, const char **argv) if (opt_kernel) { ret = list_kernel_events(); if (ret < 0) { + ret = CMD_ERROR; goto end; } } @@ -749,6 +769,7 @@ int cmd_list(int argc, const char **argv) ret = list_ust_events(); } if (ret < 0) { + ret = CMD_ERROR; goto end; } } @@ -772,10 +793,13 @@ int cmd_list(int argc, const char **argv) 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; } @@ -786,6 +810,9 @@ int cmd_list(int argc, const char **argv) 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"); @@ -812,9 +839,7 @@ int cmd_list(int argc, const char **argv) } end: - if (domains) { - free(domains); - } + free(domains); if (handle) { lttng_destroy_handle(handle); }