From: David Goulet Date: Mon, 29 Sep 2014 14:55:33 +0000 (-0400) Subject: Support syscall event in save session X-Git-Tag: v2.6.0-rc1~30 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=0de3eda1d4e80cc9aa23a62c27aaef096f1fd4bf;p=lttng-tools.git Support syscall event in save session Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c index 2c38df972..d3fb7b8f3 100644 --- a/src/bin/lttng-sessiond/save.c +++ b/src/bin/lttng-sessiond/save.c @@ -31,6 +31,7 @@ #include "save.h" #include "session.h" +#include "syscall.h" #include "trace-ust.h" static @@ -370,6 +371,7 @@ int save_kernel_event(struct config_writer *writer, } switch (event->event->instrumentation) { + case LTTNG_KERNEL_SYSCALL: case LTTNG_KERNEL_FUNCTION: ret = config_writer_open_element(writer, config_element_function_attributes); @@ -483,9 +485,54 @@ end: return ret; } +static +int save_kernel_syscall(struct config_writer *writer, + struct ltt_kernel_channel *kchan) +{ + int ret, i; + ssize_t count; + struct lttng_event *events = NULL; + + assert(writer); + assert(kchan); + + count = syscall_list_channel(kchan, &events, 0); + if (!count) { + /* No syscalls, just gracefully return. */ + ret = 0; + goto end; + } + + for (i = 0; i < count; i++) { + struct ltt_kernel_event *kevent; + + /* Create a temporary kevent in order to save it. */ + kevent = trace_kernel_create_event(&events[i]); + if (!kevent) { + ret = -ENOMEM; + goto end; + } + /* Init list in order so the destroy call can del the node. */ + CDS_INIT_LIST_HEAD(&kevent->list); + + ret = save_kernel_event(writer, kevent); + trace_kernel_destroy_event(kevent); + if (ret) { + goto end; + } + } + + /* Everything went well */ + ret = 0; + +end: + free(events); + return ret; +} + static int save_kernel_events(struct config_writer *writer, - struct ltt_kernel_event_list *event_list) + struct ltt_kernel_channel *kchan) { int ret; struct ltt_kernel_event *event; @@ -496,13 +543,19 @@ int save_kernel_events(struct config_writer *writer, goto end; } - cds_list_for_each_entry(event, &event_list->head, list) { + cds_list_for_each_entry(event, &kchan->events_list.head, list) { ret = save_kernel_event(writer, event); if (ret) { goto end; } } + /* Save syscalls if any. */ + ret = save_kernel_syscall(writer, kchan); + if (ret) { + goto end; + } + /* /events */ ret = config_writer_close_element(writer); if (ret) { @@ -861,7 +914,7 @@ int save_kernel_channel(struct config_writer *writer, goto end; } - ret = save_kernel_events(writer, &kchan->events_list); + ret = save_kernel_events(writer, kchan); if (ret) { goto end; }