Refactoring: add back constness of public API structures
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 5 Apr 2021 12:32:11 +0000 (08:32 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 6 Apr 2021 17:29:28 +0000 (13:29 -0400)
commit4e48b5d2debaf6c0c598489c183cc6cb2125c8a3
tree754f1ac6b39c029cfe40052dd0258a223edd6a2a
parent5152f6df156d6ccb234965d1b3d26b167bd6b94e
Refactoring: add back constness of public API structures

Probes defining type, enumeration label, enumeration description,
event, and probe structures should be able to define them as "const",
because those are indeed const data which never need to be changed by
the tracer.

In order to allow struct lttng_ust_probe_desc definition to be constant,
move the "head", "lazy_init_head" and "lazy" fields to an internal
structure, "struct lttng_ust_registered_probe". It is opaque from the
point of view of the probe provider, but its pointer is now used as a
cookie between registration and unregistration. Moving the list heads
into an internal structure is an overall cleanup hiding private data
from the public API.

Use a similar scheme for registration of the context provider:
internalize the "hlist" field into an internal registration structure
(opaque from the point of view of the public API), which is now used as
a cookie between registration and unregistration.

This allows to fix an issue which was introduced by a prior refactoring
of the code dealing with contexts: the RCU update of context callbacks
was broken because the context fields were shared between the old and
the new array of contexts, thus leading to non-atomic update of the 3
callback pointers. This is fixed by making struct lttng_ust_ctx private,
and changing the array of pointers to context fields to an array of
context fields.

The functions lttng_ust_context_set_session_provider,
lttng_ust_add_app_context_to_ctx_rcu, and
lttng_ust_context_set_provider_rcu are now private.

For all contexts except the "perf" context fields, define the context
field as a static const variable rather than use memory allocation. This
means freeing the event field and type is not required anymore, and the
perf context field is handled through a destroy callback using the
private data pointer.

Move struct lttng_ust_ctx_field to an internal header. The only reason
why it was public is because the callbacks expected it as an argument.
Change the callbacks to receive a private data pointer instead to
achieve the same goal without exposing our internal structures.

The internal helpers lttng_ust_create_type_integer,
lttng_ust_create_type_array_text and lttng_ust_destroy_type are removed,
and replaced by internal macro helpers lttng_ust_static_type_integer,
lttng_ust_static_type_array_text, lttng_ust_static_event_field, and
lttng_ust_static_ctx_field, to facilitate static definitions in context
code.

Because there is no need to embed list and hlist nodes in the probe
descriptor nor the context provider, there is no need to include those
list headers from public APIs anymore.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I556e00d1d99a956b6f981dd2f5eae53589303f9d
45 files changed:
include/lttng/ust-events.h
include/lttng/ust-tracepoint-event.h
include/ust-comm.h
include/ust-context-provider.h
include/ust-dynamic-type.h
liblttng-ust-comm/lttng-ust-comm.c
liblttng-ust-java-agent/jni/common/lttng_ust_context.c
liblttng-ust/context-internal.h
liblttng-ust/context-provider-internal.h
liblttng-ust/event-notifier-notification.c
liblttng-ust/lttng-bytecode-interpreter.c
liblttng-ust/lttng-bytecode-specialize.c
liblttng-ust/lttng-bytecode.c
liblttng-ust/lttng-bytecode.h
liblttng-ust/lttng-context-cgroup-ns.c
liblttng-ust/lttng-context-cpu-id.c
liblttng-ust/lttng-context-ip.c
liblttng-ust/lttng-context-ipc-ns.c
liblttng-ust/lttng-context-mnt-ns.c
liblttng-ust/lttng-context-net-ns.c
liblttng-ust/lttng-context-perf-counters.c
liblttng-ust/lttng-context-pid-ns.c
liblttng-ust/lttng-context-procname.c
liblttng-ust/lttng-context-provider.c
liblttng-ust/lttng-context-pthread-id.c
liblttng-ust/lttng-context-time-ns.c
liblttng-ust/lttng-context-user-ns.c
liblttng-ust/lttng-context-uts-ns.c
liblttng-ust/lttng-context-vegid.c
liblttng-ust/lttng-context-veuid.c
liblttng-ust/lttng-context-vgid.c
liblttng-ust/lttng-context-vpid.c
liblttng-ust/lttng-context-vsgid.c
liblttng-ust/lttng-context-vsuid.c
liblttng-ust/lttng-context-vtid.c
liblttng-ust/lttng-context-vuid.c
liblttng-ust/lttng-context.c
liblttng-ust/lttng-events.c
liblttng-ust/lttng-probes.c
liblttng-ust/lttng-ring-buffer-client-template.h
liblttng-ust/lttng-tracer-core.h
liblttng-ust/lttng-ust-dynamic-type.c
liblttng-ust/ust-core.c
liblttng-ust/ust-events-internal.h
tests/compile/test-app-ctx/hello.c
This page took 0.029067 seconds and 4 git commands to generate.