int lttng_attach_context(struct lttng_ust_context *context_param,
struct lttng_ctx **ctx, struct lttng_session *session);
+void lttng_context_init(void);
+void lttng_context_exit(void);
+struct lttng_ctx *lttng_static_ctx; /* Used by filtering */
void lttng_transport_register(struct lttng_transport *transport);
void lttng_transport_unregister(struct lttng_transport *transport);
#include <lttng/ust-events.h>
#include <lttng/ust-tracer.h>
+#include <usterr-signal-safe.h>
#include <helper.h>
#include <string.h>
#include <assert.h>
* same context performed by the same thread return the same result.
*/
+/*
+ * Static array of contexts, for $ctx filters.
+ */
+struct lttng_ctx *lttng_static_ctx;
+
int lttng_find_context(struct lttng_ctx *ctx, const char *name)
{
unsigned int i;
free(ctx->fields);
free(ctx);
}
+
+void lttng_context_init(void)
+{
+ int ret;
+
+ ret = lttng_add_pthread_id_to_ctx(<tng_static_ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_pthread_id_to_ctx");
+ }
+ ret = lttng_add_vtid_to_ctx(<tng_static_ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_vtid_to_ctx");
+ }
+ ret = lttng_add_vpid_to_ctx(<tng_static_ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_vpid_to_ctx");
+ }
+ ret = lttng_add_procname_to_ctx(<tng_static_ctx);
+ if (ret) {
+ WARN("Cannot add context lttng_add_procname_to_ctx");
+ }
+}
+
+void lttng_context_exit(void)
+{
+ lttng_destroy_context(lttng_static_ctx);
+ lttng_static_ctx = NULL;
+}
const char *filter_stack_data)
{
struct bytecode_runtime *bytecode = filter_data;
- struct lttng_ctx *ctx = bytecode->p.bc->enabler->chan->ctx;
void *pc, *next_pc, *start_pc;
int ret = -EINVAL;
uint64_t retval = 0;
dbg_printf("get context ref offset %u type string\n",
ref->offset);
- ctx_field = &ctx->fields[ref->offset];
+ ctx_field = <tng_static_ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx);
estack_ax(stack, top)->u.s.str = v.str;
dbg_printf("get context ref offset %u type s64\n",
ref->offset);
- ctx_field = &ctx->fields[ref->offset];
+ ctx_field = <tng_static_ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx);
estack_ax_v = v.s64;
dbg_printf("get context ref offset %u type double\n",
ref->offset);
- ctx_field = &ctx->fields[ref->offset];
+ ctx_field = <tng_static_ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx);
memcpy(&estack_ax(stack, top)->u.d, &v.d, sizeof(struct literal_double));
dbg_printf("Apply context reloc: %u %s\n", reloc_offset, context_name);
/* Get context index */
- idx = lttng_get_context_index(event->chan->ctx, context_name);
+ idx = lttng_get_context_index(lttng_static_ctx, context_name);
if (idx < 0)
return -ENOENT;
return -EINVAL;
/* Get context return type */
- ctx_field = &event->chan->ctx->fields[idx];
+ ctx_field = <tng_static_ctx->fields[idx];
op = (struct load_op *) &runtime->data[reloc_offset];
field_ref = (struct field_ref *) op->data;
switch (ctx_field->event_field.type.atype) {
lttng_ring_buffer_client_overwrite_rt_init();
lttng_ring_buffer_client_discard_init();
lttng_ring_buffer_client_discard_rt_init();
+ lttng_context_init();
timeout_mode = get_constructor_timeout(&constructor_timeout);
*/
lttng_ust_abi_exit();
lttng_ust_events_exit();
+ lttng_context_exit();
lttng_ring_buffer_client_discard_rt_exit();
lttng_ring_buffer_client_discard_exit();
lttng_ring_buffer_client_overwrite_rt_exit();