From 2b00d46244cab86f1186a7b00cdc660f24a26f72 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 6 Apr 2020 14:20:05 -0400 Subject: [PATCH] common: rename filter bytecode types MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The filter bytecode is going to be used for implementing capture expressions, so it's not going to be specific to filter. This patch renames the types related to bytecode to remove "filter" from their names. All the changes start in bytecode/bytecode.h, the changes in the other files are only fallouts. - `enum filter_op` is renamed `enum bytecode_op`. - `FILTER_OP_*` enumerators are renamed `BYTECODE_OP_*`. - The `filter_opcode_t` typedef is renamed `bytecode_opcode_t`. - `struct lttng_filter_bytecode_alloc` is renamed `struct lttng_bytecode_alloc`. - `struct lttng_filter_bytecode` is renamed `struct lttng_bytecode`. Change-Id: Iefdc667f3fbf715f868926c90108c6a5580b6f25 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479 --- .../lttng/event-rule/event-rule-internal.h | 4 +- include/lttng/event-rule/syscall-internal.h | 2 +- .../lttng/event-rule/tracepoint-internal.h | 2 +- src/bin/lttng-sessiond/agent.c | 2 +- src/bin/lttng-sessiond/agent.h | 4 +- src/bin/lttng-sessiond/client.c | 2 +- src/bin/lttng-sessiond/cmd.c | 14 +- src/bin/lttng-sessiond/cmd.h | 4 +- src/bin/lttng-sessiond/event.c | 20 +- src/bin/lttng-sessiond/event.h | 8 +- src/bin/lttng-sessiond/kernel.c | 2 +- src/bin/lttng-sessiond/kernel.h | 2 +- src/bin/lttng-sessiond/trace-kernel.c | 4 +- src/bin/lttng-sessiond/trace-kernel.h | 8 +- src/bin/lttng-sessiond/trace-ust.c | 4 +- src/bin/lttng-sessiond/trace-ust.h | 12 +- src/bin/lttng-sessiond/ust-app.c | 10 +- src/bin/lttng-sessiond/ust-app.h | 8 +- src/common/bytecode/bytecode.c | 20 +- src/common/bytecode/bytecode.h | 254 +++++++++--------- src/common/event-rule/event-rule.c | 2 +- src/common/event-rule/kprobe.c | 2 +- src/common/event-rule/syscall.c | 4 +- src/common/event-rule/tracepoint.c | 4 +- src/common/event-rule/uprobe.c | 2 +- src/common/filter.c | 2 +- src/common/filter.h | 2 +- src/common/filter/filter-ast.h | 4 +- .../filter/filter-visitor-generate-bytecode.c | 84 +++--- src/common/kernel-ctl/kernel-ctl.c | 2 +- src/common/kernel-ctl/kernel-ctl.h | 2 +- src/common/runas.c | 8 +- src/common/runas.h | 2 +- src/common/sessiond-comm/sessiond-comm.h | 2 +- 34 files changed, 256 insertions(+), 252 deletions(-) diff --git a/include/lttng/event-rule/event-rule-internal.h b/include/lttng/event-rule/event-rule-internal.h index a8ad34fe8..dd2d7dd18 100644 --- a/include/lttng/event-rule/event-rule-internal.h +++ b/include/lttng/event-rule/event-rule-internal.h @@ -46,7 +46,7 @@ typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)( const struct lttng_credentials *creds); typedef const char *(*event_rule_get_filter_cb)( const struct lttng_event_rule *event_rule); -typedef const struct lttng_filter_bytecode *( +typedef const struct lttng_bytecode *( *event_rule_get_filter_bytecode_cb)( const struct lttng_event_rule *event_rule); typedef enum lttng_event_rule_generate_exclusions_status ( @@ -126,7 +126,7 @@ const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule); * Caller DOES NOT own the returned object. */ LTTNG_HIDDEN -const struct lttng_filter_bytecode *lttng_event_rule_get_filter_bytecode( +const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode( const struct lttng_event_rule *rule); /* diff --git a/include/lttng/event-rule/syscall-internal.h b/include/lttng/event-rule/syscall-internal.h index e99b69ae4..b72274f5b 100644 --- a/include/lttng/event-rule/syscall-internal.h +++ b/include/lttng/event-rule/syscall-internal.h @@ -21,7 +21,7 @@ struct lttng_event_rule_syscall { /* Internal use only. */ struct { char *filter; - struct lttng_filter_bytecode *bytecode; + struct lttng_bytecode *bytecode; } internal_filter; }; diff --git a/include/lttng/event-rule/tracepoint-internal.h b/include/lttng/event-rule/tracepoint-internal.h index 039b0a6cf..227fe6de9 100644 --- a/include/lttng/event-rule/tracepoint-internal.h +++ b/include/lttng/event-rule/tracepoint-internal.h @@ -39,7 +39,7 @@ struct lttng_event_rule_tracepoint { /* internal use only. */ struct { char *filter; - struct lttng_filter_bytecode *bytecode; + struct lttng_bytecode *bytecode; } internal_filter; }; diff --git a/src/bin/lttng-sessiond/agent.c b/src/bin/lttng-sessiond/agent.c index 84728b782..283d5b035 100644 --- a/src/bin/lttng-sessiond/agent.c +++ b/src/bin/lttng-sessiond/agent.c @@ -1128,7 +1128,7 @@ error: */ struct agent_event *agent_create_event(const char *name, enum lttng_loglevel_type loglevel_type, int loglevel_value, - struct lttng_filter_bytecode *filter, char *filter_expression) + struct lttng_bytecode *filter, char *filter_expression) { struct agent_event *event = NULL; diff --git a/src/bin/lttng-sessiond/agent.h b/src/bin/lttng-sessiond/agent.h index e82f32627..c88af21c5 100644 --- a/src/bin/lttng-sessiond/agent.h +++ b/src/bin/lttng-sessiond/agent.h @@ -98,7 +98,7 @@ struct agent_event { struct lttng_ht_node_str node; /* Filter associated with the event. NULL if none. */ - struct lttng_filter_bytecode *filter; + struct lttng_bytecode *filter; char *filter_expression; struct lttng_event_exclusion *exclusion; }; @@ -146,7 +146,7 @@ void agent_add(struct agent *agt, struct lttng_ht *ht); /* Agent event API. */ struct agent_event *agent_create_event(const char *name, enum lttng_loglevel_type loglevel_type, int loglevel_value, - struct lttng_filter_bytecode *filter, + struct lttng_bytecode *filter, char *filter_expression); void agent_add_event(struct agent_event *event, struct agent *agt); diff --git a/src/bin/lttng-sessiond/client.c b/src/bin/lttng-sessiond/client.c index 00b5ec7e4..d752fb94e 100644 --- a/src/bin/lttng-sessiond/client.c +++ b/src/bin/lttng-sessiond/client.c @@ -1556,7 +1556,7 @@ error_add_context: { struct lttng_event *ev = NULL; struct lttng_event_exclusion *exclusion = NULL; - struct lttng_filter_bytecode *bytecode = NULL; + struct lttng_bytecode *bytecode = NULL; char *filter_expression = NULL; /* Handle exclusion events and receive it from the client. */ diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 8d36e7192..2d94204d3 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -115,7 +115,7 @@ static int cmd_enable_event_internal(struct ltt_session *session, const struct lttng_domain *domain, char *channel_name, struct lttng_event *event, char *filter_expression, - struct lttng_filter_bytecode *filter, + struct lttng_bytecode *filter, struct lttng_event_exclusion *exclusion, int wpipe); @@ -2083,7 +2083,7 @@ static int _cmd_enable_event(struct ltt_session *session, const struct lttng_domain *domain, char *channel_name, struct lttng_event *event, char *filter_expression, - struct lttng_filter_bytecode *filter, + struct lttng_bytecode *filter, struct lttng_event_exclusion *exclusion, int wpipe, bool internal_event) { @@ -2166,7 +2166,7 @@ static int _cmd_enable_event(struct ltt_session *session, case LTTNG_EVENT_ALL: { char *filter_expression_a = NULL; - struct lttng_filter_bytecode *filter_a = NULL; + struct lttng_bytecode *filter_a = NULL; /* * We need to duplicate filter_expression and filter, @@ -2401,11 +2401,11 @@ static int _cmd_enable_event(struct ltt_session *session, { char *filter_expression_copy = NULL; - struct lttng_filter_bytecode *filter_copy = NULL; + struct lttng_bytecode *filter_copy = NULL; if (filter) { const size_t filter_size = sizeof( - struct lttng_filter_bytecode) + struct lttng_bytecode) + filter->len; filter_copy = zmalloc(filter_size); @@ -2481,7 +2481,7 @@ int cmd_enable_event(struct ltt_session *session, const struct lttng_domain *domain, char *channel_name, struct lttng_event *event, char *filter_expression, - struct lttng_filter_bytecode *filter, + struct lttng_bytecode *filter, struct lttng_event_exclusion *exclusion, int wpipe) { @@ -2498,7 +2498,7 @@ static int cmd_enable_event_internal(struct ltt_session *session, const struct lttng_domain *domain, char *channel_name, struct lttng_event *event, char *filter_expression, - struct lttng_filter_bytecode *filter, + struct lttng_bytecode *filter, struct lttng_event_exclusion *exclusion, int wpipe) { diff --git a/src/bin/lttng-sessiond/cmd.h b/src/bin/lttng-sessiond/cmd.h index e434d50d6..dcda2365d 100644 --- a/src/bin/lttng-sessiond/cmd.h +++ b/src/bin/lttng-sessiond/cmd.h @@ -86,11 +86,11 @@ int cmd_add_context(struct ltt_session *session, enum lttng_domain_type domain, char *channel_name, const struct lttng_event_context *ctx, int kwpipe); int cmd_set_filter(struct ltt_session *session, enum lttng_domain_type domain, char *channel_name, struct lttng_event *event, - struct lttng_filter_bytecode *bytecode); + struct lttng_bytecode *bytecode); int cmd_enable_event(struct ltt_session *session, const struct lttng_domain *domain, char *channel_name, struct lttng_event *event, char *filter_expression, - struct lttng_filter_bytecode *filter, + struct lttng_bytecode *filter, struct lttng_event_exclusion *exclusion, int wpipe); diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index c7768a547..125adb9a0 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -48,7 +48,7 @@ static void add_unique_ust_event(struct lttng_ht *ht, assert(event); key.name = event->attr.name; - key.filter = (struct lttng_filter_bytecode *) event->filter; + key.filter = (struct lttng_bytecode *) event->filter; key.loglevel_type = event->attr.loglevel_type; key.loglevel_value = event->attr.loglevel; key.exclusion = event->exclusion; @@ -105,7 +105,7 @@ int event_kernel_disable_event(struct ltt_kernel_channel *kchan, */ int event_kernel_enable_event(struct ltt_kernel_channel *kchan, struct lttng_event *event, char *filter_expression, - struct lttng_filter_bytecode *filter) + struct lttng_bytecode *filter) { int ret; struct ltt_kernel_event *kevent; @@ -155,7 +155,7 @@ end: 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_bytecode *filter, struct lttng_event_exclusion *exclusion, bool internal_event) { @@ -393,7 +393,7 @@ static void agent_enable_all(struct agent *agt) */ int event_agent_enable_all(struct ltt_ust_session *usess, struct agent *agt, struct lttng_event *event, - struct lttng_filter_bytecode *filter ,char *filter_expression) + struct lttng_bytecode *filter ,char *filter_expression) { int ret; @@ -422,7 +422,7 @@ error: * contexts yet. Not an issue for now, since they are not generated by * the lttng-ctl library. */ -static int add_filter_app_ctx(struct lttng_filter_bytecode *bytecode, +static int add_filter_app_ctx(struct lttng_bytecode *bytecode, const char *filter_expression, struct agent *agt) { int ret = LTTNG_OK; @@ -481,7 +481,7 @@ end: static int agent_enable(struct agent *agt, struct lttng_event *event, - struct lttng_filter_bytecode *filter, + struct lttng_bytecode *filter, char *filter_expression) { int ret, created = 0; @@ -551,7 +551,7 @@ end: int event_agent_enable(struct ltt_ust_session *usess, struct agent *agt, struct lttng_event *event, - struct lttng_filter_bytecode *filter, + struct lttng_bytecode *filter, char *filter_expression) { assert(usess); @@ -581,8 +581,8 @@ int trigger_agent_enable(const struct lttng_trigger *trigger, struct agent *agt) const struct lttng_event_rule *rule; const char *filter_expression; char *filter_expression_copy = NULL; - const struct lttng_filter_bytecode *filter_bytecode; - struct lttng_filter_bytecode *filter_bytecode_copy = NULL; + const struct lttng_bytecode *filter_bytecode; + struct lttng_bytecode *filter_bytecode_copy = NULL; struct lttng_event *event = NULL; uid_t trigger_owner_uid = 0; const char *trigger_name; @@ -631,7 +631,7 @@ int trigger_agent_enable(const struct lttng_trigger *trigger, struct agent *agt) filter_bytecode = lttng_event_rule_get_filter_bytecode(rule); if (filter_bytecode) { filter_bytecode_copy = - lttng_filter_bytecode_copy(filter_bytecode); + lttng_bytecode_copy(filter_bytecode); if (!filter_bytecode_copy) { ret = LTTNG_ERR_NOMEM; goto end; diff --git a/src/bin/lttng-sessiond/event.h b/src/bin/lttng-sessiond/event.h index c7a849c0b..8849ee7cc 100644 --- a/src/bin/lttng-sessiond/event.h +++ b/src/bin/lttng-sessiond/event.h @@ -17,12 +17,12 @@ int event_kernel_disable_event(struct ltt_kernel_channel *kchan, int event_kernel_enable_event(struct ltt_kernel_channel *kchan, struct lttng_event *event, char *filter_expression, - struct lttng_filter_bytecode *filter); + struct lttng_bytecode *filter); 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_bytecode *filter, struct lttng_event_exclusion *exclusion, bool internal_event); int event_ust_disable_tracepoint(struct ltt_ust_session *usess, @@ -32,10 +32,10 @@ int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan); int event_agent_enable(struct ltt_ust_session *usess, struct agent *agt, - struct lttng_event *event, struct lttng_filter_bytecode *filter, + struct lttng_event *event, struct lttng_bytecode *filter, char *filter_expression); int event_agent_enable_all(struct ltt_ust_session *usess, struct agent *agt, - struct lttng_event *event, struct lttng_filter_bytecode *filter, + struct lttng_event *event, struct lttng_bytecode *filter, char *filter_expression); int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt, diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 2e920286c..23e8eac2a 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -568,7 +568,7 @@ end: int kernel_create_event(struct lttng_event *ev, struct ltt_kernel_channel *channel, char *filter_expression, - struct lttng_filter_bytecode *filter) + struct lttng_bytecode *filter) { int err, fd; enum lttng_error_code ret; diff --git a/src/bin/lttng-sessiond/kernel.h b/src/bin/lttng-sessiond/kernel.h index db05cfb44..a2dd7f060 100644 --- a/src/bin/lttng-sessiond/kernel.h +++ b/src/bin/lttng-sessiond/kernel.h @@ -29,7 +29,7 @@ int kernel_create_session(struct ltt_session *session); int kernel_create_channel(struct ltt_kernel_session *session, struct lttng_channel *chan); int kernel_create_event(struct lttng_event *ev, struct ltt_kernel_channel *channel, - char *filter_expression, struct lttng_filter_bytecode *filter); + char *filter_expression, struct lttng_bytecode *filter); int kernel_disable_channel(struct ltt_kernel_channel *chan); int kernel_disable_event(struct ltt_kernel_event *event); int kernel_enable_event(struct ltt_kernel_event *event); diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 7dde1b51d..2623b2971 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -71,7 +71,7 @@ struct ltt_kernel_channel *trace_kernel_get_channel_by_name( struct ltt_kernel_event *trace_kernel_find_event( char *name, struct ltt_kernel_channel *channel, enum lttng_event_type type, - struct lttng_filter_bytecode *filter) + struct lttng_bytecode *filter) { struct ltt_kernel_event *ev; int found = 0; @@ -330,7 +330,7 @@ error: */ enum lttng_error_code trace_kernel_create_event( struct lttng_event *ev, char *filter_expression, - struct lttng_filter_bytecode *filter, + struct lttng_bytecode *filter, struct ltt_kernel_event **kernel_event) { enum lttng_error_code ret; diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h index 4b564ee4d..89a4ab19f 100644 --- a/src/bin/lttng-sessiond/trace-kernel.h +++ b/src/bin/lttng-sessiond/trace-kernel.h @@ -48,7 +48,7 @@ struct ltt_kernel_event { struct lttng_kernel_event *event; struct cds_list_head list; char *filter_expression; - struct lttng_filter_bytecode *filter; + struct lttng_bytecode *filter; struct lttng_userspace_probe_location *userspace_probe_location; }; @@ -59,7 +59,7 @@ struct ltt_kernel_event_notifier_rule { enum lttng_event_type type; struct lttng_trigger *trigger; uint64_t token; - const struct lttng_filter_bytecode *filter; + const struct lttng_bytecode *filter; struct lttng_userspace_probe_location *userspace_probe_location; struct cds_lfht_node ht_node; /* call_rcu delayed reclaim. */ @@ -146,7 +146,7 @@ struct ltt_kernel_event *trace_kernel_get_event_by_name( struct ltt_kernel_event *trace_kernel_find_event( char *name, struct ltt_kernel_channel *channel, enum lttng_event_type type, - struct lttng_filter_bytecode *filter); + struct lttng_bytecode *filter); struct ltt_kernel_channel *trace_kernel_get_channel_by_name( const char *name, struct ltt_kernel_session *session); @@ -157,7 +157,7 @@ struct ltt_kernel_session *trace_kernel_create_session(void); struct ltt_kernel_channel *trace_kernel_create_channel( struct lttng_channel *chan); enum lttng_error_code trace_kernel_create_event(struct lttng_event *ev, - char *filter_expression, struct lttng_filter_bytecode *filter, + char *filter_expression, struct lttng_bytecode *filter, struct ltt_kernel_event **kernel_event); struct ltt_kernel_metadata *trace_kernel_create_metadata(void); struct ltt_kernel_stream *trace_kernel_create_stream(const char *name, diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 7ee379ef8..527b354f1 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -194,7 +194,7 @@ error: * MUST be acquired before calling this. */ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, - char *name, struct lttng_filter_bytecode *filter, + char *name, struct lttng_bytecode *filter, enum lttng_ust_loglevel_type loglevel_type, int loglevel_value, struct lttng_event_exclusion *exclusion) { @@ -446,7 +446,7 @@ end: */ enum lttng_error_code trace_ust_create_event(struct lttng_event *ev, char *filter_expression, - struct lttng_filter_bytecode *filter, + struct lttng_bytecode *filter, struct lttng_event_exclusion *exclusion, bool internal_event, struct ltt_ust_event **ust_event) diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index ecd0b8771..53e1ab2b5 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -24,7 +24,7 @@ struct agent; struct ltt_ust_ht_key { const char *name; - const struct lttng_filter_bytecode *filter; + const struct lttng_bytecode *filter; enum lttng_ust_loglevel_type loglevel_type; int loglevel_value; const struct lttng_event_exclusion *exclusion; @@ -43,7 +43,7 @@ struct ltt_ust_event { struct lttng_ust_event attr; struct lttng_ht_node_str node; char *filter_expression; - struct lttng_filter_bytecode *filter; + struct lttng_bytecode *filter; struct lttng_event_exclusion *exclusion; /* * An internal event is an event which was created by the session daemon @@ -182,7 +182,7 @@ int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node, * Lookup functions. NULL is returned if not found. */ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, - char *name, struct lttng_filter_bytecode *filter, + char *name, struct lttng_bytecode *filter, enum lttng_ust_loglevel_type loglevel_type, int loglevel_value, struct lttng_event_exclusion *exclusion); struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, @@ -198,7 +198,7 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, enum lttng_domain_type domain); enum lttng_error_code trace_ust_create_event(struct lttng_event *ev, char *filter_expression, - struct lttng_filter_bytecode *filter, + struct lttng_bytecode *filter, struct lttng_event_exclusion *exclusion, bool internal_event, struct ltt_ust_event **ust_event); struct ltt_ust_context *trace_ust_create_context( @@ -270,7 +270,7 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, static inline enum lttng_error_code trace_ust_create_event(struct lttng_event *ev, const char *filter_expression, - struct lttng_filter_bytecode *filter, + struct lttng_bytecode *filter, struct lttng_event_exclusion *exclusion, bool internal_event, struct ltt_ust_event **ust_event) { @@ -310,7 +310,7 @@ int trace_ust_match_context(const struct ltt_ust_context *uctx, } static inline struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, - char *name, struct lttng_filter_bytecode *filter, + char *name, struct lttng_bytecode *filter, enum lttng_ust_loglevel_type loglevel_type, int loglevel_value, struct lttng_event_exclusion *exclusion) { diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 5ba14748d..9321d2789 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1324,7 +1324,7 @@ error: * Return allocated filter or NULL on error. */ static struct lttng_ust_filter_bytecode *create_ust_bytecode_from_bytecode( - const struct lttng_filter_bytecode *orig_f) + const struct lttng_bytecode *orig_f) { struct lttng_ust_filter_bytecode *filter = NULL; @@ -1335,7 +1335,7 @@ static struct lttng_ust_filter_bytecode *create_ust_bytecode_from_bytecode( goto error; } - assert(sizeof(struct lttng_filter_bytecode) == + assert(sizeof(struct lttng_bytecode) == sizeof(struct lttng_ust_filter_bytecode)); memcpy(filter, orig_f, sizeof(*filter) + orig_f->len); error: @@ -1394,7 +1394,7 @@ error: * Return an ust_app_event object or NULL on error. */ static struct ust_app_event *find_ust_app_event(struct lttng_ht *ht, - const char *name, const struct lttng_filter_bytecode *filter, + const char *name, const struct lttng_bytecode *filter, int loglevel_value, const struct lttng_event_exclusion *exclusion) { @@ -1503,7 +1503,7 @@ error: * Set the filter on the tracer. */ static int set_ust_object_filter(struct ust_app *app, - const struct lttng_filter_bytecode *bytecode, + const struct lttng_bytecode *bytecode, struct lttng_ust_object_data *ust_object) { int ret; @@ -2112,7 +2112,7 @@ static void shadow_copy_event(struct ust_app_event *ua_event, /* Copy filter bytecode */ if (uevent->filter) { - ua_event->filter = lttng_filter_bytecode_copy(uevent->filter); + ua_event->filter = lttng_bytecode_copy(uevent->filter); /* Filter might be NULL here in case of ENONEM. */ } diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 65ed6a255..d10c1e32f 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -22,7 +22,7 @@ /* Process name (short). */ #define UST_APP_PROCNAME_LEN 16 -struct lttng_filter_bytecode; +struct lttng_bytecode; struct lttng_ust_filter_bytecode; extern int ust_consumerd64_fd, ust_consumerd32_fd; @@ -39,7 +39,7 @@ struct ust_app_notify_sock_obj { struct ust_app_ht_key { const char *name; - const struct lttng_filter_bytecode *filter; + const struct lttng_bytecode *filter; enum lttng_ust_loglevel_type loglevel_type; const struct lttng_event_exclusion *exclusion; }; @@ -108,7 +108,7 @@ struct ust_app_event { struct lttng_ust_event attr; char name[LTTNG_UST_SYM_NAME_LEN]; struct lttng_ht_node_str node; - struct lttng_filter_bytecode *filter; + struct lttng_bytecode *filter; struct lttng_event_exclusion *exclusion; }; @@ -122,7 +122,7 @@ struct ust_app_event_notifier_rule { uint64_t token; struct lttng_ht_node_u64 node; /* The event_rule object owns the filter. */ - const struct lttng_filter_bytecode *filter; + const struct lttng_bytecode *filter; /* Owned by this. */ struct lttng_event_exclusion *exclusion; /* For delayed reclaim. */ diff --git a/src/common/bytecode/bytecode.c b/src/common/bytecode/bytecode.c index e85dd66c1..4f8c325b5 100644 --- a/src/common/bytecode/bytecode.c +++ b/src/common/bytecode/bytecode.c @@ -24,11 +24,11 @@ static inline int get_count_order(unsigned int count) } LTTNG_HIDDEN -int bytecode_init(struct lttng_filter_bytecode_alloc **fb) +int bytecode_init(struct lttng_bytecode_alloc **fb) { uint32_t alloc_len; - alloc_len = sizeof(struct lttng_filter_bytecode_alloc) + INIT_ALLOC_SIZE; + alloc_len = sizeof(struct lttng_bytecode_alloc) + INIT_ALLOC_SIZE; *fb = calloc(alloc_len, 1); if (!*fb) { return -ENOMEM; @@ -39,19 +39,19 @@ int bytecode_init(struct lttng_filter_bytecode_alloc **fb) } LTTNG_HIDDEN -int32_t bytecode_reserve(struct lttng_filter_bytecode_alloc **fb, uint32_t align, uint32_t len) +int32_t bytecode_reserve(struct lttng_bytecode_alloc **fb, uint32_t align, uint32_t len) { int32_t ret; uint32_t padding = offset_align((*fb)->b.len, align); uint32_t new_len = (*fb)->b.len + padding + len; - uint32_t new_alloc_len = sizeof(struct lttng_filter_bytecode_alloc) + new_len; + uint32_t new_alloc_len = sizeof(struct lttng_bytecode_alloc) + new_len; uint32_t old_alloc_len = (*fb)->alloc_len; if (new_len > LTTNG_FILTER_MAX_LEN) return -EINVAL; if (new_alloc_len > old_alloc_len) { - struct lttng_filter_bytecode_alloc *newptr; + struct lttng_bytecode_alloc *newptr; new_alloc_len = max_t(uint32_t, 1U << get_count_order(new_alloc_len), old_alloc_len << 1); @@ -70,7 +70,7 @@ int32_t bytecode_reserve(struct lttng_filter_bytecode_alloc **fb, uint32_t align } LTTNG_HIDDEN -int bytecode_push(struct lttng_filter_bytecode_alloc **fb, const void *data, +int bytecode_push(struct lttng_bytecode_alloc **fb, const void *data, uint32_t align, uint32_t len) { int32_t offset; @@ -83,7 +83,7 @@ int bytecode_push(struct lttng_filter_bytecode_alloc **fb, const void *data, } LTTNG_HIDDEN -int bytecode_push_logical(struct lttng_filter_bytecode_alloc **fb, +int bytecode_push_logical(struct lttng_bytecode_alloc **fb, struct logical_op *data, uint32_t align, uint32_t len, uint16_t *skip_offset) @@ -106,10 +106,10 @@ int bytecode_push_logical(struct lttng_filter_bytecode_alloc **fb, * Return allocated bytecode or NULL on error. */ LTTNG_HIDDEN -struct lttng_filter_bytecode *lttng_filter_bytecode_copy( - const struct lttng_filter_bytecode *orig_f) +struct lttng_bytecode *lttng_bytecode_copy( + const struct lttng_bytecode *orig_f) { - struct lttng_filter_bytecode *bytecode = NULL; + struct lttng_bytecode *bytecode = NULL; bytecode = zmalloc(sizeof(*bytecode) + orig_f->len); if (!bytecode) { diff --git a/src/common/bytecode/bytecode.h b/src/common/bytecode/bytecode.h index 3a639c939..151ca8a0f 100644 --- a/src/common/bytecode/bytecode.h +++ b/src/common/bytecode/bytecode.h @@ -47,202 +47,206 @@ struct literal_string { char string[0]; } LTTNG_PACKED; -enum filter_op { - FILTER_OP_UNKNOWN = 0, +enum bytecode_op { + BYTECODE_OP_UNKNOWN = 0, - FILTER_OP_RETURN = 1, + BYTECODE_OP_RETURN = 1, /* binary */ - FILTER_OP_MUL = 2, - FILTER_OP_DIV = 3, - FILTER_OP_MOD = 4, - FILTER_OP_PLUS = 5, - FILTER_OP_MINUS = 6, - FILTER_OP_BIT_RSHIFT = 7, - FILTER_OP_BIT_LSHIFT = 8, - FILTER_OP_BIT_AND = 9, - FILTER_OP_BIT_OR = 10, - FILTER_OP_BIT_XOR = 11, + BYTECODE_OP_MUL = 2, + BYTECODE_OP_DIV = 3, + BYTECODE_OP_MOD = 4, + BYTECODE_OP_PLUS = 5, + BYTECODE_OP_MINUS = 6, + BYTECODE_OP_BIT_RSHIFT = 7, + BYTECODE_OP_BIT_LSHIFT = 8, + BYTECODE_OP_BIT_AND = 9, + BYTECODE_OP_BIT_OR = 10, + BYTECODE_OP_BIT_XOR = 11, /* binary comparators */ - FILTER_OP_EQ = 12, - FILTER_OP_NE = 13, - FILTER_OP_GT = 14, - FILTER_OP_LT = 15, - FILTER_OP_GE = 16, - FILTER_OP_LE = 17, + BYTECODE_OP_EQ = 12, + BYTECODE_OP_NE = 13, + BYTECODE_OP_GT = 14, + BYTECODE_OP_LT = 15, + BYTECODE_OP_GE = 16, + BYTECODE_OP_LE = 17, /* string binary comparator: apply to */ - FILTER_OP_EQ_STRING = 18, - FILTER_OP_NE_STRING = 19, - FILTER_OP_GT_STRING = 20, - FILTER_OP_LT_STRING = 21, - FILTER_OP_GE_STRING = 22, - FILTER_OP_LE_STRING = 23, + BYTECODE_OP_EQ_STRING = 18, + BYTECODE_OP_NE_STRING = 19, + BYTECODE_OP_GT_STRING = 20, + BYTECODE_OP_LT_STRING = 21, + BYTECODE_OP_GE_STRING = 22, + BYTECODE_OP_LE_STRING = 23, /* s64 binary comparator */ - FILTER_OP_EQ_S64 = 24, - FILTER_OP_NE_S64 = 25, - FILTER_OP_GT_S64 = 26, - FILTER_OP_LT_S64 = 27, - FILTER_OP_GE_S64 = 28, - FILTER_OP_LE_S64 = 29, + BYTECODE_OP_EQ_S64 = 24, + BYTECODE_OP_NE_S64 = 25, + BYTECODE_OP_GT_S64 = 26, + BYTECODE_OP_LT_S64 = 27, + BYTECODE_OP_GE_S64 = 28, + BYTECODE_OP_LE_S64 = 29, /* double binary comparator */ - FILTER_OP_EQ_DOUBLE = 30, - FILTER_OP_NE_DOUBLE = 31, - FILTER_OP_GT_DOUBLE = 32, - FILTER_OP_LT_DOUBLE = 33, - FILTER_OP_GE_DOUBLE = 34, - FILTER_OP_LE_DOUBLE = 35, + BYTECODE_OP_EQ_DOUBLE = 30, + BYTECODE_OP_NE_DOUBLE = 31, + BYTECODE_OP_GT_DOUBLE = 32, + BYTECODE_OP_LT_DOUBLE = 33, + BYTECODE_OP_GE_DOUBLE = 34, + BYTECODE_OP_LE_DOUBLE = 35, /* Mixed S64-double binary comparators */ - FILTER_OP_EQ_DOUBLE_S64 = 36, - FILTER_OP_NE_DOUBLE_S64 = 37, - FILTER_OP_GT_DOUBLE_S64 = 38, - FILTER_OP_LT_DOUBLE_S64 = 39, - FILTER_OP_GE_DOUBLE_S64 = 40, - FILTER_OP_LE_DOUBLE_S64 = 41, - - FILTER_OP_EQ_S64_DOUBLE = 42, - FILTER_OP_NE_S64_DOUBLE = 43, - FILTER_OP_GT_S64_DOUBLE = 44, - FILTER_OP_LT_S64_DOUBLE = 45, - FILTER_OP_GE_S64_DOUBLE = 46, - FILTER_OP_LE_S64_DOUBLE = 47, + BYTECODE_OP_EQ_DOUBLE_S64 = 36, + BYTECODE_OP_NE_DOUBLE_S64 = 37, + BYTECODE_OP_GT_DOUBLE_S64 = 38, + BYTECODE_OP_LT_DOUBLE_S64 = 39, + BYTECODE_OP_GE_DOUBLE_S64 = 40, + BYTECODE_OP_LE_DOUBLE_S64 = 41, + + BYTECODE_OP_EQ_S64_DOUBLE = 42, + BYTECODE_OP_NE_S64_DOUBLE = 43, + BYTECODE_OP_GT_S64_DOUBLE = 44, + BYTECODE_OP_LT_S64_DOUBLE = 45, + BYTECODE_OP_GE_S64_DOUBLE = 46, + BYTECODE_OP_LE_S64_DOUBLE = 47, /* unary */ - FILTER_OP_UNARY_PLUS = 48, - FILTER_OP_UNARY_MINUS = 49, - FILTER_OP_UNARY_NOT = 50, - FILTER_OP_UNARY_PLUS_S64 = 51, - FILTER_OP_UNARY_MINUS_S64 = 52, - FILTER_OP_UNARY_NOT_S64 = 53, - FILTER_OP_UNARY_PLUS_DOUBLE = 54, - FILTER_OP_UNARY_MINUS_DOUBLE = 55, - FILTER_OP_UNARY_NOT_DOUBLE = 56, + BYTECODE_OP_UNARY_PLUS = 48, + BYTECODE_OP_UNARY_MINUS = 49, + BYTECODE_OP_UNARY_NOT = 50, + BYTECODE_OP_UNARY_PLUS_S64 = 51, + BYTECODE_OP_UNARY_MINUS_S64 = 52, + BYTECODE_OP_UNARY_NOT_S64 = 53, + BYTECODE_OP_UNARY_PLUS_DOUBLE = 54, + BYTECODE_OP_UNARY_MINUS_DOUBLE = 55, + BYTECODE_OP_UNARY_NOT_DOUBLE = 56, /* logical */ - FILTER_OP_AND = 57, - FILTER_OP_OR = 58, + BYTECODE_OP_AND = 57, + BYTECODE_OP_OR = 58, /* load field ref */ - FILTER_OP_LOAD_FIELD_REF = 59, - FILTER_OP_LOAD_FIELD_REF_STRING = 60, - FILTER_OP_LOAD_FIELD_REF_SEQUENCE = 61, - FILTER_OP_LOAD_FIELD_REF_S64 = 62, - FILTER_OP_LOAD_FIELD_REF_DOUBLE = 63, + BYTECODE_OP_LOAD_FIELD_REF = 59, + BYTECODE_OP_LOAD_FIELD_REF_STRING = 60, + BYTECODE_OP_LOAD_FIELD_REF_SEQUENCE = 61, + BYTECODE_OP_LOAD_FIELD_REF_S64 = 62, + BYTECODE_OP_LOAD_FIELD_REF_DOUBLE = 63, /* load immediate from operand */ - FILTER_OP_LOAD_STRING = 64, - FILTER_OP_LOAD_S64 = 65, - FILTER_OP_LOAD_DOUBLE = 66, + BYTECODE_OP_LOAD_STRING = 64, + BYTECODE_OP_LOAD_S64 = 65, + BYTECODE_OP_LOAD_DOUBLE = 66, /* cast */ - FILTER_OP_CAST_TO_S64 = 67, - FILTER_OP_CAST_DOUBLE_TO_S64 = 68, - FILTER_OP_CAST_NOP = 69, + BYTECODE_OP_CAST_TO_S64 = 67, + BYTECODE_OP_CAST_DOUBLE_TO_S64 = 68, + BYTECODE_OP_CAST_NOP = 69, /* get context ref */ - FILTER_OP_GET_CONTEXT_REF = 70, - FILTER_OP_GET_CONTEXT_REF_STRING = 71, - FILTER_OP_GET_CONTEXT_REF_S64 = 72, - FILTER_OP_GET_CONTEXT_REF_DOUBLE = 73, + BYTECODE_OP_GET_CONTEXT_REF = 70, + BYTECODE_OP_GET_CONTEXT_REF_STRING = 71, + BYTECODE_OP_GET_CONTEXT_REF_S64 = 72, + BYTECODE_OP_GET_CONTEXT_REF_DOUBLE = 73, /* load userspace field ref */ - FILTER_OP_LOAD_FIELD_REF_USER_STRING = 74, - FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE = 75, + BYTECODE_OP_LOAD_FIELD_REF_USER_STRING = 74, + BYTECODE_OP_LOAD_FIELD_REF_USER_SEQUENCE = 75, /* * load immediate star globbing pattern (literal string) * from immediate */ - FILTER_OP_LOAD_STAR_GLOB_STRING = 76, + BYTECODE_OP_LOAD_STAR_GLOB_STRING = 76, /* globbing pattern binary operator: apply to */ - FILTER_OP_EQ_STAR_GLOB_STRING = 77, - FILTER_OP_NE_STAR_GLOB_STRING = 78, + BYTECODE_OP_EQ_STAR_GLOB_STRING = 77, + BYTECODE_OP_NE_STAR_GLOB_STRING = 78, /* * Instructions for recursive traversal through composed types. */ - FILTER_OP_GET_CONTEXT_ROOT = 79, - FILTER_OP_GET_APP_CONTEXT_ROOT = 80, - FILTER_OP_GET_PAYLOAD_ROOT = 81, - - FILTER_OP_GET_SYMBOL = 82, - FILTER_OP_GET_SYMBOL_FIELD = 83, - FILTER_OP_GET_INDEX_U16 = 84, - FILTER_OP_GET_INDEX_U64 = 85, - - FILTER_OP_LOAD_FIELD = 86, - FILTER_OP_LOAD_FIELD_S8 = 87, - FILTER_OP_LOAD_FIELD_S16 = 88, - FILTER_OP_LOAD_FIELD_S32 = 89, - FILTER_OP_LOAD_FIELD_S64 = 90, - FILTER_OP_LOAD_FIELD_U8 = 91, - FILTER_OP_LOAD_FIELD_U16 = 92, - FILTER_OP_LOAD_FIELD_U32 = 93, - FILTER_OP_LOAD_FIELD_U64 = 94, - FILTER_OP_LOAD_FIELD_STRING = 95, - FILTER_OP_LOAD_FIELD_SEQUENCE = 96, - FILTER_OP_LOAD_FIELD_DOUBLE = 97, - - FILTER_OP_UNARY_BIT_NOT = 98, - - FILTER_OP_RETURN_S64 = 99, - - NR_FILTER_OPS, + BYTECODE_OP_GET_CONTEXT_ROOT = 79, + BYTECODE_OP_GET_APP_CONTEXT_ROOT = 80, + BYTECODE_OP_GET_PAYLOAD_ROOT = 81, + + BYTECODE_OP_GET_SYMBOL = 82, + BYTECODE_OP_GET_SYMBOL_FIELD = 83, + BYTECODE_OP_GET_INDEX_U16 = 84, + BYTECODE_OP_GET_INDEX_U64 = 85, + + BYTECODE_OP_LOAD_FIELD = 86, + BYTECODE_OP_LOAD_FIELD_S8 = 87, + BYTECODE_OP_LOAD_FIELD_S16 = 88, + BYTECODE_OP_LOAD_FIELD_S32 = 89, + BYTECODE_OP_LOAD_FIELD_S64 = 90, + BYTECODE_OP_LOAD_FIELD_U8 = 91, + BYTECODE_OP_LOAD_FIELD_U16 = 92, + BYTECODE_OP_LOAD_FIELD_U32 = 93, + BYTECODE_OP_LOAD_FIELD_U64 = 94, + BYTECODE_OP_LOAD_FIELD_STRING = 95, + BYTECODE_OP_LOAD_FIELD_SEQUENCE = 96, + BYTECODE_OP_LOAD_FIELD_DOUBLE = 97, + + BYTECODE_OP_UNARY_BIT_NOT = 98, + + BYTECODE_OP_RETURN_S64 = 99, + + NR_BYTECODE_OPS, }; -typedef uint8_t filter_opcode_t; +typedef uint8_t bytecode_opcode_t; struct load_op { - filter_opcode_t op; + bytecode_opcode_t op; + + /* + * data to load. Size known by enum bytecode_opcode_t and null-term + * char. + */ char data[0]; - /* data to load. Size known by enum filter_opcode and null-term char. */ } LTTNG_PACKED; struct binary_op { - filter_opcode_t op; + bytecode_opcode_t op; } LTTNG_PACKED; struct unary_op { - filter_opcode_t op; + bytecode_opcode_t op; } LTTNG_PACKED; /* skip_offset is absolute from start of bytecode */ struct logical_op { - filter_opcode_t op; + bytecode_opcode_t op; uint16_t skip_offset; /* bytecode insn, if skip second test */ } LTTNG_PACKED; struct cast_op { - filter_opcode_t op; + bytecode_opcode_t op; } LTTNG_PACKED; struct return_op { - filter_opcode_t op; + bytecode_opcode_t op; } LTTNG_PACKED; -struct lttng_filter_bytecode_alloc { +struct lttng_bytecode_alloc { uint32_t alloc_len; - struct lttng_filter_bytecode b; + struct lttng_bytecode b; }; -LTTNG_HIDDEN int bytecode_init(struct lttng_filter_bytecode_alloc **fb); -LTTNG_HIDDEN int32_t bytecode_reserve(struct lttng_filter_bytecode_alloc **fb, +LTTNG_HIDDEN int bytecode_init(struct lttng_bytecode_alloc **fb); +LTTNG_HIDDEN int32_t bytecode_reserve(struct lttng_bytecode_alloc **fb, uint32_t align, uint32_t len); -LTTNG_HIDDEN int bytecode_push(struct lttng_filter_bytecode_alloc **fb, +LTTNG_HIDDEN int bytecode_push(struct lttng_bytecode_alloc **fb, const void *data, uint32_t align, uint32_t len); -LTTNG_HIDDEN int bytecode_push_logical(struct lttng_filter_bytecode_alloc **fb, +LTTNG_HIDDEN int bytecode_push_logical(struct lttng_bytecode_alloc **fb, struct logical_op *data, uint32_t align, uint32_t len, uint16_t *skip_offset); -LTTNG_HIDDEN struct lttng_filter_bytecode *lttng_filter_bytecode_copy( - const struct lttng_filter_bytecode *orig_f); +LTTNG_HIDDEN struct lttng_bytecode *lttng_bytecode_copy( + const struct lttng_bytecode *orig_f); static inline -unsigned int bytecode_get_len(struct lttng_filter_bytecode *bytecode) +unsigned int bytecode_get_len(struct lttng_bytecode *bytecode) { return bytecode->len; } diff --git a/src/common/event-rule/event-rule.c b/src/common/event-rule/event-rule.c index 98ff37411..3a5be731b 100644 --- a/src/common/event-rule/event-rule.c +++ b/src/common/event-rule/event-rule.c @@ -259,7 +259,7 @@ const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule) } LTTNG_HIDDEN -const struct lttng_filter_bytecode *lttng_event_rule_get_filter_bytecode( +const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode( const struct lttng_event_rule *rule) { assert(rule->get_filter_bytecode); diff --git a/src/common/event-rule/kprobe.c b/src/common/event-rule/kprobe.c index 01699caf1..12e6010ac 100644 --- a/src/common/event-rule/kprobe.c +++ b/src/common/event-rule/kprobe.c @@ -163,7 +163,7 @@ static const char *lttng_event_rule_kprobe_get_filter( return NULL; } -static const struct lttng_filter_bytecode * +static const struct lttng_bytecode * lttng_event_rule_kprobe_get_filter_bytecode(const struct lttng_event_rule *rule) { /* Not supported. */ diff --git a/src/common/event-rule/syscall.c b/src/common/event-rule/syscall.c index 98c272d40..b1b556aba 100644 --- a/src/common/event-rule/syscall.c +++ b/src/common/event-rule/syscall.c @@ -148,7 +148,7 @@ static enum lttng_error_code lttng_event_rule_syscall_generate_filter_bytecode( struct lttng_event_rule_syscall *syscall; enum lttng_event_rule_status status; const char *filter; - struct lttng_filter_bytecode *bytecode = NULL; + struct lttng_bytecode *bytecode = NULL; assert(rule); @@ -205,7 +205,7 @@ static const char *lttng_event_rule_syscall_get_internal_filter( return syscall->internal_filter.filter; } -static const struct lttng_filter_bytecode * +static const struct lttng_bytecode * lttng_event_rule_syscall_get_internal_filter_bytecode( const struct lttng_event_rule *rule) { diff --git a/src/common/event-rule/tracepoint.c b/src/common/event-rule/tracepoint.c index d6f3b9fb7..c8111a372 100644 --- a/src/common/event-rule/tracepoint.c +++ b/src/common/event-rule/tracepoint.c @@ -370,7 +370,7 @@ lttng_event_rule_tracepoint_generate_filter_bytecode( enum lttng_domain_type domain_type; enum lttng_event_rule_status status; const char *filter; - struct lttng_filter_bytecode *bytecode = NULL; + struct lttng_bytecode *bytecode = NULL; assert(rule); @@ -462,7 +462,7 @@ static const char *lttng_event_rule_tracepoint_get_internal_filter( return tracepoint->internal_filter.filter; } -static const struct lttng_filter_bytecode * +static const struct lttng_bytecode * lttng_event_rule_tracepoint_get_internal_filter_bytecode( const struct lttng_event_rule *rule) { diff --git a/src/common/event-rule/uprobe.c b/src/common/event-rule/uprobe.c index de4ee1cb0..67f99c482 100644 --- a/src/common/event-rule/uprobe.c +++ b/src/common/event-rule/uprobe.c @@ -155,7 +155,7 @@ static const char *lttng_event_rule_uprobe_get_filter( return NULL; } -static const struct lttng_filter_bytecode * +static const struct lttng_bytecode * lttng_event_rule_uprobe_get_filter_bytecode(const struct lttng_event_rule *rule) { /* Unsupported. */ diff --git a/src/common/filter.c b/src/common/filter.c index fc16f1d52..5d333375d 100644 --- a/src/common/filter.c +++ b/src/common/filter.c @@ -16,7 +16,7 @@ struct bytecode_symbol_iterator { LTTNG_HIDDEN struct bytecode_symbol_iterator *bytecode_symbol_iterator_create( - struct lttng_filter_bytecode *bytecode) + struct lttng_bytecode *bytecode) { struct bytecode_symbol_iterator *it = NULL; diff --git a/src/common/filter.h b/src/common/filter.h index 2cbdd14a9..a03b1d9fe 100644 --- a/src/common/filter.h +++ b/src/common/filter.h @@ -18,7 +18,7 @@ struct bytecode_symbol_iterator; */ LTTNG_HIDDEN struct bytecode_symbol_iterator *bytecode_symbol_iterator_create( - struct lttng_filter_bytecode *bytecode); + struct lttng_bytecode *bytecode); /* * Advance iterator of one element. diff --git a/src/common/filter/filter-ast.h b/src/common/filter/filter-ast.h index a82e4f6bf..93f9b9b25 100644 --- a/src/common/filter/filter-ast.h +++ b/src/common/filter/filter-ast.h @@ -158,8 +158,8 @@ struct filter_parser_ctx { struct filter_ast *ast; struct cds_list_head allocated_strings; struct ir_op *ir_root; - struct lttng_filter_bytecode_alloc *bytecode; - struct lttng_filter_bytecode_alloc *bytecode_reloc; + struct lttng_bytecode_alloc *bytecode; + struct lttng_bytecode_alloc *bytecode_reloc; }; struct filter_parser_ctx *filter_parser_ctx_alloc(FILE *input); diff --git a/src/common/filter/filter-visitor-generate-bytecode.c b/src/common/filter/filter-visitor-generate-bytecode.c index a5e7a5afe..51ebad130 100644 --- a/src/common/filter/filter-visitor-generate-bytecode.c +++ b/src/common/filter/filter-visitor-generate-bytecode.c @@ -31,7 +31,7 @@ int recursive_visit_gen_bytecode(struct filter_parser_ctx *ctx, struct ir_op *node); static -int bytecode_patch(struct lttng_filter_bytecode_alloc **fb, +int bytecode_patch(struct lttng_bytecode_alloc **fb, const void *data, uint16_t offset, uint32_t len) @@ -55,7 +55,7 @@ int visit_node_root(struct filter_parser_ctx *ctx, struct ir_op *node) return ret; /* Generate end of bytecode instruction */ - insn.op = FILTER_OP_RETURN; + insn.op = BYTECODE_OP_RETURN; return bytecode_push(&ctx->bytecode, &insn, 1, sizeof(insn)); } @@ -87,7 +87,7 @@ int append_str(char **s, const char *append) */ static int load_expression_legacy_match(const struct ir_load_expression *exp, - enum filter_op *op_type, + enum bytecode_op *op_type, char **symbol) { const struct ir_load_expression_op *op; @@ -96,21 +96,21 @@ int load_expression_legacy_match(const struct ir_load_expression *exp, op = exp->child; switch (op->type) { case IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT: - *op_type = FILTER_OP_GET_CONTEXT_REF; + *op_type = BYTECODE_OP_GET_CONTEXT_REF; if (append_str(symbol, "$ctx.")) { return -ENOMEM; } need_dot = false; break; case IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT: - *op_type = FILTER_OP_GET_CONTEXT_REF; + *op_type = BYTECODE_OP_GET_CONTEXT_REF; if (append_str(symbol, "$app.")) { return -ENOMEM; } need_dot = false; break; case IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT: - *op_type = FILTER_OP_LOAD_FIELD_REF; + *op_type = BYTECODE_OP_LOAD_FIELD_REF; need_dot = false; break; @@ -162,7 +162,7 @@ int visit_node_load_expression_legacy(struct filter_parser_ctx *ctx, struct field_ref ref_offset; uint32_t reloc_offset_u32; uint16_t reloc_offset; - enum filter_op op_type; + enum bytecode_op op_type; char *symbol = NULL; int ret; @@ -247,7 +247,7 @@ int visit_node_load_expression(struct filter_parser_ctx *ctx, insn = calloc(insn_len, 1); if (!insn) return -ENOMEM; - insn->op = FILTER_OP_GET_CONTEXT_ROOT; + insn->op = BYTECODE_OP_GET_CONTEXT_ROOT; ret = bytecode_push(&ctx->bytecode, insn, 1, insn_len); free(insn); if (ret) { @@ -264,7 +264,7 @@ int visit_node_load_expression(struct filter_parser_ctx *ctx, insn = calloc(insn_len, 1); if (!insn) return -ENOMEM; - insn->op = FILTER_OP_GET_APP_CONTEXT_ROOT; + insn->op = BYTECODE_OP_GET_APP_CONTEXT_ROOT; ret = bytecode_push(&ctx->bytecode, insn, 1, insn_len); free(insn); if (ret) { @@ -281,7 +281,7 @@ int visit_node_load_expression(struct filter_parser_ctx *ctx, insn = calloc(insn_len, 1); if (!insn) return -ENOMEM; - insn->op = FILTER_OP_GET_PAYLOAD_ROOT; + insn->op = BYTECODE_OP_GET_PAYLOAD_ROOT; ret = bytecode_push(&ctx->bytecode, insn, 1, insn_len); free(insn); if (ret) { @@ -303,7 +303,7 @@ int visit_node_load_expression(struct filter_parser_ctx *ctx, insn = calloc(insn_len, 1); if (!insn) return -ENOMEM; - insn->op = FILTER_OP_GET_SYMBOL; + insn->op = BYTECODE_OP_GET_SYMBOL; bytecode_reloc_offset_u32 = bytecode_get_len(&ctx->bytecode_reloc->b) + sizeof(reloc_offset); @@ -350,7 +350,7 @@ int visit_node_load_expression(struct filter_parser_ctx *ctx, insn = calloc(insn_len, 1); if (!insn) return -ENOMEM; - insn->op = FILTER_OP_GET_INDEX_U64; + insn->op = BYTECODE_OP_GET_INDEX_U64; index.index = op->u.index; memcpy(insn->data, &index, sizeof(index)); ret = bytecode_push(&ctx->bytecode, insn, 1, insn_len); @@ -369,7 +369,7 @@ int visit_node_load_expression(struct filter_parser_ctx *ctx, insn = calloc(insn_len, 1); if (!insn) return -ENOMEM; - insn->op = FILTER_OP_LOAD_FIELD; + insn->op = BYTECODE_OP_LOAD_FIELD; ret = bytecode_push(&ctx->bytecode, insn, 1, insn_len); free(insn); if (ret) { @@ -412,7 +412,7 @@ int visit_node_load(struct filter_parser_ctx *ctx, struct ir_op *node) * that the appropriate matching function can be * called. Also, see comment below. */ - insn->op = FILTER_OP_LOAD_STAR_GLOB_STRING; + insn->op = BYTECODE_OP_LOAD_STAR_GLOB_STRING; break; default: /* @@ -425,7 +425,7 @@ int visit_node_load(struct filter_parser_ctx *ctx, struct ir_op *node) * can be anywhere in the string) is a special * case. */ - insn->op = FILTER_OP_LOAD_STRING; + insn->op = BYTECODE_OP_LOAD_STRING; break; } @@ -443,7 +443,7 @@ int visit_node_load(struct filter_parser_ctx *ctx, struct ir_op *node) insn = calloc(insn_len, 1); if (!insn) return -ENOMEM; - insn->op = FILTER_OP_LOAD_S64; + insn->op = BYTECODE_OP_LOAD_S64; memcpy(insn->data, &node->u.load.u.num, sizeof(int64_t)); ret = bytecode_push(&ctx->bytecode, insn, 1, insn_len); free(insn); @@ -458,7 +458,7 @@ int visit_node_load(struct filter_parser_ctx *ctx, struct ir_op *node) insn = calloc(insn_len, 1); if (!insn) return -ENOMEM; - insn->op = FILTER_OP_LOAD_DOUBLE; + insn->op = BYTECODE_OP_LOAD_DOUBLE; memcpy(insn->data, &node->u.load.u.flt, sizeof(double)); ret = bytecode_push(&ctx->bytecode, insn, 1, insn_len); free(insn); @@ -491,13 +491,13 @@ int visit_node_unary(struct filter_parser_ctx *ctx, struct ir_op *node) /* Nothing to do. */ return 0; case AST_UNARY_MINUS: - insn.op = FILTER_OP_UNARY_MINUS; + insn.op = BYTECODE_OP_UNARY_MINUS; return bytecode_push(&ctx->bytecode, &insn, 1, sizeof(insn)); case AST_UNARY_NOT: - insn.op = FILTER_OP_UNARY_NOT; + insn.op = BYTECODE_OP_UNARY_NOT; return bytecode_push(&ctx->bytecode, &insn, 1, sizeof(insn)); case AST_UNARY_BIT_NOT: - insn.op = FILTER_OP_UNARY_BIT_NOT; + insn.op = BYTECODE_OP_UNARY_BIT_NOT; return bytecode_push(&ctx->bytecode, &insn, 1, sizeof(insn)); } } @@ -534,53 +534,53 @@ int visit_node_binary(struct filter_parser_ctx *ctx, struct ir_op *node) return -EINVAL; case AST_OP_MUL: - insn.op = FILTER_OP_MUL; + insn.op = BYTECODE_OP_MUL; break; case AST_OP_DIV: - insn.op = FILTER_OP_DIV; + insn.op = BYTECODE_OP_DIV; break; case AST_OP_MOD: - insn.op = FILTER_OP_MOD; + insn.op = BYTECODE_OP_MOD; break; case AST_OP_PLUS: - insn.op = FILTER_OP_PLUS; + insn.op = BYTECODE_OP_PLUS; break; case AST_OP_MINUS: - insn.op = FILTER_OP_MINUS; + insn.op = BYTECODE_OP_MINUS; break; case AST_OP_BIT_RSHIFT: - insn.op = FILTER_OP_BIT_RSHIFT; + insn.op = BYTECODE_OP_BIT_RSHIFT; break; case AST_OP_BIT_LSHIFT: - insn.op = FILTER_OP_BIT_LSHIFT; + insn.op = BYTECODE_OP_BIT_LSHIFT; break; case AST_OP_BIT_AND: - insn.op = FILTER_OP_BIT_AND; + insn.op = BYTECODE_OP_BIT_AND; break; case AST_OP_BIT_OR: - insn.op = FILTER_OP_BIT_OR; + insn.op = BYTECODE_OP_BIT_OR; break; case AST_OP_BIT_XOR: - insn.op = FILTER_OP_BIT_XOR; + insn.op = BYTECODE_OP_BIT_XOR; break; case AST_OP_EQ: - insn.op = FILTER_OP_EQ; + insn.op = BYTECODE_OP_EQ; break; case AST_OP_NE: - insn.op = FILTER_OP_NE; + insn.op = BYTECODE_OP_NE; break; case AST_OP_GT: - insn.op = FILTER_OP_GT; + insn.op = BYTECODE_OP_GT; break; case AST_OP_LT: - insn.op = FILTER_OP_LT; + insn.op = BYTECODE_OP_LT; break; case AST_OP_GE: - insn.op = FILTER_OP_GE; + insn.op = BYTECODE_OP_GE; break; case AST_OP_LE: - insn.op = FILTER_OP_LE; + insn.op = BYTECODE_OP_LE; break; } return bytecode_push(&ctx->bytecode, &insn, 1, sizeof(insn)); @@ -611,9 +611,9 @@ int visit_node_logical(struct filter_parser_ctx *ctx, struct ir_op *node) if (node->u.binary.left->data_type == IR_DATA_FIELD_REF || node->u.binary.left->data_type == IR_DATA_GET_CONTEXT_REF || node->u.binary.left->data_type == IR_DATA_EXPRESSION) { - cast_insn.op = FILTER_OP_CAST_TO_S64; + cast_insn.op = BYTECODE_OP_CAST_TO_S64; } else { - cast_insn.op = FILTER_OP_CAST_DOUBLE_TO_S64; + cast_insn.op = BYTECODE_OP_CAST_DOUBLE_TO_S64; } ret = bytecode_push(&ctx->bytecode, &cast_insn, 1, sizeof(cast_insn)); @@ -627,10 +627,10 @@ int visit_node_logical(struct filter_parser_ctx *ctx, struct ir_op *node) return -EINVAL; case AST_OP_AND: - insn.op = FILTER_OP_AND; + insn.op = BYTECODE_OP_AND; break; case AST_OP_OR: - insn.op = FILTER_OP_OR; + insn.op = BYTECODE_OP_OR; break; } insn.skip_offset = (uint16_t) -1UL; /* Temporary */ @@ -652,9 +652,9 @@ int visit_node_logical(struct filter_parser_ctx *ctx, struct ir_op *node) if (node->u.binary.right->data_type == IR_DATA_FIELD_REF || node->u.binary.right->data_type == IR_DATA_GET_CONTEXT_REF || node->u.binary.right->data_type == IR_DATA_EXPRESSION) { - cast_insn.op = FILTER_OP_CAST_TO_S64; + cast_insn.op = BYTECODE_OP_CAST_TO_S64; } else { - cast_insn.op = FILTER_OP_CAST_DOUBLE_TO_S64; + cast_insn.op = BYTECODE_OP_CAST_DOUBLE_TO_S64; } ret = bytecode_push(&ctx->bytecode, &cast_insn, 1, sizeof(cast_insn)); diff --git a/src/common/kernel-ctl/kernel-ctl.c b/src/common/kernel-ctl/kernel-ctl.c index f5efaf328..bb6602e2b 100644 --- a/src/common/kernel-ctl/kernel-ctl.c +++ b/src/common/kernel-ctl/kernel-ctl.c @@ -437,7 +437,7 @@ int kernctl_create_event_notifier(int group_fd, LTTNG_KERNEL_EVENT_NOTIFIER_CREATE, event_notifier); } -int kernctl_filter(int fd, const struct lttng_filter_bytecode *filter) +int kernctl_filter(int fd, const struct lttng_bytecode *filter) { struct lttng_kernel_filter_bytecode *kb; uint32_t len; diff --git a/src/common/kernel-ctl/kernel-ctl.h b/src/common/kernel-ctl/kernel-ctl.h index 5668468e6..3bbe69f48 100644 --- a/src/common/kernel-ctl/kernel-ctl.h +++ b/src/common/kernel-ctl/kernel-ctl.h @@ -36,7 +36,7 @@ int kernctl_create_event_notifier(int fd, const struct lttng_kernel_event_notifier *event_notifier); /* Apply on event file descriptor. */ -int kernctl_filter(int fd, const struct lttng_filter_bytecode *filter); +int kernctl_filter(int fd, const struct lttng_bytecode *filter); int kernctl_add_callsite(int fd, struct lttng_kernel_event_callsite *callsite); int kernctl_tracepoint_list(int fd); diff --git a/src/common/runas.c b/src/common/runas.c index 21c1a91ad..09fdaf40a 100644 --- a/src/common/runas.c +++ b/src/common/runas.c @@ -1800,13 +1800,13 @@ error: LTTNG_HIDDEN int run_as_generate_filter_bytecode(const char *filter_expression, const struct lttng_credentials *creds, - struct lttng_filter_bytecode **bytecode) + struct lttng_bytecode **bytecode) { int ret; struct run_as_data data = {}; struct run_as_ret run_as_ret = {}; - const struct lttng_filter_bytecode *view_bytecode = NULL; - struct lttng_filter_bytecode *local_bytecode = NULL; + const struct lttng_bytecode *view_bytecode = NULL; + struct lttng_bytecode *local_bytecode = NULL; const uid_t uid = lttng_credentials_get_uid(creds); const gid_t gid = lttng_credentials_get_gid(creds); @@ -1826,7 +1826,7 @@ int run_as_generate_filter_bytecode(const char *filter_expression, goto error; } - view_bytecode = (const struct lttng_filter_bytecode *) run_as_ret.u.generate_filter_bytecode.bytecode; + view_bytecode = (const struct lttng_bytecode *) run_as_ret.u.generate_filter_bytecode.bytecode; local_bytecode = zmalloc(sizeof(*local_bytecode) + view_bytecode->len); if (!local_bytecode) { diff --git a/src/common/runas.h b/src/common/runas.h index 40b4f91b0..18a053a05 100644 --- a/src/common/runas.h +++ b/src/common/runas.h @@ -73,7 +73,7 @@ int run_as_extract_sdt_probe_offsets(int fd, const char *provider_name, LTTNG_HIDDEN int run_as_generate_filter_bytecode(const char *filter_expression, const struct lttng_credentials *creds, - struct lttng_filter_bytecode **bytecode); + struct lttng_bytecode **bytecode); LTTNG_HIDDEN int run_as_create_worker(const char *procname, post_fork_cleanup_cb clean_up_func, void *clean_up_user_data); diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index d946aa3a3..4c1ba5cce 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -522,7 +522,7 @@ struct lttcomm_session_msg { * starts at reloc_table_offset. */ #define LTTNG_FILTER_PADDING 32 -struct lttng_filter_bytecode { +struct lttng_bytecode { uint32_t len; /* len of data */ uint32_t reloc_table_offset; uint64_t seqnum; -- 2.34.1