X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=lttng%2Flttng.c;h=9c34d2c62377ab66c02c9d4b766f01b6cff57eca;hp=75cb1b47372323c656d59b8851fc41f9bb85b4dc;hb=2ef84c95c5158ce40e77229fb5705524ff22be7b;hpb=33cb613d0d0e9238591566ce7b86868f9976c597 diff --git a/lttng/lttng.c b/lttng/lttng.c index 75cb1b473..9c34d2c62 100644 --- a/lttng/lttng.c +++ b/lttng/lttng.c @@ -47,6 +47,7 @@ static int process_client_opt(void); static int process_opt_list_apps(void); static int process_opt_list_sessions(void); static int process_opt_list_traces(void); +static int process_opt_kernel_list_events(void); static int process_opt_create_session(void); static int process_kernel_create_trace(void); static int process_opt_kernel_event(void); @@ -87,6 +88,18 @@ static int process_client_opt(void) goto error; } + if (opt_list_events) { + if (opt_trace_kernel) { + ret = process_opt_kernel_list_events(); + if (ret < 0) { + goto end; + } + } else if (opt_trace_pid != 0) { + // TODO + } + goto error; + } + /* Session creation or auto session set on */ if (auto_session || opt_create_session) { DBG("Creating a new session"); @@ -253,7 +266,40 @@ error: } /* - * process_kernel_event + * process_opt_kernel_list_events + * + * Ask for all trace events in the kernel and pretty print them. + */ +static int process_opt_kernel_list_events(void) +{ + int ret, pos, size; + char *event_list, *event, *ptr; + + DBG("Getting all tracing events"); + + ret = lttng_kernel_list_events(&event_list); + if (ret < 0) { + ERR("Unable to list events."); + return ret; + } + + MSG("Kernel tracepoints:\n-------------"); + + ptr = event_list; + while ((size = sscanf(ptr, "event { name = %m[^;]; };%n\n", &event, &pos)) == 1) { + MSG(" - %s", event); + /* Move pointer to the next line */ + ptr += pos + 1; + free(event); + } + + free(event_list); + + return 0; +} + +/* + * process_opt_kernel_event * * Enable kernel event from the command line list given. */