The -a -k --syscall was enabling all syscalls and all tracepoints.
Fix this issues by adding the enabel_kernel_event_syscalls.
At this commit, there is a problem with the list event that does not
list correctly all syscalls.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
{
struct lttcomm_session_msg lsm;
- if (!handle) {
+ if (!handle || ev == NULL) {
return -1;
}
copy_lttng_domain(&lsm.domain, &handle->domain);
- if (ev && ev->name[0] != '\0') {
+ if (ev->name[0] != '\0') {
lsm.cmd_type = LTTNG_ENABLE_EVENT;
- memcpy(&lsm.u.enable.event, ev, sizeof(lsm.u.enable.event));
} else {
lsm.cmd_type = LTTNG_ENABLE_ALL_EVENT;
}
+ memcpy(&lsm.u.enable.event, ev, sizeof(lsm.u.enable.event));
copy_string(lsm.session.name, handle->session_name,
sizeof(lsm.session.name));
#include "event.h"
#include "kernel-ctl.h"
+/*
+ * Setup a lttng_event used to enable *all* syscall tracing.
+ */
+static void init_syscalls_kernel_event(struct lttng_event *event)
+{
+ event->name[0] = '\0';
+ /*
+ * We use LTTNG_EVENT* here since the trace kernel creation will make the
+ * right changes for the kernel.
+ */
+ event->type = LTTNG_EVENT_SYSCALL;
+}
+
/*
* Disable kernel event for a channel from the kernel session.
*/
error:
return ret;
}
+
+/*
+ * Enable all kernel syscalls tracing.
+ */
+int event_kernel_enable_syscalls(struct ltt_kernel_session *ksession,
+ struct ltt_kernel_channel *kchan, int kernel_tracer_fd)
+{
+ int ret;
+ struct lttng_event event;
+
+ init_syscalls_kernel_event(&event);
+
+ DBG("Enabling all syscall tracing");
+
+ ret = kernel_create_event(&event, kchan);
+ if (ret < 0) {
+ goto error;
+ }
+
+ ret = LTTCOMM_OK;
+
+error:
+ return ret;
+}
struct ltt_kernel_channel *kchan, struct lttng_event *event);
int event_kernel_enable_all(struct ltt_kernel_session *ksession,
struct ltt_kernel_channel *kchan, int kernel_tracer_fd);
+int event_kernel_enable_syscalls(struct ltt_kernel_session *ksession,
+ struct ltt_kernel_channel *kchan, int kernel_tracer_fd);
#endif /* _LTT_EVENT_H */
* Command LTTNG_ENABLE_ALL_EVENT processed by the client thread.
*/
static int cmd_enable_event_all(struct ltt_session *session, int domain,
- char *channel_name)
+ char *channel_name, int event_type)
{
int ret;
struct ltt_kernel_channel *kchan;
goto error;
}
- ret = event_kernel_enable_all(session->kernel_session,
- kchan, kernel_tracer_fd);
+ if (event_type == LTTNG_KERNEL_SYSCALL) {
+ ret = event_kernel_enable_syscalls(session->kernel_session,
+ kchan, kernel_tracer_fd);
+ } else {
+ /*
+ * This call enables all LTTNG_KERNEL_TRACEPOINTS and events
+ * already registered to the channel.
+ */
+ ret = event_kernel_enable_all(session->kernel_session,
+ kchan, kernel_tracer_fd);
+ }
+
if (ret != LTTCOMM_OK) {
goto error;
}
DBG("Enabling all kernel event");
ret = cmd_enable_event_all(cmd_ctx->session, cmd_ctx->lsm->domain.type,
- cmd_ctx->lsm->u.enable.channel_name);
+ cmd_ctx->lsm->u.enable.channel_name,
+ cmd_ctx->lsm->u.enable.event.type);
break;
}
case LTTNG_LIST_TRACEPOINTS:
}
if (opt_enable_all) {
+ /* Default setup for enable all */
+ ev.name[0] = '\0';
+ ev.type = opt_event_type;
+
+ ret = lttng_enable_event(handle, &ev, channel_name);
+ if (ret < 0) {
+ goto error;
+ }
+
switch (opt_event_type) {
case LTTNG_EVENT_TRACEPOINT:
if (opt_kernel) {
- ret = lttng_enable_event(handle, NULL, channel_name);
- if (ret == 0) {
- MSG("All kernel events are enabled in channel %s", channel_name);
- }
- goto error;
+ MSG("All kernel events are enabled in channel %s",
+ channel_name);
}
- /* TODO: User-space tracer */
break;
case LTTNG_EVENT_SYSCALL:
if (opt_kernel) {
- ev.name[0] = '\0';
- ev.type = opt_event_type;
-
- ret = lttng_enable_event(handle, &ev, channel_name);
- if (ret == 0) {
- MSG("All kernel system calls are enabled in channel %s", channel_name);
- }
- goto error;
+ MSG("All kernel system calls are enabled in channel %s",
+ channel_name);
}
break;
default:
- MSG("Enable all not supported for this instrumentation type.");
+ /*
+ * We should not be here since lttng_enable_event should had failed
+ * on the event type.
+ */
goto error;
+
}
+
+ goto end;
}
/* Strip event list */
event_name = strtok(NULL, ",");
}
+end:
error:
if (opt_channel_name == NULL) {
free(channel_name);
{
struct lttng_handle *handle = NULL;
struct lttng_domain dom;
+ struct lttng_event event;
char *channel_name = "mychan";
int ret = 0;
dom.type = LTTNG_DOMAIN_KERNEL;
+ memset(&event, 0, sizeof(struct lttng_event));
+ event.type = LTTNG_EVENT_TRACEPOINT;
+
printf("\nTesting tracing all kernel events:\n");
printf("-----------\n");
/* Check if root */
PRINT_OK();
printf("Enabling all kernel events: ");
- if ((ret = lttng_enable_event(handle, NULL, channel_name)) < 0) {
+ if ((ret = lttng_enable_event(handle, &event, channel_name)) < 0) {
printf("error enabling event: %s\n", lttng_get_readable_code(ret));
goto enable_fail;
}