From: Jérémie Galarneau Date: Sun, 23 Aug 2015 04:26:28 +0000 (-0400) Subject: Tag events created as side-effect of agent events as internal X-Git-Tag: v2.7.0-rc2~136 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9732459c9d6ee49fdc424ecad4cd956922e6ecf0;p=lttng-tools.git Tag events created as side-effect of agent events as internal Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 83153181f..c26e5163c 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -1409,16 +1409,28 @@ end: return ret; } + +static int cmd_enable_event_internal(struct ltt_session *session, + struct lttng_domain *domain, + char *channel_name, struct lttng_event *event, + char *filter_expression, + struct lttng_filter_bytecode *filter, + struct lttng_event_exclusion *exclusion, + int wpipe); + /* - * Command LTTNG_ENABLE_EVENT processed by the client thread. - * We own filter, exclusion, and filter_expression. + * Internal version of cmd_enable_event() with a supplemental + * "internal_event" flag which is used to enable internal events which should + * be hidden from clients. Such events are used in the agent implementation to + * enable the events through which all "agent" events are funeled. */ -int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, +static int _cmd_enable_event(struct ltt_session *session, + struct lttng_domain *domain, char *channel_name, struct lttng_event *event, char *filter_expression, struct lttng_filter_bytecode *filter, struct lttng_event_exclusion *exclusion, - int wpipe) + int wpipe, bool internal_event) { int ret, channel_created = 0; struct lttng_channel *attr; @@ -1614,7 +1626,8 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, /* At this point, the session and channel exist on the tracer */ ret = event_ust_enable_tracepoint(usess, uchan, event, - filter_expression, filter, exclusion); + filter_expression, filter, exclusion, + internal_event); /* We have passed ownership */ filter_expression = NULL; filter = NULL; @@ -1697,7 +1710,7 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, + filter->len); } - ret = cmd_enable_event(session, &tmp_dom, + ret = cmd_enable_event_internal(session, &tmp_dom, (char *) default_chan_name, &uevent, filter_expression, filter_copy, NULL, wpipe); @@ -1738,6 +1751,38 @@ error: return ret; } +/* + * Command LTTNG_ENABLE_EVENT processed by the client thread. + * We own filter, exclusion, and filter_expression. + */ +int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, + char *channel_name, struct lttng_event *event, + char *filter_expression, + struct lttng_filter_bytecode *filter, + struct lttng_event_exclusion *exclusion, + int wpipe) +{ + return _cmd_enable_event(session, domain, channel_name, event, + filter_expression, filter, exclusion, wpipe, false); +} + +/* + * Enable an event which is internal to LTTng. An internal should + * never be made visible to clients and are immune to checks such as + * reserved names. + */ +static int cmd_enable_event_internal(struct ltt_session *session, + struct lttng_domain *domain, + char *channel_name, struct lttng_event *event, + char *filter_expression, + struct lttng_filter_bytecode *filter, + struct lttng_event_exclusion *exclusion, + int wpipe) +{ + return _cmd_enable_event(session, domain, channel_name, event, + filter_expression, filter, exclusion, wpipe, true); +} + /* * Command LTTNG_LIST_TRACEPOINTS processed by the client thread. */ diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index 1c0955c37..91a7a912d 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -243,7 +243,7 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, /* Create ust event */ uevent = trace_ust_create_event(&events[i], filter_expression, - filter, NULL); + filter, NULL, false); if (uevent == NULL) { ret = LTTNG_ERR_FATAL; goto error_destroy; @@ -290,7 +290,8 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan, struct lttng_event *event, char *filter_expression, struct lttng_filter_bytecode *filter, - struct lttng_event_exclusion *exclusion) + struct lttng_event_exclusion *exclusion, + bool internal_event) { int ret = LTTNG_OK, to_create = 0; struct ltt_ust_event *uevent; @@ -305,7 +306,7 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, event->loglevel, exclusion); if (uevent == NULL) { uevent = trace_ust_create_event(event, filter_expression, - filter, exclusion); + filter, exclusion, internal_event); /* We have passed ownership */ filter_expression = NULL; filter = NULL; diff --git a/src/bin/lttng-sessiond/event.h b/src/bin/lttng-sessiond/event.h index cc4a3fa02..f9b486c2a 100644 --- a/src/bin/lttng-sessiond/event.h +++ b/src/bin/lttng-sessiond/event.h @@ -35,7 +35,8 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan, struct lttng_event *event, char *filter_expression, struct lttng_filter_bytecode *filter, - struct lttng_event_exclusion *exclusion); + struct lttng_event_exclusion *exclusion, + bool internal_event); int event_ust_disable_tracepoint(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan, char *event_name); diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 727e928c9..f8064a4c9 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -374,7 +374,8 @@ error: struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, char *filter_expression, struct lttng_filter_bytecode *filter, - struct lttng_event_exclusion *exclusion) + struct lttng_event_exclusion *exclusion, + bool internal_event) { struct ltt_ust_event *lue; @@ -386,6 +387,8 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, goto error; } + lue->internal = internal_event; + switch (ev->type) { case LTTNG_EVENT_PROBE: lue->attr.instrumentation = LTTNG_UST_PROBE; diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index c4dbe06c5..121d3b0cc 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -52,6 +52,7 @@ struct ltt_ust_event { char *filter_expression; struct lttng_ust_filter_bytecode *filter; struct lttng_event_exclusion *exclusion; + bool internal; }; /* UST channel */ @@ -185,7 +186,8 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr); struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, char *filter_expression, struct lttng_filter_bytecode *filter, - struct lttng_event_exclusion *exclusion); + struct lttng_event_exclusion *exclusion, + bool internal_event); struct ltt_ust_context *trace_ust_create_context( struct lttng_event_context *ctx); int trace_ust_match_context(struct ltt_ust_context *uctx, @@ -242,7 +244,8 @@ static inline struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, const char *filter_expression, struct lttng_filter_bytecode *filter, - struct lttng_event_exclusion *exclusion) + struct lttng_event_exclusion *exclusion, + bool internal_event) { return NULL; } diff --git a/tests/unit/test_ust_data.c b/tests/unit/test_ust_data.c index 6df66acbe..d83b8b5e3 100644 --- a/tests/unit/test_ust_data.c +++ b/tests/unit/test_ust_data.c @@ -125,7 +125,7 @@ static void test_create_ust_event(void) ev.type = LTTNG_EVENT_TRACEPOINT; ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL; - event = trace_ust_create_event(&ev, NULL, NULL, NULL); + event = trace_ust_create_event(&ev, NULL, NULL, NULL, false); ok(event != NULL, "Create UST event"); @@ -166,7 +166,7 @@ static void test_create_ust_event_exclusion(void) exclusion->count = 1; strncpy((char *)(exclusion->names), get_random_string(), LTTNG_SYMBOL_NAME_LEN); - event = trace_ust_create_event(&ev, NULL, NULL, exclusion); + event = trace_ust_create_event(&ev, NULL, NULL, exclusion, false); ok(event != NULL, "Create UST event with exclusion");