Rename C++ header files to .hpp
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 15 Dec 2021 20:13:05 +0000 (15:13 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 30 Mar 2022 02:40:17 +0000 (22:40 -0400)
Rename all C++ header files (include/**/*-internal.h, src/**/*.h except
argpar and msgpack, some headers in tests) to have the .hpp extension.

Doing so highlights that we include some C++ header files in some test
files still compiled as C. This is ok for now, as the files they include
don't actually contain C++ code incompatible with C yet, but they could
eventually. This is something we can fix later.

Change-Id: I8bf326b6b2946a3e26704f3ef3ac5831bbe9bc26
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
755 files changed:
doc/examples/trigger-condition-event-matches/notification-client.cpp
include/Makefile.am
include/lttng/action/action-internal.h [deleted file]
include/lttng/action/action-internal.hpp [new file with mode: 0644]
include/lttng/action/list-internal.h [deleted file]
include/lttng/action/list-internal.hpp [new file with mode: 0644]
include/lttng/action/notify-internal.h [deleted file]
include/lttng/action/notify-internal.hpp [new file with mode: 0644]
include/lttng/action/path-internal.h [deleted file]
include/lttng/action/path-internal.hpp [new file with mode: 0644]
include/lttng/action/rate-policy-internal.h [deleted file]
include/lttng/action/rate-policy-internal.hpp [new file with mode: 0644]
include/lttng/action/rotate-session-internal.h [deleted file]
include/lttng/action/rotate-session-internal.hpp [new file with mode: 0644]
include/lttng/action/snapshot-session-internal.h [deleted file]
include/lttng/action/snapshot-session-internal.hpp [new file with mode: 0644]
include/lttng/action/start-session-internal.h [deleted file]
include/lttng/action/start-session-internal.hpp [new file with mode: 0644]
include/lttng/action/stop-session-internal.h [deleted file]
include/lttng/action/stop-session-internal.hpp [new file with mode: 0644]
include/lttng/channel-internal.h [deleted file]
include/lttng/channel-internal.hpp [new file with mode: 0644]
include/lttng/condition/buffer-usage-internal.h [deleted file]
include/lttng/condition/buffer-usage-internal.hpp [new file with mode: 0644]
include/lttng/condition/condition-internal.h [deleted file]
include/lttng/condition/condition-internal.hpp [new file with mode: 0644]
include/lttng/condition/evaluation-internal.h [deleted file]
include/lttng/condition/evaluation-internal.hpp [new file with mode: 0644]
include/lttng/condition/event-rule-matches-internal.h [deleted file]
include/lttng/condition/event-rule-matches-internal.hpp [new file with mode: 0644]
include/lttng/condition/session-consumed-size-internal.h [deleted file]
include/lttng/condition/session-consumed-size-internal.hpp [new file with mode: 0644]
include/lttng/condition/session-rotation-internal.h [deleted file]
include/lttng/condition/session-rotation-internal.hpp [new file with mode: 0644]
include/lttng/domain-internal.h [deleted file]
include/lttng/domain-internal.hpp [new file with mode: 0644]
include/lttng/endpoint-internal.h [deleted file]
include/lttng/endpoint-internal.hpp [new file with mode: 0644]
include/lttng/error-query-internal.h [deleted file]
include/lttng/error-query-internal.hpp [new file with mode: 0644]
include/lttng/event-expr-internal.h [deleted file]
include/lttng/event-expr-internal.hpp [new file with mode: 0644]
include/lttng/event-field-value-internal.h [deleted file]
include/lttng/event-field-value-internal.hpp [new file with mode: 0644]
include/lttng/event-internal.h [deleted file]
include/lttng/event-internal.hpp [new file with mode: 0644]
include/lttng/event-rule/event-rule-internal.h [deleted file]
include/lttng/event-rule/event-rule-internal.hpp [new file with mode: 0644]
include/lttng/event-rule/jul-logging-internal.h [deleted file]
include/lttng/event-rule/jul-logging-internal.hpp [new file with mode: 0644]
include/lttng/event-rule/kernel-kprobe-internal.h [deleted file]
include/lttng/event-rule/kernel-kprobe-internal.hpp [new file with mode: 0644]
include/lttng/event-rule/kernel-syscall-internal.h [deleted file]
include/lttng/event-rule/kernel-syscall-internal.hpp [new file with mode: 0644]
include/lttng/event-rule/kernel-tracepoint-internal.h [deleted file]
include/lttng/event-rule/kernel-tracepoint-internal.hpp [new file with mode: 0644]
include/lttng/event-rule/kernel-uprobe-internal.h [deleted file]
include/lttng/event-rule/kernel-uprobe-internal.hpp [new file with mode: 0644]
include/lttng/event-rule/log4j-logging-internal.h [deleted file]
include/lttng/event-rule/log4j-logging-internal.hpp [new file with mode: 0644]
include/lttng/event-rule/python-logging-internal.h [deleted file]
include/lttng/event-rule/python-logging-internal.hpp [new file with mode: 0644]
include/lttng/event-rule/user-tracepoint-internal.h [deleted file]
include/lttng/event-rule/user-tracepoint-internal.hpp [new file with mode: 0644]
include/lttng/health-internal.h [deleted file]
include/lttng/health-internal.hpp [new file with mode: 0644]
include/lttng/kernel-probe-internal.h [deleted file]
include/lttng/kernel-probe-internal.hpp [new file with mode: 0644]
include/lttng/load-internal.h [deleted file]
include/lttng/load-internal.hpp [new file with mode: 0644]
include/lttng/location-internal.h [deleted file]
include/lttng/location-internal.hpp [new file with mode: 0644]
include/lttng/log-level-rule-internal.h [deleted file]
include/lttng/log-level-rule-internal.hpp [new file with mode: 0644]
include/lttng/notification/channel-internal.h [deleted file]
include/lttng/notification/channel-internal.hpp [new file with mode: 0644]
include/lttng/notification/notification-internal.h [deleted file]
include/lttng/notification/notification-internal.hpp [new file with mode: 0644]
include/lttng/ref-internal.h [deleted file]
include/lttng/ref-internal.hpp [new file with mode: 0644]
include/lttng/rotate-internal.h [deleted file]
include/lttng/rotate-internal.hpp [new file with mode: 0644]
include/lttng/save-internal.h [deleted file]
include/lttng/save-internal.hpp [new file with mode: 0644]
include/lttng/session-descriptor-internal.h [deleted file]
include/lttng/session-descriptor-internal.hpp [new file with mode: 0644]
include/lttng/session-internal.h [deleted file]
include/lttng/session-internal.hpp [new file with mode: 0644]
include/lttng/snapshot-internal.h [deleted file]
include/lttng/snapshot-internal.hpp [new file with mode: 0644]
include/lttng/trigger/trigger-internal.h [deleted file]
include/lttng/trigger/trigger-internal.hpp [new file with mode: 0644]
include/lttng/userspace-probe-internal.h [deleted file]
include/lttng/userspace-probe-internal.hpp [new file with mode: 0644]
include/version.h [deleted file]
include/version.hpp [new file with mode: 0644]
src/bin/lttng-consumerd/Makefile.am
src/bin/lttng-consumerd/health-consumerd.cpp
src/bin/lttng-consumerd/health-consumerd.h [deleted file]
src/bin/lttng-consumerd/health-consumerd.hpp [new file with mode: 0644]
src/bin/lttng-consumerd/lttng-consumerd.cpp
src/bin/lttng-consumerd/lttng-consumerd.h [deleted file]
src/bin/lttng-consumerd/lttng-consumerd.hpp [new file with mode: 0644]
src/bin/lttng-consumerd/testpoint.h [deleted file]
src/bin/lttng-consumerd/testpoint.hpp [new file with mode: 0644]
src/bin/lttng-crash/lttng-crash.cpp
src/bin/lttng-relayd/Makefile.am
src/bin/lttng-relayd/backward-compatibility-group-by.cpp
src/bin/lttng-relayd/backward-compatibility-group-by.h [deleted file]
src/bin/lttng-relayd/backward-compatibility-group-by.hpp [new file with mode: 0644]
src/bin/lttng-relayd/cmd-2-1.cpp
src/bin/lttng-relayd/cmd-2-1.h [deleted file]
src/bin/lttng-relayd/cmd-2-1.hpp [new file with mode: 0644]
src/bin/lttng-relayd/cmd-2-11.cpp
src/bin/lttng-relayd/cmd-2-11.h [deleted file]
src/bin/lttng-relayd/cmd-2-11.hpp [new file with mode: 0644]
src/bin/lttng-relayd/cmd-2-2.cpp
src/bin/lttng-relayd/cmd-2-2.h [deleted file]
src/bin/lttng-relayd/cmd-2-2.hpp [new file with mode: 0644]
src/bin/lttng-relayd/cmd-2-4.cpp
src/bin/lttng-relayd/cmd-2-4.h [deleted file]
src/bin/lttng-relayd/cmd-2-4.hpp [new file with mode: 0644]
src/bin/lttng-relayd/cmd.h [deleted file]
src/bin/lttng-relayd/cmd.hpp [new file with mode: 0644]
src/bin/lttng-relayd/connection.cpp
src/bin/lttng-relayd/connection.h [deleted file]
src/bin/lttng-relayd/connection.hpp [new file with mode: 0644]
src/bin/lttng-relayd/ctf-trace.cpp
src/bin/lttng-relayd/ctf-trace.h [deleted file]
src/bin/lttng-relayd/ctf-trace.hpp [new file with mode: 0644]
src/bin/lttng-relayd/health-relayd.cpp
src/bin/lttng-relayd/health-relayd.h [deleted file]
src/bin/lttng-relayd/health-relayd.hpp [new file with mode: 0644]
src/bin/lttng-relayd/index.cpp
src/bin/lttng-relayd/index.h [deleted file]
src/bin/lttng-relayd/index.hpp [new file with mode: 0644]
src/bin/lttng-relayd/live.cpp
src/bin/lttng-relayd/live.h [deleted file]
src/bin/lttng-relayd/live.hpp [new file with mode: 0644]
src/bin/lttng-relayd/lttng-relayd.h [deleted file]
src/bin/lttng-relayd/lttng-relayd.hpp [new file with mode: 0644]
src/bin/lttng-relayd/lttng-viewer-abi.h [deleted file]
src/bin/lttng-relayd/lttng-viewer-abi.hpp [new file with mode: 0644]
src/bin/lttng-relayd/main.cpp
src/bin/lttng-relayd/session.cpp
src/bin/lttng-relayd/session.h [deleted file]
src/bin/lttng-relayd/session.hpp [new file with mode: 0644]
src/bin/lttng-relayd/sessiond-trace-chunks.cpp
src/bin/lttng-relayd/sessiond-trace-chunks.h [deleted file]
src/bin/lttng-relayd/sessiond-trace-chunks.hpp [new file with mode: 0644]
src/bin/lttng-relayd/stream.cpp
src/bin/lttng-relayd/stream.h [deleted file]
src/bin/lttng-relayd/stream.hpp [new file with mode: 0644]
src/bin/lttng-relayd/tcp_keep_alive.cpp
src/bin/lttng-relayd/tcp_keep_alive.h [deleted file]
src/bin/lttng-relayd/tcp_keep_alive.hpp [new file with mode: 0644]
src/bin/lttng-relayd/testpoint.h [deleted file]
src/bin/lttng-relayd/testpoint.hpp [new file with mode: 0644]
src/bin/lttng-relayd/tracefile-array.cpp
src/bin/lttng-relayd/tracefile-array.h [deleted file]
src/bin/lttng-relayd/tracefile-array.hpp [new file with mode: 0644]
src/bin/lttng-relayd/utils.cpp
src/bin/lttng-relayd/utils.h [deleted file]
src/bin/lttng-relayd/utils.hpp [new file with mode: 0644]
src/bin/lttng-relayd/viewer-session.cpp
src/bin/lttng-relayd/viewer-session.h [deleted file]
src/bin/lttng-relayd/viewer-session.hpp [new file with mode: 0644]
src/bin/lttng-relayd/viewer-stream.cpp
src/bin/lttng-relayd/viewer-stream.h [deleted file]
src/bin/lttng-relayd/viewer-stream.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/Makefile.am
src/bin/lttng-sessiond/action-executor.cpp
src/bin/lttng-sessiond/action-executor.h [deleted file]
src/bin/lttng-sessiond/action-executor.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/agent-thread.cpp
src/bin/lttng-sessiond/agent-thread.h [deleted file]
src/bin/lttng-sessiond/agent-thread.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/agent.cpp
src/bin/lttng-sessiond/agent.h [deleted file]
src/bin/lttng-sessiond/agent.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/buffer-registry.cpp
src/bin/lttng-sessiond/buffer-registry.h [deleted file]
src/bin/lttng-sessiond/buffer-registry.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/channel.cpp
src/bin/lttng-sessiond/channel.h [deleted file]
src/bin/lttng-sessiond/channel.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/clear.cpp
src/bin/lttng-sessiond/clear.h [deleted file]
src/bin/lttng-sessiond/clear.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/client.cpp
src/bin/lttng-sessiond/client.h [deleted file]
src/bin/lttng-sessiond/client.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/cmd.cpp
src/bin/lttng-sessiond/cmd.h [deleted file]
src/bin/lttng-sessiond/cmd.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/condition-internal.cpp
src/bin/lttng-sessiond/condition-internal.h [deleted file]
src/bin/lttng-sessiond/condition-internal.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/consumer.cpp
src/bin/lttng-sessiond/consumer.h [deleted file]
src/bin/lttng-sessiond/consumer.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/context.cpp
src/bin/lttng-sessiond/context.h [deleted file]
src/bin/lttng-sessiond/context.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/dispatch.cpp
src/bin/lttng-sessiond/dispatch.h [deleted file]
src/bin/lttng-sessiond/dispatch.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/event-notifier-error-accounting.cpp
src/bin/lttng-sessiond/event-notifier-error-accounting.h [deleted file]
src/bin/lttng-sessiond/event-notifier-error-accounting.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/event.cpp
src/bin/lttng-sessiond/event.h [deleted file]
src/bin/lttng-sessiond/event.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/fd-limit.cpp
src/bin/lttng-sessiond/fd-limit.h [deleted file]
src/bin/lttng-sessiond/fd-limit.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/globals.cpp
src/bin/lttng-sessiond/health-sessiond.h [deleted file]
src/bin/lttng-sessiond/health-sessiond.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/health.cpp
src/bin/lttng-sessiond/kern-modules.h [deleted file]
src/bin/lttng-sessiond/kern-modules.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/kernel-consumer.cpp
src/bin/lttng-sessiond/kernel-consumer.h [deleted file]
src/bin/lttng-sessiond/kernel-consumer.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/kernel.cpp
src/bin/lttng-sessiond/kernel.h [deleted file]
src/bin/lttng-sessiond/kernel.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/lttng-sessiond.h [deleted file]
src/bin/lttng-sessiond/lttng-sessiond.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/lttng-syscall.cpp
src/bin/lttng-sessiond/lttng-syscall.h [deleted file]
src/bin/lttng-sessiond/lttng-syscall.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/lttng-ust-abi.h [deleted file]
src/bin/lttng-sessiond/lttng-ust-abi.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/lttng-ust-ctl.h [deleted file]
src/bin/lttng-sessiond/lttng-ust-ctl.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/lttng-ust-error.h [deleted file]
src/bin/lttng-sessiond/lttng-ust-error.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/main.cpp
src/bin/lttng-sessiond/manage-apps.cpp
src/bin/lttng-sessiond/manage-apps.h [deleted file]
src/bin/lttng-sessiond/manage-apps.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/manage-consumer.cpp
src/bin/lttng-sessiond/manage-consumer.h [deleted file]
src/bin/lttng-sessiond/manage-consumer.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/manage-kernel.cpp
src/bin/lttng-sessiond/manage-kernel.h [deleted file]
src/bin/lttng-sessiond/manage-kernel.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/modprobe.cpp
src/bin/lttng-sessiond/modprobe.h [deleted file]
src/bin/lttng-sessiond/modprobe.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/notification-thread-commands.cpp
src/bin/lttng-sessiond/notification-thread-commands.h [deleted file]
src/bin/lttng-sessiond/notification-thread-commands.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/notification-thread-events.cpp
src/bin/lttng-sessiond/notification-thread-events.h [deleted file]
src/bin/lttng-sessiond/notification-thread-events.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/notification-thread-internal.h [deleted file]
src/bin/lttng-sessiond/notification-thread-internal.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/notification-thread.cpp
src/bin/lttng-sessiond/notification-thread.h [deleted file]
src/bin/lttng-sessiond/notification-thread.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/notify-apps.cpp
src/bin/lttng-sessiond/notify-apps.h [deleted file]
src/bin/lttng-sessiond/notify-apps.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/process-utils.cpp
src/bin/lttng-sessiond/register.cpp
src/bin/lttng-sessiond/register.h [deleted file]
src/bin/lttng-sessiond/register.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/rotate.cpp
src/bin/lttng-sessiond/rotate.h [deleted file]
src/bin/lttng-sessiond/rotate.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/rotation-thread.cpp
src/bin/lttng-sessiond/rotation-thread.h [deleted file]
src/bin/lttng-sessiond/rotation-thread.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/save.cpp
src/bin/lttng-sessiond/save.h [deleted file]
src/bin/lttng-sessiond/save.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/session.cpp
src/bin/lttng-sessiond/session.h [deleted file]
src/bin/lttng-sessiond/session.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/sessiond-config.cpp
src/bin/lttng-sessiond/sessiond-config.h [deleted file]
src/bin/lttng-sessiond/sessiond-config.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/snapshot.cpp
src/bin/lttng-sessiond/snapshot.h [deleted file]
src/bin/lttng-sessiond/snapshot.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/testpoint.h [deleted file]
src/bin/lttng-sessiond/testpoint.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/thread-utils.cpp
src/bin/lttng-sessiond/thread.cpp
src/bin/lttng-sessiond/thread.h [deleted file]
src/bin/lttng-sessiond/thread.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/timer.cpp
src/bin/lttng-sessiond/timer.h [deleted file]
src/bin/lttng-sessiond/timer.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/trace-kernel.cpp
src/bin/lttng-sessiond/trace-kernel.h [deleted file]
src/bin/lttng-sessiond/trace-kernel.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/trace-ust.cpp
src/bin/lttng-sessiond/trace-ust.h [deleted file]
src/bin/lttng-sessiond/trace-ust.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/tracker.cpp
src/bin/lttng-sessiond/tracker.h [deleted file]
src/bin/lttng-sessiond/tracker.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/trigger-error-query.cpp
src/bin/lttng-sessiond/ust-abi-internal.h [deleted file]
src/bin/lttng-sessiond/ust-abi-internal.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/ust-app.cpp
src/bin/lttng-sessiond/ust-app.h [deleted file]
src/bin/lttng-sessiond/ust-app.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/ust-clock.h [deleted file]
src/bin/lttng-sessiond/ust-clock.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/ust-consumer.cpp
src/bin/lttng-sessiond/ust-consumer.h [deleted file]
src/bin/lttng-sessiond/ust-consumer.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/ust-ctl-internal.h [deleted file]
src/bin/lttng-sessiond/ust-ctl-internal.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/ust-error-internal.h [deleted file]
src/bin/lttng-sessiond/ust-error-internal.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/ust-field-utils.cpp
src/bin/lttng-sessiond/ust-field-utils.h [deleted file]
src/bin/lttng-sessiond/ust-field-utils.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/ust-metadata.cpp
src/bin/lttng-sessiond/ust-registry.cpp
src/bin/lttng-sessiond/ust-registry.h [deleted file]
src/bin/lttng-sessiond/ust-registry.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/ust-sigbus.cpp
src/bin/lttng-sessiond/ust-sigbus.h [deleted file]
src/bin/lttng-sessiond/ust-sigbus.hpp [new file with mode: 0644]
src/bin/lttng-sessiond/utils.cpp
src/bin/lttng-sessiond/utils.h [deleted file]
src/bin/lttng-sessiond/utils.hpp [new file with mode: 0644]
src/bin/lttng/Makefile.am
src/bin/lttng/command.h [deleted file]
src/bin/lttng/command.hpp [new file with mode: 0644]
src/bin/lttng/commands/add_context.cpp
src/bin/lttng/commands/add_trigger.cpp
src/bin/lttng/commands/clear.cpp
src/bin/lttng/commands/create.cpp
src/bin/lttng/commands/destroy.cpp
src/bin/lttng/commands/disable_channels.cpp
src/bin/lttng/commands/disable_events.cpp
src/bin/lttng/commands/disable_rotation.cpp
src/bin/lttng/commands/enable_channels.cpp
src/bin/lttng/commands/enable_events.cpp
src/bin/lttng/commands/enable_rotation.cpp
src/bin/lttng/commands/help.cpp
src/bin/lttng/commands/list.cpp
src/bin/lttng/commands/list_triggers.cpp
src/bin/lttng/commands/load.cpp
src/bin/lttng/commands/metadata.cpp
src/bin/lttng/commands/regenerate.cpp
src/bin/lttng/commands/remove_trigger.cpp
src/bin/lttng/commands/rotate.cpp
src/bin/lttng/commands/save.cpp
src/bin/lttng/commands/set_session.cpp
src/bin/lttng/commands/snapshot.cpp
src/bin/lttng/commands/start.cpp
src/bin/lttng/commands/status.cpp
src/bin/lttng/commands/stop.cpp
src/bin/lttng/commands/track-untrack.cpp
src/bin/lttng/commands/version.cpp
src/bin/lttng/commands/view.cpp
src/bin/lttng/conf.cpp
src/bin/lttng/conf.h [deleted file]
src/bin/lttng/conf.hpp [new file with mode: 0644]
src/bin/lttng/loglevel.cpp
src/bin/lttng/loglevel.h [deleted file]
src/bin/lttng/loglevel.hpp [new file with mode: 0644]
src/bin/lttng/lttng.cpp
src/bin/lttng/uprobe.cpp
src/bin/lttng/uprobe.h [deleted file]
src/bin/lttng/uprobe.hpp [new file with mode: 0644]
src/bin/lttng/utils.cpp
src/bin/lttng/utils.h [deleted file]
src/bin/lttng/utils.hpp [new file with mode: 0644]
src/common/Makefile.am
src/common/actions/action.cpp
src/common/actions/list.cpp
src/common/actions/notify.cpp
src/common/actions/path.cpp
src/common/actions/rate-policy.cpp
src/common/actions/rotate-session.cpp
src/common/actions/snapshot-session.cpp
src/common/actions/start-session.cpp
src/common/actions/stop-session.cpp
src/common/align.h [deleted file]
src/common/align.hpp [new file with mode: 0644]
src/common/argpar-utils/argpar-utils.cpp
src/common/argpar-utils/argpar-utils.h [deleted file]
src/common/argpar-utils/argpar-utils.hpp [new file with mode: 0644]
src/common/buffer-view.cpp
src/common/buffer-view.h [deleted file]
src/common/buffer-view.hpp [new file with mode: 0644]
src/common/bug.h [deleted file]
src/common/bug.hpp [new file with mode: 0644]
src/common/bytecode/bytecode.cpp
src/common/bytecode/bytecode.h [deleted file]
src/common/bytecode/bytecode.hpp [new file with mode: 0644]
src/common/channel.cpp
src/common/common.h [deleted file]
src/common/common.hpp [new file with mode: 0644]
src/common/compat/compat-fcntl.cpp
src/common/compat/directory-handle.cpp
src/common/compat/directory-handle.h [deleted file]
src/common/compat/directory-handle.hpp [new file with mode: 0644]
src/common/compat/dirent.h [deleted file]
src/common/compat/dirent.hpp [new file with mode: 0644]
src/common/compat/endian.h [deleted file]
src/common/compat/endian.hpp [new file with mode: 0644]
src/common/compat/errno.h [deleted file]
src/common/compat/errno.hpp [new file with mode: 0644]
src/common/compat/fcntl.h [deleted file]
src/common/compat/fcntl.hpp [new file with mode: 0644]
src/common/compat/getenv.h [deleted file]
src/common/compat/getenv.hpp [new file with mode: 0644]
src/common/compat/mman.h [deleted file]
src/common/compat/mman.hpp [new file with mode: 0644]
src/common/compat/netdb.h [deleted file]
src/common/compat/netdb.hpp [new file with mode: 0644]
src/common/compat/path.h [deleted file]
src/common/compat/path.hpp [new file with mode: 0644]
src/common/compat/paths.h [deleted file]
src/common/compat/paths.hpp [new file with mode: 0644]
src/common/compat/poll.cpp
src/common/compat/poll.h [deleted file]
src/common/compat/poll.hpp [new file with mode: 0644]
src/common/compat/pthread.h [deleted file]
src/common/compat/pthread.hpp [new file with mode: 0644]
src/common/compat/socket.h [deleted file]
src/common/compat/socket.hpp [new file with mode: 0644]
src/common/compat/string.h [deleted file]
src/common/compat/string.hpp [new file with mode: 0644]
src/common/compat/tid.h [deleted file]
src/common/compat/tid.hpp [new file with mode: 0644]
src/common/compat/time.h [deleted file]
src/common/compat/time.hpp [new file with mode: 0644]
src/common/conditions/buffer-usage.cpp
src/common/conditions/condition.cpp
src/common/conditions/event-rule-matches.cpp
src/common/conditions/session-consumed-size.cpp
src/common/conditions/session-rotation.cpp
src/common/config/config-internal.h [deleted file]
src/common/config/config-internal.hpp [new file with mode: 0644]
src/common/config/config-session-abi.h [deleted file]
src/common/config/config-session-abi.hpp [new file with mode: 0644]
src/common/config/session-config.cpp
src/common/config/session-config.h [deleted file]
src/common/config/session-config.hpp [new file with mode: 0644]
src/common/consumer/consumer-metadata-cache.cpp
src/common/consumer/consumer-metadata-cache.h [deleted file]
src/common/consumer/consumer-metadata-cache.hpp [new file with mode: 0644]
src/common/consumer/consumer-stream.cpp
src/common/consumer/consumer-stream.h [deleted file]
src/common/consumer/consumer-stream.hpp [new file with mode: 0644]
src/common/consumer/consumer-testpoint.h [deleted file]
src/common/consumer/consumer-testpoint.hpp [new file with mode: 0644]
src/common/consumer/consumer-timer.cpp
src/common/consumer/consumer-timer.h [deleted file]
src/common/consumer/consumer-timer.hpp [new file with mode: 0644]
src/common/consumer/consumer.cpp
src/common/consumer/consumer.h [deleted file]
src/common/consumer/consumer.hpp [new file with mode: 0644]
src/common/consumer/metadata-bucket.cpp
src/common/consumer/metadata-bucket.h [deleted file]
src/common/consumer/metadata-bucket.hpp [new file with mode: 0644]
src/common/context.cpp
src/common/context.h [deleted file]
src/common/context.hpp [new file with mode: 0644]
src/common/credentials.cpp
src/common/credentials.h [deleted file]
src/common/credentials.hpp [new file with mode: 0644]
src/common/daemonize.cpp
src/common/daemonize.h [deleted file]
src/common/daemonize.hpp [new file with mode: 0644]
src/common/defaults.cpp
src/common/defaults.h [deleted file]
src/common/defaults.hpp [new file with mode: 0644]
src/common/domain.cpp
src/common/dynamic-array.cpp
src/common/dynamic-array.h [deleted file]
src/common/dynamic-array.hpp [new file with mode: 0644]
src/common/dynamic-buffer.cpp
src/common/dynamic-buffer.h [deleted file]
src/common/dynamic-buffer.hpp [new file with mode: 0644]
src/common/endpoint.cpp
src/common/error-query.cpp
src/common/error.cpp
src/common/error.h [deleted file]
src/common/error.hpp [new file with mode: 0644]
src/common/evaluation.cpp
src/common/event-expr/event-expr.cpp
src/common/event-field-value.cpp
src/common/event-rule/event-rule.cpp
src/common/event-rule/jul-logging.cpp
src/common/event-rule/kernel-kprobe.cpp
src/common/event-rule/kernel-syscall.cpp
src/common/event-rule/kernel-tracepoint.cpp
src/common/event-rule/kernel-uprobe.cpp
src/common/event-rule/log4j-logging.cpp
src/common/event-rule/python-logging.cpp
src/common/event-rule/user-tracepoint.cpp
src/common/event.cpp
src/common/fd-handle.cpp
src/common/fd-handle.h [deleted file]
src/common/fd-handle.hpp [new file with mode: 0644]
src/common/fd-tracker/fd-tracker.cpp
src/common/fd-tracker/fd-tracker.h [deleted file]
src/common/fd-tracker/fd-tracker.hpp [new file with mode: 0644]
src/common/fd-tracker/inode.cpp
src/common/fd-tracker/inode.h [deleted file]
src/common/fd-tracker/inode.hpp [new file with mode: 0644]
src/common/fd-tracker/utils-poll.cpp
src/common/fd-tracker/utils.cpp
src/common/fd-tracker/utils.h [deleted file]
src/common/fd-tracker/utils.hpp [new file with mode: 0644]
src/common/filter-grammar-test.cpp
src/common/filter.cpp
src/common/filter.h [deleted file]
src/common/filter.hpp [new file with mode: 0644]
src/common/filter/filter-ast.h [deleted file]
src/common/filter/filter-ast.hpp [new file with mode: 0644]
src/common/filter/filter-ir.h [deleted file]
src/common/filter/filter-ir.hpp [new file with mode: 0644]
src/common/filter/filter-lexer.lpp
src/common/filter/filter-parser.ypp
src/common/filter/filter-symbols.h [deleted file]
src/common/filter/filter-symbols.hpp [new file with mode: 0644]
src/common/filter/filter-visitor-generate-bytecode.cpp
src/common/filter/filter-visitor-generate-ir.cpp
src/common/filter/filter-visitor-ir-check-binary-comparator.cpp
src/common/filter/filter-visitor-ir-check-binary-op-nesting.cpp
src/common/filter/filter-visitor-ir-normalize-glob-patterns.cpp
src/common/filter/filter-visitor-ir-validate-globbing.cpp
src/common/filter/filter-visitor-ir-validate-string.cpp
src/common/filter/filter-visitor-xml.cpp
src/common/filter/memstream.h [deleted file]
src/common/filter/memstream.hpp [new file with mode: 0644]
src/common/fs-handle-internal.h [deleted file]
src/common/fs-handle-internal.hpp [new file with mode: 0644]
src/common/fs-handle.cpp
src/common/fs-handle.h [deleted file]
src/common/fs-handle.hpp [new file with mode: 0644]
src/common/futex.cpp
src/common/futex.h [deleted file]
src/common/futex.hpp [new file with mode: 0644]
src/common/hashtable/hashtable-symbols.h [deleted file]
src/common/hashtable/hashtable-symbols.hpp [new file with mode: 0644]
src/common/hashtable/hashtable.cpp
src/common/hashtable/hashtable.h [deleted file]
src/common/hashtable/hashtable.hpp [new file with mode: 0644]
src/common/hashtable/seed.cpp
src/common/hashtable/utils.cpp
src/common/hashtable/utils.h [deleted file]
src/common/hashtable/utils.hpp [new file with mode: 0644]
src/common/health/health.cpp
src/common/index-allocator.cpp
src/common/index-allocator.h [deleted file]
src/common/index-allocator.hpp [new file with mode: 0644]
src/common/index/ctf-index.h [deleted file]
src/common/index/ctf-index.hpp [new file with mode: 0644]
src/common/index/index.cpp
src/common/index/index.h [deleted file]
src/common/index/index.hpp [new file with mode: 0644]
src/common/ini-config/ini-config.cpp
src/common/ini-config/ini-config.h [deleted file]
src/common/ini-config/ini-config.hpp [new file with mode: 0644]
src/common/ini-config/ini.cpp
src/common/ini-config/ini.h [deleted file]
src/common/ini-config/ini.hpp [new file with mode: 0644]
src/common/kernel-consumer/kernel-consumer.cpp
src/common/kernel-consumer/kernel-consumer.h [deleted file]
src/common/kernel-consumer/kernel-consumer.hpp [new file with mode: 0644]
src/common/kernel-ctl/kernel-ctl.cpp
src/common/kernel-ctl/kernel-ctl.h [deleted file]
src/common/kernel-ctl/kernel-ctl.hpp [new file with mode: 0644]
src/common/kernel-ctl/kernel-ioctl.h [deleted file]
src/common/kernel-ctl/kernel-ioctl.hpp [new file with mode: 0644]
src/common/kernel-probe.cpp
src/common/location.cpp
src/common/log-level-rule.cpp
src/common/lttng-elf.cpp
src/common/lttng-elf.h [deleted file]
src/common/lttng-elf.hpp [new file with mode: 0644]
src/common/lttng-kernel-old.h [deleted file]
src/common/lttng-kernel-old.hpp [new file with mode: 0644]
src/common/lttng-kernel.h [deleted file]
src/common/lttng-kernel.hpp [new file with mode: 0644]
src/common/macros.h [deleted file]
src/common/macros.hpp [new file with mode: 0644]
src/common/mi-lttng.cpp
src/common/mi-lttng.h [deleted file]
src/common/mi-lttng.hpp [new file with mode: 0644]
src/common/notification.cpp
src/common/optional.h [deleted file]
src/common/optional.hpp [new file with mode: 0644]
src/common/path.cpp
src/common/path.h [deleted file]
src/common/path.hpp [new file with mode: 0644]
src/common/payload-view.cpp
src/common/payload-view.h [deleted file]
src/common/payload-view.hpp [new file with mode: 0644]
src/common/payload.cpp
src/common/payload.h [deleted file]
src/common/payload.hpp [new file with mode: 0644]
src/common/pipe.cpp
src/common/pipe.h [deleted file]
src/common/pipe.hpp [new file with mode: 0644]
src/common/readwrite.cpp
src/common/readwrite.h [deleted file]
src/common/readwrite.hpp [new file with mode: 0644]
src/common/relayd/relayd.cpp
src/common/relayd/relayd.h [deleted file]
src/common/relayd/relayd.hpp [new file with mode: 0644]
src/common/runas.cpp
src/common/runas.h [deleted file]
src/common/runas.hpp [new file with mode: 0644]
src/common/session-descriptor.cpp
src/common/sessiond-comm/agent.h [deleted file]
src/common/sessiond-comm/agent.hpp [new file with mode: 0644]
src/common/sessiond-comm/inet.cpp
src/common/sessiond-comm/inet.h [deleted file]
src/common/sessiond-comm/inet.hpp [new file with mode: 0644]
src/common/sessiond-comm/inet6.cpp
src/common/sessiond-comm/inet6.h [deleted file]
src/common/sessiond-comm/inet6.hpp [new file with mode: 0644]
src/common/sessiond-comm/relayd.h [deleted file]
src/common/sessiond-comm/relayd.hpp [new file with mode: 0644]
src/common/sessiond-comm/sessiond-comm.cpp
src/common/sessiond-comm/sessiond-comm.h [deleted file]
src/common/sessiond-comm/sessiond-comm.hpp [new file with mode: 0644]
src/common/shm.cpp
src/common/shm.h [deleted file]
src/common/shm.hpp [new file with mode: 0644]
src/common/snapshot.cpp
src/common/snapshot.h [deleted file]
src/common/snapshot.hpp [new file with mode: 0644]
src/common/spawn-viewer.cpp
src/common/spawn-viewer.h [deleted file]
src/common/spawn-viewer.hpp [new file with mode: 0644]
src/common/string-utils/format.h [deleted file]
src/common/string-utils/format.hpp [new file with mode: 0644]
src/common/string-utils/string-utils.cpp
src/common/string-utils/string-utils.h [deleted file]
src/common/string-utils/string-utils.hpp [new file with mode: 0644]
src/common/testpoint/testpoint.cpp
src/common/testpoint/testpoint.h [deleted file]
src/common/testpoint/testpoint.hpp [new file with mode: 0644]
src/common/thread.cpp
src/common/thread.h [deleted file]
src/common/thread.hpp [new file with mode: 0644]
src/common/time.cpp
src/common/time.h [deleted file]
src/common/time.hpp [new file with mode: 0644]
src/common/trace-chunk-registry.h [deleted file]
src/common/trace-chunk-registry.hpp [new file with mode: 0644]
src/common/trace-chunk.cpp
src/common/trace-chunk.h [deleted file]
src/common/trace-chunk.hpp [new file with mode: 0644]
src/common/tracker.cpp
src/common/tracker.h [deleted file]
src/common/tracker.hpp [new file with mode: 0644]
src/common/trigger.cpp
src/common/unix.cpp
src/common/unix.h [deleted file]
src/common/unix.hpp [new file with mode: 0644]
src/common/uri.cpp
src/common/uri.h [deleted file]
src/common/uri.hpp [new file with mode: 0644]
src/common/userspace-probe.cpp
src/common/ust-consumer/ust-consumer.cpp
src/common/ust-consumer/ust-consumer.h [deleted file]
src/common/ust-consumer/ust-consumer.hpp [new file with mode: 0644]
src/common/utils.cpp
src/common/utils.h [deleted file]
src/common/utils.hpp [new file with mode: 0644]
src/common/uuid.cpp
src/common/uuid.h [deleted file]
src/common/uuid.hpp [new file with mode: 0644]
src/common/waiter.cpp
src/common/waiter.h [deleted file]
src/common/waiter.hpp [new file with mode: 0644]
src/lib/lttng-ctl/Makefile.am
src/lib/lttng-ctl/channel.cpp
src/lib/lttng-ctl/clear.cpp
src/lib/lttng-ctl/destruction-handle.cpp
src/lib/lttng-ctl/event.cpp
src/lib/lttng-ctl/load.cpp
src/lib/lttng-ctl/lttng-ctl-health.cpp
src/lib/lttng-ctl/lttng-ctl-helper.h [deleted file]
src/lib/lttng-ctl/lttng-ctl-helper.hpp [new file with mode: 0644]
src/lib/lttng-ctl/lttng-ctl.cpp
src/lib/lttng-ctl/rotate.cpp
src/lib/lttng-ctl/save.cpp
src/lib/lttng-ctl/snapshot.cpp
src/lib/lttng-ctl/tracker.cpp
src/vendor/msgpack/lttng-config.h
tests/regression/kernel/select_poll_epoll.cpp
tests/regression/tools/live/live_test.cpp
tests/regression/tools/notification/consumer_testpoints.cpp
tests/regression/tools/notification/default_pipe_size_getter.cpp
tests/regression/tools/notification/notification.cpp
tests/regression/tools/notification/sessiond_testpoints.cpp
tests/regression/tools/trigger/hidden/hidden_trigger.cpp
tests/regression/tools/trigger/name/trigger_name.cpp
tests/regression/tools/trigger/utils/register-some-triggers.cpp
tests/regression/ust/clock-override/lttng-ust-clock-override-test.c
tests/regression/ust/getcpu-override/lttng-ust-getcpu-override-test.c
tests/regression/ust/ust-dl/prog.c
tests/unit/ini_config/ini_config.cpp
tests/unit/test_action.cpp
tests/unit/test_buffer_view.cpp
tests/unit/test_condition.cpp
tests/unit/test_directory_handle.cpp
tests/unit/test_event_expr_to_bytecode.cpp
tests/unit/test_event_rule.cpp
tests/unit/test_fd_tracker.cpp
tests/unit/test_kernel_data.cpp
tests/unit/test_kernel_probe.cpp
tests/unit/test_log_level_rule.cpp
tests/unit/test_notification.cpp
tests/unit/test_payload.cpp
tests/unit/test_rate_policy.cpp
tests/unit/test_relayd_backward_compat_group_by_session.cpp
tests/unit/test_session.cpp
tests/unit/test_string_utils.cpp
tests/unit/test_unix_socket.cpp
tests/unit/test_uri.cpp
tests/unit/test_ust_data.cpp
tests/unit/test_utils_compat_poll.cpp
tests/unit/test_utils_compat_pthread.cpp
tests/unit/test_utils_expand_path.cpp
tests/unit/test_utils_parse_size_suffix.cpp
tests/unit/test_utils_parse_time_suffix.cpp
tests/unit/test_uuid.cpp
tests/utils/testapp/Makefile.am
tests/utils/testapp/gen-ns-events/gen-ns-events.cpp
tests/utils/testapp/gen-syscall-events/gen-syscall-events.cpp
tests/utils/testapp/gen-ust-events-ns/gen-ust-events-ns.cpp
tests/utils/testapp/gen-ust-events/gen-ust-events.cpp
tests/utils/testapp/gen-ust-nevents-str/gen-ust-nevents-str.cpp
tests/utils/testapp/gen-ust-nevents/gen-ust-nevents.cpp
tests/utils/testapp/gen-ust-tracef/gen-ust-tracef.cpp
tests/utils/testapp/signal-helper.h [deleted file]
tests/utils/testapp/signal-helper.hpp [new file with mode: 0644]
tests/utils/testapp/userspace-probe-elf-cxx-binary/Makefile.am
tests/utils/testapp/userspace-probe-elf-cxx-binary/test_class.cpp
tests/utils/testapp/userspace-probe-elf-cxx-binary/test_class.h [deleted file]
tests/utils/testapp/userspace-probe-elf-cxx-binary/test_class.hpp [new file with mode: 0644]
tests/utils/testapp/userspace-probe-elf-cxx-binary/userspace-probe-elf-cxx-binary.cpp
tests/utils/utils.cpp
tests/utils/xml-utils/extract_xml.cpp
tests/utils/xml-utils/validate_xml.cpp

index 4a251556938d335630652d3208d599ecceb78a54..d1d5d8721471d9809cb38c75e7eae37ed72e0e61 100644 (file)
@@ -16,7 +16,7 @@
 #include <sys/time.h>
 #include <time.h>
 
-#include <common/macros.h>
+#include <common/macros.hpp>
 
 static int print_capture(const struct lttng_condition *condition,
                const struct lttng_event_field_value *capture,
index 6fe724b3ae0ee0605f9d97aff4cc0ebe4f4c5761..d840d58dcd8458487348a993feddde279d531485 100644 (file)
@@ -163,51 +163,51 @@ lttngeventruleinclude_HEADERS= \
        lttng/event-rule/user-tracepoint.h
 
 noinst_HEADERS = \
-       lttng/action/action-internal.h \
-       lttng/action/list-internal.h \
-       lttng/action/notify-internal.h \
-       lttng/action/path-internal.h \
-       lttng/action/rotate-session-internal.h \
-       lttng/action/snapshot-session-internal.h \
-       lttng/action/start-session-internal.h \
-       lttng/action/stop-session-internal.h \
-       lttng/action/rate-policy-internal.h \
-       lttng/channel-internal.h \
-       lttng/condition/buffer-usage-internal.h \
-       lttng/condition/condition-internal.h \
-       lttng/condition/evaluation-internal.h \
-       lttng/condition/event-rule-matches-internal.h \
-       lttng/condition/session-consumed-size-internal.h \
-       lttng/condition/session-rotation-internal.h \
-       lttng/domain-internal.h \
-       lttng/endpoint-internal.h \
-       lttng/error-query-internal.h \
-       lttng/event-expr-internal.h \
-       lttng/event-field-value-internal.h \
-       lttng/event-internal.h \
-       lttng/event-rule/event-rule-internal.h \
-       lttng/event-rule/jul-logging-internal.h \
-       lttng/event-rule/kernel-kprobe-internal.h \
-       lttng/event-rule/kernel-syscall-internal.h \
-       lttng/event-rule/kernel-tracepoint-internal.h \
-       lttng/event-rule/kernel-uprobe-internal.h \
-       lttng/event-rule/log4j-logging-internal.h \
-       lttng/event-rule/python-logging-internal.h \
-       lttng/event-rule/user-tracepoint-internal.h \
-       lttng/health-internal.h \
-       lttng/kernel-probe-internal.h \
-       lttng/load-internal.h \
-       lttng/location-internal.h \
-       lttng/log-level-rule-internal.h \
-       lttng/notification/channel-internal.h \
-       lttng/notification/notification-internal.h \
-       lttng/ref-internal.h \
-       lttng/rotate-internal.h \
-       lttng/save-internal.h \
-       lttng/session-descriptor-internal.h \
-       lttng/session-internal.h \
-       lttng/snapshot-internal.h \
-       lttng/trigger/trigger-internal.h \
-       lttng/userspace-probe-internal.h \
-       version.h \
+       lttng/action/action-internal.hpp \
+       lttng/action/list-internal.hpp \
+       lttng/action/notify-internal.hpp \
+       lttng/action/path-internal.hpp \
+       lttng/action/rotate-session-internal.hpp \
+       lttng/action/snapshot-session-internal.hpp \
+       lttng/action/start-session-internal.hpp \
+       lttng/action/stop-session-internal.hpp \
+       lttng/action/rate-policy-internal.hpp \
+       lttng/channel-internal.hpp \
+       lttng/condition/buffer-usage-internal.hpp \
+       lttng/condition/condition-internal.hpp \
+       lttng/condition/evaluation-internal.hpp \
+       lttng/condition/event-rule-matches-internal.hpp \
+       lttng/condition/session-consumed-size-internal.hpp \
+       lttng/condition/session-rotation-internal.hpp \
+       lttng/domain-internal.hpp \
+       lttng/endpoint-internal.hpp \
+       lttng/error-query-internal.hpp \
+       lttng/event-expr-internal.hpp \
+       lttng/event-field-value-internal.hpp \
+       lttng/event-internal.hpp \
+       lttng/event-rule/event-rule-internal.hpp \
+       lttng/event-rule/jul-logging-internal.hpp \
+       lttng/event-rule/kernel-kprobe-internal.hpp \
+       lttng/event-rule/kernel-syscall-internal.hpp \
+       lttng/event-rule/kernel-tracepoint-internal.hpp \
+       lttng/event-rule/kernel-uprobe-internal.hpp \
+       lttng/event-rule/log4j-logging-internal.hpp \
+       lttng/event-rule/python-logging-internal.hpp \
+       lttng/event-rule/user-tracepoint-internal.hpp \
+       lttng/health-internal.hpp \
+       lttng/kernel-probe-internal.hpp \
+       lttng/load-internal.hpp \
+       lttng/location-internal.hpp \
+       lttng/log-level-rule-internal.hpp \
+       lttng/notification/channel-internal.hpp \
+       lttng/notification/notification-internal.hpp \
+       lttng/ref-internal.hpp \
+       lttng/rotate-internal.hpp \
+       lttng/save-internal.hpp \
+       lttng/session-descriptor-internal.hpp \
+       lttng/session-internal.hpp \
+       lttng/snapshot-internal.hpp \
+       lttng/trigger/trigger-internal.hpp \
+       lttng/userspace-probe-internal.hpp \
+       version.hpp \
        version.i
diff --git a/include/lttng/action/action-internal.h b/include/lttng/action/action-internal.h
deleted file mode 100644 (file)
index 71270a8..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_INTERNAL_H
-#define LTTNG_ACTION_INTERNAL_H
-
-#include <common/buffer-view.h>
-#include <common/dynamic-buffer.h>
-#include <common/macros.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/lttng.h>
-#include <pthread.h>
-#include <stdbool.h>
-#include <sys/types.h>
-#include <urcu/ref.h>
-
-struct lttng_rate_policy;
-struct mi_writer;
-struct mi_lttng_error_query_callbacks;
-struct lttng_trigger;
-
-typedef bool (*action_validate_cb)(struct lttng_action *action);
-typedef void (*action_destroy_cb)(struct lttng_action *action);
-typedef int (*action_serialize_cb)(struct lttng_action *action,
-               struct lttng_payload *payload);
-typedef bool (*action_equal_cb)(const struct lttng_action *a,
-               const struct lttng_action *b);
-typedef ssize_t (*action_create_from_payload_cb)(
-               struct lttng_payload_view *view,
-               struct lttng_action **action);
-typedef const struct lttng_rate_policy *(*action_get_rate_policy_cb)(
-               const struct lttng_action *action);
-typedef enum lttng_action_status (*action_add_error_query_results_cb)(
-               const struct lttng_action *action,
-               struct lttng_error_query_results *results);
-typedef enum lttng_error_code (*action_mi_serialize_cb)(
-               const struct lttng_action *condition, struct mi_writer *writer);
-
-struct lttng_action {
-       struct urcu_ref ref;
-       enum lttng_action_type type;
-       action_validate_cb validate;
-       action_serialize_cb serialize;
-       action_equal_cb equal;
-       action_destroy_cb destroy;
-       action_get_rate_policy_cb get_rate_policy;
-       action_add_error_query_results_cb add_error_query_results;
-       action_mi_serialize_cb mi_serialize;
-
-       /* Internal use only. */
-
-       /* The number of time the actions was enqueued for execution. */
-       uint64_t execution_request_counter;
-       /*
-        * The number of time the action was actually executed.
-        * Action rate policy can impact on this number.
-        * */
-       uint64_t execution_counter;
-       /*
-        * The number of time the action execution failed.
-        * An unsigned long is used to use a type which makes atomic
-        * operations possible.
-        */
-       unsigned long execution_failure_counter;
-};
-
-struct lttng_action_comm {
-       /* enum lttng_action_type */
-       int8_t action_type;
-} LTTNG_PACKED;
-
-void lttng_action_init(struct lttng_action *action,
-               enum lttng_action_type type,
-               action_validate_cb validate,
-               action_serialize_cb serialize,
-               action_equal_cb equal,
-               action_destroy_cb destroy,
-               action_get_rate_policy_cb get_rate_policy,
-               action_add_error_query_results_cb add_error_query_results,
-               action_mi_serialize_cb mi);
-
-bool lttng_action_validate(struct lttng_action *action);
-
-int lttng_action_serialize(struct lttng_action *action,
-               struct lttng_payload *buf);
-
-ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view,
-               struct lttng_action **action);
-
-bool lttng_action_is_equal(const struct lttng_action *a,
-               const struct lttng_action *b);
-
-void lttng_action_get(struct lttng_action *action);
-
-void lttng_action_put(struct lttng_action *action);
-
-const char* lttng_action_type_string(enum lttng_action_type action_type);
-
-void lttng_action_increase_execution_request_count(struct lttng_action *action);
-
-void lttng_action_increase_execution_count(struct lttng_action *action);
-
-void lttng_action_increase_execution_failure_count(struct lttng_action *action);
-
-bool lttng_action_should_execute(const struct lttng_action *action);
-
-enum lttng_action_status lttng_action_add_error_query_results(
-               const struct lttng_action *action,
-               struct lttng_error_query_results *results);
-
-/*
- * For use by the various lttng_action implementation. Implements the default
- * behavior to the generic error "execution failure counter" that all actions
- * (except list, which passes-through) provide.
- */
-enum lttng_action_status lttng_action_generic_add_error_query_results(
-               const struct lttng_action *action,
-               struct lttng_error_query_results *results);
-enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trigger,
-               const struct lttng_action *action,
-               struct mi_writer *writer,
-               const struct mi_lttng_error_query_callbacks
-                               *error_query_callbacks,
-               struct lttng_dynamic_array *action_path_indexes);
-
-#endif /* LTTNG_ACTION_INTERNAL_H */
diff --git a/include/lttng/action/action-internal.hpp b/include/lttng/action/action-internal.hpp
new file mode 100644 (file)
index 0000000..996e166
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_INTERNAL_H
+#define LTTNG_ACTION_INTERNAL_H
+
+#include <common/buffer-view.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/macros.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/lttng.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <sys/types.h>
+#include <urcu/ref.h>
+
+struct lttng_rate_policy;
+struct mi_writer;
+struct mi_lttng_error_query_callbacks;
+struct lttng_trigger;
+
+typedef bool (*action_validate_cb)(struct lttng_action *action);
+typedef void (*action_destroy_cb)(struct lttng_action *action);
+typedef int (*action_serialize_cb)(struct lttng_action *action,
+               struct lttng_payload *payload);
+typedef bool (*action_equal_cb)(const struct lttng_action *a,
+               const struct lttng_action *b);
+typedef ssize_t (*action_create_from_payload_cb)(
+               struct lttng_payload_view *view,
+               struct lttng_action **action);
+typedef const struct lttng_rate_policy *(*action_get_rate_policy_cb)(
+               const struct lttng_action *action);
+typedef enum lttng_action_status (*action_add_error_query_results_cb)(
+               const struct lttng_action *action,
+               struct lttng_error_query_results *results);
+typedef enum lttng_error_code (*action_mi_serialize_cb)(
+               const struct lttng_action *condition, struct mi_writer *writer);
+
+struct lttng_action {
+       struct urcu_ref ref;
+       enum lttng_action_type type;
+       action_validate_cb validate;
+       action_serialize_cb serialize;
+       action_equal_cb equal;
+       action_destroy_cb destroy;
+       action_get_rate_policy_cb get_rate_policy;
+       action_add_error_query_results_cb add_error_query_results;
+       action_mi_serialize_cb mi_serialize;
+
+       /* Internal use only. */
+
+       /* The number of time the actions was enqueued for execution. */
+       uint64_t execution_request_counter;
+       /*
+        * The number of time the action was actually executed.
+        * Action rate policy can impact on this number.
+        * */
+       uint64_t execution_counter;
+       /*
+        * The number of time the action execution failed.
+        * An unsigned long is used to use a type which makes atomic
+        * operations possible.
+        */
+       unsigned long execution_failure_counter;
+};
+
+struct lttng_action_comm {
+       /* enum lttng_action_type */
+       int8_t action_type;
+} LTTNG_PACKED;
+
+void lttng_action_init(struct lttng_action *action,
+               enum lttng_action_type type,
+               action_validate_cb validate,
+               action_serialize_cb serialize,
+               action_equal_cb equal,
+               action_destroy_cb destroy,
+               action_get_rate_policy_cb get_rate_policy,
+               action_add_error_query_results_cb add_error_query_results,
+               action_mi_serialize_cb mi);
+
+bool lttng_action_validate(struct lttng_action *action);
+
+int lttng_action_serialize(struct lttng_action *action,
+               struct lttng_payload *buf);
+
+ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view,
+               struct lttng_action **action);
+
+bool lttng_action_is_equal(const struct lttng_action *a,
+               const struct lttng_action *b);
+
+void lttng_action_get(struct lttng_action *action);
+
+void lttng_action_put(struct lttng_action *action);
+
+const char* lttng_action_type_string(enum lttng_action_type action_type);
+
+void lttng_action_increase_execution_request_count(struct lttng_action *action);
+
+void lttng_action_increase_execution_count(struct lttng_action *action);
+
+void lttng_action_increase_execution_failure_count(struct lttng_action *action);
+
+bool lttng_action_should_execute(const struct lttng_action *action);
+
+enum lttng_action_status lttng_action_add_error_query_results(
+               const struct lttng_action *action,
+               struct lttng_error_query_results *results);
+
+/*
+ * For use by the various lttng_action implementation. Implements the default
+ * behavior to the generic error "execution failure counter" that all actions
+ * (except list, which passes-through) provide.
+ */
+enum lttng_action_status lttng_action_generic_add_error_query_results(
+               const struct lttng_action *action,
+               struct lttng_error_query_results *results);
+enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trigger,
+               const struct lttng_action *action,
+               struct mi_writer *writer,
+               const struct mi_lttng_error_query_callbacks
+                               *error_query_callbacks,
+               struct lttng_dynamic_array *action_path_indexes);
+
+#endif /* LTTNG_ACTION_INTERNAL_H */
diff --git a/include/lttng/action/list-internal.h b/include/lttng/action/list-internal.h
deleted file mode 100644 (file)
index 231755f..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_LIST_INTERNAL_H
-#define LTTNG_ACTION_LIST_INTERNAL_H
-
-#include <sys/types.h>
-
-#include <common/macros.h>
-
-struct lttng_action;
-struct lttng_payload_view;
-struct mi_writer;
-struct mi_lttng_error_query_callbacks;
-struct lttng_dynamic_array;
-struct lttng_trigger;
-
-/*
- * Create an action list from a payload view.
- *
- * On success, return the number of bytes consumed from `view`, and the created
- * list in `*list`. On failure, return -1.
- */
-extern ssize_t lttng_action_list_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_action **list);
-
-extern struct lttng_action *lttng_action_list_borrow_mutable_at_index(
-               const struct lttng_action *list, unsigned int index);
-
-enum lttng_error_code lttng_action_list_mi_serialize(const struct lttng_trigger *trigger,
-               const struct lttng_action *action,
-               struct mi_writer *writer,
-               const struct mi_lttng_error_query_callbacks
-                               *error_query_callbacks,
-               struct lttng_dynamic_array *action_path_indexes);
-
-#endif /* LTTNG_ACTION_LIST_INTERNAL_H */
diff --git a/include/lttng/action/list-internal.hpp b/include/lttng/action/list-internal.hpp
new file mode 100644 (file)
index 0000000..294a53c
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_LIST_INTERNAL_H
+#define LTTNG_ACTION_LIST_INTERNAL_H
+
+#include <sys/types.h>
+
+#include <common/macros.hpp>
+
+struct lttng_action;
+struct lttng_payload_view;
+struct mi_writer;
+struct mi_lttng_error_query_callbacks;
+struct lttng_dynamic_array;
+struct lttng_trigger;
+
+/*
+ * Create an action list from a payload view.
+ *
+ * On success, return the number of bytes consumed from `view`, and the created
+ * list in `*list`. On failure, return -1.
+ */
+extern ssize_t lttng_action_list_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_action **list);
+
+extern struct lttng_action *lttng_action_list_borrow_mutable_at_index(
+               const struct lttng_action *list, unsigned int index);
+
+enum lttng_error_code lttng_action_list_mi_serialize(const struct lttng_trigger *trigger,
+               const struct lttng_action *action,
+               struct mi_writer *writer,
+               const struct mi_lttng_error_query_callbacks
+                               *error_query_callbacks,
+               struct lttng_dynamic_array *action_path_indexes);
+
+#endif /* LTTNG_ACTION_LIST_INTERNAL_H */
diff --git a/include/lttng/action/notify-internal.h b/include/lttng/action/notify-internal.h
deleted file mode 100644 (file)
index 8588ac2..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_NOTIFY_INTERNAL_H
-#define LTTNG_ACTION_NOTIFY_INTERNAL_H
-
-#include <lttng/action/notify.h>
-#include <lttng/action/action-internal.h>
-
-struct lttng_action_notify {
-       struct lttng_action parent;
-       struct lttng_rate_policy *policy;
-};
-
-ssize_t lttng_action_notify_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_action **action);
-
-#endif /* LTTNG_ACTION_NOTIFY_INTERNAL_H */
diff --git a/include/lttng/action/notify-internal.hpp b/include/lttng/action/notify-internal.hpp
new file mode 100644 (file)
index 0000000..c923019
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_NOTIFY_INTERNAL_H
+#define LTTNG_ACTION_NOTIFY_INTERNAL_H
+
+#include <lttng/action/notify.h>
+#include <lttng/action/action-internal.hpp>
+
+struct lttng_action_notify {
+       struct lttng_action parent;
+       struct lttng_rate_policy *policy;
+};
+
+ssize_t lttng_action_notify_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_action **action);
+
+#endif /* LTTNG_ACTION_NOTIFY_INTERNAL_H */
diff --git a/include/lttng/action/path-internal.h b/include/lttng/action/path-internal.h
deleted file mode 100644 (file)
index 8a255f0..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_PATH_INTERNAL_H
-#define LTTNG_ACTION_PATH_INTERNAL_H
-
-#include <lttng/action/path.h>
-#include <common/macros.h>
-#include <common/dynamic-array.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <sys/types.h>
-
-struct lttng_action_path {
-       struct lttng_dynamic_array indexes;
-};
-
-/* Assumes that 'dst' is uninitialized. */
-int lttng_action_path_copy(const struct lttng_action_path *src,
-               struct lttng_action_path *dst);
-
-ssize_t lttng_action_path_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_action_path **action_path);
-
-int lttng_action_path_serialize(const struct lttng_action_path *action_path,
-               struct lttng_payload *payload);
-
-#endif /* LTTNG_ACTION_PATH_INTERNAL_H */
diff --git a/include/lttng/action/path-internal.hpp b/include/lttng/action/path-internal.hpp
new file mode 100644 (file)
index 0000000..9b9a4d1
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_PATH_INTERNAL_H
+#define LTTNG_ACTION_PATH_INTERNAL_H
+
+#include <lttng/action/path.h>
+#include <common/macros.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <sys/types.h>
+
+struct lttng_action_path {
+       struct lttng_dynamic_array indexes;
+};
+
+/* Assumes that 'dst' is uninitialized. */
+int lttng_action_path_copy(const struct lttng_action_path *src,
+               struct lttng_action_path *dst);
+
+ssize_t lttng_action_path_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_action_path **action_path);
+
+int lttng_action_path_serialize(const struct lttng_action_path *action_path,
+               struct lttng_payload *payload);
+
+#endif /* LTTNG_ACTION_PATH_INTERNAL_H */
diff --git a/include/lttng/action/rate-policy-internal.h b/include/lttng/action/rate-policy-internal.h
deleted file mode 100644 (file)
index b24ed52..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_RATE_POLICY_INTERNAL_H
-#define LTTNG_RATE_POLICY_INTERNAL_H
-
-#include <common/macros.h>
-#include <common/payload-view.h>
-#include <lttng/action/rate-policy.h>
-#include <lttng/lttng-error.h>
-#include <stdbool.h>
-
-
-struct mi_writer;
-
-int lttng_rate_policy_serialize(struct lttng_rate_policy *rate_policy,
-               struct lttng_payload *buf);
-
-ssize_t lttng_rate_policy_create_from_payload(struct lttng_payload_view *view,
-               struct lttng_rate_policy **rate_policy);
-
-bool lttng_rate_policy_is_equal(const struct lttng_rate_policy *a,
-               const struct lttng_rate_policy *b);
-
-const char *lttng_rate_policy_type_string(
-               enum lttng_rate_policy_type rate_policy_type);
-
-struct lttng_rate_policy *lttng_rate_policy_copy(
-               const struct lttng_rate_policy *source);
-
-bool lttng_rate_policy_should_execute(
-               const struct lttng_rate_policy *policy, uint64_t counter);
-
-enum lttng_error_code lttng_rate_policy_mi_serialize(
-               const struct lttng_rate_policy *policy,
-               struct mi_writer *writer);
-
-#endif /* LTTNG_RATE_POLICY */
diff --git a/include/lttng/action/rate-policy-internal.hpp b/include/lttng/action/rate-policy-internal.hpp
new file mode 100644 (file)
index 0000000..5f6eb1f
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_RATE_POLICY_INTERNAL_H
+#define LTTNG_RATE_POLICY_INTERNAL_H
+
+#include <common/macros.hpp>
+#include <common/payload-view.hpp>
+#include <lttng/action/rate-policy.h>
+#include <lttng/lttng-error.h>
+#include <stdbool.h>
+
+
+struct mi_writer;
+
+int lttng_rate_policy_serialize(struct lttng_rate_policy *rate_policy,
+               struct lttng_payload *buf);
+
+ssize_t lttng_rate_policy_create_from_payload(struct lttng_payload_view *view,
+               struct lttng_rate_policy **rate_policy);
+
+bool lttng_rate_policy_is_equal(const struct lttng_rate_policy *a,
+               const struct lttng_rate_policy *b);
+
+const char *lttng_rate_policy_type_string(
+               enum lttng_rate_policy_type rate_policy_type);
+
+struct lttng_rate_policy *lttng_rate_policy_copy(
+               const struct lttng_rate_policy *source);
+
+bool lttng_rate_policy_should_execute(
+               const struct lttng_rate_policy *policy, uint64_t counter);
+
+enum lttng_error_code lttng_rate_policy_mi_serialize(
+               const struct lttng_rate_policy *policy,
+               struct mi_writer *writer);
+
+#endif /* LTTNG_RATE_POLICY */
diff --git a/include/lttng/action/rotate-session-internal.h b/include/lttng/action/rotate-session-internal.h
deleted file mode 100644 (file)
index 9a451f8..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_ROTATE_SESSION_INTERNAL_H
-#define LTTNG_ACTION_ROTATE_SESSION_INTERNAL_H
-
-#include <common/macros.h>
-
-struct lttng_action;
-struct lttng_payload_view;
-
-/*
- * Create a "rotate session" action from a payload view.
- *
- * On success, return the number of bytes consumed from `view`, and the created
- * action in `*action`. On failure, return -1.
- */
-extern ssize_t lttng_action_rotate_session_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_action **action);
-
-#endif /* LTTNG_ACTION_ROTATE_SESSION_INTERNAL_H */
diff --git a/include/lttng/action/rotate-session-internal.hpp b/include/lttng/action/rotate-session-internal.hpp
new file mode 100644 (file)
index 0000000..5030aea
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_ROTATE_SESSION_INTERNAL_H
+#define LTTNG_ACTION_ROTATE_SESSION_INTERNAL_H
+
+#include <common/macros.hpp>
+
+struct lttng_action;
+struct lttng_payload_view;
+
+/*
+ * Create a "rotate session" action from a payload view.
+ *
+ * On success, return the number of bytes consumed from `view`, and the created
+ * action in `*action`. On failure, return -1.
+ */
+extern ssize_t lttng_action_rotate_session_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_action **action);
+
+#endif /* LTTNG_ACTION_ROTATE_SESSION_INTERNAL_H */
diff --git a/include/lttng/action/snapshot-session-internal.h b/include/lttng/action/snapshot-session-internal.h
deleted file mode 100644 (file)
index 7396c29..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_SNAPSHOT_SESSION_INTERNAL_H
-#define LTTNG_ACTION_SNAPSHOT_SESSION_INTERNAL_H
-
-#include <sys/types.h>
-
-#include <common/macros.h>
-
-struct lttng_action;
-struct lttng_payload_view;
-
-/*
- * Create a "snapshot session" action from a payload view.
- *
- * On success, return the number of bytes consumed from `view`, and the created
- * action in `*action`. On failure, return -1.
- */
-extern ssize_t lttng_action_snapshot_session_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_action **action);
-
-#endif /* LTTNG_ACTION_SNAPSHOT_SESSION_INTERNAL_H */
diff --git a/include/lttng/action/snapshot-session-internal.hpp b/include/lttng/action/snapshot-session-internal.hpp
new file mode 100644 (file)
index 0000000..27a8795
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_SNAPSHOT_SESSION_INTERNAL_H
+#define LTTNG_ACTION_SNAPSHOT_SESSION_INTERNAL_H
+
+#include <sys/types.h>
+
+#include <common/macros.hpp>
+
+struct lttng_action;
+struct lttng_payload_view;
+
+/*
+ * Create a "snapshot session" action from a payload view.
+ *
+ * On success, return the number of bytes consumed from `view`, and the created
+ * action in `*action`. On failure, return -1.
+ */
+extern ssize_t lttng_action_snapshot_session_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_action **action);
+
+#endif /* LTTNG_ACTION_SNAPSHOT_SESSION_INTERNAL_H */
diff --git a/include/lttng/action/start-session-internal.h b/include/lttng/action/start-session-internal.h
deleted file mode 100644 (file)
index 56ffb71..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_START_SESSION_INTERNAL_H
-#define LTTNG_ACTION_START_SESSION_INTERNAL_H
-
-#include <common/macros.h>
-
-struct lttng_action;
-struct lttng_payload_view;
-
-/*
- * Create a "start session" action from a payload view.
- *
- * On success, return the number of bytes consumed from `view`, and the created
- * action in `*action`. On failure, return -1.
- */
-extern ssize_t lttng_action_start_session_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_action **action);
-
-#endif /* LTTNG_ACTION_START_SESSION_INTERNAL_H */
diff --git a/include/lttng/action/start-session-internal.hpp b/include/lttng/action/start-session-internal.hpp
new file mode 100644 (file)
index 0000000..44dab1b
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_START_SESSION_INTERNAL_H
+#define LTTNG_ACTION_START_SESSION_INTERNAL_H
+
+#include <common/macros.hpp>
+
+struct lttng_action;
+struct lttng_payload_view;
+
+/*
+ * Create a "start session" action from a payload view.
+ *
+ * On success, return the number of bytes consumed from `view`, and the created
+ * action in `*action`. On failure, return -1.
+ */
+extern ssize_t lttng_action_start_session_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_action **action);
+
+#endif /* LTTNG_ACTION_START_SESSION_INTERNAL_H */
diff --git a/include/lttng/action/stop-session-internal.h b/include/lttng/action/stop-session-internal.h
deleted file mode 100644 (file)
index da4a5aa..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_STOP_SESSION_INTERNAL_H
-#define LTTNG_ACTION_STOP_SESSION_INTERNAL_H
-
-#include <common/macros.h>
-
-struct lttng_action;
-struct lttng_payload_view;
-
-/*
- * Create a "stop session" action from a payload view.
- *
- * On success, return the number of bytes consumed from `view`, and the created
- * action in `*action`. On failure, return -1.
- */
-extern ssize_t lttng_action_stop_session_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_action **action);
-
-#endif /* LTTNG_ACTION_STOP_SESSION_INTERNAL_H */
diff --git a/include/lttng/action/stop-session-internal.hpp b/include/lttng/action/stop-session-internal.hpp
new file mode 100644 (file)
index 0000000..2205535
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_STOP_SESSION_INTERNAL_H
+#define LTTNG_ACTION_STOP_SESSION_INTERNAL_H
+
+#include <common/macros.hpp>
+
+struct lttng_action;
+struct lttng_payload_view;
+
+/*
+ * Create a "stop session" action from a payload view.
+ *
+ * On success, return the number of bytes consumed from `view`, and the created
+ * action in `*action`. On failure, return -1.
+ */
+extern ssize_t lttng_action_stop_session_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_action **action);
+
+#endif /* LTTNG_ACTION_STOP_SESSION_INTERNAL_H */
diff --git a/include/lttng/channel-internal.h b/include/lttng/channel-internal.h
deleted file mode 100644 (file)
index c3e1230..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CHANNEL_INTERNAL_H
-#define LTTNG_CHANNEL_INTERNAL_H
-
-#include <common/macros.h>
-#include <lttng/channel.h>
-#include <lttng/lttng-error.h>
-
-struct lttng_dynamic_buffer;
-struct lttng_buffer_view;
-
-struct lttng_channel_extended {
-       uint64_t discarded_events;
-       uint64_t lost_packets;
-       uint64_t monitor_timer_interval;
-       int64_t blocking_timeout;
-} LTTNG_PACKED;
-
-struct lttng_channel_comm {
-       /* Includes terminator `\0`. */
-       uint32_t name_len;
-       uint8_t enabled;
-
-       /* attr */
-       int8_t overwrite;
-       uint64_t subbuf_size;
-       uint64_t num_subbuf;
-       uint32_t switch_timer_interval;
-       uint32_t read_timer_interval;
-       uint8_t output;
-       uint64_t tracefile_size;
-       uint64_t tracefile_count;
-       uint32_t live_timer_interval;
-
-       /* Extended struct */
-       uint64_t discarded_events;
-       uint64_t lost_packets;
-       uint64_t monitor_timer_interval;
-       int64_t blocking_timeout;
-} LTTNG_PACKED;
-
-struct lttng_channel *lttng_channel_create_internal(void);
-
-struct lttng_channel *lttng_channel_copy(const struct lttng_channel *src);
-
-ssize_t lttng_channel_create_from_buffer(const struct lttng_buffer_view *view,
-               struct lttng_channel **event);
-
-int lttng_channel_serialize(struct lttng_channel *channel,
-               struct lttng_dynamic_buffer *buf);
-
-void lttng_channel_set_default_extended_attr(struct lttng_domain *domain,
-               struct lttng_channel_extended *extended_attr);
-
-enum lttng_error_code lttng_channels_create_and_flatten_from_buffer(
-               const struct lttng_buffer_view *view,
-               unsigned int count,
-               struct lttng_channel **channels);
-
-#endif /* LTTNG_CHANNEL_INTERNAL_H */
diff --git a/include/lttng/channel-internal.hpp b/include/lttng/channel-internal.hpp
new file mode 100644 (file)
index 0000000..d496082
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CHANNEL_INTERNAL_H
+#define LTTNG_CHANNEL_INTERNAL_H
+
+#include <common/macros.hpp>
+
+struct lttng_channel_extended {
+       uint64_t discarded_events;
+       uint64_t lost_packets;
+       uint64_t monitor_timer_interval;
+       int64_t blocking_timeout;
+} LTTNG_PACKED;
+
+struct lttng_channel_comm {
+       /* Includes terminator `\0`. */
+       uint32_t name_len;
+       uint8_t enabled;
+
+       /* attr */
+       int8_t overwrite;
+       uint64_t subbuf_size;
+       uint64_t num_subbuf;
+       uint32_t switch_timer_interval;
+       uint32_t read_timer_interval;
+       uint8_t output;
+       uint64_t tracefile_size;
+       uint64_t tracefile_count;
+       uint32_t live_timer_interval;
+
+       /* Extended struct */
+       uint64_t discarded_events;
+       uint64_t lost_packets;
+       uint64_t monitor_timer_interval;
+       int64_t blocking_timeout;
+} LTTNG_PACKED;
+
+struct lttng_channel *lttng_channel_create_internal(void);
+
+struct lttng_channel *lttng_channel_copy(const struct lttng_channel *src);
+
+ssize_t lttng_channel_create_from_buffer(const struct lttng_buffer_view *view,
+               struct lttng_channel **event);
+
+int lttng_channel_serialize(struct lttng_channel *channel,
+               struct lttng_dynamic_buffer *buf);
+
+void lttng_channel_set_default_extended_attr(struct lttng_domain *domain,
+               struct lttng_channel_extended *extended_attr);
+
+enum lttng_error_code lttng_channels_create_and_flatten_from_buffer(
+               const struct lttng_buffer_view *view,
+               unsigned int count,
+               struct lttng_channel **channels);
+
+#endif /* LTTNG_CHANNEL_INTERNAL_H */
diff --git a/include/lttng/condition/buffer-usage-internal.h b/include/lttng/condition/buffer-usage-internal.h
deleted file mode 100644 (file)
index 1e6d5a5..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CONDITION_BUFFER_USAGE_INTERNAL_H
-#define LTTNG_CONDITION_BUFFER_USAGE_INTERNAL_H
-
-#include <lttng/condition/buffer-usage.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/evaluation-internal.h>
-#include <lttng/domain.h>
-#include "common/buffer-view.h"
-#include <common/macros.h>
-
-struct lttng_condition_buffer_usage {
-       struct lttng_condition parent;
-       struct {
-               bool set;
-               uint64_t value;
-       } threshold_bytes;
-       struct {
-               bool set;
-               double value;
-       } threshold_ratio;
-       char *session_name;
-       char *channel_name;
-       struct {
-               bool set;
-               enum lttng_domain_type type;
-       } domain;
-};
-
-struct lttng_condition_buffer_usage_comm {
-       uint8_t threshold_set_in_bytes;
-       uint64_t threshold_bytes;
-       double threshold_ratio;
-       /* Both lengths include the trailing \0. */
-       uint32_t session_name_len;
-       uint32_t channel_name_len;
-       /* enum lttng_domain_type */
-       int8_t domain_type;
-       /* session and channel names. */
-       char names[];
-} LTTNG_PACKED;
-
-struct lttng_evaluation_buffer_usage {
-       struct lttng_evaluation parent;
-       uint64_t buffer_use;
-       uint64_t buffer_capacity;
-};
-
-struct lttng_evaluation_buffer_usage_comm {
-       uint64_t buffer_use;
-       uint64_t buffer_capacity;
-} LTTNG_PACKED;
-
-struct lttng_evaluation *lttng_evaluation_buffer_usage_create(
-               enum lttng_condition_type type, uint64_t use,
-               uint64_t capacity);
-
-ssize_t lttng_condition_buffer_usage_low_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_condition **condition);
-
-ssize_t lttng_condition_buffer_usage_high_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_condition **condition);
-
-ssize_t lttng_evaluation_buffer_usage_low_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_evaluation **evaluation);
-
-ssize_t lttng_evaluation_buffer_usage_high_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_evaluation **evaluation);
-
-#endif /* LTTNG_CONDITION_BUFFER_USAGE_INTERNAL_H */
diff --git a/include/lttng/condition/buffer-usage-internal.hpp b/include/lttng/condition/buffer-usage-internal.hpp
new file mode 100644 (file)
index 0000000..b2e6f85
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CONDITION_BUFFER_USAGE_INTERNAL_H
+#define LTTNG_CONDITION_BUFFER_USAGE_INTERNAL_H
+
+#include <lttng/condition/buffer-usage.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/evaluation-internal.hpp>
+#include <lttng/domain.h>
+#include "common/buffer-view.hpp"
+#include <common/macros.hpp>
+
+struct lttng_condition_buffer_usage {
+       struct lttng_condition parent;
+       struct {
+               bool set;
+               uint64_t value;
+       } threshold_bytes;
+       struct {
+               bool set;
+               double value;
+       } threshold_ratio;
+       char *session_name;
+       char *channel_name;
+       struct {
+               bool set;
+               enum lttng_domain_type type;
+       } domain;
+};
+
+struct lttng_condition_buffer_usage_comm {
+       uint8_t threshold_set_in_bytes;
+       uint64_t threshold_bytes;
+       double threshold_ratio;
+       /* Both lengths include the trailing \0. */
+       uint32_t session_name_len;
+       uint32_t channel_name_len;
+       /* enum lttng_domain_type */
+       int8_t domain_type;
+       /* session and channel names. */
+       char names[];
+} LTTNG_PACKED;
+
+struct lttng_evaluation_buffer_usage {
+       struct lttng_evaluation parent;
+       uint64_t buffer_use;
+       uint64_t buffer_capacity;
+};
+
+struct lttng_evaluation_buffer_usage_comm {
+       uint64_t buffer_use;
+       uint64_t buffer_capacity;
+} LTTNG_PACKED;
+
+struct lttng_evaluation *lttng_evaluation_buffer_usage_create(
+               enum lttng_condition_type type, uint64_t use,
+               uint64_t capacity);
+
+ssize_t lttng_condition_buffer_usage_low_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_condition **condition);
+
+ssize_t lttng_condition_buffer_usage_high_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_condition **condition);
+
+ssize_t lttng_evaluation_buffer_usage_low_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_evaluation **evaluation);
+
+ssize_t lttng_evaluation_buffer_usage_high_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_evaluation **evaluation);
+
+#endif /* LTTNG_CONDITION_BUFFER_USAGE_INTERNAL_H */
diff --git a/include/lttng/condition/condition-internal.h b/include/lttng/condition/condition-internal.h
deleted file mode 100644 (file)
index 5bafaf0..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CONDITION_INTERNAL_H
-#define LTTNG_CONDITION_INTERNAL_H
-
-#include <common/macros.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/condition/condition.h>
-#include <lttng/lttng-error.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <urcu/list.h>
-#include <urcu/ref.h>
-
-struct mi_writer;
-struct mi_lttng_error_query_callbacks;
-struct lttng_trigger;
-
-typedef void (*condition_destroy_cb)(struct lttng_condition *condition);
-typedef bool (*condition_validate_cb)(const struct lttng_condition *condition);
-typedef int (*condition_serialize_cb)(
-               const struct lttng_condition *condition,
-               struct lttng_payload *payload);
-typedef bool (*condition_equal_cb)(const struct lttng_condition *a,
-               const struct lttng_condition *b);
-typedef ssize_t (*condition_create_from_payload_cb)(
-               struct lttng_payload_view *view,
-               struct lttng_condition **condition);
-typedef enum lttng_error_code (*condition_mi_serialize_cb)(
-               const struct lttng_condition *condition,
-               struct mi_writer *writer);
-
-struct lttng_condition {
-       /* Reference counting is only exposed to internal users. */
-       struct urcu_ref ref;
-       enum lttng_condition_type type;
-       condition_validate_cb validate;
-       condition_serialize_cb serialize;
-       condition_equal_cb equal;
-       condition_destroy_cb destroy;
-       condition_mi_serialize_cb mi_serialize;
-};
-
-struct lttng_condition_comm {
-       /* enum lttng_condition_type */
-       int8_t condition_type;
-       char payload[];
-};
-
-void lttng_condition_get(struct lttng_condition *condition);
-
-void lttng_condition_put(struct lttng_condition *condition);
-
-void lttng_condition_init(struct lttng_condition *condition,
-               enum lttng_condition_type type);
-
-bool lttng_condition_validate(const struct lttng_condition *condition);
-
-ssize_t lttng_condition_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_condition **condition);
-
-int lttng_condition_serialize(const struct lttng_condition *condition,
-               struct lttng_payload *payload);
-
-bool lttng_condition_is_equal(const struct lttng_condition *a,
-               const struct lttng_condition *b);
-
-enum lttng_error_code lttng_condition_mi_serialize(
-               const struct lttng_trigger *trigger,
-               const struct lttng_condition *condition,
-               struct mi_writer *writer,
-               const struct mi_lttng_error_query_callbacks
-                               *error_query_callbacks);
-
-const char *lttng_condition_type_str(enum lttng_condition_type type);
-
-#endif /* LTTNG_CONDITION_INTERNAL_H */
diff --git a/include/lttng/condition/condition-internal.hpp b/include/lttng/condition/condition-internal.hpp
new file mode 100644 (file)
index 0000000..27407d0
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CONDITION_INTERNAL_H
+#define LTTNG_CONDITION_INTERNAL_H
+
+#include <common/macros.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/condition/condition.h>
+#include <lttng/lttng-error.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <urcu/list.h>
+#include <urcu/ref.h>
+
+struct mi_writer;
+struct mi_lttng_error_query_callbacks;
+struct lttng_trigger;
+
+typedef void (*condition_destroy_cb)(struct lttng_condition *condition);
+typedef bool (*condition_validate_cb)(const struct lttng_condition *condition);
+typedef int (*condition_serialize_cb)(
+               const struct lttng_condition *condition,
+               struct lttng_payload *payload);
+typedef bool (*condition_equal_cb)(const struct lttng_condition *a,
+               const struct lttng_condition *b);
+typedef ssize_t (*condition_create_from_payload_cb)(
+               struct lttng_payload_view *view,
+               struct lttng_condition **condition);
+typedef enum lttng_error_code (*condition_mi_serialize_cb)(
+               const struct lttng_condition *condition,
+               struct mi_writer *writer);
+
+struct lttng_condition {
+       /* Reference counting is only exposed to internal users. */
+       struct urcu_ref ref;
+       enum lttng_condition_type type;
+       condition_validate_cb validate;
+       condition_serialize_cb serialize;
+       condition_equal_cb equal;
+       condition_destroy_cb destroy;
+       condition_mi_serialize_cb mi_serialize;
+};
+
+struct lttng_condition_comm {
+       /* enum lttng_condition_type */
+       int8_t condition_type;
+       char payload[];
+};
+
+void lttng_condition_get(struct lttng_condition *condition);
+
+void lttng_condition_put(struct lttng_condition *condition);
+
+void lttng_condition_init(struct lttng_condition *condition,
+               enum lttng_condition_type type);
+
+bool lttng_condition_validate(const struct lttng_condition *condition);
+
+ssize_t lttng_condition_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_condition **condition);
+
+int lttng_condition_serialize(const struct lttng_condition *condition,
+               struct lttng_payload *payload);
+
+bool lttng_condition_is_equal(const struct lttng_condition *a,
+               const struct lttng_condition *b);
+
+enum lttng_error_code lttng_condition_mi_serialize(
+               const struct lttng_trigger *trigger,
+               const struct lttng_condition *condition,
+               struct mi_writer *writer,
+               const struct mi_lttng_error_query_callbacks
+                               *error_query_callbacks);
+
+const char *lttng_condition_type_str(enum lttng_condition_type type);
+
+#endif /* LTTNG_CONDITION_INTERNAL_H */
diff --git a/include/lttng/condition/evaluation-internal.h b/include/lttng/condition/evaluation-internal.h
deleted file mode 100644 (file)
index 12ea104..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVALUATION_INTERNAL_H
-#define LTTNG_EVALUATION_INTERNAL_H
-
-#include <lttng/condition/evaluation.h>
-#include <lttng/condition/condition.h>
-#include <common/macros.h>
-#include <stdbool.h>
-#include <sys/types.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-
-typedef void (*evaluation_destroy_cb)(struct lttng_evaluation *evaluation);
-typedef int (*evaluation_serialize_cb)(
-               const struct lttng_evaluation *evaluation,
-               struct lttng_payload *payload);
-
-struct lttng_evaluation_comm {
-       /* enum lttng_condition_type type */
-       int8_t type;
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_evaluation {
-       enum lttng_condition_type type;
-       evaluation_serialize_cb serialize;
-       evaluation_destroy_cb destroy;
-};
-
-void lttng_evaluation_init(struct lttng_evaluation *evaluation,
-               enum lttng_condition_type type);
-
-ssize_t lttng_evaluation_create_from_payload(
-               const struct lttng_condition *condition,
-               struct lttng_payload_view *view,
-               struct lttng_evaluation **evaluation);
-
-int lttng_evaluation_serialize(const struct lttng_evaluation *evaluation,
-               struct lttng_payload *payload);
-
-#endif /* LTTNG_EVALUATION_INTERNAL_H */
diff --git a/include/lttng/condition/evaluation-internal.hpp b/include/lttng/condition/evaluation-internal.hpp
new file mode 100644 (file)
index 0000000..f74927c
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVALUATION_INTERNAL_H
+#define LTTNG_EVALUATION_INTERNAL_H
+
+#include <lttng/condition/evaluation.h>
+#include <lttng/condition/condition.h>
+#include <common/macros.hpp>
+#include <stdbool.h>
+#include <sys/types.h>
+
+struct lttng_payload;
+struct lttng_payload_view;
+
+typedef void (*evaluation_destroy_cb)(struct lttng_evaluation *evaluation);
+typedef int (*evaluation_serialize_cb)(
+               const struct lttng_evaluation *evaluation,
+               struct lttng_payload *payload);
+
+struct lttng_evaluation_comm {
+       /* enum lttng_condition_type type */
+       int8_t type;
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_evaluation {
+       enum lttng_condition_type type;
+       evaluation_serialize_cb serialize;
+       evaluation_destroy_cb destroy;
+};
+
+void lttng_evaluation_init(struct lttng_evaluation *evaluation,
+               enum lttng_condition_type type);
+
+ssize_t lttng_evaluation_create_from_payload(
+               const struct lttng_condition *condition,
+               struct lttng_payload_view *view,
+               struct lttng_evaluation **evaluation);
+
+int lttng_evaluation_serialize(const struct lttng_evaluation *evaluation,
+               struct lttng_payload *payload);
+
+#endif /* LTTNG_EVALUATION_INTERNAL_H */
diff --git a/include/lttng/condition/event-rule-matches-internal.h b/include/lttng/condition/event-rule-matches-internal.h
deleted file mode 100644 (file)
index ef39f4f..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H
-#define LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H
-
-#include <lttng/condition/condition-internal.h>
-#include <common/buffer-view.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/condition/evaluation-internal.h>
-#include <common/dynamic-array.h>
-#include <lttng/event-field-value.h>
-
-struct lttng_capture_descriptor {
-       struct lttng_event_expr *event_expression;
-       struct lttng_bytecode *bytecode;
-};
-
-struct lttng_condition_event_rule_matches {
-       struct lttng_condition parent;
-       struct lttng_event_rule *rule;
-
-       /*
-        * Internal use only.
-        * Error accounting counter index.
-        */
-       LTTNG_OPTIONAL(uint64_t) error_counter_index;
-
-       /* Array of `struct lttng_capture_descriptor *`. */
-       struct lttng_dynamic_pointer_array capture_descriptors;
-};
-
-struct lttng_evaluation_event_rule_matches {
-       struct lttng_evaluation parent;
-
-       /* MessagePack-encoded captured event field values. */
-       struct lttng_dynamic_buffer capture_payload;
-
-       /*
-        * The content of this array event field value is the decoded
-        * version of `capture_payload` above.
-        *
-        * This is a cache: it's not serialized/deserialized in
-        * communications from/to the library and the session daemon.
-        */
-       struct lttng_event_field_value *captured_values;
-};
-
-ssize_t lttng_condition_event_rule_matches_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_condition **condition);
-
-enum lttng_condition_status
-lttng_condition_event_rule_matches_borrow_rule_mutable(
-               const struct lttng_condition *condition,
-               struct lttng_event_rule **rule);
-
-void lttng_condition_event_rule_matches_set_error_counter_index(
-               struct lttng_condition *condition,
-               uint64_t error_counter_index);
-
-uint64_t lttng_condition_event_rule_matches_get_error_counter_index(
-               const struct lttng_condition *condition);
-
-struct lttng_evaluation *lttng_evaluation_event_rule_matches_create(
-               const struct lttng_condition_event_rule_matches *condition,
-               const char *capture_payload,
-               size_t capture_payload_size,
-               bool decode_capture_payload);
-
-ssize_t lttng_evaluation_event_rule_matches_create_from_payload(
-               const struct lttng_condition_event_rule_matches *condition,
-               struct lttng_payload_view *view,
-               struct lttng_evaluation **_evaluation);
-
-enum lttng_error_code
-lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode(
-               struct lttng_condition *condition);
-
-const struct lttng_bytecode *
-lttng_condition_event_rule_matches_get_capture_bytecode_at_index(
-               const struct lttng_condition *condition, unsigned int index);
-
-#endif /* LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H */
diff --git a/include/lttng/condition/event-rule-matches-internal.hpp b/include/lttng/condition/event-rule-matches-internal.hpp
new file mode 100644 (file)
index 0000000..bb7e03e
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H
+#define LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H
+
+#include <lttng/condition/condition-internal.hpp>
+#include <common/buffer-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/condition/evaluation-internal.hpp>
+#include <common/dynamic-array.hpp>
+#include <lttng/event-field-value.h>
+
+struct lttng_capture_descriptor {
+       struct lttng_event_expr *event_expression;
+       struct lttng_bytecode *bytecode;
+};
+
+struct lttng_condition_event_rule_matches {
+       struct lttng_condition parent;
+       struct lttng_event_rule *rule;
+
+       /*
+        * Internal use only.
+        * Error accounting counter index.
+        */
+       LTTNG_OPTIONAL(uint64_t) error_counter_index;
+
+       /* Array of `struct lttng_capture_descriptor *`. */
+       struct lttng_dynamic_pointer_array capture_descriptors;
+};
+
+struct lttng_evaluation_event_rule_matches {
+       struct lttng_evaluation parent;
+
+       /* MessagePack-encoded captured event field values. */
+       struct lttng_dynamic_buffer capture_payload;
+
+       /*
+        * The content of this array event field value is the decoded
+        * version of `capture_payload` above.
+        *
+        * This is a cache: it's not serialized/deserialized in
+        * communications from/to the library and the session daemon.
+        */
+       struct lttng_event_field_value *captured_values;
+};
+
+ssize_t lttng_condition_event_rule_matches_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_condition **condition);
+
+enum lttng_condition_status
+lttng_condition_event_rule_matches_borrow_rule_mutable(
+               const struct lttng_condition *condition,
+               struct lttng_event_rule **rule);
+
+void lttng_condition_event_rule_matches_set_error_counter_index(
+               struct lttng_condition *condition,
+               uint64_t error_counter_index);
+
+uint64_t lttng_condition_event_rule_matches_get_error_counter_index(
+               const struct lttng_condition *condition);
+
+struct lttng_evaluation *lttng_evaluation_event_rule_matches_create(
+               const struct lttng_condition_event_rule_matches *condition,
+               const char *capture_payload,
+               size_t capture_payload_size,
+               bool decode_capture_payload);
+
+ssize_t lttng_evaluation_event_rule_matches_create_from_payload(
+               const struct lttng_condition_event_rule_matches *condition,
+               struct lttng_payload_view *view,
+               struct lttng_evaluation **_evaluation);
+
+enum lttng_error_code
+lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode(
+               struct lttng_condition *condition);
+
+const struct lttng_bytecode *
+lttng_condition_event_rule_matches_get_capture_bytecode_at_index(
+               const struct lttng_condition *condition, unsigned int index);
+
+#endif /* LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H */
diff --git a/include/lttng/condition/session-consumed-size-internal.h b/include/lttng/condition/session-consumed-size-internal.h
deleted file mode 100644 (file)
index 9340a5f..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CONDITION_SESSION_CONSUMED_SIZE_INTERNAL_H
-#define LTTNG_CONDITION_SESSION_CONSUMED_SIZE_INTERNAL_H
-
-#include <lttng/condition/session-consumed-size.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/evaluation-internal.h>
-#include <common/buffer-view.h>
-#include <common/macros.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-
-struct lttng_condition_session_consumed_size {
-       struct lttng_condition parent;
-       struct {
-               bool set;
-               uint64_t value;
-       } consumed_threshold_bytes;
-       char *session_name;
-};
-
-struct lttng_condition_session_consumed_size_comm {
-       uint64_t consumed_threshold_bytes;
-       /* Length includes the trailing \0. */
-       uint32_t session_name_len;
-       char session_name[];
-} LTTNG_PACKED;
-
-struct lttng_evaluation_session_consumed_size {
-       struct lttng_evaluation parent;
-       uint64_t session_consumed;
-};
-
-struct lttng_evaluation_session_consumed_size_comm {
-       uint64_t session_consumed;
-} LTTNG_PACKED;
-
-struct lttng_evaluation *lttng_evaluation_session_consumed_size_create(
-               uint64_t consumed);
-
-ssize_t lttng_condition_session_consumed_size_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_condition **condition);
-
-ssize_t lttng_evaluation_session_consumed_size_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_evaluation **evaluation);
-
-#endif /* LTTNG_CONDITION_SESSION_CONSUMED_SIZE_INTERNAL_H */
diff --git a/include/lttng/condition/session-consumed-size-internal.hpp b/include/lttng/condition/session-consumed-size-internal.hpp
new file mode 100644 (file)
index 0000000..cdfa100
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CONDITION_SESSION_CONSUMED_SIZE_INTERNAL_H
+#define LTTNG_CONDITION_SESSION_CONSUMED_SIZE_INTERNAL_H
+
+#include <lttng/condition/session-consumed-size.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/evaluation-internal.hpp>
+#include <common/buffer-view.hpp>
+#include <common/macros.hpp>
+
+struct lttng_payload;
+struct lttng_payload_view;
+
+struct lttng_condition_session_consumed_size {
+       struct lttng_condition parent;
+       struct {
+               bool set;
+               uint64_t value;
+       } consumed_threshold_bytes;
+       char *session_name;
+};
+
+struct lttng_condition_session_consumed_size_comm {
+       uint64_t consumed_threshold_bytes;
+       /* Length includes the trailing \0. */
+       uint32_t session_name_len;
+       char session_name[];
+} LTTNG_PACKED;
+
+struct lttng_evaluation_session_consumed_size {
+       struct lttng_evaluation parent;
+       uint64_t session_consumed;
+};
+
+struct lttng_evaluation_session_consumed_size_comm {
+       uint64_t session_consumed;
+} LTTNG_PACKED;
+
+struct lttng_evaluation *lttng_evaluation_session_consumed_size_create(
+               uint64_t consumed);
+
+ssize_t lttng_condition_session_consumed_size_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_condition **condition);
+
+ssize_t lttng_evaluation_session_consumed_size_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_evaluation **evaluation);
+
+#endif /* LTTNG_CONDITION_SESSION_CONSUMED_SIZE_INTERNAL_H */
diff --git a/include/lttng/condition/session-rotation-internal.h b/include/lttng/condition/session-rotation-internal.h
deleted file mode 100644 (file)
index c723c6d..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CONDITION_SESSION_ROTATION_INTERNAL_H
-#define LTTNG_CONDITION_SESSION_ROTATION_INTERNAL_H
-
-#include <lttng/condition/session-rotation.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/evaluation-internal.h>
-#include "common/buffer-view.h"
-#include <lttng/location.h>
-#include <common/macros.h>
-
-struct lttng_condition_session_rotation {
-       struct lttng_condition parent;
-       char *session_name;
-};
-
-struct lttng_condition_session_rotation_comm {
-       /* Length includes the trailing \0. */
-       uint32_t session_name_len;
-       char session_name[];
-} LTTNG_PACKED;
-
-struct lttng_evaluation_session_rotation {
-       struct lttng_evaluation parent;
-       uint64_t id;
-       struct lttng_trace_archive_location *location;
-};
-
-struct lttng_evaluation_session_rotation_comm {
-       uint64_t id;
-       uint8_t has_location;
-} LTTNG_PACKED;
-
-ssize_t lttng_condition_session_rotation_ongoing_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_condition **condition);
-
-ssize_t lttng_condition_session_rotation_completed_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_condition **condition);
-
-struct lttng_evaluation *lttng_evaluation_session_rotation_ongoing_create(
-                uint64_t id);
-
-/* Ownership of location is transferred to the evaluation. */
-struct lttng_evaluation *lttng_evaluation_session_rotation_completed_create(
-               uint64_t id,
-               struct lttng_trace_archive_location *location);
-
-ssize_t lttng_evaluation_session_rotation_ongoing_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_evaluation **evaluation);
-
-ssize_t lttng_evaluation_session_rotation_completed_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_evaluation **evaluation);
-
-#endif /* LTTNG_CONDITION_SESSION_ROTATION_INTERNAL_H */
diff --git a/include/lttng/condition/session-rotation-internal.hpp b/include/lttng/condition/session-rotation-internal.hpp
new file mode 100644 (file)
index 0000000..e9a2984
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CONDITION_SESSION_ROTATION_INTERNAL_H
+#define LTTNG_CONDITION_SESSION_ROTATION_INTERNAL_H
+
+#include <lttng/condition/session-rotation.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/evaluation-internal.hpp>
+#include "common/buffer-view.hpp"
+#include <lttng/location.h>
+#include <common/macros.hpp>
+
+struct lttng_condition_session_rotation {
+       struct lttng_condition parent;
+       char *session_name;
+};
+
+struct lttng_condition_session_rotation_comm {
+       /* Length includes the trailing \0. */
+       uint32_t session_name_len;
+       char session_name[];
+} LTTNG_PACKED;
+
+struct lttng_evaluation_session_rotation {
+       struct lttng_evaluation parent;
+       uint64_t id;
+       struct lttng_trace_archive_location *location;
+};
+
+struct lttng_evaluation_session_rotation_comm {
+       uint64_t id;
+       uint8_t has_location;
+} LTTNG_PACKED;
+
+ssize_t lttng_condition_session_rotation_ongoing_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_condition **condition);
+
+ssize_t lttng_condition_session_rotation_completed_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_condition **condition);
+
+struct lttng_evaluation *lttng_evaluation_session_rotation_ongoing_create(
+                uint64_t id);
+
+/* Ownership of location is transferred to the evaluation. */
+struct lttng_evaluation *lttng_evaluation_session_rotation_completed_create(
+               uint64_t id,
+               struct lttng_trace_archive_location *location);
+
+ssize_t lttng_evaluation_session_rotation_ongoing_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_evaluation **evaluation);
+
+ssize_t lttng_evaluation_session_rotation_completed_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_evaluation **evaluation);
+
+#endif /* LTTNG_CONDITION_SESSION_ROTATION_INTERNAL_H */
diff --git a/include/lttng/domain-internal.h b/include/lttng/domain-internal.h
deleted file mode 100644 (file)
index c34ba19..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (C) 2020 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_DOMAIN_INTERNAL_H
-#define LTTNG_DOMAIN_INTERNAL_H
-
-#include "lttng/domain.h"
-#include "common/macros.h"
-
-const char *lttng_domain_type_str(enum lttng_domain_type domain_type);
-
-#endif /* LTTNG_DOMAIN_INTERNAL_H */
diff --git a/include/lttng/domain-internal.hpp b/include/lttng/domain-internal.hpp
new file mode 100644 (file)
index 0000000..4439c78
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2020 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_DOMAIN_INTERNAL_H
+#define LTTNG_DOMAIN_INTERNAL_H
+
+#include "lttng/domain.h"
+#include "common/macros.hpp"
+
+const char *lttng_domain_type_str(enum lttng_domain_type domain_type);
+
+#endif /* LTTNG_DOMAIN_INTERNAL_H */
diff --git a/include/lttng/endpoint-internal.h b/include/lttng/endpoint-internal.h
deleted file mode 100644 (file)
index 3ec1df9..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ENDPOINT_INTERNAL_H
-#define LTTNG_ENDPOINT_INTERNAL_H
-
-#include <lttng/endpoint.h>
-#include <common/macros.h>
-
-enum lttng_endpoint_type {
-       LTTNG_ENDPOINT_TYPE_DEFAULT_SESSIOND_NOTIFICATION = 0,
-       LTTNG_ENDPOINT_TYPE_DEFAULT_SESSIOND_COMMAND = 1,
-};
-
-struct lttng_endpoint {
-       enum lttng_endpoint_type type;
-};
-
-#endif /* LTTNG_ENDPOINT_INTERNAL_H */
diff --git a/include/lttng/endpoint-internal.hpp b/include/lttng/endpoint-internal.hpp
new file mode 100644 (file)
index 0000000..5317f7f
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ENDPOINT_INTERNAL_H
+#define LTTNG_ENDPOINT_INTERNAL_H
+
+#include <lttng/endpoint.h>
+#include <common/macros.hpp>
+
+enum lttng_endpoint_type {
+       LTTNG_ENDPOINT_TYPE_DEFAULT_SESSIOND_NOTIFICATION = 0,
+       LTTNG_ENDPOINT_TYPE_DEFAULT_SESSIOND_COMMAND = 1,
+};
+
+struct lttng_endpoint {
+       enum lttng_endpoint_type type;
+};
+
+#endif /* LTTNG_ENDPOINT_INTERNAL_H */
diff --git a/include/lttng/error-query-internal.h b/include/lttng/error-query-internal.h
deleted file mode 100644 (file)
index 07e2280..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * error-query-internal.h
- *
- * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ERROR_QUERY_INTERNAL_H
-#define LTTNG_ERROR_QUERY_INTERNAL_H
-
-#include <lttng/lttng.h>
-#include <common/macros.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
-
-struct mi_writer;
-
-enum lttng_error_query_target_type {
-       LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER,
-       LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION,
-       LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION,
-};
-
-enum lttng_error_query_target_type lttng_error_query_get_target_type(
-               const struct lttng_error_query *query);
-
-const struct lttng_trigger *lttng_error_query_trigger_borrow_target(
-               const struct lttng_error_query *query);
-
-const struct lttng_trigger *lttng_error_query_condition_borrow_target(
-               const struct lttng_error_query *query);
-
-const struct lttng_trigger *lttng_error_query_action_borrow_trigger_target(
-               const struct lttng_error_query *query);
-
-struct lttng_action *lttng_error_query_action_borrow_action_target(
-               const struct lttng_error_query *query,
-               struct lttng_trigger *trigger);
-
-int lttng_error_query_serialize(const struct lttng_error_query *query,
-               struct lttng_payload *payload);
-
-ssize_t lttng_error_query_create_from_payload(struct lttng_payload_view *view,
-               struct lttng_error_query **query);
-
-int lttng_error_query_result_serialize(
-               const struct lttng_error_query_result *result,
-               struct lttng_payload *payload);
-
-ssize_t lttng_error_query_result_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_error_query_result **result);
-
-int lttng_error_query_results_serialize(
-               const struct lttng_error_query_results *results,
-               struct lttng_payload *payload);
-
-ssize_t lttng_error_query_results_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_error_query_results **results);
-
-struct lttng_error_query_result *
-lttng_error_query_result_counter_create(
-               const char *name, const char *description, uint64_t value);
-
-void lttng_error_query_result_destroy(struct lttng_error_query_result *result);
-
-struct lttng_error_query_results *lttng_error_query_results_create(void);
-
-/* Ownership of `result` is transferred on success. */
-int lttng_error_query_results_add_result(
-               struct lttng_error_query_results *results,
-               struct lttng_error_query_result *result);
-
-enum lttng_error_code lttng_error_query_results_mi_serialize(
-               const struct lttng_error_query_results *results,
-               struct mi_writer *writer);
-
-#endif /* LTTNG_ERROR_QUERY_INTERNAL_H */
diff --git a/include/lttng/error-query-internal.hpp b/include/lttng/error-query-internal.hpp
new file mode 100644 (file)
index 0000000..7bf4da7
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * error-query-internal.h
+ *
+ * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ERROR_QUERY_INTERNAL_H
+#define LTTNG_ERROR_QUERY_INTERNAL_H
+
+#include <lttng/lttng.h>
+#include <common/macros.hpp>
+#include <common/payload.hpp>
+#include <common/payload-view.hpp>
+
+struct mi_writer;
+
+enum lttng_error_query_target_type {
+       LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER,
+       LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION,
+       LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION,
+};
+
+enum lttng_error_query_target_type lttng_error_query_get_target_type(
+               const struct lttng_error_query *query);
+
+const struct lttng_trigger *lttng_error_query_trigger_borrow_target(
+               const struct lttng_error_query *query);
+
+const struct lttng_trigger *lttng_error_query_condition_borrow_target(
+               const struct lttng_error_query *query);
+
+const struct lttng_trigger *lttng_error_query_action_borrow_trigger_target(
+               const struct lttng_error_query *query);
+
+struct lttng_action *lttng_error_query_action_borrow_action_target(
+               const struct lttng_error_query *query,
+               struct lttng_trigger *trigger);
+
+int lttng_error_query_serialize(const struct lttng_error_query *query,
+               struct lttng_payload *payload);
+
+ssize_t lttng_error_query_create_from_payload(struct lttng_payload_view *view,
+               struct lttng_error_query **query);
+
+int lttng_error_query_result_serialize(
+               const struct lttng_error_query_result *result,
+               struct lttng_payload *payload);
+
+ssize_t lttng_error_query_result_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_error_query_result **result);
+
+int lttng_error_query_results_serialize(
+               const struct lttng_error_query_results *results,
+               struct lttng_payload *payload);
+
+ssize_t lttng_error_query_results_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_error_query_results **results);
+
+struct lttng_error_query_result *
+lttng_error_query_result_counter_create(
+               const char *name, const char *description, uint64_t value);
+
+void lttng_error_query_result_destroy(struct lttng_error_query_result *result);
+
+struct lttng_error_query_results *lttng_error_query_results_create(void);
+
+/* Ownership of `result` is transferred on success. */
+int lttng_error_query_results_add_result(
+               struct lttng_error_query_results *results,
+               struct lttng_error_query_result *result);
+
+enum lttng_error_code lttng_error_query_results_mi_serialize(
+               const struct lttng_error_query_results *results,
+               struct mi_writer *writer);
+
+#endif /* LTTNG_ERROR_QUERY_INTERNAL_H */
diff --git a/include/lttng/event-expr-internal.h b/include/lttng/event-expr-internal.h
deleted file mode 100644 (file)
index 469fd17..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_EXPR_INTERNAL_H
-#define LTTNG_EVENT_EXPR_INTERNAL_H
-
-#include <common/macros.h>
-#include <lttng/event-expr.h>
-
-struct lttng_bytecode;
-struct mi_writer;
-
-struct lttng_event_expr {
-       enum lttng_event_expr_type type;
-};
-
-/*
- * `LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD` and
- * `LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD`.
- */
-struct lttng_event_expr_field {
-       struct lttng_event_expr parent;
-       char *name;
-};
-
-/* `LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD` */
-struct lttng_event_expr_app_specific_context_field {
-       struct lttng_event_expr parent;
-       char *provider_name;
-       char *type_name;
-};
-
-/* `LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT` */
-struct lttng_event_expr_array_field_element {
-       struct lttng_event_expr parent;
-
-       /* Owned by this */
-       struct lttng_event_expr *array_field_expr;
-
-       unsigned int index;
-};
-
-/*
- * Returns whether or not `expr` is an l-value (locator value).
- */
-static inline
-bool lttng_event_expr_is_lvalue(const struct lttng_event_expr *expr)
-{
-       LTTNG_ASSERT(expr);
-       return expr->type == LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD ||
-                       expr->type == LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD ||
-                       expr->type == LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD ||
-                       expr->type == LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT;
-}
-
-int lttng_event_expr_to_bytecode(const struct lttng_event_expr *expr,
-               struct lttng_bytecode **bytecode_out);
-
-enum lttng_error_code lttng_event_expr_mi_serialize(
-               const struct lttng_event_expr *expression,
-               struct mi_writer *writer);
-
-#endif /* LTTNG_EVENT_EXPR_INTERNAL_H */
diff --git a/include/lttng/event-expr-internal.hpp b/include/lttng/event-expr-internal.hpp
new file mode 100644 (file)
index 0000000..07547e5
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_EXPR_INTERNAL_H
+#define LTTNG_EVENT_EXPR_INTERNAL_H
+
+#include <common/macros.hpp>
+#include <lttng/event-expr.h>
+
+struct lttng_bytecode;
+struct mi_writer;
+
+struct lttng_event_expr {
+       enum lttng_event_expr_type type;
+};
+
+/*
+ * `LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD` and
+ * `LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD`.
+ */
+struct lttng_event_expr_field {
+       struct lttng_event_expr parent;
+       char *name;
+};
+
+/* `LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD` */
+struct lttng_event_expr_app_specific_context_field {
+       struct lttng_event_expr parent;
+       char *provider_name;
+       char *type_name;
+};
+
+/* `LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT` */
+struct lttng_event_expr_array_field_element {
+       struct lttng_event_expr parent;
+
+       /* Owned by this */
+       struct lttng_event_expr *array_field_expr;
+
+       unsigned int index;
+};
+
+/*
+ * Returns whether or not `expr` is an l-value (locator value).
+ */
+static inline
+bool lttng_event_expr_is_lvalue(const struct lttng_event_expr *expr)
+{
+       LTTNG_ASSERT(expr);
+       return expr->type == LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD ||
+                       expr->type == LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD ||
+                       expr->type == LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD ||
+                       expr->type == LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT;
+}
+
+int lttng_event_expr_to_bytecode(const struct lttng_event_expr *expr,
+               struct lttng_bytecode **bytecode_out);
+
+enum lttng_error_code lttng_event_expr_mi_serialize(
+               const struct lttng_event_expr *expression,
+               struct mi_writer *writer);
+
+#endif /* LTTNG_EVENT_EXPR_INTERNAL_H */
diff --git a/include/lttng/event-field-value-internal.h b/include/lttng/event-field-value-internal.h
deleted file mode 100644 (file)
index 510420a..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
-#define LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
-
-#include <stdint.h>
-#include <lttng/event-field-value.h>
-#include <common/dynamic-array.h>
-
-struct lttng_event_field_value {
-       enum lttng_event_field_value_type type;
-};
-
-/*
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT`.
- */
-struct lttng_event_field_value_uint {
-       struct lttng_event_field_value parent;
-       uint64_t val;
-};
-
-/*
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT`.
- */
-struct lttng_event_field_value_int {
-       struct lttng_event_field_value parent;
-       int64_t val;
-};
-
-/*
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` and
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM` (base).
- */
-struct lttng_event_field_value_enum {
-       struct lttng_event_field_value parent;
-
-       /*
-        * Array of `char *` (owned by this).
-        */
-       struct lttng_dynamic_pointer_array labels;
-};
-
-/*
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM`.
- */
-struct lttng_event_field_value_enum_uint {
-       struct lttng_event_field_value_enum parent;
-       uint64_t val;
-};
-
-/*
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
- */
-struct lttng_event_field_value_enum_int {
-       struct lttng_event_field_value_enum parent;
-       int64_t val;
-};
-
-/* `LTTNG_EVENT_FIELD_VALUE_TYPE_REAL` */
-struct lttng_event_field_value_real {
-       struct lttng_event_field_value parent;
-       double val;
-};
-
-/* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
-struct lttng_event_field_value_string {
-       struct lttng_event_field_value parent;
-
-       /* Owned by this */
-       char *val;
-};
-
-/* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
-struct lttng_event_field_value_array {
-       struct lttng_event_field_value parent;
-
-       /*
-        * Array of `struct lttng_event_field_value *` (owned by this).
-        *
-        * A `NULL` element means it's unavailable
-        * (`LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` status).
-        */
-       struct lttng_dynamic_pointer_array elems;
-};
-
-/*
- * This is internal since the session daemon knows nothing about the
- * enumeration fields produced by the kernel tracer. Indeed, the kernel tracer
- * manages its own metadata which remains opaque to the rest of the toolchain.
- *
- * Enumerations could be supported for the user space tracer, but it is not the
- * case right now.
- */
-
-/*
- * Sets `*count` to the number of labels of the enumeration event field
- * value `field_val`.
- *
- * Returns:
- *
- * `LTTNG_EVENT_FIELD_VALUE_STATUS_OK`:
- *     Success.
- *
- * `LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID`:
- *     * `field_val` is `NULL`.
- *     * The type of `field_val` is not
- *       `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
- *       `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
- *     * `count` is `NULL`.
- */
-enum lttng_event_field_value_status
-lttng_event_field_value_enum_get_label_count(
-               const struct lttng_event_field_value *field_val,
-               unsigned int *count);
-
-/*
- * Returns the label at index `index` of the enumeration event field
- * value `field_val`, or `NULL` if:
- *
- * * `field_val` is `NULL`.
- * * The type of `field_val` is not
- *   `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
- *   `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
- * * `index` is greater than or equal to the label count of `field_val`,
- *   as returned by lttng_event_field_value_enum_get_label_count().
- */
-const char *lttng_event_field_value_enum_get_label_at_index(
-               const struct lttng_event_field_value *field_val,
-               unsigned int index);
-
-struct lttng_event_field_value *lttng_event_field_value_uint_create(
-               uint64_t val);
-
-struct lttng_event_field_value *lttng_event_field_value_int_create(
-               int64_t val);
-
-struct lttng_event_field_value *lttng_event_field_value_enum_uint_create(
-               uint64_t val);
-
-struct lttng_event_field_value *lttng_event_field_value_enum_int_create(
-               int64_t val);
-
-struct lttng_event_field_value *lttng_event_field_value_real_create(double val);
-
-struct lttng_event_field_value *lttng_event_field_value_string_create(
-               const char *val);
-
-struct lttng_event_field_value *lttng_event_field_value_string_create_with_size(
-               const char *val, size_t size);
-
-struct lttng_event_field_value *lttng_event_field_value_array_create(void);
-
-int lttng_event_field_value_enum_append_label(
-               struct lttng_event_field_value *field_val, const char *label);
-
-int lttng_event_field_value_enum_append_label_with_size(
-               struct lttng_event_field_value *field_val, const char *label,
-               size_t size);
-
-int lttng_event_field_value_array_append(
-               struct lttng_event_field_value *array_field_val,
-               struct lttng_event_field_value *field_val);
-
-int lttng_event_field_value_array_append_unavailable(
-               struct lttng_event_field_value *array_field_val);
-
-void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val);
-
-#endif /* LTTNG_EVENT_FIELD_VALUE_INTERNAL_H */
diff --git a/include/lttng/event-field-value-internal.hpp b/include/lttng/event-field-value-internal.hpp
new file mode 100644 (file)
index 0000000..03ef896
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
+#define LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
+
+#include <stdint.h>
+#include <lttng/event-field-value.h>
+#include <common/dynamic-array.hpp>
+
+struct lttng_event_field_value {
+       enum lttng_event_field_value_type type;
+};
+
+/*
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT`.
+ */
+struct lttng_event_field_value_uint {
+       struct lttng_event_field_value parent;
+       uint64_t val;
+};
+
+/*
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT`.
+ */
+struct lttng_event_field_value_int {
+       struct lttng_event_field_value parent;
+       int64_t val;
+};
+
+/*
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` and
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM` (base).
+ */
+struct lttng_event_field_value_enum {
+       struct lttng_event_field_value parent;
+
+       /*
+        * Array of `char *` (owned by this).
+        */
+       struct lttng_dynamic_pointer_array labels;
+};
+
+/*
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM`.
+ */
+struct lttng_event_field_value_enum_uint {
+       struct lttng_event_field_value_enum parent;
+       uint64_t val;
+};
+
+/*
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
+ */
+struct lttng_event_field_value_enum_int {
+       struct lttng_event_field_value_enum parent;
+       int64_t val;
+};
+
+/* `LTTNG_EVENT_FIELD_VALUE_TYPE_REAL` */
+struct lttng_event_field_value_real {
+       struct lttng_event_field_value parent;
+       double val;
+};
+
+/* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
+struct lttng_event_field_value_string {
+       struct lttng_event_field_value parent;
+
+       /* Owned by this */
+       char *val;
+};
+
+/* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
+struct lttng_event_field_value_array {
+       struct lttng_event_field_value parent;
+
+       /*
+        * Array of `struct lttng_event_field_value *` (owned by this).
+        *
+        * A `NULL` element means it's unavailable
+        * (`LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` status).
+        */
+       struct lttng_dynamic_pointer_array elems;
+};
+
+/*
+ * This is internal since the session daemon knows nothing about the
+ * enumeration fields produced by the kernel tracer. Indeed, the kernel tracer
+ * manages its own metadata which remains opaque to the rest of the toolchain.
+ *
+ * Enumerations could be supported for the user space tracer, but it is not the
+ * case right now.
+ */
+
+/*
+ * Sets `*count` to the number of labels of the enumeration event field
+ * value `field_val`.
+ *
+ * Returns:
+ *
+ * `LTTNG_EVENT_FIELD_VALUE_STATUS_OK`:
+ *     Success.
+ *
+ * `LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID`:
+ *     * `field_val` is `NULL`.
+ *     * The type of `field_val` is not
+ *       `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
+ *       `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
+ *     * `count` is `NULL`.
+ */
+enum lttng_event_field_value_status
+lttng_event_field_value_enum_get_label_count(
+               const struct lttng_event_field_value *field_val,
+               unsigned int *count);
+
+/*
+ * Returns the label at index `index` of the enumeration event field
+ * value `field_val`, or `NULL` if:
+ *
+ * * `field_val` is `NULL`.
+ * * The type of `field_val` is not
+ *   `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
+ *   `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
+ * * `index` is greater than or equal to the label count of `field_val`,
+ *   as returned by lttng_event_field_value_enum_get_label_count().
+ */
+const char *lttng_event_field_value_enum_get_label_at_index(
+               const struct lttng_event_field_value *field_val,
+               unsigned int index);
+
+struct lttng_event_field_value *lttng_event_field_value_uint_create(
+               uint64_t val);
+
+struct lttng_event_field_value *lttng_event_field_value_int_create(
+               int64_t val);
+
+struct lttng_event_field_value *lttng_event_field_value_enum_uint_create(
+               uint64_t val);
+
+struct lttng_event_field_value *lttng_event_field_value_enum_int_create(
+               int64_t val);
+
+struct lttng_event_field_value *lttng_event_field_value_real_create(double val);
+
+struct lttng_event_field_value *lttng_event_field_value_string_create(
+               const char *val);
+
+struct lttng_event_field_value *lttng_event_field_value_string_create_with_size(
+               const char *val, size_t size);
+
+struct lttng_event_field_value *lttng_event_field_value_array_create(void);
+
+int lttng_event_field_value_enum_append_label(
+               struct lttng_event_field_value *field_val, const char *label);
+
+int lttng_event_field_value_enum_append_label_with_size(
+               struct lttng_event_field_value *field_val, const char *label,
+               size_t size);
+
+int lttng_event_field_value_array_append(
+               struct lttng_event_field_value *array_field_val,
+               struct lttng_event_field_value *field_val);
+
+int lttng_event_field_value_array_append_unavailable(
+               struct lttng_event_field_value *array_field_val);
+
+void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val);
+
+#endif /* LTTNG_EVENT_FIELD_VALUE_INTERNAL_H */
diff --git a/include/lttng/event-internal.h b/include/lttng/event-internal.h
deleted file mode 100644 (file)
index 52f7f78..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * event-internal.h
- *
- * Linux Trace Toolkit Control Library
- *
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_INTERNAL_H
-#define LTTNG_EVENT_INTERNAL_H
-
-#include <common/macros.h>
-#include <lttng/event.h>
-#include <lttng/lttng-error.h>
-
-struct lttng_event_exclusion;
-struct lttng_userspace_probe_location;
-struct lttng_dynamic_buffer;
-struct lttng_buffer_view;
-
-struct lttng_event_comm {
-       int8_t event_type;
-       int8_t loglevel_type;
-       int32_t loglevel;
-       int8_t enabled;
-       int32_t pid;
-       uint32_t flags;
-
-       /* Payload. */
-       /* Includes terminator `\0`. */
-       uint32_t name_len;
-       uint32_t exclusion_count;
-       /* Includes terminator `\0`. */
-       uint32_t filter_expression_len;
-       uint32_t bytecode_len;
-
-       /* Type specific payload. */
-       uint32_t userspace_probe_location_len;
-       uint32_t lttng_event_probe_attr_len;
-       uint32_t lttng_event_function_attr_len;
-
-       /*
-        * Contain:
-        * - name [name_len],
-        * - exclusions if any
-        * - char filter_expression[filter_expression_len],
-        * - unsigned char filter_bytecode[bytecode_len],
-        * - userspace probe location [userspace_probe_location_len],
-        * - probe or ftrace based on event type.
-        */
-
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_exclusion_comm {
-       /* Includes terminator `\0`. */
-       uint32_t len;
-       char payload [];
-} LTTNG_PACKED;
-
-struct lttng_event_probe_attr_comm {
-       uint64_t addr;
-       uint64_t offset;
-       /* Includes terminator `\0`. */
-       uint32_t symbol_name_len;
-
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_function_attr_comm {
-       /* Includes terminator `\0`. */
-       uint32_t symbol_name_len;
-
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_context_comm {
-       uint32_t type;
-       /*
-        * Depending on the type.
-        * For:
-        *  - LTTNG_EVENT_CONTEXT_APP_CONTEXT.
-        *
-        *  -> struct lttng_event_context_app_comm
-        *
-        * For
-        *  - LTTNG_EVENT_CONTEXT_PERF_COUNTER,
-        *  - LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER,
-        *  - LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER.
-        *
-        *  -> struct lttng_event_context_perf_counter_comm
-        *
-        *  Other type -> no payload.
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_context_perf_counter_comm {
-       uint32_t type;
-       uint64_t config;
-       /* Includes terminator `\0`. */
-       uint32_t name_len;
-       /*
-        * char name [name_len]
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_context_app_comm {
-       /* Includes terminator `\0`. */
-       uint32_t provider_name_len;
-       /* Includes terminator `\0`. */
-       uint32_t ctx_name_len;
-       /*
-        * provider name [provider_name_len]
-        * ctx name [ctx_name_len]
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_field_comm {
-       uint8_t type;
-       uint8_t nowrite;
-       /* Includes terminator `\0`. */
-       uint32_t name_len;
-       uint32_t event_len;
-
-       /*
-        * - name [name_len]
-        * - lttng_event object
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_extended {
-       /*
-        * exclusions and filter_expression are only set when the lttng_event
-        * was created/allocated by a list operation. These two elements must
-        * not be free'd as they are part of the same contiguous buffer that
-        * contains all events returned by the listing.
-        */
-       char *filter_expression;
-       struct {
-               unsigned int count;
-               /* Array of strings of fixed LTTNG_SYMBOL_NAME_LEN length. */
-               char *strings;
-       } exclusions;
-       struct lttng_userspace_probe_location *probe_location;
-};
-
-struct lttng_event *lttng_event_copy(const struct lttng_event *event);
-
-ssize_t lttng_event_create_from_payload(struct lttng_payload_view *view,
-               struct lttng_event **out_event,
-               struct lttng_event_exclusion **out_exclusion,
-               char **out_filter_expression,
-               struct lttng_bytecode **out_bytecode);
-
-int lttng_event_serialize(const struct lttng_event *event,
-               unsigned int exclusion_count,
-               char **exclusion_list,
-               char *filter_expression,
-               size_t bytecode_len,
-               struct lttng_bytecode *bytecode,
-               struct lttng_payload *payload);
-
-ssize_t lttng_event_context_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_event_context **event_ctx);
-
-int lttng_event_context_serialize(struct lttng_event_context *context,
-               struct lttng_payload *payload);
-
-void lttng_event_context_destroy(struct lttng_event_context *context);
-
-enum lttng_error_code lttng_events_create_and_flatten_from_payload(
-               struct lttng_payload_view *view,
-               unsigned int count,
-               struct lttng_event **events);
-
-ssize_t lttng_event_field_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_event_field **field);
-
-int lttng_event_field_serialize(const struct lttng_event_field *field,
-               struct lttng_payload *payload);
-
-enum lttng_error_code lttng_event_fields_create_and_flatten_from_payload(
-               struct lttng_payload_view *view,
-               unsigned int count,
-               struct lttng_event_field **fields);
-
-#endif /* LTTNG_EVENT_INTERNAL_H */
diff --git a/include/lttng/event-internal.hpp b/include/lttng/event-internal.hpp
new file mode 100644 (file)
index 0000000..daa8fa6
--- /dev/null
@@ -0,0 +1,196 @@
+/*
+ * event-internal.h
+ *
+ * Linux Trace Toolkit Control Library
+ *
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_INTERNAL_H
+#define LTTNG_EVENT_INTERNAL_H
+
+#include <common/macros.hpp>
+#include <lttng/event.h>
+#include <lttng/lttng-error.h>
+
+struct lttng_event_exclusion;
+struct lttng_userspace_probe_location;
+struct lttng_dynamic_buffer;
+struct lttng_buffer_view;
+
+struct lttng_event_comm {
+       int8_t event_type;
+       int8_t loglevel_type;
+       int32_t loglevel;
+       int8_t enabled;
+       int32_t pid;
+       uint32_t flags;
+
+       /* Payload. */
+       /* Includes terminator `\0`. */
+       uint32_t name_len;
+       uint32_t exclusion_count;
+       /* Includes terminator `\0`. */
+       uint32_t filter_expression_len;
+       uint32_t bytecode_len;
+
+       /* Type specific payload. */
+       uint32_t userspace_probe_location_len;
+       uint32_t lttng_event_probe_attr_len;
+       uint32_t lttng_event_function_attr_len;
+
+       /*
+        * Contain:
+        * - name [name_len],
+        * - exclusions if any
+        * - char filter_expression[filter_expression_len],
+        * - unsigned char filter_bytecode[bytecode_len],
+        * - userspace probe location [userspace_probe_location_len],
+        * - probe or ftrace based on event type.
+        */
+
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_exclusion_comm {
+       /* Includes terminator `\0`. */
+       uint32_t len;
+       char payload [];
+} LTTNG_PACKED;
+
+struct lttng_event_probe_attr_comm {
+       uint64_t addr;
+       uint64_t offset;
+       /* Includes terminator `\0`. */
+       uint32_t symbol_name_len;
+
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_function_attr_comm {
+       /* Includes terminator `\0`. */
+       uint32_t symbol_name_len;
+
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_context_comm {
+       uint32_t type;
+       /*
+        * Depending on the type.
+        * For:
+        *  - LTTNG_EVENT_CONTEXT_APP_CONTEXT.
+        *
+        *  -> struct lttng_event_context_app_comm
+        *
+        * For
+        *  - LTTNG_EVENT_CONTEXT_PERF_COUNTER,
+        *  - LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER,
+        *  - LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER.
+        *
+        *  -> struct lttng_event_context_perf_counter_comm
+        *
+        *  Other type -> no payload.
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_context_perf_counter_comm {
+       uint32_t type;
+       uint64_t config;
+       /* Includes terminator `\0`. */
+       uint32_t name_len;
+       /*
+        * char name [name_len]
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_context_app_comm {
+       /* Includes terminator `\0`. */
+       uint32_t provider_name_len;
+       /* Includes terminator `\0`. */
+       uint32_t ctx_name_len;
+       /*
+        * provider name [provider_name_len]
+        * ctx name [ctx_name_len]
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_field_comm {
+       uint8_t type;
+       uint8_t nowrite;
+       /* Includes terminator `\0`. */
+       uint32_t name_len;
+       uint32_t event_len;
+
+       /*
+        * - name [name_len]
+        * - lttng_event object
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_extended {
+       /*
+        * exclusions and filter_expression are only set when the lttng_event
+        * was created/allocated by a list operation. These two elements must
+        * not be free'd as they are part of the same contiguous buffer that
+        * contains all events returned by the listing.
+        */
+       char *filter_expression;
+       struct {
+               unsigned int count;
+               /* Array of strings of fixed LTTNG_SYMBOL_NAME_LEN length. */
+               char *strings;
+       } exclusions;
+       struct lttng_userspace_probe_location *probe_location;
+};
+
+struct lttng_event *lttng_event_copy(const struct lttng_event *event);
+
+ssize_t lttng_event_create_from_payload(struct lttng_payload_view *view,
+               struct lttng_event **out_event,
+               struct lttng_event_exclusion **out_exclusion,
+               char **out_filter_expression,
+               struct lttng_bytecode **out_bytecode);
+
+int lttng_event_serialize(const struct lttng_event *event,
+               unsigned int exclusion_count,
+               char **exclusion_list,
+               char *filter_expression,
+               size_t bytecode_len,
+               struct lttng_bytecode *bytecode,
+               struct lttng_payload *payload);
+
+ssize_t lttng_event_context_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_event_context **event_ctx);
+
+int lttng_event_context_serialize(struct lttng_event_context *context,
+               struct lttng_payload *payload);
+
+void lttng_event_context_destroy(struct lttng_event_context *context);
+
+enum lttng_error_code lttng_events_create_and_flatten_from_payload(
+               struct lttng_payload_view *view,
+               unsigned int count,
+               struct lttng_event **events);
+
+ssize_t lttng_event_field_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_event_field **field);
+
+int lttng_event_field_serialize(const struct lttng_event_field *field,
+               struct lttng_payload *payload);
+
+enum lttng_error_code lttng_event_fields_create_and_flatten_from_payload(
+               struct lttng_payload_view *view,
+               unsigned int count,
+               struct lttng_event_field **fields);
+
+#endif /* LTTNG_EVENT_INTERNAL_H */
diff --git a/include/lttng/event-rule/event-rule-internal.h b/include/lttng/event-rule/event-rule-internal.h
deleted file mode 100644 (file)
index 8026748..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_INTERNAL_H
-#define LTTNG_EVENT_RULE_INTERNAL_H
-
-#include <common/macros.h>
-#include <common/credentials.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/domain.h>
-#include <lttng/event.h>
-#include <lttng/event-rule/event-rule.h>
-#include <lttng/lttng-error.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <urcu/ref.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-struct mi_writer;
-
-enum lttng_event_rule_generate_exclusions_status {
-       LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OK,
-       LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE,
-       LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_ERROR,
-       LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OUT_OF_MEMORY,
-};
-
-typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
-typedef bool (*event_rule_validate_cb)(
-               const struct lttng_event_rule *event_rule);
-typedef int (*event_rule_serialize_cb)(
-               const struct lttng_event_rule *event_rule,
-               struct lttng_payload *payload);
-typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a,
-               const struct lttng_event_rule *b);
-typedef ssize_t (*event_rule_create_from_payload_cb)(
-               struct lttng_payload_view *view,
-               struct lttng_event_rule **event_rule);
-typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)(
-               struct lttng_event_rule *event_rule,
-               const struct lttng_credentials *creds);
-typedef const char *(*event_rule_get_filter_cb)(
-               const struct lttng_event_rule *event_rule);
-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 (
-               *event_rule_generate_exclusions_cb)(
-               const struct lttng_event_rule *event_rule,
-               struct lttng_event_exclusion **exclusions);
-typedef unsigned long (*event_rule_hash_cb)(
-               const struct lttng_event_rule *event_rule);
-typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
-               const struct lttng_event_rule *event_rule);
-typedef enum lttng_error_code (*event_rule_mi_serialize_cb)(
-               const struct lttng_event_rule *event_rule,
-               struct mi_writer *writer);
-
-struct lttng_event_rule {
-       struct urcu_ref ref;
-       enum lttng_event_rule_type type;
-       event_rule_validate_cb validate;
-       event_rule_serialize_cb serialize;
-       event_rule_equal_cb equal;
-       event_rule_destroy_cb destroy;
-       event_rule_generate_filter_bytecode_cb generate_filter_bytecode;
-       event_rule_get_filter_cb get_filter;
-       event_rule_get_filter_bytecode_cb get_filter_bytecode;
-       event_rule_generate_exclusions_cb generate_exclusions;
-       event_rule_hash_cb hash;
-       event_rule_generate_lttng_event_cb generate_lttng_event;
-       event_rule_mi_serialize_cb mi_serialize;
-};
-
-struct lttng_event_rule_comm {
-       /* enum lttng_event_rule_type */
-       int8_t event_rule_type;
-       char payload[];
-};
-
-void lttng_event_rule_init(struct lttng_event_rule *event_rule,
-               enum lttng_event_rule_type type);
-
-bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule);
-
-ssize_t lttng_event_rule_create_from_payload(
-               struct lttng_payload_view *payload,
-               struct lttng_event_rule **event_rule);
-
-int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
-               struct lttng_payload *payload);
-
-bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
-               const struct lttng_event_rule *b);
-
-bool lttng_event_rule_get(struct lttng_event_rule *rule);
-
-void lttng_event_rule_put(struct lttng_event_rule *rule);
-
-enum lttng_domain_type lttng_event_rule_get_domain_type(
-               const struct lttng_event_rule *rule);
-
-enum lttng_error_code lttng_event_rule_generate_filter_bytecode(
-               struct lttng_event_rule *rule,
-               const struct lttng_credentials *creds);
-
-/*
- * If not present/implemented returns NULL.
- * Caller DOES NOT own the returned object.
- */
-const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule);
-
-/*
- * If not present/implemented returns NULL.
- * Caller DOES NOT own the returned object.
- */
-const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode(
-               const struct lttng_event_rule *rule);
-
-/*
- * If not present/implemented return NULL.
- * Caller OWNS the returned object.
- */
-enum lttng_event_rule_generate_exclusions_status
-lttng_event_rule_generate_exclusions(const struct lttng_event_rule *rule,
-               struct lttng_event_exclusion **exclusions);
-
-const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
-
-unsigned long lttng_event_rule_hash(const struct lttng_event_rule *rule);
-
-/*
- * This is a compatibility helper allowing us to generate a sessiond-side (not
- * communication) `struct lttng_event` object from an event rule.
- *
- * This effectively bridges older parts of the code using those structures and
- * new event-rule based code.
- *
- * The caller owns the returned object.
- */
-struct lttng_event *lttng_event_rule_generate_lttng_event(
-               const struct lttng_event_rule *rule);
-
-/* Test if an event rule targets an agent domain. */
-bool lttng_event_rule_targets_agent_domain(const struct lttng_event_rule *rule);
-
-enum lttng_error_code lttng_event_rule_mi_serialize(
-               const struct lttng_event_rule *rule, struct mi_writer *writer);
-
-#endif /* LTTNG_EVENT_RULE_INTERNAL_H */
diff --git a/include/lttng/event-rule/event-rule-internal.hpp b/include/lttng/event-rule/event-rule-internal.hpp
new file mode 100644 (file)
index 0000000..46fb981
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_INTERNAL_H
+#define LTTNG_EVENT_RULE_INTERNAL_H
+
+#include <common/macros.hpp>
+#include <common/credentials.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/domain.h>
+#include <lttng/event.h>
+#include <lttng/event-rule/event-rule.h>
+#include <lttng/lttng-error.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <urcu/ref.h>
+
+struct lttng_payload;
+struct lttng_payload_view;
+struct mi_writer;
+
+enum lttng_event_rule_generate_exclusions_status {
+       LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OK,
+       LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE,
+       LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_ERROR,
+       LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OUT_OF_MEMORY,
+};
+
+typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
+typedef bool (*event_rule_validate_cb)(
+               const struct lttng_event_rule *event_rule);
+typedef int (*event_rule_serialize_cb)(
+               const struct lttng_event_rule *event_rule,
+               struct lttng_payload *payload);
+typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a,
+               const struct lttng_event_rule *b);
+typedef ssize_t (*event_rule_create_from_payload_cb)(
+               struct lttng_payload_view *view,
+               struct lttng_event_rule **event_rule);
+typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)(
+               struct lttng_event_rule *event_rule,
+               const struct lttng_credentials *creds);
+typedef const char *(*event_rule_get_filter_cb)(
+               const struct lttng_event_rule *event_rule);
+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 (
+               *event_rule_generate_exclusions_cb)(
+               const struct lttng_event_rule *event_rule,
+               struct lttng_event_exclusion **exclusions);
+typedef unsigned long (*event_rule_hash_cb)(
+               const struct lttng_event_rule *event_rule);
+typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
+               const struct lttng_event_rule *event_rule);
+typedef enum lttng_error_code (*event_rule_mi_serialize_cb)(
+               const struct lttng_event_rule *event_rule,
+               struct mi_writer *writer);
+
+struct lttng_event_rule {
+       struct urcu_ref ref;
+       enum lttng_event_rule_type type;
+       event_rule_validate_cb validate;
+       event_rule_serialize_cb serialize;
+       event_rule_equal_cb equal;
+       event_rule_destroy_cb destroy;
+       event_rule_generate_filter_bytecode_cb generate_filter_bytecode;
+       event_rule_get_filter_cb get_filter;
+       event_rule_get_filter_bytecode_cb get_filter_bytecode;
+       event_rule_generate_exclusions_cb generate_exclusions;
+       event_rule_hash_cb hash;
+       event_rule_generate_lttng_event_cb generate_lttng_event;
+       event_rule_mi_serialize_cb mi_serialize;
+};
+
+struct lttng_event_rule_comm {
+       /* enum lttng_event_rule_type */
+       int8_t event_rule_type;
+       char payload[];
+};
+
+void lttng_event_rule_init(struct lttng_event_rule *event_rule,
+               enum lttng_event_rule_type type);
+
+bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule);
+
+ssize_t lttng_event_rule_create_from_payload(
+               struct lttng_payload_view *payload,
+               struct lttng_event_rule **event_rule);
+
+int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
+               struct lttng_payload *payload);
+
+bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
+               const struct lttng_event_rule *b);
+
+bool lttng_event_rule_get(struct lttng_event_rule *rule);
+
+void lttng_event_rule_put(struct lttng_event_rule *rule);
+
+enum lttng_domain_type lttng_event_rule_get_domain_type(
+               const struct lttng_event_rule *rule);
+
+enum lttng_error_code lttng_event_rule_generate_filter_bytecode(
+               struct lttng_event_rule *rule,
+               const struct lttng_credentials *creds);
+
+/*
+ * If not present/implemented returns NULL.
+ * Caller DOES NOT own the returned object.
+ */
+const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule);
+
+/*
+ * If not present/implemented returns NULL.
+ * Caller DOES NOT own the returned object.
+ */
+const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode(
+               const struct lttng_event_rule *rule);
+
+/*
+ * If not present/implemented return NULL.
+ * Caller OWNS the returned object.
+ */
+enum lttng_event_rule_generate_exclusions_status
+lttng_event_rule_generate_exclusions(const struct lttng_event_rule *rule,
+               struct lttng_event_exclusion **exclusions);
+
+const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
+
+unsigned long lttng_event_rule_hash(const struct lttng_event_rule *rule);
+
+/*
+ * This is a compatibility helper allowing us to generate a sessiond-side (not
+ * communication) `struct lttng_event` object from an event rule.
+ *
+ * This effectively bridges older parts of the code using those structures and
+ * new event-rule based code.
+ *
+ * The caller owns the returned object.
+ */
+struct lttng_event *lttng_event_rule_generate_lttng_event(
+               const struct lttng_event_rule *rule);
+
+/* Test if an event rule targets an agent domain. */
+bool lttng_event_rule_targets_agent_domain(const struct lttng_event_rule *rule);
+
+enum lttng_error_code lttng_event_rule_mi_serialize(
+               const struct lttng_event_rule *rule, struct mi_writer *writer);
+
+#endif /* LTTNG_EVENT_RULE_INTERNAL_H */
diff --git a/include/lttng/event-rule/jul-logging-internal.h b/include/lttng/event-rule/jul-logging-internal.h
deleted file mode 100644 (file)
index 21a99eb..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_JUL_LOGGING_INTERNAL_H
-#define LTTNG_EVENT_RULE_JUL_LOGGING_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/jul-logging.h>
-#include <lttng/event.h>
-#include <lttng/log-level-rule-internal.h>
-
-struct lttng_event_rule_jul_logging {
-       struct lttng_event_rule parent;
-
-       /* Name pattern. */
-       char *pattern;
-
-       /* Filter. */
-       char *filter_expression;
-
-       /* Log level. */
-       struct lttng_log_level_rule *log_level_rule;
-
-       /* internal use only. */
-       struct {
-               char *filter;
-               struct lttng_bytecode *bytecode;
-       } internal_filter;
-};
-
-struct lttng_event_rule_jul_logging_comm {
-       /* Includes terminator `\0`. */
-       uint32_t pattern_len;
-       /* Includes terminator `\0`. */
-       uint32_t filter_expression_len;
-       /*  enum lttng_log_level_rule_comm + payload if any */
-       uint32_t log_level_rule_len;
-       /*
-        * Payload is composed of, in that order:
-        *   - pattern (null terminated),
-        *   - filter expression (null terminated),
-        *   - log level rule serialized object,
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_jul_logging_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_JUL_LOGGING_INTERNAL_H */
diff --git a/include/lttng/event-rule/jul-logging-internal.hpp b/include/lttng/event-rule/jul-logging-internal.hpp
new file mode 100644 (file)
index 0000000..b769f0f
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_JUL_LOGGING_INTERNAL_H
+#define LTTNG_EVENT_RULE_JUL_LOGGING_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/jul-logging.h>
+#include <lttng/event.h>
+#include <lttng/log-level-rule-internal.hpp>
+
+struct lttng_event_rule_jul_logging {
+       struct lttng_event_rule parent;
+
+       /* Name pattern. */
+       char *pattern;
+
+       /* Filter. */
+       char *filter_expression;
+
+       /* Log level. */
+       struct lttng_log_level_rule *log_level_rule;
+
+       /* internal use only. */
+       struct {
+               char *filter;
+               struct lttng_bytecode *bytecode;
+       } internal_filter;
+};
+
+struct lttng_event_rule_jul_logging_comm {
+       /* Includes terminator `\0`. */
+       uint32_t pattern_len;
+       /* Includes terminator `\0`. */
+       uint32_t filter_expression_len;
+       /*  enum lttng_log_level_rule_comm + payload if any */
+       uint32_t log_level_rule_len;
+       /*
+        * Payload is composed of, in that order:
+        *   - pattern (null terminated),
+        *   - filter expression (null terminated),
+        *   - log level rule serialized object,
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_jul_logging_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_JUL_LOGGING_INTERNAL_H */
diff --git a/include/lttng/event-rule/kernel-kprobe-internal.h b/include/lttng/event-rule/kernel-kprobe-internal.h
deleted file mode 100644 (file)
index 16ac2bd..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H
-#define LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-kprobe.h>
-
-struct lttng_event_rule_kernel_kprobe {
-       struct lttng_event_rule parent;
-       char *name;
-       struct lttng_kernel_probe_location *location;
-};
-
-struct lttng_event_rule_kernel_kprobe_comm {
-       /* Includes terminator `\0`. */
-       uint32_t name_len;
-       uint32_t location_len;
-       /*
-        * Payload is composed of, in that order:
-        *   - name (null terminated),
-        *   - kernel probe location object.
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_kernel_kprobe_create_from_payload(
-               struct lttng_payload_view *payload,
-               struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H */
diff --git a/include/lttng/event-rule/kernel-kprobe-internal.hpp b/include/lttng/event-rule/kernel-kprobe-internal.hpp
new file mode 100644 (file)
index 0000000..5b49979
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H
+#define LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-kprobe.h>
+
+struct lttng_event_rule_kernel_kprobe {
+       struct lttng_event_rule parent;
+       char *name;
+       struct lttng_kernel_probe_location *location;
+};
+
+struct lttng_event_rule_kernel_kprobe_comm {
+       /* Includes terminator `\0`. */
+       uint32_t name_len;
+       uint32_t location_len;
+       /*
+        * Payload is composed of, in that order:
+        *   - name (null terminated),
+        *   - kernel probe location object.
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_kernel_kprobe_create_from_payload(
+               struct lttng_payload_view *payload,
+               struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H */
diff --git a/include/lttng/event-rule/kernel-syscall-internal.h b/include/lttng/event-rule/kernel-syscall-internal.h
deleted file mode 100644 (file)
index 3012381..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_KERNEL_SYSCALL_INTERNAL_H
-#define LTTNG_EVENT_RULE_KERNEL_SYSCALL_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-syscall.h>
-
-struct lttng_event_rule_kernel_syscall {
-       struct lttng_event_rule parent;
-       enum lttng_event_rule_kernel_syscall_emission_site emission_site;
-       char *pattern;
-       char *filter_expression;
-
-       /* Internal use only. */
-       struct {
-               char *filter;
-               struct lttng_bytecode *bytecode;
-       } internal_filter;
-};
-
-struct lttng_event_rule_kernel_syscall_comm {
-       uint32_t emission_site;
-       /* Includes terminator `\0`. */
-       uint32_t pattern_len;
-       /* Includes terminator `\0`. */
-       uint32_t filter_expression_len;
-       /*
-        * Payload is composed of, in that order:
-        *   - Pattern (null terminated),
-        *   - Filter expression (null terminated).
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_kernel_syscall_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_event_rule **rule);
-
-const char *lttng_event_rule_kernel_syscall_emission_site_str(
-               enum lttng_event_rule_kernel_syscall_emission_site emission_site);
-
-#endif /* LTTNG_EVENT_RULE_KERNEL_SYSCALL_INTERNAL_H */
diff --git a/include/lttng/event-rule/kernel-syscall-internal.hpp b/include/lttng/event-rule/kernel-syscall-internal.hpp
new file mode 100644 (file)
index 0000000..2ca1823
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_KERNEL_SYSCALL_INTERNAL_H
+#define LTTNG_EVENT_RULE_KERNEL_SYSCALL_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-syscall.h>
+
+struct lttng_event_rule_kernel_syscall {
+       struct lttng_event_rule parent;
+       enum lttng_event_rule_kernel_syscall_emission_site emission_site;
+       char *pattern;
+       char *filter_expression;
+
+       /* Internal use only. */
+       struct {
+               char *filter;
+               struct lttng_bytecode *bytecode;
+       } internal_filter;
+};
+
+struct lttng_event_rule_kernel_syscall_comm {
+       uint32_t emission_site;
+       /* Includes terminator `\0`. */
+       uint32_t pattern_len;
+       /* Includes terminator `\0`. */
+       uint32_t filter_expression_len;
+       /*
+        * Payload is composed of, in that order:
+        *   - Pattern (null terminated),
+        *   - Filter expression (null terminated).
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_kernel_syscall_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_event_rule **rule);
+
+const char *lttng_event_rule_kernel_syscall_emission_site_str(
+               enum lttng_event_rule_kernel_syscall_emission_site emission_site);
+
+#endif /* LTTNG_EVENT_RULE_KERNEL_SYSCALL_INTERNAL_H */
diff --git a/include/lttng/event-rule/kernel-tracepoint-internal.h b/include/lttng/event-rule/kernel-tracepoint-internal.h
deleted file mode 100644 (file)
index e16596e..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_KERNEL_TRACEPOINT_INTERNAL_H
-#define LTTNG_EVENT_RULE_KERNEL_TRACEPOINT_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-tracepoint.h>
-#include <lttng/event.h>
-
-struct lttng_event_rule_kernel_tracepoint {
-       struct lttng_event_rule parent;
-
-       /* Name pattern. */
-       char *pattern;
-
-       /* Filter. */
-       char *filter_expression;
-
-       /* internal use only. */
-       struct {
-               char *filter;
-               struct lttng_bytecode *bytecode;
-       } internal_filter;
-};
-
-struct lttng_event_rule_kernel_tracepoint_comm {
-       /* Includes terminator `\0`. */
-       uint32_t pattern_len;
-       /* Includes terminator `\0`. */
-       uint32_t filter_expression_len;
-       /*
-        * Payload is composed of, in that order:
-        *   - pattern (null terminated),
-        *   - filter expression (null terminated),
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_kernel_tracepoint_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_KERNEL_TRACEPOINT_INTERNAL_H */
diff --git a/include/lttng/event-rule/kernel-tracepoint-internal.hpp b/include/lttng/event-rule/kernel-tracepoint-internal.hpp
new file mode 100644 (file)
index 0000000..d800eef
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_KERNEL_TRACEPOINT_INTERNAL_H
+#define LTTNG_EVENT_RULE_KERNEL_TRACEPOINT_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-tracepoint.h>
+#include <lttng/event.h>
+
+struct lttng_event_rule_kernel_tracepoint {
+       struct lttng_event_rule parent;
+
+       /* Name pattern. */
+       char *pattern;
+
+       /* Filter. */
+       char *filter_expression;
+
+       /* internal use only. */
+       struct {
+               char *filter;
+               struct lttng_bytecode *bytecode;
+       } internal_filter;
+};
+
+struct lttng_event_rule_kernel_tracepoint_comm {
+       /* Includes terminator `\0`. */
+       uint32_t pattern_len;
+       /* Includes terminator `\0`. */
+       uint32_t filter_expression_len;
+       /*
+        * Payload is composed of, in that order:
+        *   - pattern (null terminated),
+        *   - filter expression (null terminated),
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_kernel_tracepoint_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_KERNEL_TRACEPOINT_INTERNAL_H */
diff --git a/include/lttng/event-rule/kernel-uprobe-internal.h b/include/lttng/event-rule/kernel-uprobe-internal.h
deleted file mode 100644 (file)
index d8ce557..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H
-#define LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-uprobe.h>
-
-struct lttng_event_rule_kernel_uprobe {
-       struct lttng_event_rule parent;
-       char *name;
-       struct lttng_userspace_probe_location *location;
-};
-
-struct lttng_event_rule_kernel_uprobe_comm {
-       /* Includes terminator `\0`. */
-       uint32_t name_len;
-       /* Includes terminator `\0`. */
-       uint32_t location_len;
-       /*
-        * Payload is composed of, in that order:
-        *   - name (null terminated),
-        *   - user space probe location object.
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_kernel_uprobe_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_event_rule **rule);
-
-struct lttng_userspace_probe_location *
-lttng_event_rule_kernel_uprobe_get_location_mutable(
-               const struct lttng_event_rule *rule);
-
-#endif /* LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H */
diff --git a/include/lttng/event-rule/kernel-uprobe-internal.hpp b/include/lttng/event-rule/kernel-uprobe-internal.hpp
new file mode 100644 (file)
index 0000000..f9a1931
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H
+#define LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-uprobe.h>
+
+struct lttng_event_rule_kernel_uprobe {
+       struct lttng_event_rule parent;
+       char *name;
+       struct lttng_userspace_probe_location *location;
+};
+
+struct lttng_event_rule_kernel_uprobe_comm {
+       /* Includes terminator `\0`. */
+       uint32_t name_len;
+       /* Includes terminator `\0`. */
+       uint32_t location_len;
+       /*
+        * Payload is composed of, in that order:
+        *   - name (null terminated),
+        *   - user space probe location object.
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_kernel_uprobe_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_event_rule **rule);
+
+struct lttng_userspace_probe_location *
+lttng_event_rule_kernel_uprobe_get_location_mutable(
+               const struct lttng_event_rule *rule);
+
+#endif /* LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H */
diff --git a/include/lttng/event-rule/log4j-logging-internal.h b/include/lttng/event-rule/log4j-logging-internal.h
deleted file mode 100644 (file)
index 7a1ac28..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_LOG4J_LOGGING_INTERNAL_H
-#define LTTNG_EVENT_RULE_LOG4J_LOGGING_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/log4j-logging.h>
-#include <lttng/event.h>
-#include <lttng/log-level-rule-internal.h>
-
-struct lttng_event_rule_log4j_logging {
-       struct lttng_event_rule parent;
-
-       /* Name pattern. */
-       char *pattern;
-
-       /* Filter. */
-       char *filter_expression;
-
-       /* Log level. */
-       struct lttng_log_level_rule *log_level_rule;
-
-       /* internal use only. */
-       struct {
-               char *filter;
-               struct lttng_bytecode *bytecode;
-       } internal_filter;
-};
-
-struct lttng_event_rule_log4j_logging_comm {
-       /* Includes terminator `\0`. */
-       uint32_t pattern_len;
-       /* Includes terminator `\0`. */
-       uint32_t filter_expression_len;
-       /*  enum lttng_log_level_rule_comm + payload if any */
-       uint32_t log_level_rule_len;
-       /*
-        * Payload is composed of, in that order:
-        *   - pattern (null terminated),
-        *   - filter expression (null terminated),
-        *   - log level rule serialized object,
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_log4j_logging_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_LOG4J_LOGGING_INTERNAL_H */
diff --git a/include/lttng/event-rule/log4j-logging-internal.hpp b/include/lttng/event-rule/log4j-logging-internal.hpp
new file mode 100644 (file)
index 0000000..a65e74b
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_LOG4J_LOGGING_INTERNAL_H
+#define LTTNG_EVENT_RULE_LOG4J_LOGGING_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/log4j-logging.h>
+#include <lttng/event.h>
+#include <lttng/log-level-rule-internal.hpp>
+
+struct lttng_event_rule_log4j_logging {
+       struct lttng_event_rule parent;
+
+       /* Name pattern. */
+       char *pattern;
+
+       /* Filter. */
+       char *filter_expression;
+
+       /* Log level. */
+       struct lttng_log_level_rule *log_level_rule;
+
+       /* internal use only. */
+       struct {
+               char *filter;
+               struct lttng_bytecode *bytecode;
+       } internal_filter;
+};
+
+struct lttng_event_rule_log4j_logging_comm {
+       /* Includes terminator `\0`. */
+       uint32_t pattern_len;
+       /* Includes terminator `\0`. */
+       uint32_t filter_expression_len;
+       /*  enum lttng_log_level_rule_comm + payload if any */
+       uint32_t log_level_rule_len;
+       /*
+        * Payload is composed of, in that order:
+        *   - pattern (null terminated),
+        *   - filter expression (null terminated),
+        *   - log level rule serialized object,
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_log4j_logging_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_LOG4J_LOGGING_INTERNAL_H */
diff --git a/include/lttng/event-rule/python-logging-internal.h b/include/lttng/event-rule/python-logging-internal.h
deleted file mode 100644 (file)
index 9f6f7fe..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_PYTHON_LOGGING_INTERNAL_H
-#define LTTNG_EVENT_RULE_PYTHON_LOGGING_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/python-logging.h>
-#include <lttng/event.h>
-#include <lttng/log-level-rule-internal.h>
-
-struct lttng_event_rule_python_logging {
-       struct lttng_event_rule parent;
-
-       /* Name pattern. */
-       char *pattern;
-
-       /* Filter. */
-       char *filter_expression;
-
-       /* Log level. */
-       struct lttng_log_level_rule *log_level_rule;
-
-       /* internal use only. */
-       struct {
-               char *filter;
-               struct lttng_bytecode *bytecode;
-       } internal_filter;
-};
-
-struct lttng_event_rule_python_logging_comm {
-       /* Includes terminator `\0`. */
-       uint32_t pattern_len;
-       /* Includes terminator `\0`. */
-       uint32_t filter_expression_len;
-       /*  enum lttng_log_level_rule_comm + payload if any */
-       uint32_t log_level_rule_len;
-       /*
-        * Payload is composed of, in that order:
-        *   - pattern (null terminated),
-        *   - filter expression (null terminated),
-        *   - log level rule serialized object,
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_python_logging_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_PYTHON_LOGGING_INTERNAL_H */
diff --git a/include/lttng/event-rule/python-logging-internal.hpp b/include/lttng/event-rule/python-logging-internal.hpp
new file mode 100644 (file)
index 0000000..d23f4e2
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_PYTHON_LOGGING_INTERNAL_H
+#define LTTNG_EVENT_RULE_PYTHON_LOGGING_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/python-logging.h>
+#include <lttng/event.h>
+#include <lttng/log-level-rule-internal.hpp>
+
+struct lttng_event_rule_python_logging {
+       struct lttng_event_rule parent;
+
+       /* Name pattern. */
+       char *pattern;
+
+       /* Filter. */
+       char *filter_expression;
+
+       /* Log level. */
+       struct lttng_log_level_rule *log_level_rule;
+
+       /* internal use only. */
+       struct {
+               char *filter;
+               struct lttng_bytecode *bytecode;
+       } internal_filter;
+};
+
+struct lttng_event_rule_python_logging_comm {
+       /* Includes terminator `\0`. */
+       uint32_t pattern_len;
+       /* Includes terminator `\0`. */
+       uint32_t filter_expression_len;
+       /*  enum lttng_log_level_rule_comm + payload if any */
+       uint32_t log_level_rule_len;
+       /*
+        * Payload is composed of, in that order:
+        *   - pattern (null terminated),
+        *   - filter expression (null terminated),
+        *   - log level rule serialized object,
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_python_logging_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_PYTHON_LOGGING_INTERNAL_H */
diff --git a/include/lttng/event-rule/user-tracepoint-internal.h b/include/lttng/event-rule/user-tracepoint-internal.h
deleted file mode 100644 (file)
index 9cd8b05..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_USER_TRACEPOINT_INTERNAL_H
-#define LTTNG_EVENT_RULE_USER_TRACEPOINT_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/domain.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/user-tracepoint.h>
-#include <lttng/event.h>
-#include <lttng/log-level-rule-internal.h>
-
-struct lttng_event_rule_user_tracepoint {
-       struct lttng_event_rule parent;
-
-       /* Name pattern. */
-       char *pattern;
-
-       /* Filter. */
-       char *filter_expression;
-
-       /* Log level. */
-       struct lttng_log_level_rule *log_level_rule;
-
-       /* Exclusions. */
-       struct lttng_dynamic_pointer_array exclusions;
-
-       /* internal use only. */
-       struct {
-               char *filter;
-               struct lttng_bytecode *bytecode;
-       } internal_filter;
-};
-
-struct lttng_event_rule_user_tracepoint_comm {
-       /* Includes terminator `\0`. */
-       uint32_t pattern_len;
-       /* Includes terminator `\0`. */
-       uint32_t filter_expression_len;
-       /*  enum lttng_log_level_rule_comm + payload if any */
-       uint32_t log_level_rule_len;
-       uint32_t exclusions_count;
-       uint32_t exclusions_len;
-       /*
-        * Payload is composed of, in that order:
-        *   - pattern (null terminated),
-        *   - filter expression (null terminated),
-        *   - log level rule serialized object,
-        *   - exclusions (32 bit length + null terminated string).
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_user_tracepoint_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_USER_TRACEPOINT_INTERNAL_H */
diff --git a/include/lttng/event-rule/user-tracepoint-internal.hpp b/include/lttng/event-rule/user-tracepoint-internal.hpp
new file mode 100644 (file)
index 0000000..1960a8a
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_USER_TRACEPOINT_INTERNAL_H
+#define LTTNG_EVENT_RULE_USER_TRACEPOINT_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/domain.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/user-tracepoint.h>
+#include <lttng/event.h>
+#include <lttng/log-level-rule-internal.hpp>
+
+struct lttng_event_rule_user_tracepoint {
+       struct lttng_event_rule parent;
+
+       /* Name pattern. */
+       char *pattern;
+
+       /* Filter. */
+       char *filter_expression;
+
+       /* Log level. */
+       struct lttng_log_level_rule *log_level_rule;
+
+       /* Exclusions. */
+       struct lttng_dynamic_pointer_array exclusions;
+
+       /* internal use only. */
+       struct {
+               char *filter;
+               struct lttng_bytecode *bytecode;
+       } internal_filter;
+};
+
+struct lttng_event_rule_user_tracepoint_comm {
+       /* Includes terminator `\0`. */
+       uint32_t pattern_len;
+       /* Includes terminator `\0`. */
+       uint32_t filter_expression_len;
+       /*  enum lttng_log_level_rule_comm + payload if any */
+       uint32_t log_level_rule_len;
+       uint32_t exclusions_count;
+       uint32_t exclusions_len;
+       /*
+        * Payload is composed of, in that order:
+        *   - pattern (null terminated),
+        *   - filter expression (null terminated),
+        *   - log level rule serialized object,
+        *   - exclusions (32 bit length + null terminated string).
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_user_tracepoint_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_USER_TRACEPOINT_INTERNAL_H */
diff --git a/include/lttng/health-internal.h b/include/lttng/health-internal.h
deleted file mode 100644 (file)
index ceda0a8..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-#ifndef HEALTH_INTERNAL_H
-#define HEALTH_INTERNAL_H
-
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <common/compat/time.h>
-#include <pthread.h>
-#include <urcu/tls-compat.h>
-#include <urcu/uatomic.h>
-#include <urcu/list.h>
-#include <lttng/health.h>
-#include <common/macros.h>
-
-/*
- * These are the value added to the current state depending of the position in
- * the thread where is either waiting on a poll() or running in the code.
- */
-#define HEALTH_POLL_VALUE      (1UL << 0)
-#define HEALTH_CODE_VALUE      (1UL << 1)
-
-#define HEALTH_IS_IN_POLL(x)   ((x) & HEALTH_POLL_VALUE)
-
-struct health_app;
-
-enum health_flags {
-       HEALTH_ERROR                     = (1U << 0),
-};
-
-struct health_state {
-       /*
-        * last counter and last_time are only read and updated by the health_check
-        * thread (single updater).
-        */
-       unsigned long last;
-       struct timespec last_time;
-
-       /*
-        * current and flags are updated by multiple threads concurrently.
-        */
-       unsigned long current;          /* progress counter, updated atomically */
-       enum health_flags flags;        /* other flags, updated atomically */
-       int type;                       /* Indicates the nature of the thread. */
-       /* Node of the global TLS state list. */
-       struct cds_list_head node;
-};
-
-enum health_cmd {
-       HEALTH_CMD_CHECK                = 0,
-};
-
-struct health_comm_msg {
-       uint32_t cmd;           /* enum health_cmd */
-} LTTNG_PACKED;
-
-struct health_comm_reply {
-       uint64_t ret_code;      /* bitmask of threads in bad health */
-} LTTNG_PACKED;
-
-/* Declare TLS health state. */
-extern DECLARE_URCU_TLS(struct health_state, health_state);
-
-/*
- * Update current counter by 1 to indicate that the thread entered or left a
- * blocking state caused by a poll(). If the counter's value is not an even
- * number (meaning a code execution flow), an LTTNG_ASSERT() is raised.
- */
-static inline void health_poll_entry(void)
-{
-       /* Code MUST be in code execution state which is an even number. */
-       LTTNG_ASSERT(!(uatomic_read(&URCU_TLS(health_state).current)
-                               & HEALTH_POLL_VALUE));
-
-       uatomic_add(&URCU_TLS(health_state).current, HEALTH_POLL_VALUE);
-}
-
-/*
- * Update current counter by 1 indicating the exit of a poll or blocking call.
- * If the counter's value is not an odd number (a poll execution), an LTTNG_ASSERT()
- * is raised.
- */
-static inline void health_poll_exit(void)
-{
-       /* Code MUST be in poll execution state which is an odd number. */
-       LTTNG_ASSERT(uatomic_read(&URCU_TLS(health_state).current)
-                               & HEALTH_POLL_VALUE);
-
-       uatomic_add(&URCU_TLS(health_state).current, HEALTH_POLL_VALUE);
-}
-
-/*
- * Update current counter by 2 indicates progress in execution of a
- * thread.
- */
-static inline void health_code_update(void)
-{
-       uatomic_add(&URCU_TLS(health_state).current, HEALTH_CODE_VALUE);
-}
-
-/*
- * Set health "error" flag.
- */
-static inline void health_error(void)
-{
-       uatomic_or(&URCU_TLS(health_state).flags, HEALTH_ERROR);
-}
-
-struct health_app *health_app_create(int nr_types);
-void health_app_destroy(struct health_app *ha);
-int health_check_state(struct health_app *ha, int type);
-void health_register(struct health_app *ha, int type);
-void health_unregister(struct health_app *ha);
-
-#endif /* HEALTH_INTERNAL_H */
diff --git a/include/lttng/health-internal.hpp b/include/lttng/health-internal.hpp
new file mode 100644 (file)
index 0000000..67bdc6a
--- /dev/null
@@ -0,0 +1,119 @@
+#ifndef HEALTH_INTERNAL_H
+#define HEALTH_INTERNAL_H
+
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <common/compat/time.hpp>
+#include <pthread.h>
+#include <urcu/tls-compat.h>
+#include <urcu/uatomic.h>
+#include <urcu/list.h>
+#include <lttng/health.h>
+#include <common/macros.hpp>
+
+/*
+ * These are the value added to the current state depending of the position in
+ * the thread where is either waiting on a poll() or running in the code.
+ */
+#define HEALTH_POLL_VALUE      (1UL << 0)
+#define HEALTH_CODE_VALUE      (1UL << 1)
+
+#define HEALTH_IS_IN_POLL(x)   ((x) & HEALTH_POLL_VALUE)
+
+struct health_app;
+
+enum health_flags {
+       HEALTH_ERROR                     = (1U << 0),
+};
+
+struct health_state {
+       /*
+        * last counter and last_time are only read and updated by the health_check
+        * thread (single updater).
+        */
+       unsigned long last;
+       struct timespec last_time;
+
+       /*
+        * current and flags are updated by multiple threads concurrently.
+        */
+       unsigned long current;          /* progress counter, updated atomically */
+       enum health_flags flags;        /* other flags, updated atomically */
+       int type;                       /* Indicates the nature of the thread. */
+       /* Node of the global TLS state list. */
+       struct cds_list_head node;
+};
+
+enum health_cmd {
+       HEALTH_CMD_CHECK                = 0,
+};
+
+struct health_comm_msg {
+       uint32_t cmd;           /* enum health_cmd */
+} LTTNG_PACKED;
+
+struct health_comm_reply {
+       uint64_t ret_code;      /* bitmask of threads in bad health */
+} LTTNG_PACKED;
+
+/* Declare TLS health state. */
+extern DECLARE_URCU_TLS(struct health_state, health_state);
+
+/*
+ * Update current counter by 1 to indicate that the thread entered or left a
+ * blocking state caused by a poll(). If the counter's value is not an even
+ * number (meaning a code execution flow), an LTTNG_ASSERT() is raised.
+ */
+static inline void health_poll_entry(void)
+{
+       /* Code MUST be in code execution state which is an even number. */
+       LTTNG_ASSERT(!(uatomic_read(&URCU_TLS(health_state).current)
+                               & HEALTH_POLL_VALUE));
+
+       uatomic_add(&URCU_TLS(health_state).current, HEALTH_POLL_VALUE);
+}
+
+/*
+ * Update current counter by 1 indicating the exit of a poll or blocking call.
+ * If the counter's value is not an odd number (a poll execution), an LTTNG_ASSERT()
+ * is raised.
+ */
+static inline void health_poll_exit(void)
+{
+       /* Code MUST be in poll execution state which is an odd number. */
+       LTTNG_ASSERT(uatomic_read(&URCU_TLS(health_state).current)
+                               & HEALTH_POLL_VALUE);
+
+       uatomic_add(&URCU_TLS(health_state).current, HEALTH_POLL_VALUE);
+}
+
+/*
+ * Update current counter by 2 indicates progress in execution of a
+ * thread.
+ */
+static inline void health_code_update(void)
+{
+       uatomic_add(&URCU_TLS(health_state).current, HEALTH_CODE_VALUE);
+}
+
+/*
+ * Set health "error" flag.
+ */
+static inline void health_error(void)
+{
+       uatomic_or(&URCU_TLS(health_state).flags, HEALTH_ERROR);
+}
+
+struct health_app *health_app_create(int nr_types);
+void health_app_destroy(struct health_app *ha);
+int health_check_state(struct health_app *ha, int type);
+void health_register(struct health_app *ha, int type);
+void health_unregister(struct health_app *ha);
+
+#endif /* HEALTH_INTERNAL_H */
diff --git a/include/lttng/kernel-probe-internal.h b/include/lttng/kernel-probe-internal.h
deleted file mode 100644 (file)
index 2d2ab86..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_KERNEL_PROBE_INTERNAL_H
-#define LTTNG_KERNEL_PROBE_INTERNAL_H
-
-#include <common/fd-handle.h>
-#include <common/macros.h>
-#include <lttng/lttng-error.h>
-#include <lttng/kernel-probe.h>
-#include <lttng/lttng-error.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-struct lttng_dynamic_buffer;
-struct mi_writer;
-
-typedef bool (*kernel_probe_location_equal_cb)(
-               const struct lttng_kernel_probe_location *a,
-               const struct lttng_kernel_probe_location *b);
-typedef int (*kernel_probe_location_serialize_cb)(
-               const struct lttng_kernel_probe_location *kernel_probe_location,
-               struct lttng_payload *payload);
-typedef bool (*kernel_probe_location_equal_cb)(
-               const struct lttng_kernel_probe_location *a,
-               const struct lttng_kernel_probe_location *b);
-typedef ssize_t (*kernel_probe_location_create_from_payload_cb)(
-               struct lttng_payload_view *view,
-               struct lttng_kernel_probe_location **kernel_probe_location);
-typedef unsigned long (*kernel_probe_location_hash_cb)(
-               const struct lttng_kernel_probe_location *location);
-typedef enum lttng_error_code (*kernel_probe_location_mi_serialize_cb)(
-               const struct lttng_kernel_probe_location *location,
-               struct mi_writer *writer);
-
-struct lttng_kernel_probe_location_comm {
-       /* enum lttng_kernel_probe_location_type */
-       int8_t type;
-       /*
-        * Payload is composed of, in that order,
-        *   - type-specific payload
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_kernel_probe_location_symbol_comm {
-       /* Includes the trailing \0. */
-       uint32_t symbol_len;
-       /* The offset from the symbol. */
-       uint64_t offset;
-       /*
-        * Payload is composed of, in that order,
-        *   - symbol name (with trailing \0).
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_kernel_probe_location_address_comm {
-       uint64_t address;
-} LTTNG_PACKED;
-
-/* Common ancestor of all kernel probe locations. */
-struct lttng_kernel_probe_location {
-       enum lttng_kernel_probe_location_type type;
-       kernel_probe_location_equal_cb equal;
-       kernel_probe_location_serialize_cb serialize;
-       kernel_probe_location_hash_cb hash;
-       kernel_probe_location_mi_serialize_cb mi_serialize;
-};
-
-struct lttng_kernel_probe_location_symbol {
-       struct lttng_kernel_probe_location parent;
-       char *symbol_name;
-       uint64_t offset;
-};
-
-struct lttng_kernel_probe_location_address {
-       struct lttng_kernel_probe_location parent;
-       uint64_t address;
-};
-
-int lttng_kernel_probe_location_serialize(
-               const struct lttng_kernel_probe_location *location,
-               struct lttng_payload *payload);
-
-ssize_t lttng_kernel_probe_location_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_kernel_probe_location **probe_location);
-
-bool lttng_kernel_probe_location_is_equal(
-               const struct lttng_kernel_probe_location *a,
-               const struct lttng_kernel_probe_location *b);
-
-struct lttng_kernel_probe_location *lttng_kernel_probe_location_copy(
-               const struct lttng_kernel_probe_location *location);
-
-unsigned long lttng_kernel_probe_location_hash(
-               const struct lttng_kernel_probe_location *location);
-
-enum lttng_error_code lttng_kernel_probe_location_mi_serialize(
-               const struct lttng_kernel_probe_location *location,
-               struct mi_writer *writer);
-
-#endif /* LTTNG_KERNEL_PROBE_INTERNAL_H */
diff --git a/include/lttng/kernel-probe-internal.hpp b/include/lttng/kernel-probe-internal.hpp
new file mode 100644 (file)
index 0000000..07c546f
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_KERNEL_PROBE_INTERNAL_H
+#define LTTNG_KERNEL_PROBE_INTERNAL_H
+
+#include <common/fd-handle.hpp>
+#include <common/macros.hpp>
+#include <lttng/lttng-error.h>
+#include <lttng/kernel-probe.h>
+#include <lttng/lttng-error.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/types.h>
+
+struct lttng_payload;
+struct lttng_payload_view;
+struct lttng_dynamic_buffer;
+struct mi_writer;
+
+typedef bool (*kernel_probe_location_equal_cb)(
+               const struct lttng_kernel_probe_location *a,
+               const struct lttng_kernel_probe_location *b);
+typedef int (*kernel_probe_location_serialize_cb)(
+               const struct lttng_kernel_probe_location *kernel_probe_location,
+               struct lttng_payload *payload);
+typedef bool (*kernel_probe_location_equal_cb)(
+               const struct lttng_kernel_probe_location *a,
+               const struct lttng_kernel_probe_location *b);
+typedef ssize_t (*kernel_probe_location_create_from_payload_cb)(
+               struct lttng_payload_view *view,
+               struct lttng_kernel_probe_location **kernel_probe_location);
+typedef unsigned long (*kernel_probe_location_hash_cb)(
+               const struct lttng_kernel_probe_location *location);
+typedef enum lttng_error_code (*kernel_probe_location_mi_serialize_cb)(
+               const struct lttng_kernel_probe_location *location,
+               struct mi_writer *writer);
+
+struct lttng_kernel_probe_location_comm {
+       /* enum lttng_kernel_probe_location_type */
+       int8_t type;
+       /*
+        * Payload is composed of, in that order,
+        *   - type-specific payload
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_kernel_probe_location_symbol_comm {
+       /* Includes the trailing \0. */
+       uint32_t symbol_len;
+       /* The offset from the symbol. */
+       uint64_t offset;
+       /*
+        * Payload is composed of, in that order,
+        *   - symbol name (with trailing \0).
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_kernel_probe_location_address_comm {
+       uint64_t address;
+} LTTNG_PACKED;
+
+/* Common ancestor of all kernel probe locations. */
+struct lttng_kernel_probe_location {
+       enum lttng_kernel_probe_location_type type;
+       kernel_probe_location_equal_cb equal;
+       kernel_probe_location_serialize_cb serialize;
+       kernel_probe_location_hash_cb hash;
+       kernel_probe_location_mi_serialize_cb mi_serialize;
+};
+
+struct lttng_kernel_probe_location_symbol {
+       struct lttng_kernel_probe_location parent;
+       char *symbol_name;
+       uint64_t offset;
+};
+
+struct lttng_kernel_probe_location_address {
+       struct lttng_kernel_probe_location parent;
+       uint64_t address;
+};
+
+int lttng_kernel_probe_location_serialize(
+               const struct lttng_kernel_probe_location *location,
+               struct lttng_payload *payload);
+
+ssize_t lttng_kernel_probe_location_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_kernel_probe_location **probe_location);
+
+bool lttng_kernel_probe_location_is_equal(
+               const struct lttng_kernel_probe_location *a,
+               const struct lttng_kernel_probe_location *b);
+
+struct lttng_kernel_probe_location *lttng_kernel_probe_location_copy(
+               const struct lttng_kernel_probe_location *location);
+
+unsigned long lttng_kernel_probe_location_hash(
+               const struct lttng_kernel_probe_location *location);
+
+enum lttng_error_code lttng_kernel_probe_location_mi_serialize(
+               const struct lttng_kernel_probe_location *location,
+               struct mi_writer *writer);
+
+#endif /* LTTNG_KERNEL_PROBE_INTERNAL_H */
diff --git a/include/lttng/load-internal.h b/include/lttng/load-internal.h
deleted file mode 100644 (file)
index 9284741..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_LOAD_INTERNAL_ABI_H
-#define LTTNG_LOAD_INTERNAL_ABI_H
-
-#include <limits.h>
-#include <stdint.h>
-
-#include <lttng/constant.h>
-#include <common/macros.h>
-#include <common/config/session-config.h>
-
-/*
- * Object used by the load_session API. This is opaque to the public library.
- */
-struct lttng_load_session_attr {
-       /* Name of the session to load, empty string means all. */
-       char session_name[LTTNG_NAME_MAX];
-       /* URL of the session configuration file to load. */
-       char input_url[PATH_MAX];
-       /* Overwrite the session if it exists. */
-       uint32_t overwrite;
-       /* The raw override url for getter */
-       char *raw_override_url;
-       /* The raw override path url for getter */
-       char *raw_override_path_url;
-       /* The raw override ctrl url for getter */
-       char *raw_override_ctrl_url;
-       /* The raw override data url for getter */
-       char *raw_override_data_url;
-       /* Override struct */
-       struct config_load_session_override_attr *override_attr;
-} LTTNG_PACKED;
-
-#endif /* LTTNG_LOAD_INTERNAL_ABI_H */
diff --git a/include/lttng/load-internal.hpp b/include/lttng/load-internal.hpp
new file mode 100644 (file)
index 0000000..ef09ffd
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_LOAD_INTERNAL_ABI_H
+#define LTTNG_LOAD_INTERNAL_ABI_H
+
+#include <limits.h>
+#include <stdint.h>
+
+#include <lttng/constant.h>
+#include <common/macros.hpp>
+#include <common/config/session-config.hpp>
+
+/*
+ * Object used by the load_session API. This is opaque to the public library.
+ */
+struct lttng_load_session_attr {
+       /* Name of the session to load, empty string means all. */
+       char session_name[LTTNG_NAME_MAX];
+       /* URL of the session configuration file to load. */
+       char input_url[PATH_MAX];
+       /* Overwrite the session if it exists. */
+       uint32_t overwrite;
+       /* The raw override url for getter */
+       char *raw_override_url;
+       /* The raw override path url for getter */
+       char *raw_override_path_url;
+       /* The raw override ctrl url for getter */
+       char *raw_override_ctrl_url;
+       /* The raw override data url for getter */
+       char *raw_override_data_url;
+       /* Override struct */
+       struct config_load_session_override_attr *override_attr;
+} LTTNG_PACKED;
+
+#endif /* LTTNG_LOAD_INTERNAL_ABI_H */
diff --git a/include/lttng/location-internal.h b/include/lttng/location-internal.h
deleted file mode 100644 (file)
index 33498c9..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_LOCATION_INTERNAL_H
-#define LTTNG_LOCATION_INTERNAL_H
-
-#include <lttng/location.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <common/macros.h>
-#include <sys/types.h>
-#include <urcu/ref.h>
-
-/*
- * The public API assumes that trace archive locations are always
- * provided as "constant". This means that the user of liblttng-ctl never
- * has to destroy a trace archive location. Hence, users of liblttng-ctl
- * have no visibility of the reference counting of archive locations.
- */
-struct lttng_trace_archive_location {
-       struct urcu_ref ref;
-       enum lttng_trace_archive_location_type type;
-       union {
-               struct {
-                       char *absolute_path;
-               } local;
-               struct {
-                       char *host;
-                       enum lttng_trace_archive_location_relay_protocol_type protocol;
-                       struct {
-                               uint16_t control, data;
-                       } ports;
-                       char *relative_path;
-               } relay;
-       } types;
-};
-
-struct lttng_trace_archive_location_comm {
-       /* A value from enum lttng_trace_archive_location_type */
-       int8_t type;
-       union {
-               struct {
-                       /* Includes the trailing \0. */
-                       uint32_t absolute_path_len;
-               } LTTNG_PACKED local;
-               struct {
-                       /* Includes the trailing \0. */
-                       uint32_t hostname_len;
-                       /*
-                        * A value from
-                        * enum lttng_trace_archive_location_relay_protocol_type.
-                        */
-                       int8_t protocol;
-                       struct {
-                               uint16_t control, data;
-                       } ports;
-                       /* Includes the trailing \0. */
-                       uint32_t relative_path_len;
-               } LTTNG_PACKED relay;
-       } LTTNG_PACKED types;
-       /*
-        * Payload is composed of:
-        * - LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL
-        *   - absolute path, including \0
-        * - LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY
-        *   - hostname, including \0
-        *   - relative path, including \0
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-
-struct lttng_trace_archive_location *lttng_trace_archive_location_local_create(
-               const char *path);
-
-struct lttng_trace_archive_location *lttng_trace_archive_location_relay_create(
-               const char *host,
-               enum lttng_trace_archive_location_relay_protocol_type protocol,
-               uint16_t control_port, uint16_t data_port,
-               const char *relative_path);
-
-ssize_t lttng_trace_archive_location_create_from_buffer(
-               const struct lttng_buffer_view *buffer,
-               struct lttng_trace_archive_location **location);
-
-ssize_t lttng_trace_archive_location_serialize(
-               const struct lttng_trace_archive_location *location,
-               struct lttng_dynamic_buffer *buffer);
-
-void lttng_trace_archive_location_get(
-               struct lttng_trace_archive_location *location);
-
-void lttng_trace_archive_location_put(
-               struct lttng_trace_archive_location *location);
-
-#endif /* LTTNG_LOCATION_INTERNAL_H */
diff --git a/include/lttng/location-internal.hpp b/include/lttng/location-internal.hpp
new file mode 100644 (file)
index 0000000..4daeed0
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_LOCATION_INTERNAL_H
+#define LTTNG_LOCATION_INTERNAL_H
+
+#include <lttng/location.h>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
+#include <common/macros.hpp>
+#include <sys/types.h>
+#include <urcu/ref.h>
+
+/*
+ * The public API assumes that trace archive locations are always
+ * provided as "constant". This means that the user of liblttng-ctl never
+ * has to destroy a trace archive location. Hence, users of liblttng-ctl
+ * have no visibility of the reference counting of archive locations.
+ */
+struct lttng_trace_archive_location {
+       struct urcu_ref ref;
+       enum lttng_trace_archive_location_type type;
+       union {
+               struct {
+                       char *absolute_path;
+               } local;
+               struct {
+                       char *host;
+                       enum lttng_trace_archive_location_relay_protocol_type protocol;
+                       struct {
+                               uint16_t control, data;
+                       } ports;
+                       char *relative_path;
+               } relay;
+       } types;
+};
+
+struct lttng_trace_archive_location_comm {
+       /* A value from enum lttng_trace_archive_location_type */
+       int8_t type;
+       union {
+               struct {
+                       /* Includes the trailing \0. */
+                       uint32_t absolute_path_len;
+               } LTTNG_PACKED local;
+               struct {
+                       /* Includes the trailing \0. */
+                       uint32_t hostname_len;
+                       /*
+                        * A value from
+                        * enum lttng_trace_archive_location_relay_protocol_type.
+                        */
+                       int8_t protocol;
+                       struct {
+                               uint16_t control, data;
+                       } ports;
+                       /* Includes the trailing \0. */
+                       uint32_t relative_path_len;
+               } LTTNG_PACKED relay;
+       } LTTNG_PACKED types;
+       /*
+        * Payload is composed of:
+        * - LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL
+        *   - absolute path, including \0
+        * - LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY
+        *   - hostname, including \0
+        *   - relative path, including \0
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+
+struct lttng_trace_archive_location *lttng_trace_archive_location_local_create(
+               const char *path);
+
+struct lttng_trace_archive_location *lttng_trace_archive_location_relay_create(
+               const char *host,
+               enum lttng_trace_archive_location_relay_protocol_type protocol,
+               uint16_t control_port, uint16_t data_port,
+               const char *relative_path);
+
+ssize_t lttng_trace_archive_location_create_from_buffer(
+               const struct lttng_buffer_view *buffer,
+               struct lttng_trace_archive_location **location);
+
+ssize_t lttng_trace_archive_location_serialize(
+               const struct lttng_trace_archive_location *location,
+               struct lttng_dynamic_buffer *buffer);
+
+void lttng_trace_archive_location_get(
+               struct lttng_trace_archive_location *location);
+
+void lttng_trace_archive_location_put(
+               struct lttng_trace_archive_location *location);
+
+#endif /* LTTNG_LOCATION_INTERNAL_H */
diff --git a/include/lttng/log-level-rule-internal.h b/include/lttng/log-level-rule-internal.h
deleted file mode 100644 (file)
index ac0f74b..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_LOG_LEVEL_RULE_INTERNAL_H
-#define LTTNG_LOG_LEVEL_RULE_INTERNAL_H
-
-#include <stdint.h>
-
-#include <common/buffer-view.h>
-#include <common/dynamic-array.h>
-#include <common/macros.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/event.h>
-#include <lttng/log-level-rule.h>
-#include <lttng/lttng-error.h>
-
-struct mi_writer;
-
-/*
- * For now only a single backing struct is used for both type of log level
- * rule (exactly, as_severe) since both only have require "level" as property.
- */
-struct lttng_log_level_rule {
-       enum lttng_log_level_rule_type type;
-       int level;
-};
-
-struct lttng_log_level_rule_comm {
-       /* enum lttng_log_level_rule_type */
-       int8_t type;
-       int32_t level;
-};
-
-ssize_t lttng_log_level_rule_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_log_level_rule **rule);
-
-int lttng_log_level_rule_serialize(const struct lttng_log_level_rule *rule,
-               struct lttng_payload *payload);
-
-bool lttng_log_level_rule_is_equal(const struct lttng_log_level_rule *a,
-               const struct lttng_log_level_rule *b);
-
-struct lttng_log_level_rule *lttng_log_level_rule_copy(
-               const struct lttng_log_level_rule *source);
-
-void lttng_log_level_rule_to_loglevel(
-               const struct lttng_log_level_rule *log_level_rule,
-               enum lttng_loglevel_type *loglevel_type,
-               int *loglevel_value);
-
-unsigned long lttng_log_level_rule_hash(
-               const struct lttng_log_level_rule *log_level_rule);
-
-enum lttng_error_code lttng_log_level_rule_mi_serialize(
-               const struct lttng_log_level_rule *rule,
-               struct mi_writer *writer);
-
-#endif /* LTTNG_LOG_LEVEL_RULE_INTERNAL_H */
diff --git a/include/lttng/log-level-rule-internal.hpp b/include/lttng/log-level-rule-internal.hpp
new file mode 100644 (file)
index 0000000..71447cf
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_LOG_LEVEL_RULE_INTERNAL_H
+#define LTTNG_LOG_LEVEL_RULE_INTERNAL_H
+
+#include <stdint.h>
+
+#include <common/buffer-view.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/macros.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/event.h>
+#include <lttng/log-level-rule.h>
+#include <lttng/lttng-error.h>
+
+struct mi_writer;
+
+/*
+ * For now only a single backing struct is used for both type of log level
+ * rule (exactly, as_severe) since both only have require "level" as property.
+ */
+struct lttng_log_level_rule {
+       enum lttng_log_level_rule_type type;
+       int level;
+};
+
+struct lttng_log_level_rule_comm {
+       /* enum lttng_log_level_rule_type */
+       int8_t type;
+       int32_t level;
+};
+
+ssize_t lttng_log_level_rule_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_log_level_rule **rule);
+
+int lttng_log_level_rule_serialize(const struct lttng_log_level_rule *rule,
+               struct lttng_payload *payload);
+
+bool lttng_log_level_rule_is_equal(const struct lttng_log_level_rule *a,
+               const struct lttng_log_level_rule *b);
+
+struct lttng_log_level_rule *lttng_log_level_rule_copy(
+               const struct lttng_log_level_rule *source);
+
+void lttng_log_level_rule_to_loglevel(
+               const struct lttng_log_level_rule *log_level_rule,
+               enum lttng_loglevel_type *loglevel_type,
+               int *loglevel_value);
+
+unsigned long lttng_log_level_rule_hash(
+               const struct lttng_log_level_rule *log_level_rule);
+
+enum lttng_error_code lttng_log_level_rule_mi_serialize(
+               const struct lttng_log_level_rule *rule,
+               struct mi_writer *writer);
+
+#endif /* LTTNG_LOG_LEVEL_RULE_INTERNAL_H */
diff --git a/include/lttng/notification/channel-internal.h b/include/lttng/notification/channel-internal.h
deleted file mode 100644 (file)
index befdca0..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
-#define LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
-
-#include <lttng/notification/channel.h>
-#include <common/macros.h>
-#include <common/payload.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <pthread.h>
-#include <urcu/list.h>
-
-/*
- * Protocol version change log:
- * - v1.0
- *   - Initial implementation of the notification channel protocol,
- *   - Supported conditions are LOW/HIGH buffer usage conditions,
- * - v1.1
- *   - New condition type "LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE" added,
- *   - New condition type "LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING" added,
- *   - New condition type "LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED" added,
- */
-#define LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR 1
-#define LTTNG_NOTIFICATION_CHANNEL_VERSION_MINOR 1
-
-enum lttng_notification_channel_message_type {
-       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNKNOWN = -1,
-       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_HANDSHAKE = 0,
-       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE = 1,
-       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNSUBSCRIBE = 2,
-       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_COMMAND_REPLY = 3,
-       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION = 4,
-       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION_DROPPED = 5,
-};
-
-struct lttng_notification_channel_message {
-       /* enum lttng_notification_channel_message_type */
-       int8_t type;
-       /* Size of the payload following this field. */
-       uint32_t size;
-       /* Number of FDs sent. */
-       uint32_t fds;
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_notification_channel_command_handshake {
-       uint8_t major;
-       uint8_t minor;
-} LTTNG_PACKED;
-
-struct lttng_notification_channel_command_reply {
-       /* enum lttng_notification_channel_status */
-       int8_t status;
-} LTTNG_PACKED;
-
-struct pending_notification {
-       /* NULL means "notification dropped". */
-       struct lttng_notification *notification;
-       struct cds_list_head node;
-};
-
-/*
- * The notification channel protocol is bidirectional and accommodates
- * synchronous and asynchronous communication modes:
- *
- *   - Synchronous: commands emitted by the client to which a reply is expected
- *     (e.g. subscribing/unsubscribing to conditions),
- *   - Asynchronous: notifications which are sent by the lttng_endpoint to the
- *     client as one of the subscribed condition has occurred.
- *
- * The nature of this hybrid communication mode means that asynchronous messages
- * (e.g. notifications) may be interleaved between synchronous messages (e.g. a
- * command and its reply).
- *
- * Notifications that are received between a command and its reply and enqueued
- * in the pending_notifications list.
- */
-struct lttng_notification_channel {
-       pthread_mutex_t lock;
-       int socket;
-       struct {
-               /* Count of pending notifications. */
-               unsigned int count;
-               /* List of struct pending_notification. */
-               struct cds_list_head list;
-       } pending_notifications;
-       struct lttng_payload reception_payload;
-       /* Sessiond notification protocol version. */
-       struct {
-               bool set;
-               int8_t major, minor;
-       } version;
-};
-
-#endif /* LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H */
diff --git a/include/lttng/notification/channel-internal.hpp b/include/lttng/notification/channel-internal.hpp
new file mode 100644 (file)
index 0000000..3364704
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
+#define LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
+
+#include <lttng/notification/channel.h>
+#include <common/macros.hpp>
+#include <common/payload.hpp>
+#include <stdint.h>
+#include <stdbool.h>
+#include <pthread.h>
+#include <urcu/list.h>
+
+/*
+ * Protocol version change log:
+ * - v1.0
+ *   - Initial implementation of the notification channel protocol,
+ *   - Supported conditions are LOW/HIGH buffer usage conditions,
+ * - v1.1
+ *   - New condition type "LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE" added,
+ *   - New condition type "LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING" added,
+ *   - New condition type "LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED" added,
+ */
+#define LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR 1
+#define LTTNG_NOTIFICATION_CHANNEL_VERSION_MINOR 1
+
+enum lttng_notification_channel_message_type {
+       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNKNOWN = -1,
+       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_HANDSHAKE = 0,
+       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE = 1,
+       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNSUBSCRIBE = 2,
+       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_COMMAND_REPLY = 3,
+       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION = 4,
+       LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION_DROPPED = 5,
+};
+
+struct lttng_notification_channel_message {
+       /* enum lttng_notification_channel_message_type */
+       int8_t type;
+       /* Size of the payload following this field. */
+       uint32_t size;
+       /* Number of FDs sent. */
+       uint32_t fds;
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_notification_channel_command_handshake {
+       uint8_t major;
+       uint8_t minor;
+} LTTNG_PACKED;
+
+struct lttng_notification_channel_command_reply {
+       /* enum lttng_notification_channel_status */
+       int8_t status;
+} LTTNG_PACKED;
+
+struct pending_notification {
+       /* NULL means "notification dropped". */
+       struct lttng_notification *notification;
+       struct cds_list_head node;
+};
+
+/*
+ * The notification channel protocol is bidirectional and accommodates
+ * synchronous and asynchronous communication modes:
+ *
+ *   - Synchronous: commands emitted by the client to which a reply is expected
+ *     (e.g. subscribing/unsubscribing to conditions),
+ *   - Asynchronous: notifications which are sent by the lttng_endpoint to the
+ *     client as one of the subscribed condition has occurred.
+ *
+ * The nature of this hybrid communication mode means that asynchronous messages
+ * (e.g. notifications) may be interleaved between synchronous messages (e.g. a
+ * command and its reply).
+ *
+ * Notifications that are received between a command and its reply and enqueued
+ * in the pending_notifications list.
+ */
+struct lttng_notification_channel {
+       pthread_mutex_t lock;
+       int socket;
+       struct {
+               /* Count of pending notifications. */
+               unsigned int count;
+               /* List of struct pending_notification. */
+               struct cds_list_head list;
+       } pending_notifications;
+       struct lttng_payload reception_payload;
+       /* Sessiond notification protocol version. */
+       struct {
+               bool set;
+               int8_t major, minor;
+       } version;
+};
+
+#endif /* LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H */
diff --git a/include/lttng/notification/notification-internal.h b/include/lttng/notification/notification-internal.h
deleted file mode 100644 (file)
index 7e601b0..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_NOTIFICATION_INTERNAL_H
-#define LTTNG_NOTIFICATION_INTERNAL_H
-
-#include <lttng/notification/notification.h>
-#include <common/macros.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <sys/types.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-
-struct lttng_notification {
-       struct lttng_trigger *trigger;
-       struct lttng_evaluation *evaluation;
-};
-
-struct lttng_notification_comm {
-       /* Size of the payload following this field. */
-       uint32_t length;
-       /* Trigger and evaluation objects follow. */
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_notification *lttng_notification_create(
-               struct lttng_trigger *trigger,
-               struct lttng_evaluation *evaluation);
-
-int lttng_notification_serialize(const struct lttng_notification *notification,
-               struct lttng_payload *payload);
-
-ssize_t lttng_notification_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_notification **notification);
-
-#endif /* LTTNG_NOTIFICATION_INTERNAL_H */
diff --git a/include/lttng/notification/notification-internal.hpp b/include/lttng/notification/notification-internal.hpp
new file mode 100644 (file)
index 0000000..37c8f2a
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_NOTIFICATION_INTERNAL_H
+#define LTTNG_NOTIFICATION_INTERNAL_H
+
+#include <lttng/notification/notification.h>
+#include <common/macros.hpp>
+#include <stdint.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+struct lttng_payload;
+struct lttng_payload_view;
+
+struct lttng_notification {
+       struct lttng_trigger *trigger;
+       struct lttng_evaluation *evaluation;
+};
+
+struct lttng_notification_comm {
+       /* Size of the payload following this field. */
+       uint32_t length;
+       /* Trigger and evaluation objects follow. */
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_notification *lttng_notification_create(
+               struct lttng_trigger *trigger,
+               struct lttng_evaluation *evaluation);
+
+int lttng_notification_serialize(const struct lttng_notification *notification,
+               struct lttng_payload *payload);
+
+ssize_t lttng_notification_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_notification **notification);
+
+#endif /* LTTNG_NOTIFICATION_INTERNAL_H */
diff --git a/include/lttng/ref-internal.h b/include/lttng/ref-internal.h
deleted file mode 100644 (file)
index a02ae4c..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef LTTNG_REF_INTERNAL_H
-#define LTTNG_REF_INTERNAL_H
-
-/*
- * LTTng - Non thread-safe reference counting
- *
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-
-typedef void (*lttng_release_func)(void *);
-
-struct lttng_ref {
-       unsigned long count;
-       lttng_release_func release;
-};
-
-static inline
-void lttng_ref_init(struct lttng_ref *ref, lttng_release_func release)
-{
-       LTTNG_ASSERT(ref);
-       ref->count = 1;
-       ref->release = release;
-}
-
-static inline
-void lttng_ref_get(struct lttng_ref *ref)
-{
-       LTTNG_ASSERT(ref);
-       ref->count++;
-       /* Overflow check. */
-       LTTNG_ASSERT(ref->count);
-}
-
-static inline
-void lttng_ref_put(struct lttng_ref *ref)
-{
-       LTTNG_ASSERT(ref);
-       /* Underflow check. */
-       LTTNG_ASSERT(ref->count);
-       if (caa_unlikely((--ref->count) == 0)) {
-               ref->release(ref);
-       }
-}
-
-#endif /* LTTNG_REF_INTERNAL_H */
diff --git a/include/lttng/ref-internal.hpp b/include/lttng/ref-internal.hpp
new file mode 100644 (file)
index 0000000..a02ae4c
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef LTTNG_REF_INTERNAL_H
+#define LTTNG_REF_INTERNAL_H
+
+/*
+ * LTTng - Non thread-safe reference counting
+ *
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+
+typedef void (*lttng_release_func)(void *);
+
+struct lttng_ref {
+       unsigned long count;
+       lttng_release_func release;
+};
+
+static inline
+void lttng_ref_init(struct lttng_ref *ref, lttng_release_func release)
+{
+       LTTNG_ASSERT(ref);
+       ref->count = 1;
+       ref->release = release;
+}
+
+static inline
+void lttng_ref_get(struct lttng_ref *ref)
+{
+       LTTNG_ASSERT(ref);
+       ref->count++;
+       /* Overflow check. */
+       LTTNG_ASSERT(ref->count);
+}
+
+static inline
+void lttng_ref_put(struct lttng_ref *ref)
+{
+       LTTNG_ASSERT(ref);
+       /* Underflow check. */
+       LTTNG_ASSERT(ref->count);
+       if (caa_unlikely((--ref->count) == 0)) {
+               ref->release(ref);
+       }
+}
+
+#endif /* LTTNG_REF_INTERNAL_H */
diff --git a/include/lttng/rotate-internal.h b/include/lttng/rotate-internal.h
deleted file mode 100644 (file)
index 0296efe..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ROTATE_INTERNAL_ABI_H
-#define LTTNG_ROTATE_INTERNAL_ABI_H
-
-#include <limits.h>
-#include <stdint.h>
-#include <stdbool.h>
-
-#include <lttng/constant.h>
-#include <lttng/rotation.h>
-#include <common/macros.h>
-
-/*
- * Object returned by the rotate session API.
- * This is opaque to the public library.
- */
-struct lttng_rotation_handle {
-       char session_name[LTTNG_NAME_MAX];
-       /*
-        * ID of the rotate command.
-        * This matches the session->rotate_count, so the handle is valid until
-        * the next rotate command. After that, the rotation_get_state command
-        * returns the "expired" state.
-        */
-       uint64_t rotation_id;
-       /*
-        * Where the rotated (readable) trace has been stored when the
-        * rotation is completed.
-        */
-       struct lttng_trace_archive_location *archive_location;
-};
-
-struct lttng_rotation_schedule {
-       enum lttng_rotation_schedule_type type;
-};
-
-struct lttng_rotation_schedule_size_threshold {
-       struct lttng_rotation_schedule parent;
-       struct {
-               bool set;
-               uint64_t bytes;
-       } size;
-};
-
-struct lttng_rotation_schedule_periodic {
-       struct lttng_rotation_schedule parent;
-       struct {
-               bool set;
-               uint64_t us;
-       } period;
-};
-
-struct lttng_rotation_schedules {
-       /*
-        * Only one rotation schedule per type is supported for now.
-        * Schedules are owned by this object.
-        */
-       unsigned int count;
-       struct lttng_rotation_schedule *schedules[2];
-};
-
-/*
- * Internal objects between lttng-ctl and the session daemon, the values
- * are then copied to the user's lttng_rotation_handle object.
- */
-
-/* For the LTTNG_ROTATE_SESSION command. */
-struct lttng_rotate_session_return {
-       uint64_t rotation_id;
-} LTTNG_PACKED;
-
-/* For the LTTNG_ROTATION_GET_INFO command. */
-struct lttng_rotation_get_info_return {
-       /* Represents values defined in enum lttng_rotation_state. */
-       int32_t status;
-       /*
-        * Represents values defined in enum lttng_trace_archive_location_type.
-        */
-       int8_t location_type;
-       union {
-               struct {
-                       char absolute_path[LTTNG_PATH_MAX];
-               } LTTNG_PACKED local;
-               struct {
-                       char host[LTTNG_HOST_NAME_MAX];
-                       /*
-                        * Represents values defined in
-                        * enum lttng_trace_archive_location_relay_protocol_type.
-                        */
-                       int8_t protocol;
-                       struct {
-                               uint16_t control;
-                               uint16_t data;
-                       } LTTNG_PACKED ports;
-                       char relative_path[LTTNG_PATH_MAX];
-               } LTTNG_PACKED relay;
-       } location;
-} LTTNG_PACKED;
-
-/* For the LTTNG_SESSION_LIST_SCHEDULES command. */
-struct lttng_session_list_schedules_return {
-       struct {
-               uint8_t set;
-               uint64_t value;
-       } LTTNG_PACKED periodic;
-       struct {
-               uint8_t set;
-               uint64_t value;
-       } LTTNG_PACKED size;
-} LTTNG_PACKED;
-
-#endif /* LTTNG_ROTATE_INTERNAL_ABI_H */
diff --git a/include/lttng/rotate-internal.hpp b/include/lttng/rotate-internal.hpp
new file mode 100644 (file)
index 0000000..076f50a
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ROTATE_INTERNAL_ABI_H
+#define LTTNG_ROTATE_INTERNAL_ABI_H
+
+#include <limits.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <lttng/constant.h>
+#include <lttng/rotation.h>
+#include <common/macros.hpp>
+
+/*
+ * Object returned by the rotate session API.
+ * This is opaque to the public library.
+ */
+struct lttng_rotation_handle {
+       char session_name[LTTNG_NAME_MAX];
+       /*
+        * ID of the rotate command.
+        * This matches the session->rotate_count, so the handle is valid until
+        * the next rotate command. After that, the rotation_get_state command
+        * returns the "expired" state.
+        */
+       uint64_t rotation_id;
+       /*
+        * Where the rotated (readable) trace has been stored when the
+        * rotation is completed.
+        */
+       struct lttng_trace_archive_location *archive_location;
+};
+
+struct lttng_rotation_schedule {
+       enum lttng_rotation_schedule_type type;
+};
+
+struct lttng_rotation_schedule_size_threshold {
+       struct lttng_rotation_schedule parent;
+       struct {
+               bool set;
+               uint64_t bytes;
+       } size;
+};
+
+struct lttng_rotation_schedule_periodic {
+       struct lttng_rotation_schedule parent;
+       struct {
+               bool set;
+               uint64_t us;
+       } period;
+};
+
+struct lttng_rotation_schedules {
+       /*
+        * Only one rotation schedule per type is supported for now.
+        * Schedules are owned by this object.
+        */
+       unsigned int count;
+       struct lttng_rotation_schedule *schedules[2];
+};
+
+/*
+ * Internal objects between lttng-ctl and the session daemon, the values
+ * are then copied to the user's lttng_rotation_handle object.
+ */
+
+/* For the LTTNG_ROTATE_SESSION command. */
+struct lttng_rotate_session_return {
+       uint64_t rotation_id;
+} LTTNG_PACKED;
+
+/* For the LTTNG_ROTATION_GET_INFO command. */
+struct lttng_rotation_get_info_return {
+       /* Represents values defined in enum lttng_rotation_state. */
+       int32_t status;
+       /*
+        * Represents values defined in enum lttng_trace_archive_location_type.
+        */
+       int8_t location_type;
+       union {
+               struct {
+                       char absolute_path[LTTNG_PATH_MAX];
+               } LTTNG_PACKED local;
+               struct {
+                       char host[LTTNG_HOST_NAME_MAX];
+                       /*
+                        * Represents values defined in
+                        * enum lttng_trace_archive_location_relay_protocol_type.
+                        */
+                       int8_t protocol;
+                       struct {
+                               uint16_t control;
+                               uint16_t data;
+                       } LTTNG_PACKED ports;
+                       char relative_path[LTTNG_PATH_MAX];
+               } LTTNG_PACKED relay;
+       } location;
+} LTTNG_PACKED;
+
+/* For the LTTNG_SESSION_LIST_SCHEDULES command. */
+struct lttng_session_list_schedules_return {
+       struct {
+               uint8_t set;
+               uint64_t value;
+       } LTTNG_PACKED periodic;
+       struct {
+               uint8_t set;
+               uint64_t value;
+       } LTTNG_PACKED size;
+} LTTNG_PACKED;
+
+#endif /* LTTNG_ROTATE_INTERNAL_ABI_H */
diff --git a/include/lttng/save-internal.h b/include/lttng/save-internal.h
deleted file mode 100644 (file)
index 1af3f87..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_SAVE_INTERNAL_ABI_H
-#define LTTNG_SAVE_INTERNAL_ABI_H
-
-#include <limits.h>
-#include <stdint.h>
-
-#include <lttng/constant.h>
-#include <common/macros.h>
-
-/*
- * Object used by the save_session API. This is opaque to the public library.
- */
-struct lttng_save_session_attr {
-       /* Name of the session to save, empty string means all. */
-       char session_name[LTTNG_NAME_MAX];
-       /* Destination of the session configuration. See lttng(1) for URL format. */
-       char configuration_url[PATH_MAX];
-       /* Overwrite the session configuration file if it exists. */
-       uint8_t overwrite;
-       /* Omit the sessions' name(s). */
-       uint8_t omit_name;
-       /* Omit the sessions' output(s). */
-       uint8_t omit_output;
-} LTTNG_PACKED;
-
-#endif /* LTTNG_SAVE_INTERNAL_ABI_H */
diff --git a/include/lttng/save-internal.hpp b/include/lttng/save-internal.hpp
new file mode 100644 (file)
index 0000000..6b2bb94
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_SAVE_INTERNAL_ABI_H
+#define LTTNG_SAVE_INTERNAL_ABI_H
+
+#include <limits.h>
+#include <stdint.h>
+
+#include <lttng/constant.h>
+#include <common/macros.hpp>
+
+/*
+ * Object used by the save_session API. This is opaque to the public library.
+ */
+struct lttng_save_session_attr {
+       /* Name of the session to save, empty string means all. */
+       char session_name[LTTNG_NAME_MAX];
+       /* Destination of the session configuration. See lttng(1) for URL format. */
+       char configuration_url[PATH_MAX];
+       /* Overwrite the session configuration file if it exists. */
+       uint8_t overwrite;
+       /* Omit the sessions' name(s). */
+       uint8_t omit_name;
+       /* Omit the sessions' output(s). */
+       uint8_t omit_output;
+} LTTNG_PACKED;
+
+#endif /* LTTNG_SAVE_INTERNAL_ABI_H */
diff --git a/include/lttng/session-descriptor-internal.h b/include/lttng/session-descriptor-internal.h
deleted file mode 100644 (file)
index f438d48..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_SESSION_DESCRIPTOR_INTERNAL_H
-#define LTTNG_SESSION_DESCRIPTOR_INTERNAL_H
-
-#include <lttng/session-descriptor.h>
-#include <lttng/lttng-error.h>
-#include <common/uri.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <stdbool.h>
-
-/* Note that these enums are used as part of the lttnctl protocol. */
-enum lttng_session_descriptor_type {
-       LTTNG_SESSION_DESCRIPTOR_TYPE_UNKNOWN = -1,
-       /*
-        * The output type determines whether this is a no-output, local,
-        * or networked tracing session.
-        */
-       LTTNG_SESSION_DESCRIPTOR_TYPE_REGULAR = 1,
-       LTTNG_SESSION_DESCRIPTOR_TYPE_SNAPSHOT = 2,
-       LTTNG_SESSION_DESCRIPTOR_TYPE_LIVE = 3,
-};
-
-enum lttng_session_descriptor_output_type {
-       LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE = 0,
-       LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_LOCAL = 1,
-       LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK = 2,
-};
-
-ssize_t lttng_session_descriptor_create_from_buffer(
-               const struct lttng_buffer_view *view,
-               struct lttng_session_descriptor **descriptor);
-
-int lttng_session_descriptor_serialize(
-               const struct lttng_session_descriptor *descriptor,
-               struct lttng_dynamic_buffer *buffer);
-
-enum lttng_session_descriptor_type
-lttng_session_descriptor_get_type(
-               const struct lttng_session_descriptor *descriptor);
-
-enum lttng_session_descriptor_output_type
-lttng_session_descriptor_get_output_type(
-               const struct lttng_session_descriptor *descriptor);
-
-void lttng_session_descriptor_get_local_output_uri(
-               const struct lttng_session_descriptor *descriptor,
-               struct lttng_uri *local_uri);
-
-void lttng_session_descriptor_get_network_output_uris(
-               const struct lttng_session_descriptor *descriptor,
-               struct lttng_uri *control,
-               struct lttng_uri *data);
-
-unsigned long long
-lttng_session_descriptor_live_get_timer_interval(
-               const struct lttng_session_descriptor *descriptor);
-
-int lttng_session_descriptor_set_session_name(
-               struct lttng_session_descriptor *descriptor,
-               const char *name);
-
-bool lttng_session_descriptor_is_output_destination_initialized(
-               const struct lttng_session_descriptor *descriptor);
-
-bool lttng_session_descriptor_has_output_directory(
-               const struct lttng_session_descriptor *descriptor);
-
-enum lttng_error_code lttng_session_descriptor_set_default_output(
-               struct lttng_session_descriptor *descriptor,
-               time_t *session_creation_time,
-               const char *absolute_home_path);
-
-int lttng_session_descriptor_assign(
-               struct lttng_session_descriptor *dst_descriptor,
-               const struct lttng_session_descriptor *src_descriptor);
-
-#endif /* LTTNG_SESSION_DESCRIPTOR_INTERNAL_H */
diff --git a/include/lttng/session-descriptor-internal.hpp b/include/lttng/session-descriptor-internal.hpp
new file mode 100644 (file)
index 0000000..c132f56
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_SESSION_DESCRIPTOR_INTERNAL_H
+#define LTTNG_SESSION_DESCRIPTOR_INTERNAL_H
+
+#include <lttng/session-descriptor.h>
+#include <lttng/lttng-error.h>
+#include <common/uri.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
+#include <stdbool.h>
+
+/* Note that these enums are used as part of the lttnctl protocol. */
+enum lttng_session_descriptor_type {
+       LTTNG_SESSION_DESCRIPTOR_TYPE_UNKNOWN = -1,
+       /*
+        * The output type determines whether this is a no-output, local,
+        * or networked tracing session.
+        */
+       LTTNG_SESSION_DESCRIPTOR_TYPE_REGULAR = 1,
+       LTTNG_SESSION_DESCRIPTOR_TYPE_SNAPSHOT = 2,
+       LTTNG_SESSION_DESCRIPTOR_TYPE_LIVE = 3,
+};
+
+enum lttng_session_descriptor_output_type {
+       LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE = 0,
+       LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_LOCAL = 1,
+       LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK = 2,
+};
+
+ssize_t lttng_session_descriptor_create_from_buffer(
+               const struct lttng_buffer_view *view,
+               struct lttng_session_descriptor **descriptor);
+
+int lttng_session_descriptor_serialize(
+               const struct lttng_session_descriptor *descriptor,
+               struct lttng_dynamic_buffer *buffer);
+
+enum lttng_session_descriptor_type
+lttng_session_descriptor_get_type(
+               const struct lttng_session_descriptor *descriptor);
+
+enum lttng_session_descriptor_output_type
+lttng_session_descriptor_get_output_type(
+               const struct lttng_session_descriptor *descriptor);
+
+void lttng_session_descriptor_get_local_output_uri(
+               const struct lttng_session_descriptor *descriptor,
+               struct lttng_uri *local_uri);
+
+void lttng_session_descriptor_get_network_output_uris(
+               const struct lttng_session_descriptor *descriptor,
+               struct lttng_uri *control,
+               struct lttng_uri *data);
+
+unsigned long long
+lttng_session_descriptor_live_get_timer_interval(
+               const struct lttng_session_descriptor *descriptor);
+
+int lttng_session_descriptor_set_session_name(
+               struct lttng_session_descriptor *descriptor,
+               const char *name);
+
+bool lttng_session_descriptor_is_output_destination_initialized(
+               const struct lttng_session_descriptor *descriptor);
+
+bool lttng_session_descriptor_has_output_directory(
+               const struct lttng_session_descriptor *descriptor);
+
+enum lttng_error_code lttng_session_descriptor_set_default_output(
+               struct lttng_session_descriptor *descriptor,
+               time_t *session_creation_time,
+               const char *absolute_home_path);
+
+int lttng_session_descriptor_assign(
+               struct lttng_session_descriptor *dst_descriptor,
+               const struct lttng_session_descriptor *src_descriptor);
+
+#endif /* LTTNG_SESSION_DESCRIPTOR_INTERNAL_H */
diff --git a/include/lttng/session-internal.h b/include/lttng/session-internal.h
deleted file mode 100644 (file)
index 305c3f5..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_SESSION_INTERNAL_H
-#define LTTNG_SESSION_INTERNAL_H
-
-#include <lttng/constant.h>
-#include <common/macros.h>
-
-struct lttng_session_extended {
-       struct {
-               uint64_t value;
-               uint8_t is_set;
-       } LTTNG_PACKED creation_time;
-} LTTNG_PACKED;
-
-#endif /* LTTNG_SESSION_INTERNAL_H */
diff --git a/include/lttng/session-internal.hpp b/include/lttng/session-internal.hpp
new file mode 100644 (file)
index 0000000..7f73b96
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_SESSION_INTERNAL_H
+#define LTTNG_SESSION_INTERNAL_H
+
+#include <lttng/constant.h>
+#include <common/macros.hpp>
+
+struct lttng_session_extended {
+       struct {
+               uint64_t value;
+               uint8_t is_set;
+       } LTTNG_PACKED creation_time;
+} LTTNG_PACKED;
+
+#endif /* LTTNG_SESSION_INTERNAL_H */
diff --git a/include/lttng/snapshot-internal.h b/include/lttng/snapshot-internal.h
deleted file mode 100644 (file)
index 78c7413..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_SNAPSHOT_INTERNAL_ABI_H
-#define LTTNG_SNAPSHOT_INTERNAL_ABI_H
-
-#include <limits.h>
-#include <stdint.h>
-#include <lttng/constant.h>
-#include <common/macros.h>
-
-/*
- * Object used for the snapshot API. This is opaque to the public library.
- */
-struct lttng_snapshot_output {
-       /*
-        * ID of the snapshot output. This is only used when they are listed. It is
-        * assigned by the session daemon so when adding an output, this value will
-        * not be used.
-        */
-       uint32_t id;
-       /*
-        * Maximum size in bytes of the snapshot meaning the total size of all
-        * stream combined. A value of 0 is unlimited.
-        */
-       uint64_t max_size;
-       /* Name of the output so it can be recognized easily when listing them. */
-       char name[LTTNG_NAME_MAX];
-       /* Destination of the output. See lttng(1) for URL format. */
-       char ctrl_url[PATH_MAX];
-       /* Destination of the output. See lttng(1) for URL format. */
-       char data_url[PATH_MAX];
-} LTTNG_PACKED;
-
-/*
- * Snapshot output list object opaque to the user.
- */
-struct lttng_snapshot_output_list {
-       /*
-        * The position in the output array. This is changed by a get_next call.
-        */
-       int index;
-
-       /*
-        * Number of element in the array.
-        */
-       size_t count;
-
-       /*
-        * Contains snapshot output object.
-        */
-       struct lttng_snapshot_output *array;
-};
-
-#endif /* LTTNG_SNAPSHOT_INTERNAL_ABI_H */
diff --git a/include/lttng/snapshot-internal.hpp b/include/lttng/snapshot-internal.hpp
new file mode 100644 (file)
index 0000000..c60a196
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_SNAPSHOT_INTERNAL_ABI_H
+#define LTTNG_SNAPSHOT_INTERNAL_ABI_H
+
+#include <limits.h>
+#include <stdint.h>
+#include <lttng/constant.h>
+#include <common/macros.hpp>
+
+/*
+ * Object used for the snapshot API. This is opaque to the public library.
+ */
+struct lttng_snapshot_output {
+       /*
+        * ID of the snapshot output. This is only used when they are listed. It is
+        * assigned by the session daemon so when adding an output, this value will
+        * not be used.
+        */
+       uint32_t id;
+       /*
+        * Maximum size in bytes of the snapshot meaning the total size of all
+        * stream combined. A value of 0 is unlimited.
+        */
+       uint64_t max_size;
+       /* Name of the output so it can be recognized easily when listing them. */
+       char name[LTTNG_NAME_MAX];
+       /* Destination of the output. See lttng(1) for URL format. */
+       char ctrl_url[PATH_MAX];
+       /* Destination of the output. See lttng(1) for URL format. */
+       char data_url[PATH_MAX];
+} LTTNG_PACKED;
+
+/*
+ * Snapshot output list object opaque to the user.
+ */
+struct lttng_snapshot_output_list {
+       /*
+        * The position in the output array. This is changed by a get_next call.
+        */
+       int index;
+
+       /*
+        * Number of element in the array.
+        */
+       size_t count;
+
+       /*
+        * Contains snapshot output object.
+        */
+       struct lttng_snapshot_output *array;
+};
+
+#endif /* LTTNG_SNAPSHOT_INTERNAL_ABI_H */
diff --git a/include/lttng/trigger/trigger-internal.h b/include/lttng/trigger/trigger-internal.h
deleted file mode 100644 (file)
index dab46ae..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_TRIGGER_INTERNAL_H
-#define LTTNG_TRIGGER_INTERNAL_H
-
-#include <common/credentials.h>
-#include <common/dynamic-array.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/lttng.h>
-#include <pthread.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <urcu/ref.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-struct mi_writer;
-struct mi_lttng_error_query_callbacks;
-
-struct lttng_trigger {
-       /* Reference counting is only exposed to internal users. */
-       struct urcu_ref ref;
-
-       struct lttng_condition *condition;
-       struct lttng_action *action;
-       char *name;
-       /* For now only the uid portion of the credentials is used. */
-       struct lttng_credentials creds;
-       /*
-        * Internal use only.
-        * The unique token passed to the tracer to identify an event-rule
-        * notification.
-        */
-       LTTNG_OPTIONAL(uint64_t) tracer_token;
-
-       /*
-        * Is the trigger registered?
-        *
-        * This is necessary since a reference holder might be interested in the
-        * overall state of the trigger from the point of view of its owner.
-        *
-        * The main user is the action executor since we want to prevent the
-        * execution of actions related to a trigger that is unregistered.
-        *
-        * Not considered for `is_equal`.
-        */
-       bool registered;
-
-       /*
-        * A "hidden" trigger is a trigger that is not externally listed.
-        * It is used to hide triggers that are used internally by the session
-        * daemon so that they can't be listed nor unregistered by external
-        * clients.
-        *
-        * This is a property that can only be set internally by the session
-        * daemon. As such, it is not serialized nor set by a
-        * "create_from_buffer" constructor.
-        *
-        * The hidden property is preserved by copies.
-        *
-        * Note that notifications originating from an "hidden" trigger will not
-        * be sent to clients that are not within the session daemon's process.
-        */
-       bool is_hidden;
-
-       /*
-        * The lock is used to protect against concurrent trigger execution and
-        * trigger removal.
-        */
-       pthread_mutex_t lock;
-};
-
-struct lttng_triggers {
-       struct lttng_dynamic_pointer_array array;
-};
-
-struct lttng_trigger_comm {
-       /*
-        * Credentials, only the uid portion is used for now.
-        * Used as an override when desired by the root user.
-        */
-       uint64_t uid;
-       /*
-        * Length of the variable length payload (name, condition, and
-        * an action).
-        */
-       uint32_t length;
-       /* Includes '\0' terminator. */
-       uint32_t name_length;
-       /* A null-terminated name, a condition, and an action follow. */
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_triggers_comm {
-       uint32_t count;
-       uint32_t length;
-       /* Count * lttng_trigger_comm structure */
-       char payload[];
-};
-
-ssize_t lttng_trigger_create_from_payload(struct lttng_payload_view *view,
-               struct lttng_trigger **trigger);
-
-int lttng_trigger_serialize(const struct lttng_trigger *trigger,
-               struct lttng_payload *payload);
-
-bool lttng_trigger_validate(const struct lttng_trigger *trigger);
-
-int lttng_trigger_assign_name(
-               struct lttng_trigger *dst, const struct lttng_trigger *src);
-
-void lttng_trigger_set_tracer_token(
-               struct lttng_trigger *trigger, uint64_t token);
-
-uint64_t lttng_trigger_get_tracer_token(const struct lttng_trigger *trigger);
-
-int lttng_trigger_generate_name(struct lttng_trigger *trigger,
-               uint64_t unique_id);
-
-bool lttng_trigger_is_equal(
-               const struct lttng_trigger *a, const struct lttng_trigger *b);
-
-bool lttng_trigger_is_hidden(const struct lttng_trigger *trigger);
-
-void lttng_trigger_set_hidden(struct lttng_trigger *trigger);
-
-void lttng_trigger_get(struct lttng_trigger *trigger);
-
-void lttng_trigger_put(struct lttng_trigger *trigger);
-
-/*
- * Serialize a trigger to a mi_writer.
- * Return LTTNG_OK in success, other enum lttng_error_code on error.
- */
-enum lttng_error_code lttng_trigger_mi_serialize(const struct lttng_trigger *trigger,
-               struct mi_writer *writer,
-               const struct mi_lttng_error_query_callbacks
-                               *error_query_callbacks);
-
-/*
- * Allocate a new set of triggers.
- * The returned object must be freed via lttng_triggers_destroy.
- */
-struct lttng_triggers *lttng_triggers_create(void);
-
-/*
- * Return the a pointer to a mutable element at index "index" of an
- * lttng_triggers set.
- *
- * This differs from the public `lttng_triggers_get_at_index` in that
- * the returned pointer to a mutable trigger.
- *
- * The ownership of the trigger set element is NOT transfered.
- * The returned object can NOT be freed via lttng_trigger_destroy.
- */
-struct lttng_trigger *lttng_triggers_borrow_mutable_at_index(
-               const struct lttng_triggers *triggers, unsigned int index);
-
-/*
- * Add a trigger to the triggers set.
- *
- * A reference to the added trigger is acquired on behalf of the trigger set
- * on success.
- */
-int lttng_triggers_add(
-               struct lttng_triggers *triggers, struct lttng_trigger *trigger);
-
-/*
- * Remove all triggers marked as hidden from the provided trigger set.
- */
-int lttng_triggers_remove_hidden_triggers(struct lttng_triggers *triggers);
-
-/*
- * Serialize a trigger set to an lttng_payload object.
- * Return LTTNG_OK on success, negative lttng error code on error.
- */
-int lttng_triggers_serialize(const struct lttng_triggers *triggers,
-               struct lttng_payload *payload);
-
-ssize_t lttng_triggers_create_from_payload(struct lttng_payload_view *view,
-               struct lttng_triggers **triggers);
-
-/*
- * Serialize a trigger set to a mi_writer.
- * Return LTTNG_OK in success, other enum lttng_error_code on error.
- */
-enum lttng_error_code lttng_triggers_mi_serialize(const struct lttng_triggers *triggers,
-               struct mi_writer *writer,
-               const struct mi_lttng_error_query_callbacks
-                               *error_query_callbacks);
-
-const struct lttng_credentials *lttng_trigger_get_credentials(
-               const struct lttng_trigger *trigger);
-
-void lttng_trigger_set_credentials(struct lttng_trigger *trigger,
-               const struct lttng_credentials *creds);
-
-/*
- * Return the type of any underlying domain restriction. If no particular
- * requirement is present, returns LTTNG_DOMAIN_NONE.
- */
-enum lttng_domain_type lttng_trigger_get_underlying_domain_type_restriction(
-               const struct lttng_trigger *trigger);
-
-/*
- * Generate any bytecode related to the trigger.
- * On success LTTNG_OK. On error, returns lttng_error code.
- */
-enum lttng_error_code lttng_trigger_generate_bytecode(
-               struct lttng_trigger *trigger,
-               const struct lttng_credentials *creds);
-
-/*
- * Note that the trigger object is not locked by "copy" as it is const and
- * used with a number of 'const' triggers. If the trigger could be shared at
- * the moment of the copy, it is the caller's responsability to lock it for
- * the duration of the copy.
- */
-struct lttng_trigger *lttng_trigger_copy(const struct lttng_trigger *trigger);
-
-/*
- * A given trigger needs a tracer notifier if
- *  it has an event-rule condition,
- *  AND
- *  it has one or more sessiond-execution action.
- */
-bool lttng_trigger_needs_tracer_notifier(const struct lttng_trigger *trigger);
-
-void lttng_trigger_set_as_registered(struct lttng_trigger *trigger);
-
-void lttng_trigger_set_as_unregistered(struct lttng_trigger *trigger);
-
-/*
- * The trigger must be locked before calling lttng_trigger_is_registered.
- *
- * The lock is necessary since a trigger can be unregistered at any time.
- *
- * Manipulations requiring that the trigger be registered must always acquire
- * the trigger lock for the duration of the manipulation using
- * `lttng_trigger_lock` and `lttng_trigger_unlock`.
- */
-bool lttng_trigger_is_registered(struct lttng_trigger *trigger);
-
-void lttng_trigger_lock(struct lttng_trigger *trigger);
-
-void lttng_trigger_unlock(struct lttng_trigger *trigger);
-
-enum lttng_trigger_status lttng_trigger_add_error_results(
-               const struct lttng_trigger *trigger,
-               struct lttng_error_query_results *results);
-
-enum lttng_trigger_status lttng_trigger_condition_add_error_results(
-               const struct lttng_trigger *trigger,
-               struct lttng_error_query_results *results);
-
-enum lttng_trigger_status lttng_trigger_add_action_error_query_results(
-               struct lttng_trigger *trigger,
-               struct lttng_error_query_results *results);
-
-/*
- * Set the trigger name.
- *
- * A name is optional.
- * A name will be assigned on trigger registration if no name is set.
- *
- * The name is copied.
- *
- * Return LTTNG_TRIGGER_STATUS_OK on success, LTTNG_TRIGGER_STATUS_INVALID
- * if invalid parameters are passed.
- */
-enum lttng_trigger_status lttng_trigger_set_name(
-               struct lttng_trigger *trigger, const char *name);
-
-#endif /* LTTNG_TRIGGER_INTERNAL_H */
diff --git a/include/lttng/trigger/trigger-internal.hpp b/include/lttng/trigger/trigger-internal.hpp
new file mode 100644 (file)
index 0000000..206e7df
--- /dev/null
@@ -0,0 +1,281 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_TRIGGER_INTERNAL_H
+#define LTTNG_TRIGGER_INTERNAL_H
+
+#include <common/credentials.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/lttng.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <urcu/ref.h>
+
+struct lttng_payload;
+struct lttng_payload_view;
+struct mi_writer;
+struct mi_lttng_error_query_callbacks;
+
+struct lttng_trigger {
+       /* Reference counting is only exposed to internal users. */
+       struct urcu_ref ref;
+
+       struct lttng_condition *condition;
+       struct lttng_action *action;
+       char *name;
+       /* For now only the uid portion of the credentials is used. */
+       struct lttng_credentials creds;
+       /*
+        * Internal use only.
+        * The unique token passed to the tracer to identify an event-rule
+        * notification.
+        */
+       LTTNG_OPTIONAL(uint64_t) tracer_token;
+
+       /*
+        * Is the trigger registered?
+        *
+        * This is necessary since a reference holder might be interested in the
+        * overall state of the trigger from the point of view of its owner.
+        *
+        * The main user is the action executor since we want to prevent the
+        * execution of actions related to a trigger that is unregistered.
+        *
+        * Not considered for `is_equal`.
+        */
+       bool registered;
+
+       /*
+        * A "hidden" trigger is a trigger that is not externally listed.
+        * It is used to hide triggers that are used internally by the session
+        * daemon so that they can't be listed nor unregistered by external
+        * clients.
+        *
+        * This is a property that can only be set internally by the session
+        * daemon. As such, it is not serialized nor set by a
+        * "create_from_buffer" constructor.
+        *
+        * The hidden property is preserved by copies.
+        *
+        * Note that notifications originating from an "hidden" trigger will not
+        * be sent to clients that are not within the session daemon's process.
+        */
+       bool is_hidden;
+
+       /*
+        * The lock is used to protect against concurrent trigger execution and
+        * trigger removal.
+        */
+       pthread_mutex_t lock;
+};
+
+struct lttng_triggers {
+       struct lttng_dynamic_pointer_array array;
+};
+
+struct lttng_trigger_comm {
+       /*
+        * Credentials, only the uid portion is used for now.
+        * Used as an override when desired by the root user.
+        */
+       uint64_t uid;
+       /*
+        * Length of the variable length payload (name, condition, and
+        * an action).
+        */
+       uint32_t length;
+       /* Includes '\0' terminator. */
+       uint32_t name_length;
+       /* A null-terminated name, a condition, and an action follow. */
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_triggers_comm {
+       uint32_t count;
+       uint32_t length;
+       /* Count * lttng_trigger_comm structure */
+       char payload[];
+};
+
+ssize_t lttng_trigger_create_from_payload(struct lttng_payload_view *view,
+               struct lttng_trigger **trigger);
+
+int lttng_trigger_serialize(const struct lttng_trigger *trigger,
+               struct lttng_payload *payload);
+
+bool lttng_trigger_validate(const struct lttng_trigger *trigger);
+
+int lttng_trigger_assign_name(
+               struct lttng_trigger *dst, const struct lttng_trigger *src);
+
+void lttng_trigger_set_tracer_token(
+               struct lttng_trigger *trigger, uint64_t token);
+
+uint64_t lttng_trigger_get_tracer_token(const struct lttng_trigger *trigger);
+
+int lttng_trigger_generate_name(struct lttng_trigger *trigger,
+               uint64_t unique_id);
+
+bool lttng_trigger_is_equal(
+               const struct lttng_trigger *a, const struct lttng_trigger *b);
+
+bool lttng_trigger_is_hidden(const struct lttng_trigger *trigger);
+
+void lttng_trigger_set_hidden(struct lttng_trigger *trigger);
+
+void lttng_trigger_get(struct lttng_trigger *trigger);
+
+void lttng_trigger_put(struct lttng_trigger *trigger);
+
+/*
+ * Serialize a trigger to a mi_writer.
+ * Return LTTNG_OK in success, other enum lttng_error_code on error.
+ */
+enum lttng_error_code lttng_trigger_mi_serialize(const struct lttng_trigger *trigger,
+               struct mi_writer *writer,
+               const struct mi_lttng_error_query_callbacks
+                               *error_query_callbacks);
+
+/*
+ * Allocate a new set of triggers.
+ * The returned object must be freed via lttng_triggers_destroy.
+ */
+struct lttng_triggers *lttng_triggers_create(void);
+
+/*
+ * Return the a pointer to a mutable element at index "index" of an
+ * lttng_triggers set.
+ *
+ * This differs from the public `lttng_triggers_get_at_index` in that
+ * the returned pointer to a mutable trigger.
+ *
+ * The ownership of the trigger set element is NOT transfered.
+ * The returned object can NOT be freed via lttng_trigger_destroy.
+ */
+struct lttng_trigger *lttng_triggers_borrow_mutable_at_index(
+               const struct lttng_triggers *triggers, unsigned int index);
+
+/*
+ * Add a trigger to the triggers set.
+ *
+ * A reference to the added trigger is acquired on behalf of the trigger set
+ * on success.
+ */
+int lttng_triggers_add(
+               struct lttng_triggers *triggers, struct lttng_trigger *trigger);
+
+/*
+ * Remove all triggers marked as hidden from the provided trigger set.
+ */
+int lttng_triggers_remove_hidden_triggers(struct lttng_triggers *triggers);
+
+/*
+ * Serialize a trigger set to an lttng_payload object.
+ * Return LTTNG_OK on success, negative lttng error code on error.
+ */
+int lttng_triggers_serialize(const struct lttng_triggers *triggers,
+               struct lttng_payload *payload);
+
+ssize_t lttng_triggers_create_from_payload(struct lttng_payload_view *view,
+               struct lttng_triggers **triggers);
+
+/*
+ * Serialize a trigger set to a mi_writer.
+ * Return LTTNG_OK in success, other enum lttng_error_code on error.
+ */
+enum lttng_error_code lttng_triggers_mi_serialize(const struct lttng_triggers *triggers,
+               struct mi_writer *writer,
+               const struct mi_lttng_error_query_callbacks
+                               *error_query_callbacks);
+
+const struct lttng_credentials *lttng_trigger_get_credentials(
+               const struct lttng_trigger *trigger);
+
+void lttng_trigger_set_credentials(struct lttng_trigger *trigger,
+               const struct lttng_credentials *creds);
+
+/*
+ * Return the type of any underlying domain restriction. If no particular
+ * requirement is present, returns LTTNG_DOMAIN_NONE.
+ */
+enum lttng_domain_type lttng_trigger_get_underlying_domain_type_restriction(
+               const struct lttng_trigger *trigger);
+
+/*
+ * Generate any bytecode related to the trigger.
+ * On success LTTNG_OK. On error, returns lttng_error code.
+ */
+enum lttng_error_code lttng_trigger_generate_bytecode(
+               struct lttng_trigger *trigger,
+               const struct lttng_credentials *creds);
+
+/*
+ * Note that the trigger object is not locked by "copy" as it is const and
+ * used with a number of 'const' triggers. If the trigger could be shared at
+ * the moment of the copy, it is the caller's responsability to lock it for
+ * the duration of the copy.
+ */
+struct lttng_trigger *lttng_trigger_copy(const struct lttng_trigger *trigger);
+
+/*
+ * A given trigger needs a tracer notifier if
+ *  it has an event-rule condition,
+ *  AND
+ *  it has one or more sessiond-execution action.
+ */
+bool lttng_trigger_needs_tracer_notifier(const struct lttng_trigger *trigger);
+
+void lttng_trigger_set_as_registered(struct lttng_trigger *trigger);
+
+void lttng_trigger_set_as_unregistered(struct lttng_trigger *trigger);
+
+/*
+ * The trigger must be locked before calling lttng_trigger_is_registered.
+ *
+ * The lock is necessary since a trigger can be unregistered at any time.
+ *
+ * Manipulations requiring that the trigger be registered must always acquire
+ * the trigger lock for the duration of the manipulation using
+ * `lttng_trigger_lock` and `lttng_trigger_unlock`.
+ */
+bool lttng_trigger_is_registered(struct lttng_trigger *trigger);
+
+void lttng_trigger_lock(struct lttng_trigger *trigger);
+
+void lttng_trigger_unlock(struct lttng_trigger *trigger);
+
+enum lttng_trigger_status lttng_trigger_add_error_results(
+               const struct lttng_trigger *trigger,
+               struct lttng_error_query_results *results);
+
+enum lttng_trigger_status lttng_trigger_condition_add_error_results(
+               const struct lttng_trigger *trigger,
+               struct lttng_error_query_results *results);
+
+enum lttng_trigger_status lttng_trigger_add_action_error_query_results(
+               struct lttng_trigger *trigger,
+               struct lttng_error_query_results *results);
+
+/*
+ * Set the trigger name.
+ *
+ * A name is optional.
+ * A name will be assigned on trigger registration if no name is set.
+ *
+ * The name is copied.
+ *
+ * Return LTTNG_TRIGGER_STATUS_OK on success, LTTNG_TRIGGER_STATUS_INVALID
+ * if invalid parameters are passed.
+ */
+enum lttng_trigger_status lttng_trigger_set_name(
+               struct lttng_trigger *trigger, const char *name);
+
+#endif /* LTTNG_TRIGGER_INTERNAL_H */
diff --git a/include/lttng/userspace-probe-internal.h b/include/lttng/userspace-probe-internal.h
deleted file mode 100644 (file)
index 5e960c1..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_USERSPACE_PROBE_INTERNAL_H
-#define LTTNG_USERSPACE_PROBE_INTERNAL_H
-
-#include <lttng/userspace-probe.h>
-#include <common/macros.h>
-#include <common/fd-handle.h>
-#include <stdbool.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-struct lttng_dynamic_buffer;
-struct mi_writer;
-
-typedef bool (*userspace_probe_location_equal_cb)(
-               const struct lttng_userspace_probe_location *a,
-               const struct lttng_userspace_probe_location *b);
-typedef unsigned long (*userspace_probe_location_hash_cb)(
-               const struct lttng_userspace_probe_location *location);
-typedef enum lttng_error_code (*userspace_probe_location_mi)(
-               const struct lttng_userspace_probe_location *location,
-               struct mi_writer);
-
-/*
- * No elf-specific comm structure is defined since no elf-specific payload is
- * currently needed.
- */
-struct lttng_userspace_probe_location_lookup_method_comm {
-       /* enum lttng_userspace_probe_location_lookup_method_type */
-       int8_t type;
-       /* type-specific payload */
-       char payload[];
-};
-
-/* Common ancestor of all userspace probe location lookup methods. */
-struct lttng_userspace_probe_location_lookup_method {
-       enum lttng_userspace_probe_location_lookup_method_type type;
-};
-
-struct lttng_userspace_probe_location_lookup_method_elf {
-       struct lttng_userspace_probe_location_lookup_method parent;
-};
-
-struct lttng_userspace_probe_location_lookup_method_sdt {
-       struct lttng_userspace_probe_location_lookup_method parent;
-};
-
-struct lttng_userspace_probe_location_comm {
-       /* enum lttng_userspace_probe_location_type */
-       int8_t type;
-       /*
-        * Payload is composed of, in that order,
-        *   - type-specific payload
-        *   - struct lttng_userspace_probe_location_lookup_method_comm
-        */
-       char payload[];
-};
-
-struct lttng_userspace_probe_location_function_comm {
-       /* Both lengths include the trailing \0. */
-       uint32_t function_name_len;
-       uint32_t binary_path_len;
-       /*
-        * Payload is composed of, in that order,
-        *   - function name (with trailing \0),
-        *   - absolute binary path (with trailing \0)
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-struct lttng_userspace_probe_location_tracepoint_comm {
-       /* The three lengths include the trailing \0. */
-       uint32_t probe_name_len;
-       uint32_t provider_name_len;
-       uint32_t binary_path_len;
-       /*
-        * Payload is composed of, in that order,
-        *   - probe name (with trailing \0),
-        *   - provider name (with trailing \0),
-        *   - absolute binary path (with trailing \0)
-        */
-       char payload[];
-} LTTNG_PACKED;
-
-/* Common ancestor of all userspace probe locations. */
-struct lttng_userspace_probe_location {
-       enum lttng_userspace_probe_location_type type;
-       struct lttng_userspace_probe_location_lookup_method *lookup_method;
-       userspace_probe_location_equal_cb equal;
-       userspace_probe_location_hash_cb hash;
-       userspace_probe_location_hash_cb mi;
-};
-
-struct lttng_userspace_probe_location_function {
-       struct lttng_userspace_probe_location parent;
-       char *function_name;
-       char *binary_path;
-       /*
-        * binary_fd is a file descriptor to the executable file. It's open
-        * early on to keep the backing inode valid over the course of the
-        * intrumentation and use. It prevents deletion and reuse races.
-        */
-       struct fd_handle *binary_fd_handle;
-       enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
-};
-
-struct lttng_userspace_probe_location_tracepoint {
-       struct lttng_userspace_probe_location parent;
-       char *probe_name;
-       char *provider_name;
-       char *binary_path;
-       /*
-        * binary_fd is a file descriptor to the executable file. It's open
-        * early on to keep the backing inode valid over the course of the
-        * intrumentation and use. It prevents deletion and reuse races.
-        */
-       struct fd_handle *binary_fd_handle;
-};
-
-int lttng_userspace_probe_location_serialize(
-               const struct lttng_userspace_probe_location *location,
-               struct lttng_payload *payload);
-
-int lttng_userspace_probe_location_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_userspace_probe_location **probe_location);
-
-/*
- * Returns a version of the location that is serialized to a contiguous region
- * of memory. Pass NULL to buffer to only get the storage requirement of the
- * flattened userspace probe location.
- */
-int lttng_userspace_probe_location_flatten(
-               const struct lttng_userspace_probe_location *location,
-               struct lttng_dynamic_buffer *buffer);
-
-struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
-               const struct lttng_userspace_probe_location *location);
-
-bool lttng_userspace_probe_location_lookup_method_is_equal(
-               const struct lttng_userspace_probe_location_lookup_method *a,
-               const struct lttng_userspace_probe_location_lookup_method *b);
-
-bool lttng_userspace_probe_location_is_equal(
-               const struct lttng_userspace_probe_location *a,
-               const struct lttng_userspace_probe_location *b);
-
-unsigned long lttng_userspace_probe_location_hash(
-               const struct lttng_userspace_probe_location *location);
-
-enum lttng_error_code lttng_userspace_probe_location_mi_serialize(
-               const struct lttng_userspace_probe_location *location,
-               struct mi_writer *writer);
-
-#endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
diff --git a/include/lttng/userspace-probe-internal.hpp b/include/lttng/userspace-probe-internal.hpp
new file mode 100644 (file)
index 0000000..392242d
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_USERSPACE_PROBE_INTERNAL_H
+#define LTTNG_USERSPACE_PROBE_INTERNAL_H
+
+#include <lttng/userspace-probe.h>
+#include <common/macros.hpp>
+#include <common/fd-handle.hpp>
+#include <stdbool.h>
+
+struct lttng_payload;
+struct lttng_payload_view;
+struct lttng_dynamic_buffer;
+struct mi_writer;
+
+typedef bool (*userspace_probe_location_equal_cb)(
+               const struct lttng_userspace_probe_location *a,
+               const struct lttng_userspace_probe_location *b);
+typedef unsigned long (*userspace_probe_location_hash_cb)(
+               const struct lttng_userspace_probe_location *location);
+typedef enum lttng_error_code (*userspace_probe_location_mi)(
+               const struct lttng_userspace_probe_location *location,
+               struct mi_writer);
+
+/*
+ * No elf-specific comm structure is defined since no elf-specific payload is
+ * currently needed.
+ */
+struct lttng_userspace_probe_location_lookup_method_comm {
+       /* enum lttng_userspace_probe_location_lookup_method_type */
+       int8_t type;
+       /* type-specific payload */
+       char payload[];
+};
+
+/* Common ancestor of all userspace probe location lookup methods. */
+struct lttng_userspace_probe_location_lookup_method {
+       enum lttng_userspace_probe_location_lookup_method_type type;
+};
+
+struct lttng_userspace_probe_location_lookup_method_elf {
+       struct lttng_userspace_probe_location_lookup_method parent;
+};
+
+struct lttng_userspace_probe_location_lookup_method_sdt {
+       struct lttng_userspace_probe_location_lookup_method parent;
+};
+
+struct lttng_userspace_probe_location_comm {
+       /* enum lttng_userspace_probe_location_type */
+       int8_t type;
+       /*
+        * Payload is composed of, in that order,
+        *   - type-specific payload
+        *   - struct lttng_userspace_probe_location_lookup_method_comm
+        */
+       char payload[];
+};
+
+struct lttng_userspace_probe_location_function_comm {
+       /* Both lengths include the trailing \0. */
+       uint32_t function_name_len;
+       uint32_t binary_path_len;
+       /*
+        * Payload is composed of, in that order,
+        *   - function name (with trailing \0),
+        *   - absolute binary path (with trailing \0)
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+struct lttng_userspace_probe_location_tracepoint_comm {
+       /* The three lengths include the trailing \0. */
+       uint32_t probe_name_len;
+       uint32_t provider_name_len;
+       uint32_t binary_path_len;
+       /*
+        * Payload is composed of, in that order,
+        *   - probe name (with trailing \0),
+        *   - provider name (with trailing \0),
+        *   - absolute binary path (with trailing \0)
+        */
+       char payload[];
+} LTTNG_PACKED;
+
+/* Common ancestor of all userspace probe locations. */
+struct lttng_userspace_probe_location {
+       enum lttng_userspace_probe_location_type type;
+       struct lttng_userspace_probe_location_lookup_method *lookup_method;
+       userspace_probe_location_equal_cb equal;
+       userspace_probe_location_hash_cb hash;
+       userspace_probe_location_hash_cb mi;
+};
+
+struct lttng_userspace_probe_location_function {
+       struct lttng_userspace_probe_location parent;
+       char *function_name;
+       char *binary_path;
+       /*
+        * binary_fd is a file descriptor to the executable file. It's open
+        * early on to keep the backing inode valid over the course of the
+        * intrumentation and use. It prevents deletion and reuse races.
+        */
+       struct fd_handle *binary_fd_handle;
+       enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
+};
+
+struct lttng_userspace_probe_location_tracepoint {
+       struct lttng_userspace_probe_location parent;
+       char *probe_name;
+       char *provider_name;
+       char *binary_path;
+       /*
+        * binary_fd is a file descriptor to the executable file. It's open
+        * early on to keep the backing inode valid over the course of the
+        * intrumentation and use. It prevents deletion and reuse races.
+        */
+       struct fd_handle *binary_fd_handle;
+};
+
+int lttng_userspace_probe_location_serialize(
+               const struct lttng_userspace_probe_location *location,
+               struct lttng_payload *payload);
+
+int lttng_userspace_probe_location_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_userspace_probe_location **probe_location);
+
+/*
+ * Returns a version of the location that is serialized to a contiguous region
+ * of memory. Pass NULL to buffer to only get the storage requirement of the
+ * flattened userspace probe location.
+ */
+int lttng_userspace_probe_location_flatten(
+               const struct lttng_userspace_probe_location *location,
+               struct lttng_dynamic_buffer *buffer);
+
+struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
+               const struct lttng_userspace_probe_location *location);
+
+bool lttng_userspace_probe_location_lookup_method_is_equal(
+               const struct lttng_userspace_probe_location_lookup_method *a,
+               const struct lttng_userspace_probe_location_lookup_method *b);
+
+bool lttng_userspace_probe_location_is_equal(
+               const struct lttng_userspace_probe_location *a,
+               const struct lttng_userspace_probe_location *b);
+
+unsigned long lttng_userspace_probe_location_hash(
+               const struct lttng_userspace_probe_location *location);
+
+enum lttng_error_code lttng_userspace_probe_location_mi_serialize(
+               const struct lttng_userspace_probe_location *location,
+               struct mi_writer *writer);
+
+#endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
diff --git a/include/version.h b/include/version.h
deleted file mode 100644 (file)
index 9bd5e0c..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Raphaël Beamonte <raphael.beamonte@gmail.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef VERSION_H
-#define VERSION_H
-
-#include <version.i>
-
-#endif /* VERSION_H */
diff --git a/include/version.hpp b/include/version.hpp
new file mode 100644 (file)
index 0000000..9bd5e0c
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2013-2014 Raphaël Beamonte <raphael.beamonte@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef VERSION_H
+#define VERSION_H
+
+#include <version.i>
+
+#endif /* VERSION_H */
index 19bc7ed4cda4f6e8463e75190758b48538d740d6..3ad8210ccbadd28a49688b20818bd07090a96343 100644 (file)
@@ -4,9 +4,9 @@ lttnglibexec_PROGRAMS = lttng-consumerd
 
 lttng_consumerd_SOURCES = \
        lttng-consumerd.cpp \
-       lttng-consumerd.h \
+       lttng-consumerd.hpp \
        health-consumerd.cpp \
-       health-consumerd.h
+       health-consumerd.hpp
 
 lttng_consumerd_LDADD = \
           $(top_builddir)/src/common/libconsumer.la \
index e3adbe1422fc92aabe5d68e6d330b2e17bd90006..8417fc6dccfca4122561edeadb4b2d623dc9f029 100644 (file)
 #include <ulimit.h>
 #include <inttypes.h>
 
-#include <common/defaults.h>
-#include <common/common.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/compat/poll.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
-
-#include "lttng-consumerd.h"
-#include "health-consumerd.h"
+#include <common/defaults.hpp>
+#include <common/common.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/compat/poll.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+
+#include "lttng-consumerd.hpp"
+#include "health-consumerd.hpp"
 
 /* Global health check unix path */
 static char health_unix_sock_path[PATH_MAX];
diff --git a/src/bin/lttng-consumerd/health-consumerd.h b/src/bin/lttng-consumerd/health-consumerd.h
deleted file mode 100644 (file)
index 9faa081..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef HEALTH_CONSUMERD_H
-#define HEALTH_CONSUMERD_H
-
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- */
-
-#include <lttng/health-internal.h>
-
-enum health_type_consumerd {
-       HEALTH_CONSUMERD_TYPE_CHANNEL           = 0,
-       HEALTH_CONSUMERD_TYPE_METADATA          = 1,
-       HEALTH_CONSUMERD_TYPE_DATA              = 2,
-       HEALTH_CONSUMERD_TYPE_SESSIOND          = 3,
-       HEALTH_CONSUMERD_TYPE_METADATA_TIMER    = 4,
-
-       NR_HEALTH_CONSUMERD_TYPES,
-};
-
-/* Consumerd health monitoring */
-extern struct health_app *health_consumerd;
-
-void *thread_manage_health_consumerd(void *data);
-
-extern int health_quit_pipe[2];
-
-#endif /* HEALTH_CONSUMERD_H */
diff --git a/src/bin/lttng-consumerd/health-consumerd.hpp b/src/bin/lttng-consumerd/health-consumerd.hpp
new file mode 100644 (file)
index 0000000..4e3bf86
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef HEALTH_CONSUMERD_H
+#define HEALTH_CONSUMERD_H
+
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ */
+
+#include <lttng/health-internal.hpp>
+
+enum health_type_consumerd {
+       HEALTH_CONSUMERD_TYPE_CHANNEL           = 0,
+       HEALTH_CONSUMERD_TYPE_METADATA          = 1,
+       HEALTH_CONSUMERD_TYPE_DATA              = 2,
+       HEALTH_CONSUMERD_TYPE_SESSIOND          = 3,
+       HEALTH_CONSUMERD_TYPE_METADATA_TIMER    = 4,
+
+       NR_HEALTH_CONSUMERD_TYPES,
+};
+
+/* Consumerd health monitoring */
+extern struct health_app *health_consumerd;
+
+void *thread_manage_health_consumerd(void *data);
+
+extern int health_quit_pipe[2];
+
+#endif /* HEALTH_CONSUMERD_H */
index 3ee13dcb52bd9396cf2b378104d270873290183f..47d1e113d25f5201e678ade7e5ad4cc2506a8606 100644 (file)
 #include <urcu/compiler.h>
 #include <ulimit.h>
 
-#include <common/defaults.h>
-#include <common/common.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/compat/poll.h>
-#include <common/compat/getenv.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
-
-#include "lttng-consumerd.h"
-#include "health-consumerd.h"
+#include <common/defaults.hpp>
+#include <common/common.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/compat/poll.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+
+#include "lttng-consumerd.hpp"
+#include "health-consumerd.hpp"
 
 /* threads (channel handling, poll, metadata, sessiond) */
 
diff --git a/src/bin/lttng-consumerd/lttng-consumerd.h b/src/bin/lttng-consumerd/lttng-consumerd.h
deleted file mode 100644 (file)
index 833116a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_CONSUMERD_H
-#define _LTTNG_CONSUMERD_H
-
-
-#define NR_LTTNG_CONSUMER_READY                1
-extern int lttng_consumer_ready;
-
-extern const char *tracing_group_name;
-
-/*
- * This function is dlsym-ed from a test, so needs to be exported.  Making it
- * have a C linkage name makes it easier, as it avoids having to look up a
- * mangled name.
- */
-extern "C" LTTNG_EXPORT
-enum lttng_consumer_type lttng_consumer_get_type();
-
-#endif /* _LTTNG_CONSUMERD_H */
diff --git a/src/bin/lttng-consumerd/lttng-consumerd.hpp b/src/bin/lttng-consumerd/lttng-consumerd.hpp
new file mode 100644 (file)
index 0000000..833116a
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_CONSUMERD_H
+#define _LTTNG_CONSUMERD_H
+
+
+#define NR_LTTNG_CONSUMER_READY                1
+extern int lttng_consumer_ready;
+
+extern const char *tracing_group_name;
+
+/*
+ * This function is dlsym-ed from a test, so needs to be exported.  Making it
+ * have a C linkage name makes it easier, as it avoids having to look up a
+ * mangled name.
+ */
+extern "C" LTTNG_EXPORT
+enum lttng_consumer_type lttng_consumer_get_type();
+
+#endif /* _LTTNG_CONSUMERD_H */
diff --git a/src/bin/lttng-consumerd/testpoint.h b/src/bin/lttng-consumerd/testpoint.h
deleted file mode 100644 (file)
index e0b8b3e..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef CONSUMERD_TESTPOINT_H
-#define CONSUMERD_TESTPOINT_H
-
-#include <common/testpoint/testpoint.h>
-
-/* Testpoints, internal use only */
-TESTPOINT_DECL(consumerd_data_thread_poll);
-
-#endif /* CONSUMERD_TESTPOINT_H */
diff --git a/src/bin/lttng-consumerd/testpoint.hpp b/src/bin/lttng-consumerd/testpoint.hpp
new file mode 100644 (file)
index 0000000..da7eed5
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef CONSUMERD_TESTPOINT_H
+#define CONSUMERD_TESTPOINT_H
+
+#include <common/testpoint/testpoint.hpp>
+
+/* Testpoints, internal use only */
+TESTPOINT_DECL(consumerd_data_thread_poll);
+
+#endif /* CONSUMERD_TESTPOINT_H */
index bee9c29b0fd5bfc75cdf540df2b404835baa5893..0b4afc91bdfa49a95ed980fcd33f25cf3b627de4 100644 (file)
 #include <unistd.h>
 #include <ctype.h>
 #include <dirent.h>
-#include <common/compat/endian.h>
+#include <common/compat/endian.hpp>
 #include <inttypes.h>
 #include <stdbool.h>
 
-#include <version.h>
+#include <version.hpp>
 #include <lttng/lttng.h>
-#include <common/common.h>
-#include <common/spawn-viewer.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/spawn-viewer.hpp>
+#include <common/utils.hpp>
 
 #define COPY_BUFLEN            4096
 #define RB_CRASH_DUMP_ABI_LEN  32
index afb435f06e76609bb6d7f0f86473282849e3b0d3..b473d5c62b29463eb449bc7ee096ae9a96ab672b 100644 (file)
@@ -9,23 +9,23 @@ endif
 
 bin_PROGRAMS = lttng-relayd
 
-lttng_relayd_SOURCES = main.cpp lttng-relayd.h utils.h utils.cpp cmd.h \
-                       index.cpp index.h live.cpp live.h ctf-trace.cpp ctf-trace.h \
-                       cmd-2-1.cpp cmd-2-1.h \
-                       cmd-2-2.cpp cmd-2-2.h \
-                       cmd-2-4.cpp cmd-2-4.h \
-                       cmd-2-11.cpp cmd-2-11.h \
-                       health-relayd.cpp health-relayd.h \
-                       lttng-viewer-abi.h testpoint.h \
-                       viewer-stream.h viewer-stream.cpp \
-                       session.cpp session.h \
-                       stream.cpp stream.h \
-                       connection.cpp connection.h \
-                       viewer-session.cpp viewer-session.h \
-                       tracefile-array.cpp tracefile-array.h \
-                       tcp_keep_alive.cpp tcp_keep_alive.h \
-                       sessiond-trace-chunks.cpp sessiond-trace-chunks.h \
-                       backward-compatibility-group-by.cpp backward-compatibility-group-by.h
+lttng_relayd_SOURCES = main.cpp lttng-relayd.hpp utils.hpp utils.cpp cmd.hpp \
+                       index.cpp index.hpp live.cpp live.hpp ctf-trace.cpp ctf-trace.hpp \
+                       cmd-2-1.cpp cmd-2-1.hpp \
+                       cmd-2-2.cpp cmd-2-2.hpp \
+                       cmd-2-4.cpp cmd-2-4.hpp \
+                       cmd-2-11.cpp cmd-2-11.hpp \
+                       health-relayd.cpp health-relayd.hpp \
+                       lttng-viewer-abi.hpp testpoint.hpp \
+                       viewer-stream.hpp viewer-stream.cpp \
+                       session.cpp session.hpp \
+                       stream.cpp stream.hpp \
+                       connection.cpp connection.hpp \
+                       viewer-session.cpp viewer-session.hpp \
+                       tracefile-array.cpp tracefile-array.hpp \
+                       tcp_keep_alive.cpp tcp_keep_alive.hpp \
+                       sessiond-trace-chunks.cpp sessiond-trace-chunks.hpp \
+                       backward-compatibility-group-by.cpp backward-compatibility-group-by.hpp
 
 # link on liblttngctl for check if relayd is already alive.
 lttng_relayd_LDADD = $(URCU_LIBS) \
index f0454a56b70a0c2db24a632323d8df62f462c525..e1d289d98748090e9fada15a72c8536d52b675f6 100644 (file)
@@ -5,17 +5,17 @@
  *
  */
 
-#include "common/time.h"
+#include "common/time.hpp"
 #include <regex.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
 
-#include "backward-compatibility-group-by.h"
+#include "backward-compatibility-group-by.hpp"
 
 #define DATETIME_REGEX \
        ".*-[1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]-[0-2][0-9][0-5][0-9][0-5][0-9]$"
diff --git a/src/bin/lttng-relayd/backward-compatibility-group-by.h b/src/bin/lttng-relayd/backward-compatibility-group-by.h
deleted file mode 100644 (file)
index 4cf7462..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef BACKWARD_COMPATIBILITY_GROUP_BY_H
-#define BACKWARD_COMPATIBILITY_GROUP_BY_H
-
-#include <time.h>
-
-char *backward_compat_group_by_session(const char *path,
-               const char *local_session_name,
-               time_t session_creation_time);
-
-#endif /* BACKWARD_COMPATIBILITY_GROUP_BY_H */
diff --git a/src/bin/lttng-relayd/backward-compatibility-group-by.hpp b/src/bin/lttng-relayd/backward-compatibility-group-by.hpp
new file mode 100644 (file)
index 0000000..4cf7462
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef BACKWARD_COMPATIBILITY_GROUP_BY_H
+#define BACKWARD_COMPATIBILITY_GROUP_BY_H
+
+#include <time.h>
+
+char *backward_compat_group_by_session(const char *path,
+               const char *local_session_name,
+               time_t session_creation_time);
+
+#endif /* BACKWARD_COMPATIBILITY_GROUP_BY_H */
index 1f939dd07428a45fdee4ea610c8cebf45dbd2dd1..9befdd606ac6b8f0db8b7d0a36b2dc9148285f50 100644 (file)
@@ -9,13 +9,13 @@
 
 #define _LGPL_SOURCE
 
-#include <common/common.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/compat/string.h>
+#include <common/common.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/compat/string.hpp>
 #include <lttng/constant.h>
 
-#include "cmd-2-1.h"
-#include "utils.h"
+#include "cmd-2-1.hpp"
+#include "utils.hpp"
 
 /*
  * cmd_recv_stream_2_1 allocates path_name and channel_name.
diff --git a/src/bin/lttng-relayd/cmd-2-1.h b/src/bin/lttng-relayd/cmd-2-1.h
deleted file mode 100644 (file)
index 7040e4f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef RELAYD_CMD_2_1_H
-#define RELAYD_CMD_2_1_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include "lttng-relayd.h"
-#include <common/buffer-view.h>
-
-int cmd_recv_stream_2_1(const struct lttng_buffer_view *payload,
-               char **path_name, char **channel_name);
-
-#endif /* RELAYD_CMD_2_1_H */
diff --git a/src/bin/lttng-relayd/cmd-2-1.hpp b/src/bin/lttng-relayd/cmd-2-1.hpp
new file mode 100644 (file)
index 0000000..147069b
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef RELAYD_CMD_2_1_H
+#define RELAYD_CMD_2_1_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include "lttng-relayd.hpp"
+#include <common/buffer-view.hpp>
+
+int cmd_recv_stream_2_1(const struct lttng_buffer_view *payload,
+               char **path_name, char **channel_name);
+
+#endif /* RELAYD_CMD_2_1_H */
index 572b1836c9a2fd1c44a8887aaead21ca3cb7a179..680cb307b15bfa12999a8b1039bde4fca99f98f4 100644 (file)
@@ -8,15 +8,15 @@
 #define _LGPL_SOURCE
 #include <inttypes.h>
 
-#include <common/common.h>
-#include <common/sessiond-comm/relayd.h>
+#include <common/common.hpp>
+#include <common/sessiond-comm/relayd.hpp>
 
-#include <common/compat/endian.h>
-#include <common/compat/string.h>
+#include <common/compat/endian.hpp>
+#include <common/compat/string.hpp>
 #include <lttng/constant.h>
 
-#include "cmd-2-11.h"
-#include "utils.h"
+#include "cmd-2-11.hpp"
+#include "utils.hpp"
 
 int cmd_create_session_2_11(const struct lttng_buffer_view *payload,
                char *session_name, char *hostname, char *base_path,
diff --git a/src/bin/lttng-relayd/cmd-2-11.h b/src/bin/lttng-relayd/cmd-2-11.h
deleted file mode 100644 (file)
index b3a3a99..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef RELAYD_CMD_2_11_H
-#define RELAYD_CMD_2_11_H
-
-#include "lttng-relayd.h"
-#include <common/buffer-view.h>
-#include <common/uuid.h>
-
-int cmd_create_session_2_11(const struct lttng_buffer_view *payload,
-               char *session_name, char *hostname, char *base_path,
-               uint32_t *live_timer, bool *snapshot,
-               uint64_t *id_sessiond, lttng_uuid sessiond_uuid,
-               bool *has_current_chunk, uint64_t *current_chunk_id,
-               time_t *creation_time,
-               bool *session_name_contains_creation_time);
-
-int cmd_recv_stream_2_11(const struct lttng_buffer_view *payload,
-               char **ret_path_name, char **ret_channel_name,
-               uint64_t *tracefile_size, uint64_t *tracefile_count,
-               uint64_t *trace_archive_id);
-
-#endif /* RELAYD_CMD_2_11_H */
diff --git a/src/bin/lttng-relayd/cmd-2-11.hpp b/src/bin/lttng-relayd/cmd-2-11.hpp
new file mode 100644 (file)
index 0000000..4b004f0
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2018 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef RELAYD_CMD_2_11_H
+#define RELAYD_CMD_2_11_H
+
+#include "lttng-relayd.hpp"
+#include <common/buffer-view.hpp>
+#include <common/uuid.hpp>
+
+int cmd_create_session_2_11(const struct lttng_buffer_view *payload,
+               char *session_name, char *hostname, char *base_path,
+               uint32_t *live_timer, bool *snapshot,
+               uint64_t *id_sessiond, lttng_uuid sessiond_uuid,
+               bool *has_current_chunk, uint64_t *current_chunk_id,
+               time_t *creation_time,
+               bool *session_name_contains_creation_time);
+
+int cmd_recv_stream_2_11(const struct lttng_buffer_view *payload,
+               char **ret_path_name, char **ret_channel_name,
+               uint64_t *tracefile_size, uint64_t *tracefile_count,
+               uint64_t *trace_archive_id);
+
+#endif /* RELAYD_CMD_2_11_H */
index bd18714af840626d0291382205a33bd6a4054563..3d9af63a313f5f2a9ff6bf9a6f451d62dcf25578 100644 (file)
@@ -9,16 +9,16 @@
 
 #define _LGPL_SOURCE
 
-#include <common/common.h>
-#include <common/sessiond-comm/relayd.h>
+#include <common/common.hpp>
+#include <common/sessiond-comm/relayd.hpp>
 
-#include <common/compat/endian.h>
-#include <common/compat/string.h>
+#include <common/compat/endian.hpp>
+#include <common/compat/string.hpp>
 #include <lttng/constant.h>
 
-#include "cmd-2-2.h"
-#include "cmd-2-1.h"
-#include "utils.h"
+#include "cmd-2-2.hpp"
+#include "cmd-2-1.hpp"
+#include "utils.hpp"
 
 /*
  * cmd_recv_stream_2_2 allocates path_name and channel_name.
diff --git a/src/bin/lttng-relayd/cmd-2-2.h b/src/bin/lttng-relayd/cmd-2-2.h
deleted file mode 100644 (file)
index e754ace..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef RELAYD_CMD_2_2_H
-#define RELAYD_CMD_2_2_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include "lttng-relayd.h"
-#include <common/buffer-view.h>
-
-int cmd_recv_stream_2_2(const struct lttng_buffer_view *payload,
-               char **path_name, char **channel_name,
-               uint64_t *tracefile_size, uint64_t *tracefile_count);
-
-#endif /* RELAYD_CMD_2_2_H */
diff --git a/src/bin/lttng-relayd/cmd-2-2.hpp b/src/bin/lttng-relayd/cmd-2-2.hpp
new file mode 100644 (file)
index 0000000..010bbb1
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef RELAYD_CMD_2_2_H
+#define RELAYD_CMD_2_2_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include "lttng-relayd.hpp"
+#include <common/buffer-view.hpp>
+
+int cmd_recv_stream_2_2(const struct lttng_buffer_view *payload,
+               char **path_name, char **channel_name,
+               uint64_t *tracefile_size, uint64_t *tracefile_count);
+
+#endif /* RELAYD_CMD_2_2_H */
index 7abc371f06732056bf61435d8bf71750cdb3a774..7b546c7f661d5babd2161c0e51abb98d0f250036 100644 (file)
@@ -9,15 +9,15 @@
 
 #define _LGPL_SOURCE
 
-#include <common/common.h>
-#include <common/sessiond-comm/relayd.h>
+#include <common/common.hpp>
+#include <common/sessiond-comm/relayd.hpp>
 
-#include <common/compat/endian.h>
-#include <common/compat/string.h>
+#include <common/compat/endian.hpp>
+#include <common/compat/string.hpp>
 #include <lttng/constant.h>
 
-#include "cmd-2-4.h"
-#include "lttng-relayd.h"
+#include "cmd-2-4.hpp"
+#include "lttng-relayd.hpp"
 
 int cmd_create_session_2_4(const struct lttng_buffer_view *payload,
                char *session_name, char *hostname,
diff --git a/src/bin/lttng-relayd/cmd-2-4.h b/src/bin/lttng-relayd/cmd-2-4.h
deleted file mode 100644 (file)
index 0949287..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef RELAYD_CMD_2_4_H
-#define RELAYD_CMD_2_4_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include "lttng-relayd.h"
-#include <common/buffer-view.h>
-
-int cmd_create_session_2_4(const struct lttng_buffer_view *payload,
-               char *session_name, char *hostname,
-               uint32_t *live_timer, bool *snapshot);
-
-#endif /* RELAYD_CMD_2_4_H */
diff --git a/src/bin/lttng-relayd/cmd-2-4.hpp b/src/bin/lttng-relayd/cmd-2-4.hpp
new file mode 100644 (file)
index 0000000..b3d105c
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef RELAYD_CMD_2_4_H
+#define RELAYD_CMD_2_4_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include "lttng-relayd.hpp"
+#include <common/buffer-view.hpp>
+
+int cmd_create_session_2_4(const struct lttng_buffer_view *payload,
+               char *session_name, char *hostname,
+               uint32_t *live_timer, bool *snapshot);
+
+#endif /* RELAYD_CMD_2_4_H */
diff --git a/src/bin/lttng-relayd/cmd.h b/src/bin/lttng-relayd/cmd.h
deleted file mode 100644 (file)
index 86668b4..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef RELAYD_CMD_H
-#define RELAYD_CMD_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include "cmd-2-1.h"
-#include "cmd-2-2.h"
-#include "cmd-2-4.h"
-#include "cmd-2-11.h"
-
-#endif /* RELAYD_CMD_H */
diff --git a/src/bin/lttng-relayd/cmd.hpp b/src/bin/lttng-relayd/cmd.hpp
new file mode 100644 (file)
index 0000000..24e361a
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef RELAYD_CMD_H
+#define RELAYD_CMD_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include "cmd-2-1.hpp"
+#include "cmd-2-2.hpp"
+#include "cmd-2-4.hpp"
+#include "cmd-2-11.hpp"
+
+#endif /* RELAYD_CMD_H */
index 98ffad29f986de121db5b607c9a9cfd7b0918abb..c1e58aba3430f0fbbbedb89cb42261731cc94b3d 100644 (file)
@@ -8,12 +8,12 @@
  */
 
 #define _LGPL_SOURCE
-#include <common/common.h>
+#include <common/common.hpp>
 #include <urcu/rculist.h>
 
-#include "connection.h"
-#include "stream.h"
-#include "viewer-session.h"
+#include "connection.hpp"
+#include "stream.hpp"
+#include "viewer-session.hpp"
 
 bool connection_get(struct relay_connection *conn)
 {
diff --git a/src/bin/lttng-relayd/connection.h b/src/bin/lttng-relayd/connection.h
deleted file mode 100644 (file)
index 98ca915..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-#ifndef _CONNECTION_H
-#define _CONNECTION_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <urcu.h>
-#include <urcu/wfcqueue.h>
-#include <urcu/list.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/dynamic-buffer.h>
-
-#include "session.h"
-
-enum connection_type {
-       RELAY_CONNECTION_UNKNOWN    = 0,
-       RELAY_DATA                  = 1,
-       RELAY_CONTROL               = 2,
-       RELAY_VIEWER_COMMAND        = 3,
-       RELAY_VIEWER_NOTIFICATION   = 4,
-};
-
-enum data_connection_state {
-       DATA_CONNECTION_STATE_RECEIVE_HEADER = 0,
-       DATA_CONNECTION_STATE_RECEIVE_PAYLOAD = 1,
-};
-
-enum ctrl_connection_state {
-       CTRL_CONNECTION_STATE_RECEIVE_HEADER = 0,
-       CTRL_CONNECTION_STATE_RECEIVE_PAYLOAD = 1,
-};
-
-struct data_connection_state_receive_header {
-       uint64_t received, left_to_receive;
-       char header_reception_buffer[sizeof(struct lttcomm_relayd_data_hdr)];
-};
-
-struct data_connection_state_receive_payload {
-       uint64_t received, left_to_receive;
-       struct lttcomm_relayd_data_hdr header;
-       bool rotate_index;
-};
-
-struct ctrl_connection_state_receive_header {
-       uint64_t received, left_to_receive;
-};
-
-struct ctrl_connection_state_receive_payload {
-       uint64_t received, left_to_receive;
-       struct lttcomm_relayd_hdr header;
-};
-
-/*
- * Internal structure to map a socket with the corresponding session.
- * A hashtable indexed on the socket FD is used for the lookups.
- *
- * Connections are assumed to be accessed from a single thread. Live
- * connections between the relay and a live client are only accessed
- * from the live worker thread.
- *
- * The connections between the consumerd/sessiond and the relayd are only
- * handled by the "main" worker thread (as in, the worker thread in main.c).
- *
- * This is why there are no back references to connections from the
- * sessions and session list.
- */
-struct relay_connection {
-       struct lttcomm_sock *sock;
-       struct cds_wfcq_node qnode;
-
-       enum connection_type type;
-       /*
-        * session is only ever set for RELAY_CONTROL connection type.
-        */
-       struct relay_session *session;
-       /*
-        * viewer_session is only ever set for RELAY_VIEWER_COMMAND
-        * connection type.
-        */
-       struct relay_viewer_session *viewer_session;
-
-       /*
-        * Protocol version to use for this connection. Only valid for
-        * RELAY_CONTROL connection type.
-        */
-       uint32_t major;
-       uint32_t minor;
-
-       struct urcu_ref ref;
-
-       bool version_check_done;
-
-       /*
-        * Node member of connection within global socket hash table.
-        */
-       struct lttng_ht_node_ulong sock_n;
-       bool in_socket_ht;
-       struct lttng_ht *socket_ht;     /* HACK: Contained within this hash table. */
-       struct rcu_head rcu_node;       /* For call_rcu teardown. */
-
-       union {
-               struct {
-                       enum data_connection_state state_id;
-                       union {
-                               struct data_connection_state_receive_header receive_header;
-                               struct data_connection_state_receive_payload receive_payload;
-                       } state;
-               } data;
-               struct {
-                       enum ctrl_connection_state state_id;
-                       union {
-                               struct ctrl_connection_state_receive_header receive_header;
-                               struct ctrl_connection_state_receive_payload receive_payload;
-                       } state;
-                       struct lttng_dynamic_buffer reception_buffer;
-               } ctrl;
-       } protocol;
-};
-
-struct relay_connection *connection_create(struct lttcomm_sock *sock,
-               enum connection_type type);
-struct relay_connection *connection_get_by_sock(struct lttng_ht *relay_connections_ht,
-               int sock);
-int connection_reset_protocol_state(struct relay_connection *connection);
-bool connection_get(struct relay_connection *connection);
-void connection_put(struct relay_connection *connection);
-void connection_ht_add(struct lttng_ht *relay_connections_ht,
-               struct relay_connection *conn);
-int connection_set_session(struct relay_connection *conn,
-               struct relay_session *session);
-
-#endif /* _CONNECTION_H */
diff --git a/src/bin/lttng-relayd/connection.hpp b/src/bin/lttng-relayd/connection.hpp
new file mode 100644 (file)
index 0000000..de25255
--- /dev/null
@@ -0,0 +1,144 @@
+#ifndef _CONNECTION_H
+#define _CONNECTION_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <urcu.h>
+#include <urcu/wfcqueue.h>
+#include <urcu/list.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/dynamic-buffer.hpp>
+
+#include "session.hpp"
+
+enum connection_type {
+       RELAY_CONNECTION_UNKNOWN    = 0,
+       RELAY_DATA                  = 1,
+       RELAY_CONTROL               = 2,
+       RELAY_VIEWER_COMMAND        = 3,
+       RELAY_VIEWER_NOTIFICATION   = 4,
+};
+
+enum data_connection_state {
+       DATA_CONNECTION_STATE_RECEIVE_HEADER = 0,
+       DATA_CONNECTION_STATE_RECEIVE_PAYLOAD = 1,
+};
+
+enum ctrl_connection_state {
+       CTRL_CONNECTION_STATE_RECEIVE_HEADER = 0,
+       CTRL_CONNECTION_STATE_RECEIVE_PAYLOAD = 1,
+};
+
+struct data_connection_state_receive_header {
+       uint64_t received, left_to_receive;
+       char header_reception_buffer[sizeof(struct lttcomm_relayd_data_hdr)];
+};
+
+struct data_connection_state_receive_payload {
+       uint64_t received, left_to_receive;
+       struct lttcomm_relayd_data_hdr header;
+       bool rotate_index;
+};
+
+struct ctrl_connection_state_receive_header {
+       uint64_t received, left_to_receive;
+};
+
+struct ctrl_connection_state_receive_payload {
+       uint64_t received, left_to_receive;
+       struct lttcomm_relayd_hdr header;
+};
+
+/*
+ * Internal structure to map a socket with the corresponding session.
+ * A hashtable indexed on the socket FD is used for the lookups.
+ *
+ * Connections are assumed to be accessed from a single thread. Live
+ * connections between the relay and a live client are only accessed
+ * from the live worker thread.
+ *
+ * The connections between the consumerd/sessiond and the relayd are only
+ * handled by the "main" worker thread (as in, the worker thread in main.c).
+ *
+ * This is why there are no back references to connections from the
+ * sessions and session list.
+ */
+struct relay_connection {
+       struct lttcomm_sock *sock;
+       struct cds_wfcq_node qnode;
+
+       enum connection_type type;
+       /*
+        * session is only ever set for RELAY_CONTROL connection type.
+        */
+       struct relay_session *session;
+       /*
+        * viewer_session is only ever set for RELAY_VIEWER_COMMAND
+        * connection type.
+        */
+       struct relay_viewer_session *viewer_session;
+
+       /*
+        * Protocol version to use for this connection. Only valid for
+        * RELAY_CONTROL connection type.
+        */
+       uint32_t major;
+       uint32_t minor;
+
+       struct urcu_ref ref;
+
+       bool version_check_done;
+
+       /*
+        * Node member of connection within global socket hash table.
+        */
+       struct lttng_ht_node_ulong sock_n;
+       bool in_socket_ht;
+       struct lttng_ht *socket_ht;     /* HACK: Contained within this hash table. */
+       struct rcu_head rcu_node;       /* For call_rcu teardown. */
+
+       union {
+               struct {
+                       enum data_connection_state state_id;
+                       union {
+                               struct data_connection_state_receive_header receive_header;
+                               struct data_connection_state_receive_payload receive_payload;
+                       } state;
+               } data;
+               struct {
+                       enum ctrl_connection_state state_id;
+                       union {
+                               struct ctrl_connection_state_receive_header receive_header;
+                               struct ctrl_connection_state_receive_payload receive_payload;
+                       } state;
+                       struct lttng_dynamic_buffer reception_buffer;
+               } ctrl;
+       } protocol;
+};
+
+struct relay_connection *connection_create(struct lttcomm_sock *sock,
+               enum connection_type type);
+struct relay_connection *connection_get_by_sock(struct lttng_ht *relay_connections_ht,
+               int sock);
+int connection_reset_protocol_state(struct relay_connection *connection);
+bool connection_get(struct relay_connection *connection);
+void connection_put(struct relay_connection *connection);
+void connection_ht_add(struct lttng_ht *relay_connections_ht,
+               struct relay_connection *conn);
+int connection_set_session(struct relay_connection *conn,
+               struct relay_session *session);
+
+#endif /* _CONNECTION_H */
index 861bcfbb3f7a44c6d055babdc544abc584835dfc..4ee745a10c9102b42e01f32a6e16ffbf699a12cd 100644 (file)
@@ -9,13 +9,13 @@
 
 #define _LGPL_SOURCE
 
-#include <common/common.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/utils.hpp>
 #include <urcu/rculist.h>
 
-#include "ctf-trace.h"
-#include "lttng-relayd.h"
-#include "stream.h"
+#include "ctf-trace.hpp"
+#include "lttng-relayd.hpp"
+#include "stream.hpp"
 
 static uint64_t last_relay_ctf_trace_id;
 static pthread_mutex_t last_relay_ctf_trace_id_lock = PTHREAD_MUTEX_INITIALIZER;
diff --git a/src/bin/lttng-relayd/ctf-trace.h b/src/bin/lttng-relayd/ctf-trace.h
deleted file mode 100644 (file)
index 3afc00f..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef _CTF_TRACE_H
-#define _CTF_TRACE_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <inttypes.h>
-#include <urcu/ref.h>
-
-#include <common/hashtable/hashtable.h>
-
-#include "session.h"
-#include "stream.h"
-#include "viewer-stream.h"
-
-struct ctf_trace {
-       struct urcu_ref ref;            /* Every stream has a ref on the trace. */
-       struct relay_session *session;  /* Back ref to trace session */
-
-       /* Trace sub-folder relative to the session output path. */
-       char *path;
-
-       /*
-        * The ctf_trace lock nests inside the session lock.
-        */
-       pthread_mutex_t lock;
-       uint64_t id;
-       struct relay_viewer_stream *viewer_metadata_stream;     /* RCU protected */
-
-       /*
-        * Relay streams associated with this ctf trace.
-        * Updates are protected by the stream_list lock.
-        * Traversals are protected by RCU.
-        */
-       struct cds_list_head stream_list;
-       pthread_mutex_t stream_list_lock;
-
-       /*
-        * Node within session trace hash table. Node is indexed by
-        * stream path name.
-        */
-       struct lttng_ht_node_str node;
-       struct rcu_head rcu_node;       /* For call_rcu teardown. */
-
-       /*
-        * True if the metadata stream of this trace was sent the viewer in the
-        * past.
-        */
-       bool metadata_stream_sent_to_viewer;
-};
-
-struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session,
-               const char *subpath);
-bool ctf_trace_get(struct ctf_trace *trace);
-void ctf_trace_put(struct ctf_trace *trace);
-
-int ctf_trace_close(struct ctf_trace *trace);
-
-struct relay_viewer_stream *ctf_trace_get_viewer_metadata_stream(struct ctf_trace *trace);
-
-#endif /* _CTF_TRACE_H */
diff --git a/src/bin/lttng-relayd/ctf-trace.hpp b/src/bin/lttng-relayd/ctf-trace.hpp
new file mode 100644 (file)
index 0000000..dbf7d3f
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef _CTF_TRACE_H
+#define _CTF_TRACE_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <inttypes.h>
+#include <urcu/ref.h>
+
+#include <common/hashtable/hashtable.hpp>
+
+#include "session.hpp"
+#include "stream.hpp"
+#include "viewer-stream.hpp"
+
+struct ctf_trace {
+       struct urcu_ref ref;            /* Every stream has a ref on the trace. */
+       struct relay_session *session;  /* Back ref to trace session */
+
+       /* Trace sub-folder relative to the session output path. */
+       char *path;
+
+       /*
+        * The ctf_trace lock nests inside the session lock.
+        */
+       pthread_mutex_t lock;
+       uint64_t id;
+       struct relay_viewer_stream *viewer_metadata_stream;     /* RCU protected */
+
+       /*
+        * Relay streams associated with this ctf trace.
+        * Updates are protected by the stream_list lock.
+        * Traversals are protected by RCU.
+        */
+       struct cds_list_head stream_list;
+       pthread_mutex_t stream_list_lock;
+
+       /*
+        * Node within session trace hash table. Node is indexed by
+        * stream path name.
+        */
+       struct lttng_ht_node_str node;
+       struct rcu_head rcu_node;       /* For call_rcu teardown. */
+
+       /*
+        * True if the metadata stream of this trace was sent the viewer in the
+        * past.
+        */
+       bool metadata_stream_sent_to_viewer;
+};
+
+struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session,
+               const char *subpath);
+bool ctf_trace_get(struct ctf_trace *trace);
+void ctf_trace_put(struct ctf_trace *trace);
+
+int ctf_trace_close(struct ctf_trace *trace);
+
+struct relay_viewer_stream *ctf_trace_get_viewer_metadata_stream(struct ctf_trace *trace);
+
+#endif /* _CTF_TRACE_H */
index d43c371856b9fdc45e3dd9ccb9287eef4b614f57..8e22dfe66335f1332ff8740e6e64ee0869480411 100644 (file)
 #include <urcu/compiler.h>
 #include <inttypes.h>
 
-#include <common/defaults.h>
-#include <common/common.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/compat/poll.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
-#include <common/compat/getenv.h>
-#include <common/fd-tracker/utils.h>
-
-#include "lttng-relayd.h"
-#include "health-relayd.h"
+#include <common/defaults.hpp>
+#include <common/common.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/compat/poll.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/fd-tracker/utils.hpp>
+
+#include "lttng-relayd.hpp"
+#include "health-relayd.hpp"
 
 /* Global health check unix path */
 static
diff --git a/src/bin/lttng-relayd/health-relayd.h b/src/bin/lttng-relayd/health-relayd.h
deleted file mode 100644 (file)
index 4cd3ec1..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef HEALTH_RELAYD_H
-#define HEALTH_RELAYD_H
-
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <lttng/health-internal.h>
-
-#define LTTNG_RELAYD_HEALTH_ENV                "LTTNG_RELAYD_HEALTH"
-
-enum health_type_relayd {
-       HEALTH_RELAYD_TYPE_DISPATCHER           = 0,
-       HEALTH_RELAYD_TYPE_WORKER               = 1,
-       HEALTH_RELAYD_TYPE_LISTENER             = 2,
-       HEALTH_RELAYD_TYPE_LIVE_DISPATCHER      = 3,
-       HEALTH_RELAYD_TYPE_LIVE_WORKER          = 4,
-       HEALTH_RELAYD_TYPE_LIVE_LISTENER        = 5,
-
-       NR_HEALTH_RELAYD_TYPES,
-};
-
-extern struct health_app *health_relayd;
-
-extern int health_quit_pipe[2];
-
-void *thread_manage_health_relayd(void *data);
-
-#endif /* HEALTH_RELAYD_H */
diff --git a/src/bin/lttng-relayd/health-relayd.hpp b/src/bin/lttng-relayd/health-relayd.hpp
new file mode 100644 (file)
index 0000000..7d885c6
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef HEALTH_RELAYD_H
+#define HEALTH_RELAYD_H
+
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <lttng/health-internal.hpp>
+
+#define LTTNG_RELAYD_HEALTH_ENV                "LTTNG_RELAYD_HEALTH"
+
+enum health_type_relayd {
+       HEALTH_RELAYD_TYPE_DISPATCHER           = 0,
+       HEALTH_RELAYD_TYPE_WORKER               = 1,
+       HEALTH_RELAYD_TYPE_LISTENER             = 2,
+       HEALTH_RELAYD_TYPE_LIVE_DISPATCHER      = 3,
+       HEALTH_RELAYD_TYPE_LIVE_WORKER          = 4,
+       HEALTH_RELAYD_TYPE_LIVE_LISTENER        = 5,
+
+       NR_HEALTH_RELAYD_TYPES,
+};
+
+extern struct health_app *health_relayd;
+
+extern int health_quit_pipe[2];
+
+void *thread_manage_health_relayd(void *data);
+
+#endif /* HEALTH_RELAYD_H */
index 6cf131b256757cba64ab7796ea50a19cd0c20a8a..651b36715c106a9f0a2794ad1572b48a9ba0ffff 100644 (file)
@@ -9,14 +9,14 @@
 
 #define _LGPL_SOURCE
 
-#include <common/common.h>
-#include <common/utils.h>
-#include <common/compat/endian.h>
-
-#include "lttng-relayd.h"
-#include "stream.h"
-#include "index.h"
-#include "connection.h"
+#include <common/common.hpp>
+#include <common/utils.hpp>
+#include <common/compat/endian.hpp>
+
+#include "lttng-relayd.hpp"
+#include "stream.hpp"
+#include "index.hpp"
+#include "connection.hpp"
 
 /*
  * Allocate a new relay index object. Pass the stream in which it is
diff --git a/src/bin/lttng-relayd/index.h b/src/bin/lttng-relayd/index.h
deleted file mode 100644 (file)
index 4364f12..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef _RELAY_INDEX_H
-#define _RELAY_INDEX_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <inttypes.h>
-#include <pthread.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/index/index.h>
-
-struct relay_stream;
-struct relay_connection;
-struct lttcomm_relayd_index;
-
-struct relay_index {
-       /*
-        * index lock nests inside stream lock.
-        */
-       struct urcu_ref ref;            /* Reference from getters. */
-       struct relay_stream *stream;    /* Back ref to stream */
-
-       pthread_mutex_t lock;
-       /*
-        * index file on which to write the index data. May differ from
-        * stream->index_file due to tracefile rotation.
-        */
-       struct lttng_index_file *index_file;
-
-       /* Index packet data. This is the data that is written on disk. */
-       struct ctf_packet_index index_data;
-       /* Data + padding size of this packet, filled by the data thread. */
-       uint64_t total_size;
-
-       bool has_index_data;
-       bool flushed;
-       bool in_hash_table;
-
-       /*
-        * Node within indexes_ht that corresponds to this struct
-        * relay_index. Indexed by net_seq_num, which is unique for this
-        * index across the stream.
-        */
-       struct lttng_ht_node_u64 index_n;
-       struct rcu_head rcu_node;       /* For call_rcu teardown. */
-};
-
-struct relay_index *relay_index_get_by_id_or_create(struct relay_stream *stream,
-               uint64_t net_seq_num);
-void relay_index_put(struct relay_index *index);
-int relay_index_set_file(struct relay_index *index,
-               struct lttng_index_file *index_file,
-               uint64_t data_offset);
-int relay_index_set_data(struct relay_index *index,
-               const struct ctf_packet_index *data);
-int relay_index_try_flush(struct relay_index *index);
-
-void relay_index_close_all(struct relay_stream *stream);
-void relay_index_close_partial_fd(struct relay_stream *stream);
-uint64_t relay_index_find_last(struct relay_stream *stream);
-int relay_index_switch_all_files(struct relay_stream *stream);
-int relay_index_set_control_data(struct relay_index *index,
-               const struct lttcomm_relayd_index *data,
-               unsigned int minor_version);
-
-#endif /* _RELAY_INDEX_H */
diff --git a/src/bin/lttng-relayd/index.hpp b/src/bin/lttng-relayd/index.hpp
new file mode 100644 (file)
index 0000000..cb29485
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef _RELAY_INDEX_H
+#define _RELAY_INDEX_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <inttypes.h>
+#include <pthread.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/index/index.hpp>
+
+struct relay_stream;
+struct relay_connection;
+struct lttcomm_relayd_index;
+
+struct relay_index {
+       /*
+        * index lock nests inside stream lock.
+        */
+       struct urcu_ref ref;            /* Reference from getters. */
+       struct relay_stream *stream;    /* Back ref to stream */
+
+       pthread_mutex_t lock;
+       /*
+        * index file on which to write the index data. May differ from
+        * stream->index_file due to tracefile rotation.
+        */
+       struct lttng_index_file *index_file;
+
+       /* Index packet data. This is the data that is written on disk. */
+       struct ctf_packet_index index_data;
+       /* Data + padding size of this packet, filled by the data thread. */
+       uint64_t total_size;
+
+       bool has_index_data;
+       bool flushed;
+       bool in_hash_table;
+
+       /*
+        * Node within indexes_ht that corresponds to this struct
+        * relay_index. Indexed by net_seq_num, which is unique for this
+        * index across the stream.
+        */
+       struct lttng_ht_node_u64 index_n;
+       struct rcu_head rcu_node;       /* For call_rcu teardown. */
+};
+
+struct relay_index *relay_index_get_by_id_or_create(struct relay_stream *stream,
+               uint64_t net_seq_num);
+void relay_index_put(struct relay_index *index);
+int relay_index_set_file(struct relay_index *index,
+               struct lttng_index_file *index_file,
+               uint64_t data_offset);
+int relay_index_set_data(struct relay_index *index,
+               const struct ctf_packet_index *data);
+int relay_index_try_flush(struct relay_index *index);
+
+void relay_index_close_all(struct relay_stream *stream);
+void relay_index_close_partial_fd(struct relay_stream *stream);
+uint64_t relay_index_find_last(struct relay_stream *stream);
+int relay_index_switch_all_files(struct relay_stream *stream);
+int relay_index_set_control_data(struct relay_index *index,
+               const struct lttcomm_relayd_index *data,
+               unsigned int minor_version);
+
+#endif /* _RELAY_INDEX_H */
index 5aa899b282605a0c058f7f497f9b500ad7e0226b..64c194fdc9bcfd61ac02471406641de66f45d165 100644 (file)
 #include <urcu/uatomic.h>
 #include <string>
 
-#include <common/common.h>
-#include <common/compat/endian.h>
-#include <common/compat/poll.h>
-#include <common/compat/socket.h>
-#include <common/defaults.h>
-#include <common/fd-tracker/utils.h>
-#include <common/fs-handle.h>
-#include <common/futex.h>
-#include <common/index/index.h>
-#include <common/sessiond-comm/inet.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/poll.hpp>
+#include <common/compat/socket.hpp>
+#include <common/defaults.hpp>
+#include <common/fd-tracker/utils.hpp>
+#include <common/fs-handle.hpp>
+#include <common/futex.hpp>
+#include <common/index/index.hpp>
+#include <common/sessiond-comm/inet.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
 #include <lttng/lttng.h>
 
-#include "cmd.h"
-#include "connection.h"
-#include "ctf-trace.h"
-#include "health-relayd.h"
-#include "live.h"
-#include "lttng-relayd.h"
-#include "session.h"
-#include "stream.h"
-#include "testpoint.h"
-#include "utils.h"
-#include "viewer-session.h"
-#include "viewer-stream.h"
+#include "cmd.hpp"
+#include "connection.hpp"
+#include "ctf-trace.hpp"
+#include "health-relayd.hpp"
+#include "live.hpp"
+#include "lttng-relayd.hpp"
+#include "session.hpp"
+#include "stream.hpp"
+#include "testpoint.hpp"
+#include "utils.hpp"
+#include "viewer-session.hpp"
+#include "viewer-stream.hpp"
 
 #define SESSION_BUF_DEFAULT_COUNT      16
 
diff --git a/src/bin/lttng-relayd/live.h b/src/bin/lttng-relayd/live.h
deleted file mode 100644 (file)
index d6ec89e..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef LTTNG_RELAYD_LIVE_H
-#define LTTNG_RELAYD_LIVE_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <common/uri.h>
-
-#include "lttng-relayd.h"
-
-int relayd_live_create(struct lttng_uri *live_uri);
-int relayd_live_stop(void);
-int relayd_live_join(void);
-
-#endif /* LTTNG_RELAYD_LIVE_H */
diff --git a/src/bin/lttng-relayd/live.hpp b/src/bin/lttng-relayd/live.hpp
new file mode 100644 (file)
index 0000000..d1866d3
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef LTTNG_RELAYD_LIVE_H
+#define LTTNG_RELAYD_LIVE_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <common/uri.hpp>
+
+#include "lttng-relayd.hpp"
+
+int relayd_live_create(struct lttng_uri *live_uri);
+int relayd_live_stop(void);
+int relayd_live_join(void);
+
+#endif /* LTTNG_RELAYD_LIVE_H */
diff --git a/src/bin/lttng-relayd/lttng-relayd.h b/src/bin/lttng-relayd/lttng-relayd.h
deleted file mode 100644 (file)
index e64bb37..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef LTTNG_RELAYD_H
-#define LTTNG_RELAYD_H
-
-/*
- * Copyright (C) 2012 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <urcu.h>
-#include <urcu/wfcqueue.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/fd-tracker/fd-tracker.h>
-
-struct sessiond_trace_chunk_registry;
-
-/*
- * Queue used to enqueue relay requests
- */
-struct relay_conn_queue {
-       struct cds_wfcq_head head;
-       struct cds_wfcq_tail tail;
-       int32_t futex;
-};
-
-enum relay_group_output_by {
-       RELAYD_GROUP_OUTPUT_BY_UNKNOWN,
-       RELAYD_GROUP_OUTPUT_BY_HOST,
-       RELAYD_GROUP_OUTPUT_BY_SESSION,
-};
-
-/*
- * Contains stream indexed by ID. This is important since many commands lookup
- * streams only by ID thus also keeping them in this hash table makes the
- * search O(1).
- */
-extern struct lttng_ht *sessions_ht;
-extern struct lttng_ht *relay_streams_ht;
-extern struct lttng_ht *viewer_streams_ht;
-extern struct sessiond_trace_chunk_registry *sessiond_trace_chunk_registry;
-
-extern char *opt_output_path;
-extern const char *tracing_group_name;
-extern const char * const config_section_name;
-extern enum relay_group_output_by opt_group_output_by;
-
-extern int thread_quit_pipe[2];
-
-extern struct fd_tracker *the_fd_tracker;
-
-void lttng_relay_notify_ready(void);
-int lttng_relay_stop_threads(void);
-
-#endif /* LTTNG_RELAYD_H */
diff --git a/src/bin/lttng-relayd/lttng-relayd.hpp b/src/bin/lttng-relayd/lttng-relayd.hpp
new file mode 100644 (file)
index 0000000..a92ace7
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef LTTNG_RELAYD_H
+#define LTTNG_RELAYD_H
+
+/*
+ * Copyright (C) 2012 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <urcu.h>
+#include <urcu/wfcqueue.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
+
+struct sessiond_trace_chunk_registry;
+
+/*
+ * Queue used to enqueue relay requests
+ */
+struct relay_conn_queue {
+       struct cds_wfcq_head head;
+       struct cds_wfcq_tail tail;
+       int32_t futex;
+};
+
+enum relay_group_output_by {
+       RELAYD_GROUP_OUTPUT_BY_UNKNOWN,
+       RELAYD_GROUP_OUTPUT_BY_HOST,
+       RELAYD_GROUP_OUTPUT_BY_SESSION,
+};
+
+/*
+ * Contains stream indexed by ID. This is important since many commands lookup
+ * streams only by ID thus also keeping them in this hash table makes the
+ * search O(1).
+ */
+extern struct lttng_ht *sessions_ht;
+extern struct lttng_ht *relay_streams_ht;
+extern struct lttng_ht *viewer_streams_ht;
+extern struct sessiond_trace_chunk_registry *sessiond_trace_chunk_registry;
+
+extern char *opt_output_path;
+extern const char *tracing_group_name;
+extern const char * const config_section_name;
+extern enum relay_group_output_by opt_group_output_by;
+
+extern int thread_quit_pipe[2];
+
+extern struct fd_tracker *the_fd_tracker;
+
+void lttng_relay_notify_ready(void);
+int lttng_relay_stop_threads(void);
+
+#endif /* LTTNG_RELAYD_H */
diff --git a/src/bin/lttng-relayd/lttng-viewer-abi.h b/src/bin/lttng-relayd/lttng-viewer-abi.h
deleted file mode 100644 (file)
index f5f61b4..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-#ifndef LTTNG_VIEWER_ABI_H
-#define LTTNG_VIEWER_ABI_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#include <limits.h>
-#include <common/macros.h>
-
-#define LTTNG_VIEWER_PATH_MAX          4096
-#define LTTNG_VIEWER_NAME_MAX          255
-#define LTTNG_VIEWER_HOST_NAME_MAX     64
-
-/* Flags in reply to get_next_index and get_packet. */
-enum {
-       /* New metadata is required to read this packet. */
-       LTTNG_VIEWER_FLAG_NEW_METADATA  = (1 << 0),
-       /* New stream got added to the trace. */
-       LTTNG_VIEWER_FLAG_NEW_STREAM    = (1 << 1),
-};
-
-enum lttng_viewer_command {
-       LTTNG_VIEWER_CONNECT            = 1,
-       LTTNG_VIEWER_LIST_SESSIONS      = 2,
-       LTTNG_VIEWER_ATTACH_SESSION     = 3,
-       LTTNG_VIEWER_GET_NEXT_INDEX     = 4,
-       LTTNG_VIEWER_GET_PACKET         = 5,
-       LTTNG_VIEWER_GET_METADATA       = 6,
-       LTTNG_VIEWER_GET_NEW_STREAMS    = 7,
-       LTTNG_VIEWER_CREATE_SESSION     = 8,
-       LTTNG_VIEWER_DETACH_SESSION     = 9,
-};
-
-enum lttng_viewer_attach_return_code {
-       LTTNG_VIEWER_ATTACH_OK          = 1, /* The attach command succeeded. */
-       LTTNG_VIEWER_ATTACH_ALREADY     = 2, /* A viewer is already attached. */
-       LTTNG_VIEWER_ATTACH_UNK         = 3, /* The session ID is unknown. */
-       LTTNG_VIEWER_ATTACH_NOT_LIVE    = 4, /* The session is not live. */
-       LTTNG_VIEWER_ATTACH_SEEK_ERR    = 5, /* Seek error. */
-       LTTNG_VIEWER_ATTACH_NO_SESSION  = 6, /* No viewer session created. */
-};
-
-enum lttng_viewer_next_index_return_code {
-       LTTNG_VIEWER_INDEX_OK           = 1, /* Index is available. */
-       LTTNG_VIEWER_INDEX_RETRY        = 2, /* Index not yet available. */
-       LTTNG_VIEWER_INDEX_HUP          = 3, /* Index closed (trace destroyed). */
-       LTTNG_VIEWER_INDEX_ERR          = 4, /* Unknow error. */
-       LTTNG_VIEWER_INDEX_INACTIVE     = 5, /* Inactive stream beacon. */
-       LTTNG_VIEWER_INDEX_EOF          = 6, /* End of index file. */
-};
-
-enum lttng_viewer_get_packet_return_code {
-       LTTNG_VIEWER_GET_PACKET_OK      = 1,
-       LTTNG_VIEWER_GET_PACKET_RETRY   = 2,
-       LTTNG_VIEWER_GET_PACKET_ERR     = 3,
-       LTTNG_VIEWER_GET_PACKET_EOF     = 4,
-};
-
-enum lttng_viewer_get_metadata_return_code {
-       LTTNG_VIEWER_METADATA_OK        = 1,
-       LTTNG_VIEWER_NO_NEW_METADATA    = 2,
-       LTTNG_VIEWER_METADATA_ERR       = 3,
-};
-
-enum lttng_viewer_connection_type {
-       LTTNG_VIEWER_CLIENT_COMMAND             = 1,
-       LTTNG_VIEWER_CLIENT_NOTIFICATION        = 2,
-};
-
-enum lttng_viewer_seek {
-       /* Receive the trace packets from the beginning. */
-       LTTNG_VIEWER_SEEK_BEGINNING     = 1,
-       /* Receive the trace packets from now. */
-       LTTNG_VIEWER_SEEK_LAST          = 2,
-};
-
-enum lttng_viewer_new_streams_return_code {
-       LTTNG_VIEWER_NEW_STREAMS_OK           = 1, /* If new streams are being sent. */
-       LTTNG_VIEWER_NEW_STREAMS_NO_NEW       = 2, /* If no new streams are available. */
-       LTTNG_VIEWER_NEW_STREAMS_ERR          = 3, /* Error. */
-       LTTNG_VIEWER_NEW_STREAMS_HUP          = 4, /* Session closed. */
-};
-
-enum lttng_viewer_create_session_return_code {
-       LTTNG_VIEWER_CREATE_SESSION_OK          = 1,
-       LTTNG_VIEWER_CREATE_SESSION_ERR         = 2,
-};
-
-enum lttng_viewer_detach_session_return_code {
-       LTTNG_VIEWER_DETACH_SESSION_OK          = 1,
-       LTTNG_VIEWER_DETACH_SESSION_UNK         = 2,
-       LTTNG_VIEWER_DETACH_SESSION_ERR         = 3,
-};
-
-struct lttng_viewer_session {
-       uint64_t id;
-       uint32_t live_timer;
-       uint32_t clients;
-       uint32_t streams;
-       char hostname[LTTNG_VIEWER_HOST_NAME_MAX];
-       char session_name[LTTNG_VIEWER_NAME_MAX];
-} LTTNG_PACKED;
-
-struct lttng_viewer_stream {
-       uint64_t id;
-       uint64_t ctf_trace_id;
-       uint32_t metadata_flag;
-       char path_name[LTTNG_VIEWER_PATH_MAX];
-       char channel_name[LTTNG_VIEWER_NAME_MAX];
-} LTTNG_PACKED;
-
-struct lttng_viewer_cmd {
-       uint64_t data_size;     /* data size following this header */
-       uint32_t cmd;           /* enum lttcomm_relayd_command */
-       uint32_t cmd_version;   /* command version */
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_CONNECT payload.
- */
-struct lttng_viewer_connect {
-       /* session ID assigned by the relay for command connections */
-       uint64_t viewer_session_id;
-       uint32_t major;
-       uint32_t minor;
-       uint32_t type;          /* enum lttng_viewer_connection_type */
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_LIST_SESSIONS payload.
- */
-struct lttng_viewer_list_sessions {
-       uint32_t sessions_count;
-       char session_list[];    /* struct lttng_viewer_session */
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_ATTACH_SESSION payload.
- */
-struct lttng_viewer_attach_session_request {
-       uint64_t session_id;
-       uint64_t offset;        /* unused for now */
-       uint32_t seek;          /* enum lttng_viewer_seek */
-} LTTNG_PACKED;
-
-struct lttng_viewer_attach_session_response {
-       /* enum lttng_viewer_attach_return_code */
-       uint32_t status;
-       uint32_t streams_count;
-       /* struct lttng_viewer_stream */
-       char stream_list[];
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_GET_NEXT_INDEX payload.
- */
-struct lttng_viewer_get_next_index {
-       uint64_t stream_id;
-} __attribute__ ((__packed__));
-
-struct lttng_viewer_index {
-       uint64_t offset;
-       uint64_t packet_size;
-       uint64_t content_size;
-       uint64_t timestamp_begin;
-       uint64_t timestamp_end;
-       uint64_t events_discarded;
-       uint64_t stream_id;
-       uint32_t status;        /* enum lttng_viewer_next_index_return_code */
-       uint32_t flags;         /* LTTNG_VIEWER_FLAG_* */
-} __attribute__ ((__packed__));
-
-/*
- * LTTNG_VIEWER_GET_PACKET payload.
- */
-struct lttng_viewer_get_packet {
-       uint64_t stream_id;
-       uint64_t offset;
-       uint32_t len;
-} LTTNG_PACKED;
-
-struct lttng_viewer_trace_packet {
-       uint32_t status;        /* enum lttng_viewer_get_packet_return_code */
-       uint32_t len;
-       uint32_t flags;         /* LTTNG_VIEWER_FLAG_* */
-       char data[];
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_GET_METADATA payload.
- */
-struct lttng_viewer_get_metadata {
-       uint64_t stream_id;
-} LTTNG_PACKED;
-
-struct lttng_viewer_metadata_packet {
-       uint64_t len;
-       uint32_t status;        /* enum lttng_viewer_get_metadata_return_code */
-       char data[];
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_GET_NEW_STREAMS payload.
- */
-struct lttng_viewer_new_streams_request {
-       uint64_t session_id;
-} LTTNG_PACKED;
-
-struct lttng_viewer_new_streams_response {
-       /* enum lttng_viewer_new_streams_return_code */
-       uint32_t status;
-       uint32_t streams_count;
-       /* struct lttng_viewer_stream */
-       char stream_list[];
-} LTTNG_PACKED;
-
-struct lttng_viewer_create_session_response {
-       /* enum lttng_viewer_create_session_return_code */
-       uint32_t status;
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_DETACH_SESSION payload.
- */
-struct lttng_viewer_detach_session_request {
-       uint64_t session_id;
-} LTTNG_PACKED;
-
-struct lttng_viewer_detach_session_response {
-       /* enum lttng_viewer_detach_session_return_code */
-       uint32_t status;
-} LTTNG_PACKED;
-
-#endif /* LTTNG_VIEWER_ABI_H */
diff --git a/src/bin/lttng-relayd/lttng-viewer-abi.hpp b/src/bin/lttng-relayd/lttng-viewer-abi.hpp
new file mode 100644 (file)
index 0000000..6fdb7fa
--- /dev/null
@@ -0,0 +1,240 @@
+#ifndef LTTNG_VIEWER_ABI_H
+#define LTTNG_VIEWER_ABI_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#include <limits.h>
+#include <common/macros.hpp>
+
+#define LTTNG_VIEWER_PATH_MAX          4096
+#define LTTNG_VIEWER_NAME_MAX          255
+#define LTTNG_VIEWER_HOST_NAME_MAX     64
+
+/* Flags in reply to get_next_index and get_packet. */
+enum {
+       /* New metadata is required to read this packet. */
+       LTTNG_VIEWER_FLAG_NEW_METADATA  = (1 << 0),
+       /* New stream got added to the trace. */
+       LTTNG_VIEWER_FLAG_NEW_STREAM    = (1 << 1),
+};
+
+enum lttng_viewer_command {
+       LTTNG_VIEWER_CONNECT            = 1,
+       LTTNG_VIEWER_LIST_SESSIONS      = 2,
+       LTTNG_VIEWER_ATTACH_SESSION     = 3,
+       LTTNG_VIEWER_GET_NEXT_INDEX     = 4,
+       LTTNG_VIEWER_GET_PACKET         = 5,
+       LTTNG_VIEWER_GET_METADATA       = 6,
+       LTTNG_VIEWER_GET_NEW_STREAMS    = 7,
+       LTTNG_VIEWER_CREATE_SESSION     = 8,
+       LTTNG_VIEWER_DETACH_SESSION     = 9,
+};
+
+enum lttng_viewer_attach_return_code {
+       LTTNG_VIEWER_ATTACH_OK          = 1, /* The attach command succeeded. */
+       LTTNG_VIEWER_ATTACH_ALREADY     = 2, /* A viewer is already attached. */
+       LTTNG_VIEWER_ATTACH_UNK         = 3, /* The session ID is unknown. */
+       LTTNG_VIEWER_ATTACH_NOT_LIVE    = 4, /* The session is not live. */
+       LTTNG_VIEWER_ATTACH_SEEK_ERR    = 5, /* Seek error. */
+       LTTNG_VIEWER_ATTACH_NO_SESSION  = 6, /* No viewer session created. */
+};
+
+enum lttng_viewer_next_index_return_code {
+       LTTNG_VIEWER_INDEX_OK           = 1, /* Index is available. */
+       LTTNG_VIEWER_INDEX_RETRY        = 2, /* Index not yet available. */
+       LTTNG_VIEWER_INDEX_HUP          = 3, /* Index closed (trace destroyed). */
+       LTTNG_VIEWER_INDEX_ERR          = 4, /* Unknow error. */
+       LTTNG_VIEWER_INDEX_INACTIVE     = 5, /* Inactive stream beacon. */
+       LTTNG_VIEWER_INDEX_EOF          = 6, /* End of index file. */
+};
+
+enum lttng_viewer_get_packet_return_code {
+       LTTNG_VIEWER_GET_PACKET_OK      = 1,
+       LTTNG_VIEWER_GET_PACKET_RETRY   = 2,
+       LTTNG_VIEWER_GET_PACKET_ERR     = 3,
+       LTTNG_VIEWER_GET_PACKET_EOF     = 4,
+};
+
+enum lttng_viewer_get_metadata_return_code {
+       LTTNG_VIEWER_METADATA_OK        = 1,
+       LTTNG_VIEWER_NO_NEW_METADATA    = 2,
+       LTTNG_VIEWER_METADATA_ERR       = 3,
+};
+
+enum lttng_viewer_connection_type {
+       LTTNG_VIEWER_CLIENT_COMMAND             = 1,
+       LTTNG_VIEWER_CLIENT_NOTIFICATION        = 2,
+};
+
+enum lttng_viewer_seek {
+       /* Receive the trace packets from the beginning. */
+       LTTNG_VIEWER_SEEK_BEGINNING     = 1,
+       /* Receive the trace packets from now. */
+       LTTNG_VIEWER_SEEK_LAST          = 2,
+};
+
+enum lttng_viewer_new_streams_return_code {
+       LTTNG_VIEWER_NEW_STREAMS_OK           = 1, /* If new streams are being sent. */
+       LTTNG_VIEWER_NEW_STREAMS_NO_NEW       = 2, /* If no new streams are available. */
+       LTTNG_VIEWER_NEW_STREAMS_ERR          = 3, /* Error. */
+       LTTNG_VIEWER_NEW_STREAMS_HUP          = 4, /* Session closed. */
+};
+
+enum lttng_viewer_create_session_return_code {
+       LTTNG_VIEWER_CREATE_SESSION_OK          = 1,
+       LTTNG_VIEWER_CREATE_SESSION_ERR         = 2,
+};
+
+enum lttng_viewer_detach_session_return_code {
+       LTTNG_VIEWER_DETACH_SESSION_OK          = 1,
+       LTTNG_VIEWER_DETACH_SESSION_UNK         = 2,
+       LTTNG_VIEWER_DETACH_SESSION_ERR         = 3,
+};
+
+struct lttng_viewer_session {
+       uint64_t id;
+       uint32_t live_timer;
+       uint32_t clients;
+       uint32_t streams;
+       char hostname[LTTNG_VIEWER_HOST_NAME_MAX];
+       char session_name[LTTNG_VIEWER_NAME_MAX];
+} LTTNG_PACKED;
+
+struct lttng_viewer_stream {
+       uint64_t id;
+       uint64_t ctf_trace_id;
+       uint32_t metadata_flag;
+       char path_name[LTTNG_VIEWER_PATH_MAX];
+       char channel_name[LTTNG_VIEWER_NAME_MAX];
+} LTTNG_PACKED;
+
+struct lttng_viewer_cmd {
+       uint64_t data_size;     /* data size following this header */
+       uint32_t cmd;           /* enum lttcomm_relayd_command */
+       uint32_t cmd_version;   /* command version */
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_CONNECT payload.
+ */
+struct lttng_viewer_connect {
+       /* session ID assigned by the relay for command connections */
+       uint64_t viewer_session_id;
+       uint32_t major;
+       uint32_t minor;
+       uint32_t type;          /* enum lttng_viewer_connection_type */
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_LIST_SESSIONS payload.
+ */
+struct lttng_viewer_list_sessions {
+       uint32_t sessions_count;
+       char session_list[];    /* struct lttng_viewer_session */
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_ATTACH_SESSION payload.
+ */
+struct lttng_viewer_attach_session_request {
+       uint64_t session_id;
+       uint64_t offset;        /* unused for now */
+       uint32_t seek;          /* enum lttng_viewer_seek */
+} LTTNG_PACKED;
+
+struct lttng_viewer_attach_session_response {
+       /* enum lttng_viewer_attach_return_code */
+       uint32_t status;
+       uint32_t streams_count;
+       /* struct lttng_viewer_stream */
+       char stream_list[];
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_GET_NEXT_INDEX payload.
+ */
+struct lttng_viewer_get_next_index {
+       uint64_t stream_id;
+} __attribute__ ((__packed__));
+
+struct lttng_viewer_index {
+       uint64_t offset;
+       uint64_t packet_size;
+       uint64_t content_size;
+       uint64_t timestamp_begin;
+       uint64_t timestamp_end;
+       uint64_t events_discarded;
+       uint64_t stream_id;
+       uint32_t status;        /* enum lttng_viewer_next_index_return_code */
+       uint32_t flags;         /* LTTNG_VIEWER_FLAG_* */
+} __attribute__ ((__packed__));
+
+/*
+ * LTTNG_VIEWER_GET_PACKET payload.
+ */
+struct lttng_viewer_get_packet {
+       uint64_t stream_id;
+       uint64_t offset;
+       uint32_t len;
+} LTTNG_PACKED;
+
+struct lttng_viewer_trace_packet {
+       uint32_t status;        /* enum lttng_viewer_get_packet_return_code */
+       uint32_t len;
+       uint32_t flags;         /* LTTNG_VIEWER_FLAG_* */
+       char data[];
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_GET_METADATA payload.
+ */
+struct lttng_viewer_get_metadata {
+       uint64_t stream_id;
+} LTTNG_PACKED;
+
+struct lttng_viewer_metadata_packet {
+       uint64_t len;
+       uint32_t status;        /* enum lttng_viewer_get_metadata_return_code */
+       char data[];
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_GET_NEW_STREAMS payload.
+ */
+struct lttng_viewer_new_streams_request {
+       uint64_t session_id;
+} LTTNG_PACKED;
+
+struct lttng_viewer_new_streams_response {
+       /* enum lttng_viewer_new_streams_return_code */
+       uint32_t status;
+       uint32_t streams_count;
+       /* struct lttng_viewer_stream */
+       char stream_list[];
+} LTTNG_PACKED;
+
+struct lttng_viewer_create_session_response {
+       /* enum lttng_viewer_create_session_return_code */
+       uint32_t status;
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_DETACH_SESSION payload.
+ */
+struct lttng_viewer_detach_session_request {
+       uint64_t session_id;
+} LTTNG_PACKED;
+
+struct lttng_viewer_detach_session_response {
+       /* enum lttng_viewer_detach_session_return_code */
+       uint32_t status;
+} LTTNG_PACKED;
+
+#endif /* LTTNG_VIEWER_ABI_H */
index 42eb09a897a1cc3f7d4fa285522efceca435dfe2..e1c74e358ebff36c9426cba3c2cc82a1ece4b3c8 100644 (file)
 #include <algorithm>
 
 #include <lttng/lttng.h>
-#include <common/common.h>
-#include <common/compat/poll.h>
-#include <common/compat/socket.h>
-#include <common/compat/endian.h>
-#include <common/compat/getenv.h>
-#include <common/defaults.h>
-#include <common/daemonize.h>
-#include <common/futex.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/sessiond-comm/inet.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/uri.h>
-#include <common/utils.h>
-#include <common/path.h>
-#include <common/align.h>
-#include <common/ini-config/ini-config.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <common/string-utils/format.h>
-#include <common/fd-tracker/fd-tracker.h>
-#include <common/fd-tracker/utils.h>
-
-#include "backward-compatibility-group-by.h"
-#include "cmd.h"
-#include "connection.h"
-#include "ctf-trace.h"
-#include "health-relayd.h"
-#include "index.h"
-#include "live.h"
-#include "lttng-relayd.h"
-#include "session.h"
-#include "sessiond-trace-chunks.h"
-#include "stream.h"
-#include "tcp_keep_alive.h"
-#include "testpoint.h"
-#include "tracefile-array.h"
-#include "utils.h"
-#include "version.h"
-#include "viewer-stream.h"
+#include <common/common.hpp>
+#include <common/compat/poll.hpp>
+#include <common/compat/socket.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/defaults.hpp>
+#include <common/daemonize.hpp>
+#include <common/futex.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/sessiond-comm/inet.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
+#include <common/align.hpp>
+#include <common/ini-config/ini-config.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
+#include <common/string-utils/format.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
+#include <common/fd-tracker/utils.hpp>
+
+#include "backward-compatibility-group-by.hpp"
+#include "cmd.hpp"
+#include "connection.hpp"
+#include "ctf-trace.hpp"
+#include "health-relayd.hpp"
+#include "index.hpp"
+#include "live.hpp"
+#include "lttng-relayd.hpp"
+#include "session.hpp"
+#include "sessiond-trace-chunks.hpp"
+#include "stream.hpp"
+#include "tcp_keep_alive.hpp"
+#include "testpoint.hpp"
+#include "tracefile-array.hpp"
+#include "utils.hpp"
+#include "version.hpp"
+#include "viewer-stream.hpp"
 
 static const char *help_msg =
 #ifdef LTTNG_EMBED_HELP
index ca8e183e64bbb2ca5118b52217c6228aca522271..abefc0d276ef355fefa11cc60d60de554e27b3da 100644 (file)
@@ -8,23 +8,23 @@
  */
 
 #define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/compat/path.h>
-#include <common/fd-tracker/utils.h>
-#include <common/time.h>
-#include <common/utils.h>
-#include <common/uuid.h>
+#include <common/common.hpp>
+#include <common/compat/path.hpp>
+#include <common/fd-tracker/utils.hpp>
+#include <common/time.hpp>
+#include <common/utils.hpp>
+#include <common/uuid.hpp>
 #include <urcu/rculist.h>
 
 #include <sys/stat.h>
 
-#include "ctf-trace.h"
-#include "lttng-relayd.h"
-#include "session.h"
-#include "sessiond-trace-chunks.h"
-#include "stream.h"
-#include <common/defaults.h>
-#include "utils.h"
+#include "ctf-trace.hpp"
+#include "lttng-relayd.hpp"
+#include "session.hpp"
+#include "sessiond-trace-chunks.hpp"
+#include "stream.hpp"
+#include <common/defaults.hpp>
+#include "utils.hpp"
 
 /* Global session id used in the session creation. */
 static uint64_t last_relay_session_id;
diff --git a/src/bin/lttng-relayd/session.h b/src/bin/lttng-relayd/session.h
deleted file mode 100644 (file)
index 8029dcd..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-#ifndef _SESSION_H
-#define _SESSION_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <urcu/list.h>
-#include <urcu/ref.h>
-
-#include <lttng/constant.h>
-#include <common/hashtable/hashtable.h>
-#include <common/uuid.h>
-#include <common/trace-chunk.h>
-#include <common/optional.h>
-
-/*
- * Represents a session for the relay point of view
- */
-struct relay_session {
-       /*
-        * This session id is generated by the relay daemon to guarantee
-        * its uniqueness even when serving multiple session daemons.
-        * It is used to match a set of streams to their session.
-        */
-       uint64_t id;
-       /*
-        * ID of the session in the session daemon's domain.
-        * This information is only provided by 2.11+ peers.
-        */
-       LTTNG_OPTIONAL(uint64_t) id_sessiond;
-       /*
-        * Only provided by 2.11+ peers. However, the UUID is set to 'nil' in
-        * the other cases.
-        */
-       lttng_uuid sessiond_uuid;
-       /*
-        * Contains the creation time on the session daemon's end for 2.11+
-        * peers. Otherwise, this contains the session creation time on the
-        * relay daemon's end.
-        */
-       LTTNG_OPTIONAL(time_t) creation_time;
-       /* Must _not_ be empty for 2.4+ peers. */
-       char session_name[LTTNG_NAME_MAX];
-       char hostname[LTTNG_HOST_NAME_MAX];
-       char base_path[LTTNG_PATH_MAX];
-       /*
-        * Session output path relative to relayd's output path.
-        * Will be empty when interacting with peers < 2.11 since their
-        * streams' path are expressed relative to the relay daemon's
-        * output path.
-        */
-       char output_path[LTTNG_PATH_MAX];
-       uint32_t live_timer;
-
-       /* Session in snapshot mode. */
-       bool snapshot;
-
-       /*
-        * Session has no back reference to its connection because it
-        * has a life-time that can be longer than the consumer connection's
-        * life-time; a reference can still be held by the viewer
-        * connection through the viewer streams.
-        */
-
-       struct urcu_ref ref;
-
-       mutable pthread_mutex_t lock;
-
-       /* major/minor version used for this session. */
-       uint32_t major;
-       uint32_t minor;
-
-       bool viewer_attached;
-       /* Tell if the session connection has been closed on the streaming side. */
-       bool connection_closed;
-
-       /*
-        * Tell if the session is currently living in a exiting relayd and
-        * should be cleaned forcefully without waiting for pending data or
-        * pending ctrl data.
-        */
-       bool aborted;
-
-       bool session_name_contains_creation_time;
-       /* Whether session has performed an explicit rotation. */
-       bool has_rotated;
-
-       /* Contains ctf_trace object of that session indexed by path name. */
-       struct lttng_ht *ctf_traces_ht;
-
-       /*
-        * This contains streams that are received on that connection.
-        * It's used to store them until we get the streams sent
-        * command. When this is received, we remove those streams from
-        * the list and publish them.
-        *
-        * Updates are protected by the recv_list_lock.
-        * Traversals are protected by RCU.
-        * recv_list_lock also protects stream_count.
-        */
-       struct cds_list_head recv_list; /* RCU list. */
-       uint32_t stream_count;
-       pthread_mutex_t recv_list_lock;
-
-       /*
-        * Flag checked and exchanged with uatomic_cmpxchg to tell the
-        * viewer-side if new streams got added since the last check.
-        */
-       unsigned long new_streams;
-
-       /*
-        * Node in the global session hash table.
-        */
-       struct lttng_ht_node_u64 session_n;
-       /*
-        * Member of the session list in struct relay_viewer_session.
-        * Updates are protected by the relay_viewer_session
-        * session_list_lock. Traversals are protected by RCU.
-        */
-       struct cds_list_head viewer_session_node;
-       struct lttng_trace_chunk *current_trace_chunk;
-       struct lttng_trace_chunk *pending_closure_trace_chunk;
-       /*
-        * Prevent live viewers from taking of copy of the chunk
-        * while new chunk has a temporary directory name.
-        */
-       bool ongoing_rotation;
-       struct lttng_directory_handle *output_directory;
-       struct rcu_head rcu_node;       /* For call_rcu teardown. */
-};
-
-struct relay_session *session_create(const char *session_name,
-               const char *hostname, const char *base_path,
-               uint32_t live_timer,
-               bool snapshot,
-               const lttng_uuid sessiond_uuid,
-               const uint64_t *id_sessiond,
-               const uint64_t *current_chunk_id,
-               const time_t *creation_time,
-               uint32_t major,
-               uint32_t minor,
-               bool session_name_contains_creation_timestamp);
-struct relay_session *session_get_by_id(uint64_t id);
-bool session_get(struct relay_session *session);
-void session_put(struct relay_session *session);
-
-int session_close(struct relay_session *session);
-int session_abort(struct relay_session *session);
-
-bool session_has_ongoing_rotation(const struct relay_session *session);
-
-void print_sessions(void);
-
-#endif /* _SESSION_H */
diff --git a/src/bin/lttng-relayd/session.hpp b/src/bin/lttng-relayd/session.hpp
new file mode 100644 (file)
index 0000000..9c61b94
--- /dev/null
@@ -0,0 +1,163 @@
+#ifndef _SESSION_H
+#define _SESSION_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <urcu/list.h>
+#include <urcu/ref.h>
+
+#include <lttng/constant.h>
+#include <common/hashtable/hashtable.hpp>
+#include <common/uuid.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/optional.hpp>
+
+/*
+ * Represents a session for the relay point of view
+ */
+struct relay_session {
+       /*
+        * This session id is generated by the relay daemon to guarantee
+        * its uniqueness even when serving multiple session daemons.
+        * It is used to match a set of streams to their session.
+        */
+       uint64_t id;
+       /*
+        * ID of the session in the session daemon's domain.
+        * This information is only provided by 2.11+ peers.
+        */
+       LTTNG_OPTIONAL(uint64_t) id_sessiond;
+       /*
+        * Only provided by 2.11+ peers. However, the UUID is set to 'nil' in
+        * the other cases.
+        */
+       lttng_uuid sessiond_uuid;
+       /*
+        * Contains the creation time on the session daemon's end for 2.11+
+        * peers. Otherwise, this contains the session creation time on the
+        * relay daemon's end.
+        */
+       LTTNG_OPTIONAL(time_t) creation_time;
+       /* Must _not_ be empty for 2.4+ peers. */
+       char session_name[LTTNG_NAME_MAX];
+       char hostname[LTTNG_HOST_NAME_MAX];
+       char base_path[LTTNG_PATH_MAX];
+       /*
+        * Session output path relative to relayd's output path.
+        * Will be empty when interacting with peers < 2.11 since their
+        * streams' path are expressed relative to the relay daemon's
+        * output path.
+        */
+       char output_path[LTTNG_PATH_MAX];
+       uint32_t live_timer;
+
+       /* Session in snapshot mode. */
+       bool snapshot;
+
+       /*
+        * Session has no back reference to its connection because it
+        * has a life-time that can be longer than the consumer connection's
+        * life-time; a reference can still be held by the viewer
+        * connection through the viewer streams.
+        */
+
+       struct urcu_ref ref;
+
+       mutable pthread_mutex_t lock;
+
+       /* major/minor version used for this session. */
+       uint32_t major;
+       uint32_t minor;
+
+       bool viewer_attached;
+       /* Tell if the session connection has been closed on the streaming side. */
+       bool connection_closed;
+
+       /*
+        * Tell if the session is currently living in a exiting relayd and
+        * should be cleaned forcefully without waiting for pending data or
+        * pending ctrl data.
+        */
+       bool aborted;
+
+       bool session_name_contains_creation_time;
+       /* Whether session has performed an explicit rotation. */
+       bool has_rotated;
+
+       /* Contains ctf_trace object of that session indexed by path name. */
+       struct lttng_ht *ctf_traces_ht;
+
+       /*
+        * This contains streams that are received on that connection.
+        * It's used to store them until we get the streams sent
+        * command. When this is received, we remove those streams from
+        * the list and publish them.
+        *
+        * Updates are protected by the recv_list_lock.
+        * Traversals are protected by RCU.
+        * recv_list_lock also protects stream_count.
+        */
+       struct cds_list_head recv_list; /* RCU list. */
+       uint32_t stream_count;
+       pthread_mutex_t recv_list_lock;
+
+       /*
+        * Flag checked and exchanged with uatomic_cmpxchg to tell the
+        * viewer-side if new streams got added since the last check.
+        */
+       unsigned long new_streams;
+
+       /*
+        * Node in the global session hash table.
+        */
+       struct lttng_ht_node_u64 session_n;
+       /*
+        * Member of the session list in struct relay_viewer_session.
+        * Updates are protected by the relay_viewer_session
+        * session_list_lock. Traversals are protected by RCU.
+        */
+       struct cds_list_head viewer_session_node;
+       struct lttng_trace_chunk *current_trace_chunk;
+       struct lttng_trace_chunk *pending_closure_trace_chunk;
+       /*
+        * Prevent live viewers from taking of copy of the chunk
+        * while new chunk has a temporary directory name.
+        */
+       bool ongoing_rotation;
+       struct lttng_directory_handle *output_directory;
+       struct rcu_head rcu_node;       /* For call_rcu teardown. */
+};
+
+struct relay_session *session_create(const char *session_name,
+               const char *hostname, const char *base_path,
+               uint32_t live_timer,
+               bool snapshot,
+               const lttng_uuid sessiond_uuid,
+               const uint64_t *id_sessiond,
+               const uint64_t *current_chunk_id,
+               const time_t *creation_time,
+               uint32_t major,
+               uint32_t minor,
+               bool session_name_contains_creation_timestamp);
+struct relay_session *session_get_by_id(uint64_t id);
+bool session_get(struct relay_session *session);
+void session_put(struct relay_session *session);
+
+int session_close(struct relay_session *session);
+int session_abort(struct relay_session *session);
+
+bool session_has_ongoing_rotation(const struct relay_session *session);
+
+void print_sessions(void);
+
+#endif /* _SESSION_H */
index 18ef586d00c85d62e5b92bfbc083979dc32e5bf6..0a5c44825414bc720fe6081e459b5b3410c349b4 100644 (file)
@@ -5,17 +5,17 @@
  *
  */
 
-#include "sessiond-trace-chunks.h"
+#include "sessiond-trace-chunks.hpp"
 #include <urcu.h>
 #include <urcu/rculfhash.h>
 #include <urcu/ref.h>
-#include <common/macros.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/trace-chunk-registry.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/string-utils/format.h>
+#include <common/macros.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/trace-chunk-registry.hpp>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/string-utils/format.hpp>
 #include <stdio.h>
 #include <inttypes.h>
 
diff --git a/src/bin/lttng-relayd/sessiond-trace-chunks.h b/src/bin/lttng-relayd/sessiond-trace-chunks.h
deleted file mode 100644 (file)
index 2c771d8..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_TRACE_CHUNK_REGISTRY_H
-#define SESSIOND_TRACE_CHUNK_REGISTRY_H
-
-#include <common/uuid.h>
-#include <common/trace-chunk.h>
-#include <stdint.h>
-
-/*
- * A session trace chunk registry allows the relay daemon to share trace chunks
- * used by different "relay sessions" when they were created for the same
- * user-visible session daemon session. Tracing multiple domains (e.g. ust and
- * kernel) results in per-domain relay sessions being created.
- *
- * Sharing trace chunks, and their output directory more specifically, is
- * essential to properly implement session rotations. The sharing of output
- * directory handles allows directory renames to be performed once and without
- * races that would stem from from multiple renames.
- */
-struct sessiond_trace_chunk_registry;
-
-struct sessiond_trace_chunk_registry *
-sessiond_trace_chunk_registry_create(void);
-
-void sessiond_trace_chunk_registry_destroy(
-               struct sessiond_trace_chunk_registry *sessiond_registry);
-
-int sessiond_trace_chunk_registry_session_created(
-               struct sessiond_trace_chunk_registry *sessiond_registry,
-               const lttng_uuid sessiond_uuid);
-
-int sessiond_trace_chunk_registry_session_destroyed(
-               struct sessiond_trace_chunk_registry *sessiond_registry,
-               const lttng_uuid sessiond_uuid);
-
-struct lttng_trace_chunk *sessiond_trace_chunk_registry_publish_chunk(
-               struct sessiond_trace_chunk_registry *sessiond_registry,
-               const lttng_uuid sessiond_uuid, uint64_t session_id,
-               struct lttng_trace_chunk *chunk);
-
-struct lttng_trace_chunk *
-sessiond_trace_chunk_registry_get_anonymous_chunk(
-               struct sessiond_trace_chunk_registry *sessiond_registry,
-               const lttng_uuid sessiond_uuid,
-               uint64_t session_id);
-
-struct lttng_trace_chunk *
-sessiond_trace_chunk_registry_get_chunk(
-               struct sessiond_trace_chunk_registry *sessiond_registry,
-               const lttng_uuid sessiond_uuid,
-               uint64_t session_id, uint64_t chunk_id);
-
-int sessiond_trace_chunk_registry_chunk_exists(
-               struct sessiond_trace_chunk_registry *sessiond_registry,
-               const lttng_uuid sessiond_uuid,
-               uint64_t session_id, uint64_t chunk_id, bool *chunk_exists);
-
-#endif /* SESSIOND_TRACE_CHUNK_REGISTRY_H */
diff --git a/src/bin/lttng-relayd/sessiond-trace-chunks.hpp b/src/bin/lttng-relayd/sessiond-trace-chunks.hpp
new file mode 100644 (file)
index 0000000..2e49429
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_TRACE_CHUNK_REGISTRY_H
+#define SESSIOND_TRACE_CHUNK_REGISTRY_H
+
+#include <common/uuid.hpp>
+#include <common/trace-chunk.hpp>
+#include <stdint.h>
+
+/*
+ * A session trace chunk registry allows the relay daemon to share trace chunks
+ * used by different "relay sessions" when they were created for the same
+ * user-visible session daemon session. Tracing multiple domains (e.g. ust and
+ * kernel) results in per-domain relay sessions being created.
+ *
+ * Sharing trace chunks, and their output directory more specifically, is
+ * essential to properly implement session rotations. The sharing of output
+ * directory handles allows directory renames to be performed once and without
+ * races that would stem from from multiple renames.
+ */
+struct sessiond_trace_chunk_registry;
+
+struct sessiond_trace_chunk_registry *
+sessiond_trace_chunk_registry_create(void);
+
+void sessiond_trace_chunk_registry_destroy(
+               struct sessiond_trace_chunk_registry *sessiond_registry);
+
+int sessiond_trace_chunk_registry_session_created(
+               struct sessiond_trace_chunk_registry *sessiond_registry,
+               const lttng_uuid sessiond_uuid);
+
+int sessiond_trace_chunk_registry_session_destroyed(
+               struct sessiond_trace_chunk_registry *sessiond_registry,
+               const lttng_uuid sessiond_uuid);
+
+struct lttng_trace_chunk *sessiond_trace_chunk_registry_publish_chunk(
+               struct sessiond_trace_chunk_registry *sessiond_registry,
+               const lttng_uuid sessiond_uuid, uint64_t session_id,
+               struct lttng_trace_chunk *chunk);
+
+struct lttng_trace_chunk *
+sessiond_trace_chunk_registry_get_anonymous_chunk(
+               struct sessiond_trace_chunk_registry *sessiond_registry,
+               const lttng_uuid sessiond_uuid,
+               uint64_t session_id);
+
+struct lttng_trace_chunk *
+sessiond_trace_chunk_registry_get_chunk(
+               struct sessiond_trace_chunk_registry *sessiond_registry,
+               const lttng_uuid sessiond_uuid,
+               uint64_t session_id, uint64_t chunk_id);
+
+int sessiond_trace_chunk_registry_chunk_exists(
+               struct sessiond_trace_chunk_registry *sessiond_registry,
+               const lttng_uuid sessiond_uuid,
+               uint64_t session_id, uint64_t chunk_id, bool *chunk_exists);
+
+#endif /* SESSIOND_TRACE_CHUNK_REGISTRY_H */
index 65a8ce11abf95a9c8b45a7077c06f5db94cd535a..aba160bfa473c5ac401f9e62a55482839e3c837d 100644 (file)
 
 #define _LGPL_SOURCE
 #include <algorithm>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/fs-handle.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/fs-handle.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/utils.hpp>
 #include <sys/stat.h>
 #include <urcu/rculist.h>
 
-#include "lttng-relayd.h"
-#include "index.h"
-#include "stream.h"
-#include "viewer-stream.h"
+#include "lttng-relayd.hpp"
+#include "index.hpp"
+#include "stream.hpp"
+#include "viewer-stream.hpp"
 
 #include <sys/types.h>
 #include <fcntl.h>
diff --git a/src/bin/lttng-relayd/stream.h b/src/bin/lttng-relayd/stream.h
deleted file mode 100644 (file)
index c64b180..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-#ifndef _STREAM_H
-#define _STREAM_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <urcu/list.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/trace-chunk.h>
-#include <common/optional.h>
-#include <common/buffer-view.h>
-
-#include "session.h"
-#include "tracefile-array.h"
-
-struct lttcomm_relayd_index;
-
-struct relay_stream_rotation {
-       /*
-        * Indicates if the stream's data and index have been rotated. A
-        * rotation is considered completed when both rotations have occurred.
-        */
-       bool data_rotated;
-       bool index_rotated;
-       /*
-        * Packet sequence number of the first packet of the new trace chunk to
-        * which the stream is rotating.
-        */
-       uint64_t packet_seq_num;
-       /*
-        * Monotonically increasing previous network sequence number of first
-        * data packet of the new trace chunk to which the stream is rotating.
-        */
-       uint64_t prev_data_net_seq;
-       struct lttng_trace_chunk *next_trace_chunk;
-};
-
-/*
- * Represents a stream in the relay
- */
-struct relay_stream {
-       uint64_t stream_handle;
-
-       struct urcu_ref ref;
-       /* Back reference to trace. Protected by refcount on trace object. */
-       struct ctf_trace *trace;
-
-       /*
-        * To protect from concurrent read/update. The viewer stream
-        * lock nests inside the stream lock. The stream lock nests
-        * inside the ctf_trace lock.
-        */
-       pthread_mutex_t lock;
-       /* previous data sequence number written to disk. */
-       uint64_t prev_data_seq;
-       /* previous index sequence number written to disk. */
-       uint64_t prev_index_seq;
-       /* seq num to encounter before closing. */
-       uint64_t last_net_seq_num;
-
-       struct fs_handle *file;
-       /* index file on which to write the index data. */
-       struct lttng_index_file *index_file;
-
-       char *path_name;
-       char *channel_name;
-
-       /* On-disk circular buffer of tracefiles. */
-       uint64_t tracefile_size;
-       uint64_t tracefile_size_current;
-       /* Max number of trace files for this stream. */
-       uint64_t tracefile_count;
-       /*
-        * Index of the currently active file for this stream's on-disk
-        * ring buffer.
-        */
-       uint64_t tracefile_current_index;
-       /*
-        * Indicates that the on-disk buffer has wrapped around. Stream
-        * files shall be unlinked before being opened after this has occurred.
-        */
-       bool tracefile_wrapped_around;
-
-       /*
-        * Position in the tracefile where we have the full index also on disk.
-        */
-       uint64_t pos_after_last_complete_data_index;
-
-       /*
-        * Counts the number of received indexes. The "tag" associated
-        * with an index is taken before incrementing this seqcount.
-        * Therefore, the sequence tag associated with the last index
-        * received is always index_received_seqcount - 1.
-        */
-       uint64_t index_received_seqcount;
-
-       /*
-        * Packet sequence number of the last received packet index.
-        * Only populated when interacting with CTF_INDEX 1.1+.
-        */
-       LTTNG_OPTIONAL(uint64_t) received_packet_seq_num;
-
-       /*
-        * Tracefile array is an index of the stream trace files,
-        * indexed by position. It allows keeping track of the oldest
-        * available indexes when overwriting trace files in tracefile
-        * rotation.
-        */
-       struct tracefile_array *tfa;
-
-       bool closed;            /* Stream is closed. */
-       bool close_requested;   /* Close command has been received. */
-
-       /*
-        * Counts number of indexes in indexes_ht. Redundant info.
-        * Protected by stream lock.
-        */
-       int indexes_in_flight;
-       struct lttng_ht *indexes_ht;
-
-       /*
-        * If the stream is inactive, this field is updated with the
-        * live beacon timestamp end, when it is active, this
-        * field == -1ULL.
-        */
-       uint64_t beacon_ts_end;
-
-       /* CTF stream ID, -1ULL when unset (first packet not received yet). */
-       uint64_t ctf_stream_id;
-
-       /* Indicate if the stream was initialized for a data pending command. */
-       bool data_pending_check_done;
-
-       /* Is this stream a metadata stream ? */
-       bool is_metadata;
-       /* Amount of metadata received (bytes). */
-       uint64_t metadata_received;
-
-       /*
-        * Member of the stream list in struct ctf_trace.
-        * Updates are protected by the stream_list_lock.
-        * Traversals are protected by RCU.
-        */
-       struct cds_list_head stream_node;
-       /*
-        * Temporary list belonging to the connection until all streams
-        * are received for that connection.
-        * Member of the stream recv list in the connection.
-        * Updates are protected by the stream_recv_list_lock.
-        * Traversals are protected by RCU.
-        */
-       bool in_recv_list;
-       struct cds_list_head recv_node;
-       /* Protected by session lock. */
-       bool published;
-       /* Notified viewer that no new metadata is available. */
-       bool no_new_metadata_notified;
-       /*
-        * Node of stream within global stream hash table.
-        */
-       struct lttng_ht_node_u64 node;
-       bool in_stream_ht;              /* is stream in stream hash table. */
-       struct rcu_head rcu_node;       /* For call_rcu teardown. */
-       /*
-        * The trace chunk to which the file currently being produced (if any)
-        * belongs.
-        *
-        * Note that a relay stream can have no output trace chunk. For
-        * instance, after a session stop followed by a session clear,
-        * streams will not have an output trace chunk until the session
-        * is resumed.
-        */
-       struct lttng_trace_chunk *trace_chunk;
-       LTTNG_OPTIONAL(struct relay_stream_rotation) ongoing_rotation;
-       uint64_t completed_rotation_count;
-};
-
-struct relay_stream *stream_create(struct ctf_trace *trace,
-       uint64_t stream_handle, char *path_name,
-       char *channel_name, uint64_t tracefile_size,
-       uint64_t tracefile_count);
-
-struct relay_stream *stream_get_by_id(uint64_t stream_id);
-bool stream_get(struct relay_stream *stream);
-void stream_put(struct relay_stream *stream);
-int stream_rotate_output_files(struct relay_session *session,
-               struct relay_stream *stream);
-int stream_set_pending_rotation(struct relay_stream *stream,
-               struct lttng_trace_chunk *next_trace_chunk,
-               uint64_t rotation_sequence_number);
-void try_stream_close(struct relay_stream *stream);
-void stream_publish(struct relay_stream *stream);
-int stream_init_packet(struct relay_stream *stream, size_t packet_size,
-               bool *file_rotated);
-int stream_write(struct relay_stream *stream,
-               const struct lttng_buffer_view *packet, size_t padding_len);
-/* Called after the reception of a complete data packet. */
-int stream_update_index(struct relay_stream *stream, uint64_t net_seq_num,
-               bool rotate_index, bool *flushed, uint64_t total_size);
-int stream_complete_packet(struct relay_stream *stream,
-               size_t packet_total_size, uint64_t sequence_number,
-               bool index_flushed);
-/* Index info is in host endianness. */
-int stream_add_index(struct relay_stream *stream,
-               const struct lttcomm_relayd_index *index_info);
-int stream_reset_file(struct relay_stream *stream);
-
-void print_relay_streams(void);
-
-#endif /* _STREAM_H */
diff --git a/src/bin/lttng-relayd/stream.hpp b/src/bin/lttng-relayd/stream.hpp
new file mode 100644 (file)
index 0000000..6e09c55
--- /dev/null
@@ -0,0 +1,220 @@
+#ifndef _STREAM_H
+#define _STREAM_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <urcu/list.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/optional.hpp>
+#include <common/buffer-view.hpp>
+
+#include "session.hpp"
+#include "tracefile-array.hpp"
+
+struct lttcomm_relayd_index;
+
+struct relay_stream_rotation {
+       /*
+        * Indicates if the stream's data and index have been rotated. A
+        * rotation is considered completed when both rotations have occurred.
+        */
+       bool data_rotated;
+       bool index_rotated;
+       /*
+        * Packet sequence number of the first packet of the new trace chunk to
+        * which the stream is rotating.
+        */
+       uint64_t packet_seq_num;
+       /*
+        * Monotonically increasing previous network sequence number of first
+        * data packet of the new trace chunk to which the stream is rotating.
+        */
+       uint64_t prev_data_net_seq;
+       struct lttng_trace_chunk *next_trace_chunk;
+};
+
+/*
+ * Represents a stream in the relay
+ */
+struct relay_stream {
+       uint64_t stream_handle;
+
+       struct urcu_ref ref;
+       /* Back reference to trace. Protected by refcount on trace object. */
+       struct ctf_trace *trace;
+
+       /*
+        * To protect from concurrent read/update. The viewer stream
+        * lock nests inside the stream lock. The stream lock nests
+        * inside the ctf_trace lock.
+        */
+       pthread_mutex_t lock;
+       /* previous data sequence number written to disk. */
+       uint64_t prev_data_seq;
+       /* previous index sequence number written to disk. */
+       uint64_t prev_index_seq;
+       /* seq num to encounter before closing. */
+       uint64_t last_net_seq_num;
+
+       struct fs_handle *file;
+       /* index file on which to write the index data. */
+       struct lttng_index_file *index_file;
+
+       char *path_name;
+       char *channel_name;
+
+       /* On-disk circular buffer of tracefiles. */
+       uint64_t tracefile_size;
+       uint64_t tracefile_size_current;
+       /* Max number of trace files for this stream. */
+       uint64_t tracefile_count;
+       /*
+        * Index of the currently active file for this stream's on-disk
+        * ring buffer.
+        */
+       uint64_t tracefile_current_index;
+       /*
+        * Indicates that the on-disk buffer has wrapped around. Stream
+        * files shall be unlinked before being opened after this has occurred.
+        */
+       bool tracefile_wrapped_around;
+
+       /*
+        * Position in the tracefile where we have the full index also on disk.
+        */
+       uint64_t pos_after_last_complete_data_index;
+
+       /*
+        * Counts the number of received indexes. The "tag" associated
+        * with an index is taken before incrementing this seqcount.
+        * Therefore, the sequence tag associated with the last index
+        * received is always index_received_seqcount - 1.
+        */
+       uint64_t index_received_seqcount;
+
+       /*
+        * Packet sequence number of the last received packet index.
+        * Only populated when interacting with CTF_INDEX 1.1+.
+        */
+       LTTNG_OPTIONAL(uint64_t) received_packet_seq_num;
+
+       /*
+        * Tracefile array is an index of the stream trace files,
+        * indexed by position. It allows keeping track of the oldest
+        * available indexes when overwriting trace files in tracefile
+        * rotation.
+        */
+       struct tracefile_array *tfa;
+
+       bool closed;            /* Stream is closed. */
+       bool close_requested;   /* Close command has been received. */
+
+       /*
+        * Counts number of indexes in indexes_ht. Redundant info.
+        * Protected by stream lock.
+        */
+       int indexes_in_flight;
+       struct lttng_ht *indexes_ht;
+
+       /*
+        * If the stream is inactive, this field is updated with the
+        * live beacon timestamp end, when it is active, this
+        * field == -1ULL.
+        */
+       uint64_t beacon_ts_end;
+
+       /* CTF stream ID, -1ULL when unset (first packet not received yet). */
+       uint64_t ctf_stream_id;
+
+       /* Indicate if the stream was initialized for a data pending command. */
+       bool data_pending_check_done;
+
+       /* Is this stream a metadata stream ? */
+       bool is_metadata;
+       /* Amount of metadata received (bytes). */
+       uint64_t metadata_received;
+
+       /*
+        * Member of the stream list in struct ctf_trace.
+        * Updates are protected by the stream_list_lock.
+        * Traversals are protected by RCU.
+        */
+       struct cds_list_head stream_node;
+       /*
+        * Temporary list belonging to the connection until all streams
+        * are received for that connection.
+        * Member of the stream recv list in the connection.
+        * Updates are protected by the stream_recv_list_lock.
+        * Traversals are protected by RCU.
+        */
+       bool in_recv_list;
+       struct cds_list_head recv_node;
+       /* Protected by session lock. */
+       bool published;
+       /* Notified viewer that no new metadata is available. */
+       bool no_new_metadata_notified;
+       /*
+        * Node of stream within global stream hash table.
+        */
+       struct lttng_ht_node_u64 node;
+       bool in_stream_ht;              /* is stream in stream hash table. */
+       struct rcu_head rcu_node;       /* For call_rcu teardown. */
+       /*
+        * The trace chunk to which the file currently being produced (if any)
+        * belongs.
+        *
+        * Note that a relay stream can have no output trace chunk. For
+        * instance, after a session stop followed by a session clear,
+        * streams will not have an output trace chunk until the session
+        * is resumed.
+        */
+       struct lttng_trace_chunk *trace_chunk;
+       LTTNG_OPTIONAL(struct relay_stream_rotation) ongoing_rotation;
+       uint64_t completed_rotation_count;
+};
+
+struct relay_stream *stream_create(struct ctf_trace *trace,
+       uint64_t stream_handle, char *path_name,
+       char *channel_name, uint64_t tracefile_size,
+       uint64_t tracefile_count);
+
+struct relay_stream *stream_get_by_id(uint64_t stream_id);
+bool stream_get(struct relay_stream *stream);
+void stream_put(struct relay_stream *stream);
+int stream_rotate_output_files(struct relay_session *session,
+               struct relay_stream *stream);
+int stream_set_pending_rotation(struct relay_stream *stream,
+               struct lttng_trace_chunk *next_trace_chunk,
+               uint64_t rotation_sequence_number);
+void try_stream_close(struct relay_stream *stream);
+void stream_publish(struct relay_stream *stream);
+int stream_init_packet(struct relay_stream *stream, size_t packet_size,
+               bool *file_rotated);
+int stream_write(struct relay_stream *stream,
+               const struct lttng_buffer_view *packet, size_t padding_len);
+/* Called after the reception of a complete data packet. */
+int stream_update_index(struct relay_stream *stream, uint64_t net_seq_num,
+               bool rotate_index, bool *flushed, uint64_t total_size);
+int stream_complete_packet(struct relay_stream *stream,
+               size_t packet_total_size, uint64_t sequence_number,
+               bool index_flushed);
+/* Index info is in host endianness. */
+int stream_add_index(struct relay_stream *stream,
+               const struct lttcomm_relayd_index *index_info);
+int stream_reset_file(struct relay_stream *stream);
+
+void print_relay_streams(void);
+
+#endif /* _STREAM_H */
index c52a55ffba4cb1493d1b9ce60d743ed6ee62b552..885b2a6a5617391e4a430674e37f4c4459cfca34 100644 (file)
 #include <sys/socket.h>
 #include <limits.h>
 
-#include <common/compat/getenv.h>
-#include <common/time.h>
-#include <common/defaults.h>
-#include <common/ini-config/ini-config.h>
+#include <common/compat/getenv.hpp>
+#include <common/time.hpp>
+#include <common/defaults.hpp>
+#include <common/ini-config/ini-config.hpp>
 
-#include "tcp_keep_alive.h"
+#include "tcp_keep_alive.hpp"
 
 #define SOLARIS_IDLE_TIME_MIN_S 10
 #define SOLARIS_IDLE_TIME_MAX_S 864000 /* 10 days */
diff --git a/src/bin/lttng-relayd/tcp_keep_alive.h b/src/bin/lttng-relayd/tcp_keep_alive.h
deleted file mode 100644 (file)
index 2236028..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef RELAYD_TCP_KEEP_ALIVE_H
-#define RELAYD_TCP_KEEP_ALIVE_H
-
-#include <common/macros.h>
-
-int socket_apply_keep_alive_config(int socket_fd);
-
-#endif /* RELAYD_TCP_KEEP_ALIVE_H */
diff --git a/src/bin/lttng-relayd/tcp_keep_alive.hpp b/src/bin/lttng-relayd/tcp_keep_alive.hpp
new file mode 100644 (file)
index 0000000..840730f
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef RELAYD_TCP_KEEP_ALIVE_H
+#define RELAYD_TCP_KEEP_ALIVE_H
+
+#include <common/macros.hpp>
+
+int socket_apply_keep_alive_config(int socket_fd);
+
+#endif /* RELAYD_TCP_KEEP_ALIVE_H */
diff --git a/src/bin/lttng-relayd/testpoint.h b/src/bin/lttng-relayd/testpoint.h
deleted file mode 100644 (file)
index f58836a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef RELAYD_TESTPOINT_H
-#define RELAYD_TESTPOINT_H
-
-/*
- * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
- * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <common/testpoint/testpoint.h>
-
-/* Testpoints, internal use only */
-TESTPOINT_DECL(relayd_thread_dispatcher);
-TESTPOINT_DECL(relayd_thread_worker);
-TESTPOINT_DECL(relayd_thread_listener);
-TESTPOINT_DECL(relayd_thread_live_dispatcher);
-TESTPOINT_DECL(relayd_thread_live_worker);
-TESTPOINT_DECL(relayd_thread_live_listener);
-
-#endif /* SESSIOND_TESTPOINT_H */
diff --git a/src/bin/lttng-relayd/testpoint.hpp b/src/bin/lttng-relayd/testpoint.hpp
new file mode 100644 (file)
index 0000000..84fb4a8
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef RELAYD_TESTPOINT_H
+#define RELAYD_TESTPOINT_H
+
+/*
+ * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
+ * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <common/testpoint/testpoint.hpp>
+
+/* Testpoints, internal use only */
+TESTPOINT_DECL(relayd_thread_dispatcher);
+TESTPOINT_DECL(relayd_thread_worker);
+TESTPOINT_DECL(relayd_thread_listener);
+TESTPOINT_DECL(relayd_thread_live_dispatcher);
+TESTPOINT_DECL(relayd_thread_live_worker);
+TESTPOINT_DECL(relayd_thread_live_listener);
+
+#endif /* SESSIOND_TESTPOINT_H */
index 05012b642cc40f6f6c913806e808b56d488e45d5..8b1b533d5d60e8520344531ff3f3813d36030591 100644 (file)
@@ -6,11 +6,11 @@
  */
 
 #define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/utils.h>
-#include <common/defaults.h>
+#include <common/common.hpp>
+#include <common/utils.hpp>
+#include <common/defaults.hpp>
 
-#include "tracefile-array.h"
+#include "tracefile-array.hpp"
 
 struct tracefile_array *tracefile_array_create(size_t count)
 {
diff --git a/src/bin/lttng-relayd/tracefile-array.h b/src/bin/lttng-relayd/tracefile-array.h
deleted file mode 100644 (file)
index 09c425f..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef _TRACEFILE_ARRAY_H
-#define _TRACEFILE_ARRAY_H
-
-/*
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <stdbool.h>
-
-struct tracefile {
-       /* Per-tracefile head/tail seq. */
-       uint64_t seq_head;      /* Newest seqcount. Inclusive. */
-       uint64_t seq_tail;      /* Oldest seqcount. Inclusive. */
-};
-
-enum tracefile_rotate_type {
-       TRACEFILE_ROTATE_READ,
-       TRACEFILE_ROTATE_WRITE,
-};
-
-/*
- * Represents an array of trace files in a stream.
- * head is the most recent file/trace packet.
- * tail is the oldest file/trace packet.
- *
- * There are two heads: a "read" head and a "write" head. The "write" head is
- * the position of the newest data file. The "read" head position is only moved
- * forward when the index is received.
- *
- * The viewer uses the "read" head position as upper bound, which
- * ensures it never attempts to open a non-existing index file.
- */
-struct tracefile_array {
-       struct tracefile *tf;
-       size_t count;
-
-       /* Current head/tail files. */
-       uint64_t file_head_read;
-       uint64_t file_head_write;
-       uint64_t file_tail;
-
-       /* Overall head/tail seq for the entire array. Inclusive. */
-       uint64_t seq_head;
-       uint64_t seq_tail;
-};
-
-struct tracefile_array *tracefile_array_create(size_t count);
-void tracefile_array_destroy(struct tracefile_array *tfa);
-
-void tracefile_array_file_rotate(struct tracefile_array *tfa, enum tracefile_rotate_type type);
-void tracefile_array_commit_seq(struct tracefile_array *tfa,
-               uint64_t new_seq_head);
-void tracefile_array_reset(struct tracefile_array *tfa);
-
-uint64_t tracefile_array_get_read_file_index_head(struct tracefile_array *tfa);
-/* May return -1ULL in the case where we have not received any indexes yet. */
-uint64_t tracefile_array_get_seq_head(struct tracefile_array *tfa);
-
-uint64_t tracefile_array_get_file_index_tail(struct tracefile_array *tfa);
-/* May return -1ULL in the case where we have not received any indexes yet. */
-uint64_t tracefile_array_get_seq_tail(struct tracefile_array *tfa);
-
-bool tracefile_array_seq_in_file(struct tracefile_array *tfa,
-               uint64_t file_index, uint64_t seq);
-
-#endif /* _STREAM_H */
diff --git a/src/bin/lttng-relayd/tracefile-array.hpp b/src/bin/lttng-relayd/tracefile-array.hpp
new file mode 100644 (file)
index 0000000..09c425f
--- /dev/null
@@ -0,0 +1,72 @@
+#ifndef _TRACEFILE_ARRAY_H
+#define _TRACEFILE_ARRAY_H
+
+/*
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <stdbool.h>
+
+struct tracefile {
+       /* Per-tracefile head/tail seq. */
+       uint64_t seq_head;      /* Newest seqcount. Inclusive. */
+       uint64_t seq_tail;      /* Oldest seqcount. Inclusive. */
+};
+
+enum tracefile_rotate_type {
+       TRACEFILE_ROTATE_READ,
+       TRACEFILE_ROTATE_WRITE,
+};
+
+/*
+ * Represents an array of trace files in a stream.
+ * head is the most recent file/trace packet.
+ * tail is the oldest file/trace packet.
+ *
+ * There are two heads: a "read" head and a "write" head. The "write" head is
+ * the position of the newest data file. The "read" head position is only moved
+ * forward when the index is received.
+ *
+ * The viewer uses the "read" head position as upper bound, which
+ * ensures it never attempts to open a non-existing index file.
+ */
+struct tracefile_array {
+       struct tracefile *tf;
+       size_t count;
+
+       /* Current head/tail files. */
+       uint64_t file_head_read;
+       uint64_t file_head_write;
+       uint64_t file_tail;
+
+       /* Overall head/tail seq for the entire array. Inclusive. */
+       uint64_t seq_head;
+       uint64_t seq_tail;
+};
+
+struct tracefile_array *tracefile_array_create(size_t count);
+void tracefile_array_destroy(struct tracefile_array *tfa);
+
+void tracefile_array_file_rotate(struct tracefile_array *tfa, enum tracefile_rotate_type type);
+void tracefile_array_commit_seq(struct tracefile_array *tfa,
+               uint64_t new_seq_head);
+void tracefile_array_reset(struct tracefile_array *tfa);
+
+uint64_t tracefile_array_get_read_file_index_head(struct tracefile_array *tfa);
+/* May return -1ULL in the case where we have not received any indexes yet. */
+uint64_t tracefile_array_get_seq_head(struct tracefile_array *tfa);
+
+uint64_t tracefile_array_get_file_index_tail(struct tracefile_array *tfa);
+/* May return -1ULL in the case where we have not received any indexes yet. */
+uint64_t tracefile_array_get_seq_tail(struct tracefile_array *tfa);
+
+bool tracefile_array_seq_in_file(struct tracefile_array *tfa,
+               uint64_t file_index, uint64_t seq);
+
+#endif /* _STREAM_H */
index 52ac19e8a65c8641b06a9a7a86dd7bbc7a4a7583..ccfc3a92a745f85a68848556f78529f47ebc2a9e 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/utils.h>
-#include <common/path.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
 
-#include "lttng-relayd.h"
-#include "utils.h"
+#include "lttng-relayd.hpp"
+#include "utils.hpp"
 
 static char *create_output_path_auto(const char *path_name)
 {
diff --git a/src/bin/lttng-relayd/utils.h b/src/bin/lttng-relayd/utils.h
deleted file mode 100644 (file)
index b02a791..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef RELAYD_UTILS_H
-#define RELAYD_UTILS_H
-
-/*
- * Copyright (C) 2012 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-char *create_output_path(const char *path_name);
-
-#endif /* RELAYD_UTILS_H */
diff --git a/src/bin/lttng-relayd/utils.hpp b/src/bin/lttng-relayd/utils.hpp
new file mode 100644 (file)
index 0000000..b02a791
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef RELAYD_UTILS_H
+#define RELAYD_UTILS_H
+
+/*
+ * Copyright (C) 2012 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+char *create_output_path(const char *path_name);
+
+#endif /* RELAYD_UTILS_H */
index ac14dbff0cf8fcf3d042775f0d0335febdfb4db5..4529a21fa7c9342f9aa30749dce2dcfd226dcdc0 100644 (file)
@@ -8,15 +8,15 @@
  */
 
 #define _LGPL_SOURCE
-#include <common/common.h>
+#include <common/common.hpp>
 #include <urcu/rculist.h>
 
-#include "lttng-relayd.h"
-#include "ctf-trace.h"
-#include "session.h"
-#include "viewer-session.h"
-#include "viewer-stream.h"
-#include "stream.h"
+#include "lttng-relayd.hpp"
+#include "ctf-trace.hpp"
+#include "session.hpp"
+#include "viewer-session.hpp"
+#include "viewer-stream.hpp"
+#include "stream.hpp"
 
 struct relay_viewer_session *viewer_session_create(void)
 {
diff --git a/src/bin/lttng-relayd/viewer-session.h b/src/bin/lttng-relayd/viewer-session.h
deleted file mode 100644 (file)
index f70daed..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef _VIEWER_SESSION_H
-#define _VIEWER_SESSION_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <urcu/list.h>
-#include <urcu/ref.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/trace-chunk.h>
-
-#include "session.h"
-#include "lttng-viewer-abi.h"
-
-struct relay_viewer_session {
-       /*
-        * Session list. Updates are protected by the session_list_lock.
-        * Traversals are protected by RCU.
-        * This list limits the design to having the sessions in at most
-        * one viewer session.
-        */
-       struct cds_list_head session_list;      /* RCU list. */
-       pthread_mutex_t session_list_lock;      /* Protects list updates. */
-       /*
-        * The viewer session's current trace chunk is initially set, when
-        * a viewer attaches to the viewer session, to a copy the corresponding
-        * relay_session's current trace chunk.
-        *
-        * A live session always attempts to "catch-up" to the newest available
-        * trace chunk. This means that when a viewer reaches the end of a
-        * trace chunk, the viewer session may not transition to the "next" one:
-        * it jumps to the most recent trace chunk available (the one being
-        * produced by the relay_session). Hence, if the producer performs
-        * multiple rotations before a viewer completes the consumption of a
-        * trace chunk, it will skip over those "intermediary" trace chunks.
-        *
-        * A viewer session updates its current trace chunk when:
-        *   1) new viewer streams are created,
-        *   2) a new index is requested,
-        *   3) metadata is requested.
-        *
-        * Hence, as a general principle, the viewer session will reference the
-        * most recent trace chunk available _even if its streams do not point to
-        * it_. It indicates which trace chunk viewer streams should transition
-        * to when the end of their current trace chunk is reached.
-        *
-        * Note that a viewer session's trace chunk points to the session's
-        * output directory. The sub-directories in which the various stream files
-        * are created are considered as being a part of their name.
-        */
-       struct lttng_trace_chunk *current_trace_chunk;
-};
-
-struct relay_viewer_session *viewer_session_create(void);
-void viewer_session_destroy(struct relay_viewer_session *vsession);
-void viewer_session_close(struct relay_viewer_session *vsession);
-
-enum lttng_viewer_attach_return_code viewer_session_attach(
-               struct relay_viewer_session *vsession,
-               struct relay_session *session);
-int viewer_session_is_attached(struct relay_viewer_session *vsession,
-               struct relay_session *session);
-void viewer_session_close_one_session(struct relay_viewer_session *vsession,
-               struct relay_session *session);
-int viewer_session_set_trace_chunk_copy(struct relay_viewer_session *vsession,
-               struct lttng_trace_chunk *relay_session_trace_chunk);
-
-#endif /* _VIEWER_SESSION_H */
diff --git a/src/bin/lttng-relayd/viewer-session.hpp b/src/bin/lttng-relayd/viewer-session.hpp
new file mode 100644 (file)
index 0000000..65ad3e1
--- /dev/null
@@ -0,0 +1,78 @@
+#ifndef _VIEWER_SESSION_H
+#define _VIEWER_SESSION_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <urcu/list.h>
+#include <urcu/ref.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/trace-chunk.hpp>
+
+#include "session.hpp"
+#include "lttng-viewer-abi.hpp"
+
+struct relay_viewer_session {
+       /*
+        * Session list. Updates are protected by the session_list_lock.
+        * Traversals are protected by RCU.
+        * This list limits the design to having the sessions in at most
+        * one viewer session.
+        */
+       struct cds_list_head session_list;      /* RCU list. */
+       pthread_mutex_t session_list_lock;      /* Protects list updates. */
+       /*
+        * The viewer session's current trace chunk is initially set, when
+        * a viewer attaches to the viewer session, to a copy the corresponding
+        * relay_session's current trace chunk.
+        *
+        * A live session always attempts to "catch-up" to the newest available
+        * trace chunk. This means that when a viewer reaches the end of a
+        * trace chunk, the viewer session may not transition to the "next" one:
+        * it jumps to the most recent trace chunk available (the one being
+        * produced by the relay_session). Hence, if the producer performs
+        * multiple rotations before a viewer completes the consumption of a
+        * trace chunk, it will skip over those "intermediary" trace chunks.
+        *
+        * A viewer session updates its current trace chunk when:
+        *   1) new viewer streams are created,
+        *   2) a new index is requested,
+        *   3) metadata is requested.
+        *
+        * Hence, as a general principle, the viewer session will reference the
+        * most recent trace chunk available _even if its streams do not point to
+        * it_. It indicates which trace chunk viewer streams should transition
+        * to when the end of their current trace chunk is reached.
+        *
+        * Note that a viewer session's trace chunk points to the session's
+        * output directory. The sub-directories in which the various stream files
+        * are created are considered as being a part of their name.
+        */
+       struct lttng_trace_chunk *current_trace_chunk;
+};
+
+struct relay_viewer_session *viewer_session_create(void);
+void viewer_session_destroy(struct relay_viewer_session *vsession);
+void viewer_session_close(struct relay_viewer_session *vsession);
+
+enum lttng_viewer_attach_return_code viewer_session_attach(
+               struct relay_viewer_session *vsession,
+               struct relay_session *session);
+int viewer_session_is_attached(struct relay_viewer_session *vsession,
+               struct relay_session *session);
+void viewer_session_close_one_session(struct relay_viewer_session *vsession,
+               struct relay_session *session);
+int viewer_session_set_trace_chunk_copy(struct relay_viewer_session *vsession,
+               struct lttng_trace_chunk *relay_session_trace_chunk);
+
+#endif /* _VIEWER_SESSION_H */
index 69671bd7af4552ae6eb1803654692265a1c30cd3..fa447d45bb20584a75236d9969e0ade9a534d03a 100644 (file)
@@ -8,17 +8,17 @@
  */
 
 #define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/index/index.h>
-#include <common/compat/string.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/index/index.hpp>
+#include <common/compat/string.hpp>
+#include <common/utils.hpp>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <algorithm>
 
-#include "lttng-relayd.h"
-#include "viewer-stream.h"
+#include "lttng-relayd.hpp"
+#include "viewer-stream.hpp"
 
 static void viewer_stream_release_composite_objects(struct relay_viewer_stream *vstream)
 {
diff --git a/src/bin/lttng-relayd/viewer-stream.h b/src/bin/lttng-relayd/viewer-stream.h
deleted file mode 100644 (file)
index e7d733b..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#ifndef _VIEWER_STREAM_H
-#define _VIEWER_STREAM_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <inttypes.h>
-#include <pthread.h>
-
-#include <common/hashtable/hashtable.h>
-
-#include "ctf-trace.h"
-#include "lttng-viewer-abi.h"
-#include "stream.h"
-
-struct relay_stream;
-
-/*
- * The viewer stream's lifetime is the intersection of their viewer connection's
- * lifetime and the duration during which at least:
- * a) their input source is still active
- * b) they still have data left to send to the client.
- *
- * This means that both the sessiond/consumerd connection or the viewer
- * connection may tear down (and unpublish) a relay_viewer_stream.
- *
- * Viewer stream updates are protected by their associated stream's lock.
- */
-struct relay_viewer_stream {
-       struct urcu_ref ref;
-
-       /* Back ref to stream. */
-       struct relay_stream *stream;
-
-       struct {
-               struct fs_handle *handle;
-               struct lttng_trace_chunk *trace_chunk;
-       } stream_file;
-       /* index file from which to read the index data. */
-       struct lttng_index_file *index_file;
-       /*
-        * Last seen rotation count in stream.
-        *
-        * Sampled on every change to the viewer stream trace chunk,
-        * this allows the live server to determine if it saw the latest
-        * rotation that occurred on the receiving end.
-        */
-       uint64_t last_seen_rotation_count;
-
-       char *path_name;
-       char *channel_name;
-
-       uint64_t current_tracefile_id;
-
-       /*
-        * Counts the number of sent indexes. The "tag" associated
-        * with an index to send is the current index_received_seqcount,
-        * because we increment index_received_seqcount after sending
-        * each index. This index_received_seqcount counter can also be
-        * updated when catching up with the producer.
-        */
-       uint64_t index_sent_seqcount;
-
-       /* Indicates if this stream has been sent to a viewer client. */
-       bool sent_flag;
-       /* For metadata stream, how much metadata has been sent. */
-       uint64_t metadata_sent;
-
-       struct lttng_ht_node_u64 stream_n;
-       struct rcu_head rcu_node;
-};
-
-struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream,
-               struct lttng_trace_chunk *viewer_trace_chunk,
-               enum lttng_viewer_seek seek_t);
-
-struct relay_viewer_stream *viewer_stream_get_by_id(uint64_t id);
-bool viewer_stream_get(struct relay_viewer_stream *vstream);
-void viewer_stream_put(struct relay_viewer_stream *vstream);
-int viewer_stream_rotate(struct relay_viewer_stream *vstream);
-bool viewer_stream_is_tracefile_seq_readable(struct relay_viewer_stream *vstream,
-               uint64_t seq);
-void print_viewer_streams(void);
-void viewer_stream_close_files(struct relay_viewer_stream *vstream);
-void viewer_stream_sync_tracefile_array_tail(struct relay_viewer_stream *vstream);
-
-#endif /* _VIEWER_STREAM_H */
diff --git a/src/bin/lttng-relayd/viewer-stream.hpp b/src/bin/lttng-relayd/viewer-stream.hpp
new file mode 100644 (file)
index 0000000..42bdc1e
--- /dev/null
@@ -0,0 +1,94 @@
+#ifndef _VIEWER_STREAM_H
+#define _VIEWER_STREAM_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <inttypes.h>
+#include <pthread.h>
+
+#include <common/hashtable/hashtable.hpp>
+
+#include "ctf-trace.hpp"
+#include "lttng-viewer-abi.hpp"
+#include "stream.hpp"
+
+struct relay_stream;
+
+/*
+ * The viewer stream's lifetime is the intersection of their viewer connection's
+ * lifetime and the duration during which at least:
+ * a) their input source is still active
+ * b) they still have data left to send to the client.
+ *
+ * This means that both the sessiond/consumerd connection or the viewer
+ * connection may tear down (and unpublish) a relay_viewer_stream.
+ *
+ * Viewer stream updates are protected by their associated stream's lock.
+ */
+struct relay_viewer_stream {
+       struct urcu_ref ref;
+
+       /* Back ref to stream. */
+       struct relay_stream *stream;
+
+       struct {
+               struct fs_handle *handle;
+               struct lttng_trace_chunk *trace_chunk;
+       } stream_file;
+       /* index file from which to read the index data. */
+       struct lttng_index_file *index_file;
+       /*
+        * Last seen rotation count in stream.
+        *
+        * Sampled on every change to the viewer stream trace chunk,
+        * this allows the live server to determine if it saw the latest
+        * rotation that occurred on the receiving end.
+        */
+       uint64_t last_seen_rotation_count;
+
+       char *path_name;
+       char *channel_name;
+
+       uint64_t current_tracefile_id;
+
+       /*
+        * Counts the number of sent indexes. The "tag" associated
+        * with an index to send is the current index_received_seqcount,
+        * because we increment index_received_seqcount after sending
+        * each index. This index_received_seqcount counter can also be
+        * updated when catching up with the producer.
+        */
+       uint64_t index_sent_seqcount;
+
+       /* Indicates if this stream has been sent to a viewer client. */
+       bool sent_flag;
+       /* For metadata stream, how much metadata has been sent. */
+       uint64_t metadata_sent;
+
+       struct lttng_ht_node_u64 stream_n;
+       struct rcu_head rcu_node;
+};
+
+struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream,
+               struct lttng_trace_chunk *viewer_trace_chunk,
+               enum lttng_viewer_seek seek_t);
+
+struct relay_viewer_stream *viewer_stream_get_by_id(uint64_t id);
+bool viewer_stream_get(struct relay_viewer_stream *vstream);
+void viewer_stream_put(struct relay_viewer_stream *vstream);
+int viewer_stream_rotate(struct relay_viewer_stream *vstream);
+bool viewer_stream_is_tracefile_seq_readable(struct relay_viewer_stream *vstream,
+               uint64_t seq);
+void print_viewer_streams(void);
+void viewer_stream_close_files(struct relay_viewer_stream *vstream);
+void viewer_stream_sync_tracefile_array_tail(struct relay_viewer_stream *vstream);
+
+#endif /* _VIEWER_STREAM_H */
index 96a20a4dda4bcc8f9de4a88ae5a44540e6e7a5ad..13fdb714ed069f724f282b383cad2598d5bba010 100644 (file)
@@ -9,61 +9,61 @@ endif
 
 noinst_LTLIBRARIES = liblttng-sessiond-common.la
 
-liblttng_sessiond_common_la_SOURCES = utils.cpp utils.h \
-                       trace-kernel.cpp trace-kernel.h \
-                       kernel.cpp kernel.h \
-                       ust-app.h ust-sigbus.h trace-ust.h notify-apps.h \
-                       lttng-ust-ctl.h lttng-ust-abi.h lttng-ust-error.h \
-                       ust-ctl-internal.h ust-abi-internal.h ust-error-internal.h \
-                       ust-registry.h \
-                       condition-internal.cpp condition-internal.h \
-                       context.cpp context.h \
-                       channel.cpp channel.h \
-                       event.cpp event.h \
-                       consumer.cpp consumer.h \
-                       session.cpp session.h \
-                       modprobe.cpp modprobe.h kern-modules.h \
-                       fd-limit.cpp fd-limit.h \
-                       kernel-consumer.cpp kernel-consumer.h \
-                       consumer.h \
-                       health-sessiond.h \
-                       cmd.cpp cmd.h \
-                       buffer-registry.cpp buffer-registry.h \
-                       testpoint.h \
-                       snapshot.cpp snapshot.h \
-                       agent.cpp agent.h \
-                       save.h save.cpp \
-                       lttng-syscall.h lttng-syscall.cpp \
-                       notification-thread.h notification-thread.cpp \
-                       notification-thread-internal.h \
-                       notification-thread-commands.h notification-thread-commands.cpp \
-                       notification-thread-events.h notification-thread-events.cpp \
-                       sessiond-config.h sessiond-config.cpp \
-                       rotate.h rotate.cpp \
-                       rotation-thread.h rotation-thread.cpp \
-                       timer.cpp timer.h \
+liblttng_sessiond_common_la_SOURCES = utils.cpp utils.hpp \
+                       trace-kernel.cpp trace-kernel.hpp \
+                       kernel.cpp kernel.hpp \
+                       ust-app.hpp ust-sigbus.hpp trace-ust.hpp notify-apps.hpp \
+                       lttng-ust-ctl.hpp lttng-ust-abi.hpp lttng-ust-error.hpp \
+                       ust-ctl-internal.hpp ust-abi-internal.hpp ust-error-internal.hpp \
+                       ust-registry.hpp \
+                       condition-internal.cpp condition-internal.hpp \
+                       context.cpp context.hpp \
+                       channel.cpp channel.hpp \
+                       event.cpp event.hpp \
+                       consumer.cpp consumer.hpp \
+                       session.cpp session.hpp \
+                       modprobe.cpp modprobe.hpp kern-modules.hpp \
+                       fd-limit.cpp fd-limit.hpp \
+                       kernel-consumer.cpp kernel-consumer.hpp \
+                       consumer.hpp \
+                       health-sessiond.hpp \
+                       cmd.cpp cmd.hpp \
+                       buffer-registry.cpp buffer-registry.hpp \
+                       testpoint.hpp \
+                       snapshot.cpp snapshot.hpp \
+                       agent.cpp agent.hpp \
+                       save.hpp save.cpp \
+                       lttng-syscall.hpp lttng-syscall.cpp \
+                       notification-thread.hpp notification-thread.cpp \
+                       notification-thread-internal.hpp \
+                       notification-thread-commands.hpp notification-thread-commands.cpp \
+                       notification-thread-events.hpp notification-thread-events.cpp \
+                       sessiond-config.hpp sessiond-config.cpp \
+                       rotate.hpp rotate.cpp \
+                       rotation-thread.hpp rotation-thread.cpp \
+                       timer.cpp timer.hpp \
                        globals.cpp \
                        thread-utils.cpp \
                        process-utils.cpp \
-                       thread.cpp thread.h \
+                       thread.cpp thread.hpp \
                        health.cpp \
-                       client.cpp client.h \
-                       dispatch.cpp dispatch.h \
-                       register.cpp register.h \
-                       manage-apps.cpp manage-apps.h \
-                       manage-kernel.cpp manage-kernel.h \
-                       manage-consumer.cpp manage-consumer.h \
-                       clear.cpp clear.h \
-                       tracker.cpp tracker.h \
-                       event-notifier-error-accounting.cpp event-notifier-error-accounting.h \
-                       action-executor.cpp action-executor.h\
+                       client.cpp client.hpp \
+                       dispatch.cpp dispatch.hpp \
+                       register.cpp register.hpp \
+                       manage-apps.cpp manage-apps.hpp \
+                       manage-kernel.cpp manage-kernel.hpp \
+                       manage-consumer.cpp manage-consumer.hpp \
+                       clear.cpp clear.hpp \
+                       tracker.cpp tracker.hpp \
+                       event-notifier-error-accounting.cpp event-notifier-error-accounting.hpp \
+                       action-executor.cpp action-executor.hpp\
                        trigger-error-query.cpp
 
 if HAVE_LIBLTTNG_UST_CTL
 liblttng_sessiond_common_la_SOURCES += trace-ust.cpp ust-registry.cpp ust-app.cpp \
-                       ust-consumer.cpp ust-consumer.h notify-apps.cpp \
-                       ust-metadata.cpp ust-clock.h agent-thread.cpp agent-thread.h \
-                       ust-field-utils.h ust-field-utils.cpp \
+                       ust-consumer.cpp ust-consumer.hpp notify-apps.cpp \
+                       ust-metadata.cpp ust-clock.hpp agent-thread.cpp agent-thread.hpp \
+                       ust-field-utils.hpp ust-field-utils.cpp \
                        ust-sigbus.cpp
 endif
 
@@ -87,7 +87,7 @@ endif
 
 bin_PROGRAMS = lttng-sessiond
 
-lttng_sessiond_SOURCES = lttng-sessiond.h main.cpp
+lttng_sessiond_SOURCES = lttng-sessiond.hpp main.cpp
 
 lttng_sessiond_LDFLAGS = -rdynamic
 
index e2eeed45115cfb36583a9615fa9bd3ba767ce187..f43716c63986673377890c8a635f25c149a4f7d7 100644 (file)
@@ -5,29 +5,29 @@
  *
  */
 
-#include "action-executor.h"
-#include "cmd.h"
-#include "health-sessiond.h"
-#include "lttng-sessiond.h"
-#include "notification-thread-internal.h"
-#include "session.h"
-#include "thread.h"
-#include <common/dynamic-array.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/list-internal.h>
+#include "action-executor.hpp"
+#include "cmd.hpp"
+#include "health-sessiond.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-internal.hpp"
+#include "session.hpp"
+#include "thread.hpp"
+#include <common/dynamic-array.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/list-internal.hpp>
 #include <lttng/action/list.h>
-#include <lttng/action/notify-internal.h>
+#include <lttng/action/notify-internal.hpp>
 #include <lttng/action/notify.h>
 #include <lttng/action/rotate-session.h>
 #include <lttng/action/snapshot-session.h>
 #include <lttng/action/start-session.h>
 #include <lttng/action/stop-session.h>
 #include <lttng/condition/evaluation.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/event-rule-matches-internal.hpp>
 #include <lttng/lttng-error.h>
-#include <lttng/trigger/trigger-internal.h>
+#include <lttng/trigger/trigger-internal.hpp>
 #include <pthread.h>
 #include <stdbool.h>
 #include <stddef.h>
diff --git a/src/bin/lttng-sessiond/action-executor.h b/src/bin/lttng-sessiond/action-executor.h
deleted file mode 100644 (file)
index 85d5931..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef ACTION_EXECUTOR_H
-#define ACTION_EXECUTOR_H
-
-struct action_executor;
-struct notification_thread_handle;
-struct lttng_evaluation;
-struct lttng_trigger;
-struct notification_client_list;
-struct lttng_credentials;
-
-enum action_executor_status {
-       ACTION_EXECUTOR_STATUS_OK,
-       ACTION_EXECUTOR_STATUS_OVERFLOW,
-       ACTION_EXECUTOR_STATUS_ERROR,
-       ACTION_EXECUTOR_STATUS_INVALID,
-};
-
-struct action_executor *action_executor_create(
-               struct notification_thread_handle *handle);
-
-void action_executor_destroy(struct action_executor *executor);
-
-/*
- * Enqueue a job on an action executor's work queue to perform the actions
- * associated with a trigger.
- *
- * A reference to `trigger` is acquired.
- * A reference to `list` is acquired.
- *
- * This function assumes the ownership of the `evaluation` both on success and
- * failure: the caller should no longer access it once the function returns.
- */
-enum action_executor_status action_executor_enqueue_trigger(
-               struct action_executor *executor,
-               struct lttng_trigger *trigger,
-               struct lttng_evaluation *evaluation,
-               const struct lttng_credentials *object_creds,
-               struct notification_client_list *list);
-
-#endif /* ACTION_EXECUTOR_H */
diff --git a/src/bin/lttng-sessiond/action-executor.hpp b/src/bin/lttng-sessiond/action-executor.hpp
new file mode 100644 (file)
index 0000000..85d5931
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef ACTION_EXECUTOR_H
+#define ACTION_EXECUTOR_H
+
+struct action_executor;
+struct notification_thread_handle;
+struct lttng_evaluation;
+struct lttng_trigger;
+struct notification_client_list;
+struct lttng_credentials;
+
+enum action_executor_status {
+       ACTION_EXECUTOR_STATUS_OK,
+       ACTION_EXECUTOR_STATUS_OVERFLOW,
+       ACTION_EXECUTOR_STATUS_ERROR,
+       ACTION_EXECUTOR_STATUS_INVALID,
+};
+
+struct action_executor *action_executor_create(
+               struct notification_thread_handle *handle);
+
+void action_executor_destroy(struct action_executor *executor);
+
+/*
+ * Enqueue a job on an action executor's work queue to perform the actions
+ * associated with a trigger.
+ *
+ * A reference to `trigger` is acquired.
+ * A reference to `list` is acquired.
+ *
+ * This function assumes the ownership of the `evaluation` both on success and
+ * failure: the caller should no longer access it once the function returns.
+ */
+enum action_executor_status action_executor_enqueue_trigger(
+               struct action_executor *executor,
+               struct lttng_trigger *trigger,
+               struct lttng_evaluation *evaluation,
+               const struct lttng_credentials *object_creds,
+               struct notification_client_list *list);
+
+#endif /* ACTION_EXECUTOR_H */
index 5e158b49bea408d2c161121f90eed7fbe4294359..77470b3ee1a25446a9a8f23e2be3c9f4f4a7e134 100644 (file)
@@ -7,20 +7,20 @@
 
 #define _LGPL_SOURCE
 
-#include <common/common.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-#include <common/utils.h>
-
-#include <common/compat/endian.h>
-
-#include "fd-limit.h"
-#include "agent-thread.h"
-#include "agent.h"
-#include "lttng-sessiond.h"
-#include "session.h"
-#include "utils.h"
-#include "thread.h"
+#include <common/common.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+
+#include <common/compat/endian.hpp>
+
+#include "fd-limit.hpp"
+#include "agent-thread.hpp"
+#include "agent.hpp"
+#include "lttng-sessiond.hpp"
+#include "session.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
 
 struct thread_notifiers {
        struct lttng_pipe *quit_pipe;
diff --git a/src/bin/lttng-sessiond/agent-thread.h b/src/bin/lttng-sessiond/agent-thread.h
deleted file mode 100644 (file)
index d84ea61..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <stdbool.h>
-
-#ifndef LTTNG_SESSIOND_AGENT_THREAD_H
-#define LTTNG_SESSIOND_AGENT_THREAD_H
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-bool launch_agent_management_thread(void);
-bool agent_tracing_is_enabled(void);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline
-bool launch_agent_management_thread(void)
-{
-       return true;
-}
-
-static inline
-bool agent_tracing_is_enabled(void)
-{
-       return false;
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* LTTNG_SESSIOND_AGENT_THREAD_H */
diff --git a/src/bin/lttng-sessiond/agent-thread.hpp b/src/bin/lttng-sessiond/agent-thread.hpp
new file mode 100644 (file)
index 0000000..d84ea61
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <stdbool.h>
+
+#ifndef LTTNG_SESSIOND_AGENT_THREAD_H
+#define LTTNG_SESSIOND_AGENT_THREAD_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+bool launch_agent_management_thread(void);
+bool agent_tracing_is_enabled(void);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+bool launch_agent_management_thread(void)
+{
+       return true;
+}
+
+static inline
+bool agent_tracing_is_enabled(void)
+{
+       return false;
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_SESSIOND_AGENT_THREAD_H */
index b0ac94b1300a11e98fc83683028c149887419d56..ed8a8d12607aad0c2e7d45fd43485f11071de0ba 100644 (file)
 #include <urcu/rculist.h>
 
 #include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
 #include <lttng/event-rule/jul-logging.h>
 #include <lttng/event-rule/log4j-logging.h>
 #include <lttng/event-rule/python-logging.h>
 #include <lttng/condition/condition.h>
 #include <lttng/condition/event-rule-matches.h>
-#include <lttng/domain-internal.h>
-#include <lttng/log-level-rule-internal.h>
+#include <lttng/domain-internal.hpp>
+#include <lttng/log-level-rule-internal.hpp>
 
-#include <common/common.h>
-#include <common/sessiond-comm/agent.h>
+#include <common/common.hpp>
+#include <common/sessiond-comm/agent.hpp>
 
-#include <common/compat/endian.h>
+#include <common/compat/endian.hpp>
 
-#include "agent.h"
-#include "ust-app.h"
-#include "utils.h"
-#include "common/error.h"
+#include "agent.hpp"
+#include "ust-app.hpp"
+#include "utils.hpp"
+#include "common/error.hpp"
 
 typedef enum lttng_event_rule_status (*event_rule_logging_get_name_pattern)(
                const struct lttng_event_rule *rule, const char **pattern);
diff --git a/src/bin/lttng-sessiond/agent.h b/src/bin/lttng-sessiond/agent.h
deleted file mode 100644 (file)
index b0a4fa8..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_SESSIOND_AGENT_H
-#define LTTNG_SESSIOND_AGENT_H
-
-#include <inttypes.h>
-
-#include <common/hashtable/hashtable.h>
-#include <lttng/lttng.h>
-
-/* Agent protocol version that is verified during the agent registration. */
-#define AGENT_MAJOR_VERSION            2
-#define AGENT_MINOR_VERSION            0
-
-/*
- * Hash table that contains the agent app created upon registration indexed by
- * socket. Global to the session daemon.
- */
-extern struct lttng_ht *the_agent_apps_ht_by_sock;
-
-/*
- * Hash table that contains the trigger agents by domain */
-extern struct lttng_ht *the_trigger_agents_ht_by_domain;
-
-struct agent_ht_key {
-       const char *name;
-       int loglevel_value;
-       enum lttng_loglevel_type loglevel_type;
-       const char *filter_expression;
-};
-
-/*
- * Registration message payload from an agent application. The PID is used to
- * find back the corresponding UST app object so both socket can be linked.
- */
-struct agent_register_msg {
-       /* This maps to a lttng_domain_type. */
-       uint32_t domain;
-       uint32_t pid;
-       uint32_t major_version;
-       uint32_t minor_version;
-};
-
-/*
- * Agent application object created after a successful registration. This
- * object is linked to its associated UST app by their PID through hash table
- * lookups.
- */
-struct agent_app {
-       /*
-        * PID sent during registration of an agent application.
-        */
-       pid_t pid;
-
-       /* Domain of the application. */
-       enum lttng_domain_type domain;
-
-       /*
-        * AGENT TCP socket that was created upon registration.
-        */
-       struct lttcomm_sock *sock;
-
-       /* Initialized with the AGENT sock value. */
-       struct lttng_ht_node_ulong node;
-};
-
-/*
- * Agent event representation.
- * Accesses to this structure are protected by the session list lock.
- */
-struct agent_event {
-       /* Name of the event. */
-       char name[LTTNG_SYMBOL_NAME_LEN];
-       int loglevel_value;
-       enum lttng_loglevel_type loglevel_type;
-
-       /*
-        * Tells if the event is enabled or not on the agent. While this can be
-        * implicitly tested as a boolean, it is in fact a reference count and
-        * the AGENT_EVENT_IS_ENABLED macro should be used to prevent accidental
-        * comparisons to non-zero literals (e.g. '1').
-        *
-        * Multiple triggers and events can map to the same agent event as it
-        * is merely a "filter" in front of a user space tracer enabler.
-        *
-        * This count is updated to ensure an event is only disabled when all
-        * matching enablers are disabled.
-        */
-       unsigned int enabled_count;
-
-       /* Hash table node of the agent domain object. */
-       struct lttng_ht_node_str node;
-
-       /* Filter associated with the event. NULL if none. */
-       struct lttng_bytecode *filter;
-       char *filter_expression;
-       struct lttng_event_exclusion *exclusion;
-};
-
-#define AGENT_EVENT_IS_ENABLED(agent_event) (!!agent_event->enabled_count)
-
-/*
- * Agent object containing events enabled/disabled for a given domain in a
- * scope. The scope is typically a session, but can also be "global" in the
- * context of event notifiers: see event_notifiers_find_agent().
- */
-struct agent {
-       /*
-        * This indicates if that domain is being used meaning if at least one
-        * event has been at some point in time added to it. This is used so when
-        * listing domains for a session, we can tell or not if the agent is
-        * actually enabled.
-        */
-       unsigned int being_used:1;
-
-       /* What domain this agent is. */
-       enum lttng_domain_type domain;
-
-       /* Contains event indexed by name. */
-       struct lttng_ht *events;
-
-       /* Application context list (struct agent_app_ctx). */
-       struct cds_list_head app_ctx_list;
-
-       /* Node used for the hash table indexed by domain type. */
-       struct lttng_ht_node_u64 node;
-};
-
-/* Allocate agent apps hash table */
-int agent_app_ht_alloc(void);
-/* Clean-up agent apps hash table */
-void agent_app_ht_clean(void);
-
-/* Initialize an already allocated agent domain. */
-int agent_init(struct agent *agt);
-struct agent *agent_create(enum lttng_domain_type domain);
-void agent_destroy(struct agent *agt);
-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_bytecode *filter,
-               char *filter_expression);
-void agent_add_event(struct agent_event *event, struct agent *agt);
-
-struct agent_event *agent_find_event(const char *name,
-               enum lttng_loglevel_type loglevel_type,
-               int loglevel_value,
-               const char *filter_expression,
-               struct agent *agt);
-void agent_find_events_by_name(const char *name, struct agent *agt,
-               struct lttng_ht_iter* iter);
-void agent_event_next_duplicate(const char *name,
-               struct agent *agt, struct lttng_ht_iter* iter);
-void agent_delete_event(struct agent_event *event, struct agent *agt);
-void agent_destroy_event(struct agent_event *event);
-
-/* Agent context API.*/
-int agent_enable_context(const struct lttng_event_context *ctx,
-               enum lttng_domain_type domain);
-int agent_add_context(const struct lttng_event_context *ctx,
-               struct agent *agt);
-
-/* Agent app API. */
-struct agent_app *agent_create_app(pid_t pid, enum lttng_domain_type domain,
-               struct lttcomm_sock *sock);
-void agent_add_app(struct agent_app *app);
-void agent_delete_app(struct agent_app *app);
-struct agent_app *agent_find_app_by_sock(int sock);
-void agent_destroy_app(struct agent_app *app);
-void agent_destroy_app_by_sock(int sock);
-int agent_send_registration_done(struct agent_app *app);
-
-/* Agent action API */
-int agent_enable_event(struct agent_event *event,
-               enum lttng_domain_type domain);
-int agent_disable_event(struct agent_event *event,
-               enum lttng_domain_type domain);
-void agent_update(const struct agent *agt, const struct agent_app *app);
-int agent_list_events(struct lttng_event **events,
-               enum lttng_domain_type domain);
-
-struct agent_event *agent_find_event_by_trigger(
-               const struct lttng_trigger *trigger, struct agent *agt);
-
-/* Global event notifier per-domain agents. */
-struct agent *agent_find_by_event_notifier_domain(
-               enum lttng_domain_type domain_type);
-void agent_by_event_notifier_domain_ht_destroy(void);
-int agent_by_event_notifier_domain_ht_create(void);
-
-#endif /* LTTNG_SESSIOND_AGENT_H */
diff --git a/src/bin/lttng-sessiond/agent.hpp b/src/bin/lttng-sessiond/agent.hpp
new file mode 100644 (file)
index 0000000..2ad42c3
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_SESSIOND_AGENT_H
+#define LTTNG_SESSIOND_AGENT_H
+
+#include <inttypes.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <lttng/lttng.h>
+
+/* Agent protocol version that is verified during the agent registration. */
+#define AGENT_MAJOR_VERSION            2
+#define AGENT_MINOR_VERSION            0
+
+/*
+ * Hash table that contains the agent app created upon registration indexed by
+ * socket. Global to the session daemon.
+ */
+extern struct lttng_ht *the_agent_apps_ht_by_sock;
+
+/*
+ * Hash table that contains the trigger agents by domain */
+extern struct lttng_ht *the_trigger_agents_ht_by_domain;
+
+struct agent_ht_key {
+       const char *name;
+       int loglevel_value;
+       enum lttng_loglevel_type loglevel_type;
+       const char *filter_expression;
+};
+
+/*
+ * Registration message payload from an agent application. The PID is used to
+ * find back the corresponding UST app object so both socket can be linked.
+ */
+struct agent_register_msg {
+       /* This maps to a lttng_domain_type. */
+       uint32_t domain;
+       uint32_t pid;
+       uint32_t major_version;
+       uint32_t minor_version;
+};
+
+/*
+ * Agent application object created after a successful registration. This
+ * object is linked to its associated UST app by their PID through hash table
+ * lookups.
+ */
+struct agent_app {
+       /*
+        * PID sent during registration of an agent application.
+        */
+       pid_t pid;
+
+       /* Domain of the application. */
+       enum lttng_domain_type domain;
+
+       /*
+        * AGENT TCP socket that was created upon registration.
+        */
+       struct lttcomm_sock *sock;
+
+       /* Initialized with the AGENT sock value. */
+       struct lttng_ht_node_ulong node;
+};
+
+/*
+ * Agent event representation.
+ * Accesses to this structure are protected by the session list lock.
+ */
+struct agent_event {
+       /* Name of the event. */
+       char name[LTTNG_SYMBOL_NAME_LEN];
+       int loglevel_value;
+       enum lttng_loglevel_type loglevel_type;
+
+       /*
+        * Tells if the event is enabled or not on the agent. While this can be
+        * implicitly tested as a boolean, it is in fact a reference count and
+        * the AGENT_EVENT_IS_ENABLED macro should be used to prevent accidental
+        * comparisons to non-zero literals (e.g. '1').
+        *
+        * Multiple triggers and events can map to the same agent event as it
+        * is merely a "filter" in front of a user space tracer enabler.
+        *
+        * This count is updated to ensure an event is only disabled when all
+        * matching enablers are disabled.
+        */
+       unsigned int enabled_count;
+
+       /* Hash table node of the agent domain object. */
+       struct lttng_ht_node_str node;
+
+       /* Filter associated with the event. NULL if none. */
+       struct lttng_bytecode *filter;
+       char *filter_expression;
+       struct lttng_event_exclusion *exclusion;
+};
+
+#define AGENT_EVENT_IS_ENABLED(agent_event) (!!agent_event->enabled_count)
+
+/*
+ * Agent object containing events enabled/disabled for a given domain in a
+ * scope. The scope is typically a session, but can also be "global" in the
+ * context of event notifiers: see event_notifiers_find_agent().
+ */
+struct agent {
+       /*
+        * This indicates if that domain is being used meaning if at least one
+        * event has been at some point in time added to it. This is used so when
+        * listing domains for a session, we can tell or not if the agent is
+        * actually enabled.
+        */
+       unsigned int being_used:1;
+
+       /* What domain this agent is. */
+       enum lttng_domain_type domain;
+
+       /* Contains event indexed by name. */
+       struct lttng_ht *events;
+
+       /* Application context list (struct agent_app_ctx). */
+       struct cds_list_head app_ctx_list;
+
+       /* Node used for the hash table indexed by domain type. */
+       struct lttng_ht_node_u64 node;
+};
+
+/* Allocate agent apps hash table */
+int agent_app_ht_alloc(void);
+/* Clean-up agent apps hash table */
+void agent_app_ht_clean(void);
+
+/* Initialize an already allocated agent domain. */
+int agent_init(struct agent *agt);
+struct agent *agent_create(enum lttng_domain_type domain);
+void agent_destroy(struct agent *agt);
+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_bytecode *filter,
+               char *filter_expression);
+void agent_add_event(struct agent_event *event, struct agent *agt);
+
+struct agent_event *agent_find_event(const char *name,
+               enum lttng_loglevel_type loglevel_type,
+               int loglevel_value,
+               const char *filter_expression,
+               struct agent *agt);
+void agent_find_events_by_name(const char *name, struct agent *agt,
+               struct lttng_ht_iter* iter);
+void agent_event_next_duplicate(const char *name,
+               struct agent *agt, struct lttng_ht_iter* iter);
+void agent_delete_event(struct agent_event *event, struct agent *agt);
+void agent_destroy_event(struct agent_event *event);
+
+/* Agent context API.*/
+int agent_enable_context(const struct lttng_event_context *ctx,
+               enum lttng_domain_type domain);
+int agent_add_context(const struct lttng_event_context *ctx,
+               struct agent *agt);
+
+/* Agent app API. */
+struct agent_app *agent_create_app(pid_t pid, enum lttng_domain_type domain,
+               struct lttcomm_sock *sock);
+void agent_add_app(struct agent_app *app);
+void agent_delete_app(struct agent_app *app);
+struct agent_app *agent_find_app_by_sock(int sock);
+void agent_destroy_app(struct agent_app *app);
+void agent_destroy_app_by_sock(int sock);
+int agent_send_registration_done(struct agent_app *app);
+
+/* Agent action API */
+int agent_enable_event(struct agent_event *event,
+               enum lttng_domain_type domain);
+int agent_disable_event(struct agent_event *event,
+               enum lttng_domain_type domain);
+void agent_update(const struct agent *agt, const struct agent_app *app);
+int agent_list_events(struct lttng_event **events,
+               enum lttng_domain_type domain);
+
+struct agent_event *agent_find_event_by_trigger(
+               const struct lttng_trigger *trigger, struct agent *agt);
+
+/* Global event notifier per-domain agents. */
+struct agent *agent_find_by_event_notifier_domain(
+               enum lttng_domain_type domain_type);
+void agent_by_event_notifier_domain_ht_destroy(void);
+int agent_by_event_notifier_domain_ht_create(void);
+
+#endif /* LTTNG_SESSIOND_AGENT_H */
index 64e98333ffb6549cb2ffc5ca849a4d598b8780f4..ca7830a384d8dcca29537fc4e0c724f4216f9f7d 100644 (file)
@@ -8,15 +8,15 @@
 #define _LGPL_SOURCE
 #include <inttypes.h>
 
-#include <common/common.h>
-#include <common/hashtable/utils.h>
-
-#include "buffer-registry.h"
-#include "fd-limit.h"
-#include "ust-consumer.h"
-#include "lttng-ust-ctl.h"
-#include "lttng-ust-error.h"
-#include "utils.h"
+#include <common/common.hpp>
+#include <common/hashtable/utils.hpp>
+
+#include "buffer-registry.hpp"
+#include "fd-limit.hpp"
+#include "ust-consumer.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "lttng-ust-error.hpp"
+#include "utils.hpp"
 
 /*
  * Set in main.c during initialization process of the daemon. This contains
diff --git a/src/bin/lttng-sessiond/buffer-registry.h b/src/bin/lttng-sessiond/buffer-registry.h
deleted file mode 100644 (file)
index 440493d..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_BUFFER_REGISTRY_H
-#define LTTNG_BUFFER_REGISTRY_H
-
-#include <stdint.h>
-#include <urcu/list.h>
-
-#include <lttng/lttng.h>
-#include <common/hashtable/hashtable.h>
-
-#include "consumer.h"
-#include "lttng-ust-ctl.h"
-#include "ust-registry.h"
-
-struct buffer_reg_stream {
-       struct cds_list_head lnode;
-       union {
-               /* Original object data that MUST be copied over. */
-               struct lttng_ust_abi_object_data *ust;
-       } obj;
-};
-
-struct buffer_reg_channel {
-       /* This key is the same as a tracing channel key. */
-       uint32_t key;
-       /* Key of the channel on the consumer side. */
-       uint64_t consumer_key;
-       /* Stream registry object of this channel registry. */
-       struct cds_list_head streams;
-       /* Total number of stream in the list. */
-       uint64_t stream_count;
-       /* Used to ensure mutual exclusion to the stream's list. */
-       pthread_mutex_t stream_list_lock;
-       /* Node for hash table usage. */
-       struct lttng_ht_node_u64 node;
-       /* Size of subbuffers in this channel. */
-       size_t subbuf_size;
-       /* Number of subbuffers per stream. */
-       size_t num_subbuf;
-       union {
-               /* Original object data that MUST be copied over. */
-               struct lttng_ust_abi_object_data *ust;
-       } obj;
-};
-
-struct buffer_reg_session {
-       /* Registry per domain. */
-       union {
-               struct ust_registry_session *ust;
-       } reg;
-
-       /* Contains buffer registry channel indexed by tracing channel key. */
-       struct lttng_ht *channels;
-};
-
-/*
- * Registry object for per UID buffers.
- */
-struct buffer_reg_uid {
-       /*
-        * Keys to match this object in a hash table. The following three variables
-        * identify a unique per UID buffer registry.
-        */
-       uint64_t session_id;    /* Unique tracing session id. */
-       int bits_per_long;      /* ABI */
-       uid_t uid;                      /* Owner. */
-
-       enum lttng_domain_type domain;
-       struct buffer_reg_session *registry;
-
-       /* Indexed by session id. */
-       struct lttng_ht_node_u64 node;
-       /* Node of a linked list used to teardown object at a destroy session. */
-       struct cds_list_head lnode;
-
-       char root_shm_path[PATH_MAX];
-       char shm_path[PATH_MAX];
-};
-
-/*
- * Registry object for per PID buffers.
- */
-struct buffer_reg_pid {
-       uint64_t session_id;
-
-       struct buffer_reg_session *registry;
-
-       /* Indexed by session id. */
-       struct lttng_ht_node_u64 node;
-
-       char root_shm_path[PATH_MAX];
-       char shm_path[PATH_MAX];
-};
-
-/* Buffer registry per UID. */
-void buffer_reg_init_uid_registry(void);
-int buffer_reg_uid_create(uint64_t session_id, uint32_t bits_per_long, uid_t uid,
-               enum lttng_domain_type domain, struct buffer_reg_uid **regp,
-               const char *root_shm_path, const char *shm_path);
-void buffer_reg_uid_add(struct buffer_reg_uid *reg);
-struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id,
-               uint32_t bits_per_long, uid_t uid);
-void buffer_reg_uid_remove(struct buffer_reg_uid *regp);
-void buffer_reg_uid_destroy(struct buffer_reg_uid *regp,
-               struct consumer_output *consumer);
-
-/* Buffer registry per PID. */
-void buffer_reg_init_pid_registry(void);
-int buffer_reg_pid_create(uint64_t session_id, struct buffer_reg_pid **regp,
-               const char *root_shm_path, const char *shm_path);
-void buffer_reg_pid_add(struct buffer_reg_pid *reg);
-struct buffer_reg_pid *buffer_reg_pid_find(uint64_t session_id);
-void buffer_reg_pid_remove(struct buffer_reg_pid *regp);
-void buffer_reg_pid_destroy(struct buffer_reg_pid *regp);
-
-/* Channel */
-int buffer_reg_channel_create(uint64_t key, struct buffer_reg_channel **regp);
-void buffer_reg_channel_add(struct buffer_reg_session *session,
-               struct buffer_reg_channel *channel);
-struct buffer_reg_channel *buffer_reg_channel_find(uint64_t key,
-               struct buffer_reg_uid *reg);
-void buffer_reg_channel_remove(struct buffer_reg_session *session,
-               struct buffer_reg_channel *regp);
-void buffer_reg_channel_destroy(struct buffer_reg_channel *regp,
-               enum lttng_domain_type domain);
-
-/* Stream */
-int buffer_reg_stream_create(struct buffer_reg_stream **regp);
-void buffer_reg_stream_add(struct buffer_reg_stream *stream,
-               struct buffer_reg_channel *channel);
-void buffer_reg_stream_destroy(struct buffer_reg_stream *regp,
-               enum lttng_domain_type domain);
-
-/* Global registry. */
-void buffer_reg_destroy_registries(void);
-
-int buffer_reg_uid_consumer_channel_key(
-               struct cds_list_head *buffer_reg_uid_list,
-               uint64_t chan_key, uint64_t *consumer_chan_key);
-
-#endif /* LTTNG_BUFFER_REGISTRY_H */
diff --git a/src/bin/lttng-sessiond/buffer-registry.hpp b/src/bin/lttng-sessiond/buffer-registry.hpp
new file mode 100644 (file)
index 0000000..a06be60
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_BUFFER_REGISTRY_H
+#define LTTNG_BUFFER_REGISTRY_H
+
+#include <stdint.h>
+#include <urcu/list.h>
+
+#include <lttng/lttng.h>
+#include <common/hashtable/hashtable.hpp>
+
+#include "consumer.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "ust-registry.hpp"
+
+struct buffer_reg_stream {
+       struct cds_list_head lnode;
+       union {
+               /* Original object data that MUST be copied over. */
+               struct lttng_ust_abi_object_data *ust;
+       } obj;
+};
+
+struct buffer_reg_channel {
+       /* This key is the same as a tracing channel key. */
+       uint32_t key;
+       /* Key of the channel on the consumer side. */
+       uint64_t consumer_key;
+       /* Stream registry object of this channel registry. */
+       struct cds_list_head streams;
+       /* Total number of stream in the list. */
+       uint64_t stream_count;
+       /* Used to ensure mutual exclusion to the stream's list. */
+       pthread_mutex_t stream_list_lock;
+       /* Node for hash table usage. */
+       struct lttng_ht_node_u64 node;
+       /* Size of subbuffers in this channel. */
+       size_t subbuf_size;
+       /* Number of subbuffers per stream. */
+       size_t num_subbuf;
+       union {
+               /* Original object data that MUST be copied over. */
+               struct lttng_ust_abi_object_data *ust;
+       } obj;
+};
+
+struct buffer_reg_session {
+       /* Registry per domain. */
+       union {
+               struct ust_registry_session *ust;
+       } reg;
+
+       /* Contains buffer registry channel indexed by tracing channel key. */
+       struct lttng_ht *channels;
+};
+
+/*
+ * Registry object for per UID buffers.
+ */
+struct buffer_reg_uid {
+       /*
+        * Keys to match this object in a hash table. The following three variables
+        * identify a unique per UID buffer registry.
+        */
+       uint64_t session_id;    /* Unique tracing session id. */
+       int bits_per_long;      /* ABI */
+       uid_t uid;                      /* Owner. */
+
+       enum lttng_domain_type domain;
+       struct buffer_reg_session *registry;
+
+       /* Indexed by session id. */
+       struct lttng_ht_node_u64 node;
+       /* Node of a linked list used to teardown object at a destroy session. */
+       struct cds_list_head lnode;
+
+       char root_shm_path[PATH_MAX];
+       char shm_path[PATH_MAX];
+};
+
+/*
+ * Registry object for per PID buffers.
+ */
+struct buffer_reg_pid {
+       uint64_t session_id;
+
+       struct buffer_reg_session *registry;
+
+       /* Indexed by session id. */
+       struct lttng_ht_node_u64 node;
+
+       char root_shm_path[PATH_MAX];
+       char shm_path[PATH_MAX];
+};
+
+/* Buffer registry per UID. */
+void buffer_reg_init_uid_registry(void);
+int buffer_reg_uid_create(uint64_t session_id, uint32_t bits_per_long, uid_t uid,
+               enum lttng_domain_type domain, struct buffer_reg_uid **regp,
+               const char *root_shm_path, const char *shm_path);
+void buffer_reg_uid_add(struct buffer_reg_uid *reg);
+struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id,
+               uint32_t bits_per_long, uid_t uid);
+void buffer_reg_uid_remove(struct buffer_reg_uid *regp);
+void buffer_reg_uid_destroy(struct buffer_reg_uid *regp,
+               struct consumer_output *consumer);
+
+/* Buffer registry per PID. */
+void buffer_reg_init_pid_registry(void);
+int buffer_reg_pid_create(uint64_t session_id, struct buffer_reg_pid **regp,
+               const char *root_shm_path, const char *shm_path);
+void buffer_reg_pid_add(struct buffer_reg_pid *reg);
+struct buffer_reg_pid *buffer_reg_pid_find(uint64_t session_id);
+void buffer_reg_pid_remove(struct buffer_reg_pid *regp);
+void buffer_reg_pid_destroy(struct buffer_reg_pid *regp);
+
+/* Channel */
+int buffer_reg_channel_create(uint64_t key, struct buffer_reg_channel **regp);
+void buffer_reg_channel_add(struct buffer_reg_session *session,
+               struct buffer_reg_channel *channel);
+struct buffer_reg_channel *buffer_reg_channel_find(uint64_t key,
+               struct buffer_reg_uid *reg);
+void buffer_reg_channel_remove(struct buffer_reg_session *session,
+               struct buffer_reg_channel *regp);
+void buffer_reg_channel_destroy(struct buffer_reg_channel *regp,
+               enum lttng_domain_type domain);
+
+/* Stream */
+int buffer_reg_stream_create(struct buffer_reg_stream **regp);
+void buffer_reg_stream_add(struct buffer_reg_stream *stream,
+               struct buffer_reg_channel *channel);
+void buffer_reg_stream_destroy(struct buffer_reg_stream *regp,
+               enum lttng_domain_type domain);
+
+/* Global registry. */
+void buffer_reg_destroy_registries(void);
+
+int buffer_reg_uid_consumer_channel_key(
+               struct cds_list_head *buffer_reg_uid_list,
+               uint64_t chan_key, uint64_t *consumer_chan_key);
+
+#endif /* LTTNG_BUFFER_REGISTRY_H */
index c5b944d617ad704b2b56944ee5c85b8e4027bab8..e3bb232fa155d32d9620c07c0a0c87bc406e0b85 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-
-#include "channel.h"
-#include "lttng-sessiond.h"
-#include "kernel.h"
-#include "lttng-ust-ctl.h"
-#include "lttng-ust-error.h"
-#include "utils.h"
-#include "ust-app.h"
-#include "agent.h"
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include "channel.hpp"
+#include "lttng-sessiond.hpp"
+#include "kernel.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "lttng-ust-error.hpp"
+#include "utils.hpp"
+#include "ust-app.hpp"
+#include "agent.hpp"
 
 /*
  * Return allocated channel attributes.
diff --git a/src/bin/lttng-sessiond/channel.h b/src/bin/lttng-sessiond/channel.h
deleted file mode 100644 (file)
index fcc4d6b..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_CHANNEL_H
-#define _LTT_CHANNEL_H
-
-#include <lttng/lttng.h>
-
-#include "trace-kernel.h"
-#include "trace-ust.h"
-
-int channel_kernel_disable(struct ltt_kernel_session *ksession,
-               char *channel_name);
-enum lttng_error_code channel_kernel_enable(struct ltt_kernel_session *ksession,
-               struct ltt_kernel_channel *kchan);
-enum lttng_error_code channel_kernel_create(struct ltt_kernel_session *ksession,
-               struct lttng_channel *chan,
-               int kernel_pipe);
-
-struct lttng_channel *channel_new_default_attr(int domain,
-               enum lttng_buffer_type type);
-void channel_attr_destroy(struct lttng_channel *channel);
-
-enum lttng_error_code channel_ust_create(struct ltt_ust_session *usess,
-               struct lttng_channel *attr, enum lttng_buffer_type type);
-enum lttng_error_code channel_ust_enable(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan);
-int channel_ust_disable(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan);
-
-struct lttng_channel *trace_ust_channel_to_lttng_channel(
-               const struct ltt_ust_channel *uchan);
-
-#endif /* _LTT_CHANNEL_H */
diff --git a/src/bin/lttng-sessiond/channel.hpp b/src/bin/lttng-sessiond/channel.hpp
new file mode 100644 (file)
index 0000000..342e30f
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_CHANNEL_H
+#define _LTT_CHANNEL_H
+
+#include <lttng/lttng.h>
+
+#include "trace-kernel.hpp"
+#include "trace-ust.hpp"
+
+int channel_kernel_disable(struct ltt_kernel_session *ksession,
+               char *channel_name);
+enum lttng_error_code channel_kernel_enable(struct ltt_kernel_session *ksession,
+               struct ltt_kernel_channel *kchan);
+enum lttng_error_code channel_kernel_create(struct ltt_kernel_session *ksession,
+               struct lttng_channel *chan,
+               int kernel_pipe);
+
+struct lttng_channel *channel_new_default_attr(int domain,
+               enum lttng_buffer_type type);
+void channel_attr_destroy(struct lttng_channel *channel);
+
+enum lttng_error_code channel_ust_create(struct ltt_ust_session *usess,
+               struct lttng_channel *attr, enum lttng_buffer_type type);
+enum lttng_error_code channel_ust_enable(struct ltt_ust_session *usess,
+               struct ltt_ust_channel *uchan);
+int channel_ust_disable(struct ltt_ust_session *usess,
+               struct ltt_ust_channel *uchan);
+
+struct lttng_channel *trace_ust_channel_to_lttng_channel(
+               const struct ltt_ust_channel *uchan);
+
+#endif /* _LTT_CHANNEL_H */
index a0817c2daff618c90936cb48a2f0d51fe999b91e..fcac76ffa4c349a7e97ce521b2d9cc8c06539413 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/utils.h>
-
-#include "clear.h"
-#include "session.h"
-#include "ust-app.h"
-#include "kernel.h"
-#include "cmd.h"
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/utils.hpp>
+
+#include "clear.hpp"
+#include "session.hpp"
+#include "ust-app.hpp"
+#include "kernel.hpp"
+#include "cmd.hpp"
 
 struct cmd_clear_session_reply_context {
        int reply_sock_fd;
diff --git a/src/bin/lttng-sessiond/clear.h b/src/bin/lttng-sessiond/clear.h
deleted file mode 100644 (file)
index e788ec7..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef CLEAR_H
-#define CLEAR_H
-
-#include "session.h"
-
-int cmd_clear_session(struct ltt_session *session, int *sock_fd);
-
-#endif /* CLEAT_H */
diff --git a/src/bin/lttng-sessiond/clear.hpp b/src/bin/lttng-sessiond/clear.hpp
new file mode 100644 (file)
index 0000000..aca20d3
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef CLEAR_H
+#define CLEAR_H
+
+#include "session.hpp"
+
+int cmd_clear_session(struct ltt_session *session, int *sock_fd);
+
+#endif /* CLEAT_H */
index 4c1f6954b952ae1c4d553c5e52a71d48569ffc79..cf3fd44243bd18cbce118f4d53b37aa8000a0c15 100644 (file)
@@ -7,25 +7,25 @@
  *
  */
 
-#include "common/buffer-view.h"
-#include "common/compat/socket.h"
-#include "common/dynamic-array.h"
-#include "common/dynamic-buffer.h"
-#include "common/fd-handle.h"
-#include "common/payload-view.h"
-#include "common/payload.h"
-#include "common/sessiond-comm/sessiond-comm.h"
+#include "common/buffer-view.hpp"
+#include "common/compat/socket.hpp"
+#include "common/dynamic-array.hpp"
+#include "common/dynamic-buffer.hpp"
+#include "common/fd-handle.hpp"
+#include "common/payload-view.hpp"
+#include "common/payload.hpp"
+#include "common/sessiond-comm/sessiond-comm.hpp"
 #include "lttng/lttng-error.h"
 #include "lttng/tracker.h"
-#include <common/compat/getenv.h>
-#include <common/tracker.h>
-#include <common/unix.h>
-#include <common/utils.h>
-#include <lttng/error-query-internal.h>
-#include <lttng/event-internal.h>
-#include <lttng/session-descriptor-internal.h>
-#include <lttng/session-internal.h>
-#include <lttng/userspace-probe-internal.h>
+#include <common/compat/getenv.hpp>
+#include <common/tracker.hpp>
+#include <common/unix.hpp>
+#include <common/utils.hpp>
+#include <lttng/error-query-internal.hpp>
+#include <lttng/event-internal.hpp>
+#include <lttng/session-descriptor-internal.hpp>
+#include <lttng/session-internal.hpp>
+#include <lttng/userspace-probe-internal.hpp>
 #include <pthread.h>
 #include <signal.h>
 #include <stddef.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include "agent-thread.h"
-#include "clear.h"
-#include "client.h"
-#include "cmd.h"
-#include "health-sessiond.h"
-#include "kernel.h"
-#include "lttng-sessiond.h"
-#include "manage-consumer.h"
-#include "save.h"
-#include "testpoint.h"
-#include "utils.h"
+#include "agent-thread.hpp"
+#include "clear.hpp"
+#include "client.hpp"
+#include "cmd.hpp"
+#include "health-sessiond.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "manage-consumer.hpp"
+#include "save.hpp"
+#include "testpoint.hpp"
+#include "utils.hpp"
 
 static bool is_root;
 
diff --git a/src/bin/lttng-sessiond/client.h b/src/bin/lttng-sessiond/client.h
deleted file mode 100644 (file)
index 0610d45..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef CLIENT_SESSIOND_H
-#define CLIENT_SESSIOND_H
-
-#include "thread.h"
-
-struct lttng_thread *launch_client_thread(void);
-
-#endif /* CLIENT_SESSIOND_H */
diff --git a/src/bin/lttng-sessiond/client.hpp b/src/bin/lttng-sessiond/client.hpp
new file mode 100644 (file)
index 0000000..49a454d
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef CLIENT_SESSIOND_H
+#define CLIENT_SESSIOND_H
+
+#include "thread.hpp"
+
+struct lttng_thread *launch_client_thread(void);
+
+#endif /* CLIENT_SESSIOND_H */
index 3ed56f7b064503402b41b1fa204166ada14655fb..47c049b319ed9a9f3dbc31f4dda935f8ff31007d 100644 (file)
 #include <urcu/list.h>
 #include <urcu/uatomic.h>
 
-#include <common/buffer-view.h>
-#include <common/common.h>
-#include <common/compat/string.h>
-#include <common/defaults.h>
-#include <common/dynamic-buffer.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/relayd/relayd.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/string-utils/string-utils.h>
-#include <common/trace-chunk.h>
-#include <common/utils.h>
-
+#include <common/buffer-view.hpp>
+#include <common/common.hpp>
+#include <common/compat/string.hpp>
+#include <common/defaults.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/utils.hpp>
+#include <lttng/action/action-internal.hpp>
 #include <lttng/action/action.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/channel-internal.h>
+#include <lttng/channel-internal.hpp>
 #include <lttng/channel.h>
+#include <lttng/condition/condition-internal.hpp>
 #include <lttng/condition/condition.h>
-#include <lttng/error-query-internal.h>
-#include <lttng/event-internal.h>
-#include <lttng/location-internal.h>
-#include <lttng/rotate-internal.h>
-#include <lttng/session-descriptor-internal.h>
-#include <lttng/session-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/userspace-probe-internal.h>
-
-#include "agent-thread.h"
-#include "agent.h"
-#include "buffer-registry.h"
-#include "channel.h"
-#include "cmd.h"
-#include "consumer.h"
-#include "event-notifier-error-accounting.h"
-#include "event.h"
-#include "health-sessiond.h"
-#include "kernel-consumer.h"
-#include "kernel.h"
-#include "lttng-sessiond.h"
-#include "lttng-syscall.h"
-#include "notification-thread-commands.h"
-#include "notification-thread.h"
-#include "rotate.h"
-#include "rotation-thread.h"
-#include "session.h"
-#include "timer.h"
-#include "tracker.h"
-#include "utils.h"
+#include <lttng/condition/event-rule-matches-internal.hpp>
+#include <lttng/condition/event-rule-matches.h>
+#include <lttng/error-query-internal.hpp>
+#include <lttng/event-internal.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/event-rule.h>
+#include <lttng/location-internal.hpp>
+#include <lttng/lttng-error.h>
+#include <lttng/rotate-internal.hpp>
+#include <lttng/session-descriptor-internal.hpp>
+#include <lttng/session-internal.hpp>
+#include <lttng/tracker.h>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <lttng/userspace-probe-internal.hpp>
+
+#include "agent-thread.hpp"
+#include "agent.hpp"
+#include "buffer-registry.hpp"
+#include "channel.hpp"
+#include "cmd.hpp"
+#include "consumer.hpp"
+#include "event-notifier-error-accounting.hpp"
+#include "event.hpp"
+#include "health-sessiond.hpp"
+#include "kernel-consumer.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng-syscall.hpp"
+#include "notification-thread-commands.hpp"
+#include "notification-thread.hpp"
+#include "rotate.hpp"
+#include "rotation-thread.hpp"
+#include "session.hpp"
+#include "timer.hpp"
+#include "tracker.hpp"
+#include "utils.hpp"
 
 /* Sleep for 100ms between each check for the shm path's deletion. */
 #define SESSION_DESTROY_SHM_PATH_CHECK_DELAY_US 100000
diff --git a/src/bin/lttng-sessiond/cmd.h b/src/bin/lttng-sessiond/cmd.h
deleted file mode 100644 (file)
index 13d540e..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef CMD_H
-#define CMD_H
-
-#include "context.h"
-#include "lttng-sessiond.h"
-#include "lttng/tracker.h"
-#include "session.h"
-#include <common/tracker.h>
-
-struct notification_thread_handle;
-struct lttng_dynamic_buffer;
-
-/*
- * A callback (and associated user data) that should be run after a command
- * has been executed. No locks should be taken while executing this handler.
- *
- * The command's reply should not be sent until the handler has run and
- * completed successfully. On failure, the handler's return code should
- * be the only reply sent to the client.
- */
-typedef enum lttng_error_code (*completion_handler_function)(void *);
-struct cmd_completion_handler {
-       completion_handler_function run;
-       void *data;
-};
-
-/*
- * Init the command subsystem. Must be called before using any of the functions
- * above. This is called in the main() of the session daemon.
- */
-void cmd_init(void);
-
-/* Session commands */
-enum lttng_error_code cmd_create_session(struct command_ctx *cmd_ctx, int sock,
-               struct lttng_session_descriptor **return_descriptor);
-int cmd_destroy_session(struct ltt_session *session,
-               struct notification_thread_handle *notification_thread_handle,
-               int *sock_fd);
-
-/* Channel commands */
-int cmd_disable_channel(struct ltt_session *session,
-               enum lttng_domain_type domain, char *channel_name);
-int cmd_enable_channel(struct command_ctx *cmd_ctx, int sock, int wpipe);
-
-/* Process attribute tracker commands */
-enum lttng_error_code cmd_process_attr_tracker_get_tracking_policy(
-               struct ltt_session *session,
-               enum lttng_domain_type domain,
-               enum lttng_process_attr process_attr,
-               enum lttng_tracking_policy *policy);
-enum lttng_error_code cmd_process_attr_tracker_set_tracking_policy(
-               struct ltt_session *session,
-               enum lttng_domain_type domain,
-               enum lttng_process_attr process_attr,
-               enum lttng_tracking_policy policy);
-enum lttng_error_code cmd_process_attr_tracker_inclusion_set_add_value(
-               struct ltt_session *session,
-               enum lttng_domain_type domain,
-               enum lttng_process_attr process_attr,
-               const struct process_attr_value *value);
-enum lttng_error_code cmd_process_attr_tracker_inclusion_set_remove_value(
-               struct ltt_session *session,
-               enum lttng_domain_type domain,
-               enum lttng_process_attr process_attr,
-               const struct process_attr_value *value);
-enum lttng_error_code cmd_process_attr_tracker_get_inclusion_set(
-               struct ltt_session *session,
-               enum lttng_domain_type domain,
-               enum lttng_process_attr process_attr,
-               struct lttng_process_attr_values **values);
-
-/* Event commands */
-int cmd_disable_event(struct command_ctx *cmd_ctx,
-               struct lttng_event *event,
-               char *filter_expression,
-               struct lttng_bytecode *filter,
-               struct lttng_event_exclusion *exclusion);
-int cmd_add_context(struct command_ctx *cmd_ctx,
-               const struct lttng_event_context *event_context,
-               int kwpipe);
-int cmd_set_filter(struct ltt_session *session, enum lttng_domain_type domain,
-               char *channel_name, struct lttng_event *event,
-               struct lttng_bytecode *bytecode);
-int cmd_enable_event(struct command_ctx *cmd_ctx,
-               struct lttng_event *event,
-               char *filter_expression,
-               struct lttng_event_exclusion *exclusion,
-               struct lttng_bytecode *bytecode,
-               int wpipe);
-
-/* Trace session action commands */
-int cmd_start_trace(struct ltt_session *session);
-int cmd_stop_trace(struct ltt_session *session);
-
-/* Consumer commands */
-int cmd_register_consumer(struct ltt_session *session,
-               enum lttng_domain_type domain,
-               const char *sock_path, struct consumer_data *cdata);
-int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri,
-               struct lttng_uri *uris);
-int cmd_setup_relayd(struct ltt_session *session);
-
-/* Listing commands */
-ssize_t cmd_list_domains(struct ltt_session *session,
-               struct lttng_domain **domains);
-enum lttng_error_code cmd_list_events(enum lttng_domain_type domain,
-               struct ltt_session *session,
-               char *channel_name,
-               struct lttng_payload *payload);
-enum lttng_error_code cmd_list_channels(enum lttng_domain_type domain,
-               struct ltt_session *session,
-               struct lttng_payload *payload);
-void cmd_list_lttng_sessions(struct lttng_session *sessions,
-               size_t session_count, uid_t uid, gid_t gid);
-enum lttng_error_code cmd_list_tracepoint_fields(enum lttng_domain_type domain,
-               struct lttng_payload *reply);
-enum lttng_error_code cmd_list_tracepoints(enum lttng_domain_type domain,
-               struct lttng_payload *reply_payload);
-ssize_t cmd_snapshot_list_outputs(struct ltt_session *session,
-               struct lttng_snapshot_output **outputs);
-enum lttng_error_code cmd_list_syscalls(
-               struct lttng_payload *reply_payload);
-
-int cmd_data_pending(struct ltt_session *session);
-
-/* Snapshot */
-int cmd_snapshot_add_output(struct ltt_session *session,
-               const struct lttng_snapshot_output *output, uint32_t *id);
-int cmd_snapshot_del_output(struct ltt_session *session,
-               const struct lttng_snapshot_output *output);
-int cmd_snapshot_record(struct ltt_session *session,
-               const struct lttng_snapshot_output *output, int wait);
-
-int cmd_set_session_shm_path(struct ltt_session *session,
-               const char *shm_path);
-int cmd_regenerate_metadata(struct ltt_session *session);
-int cmd_regenerate_statedump(struct ltt_session *session);
-
-enum lttng_error_code cmd_register_trigger(
-               const struct lttng_credentials *cmd_creds,
-               struct lttng_trigger *trigger,
-               bool is_anonymous_trigger,
-               struct notification_thread_handle *notification_thread_handle,
-               struct lttng_trigger **return_trigger);
-enum lttng_error_code cmd_unregister_trigger(
-               const struct lttng_credentials *cmd_creds,
-               const struct lttng_trigger *trigger,
-               struct notification_thread_handle *notification_thread_handle);
-
-enum lttng_error_code cmd_list_triggers(struct command_ctx *cmd_ctx,
-               struct notification_thread_handle *notification_thread_handle,
-               struct lttng_triggers **return_triggers);
-enum lttng_error_code cmd_execute_error_query(const struct lttng_credentials *cmd_creds,
-               const struct lttng_error_query *query,
-               struct lttng_error_query_results **_results,
-               struct notification_thread_handle *notification_thread);
-
-int cmd_rotate_session(struct ltt_session *session,
-               struct lttng_rotate_session_return *rotate_return,
-               bool quiet_rotation,
-               enum lttng_trace_chunk_command_type command);
-int cmd_rotate_get_info(struct ltt_session *session,
-               struct lttng_rotation_get_info_return *info_return,
-               uint64_t rotate_id);
-int cmd_rotation_set_schedule(struct ltt_session *session,
-               bool activate, enum lttng_rotation_schedule_type schedule_type,
-               uint64_t value,
-               struct notification_thread_handle *notification_thread_handle);
-
-const struct cmd_completion_handler *cmd_pop_completion_handler(void);
-int start_kernel_session(struct ltt_kernel_session *ksess);
-int stop_kernel_session(struct ltt_kernel_session *ksess);
-
-#endif /* CMD_H */
diff --git a/src/bin/lttng-sessiond/cmd.hpp b/src/bin/lttng-sessiond/cmd.hpp
new file mode 100644 (file)
index 0000000..8727e74
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef CMD_H
+#define CMD_H
+
+#include "context.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng/tracker.h"
+#include "session.hpp"
+#include <common/tracker.hpp>
+
+struct notification_thread_handle;
+struct lttng_dynamic_buffer;
+
+/*
+ * A callback (and associated user data) that should be run after a command
+ * has been executed. No locks should be taken while executing this handler.
+ *
+ * The command's reply should not be sent until the handler has run and
+ * completed successfully. On failure, the handler's return code should
+ * be the only reply sent to the client.
+ */
+typedef enum lttng_error_code (*completion_handler_function)(void *);
+struct cmd_completion_handler {
+       completion_handler_function run;
+       void *data;
+};
+
+/*
+ * Init the command subsystem. Must be called before using any of the functions
+ * above. This is called in the main() of the session daemon.
+ */
+void cmd_init(void);
+
+/* Session commands */
+enum lttng_error_code cmd_create_session(struct command_ctx *cmd_ctx, int sock,
+               struct lttng_session_descriptor **return_descriptor);
+int cmd_destroy_session(struct ltt_session *session,
+               struct notification_thread_handle *notification_thread_handle,
+               int *sock_fd);
+
+/* Channel commands */
+int cmd_disable_channel(struct ltt_session *session,
+               enum lttng_domain_type domain, char *channel_name);
+int cmd_enable_channel(struct command_ctx *cmd_ctx, int sock, int wpipe);
+
+/* Process attribute tracker commands */
+enum lttng_error_code cmd_process_attr_tracker_get_tracking_policy(
+               struct ltt_session *session,
+               enum lttng_domain_type domain,
+               enum lttng_process_attr process_attr,
+               enum lttng_tracking_policy *policy);
+enum lttng_error_code cmd_process_attr_tracker_set_tracking_policy(
+               struct ltt_session *session,
+               enum lttng_domain_type domain,
+               enum lttng_process_attr process_attr,
+               enum lttng_tracking_policy policy);
+enum lttng_error_code cmd_process_attr_tracker_inclusion_set_add_value(
+               struct ltt_session *session,
+               enum lttng_domain_type domain,
+               enum lttng_process_attr process_attr,
+               const struct process_attr_value *value);
+enum lttng_error_code cmd_process_attr_tracker_inclusion_set_remove_value(
+               struct ltt_session *session,
+               enum lttng_domain_type domain,
+               enum lttng_process_attr process_attr,
+               const struct process_attr_value *value);
+enum lttng_error_code cmd_process_attr_tracker_get_inclusion_set(
+               struct ltt_session *session,
+               enum lttng_domain_type domain,
+               enum lttng_process_attr process_attr,
+               struct lttng_process_attr_values **values);
+
+/* Event commands */
+int cmd_disable_event(struct command_ctx *cmd_ctx,
+               struct lttng_event *event,
+               char *filter_expression,
+               struct lttng_bytecode *filter,
+               struct lttng_event_exclusion *exclusion);
+int cmd_add_context(struct command_ctx *cmd_ctx,
+               const struct lttng_event_context *event_context,
+               int kwpipe);
+int cmd_set_filter(struct ltt_session *session, enum lttng_domain_type domain,
+               char *channel_name, struct lttng_event *event,
+               struct lttng_bytecode *bytecode);
+int cmd_enable_event(struct command_ctx *cmd_ctx,
+               struct lttng_event *event,
+               char *filter_expression,
+               struct lttng_event_exclusion *exclusion,
+               struct lttng_bytecode *bytecode,
+               int wpipe);
+
+/* Trace session action commands */
+int cmd_start_trace(struct ltt_session *session);
+int cmd_stop_trace(struct ltt_session *session);
+
+/* Consumer commands */
+int cmd_register_consumer(struct ltt_session *session,
+               enum lttng_domain_type domain,
+               const char *sock_path, struct consumer_data *cdata);
+int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri,
+               struct lttng_uri *uris);
+int cmd_setup_relayd(struct ltt_session *session);
+
+/* Listing commands */
+ssize_t cmd_list_domains(struct ltt_session *session,
+               struct lttng_domain **domains);
+enum lttng_error_code cmd_list_events(enum lttng_domain_type domain,
+               struct ltt_session *session,
+               char *channel_name,
+               struct lttng_payload *payload);
+enum lttng_error_code cmd_list_channels(enum lttng_domain_type domain,
+               struct ltt_session *session,
+               struct lttng_payload *payload);
+void cmd_list_lttng_sessions(struct lttng_session *sessions,
+               size_t session_count, uid_t uid, gid_t gid);
+enum lttng_error_code cmd_list_tracepoint_fields(enum lttng_domain_type domain,
+               struct lttng_payload *reply);
+enum lttng_error_code cmd_list_tracepoints(enum lttng_domain_type domain,
+               struct lttng_payload *reply_payload);
+ssize_t cmd_snapshot_list_outputs(struct ltt_session *session,
+               struct lttng_snapshot_output **outputs);
+enum lttng_error_code cmd_list_syscalls(
+               struct lttng_payload *reply_payload);
+
+int cmd_data_pending(struct ltt_session *session);
+
+/* Snapshot */
+int cmd_snapshot_add_output(struct ltt_session *session,
+               const struct lttng_snapshot_output *output, uint32_t *id);
+int cmd_snapshot_del_output(struct ltt_session *session,
+               const struct lttng_snapshot_output *output);
+int cmd_snapshot_record(struct ltt_session *session,
+               const struct lttng_snapshot_output *output, int wait);
+
+int cmd_set_session_shm_path(struct ltt_session *session,
+               const char *shm_path);
+int cmd_regenerate_metadata(struct ltt_session *session);
+int cmd_regenerate_statedump(struct ltt_session *session);
+
+enum lttng_error_code cmd_register_trigger(
+               const struct lttng_credentials *cmd_creds,
+               struct lttng_trigger *trigger,
+               bool is_anonymous_trigger,
+               struct notification_thread_handle *notification_thread_handle,
+               struct lttng_trigger **return_trigger);
+enum lttng_error_code cmd_unregister_trigger(
+               const struct lttng_credentials *cmd_creds,
+               const struct lttng_trigger *trigger,
+               struct notification_thread_handle *notification_thread_handle);
+
+enum lttng_error_code cmd_list_triggers(struct command_ctx *cmd_ctx,
+               struct notification_thread_handle *notification_thread_handle,
+               struct lttng_triggers **return_triggers);
+enum lttng_error_code cmd_execute_error_query(const struct lttng_credentials *cmd_creds,
+               const struct lttng_error_query *query,
+               struct lttng_error_query_results **_results,
+               struct notification_thread_handle *notification_thread);
+
+int cmd_rotate_session(struct ltt_session *session,
+               struct lttng_rotate_session_return *rotate_return,
+               bool quiet_rotation,
+               enum lttng_trace_chunk_command_type command);
+int cmd_rotate_get_info(struct ltt_session *session,
+               struct lttng_rotation_get_info_return *info_return,
+               uint64_t rotate_id);
+int cmd_rotation_set_schedule(struct ltt_session *session,
+               bool activate, enum lttng_rotation_schedule_type schedule_type,
+               uint64_t value,
+               struct notification_thread_handle *notification_thread_handle);
+
+const struct cmd_completion_handler *cmd_pop_completion_handler(void);
+int start_kernel_session(struct ltt_kernel_session *ksess);
+int stop_kernel_session(struct ltt_kernel_session *ksess);
+
+#endif /* CMD_H */
index dd9c244b3253ac68694799348066bc048daa1274..7daa53625190769284ecb0586387cba9d7bc5044 100644 (file)
@@ -5,19 +5,19 @@
  *
  */
 
-#include <common/hashtable/utils.h>
-#include <common/hashtable/hashtable.h>
+#include <common/hashtable/utils.hpp>
+#include <common/hashtable/hashtable.hpp>
 
 #include <lttng/condition/condition.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <lttng/condition/session-consumed-size-internal.h>
-#include <lttng/condition/session-rotation-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/session-consumed-size-internal.hpp>
+#include <lttng/condition/session-rotation-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
 #include <lttng/condition/event-rule-matches.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
-#include "condition-internal.h"
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
+#include "condition-internal.hpp"
 
 static
 unsigned long lttng_condition_buffer_usage_hash(
diff --git a/src/bin/lttng-sessiond/condition-internal.h b/src/bin/lttng-sessiond/condition-internal.h
deleted file mode 100644 (file)
index 49a0749..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_SESSIOND_CONDITION_INTERNAL_H
-#define LTTNG_SESSIOND_CONDITION_INTERNAL_H
-
-#include <lttng/condition/condition.h>
-
-/*
- * The lttng_condition hashing code is kept in this file (rather than
- * condition.c) since it makes use of GPLv2 code (hashtable utils), which we
- * don't want to link in liblttng-ctl.
- */
-unsigned long lttng_condition_hash(const struct lttng_condition *condition);
-
-struct lttng_condition *lttng_condition_copy(
-               const struct lttng_condition *condition);
-
-#endif /* LTTNG_SESSIOND_CONDITION_INTERNAL_H */
diff --git a/src/bin/lttng-sessiond/condition-internal.hpp b/src/bin/lttng-sessiond/condition-internal.hpp
new file mode 100644 (file)
index 0000000..49a0749
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_SESSIOND_CONDITION_INTERNAL_H
+#define LTTNG_SESSIOND_CONDITION_INTERNAL_H
+
+#include <lttng/condition/condition.h>
+
+/*
+ * The lttng_condition hashing code is kept in this file (rather than
+ * condition.c) since it makes use of GPLv2 code (hashtable utils), which we
+ * don't want to link in liblttng-ctl.
+ */
+unsigned long lttng_condition_hash(const struct lttng_condition *condition);
+
+struct lttng_condition *lttng_condition_copy(
+               const struct lttng_condition *condition);
+
+#endif /* LTTNG_SESSIOND_CONDITION_INTERNAL_H */
index f76dffa7eb787e537e72b57637b1e4af0f94d462..238da05085739aaca35506b543b10380e89c1197 100644 (file)
 #include <unistd.h>
 #include <inttypes.h>
 
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/uri.h>
-#include <common/relayd/relayd.h>
-#include <common/string-utils/format.h>
-
-#include "consumer.h"
-#include "health-sessiond.h"
-#include "ust-app.h"
-#include "utils.h"
-#include "lttng-sessiond.h"
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/uri.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/string-utils/format.hpp>
+
+#include "consumer.hpp"
+#include "health-sessiond.hpp"
+#include "ust-app.hpp"
+#include "utils.hpp"
+#include "lttng-sessiond.hpp"
 
 /*
  * Return allocated full pathname of the session using the consumer trace path
diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h
deleted file mode 100644 (file)
index a179206..0000000
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _CONSUMER_H
-#define _CONSUMER_H
-
-#include <common/consumer/consumer.h>
-#include <common/hashtable/hashtable.h>
-#include <lttng/lttng.h>
-#include <urcu/ref.h>
-#include <algorithm>
-
-#include "snapshot.h"
-
-struct snapshot;
-struct snapshot_output;
-struct ltt_session;
-
-/*
- * Needed until we use C++14, where std::max is constexpr.
- *
- * Use a static_assert so we remember to remove it when we upgrade to a newer
- * C++.
- */
-static_assert(__cplusplus == 201103L, "");
-template <typename T>
-constexpr T max_constexpr(T l, T r)
-{
-       return l > r ? l : r;
-}
-
-enum consumer_dst_type {
-       CONSUMER_DST_LOCAL,
-       CONSUMER_DST_NET,
-};
-
-enum consumer_trace_chunk_exists_status {
-       CONSUMER_TRACE_CHUNK_EXISTS_STATUS_EXISTS_LOCAL,
-       CONSUMER_TRACE_CHUNK_EXISTS_STATUS_EXISTS_REMOTE,
-       CONSUMER_TRACE_CHUNK_EXISTS_STATUS_UNKNOWN_CHUNK,
-};
-
-struct consumer_socket {
-       /*
-        * File descriptor. This is just a reference to the consumer data meaning
-        * that every access must be locked and checked for a possible invalid
-        * value.
-        */
-       int *fd_ptr;
-
-       /*
-        * To use this socket (send/recv), this lock MUST be acquired.
-        */
-       pthread_mutex_t *lock;
-
-       /*
-        * Indicates if the socket was registered by a third part
-        * (REGISTER_CONSUMER) or is the spawn consumer of the session daemon.
-        * During the destroy phase of a consumer output, we close the socket if
-        * this flag is set to 1 since we don't need the fd anymore.
-        */
-       unsigned int registered;
-
-       /* Flag if network sockets were sent to the consumer. */
-       unsigned int control_sock_sent;
-       unsigned int data_sock_sent;
-
-       struct lttng_ht_node_ulong node;
-
-       enum lttng_consumer_type type;
-};
-
-struct consumer_data {
-       consumer_data (lttng_consumer_type type_)
-               : type(type_)
-       {}
-
-       enum lttng_consumer_type type;
-
-       /* Mutex to control consumerd pid assignation */
-       pthread_mutex_t pid_mutex = PTHREAD_MUTEX_INITIALIZER;
-       pid_t pid = 0;
-
-       int err_sock = -1;
-       /* These two sockets uses the cmd_unix_sock_path. */
-       int cmd_sock = -1;
-       /*
-        * Write-end of the channel monitoring pipe to be passed to the
-        * consumer.
-        */
-       int channel_monitor_pipe = -1;
-       /*
-        * The metadata socket object is handled differently and only created
-        * locally in this object thus it's the only reference available in the
-        * session daemon. For that reason, a variable for the fd is required and
-        * the metadata socket fd points to it.
-        */
-       int metadata_fd = 0;
-       struct consumer_socket metadata_sock {};
-
-       /* consumer error and command Unix socket path */
-       const char *err_unix_sock_path = nullptr;
-       const char *cmd_unix_sock_path = nullptr;
-
-       /*
-        * This lock has two purposes. It protects any change to the consumer
-        * socket and make sure only one thread uses this object for read/write
-        * operations.
-        */
-       pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-};
-
-/*
- * Network URIs
- */
-struct consumer_net {
-       /*
-        * Indicate if URI type is set. Those flags should only be set when the
-        * created URI is done AND valid.
-        */
-       int control_isset;
-       int data_isset;
-
-       /*
-        * The following two URIs MUST have the same destination address for
-        * network streaming to work. Network hop are not yet supported.
-        */
-
-       /* Control path for network streaming. */
-       struct lttng_uri control;
-
-       /* Data path for network streaming. */
-       struct lttng_uri data;
-
-       /* <hostname>/<session-name> */
-       char base_dir[PATH_MAX];
-};
-
-/*
- * Consumer output object describing where and how to send data.
- */
-struct consumer_output {
-       struct urcu_ref ref;    /* Refcount */
-
-       /* If the consumer is enabled meaning that should be used */
-       unsigned int enabled;
-       enum consumer_dst_type type;
-
-       /*
-        * The net_seq_index is the index of the network stream on the consumer
-        * side. It tells the consumer which streams goes to which relayd with this
-        * index. The relayd sockets are index with it on the consumer side.
-        */
-       uint64_t net_seq_index;
-       /* Store the relay protocol in use if the session is remote. */
-       uint32_t relay_major_version;
-       uint32_t relay_minor_version;
-
-       /* True if relayd supports the clear feature. */
-       bool relay_allows_clear;
-
-       /*
-        * Subdirectory path name used for both local and network
-        * consumer ("kernel", "ust", or empty).
-        */
-       char domain_subdir[
-               max_constexpr(sizeof(DEFAULT_KERNEL_TRACE_DIR),
-                       sizeof(DEFAULT_UST_TRACE_DIR))];
-
-       /*
-        * Hashtable of consumer_socket index by the file descriptor value. For
-        * multiarch consumer support, we can have more than one consumer (ex:
-        * 32 and 64 bit).
-        */
-       struct lttng_ht *socks;
-
-       /* Tell if this output is used for snapshot. */
-       unsigned int snapshot:1;
-
-       union {
-               char session_root_path[LTTNG_PATH_MAX];
-               struct consumer_net net;
-       } dst;
-
-       /*
-        * Sub-directory below the session_root_path where the next chunk of
-        * trace will be stored (\0 before the first session rotation).
-        */
-       char chunk_path[LTTNG_PATH_MAX];
-};
-
-struct consumer_socket *consumer_find_socket(int key,
-               const struct consumer_output *consumer);
-struct consumer_socket *consumer_find_socket_by_bitness(int bits,
-               const struct consumer_output *consumer);
-struct consumer_socket *consumer_allocate_socket(int *fd);
-void consumer_add_socket(struct consumer_socket *sock,
-               struct consumer_output *consumer);
-void consumer_del_socket(struct consumer_socket *sock,
-               struct consumer_output *consumer);
-void consumer_destroy_socket(struct consumer_socket *sock);
-int consumer_copy_sockets(struct consumer_output *dst,
-               struct consumer_output *src);
-void consumer_destroy_output_sockets(struct consumer_output *obj);
-int consumer_socket_send(struct consumer_socket *socket, const void *msg,
-               size_t len);
-int consumer_socket_recv(struct consumer_socket *socket, void *msg,
-               size_t len);
-
-struct consumer_output *consumer_create_output(enum consumer_dst_type type);
-struct consumer_output *consumer_copy_output(struct consumer_output *obj);
-void consumer_output_get(struct consumer_output *obj);
-void consumer_output_put(struct consumer_output *obj);
-int consumer_set_network_uri(const struct ltt_session *session,
-               struct consumer_output *obj,
-               struct lttng_uri *uri);
-int consumer_send_fds(struct consumer_socket *sock, const int *fds,
-               size_t nb_fd);
-int consumer_send_msg(struct consumer_socket *sock,
-               const struct lttcomm_consumer_msg *msg);
-int consumer_send_stream(struct consumer_socket *sock,
-               struct consumer_output *dst, struct lttcomm_consumer_msg *msg,
-               const int *fds, size_t nb_fd);
-int consumer_send_channel(struct consumer_socket *sock,
-               struct lttcomm_consumer_msg *msg);
-int consumer_send_relayd_socket(struct consumer_socket *consumer_sock,
-               struct lttcomm_relayd_sock *rsock, struct consumer_output *consumer,
-               enum lttng_stream_type type, uint64_t session_id,
-               const char *session_name, const char *hostname,
-               const char *base_path, int session_live_timer,
-               const uint64_t *current_chunk_id, time_t session_creation_time,
-               bool session_name_contains_creation_time);
-int consumer_send_channel_monitor_pipe(struct consumer_socket *consumer_sock,
-               int pipe);
-int consumer_send_destroy_relayd(struct consumer_socket *sock,
-               struct consumer_output *consumer);
-int consumer_recv_status_reply(struct consumer_socket *sock);
-int consumer_recv_status_channel(struct consumer_socket *sock,
-               uint64_t *key, unsigned int *stream_count);
-void consumer_output_send_destroy_relayd(struct consumer_output *consumer);
-int consumer_create_socket(struct consumer_data *data,
-               struct consumer_output *output);
-
-void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
-               uint64_t subbuf_size,
-               uint64_t num_subbuf,
-               int overwrite,
-               unsigned int switch_timer_interval,
-               unsigned int read_timer_interval,
-               unsigned int live_timer_interval,
-               bool is_in_live_session,
-               unsigned int monitor_timer_interval,
-               int output,
-               int type,
-               uint64_t session_id,
-               const char *pathname,
-               const char *name,
-               uint64_t relayd_id,
-               uint64_t key,
-               unsigned char *uuid,
-               uint32_t chan_id,
-               uint64_t tracefile_size,
-               uint64_t tracefile_count,
-               uint64_t session_id_per_pid,
-               unsigned int monitor,
-               uint32_t ust_app_uid,
-               int64_t blocking_timeout,
-               const char *root_shm_path,
-               const char *shm_path,
-               struct lttng_trace_chunk *trace_chunk,
-               const struct lttng_credentials *buffer_credentials);
-void consumer_init_add_stream_comm_msg(struct lttcomm_consumer_msg *msg,
-               uint64_t channel_key,
-               uint64_t stream_key,
-               int32_t cpu);
-void consumer_init_streams_sent_comm_msg(struct lttcomm_consumer_msg *msg,
-               enum lttng_consumer_command cmd,
-               uint64_t channel_key, uint64_t net_seq_idx);
-void consumer_init_add_channel_comm_msg(struct lttcomm_consumer_msg *msg,
-               uint64_t channel_key,
-               uint64_t session_id,
-               const char *pathname,
-               uint64_t relayd_id,
-               const char *name,
-               unsigned int nb_init_streams,
-               enum lttng_event_output output,
-               int type,
-               uint64_t tracefile_size,
-               uint64_t tracefile_count,
-               unsigned int monitor,
-               unsigned int live_timer_interval,
-               bool is_in_live_session,
-               unsigned int monitor_timer_interval,
-               struct lttng_trace_chunk *trace_chunk);
-int consumer_is_data_pending(uint64_t session_id,
-               struct consumer_output *consumer);
-int consumer_close_metadata(struct consumer_socket *socket,
-               uint64_t metadata_key);
-int consumer_setup_metadata(struct consumer_socket *socket,
-               uint64_t metadata_key);
-int consumer_push_metadata(struct consumer_socket *socket,
-               uint64_t metadata_key, char *metadata_str, size_t len,
-               size_t target_offset, uint64_t version);
-int consumer_flush_channel(struct consumer_socket *socket, uint64_t key);
-int consumer_clear_quiescent_channel(struct consumer_socket *socket, uint64_t key);
-int consumer_get_discarded_events(uint64_t session_id, uint64_t channel_key,
-               struct consumer_output *consumer, uint64_t *discarded);
-int consumer_get_lost_packets(uint64_t session_id, uint64_t channel_key,
-               struct consumer_output *consumer, uint64_t *lost);
-
-/* Snapshot command. */
-enum lttng_error_code consumer_snapshot_channel(struct consumer_socket *socket,
-               uint64_t key, const struct consumer_output *output, int metadata,
-               const char *channel_path, uint64_t nb_packets_per_stream);
-
-/* Rotation commands. */
-int consumer_rotate_channel(struct consumer_socket *socket, uint64_t key,
-               struct consumer_output *output, bool is_metadata_channel);
-int consumer_init(struct consumer_socket *socket,
-               const lttng_uuid sessiond_uuid);
-
-int consumer_create_trace_chunk(struct consumer_socket *socket,
-               uint64_t relayd_id, uint64_t session_id,
-               struct lttng_trace_chunk *chunk,
-               const char *domain_subdir);
-int consumer_close_trace_chunk(struct consumer_socket *socket,
-               uint64_t relayd_id, uint64_t session_id,
-               struct lttng_trace_chunk *chunk,
-               char *closed_trace_chunk_path);
-int consumer_trace_chunk_exists(struct consumer_socket *socket,
-               uint64_t relayd_id, uint64_t session_id,
-               struct lttng_trace_chunk *chunk,
-               enum consumer_trace_chunk_exists_status *result);
-int consumer_open_channel_packets(struct consumer_socket *socket, uint64_t key);
-
-char *setup_channel_trace_path(struct consumer_output *consumer,
-               const char *session_path, size_t *consumer_path_offset);
-
-/* Clear command */
-int consumer_clear_channel(struct consumer_socket *socket, uint64_t key);
-
-#endif /* _CONSUMER_H */
diff --git a/src/bin/lttng-sessiond/consumer.hpp b/src/bin/lttng-sessiond/consumer.hpp
new file mode 100644 (file)
index 0000000..15e2a2f
--- /dev/null
@@ -0,0 +1,346 @@
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _CONSUMER_H
+#define _CONSUMER_H
+
+#include <common/consumer/consumer.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <lttng/lttng.h>
+#include <urcu/ref.h>
+#include <algorithm>
+
+#include "snapshot.hpp"
+
+struct snapshot;
+struct snapshot_output;
+struct ltt_session;
+
+/*
+ * Needed until we use C++14, where std::max is constexpr.
+ *
+ * Use a static_assert so we remember to remove it when we upgrade to a newer
+ * C++.
+ */
+static_assert(__cplusplus == 201103L, "");
+template <typename T>
+constexpr T max_constexpr(T l, T r)
+{
+       return l > r ? l : r;
+}
+
+enum consumer_dst_type {
+       CONSUMER_DST_LOCAL,
+       CONSUMER_DST_NET,
+};
+
+enum consumer_trace_chunk_exists_status {
+       CONSUMER_TRACE_CHUNK_EXISTS_STATUS_EXISTS_LOCAL,
+       CONSUMER_TRACE_CHUNK_EXISTS_STATUS_EXISTS_REMOTE,
+       CONSUMER_TRACE_CHUNK_EXISTS_STATUS_UNKNOWN_CHUNK,
+};
+
+struct consumer_socket {
+       /*
+        * File descriptor. This is just a reference to the consumer data meaning
+        * that every access must be locked and checked for a possible invalid
+        * value.
+        */
+       int *fd_ptr;
+
+       /*
+        * To use this socket (send/recv), this lock MUST be acquired.
+        */
+       pthread_mutex_t *lock;
+
+       /*
+        * Indicates if the socket was registered by a third part
+        * (REGISTER_CONSUMER) or is the spawn consumer of the session daemon.
+        * During the destroy phase of a consumer output, we close the socket if
+        * this flag is set to 1 since we don't need the fd anymore.
+        */
+       unsigned int registered;
+
+       /* Flag if network sockets were sent to the consumer. */
+       unsigned int control_sock_sent;
+       unsigned int data_sock_sent;
+
+       struct lttng_ht_node_ulong node;
+
+       enum lttng_consumer_type type;
+};
+
+struct consumer_data {
+       consumer_data (lttng_consumer_type type_)
+               : type(type_)
+       {}
+
+       enum lttng_consumer_type type;
+
+       /* Mutex to control consumerd pid assignation */
+       pthread_mutex_t pid_mutex = PTHREAD_MUTEX_INITIALIZER;
+       pid_t pid = 0;
+
+       int err_sock = -1;
+       /* These two sockets uses the cmd_unix_sock_path. */
+       int cmd_sock = -1;
+       /*
+        * Write-end of the channel monitoring pipe to be passed to the
+        * consumer.
+        */
+       int channel_monitor_pipe = -1;
+       /*
+        * The metadata socket object is handled differently and only created
+        * locally in this object thus it's the only reference available in the
+        * session daemon. For that reason, a variable for the fd is required and
+        * the metadata socket fd points to it.
+        */
+       int metadata_fd = 0;
+       struct consumer_socket metadata_sock {};
+
+       /* consumer error and command Unix socket path */
+       const char *err_unix_sock_path = nullptr;
+       const char *cmd_unix_sock_path = nullptr;
+
+       /*
+        * This lock has two purposes. It protects any change to the consumer
+        * socket and make sure only one thread uses this object for read/write
+        * operations.
+        */
+       pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+};
+
+/*
+ * Network URIs
+ */
+struct consumer_net {
+       /*
+        * Indicate if URI type is set. Those flags should only be set when the
+        * created URI is done AND valid.
+        */
+       int control_isset;
+       int data_isset;
+
+       /*
+        * The following two URIs MUST have the same destination address for
+        * network streaming to work. Network hop are not yet supported.
+        */
+
+       /* Control path for network streaming. */
+       struct lttng_uri control;
+
+       /* Data path for network streaming. */
+       struct lttng_uri data;
+
+       /* <hostname>/<session-name> */
+       char base_dir[PATH_MAX];
+};
+
+/*
+ * Consumer output object describing where and how to send data.
+ */
+struct consumer_output {
+       struct urcu_ref ref;    /* Refcount */
+
+       /* If the consumer is enabled meaning that should be used */
+       unsigned int enabled;
+       enum consumer_dst_type type;
+
+       /*
+        * The net_seq_index is the index of the network stream on the consumer
+        * side. It tells the consumer which streams goes to which relayd with this
+        * index. The relayd sockets are index with it on the consumer side.
+        */
+       uint64_t net_seq_index;
+       /* Store the relay protocol in use if the session is remote. */
+       uint32_t relay_major_version;
+       uint32_t relay_minor_version;
+
+       /* True if relayd supports the clear feature. */
+       bool relay_allows_clear;
+
+       /*
+        * Subdirectory path name used for both local and network
+        * consumer ("kernel", "ust", or empty).
+        */
+       char domain_subdir[
+               max_constexpr(sizeof(DEFAULT_KERNEL_TRACE_DIR),
+                       sizeof(DEFAULT_UST_TRACE_DIR))];
+
+       /*
+        * Hashtable of consumer_socket index by the file descriptor value. For
+        * multiarch consumer support, we can have more than one consumer (ex:
+        * 32 and 64 bit).
+        */
+       struct lttng_ht *socks;
+
+       /* Tell if this output is used for snapshot. */
+       unsigned int snapshot:1;
+
+       union {
+               char session_root_path[LTTNG_PATH_MAX];
+               struct consumer_net net;
+       } dst;
+
+       /*
+        * Sub-directory below the session_root_path where the next chunk of
+        * trace will be stored (\0 before the first session rotation).
+        */
+       char chunk_path[LTTNG_PATH_MAX];
+};
+
+struct consumer_socket *consumer_find_socket(int key,
+               const struct consumer_output *consumer);
+struct consumer_socket *consumer_find_socket_by_bitness(int bits,
+               const struct consumer_output *consumer);
+struct consumer_socket *consumer_allocate_socket(int *fd);
+void consumer_add_socket(struct consumer_socket *sock,
+               struct consumer_output *consumer);
+void consumer_del_socket(struct consumer_socket *sock,
+               struct consumer_output *consumer);
+void consumer_destroy_socket(struct consumer_socket *sock);
+int consumer_copy_sockets(struct consumer_output *dst,
+               struct consumer_output *src);
+void consumer_destroy_output_sockets(struct consumer_output *obj);
+int consumer_socket_send(struct consumer_socket *socket, const void *msg,
+               size_t len);
+int consumer_socket_recv(struct consumer_socket *socket, void *msg,
+               size_t len);
+
+struct consumer_output *consumer_create_output(enum consumer_dst_type type);
+struct consumer_output *consumer_copy_output(struct consumer_output *obj);
+void consumer_output_get(struct consumer_output *obj);
+void consumer_output_put(struct consumer_output *obj);
+int consumer_set_network_uri(const struct ltt_session *session,
+               struct consumer_output *obj,
+               struct lttng_uri *uri);
+int consumer_send_fds(struct consumer_socket *sock, const int *fds,
+               size_t nb_fd);
+int consumer_send_msg(struct consumer_socket *sock,
+               const struct lttcomm_consumer_msg *msg);
+int consumer_send_stream(struct consumer_socket *sock,
+               struct consumer_output *dst, struct lttcomm_consumer_msg *msg,
+               const int *fds, size_t nb_fd);
+int consumer_send_channel(struct consumer_socket *sock,
+               struct lttcomm_consumer_msg *msg);
+int consumer_send_relayd_socket(struct consumer_socket *consumer_sock,
+               struct lttcomm_relayd_sock *rsock, struct consumer_output *consumer,
+               enum lttng_stream_type type, uint64_t session_id,
+               const char *session_name, const char *hostname,
+               const char *base_path, int session_live_timer,
+               const uint64_t *current_chunk_id, time_t session_creation_time,
+               bool session_name_contains_creation_time);
+int consumer_send_channel_monitor_pipe(struct consumer_socket *consumer_sock,
+               int pipe);
+int consumer_send_destroy_relayd(struct consumer_socket *sock,
+               struct consumer_output *consumer);
+int consumer_recv_status_reply(struct consumer_socket *sock);
+int consumer_recv_status_channel(struct consumer_socket *sock,
+               uint64_t *key, unsigned int *stream_count);
+void consumer_output_send_destroy_relayd(struct consumer_output *consumer);
+int consumer_create_socket(struct consumer_data *data,
+               struct consumer_output *output);
+
+void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
+               uint64_t subbuf_size,
+               uint64_t num_subbuf,
+               int overwrite,
+               unsigned int switch_timer_interval,
+               unsigned int read_timer_interval,
+               unsigned int live_timer_interval,
+               bool is_in_live_session,
+               unsigned int monitor_timer_interval,
+               int output,
+               int type,
+               uint64_t session_id,
+               const char *pathname,
+               const char *name,
+               uint64_t relayd_id,
+               uint64_t key,
+               unsigned char *uuid,
+               uint32_t chan_id,
+               uint64_t tracefile_size,
+               uint64_t tracefile_count,
+               uint64_t session_id_per_pid,
+               unsigned int monitor,
+               uint32_t ust_app_uid,
+               int64_t blocking_timeout,
+               const char *root_shm_path,
+               const char *shm_path,
+               struct lttng_trace_chunk *trace_chunk,
+               const struct lttng_credentials *buffer_credentials);
+void consumer_init_add_stream_comm_msg(struct lttcomm_consumer_msg *msg,
+               uint64_t channel_key,
+               uint64_t stream_key,
+               int32_t cpu);
+void consumer_init_streams_sent_comm_msg(struct lttcomm_consumer_msg *msg,
+               enum lttng_consumer_command cmd,
+               uint64_t channel_key, uint64_t net_seq_idx);
+void consumer_init_add_channel_comm_msg(struct lttcomm_consumer_msg *msg,
+               uint64_t channel_key,
+               uint64_t session_id,
+               const char *pathname,
+               uint64_t relayd_id,
+               const char *name,
+               unsigned int nb_init_streams,
+               enum lttng_event_output output,
+               int type,
+               uint64_t tracefile_size,
+               uint64_t tracefile_count,
+               unsigned int monitor,
+               unsigned int live_timer_interval,
+               bool is_in_live_session,
+               unsigned int monitor_timer_interval,
+               struct lttng_trace_chunk *trace_chunk);
+int consumer_is_data_pending(uint64_t session_id,
+               struct consumer_output *consumer);
+int consumer_close_metadata(struct consumer_socket *socket,
+               uint64_t metadata_key);
+int consumer_setup_metadata(struct consumer_socket *socket,
+               uint64_t metadata_key);
+int consumer_push_metadata(struct consumer_socket *socket,
+               uint64_t metadata_key, char *metadata_str, size_t len,
+               size_t target_offset, uint64_t version);
+int consumer_flush_channel(struct consumer_socket *socket, uint64_t key);
+int consumer_clear_quiescent_channel(struct consumer_socket *socket, uint64_t key);
+int consumer_get_discarded_events(uint64_t session_id, uint64_t channel_key,
+               struct consumer_output *consumer, uint64_t *discarded);
+int consumer_get_lost_packets(uint64_t session_id, uint64_t channel_key,
+               struct consumer_output *consumer, uint64_t *lost);
+
+/* Snapshot command. */
+enum lttng_error_code consumer_snapshot_channel(struct consumer_socket *socket,
+               uint64_t key, const struct consumer_output *output, int metadata,
+               const char *channel_path, uint64_t nb_packets_per_stream);
+
+/* Rotation commands. */
+int consumer_rotate_channel(struct consumer_socket *socket, uint64_t key,
+               struct consumer_output *output, bool is_metadata_channel);
+int consumer_init(struct consumer_socket *socket,
+               const lttng_uuid sessiond_uuid);
+
+int consumer_create_trace_chunk(struct consumer_socket *socket,
+               uint64_t relayd_id, uint64_t session_id,
+               struct lttng_trace_chunk *chunk,
+               const char *domain_subdir);
+int consumer_close_trace_chunk(struct consumer_socket *socket,
+               uint64_t relayd_id, uint64_t session_id,
+               struct lttng_trace_chunk *chunk,
+               char *closed_trace_chunk_path);
+int consumer_trace_chunk_exists(struct consumer_socket *socket,
+               uint64_t relayd_id, uint64_t session_id,
+               struct lttng_trace_chunk *chunk,
+               enum consumer_trace_chunk_exists_status *result);
+int consumer_open_channel_packets(struct consumer_socket *socket, uint64_t key);
+
+char *setup_channel_trace_path(struct consumer_output *consumer,
+               const char *session_path, size_t *consumer_path_offset);
+
+/* Clear command */
+int consumer_clear_channel(struct consumer_socket *socket, uint64_t key);
+
+#endif /* _CONSUMER_H */
index 1f1fcb3c2111a2856a470ee63b9a97f0aa13a974..8dc82fbe82e70b538d41c2df88a1deb377df9412 100644 (file)
 #include <unistd.h>
 #include <urcu/list.h>
 
-#include <common/error.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-
-#include "context.h"
-#include "kernel.h"
-#include "ust-app.h"
-#include "trace-ust.h"
-#include "agent.h"
+#include <common/error.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include "context.hpp"
+#include "kernel.hpp"
+#include "ust-app.hpp"
+#include "trace-ust.hpp"
+#include "agent.hpp"
 
 /*
  * Add kernel context to all channel.
diff --git a/src/bin/lttng-sessiond/context.h b/src/bin/lttng-sessiond/context.h
deleted file mode 100644 (file)
index 073a2e1..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_CONTEXT_H
-#define _LTT_CONTEXT_H
-
-#include <lttng/lttng.h>
-
-#include "trace-kernel.h"
-#include "trace-ust.h"
-#include "lttng-ust-ctl.h"
-
-int context_kernel_add(struct ltt_kernel_session *ksession,
-               const struct lttng_event_context *ctx,
-               const char *channel_name);
-int context_ust_add(struct ltt_ust_session *usess,
-               enum lttng_domain_type domain,
-               const struct lttng_event_context *ctx,
-               const char *channel_name);
-
-#endif /* _LTT_CONTEXT_H */
diff --git a/src/bin/lttng-sessiond/context.hpp b/src/bin/lttng-sessiond/context.hpp
new file mode 100644 (file)
index 0000000..a55f571
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_CONTEXT_H
+#define _LTT_CONTEXT_H
+
+#include <lttng/lttng.h>
+
+#include "trace-kernel.hpp"
+#include "trace-ust.hpp"
+#include "lttng-ust-ctl.hpp"
+
+int context_kernel_add(struct ltt_kernel_session *ksession,
+               const struct lttng_event_context *ctx,
+               const char *channel_name);
+int context_ust_add(struct ltt_ust_session *usess,
+               enum lttng_domain_type domain,
+               const struct lttng_event_context *ctx,
+               const char *channel_name);
+
+#endif /* _LTT_CONTEXT_H */
index 6cbb26126f8c080c3a66428f9c589b77e034b7b0..7988f1ba8a212894dc09d7c3e8338f267b6fb221 100644 (file)
 #include <stddef.h>
 #include <stdlib.h>
 #include <urcu.h>
-#include <common/futex.h>
-#include <common/macros.h>
-
-#include "dispatch.h"
-#include "ust-app.h"
-#include "testpoint.h"
-#include "fd-limit.h"
-#include "health-sessiond.h"
-#include "lttng-sessiond.h"
-#include "thread.h"
+#include <common/futex.hpp>
+#include <common/macros.hpp>
+
+#include "dispatch.hpp"
+#include "ust-app.hpp"
+#include "testpoint.hpp"
+#include "fd-limit.hpp"
+#include "health-sessiond.hpp"
+#include "lttng-sessiond.hpp"
+#include "thread.hpp"
 
 struct thread_notifiers {
        struct ust_cmd_queue *ust_cmd_queue;
diff --git a/src/bin/lttng-sessiond/dispatch.h b/src/bin/lttng-sessiond/dispatch.h
deleted file mode 100644 (file)
index 7c8790e..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_UST_DISPATCH_THREAD_H
-#define SESSIOND_UST_DISPATCH_THREAD_H
-
-#include <stdbool.h>
-#include "lttng-sessiond.h"
-
-bool launch_ust_dispatch_thread(struct ust_cmd_queue *cmd_queue,
-               int apps_cmd_pipe_write_fd,
-               int apps_cmd_notify_write_fd);
-
-#endif /* SESSIOND_UST_DISPATCH_THREAD_H */
diff --git a/src/bin/lttng-sessiond/dispatch.hpp b/src/bin/lttng-sessiond/dispatch.hpp
new file mode 100644 (file)
index 0000000..d5ec8c9
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_UST_DISPATCH_THREAD_H
+#define SESSIOND_UST_DISPATCH_THREAD_H
+
+#include <stdbool.h>
+#include "lttng-sessiond.hpp"
+
+bool launch_ust_dispatch_thread(struct ust_cmd_queue *cmd_queue,
+               int apps_cmd_pipe_write_fd,
+               int apps_cmd_notify_write_fd);
+
+#endif /* SESSIOND_UST_DISPATCH_THREAD_H */
index 138d51b4df2fd2823979f32f3eec7c2ad08e74eb..10d69493bbc5a9ecfd42a87b87252d3b7faf3d22 100644 (file)
 #include <urcu/compiler.h>
 #include <pthread.h>
 
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/index-allocator.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/shm.h>
-#include <lttng/trigger/trigger-internal.h>
-
-#include "event-notifier-error-accounting.h"
-#include "lttng-ust-error.h"
-#include "ust-app.h"
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/index-allocator.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/shm.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+
+#include "event-notifier-error-accounting.hpp"
+#include "lttng-ust-error.hpp"
+#include "ust-app.hpp"
 
 #define ERROR_COUNTER_INDEX_HT_INITIAL_SIZE 16
 
diff --git a/src/bin/lttng-sessiond/event-notifier-error-accounting.h b/src/bin/lttng-sessiond/event-notifier-error-accounting.h
deleted file mode 100644 (file)
index 440b9d0..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _EVENT_NOTIFIER_ERROR_ACCOUNTING_H
-#define _EVENT_NOTIFIER_ERROR_ACCOUNTING_H
-
-#include <stdint.h>
-
-#include <lttng/trigger/trigger.h>
-
-#include "ust-app.h"
-
-enum event_notifier_error_accounting_status {
-       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK,
-       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR,
-       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOT_FOUND,
-       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM,
-       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE,
-       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD,
-       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_UNSUPPORTED,
-};
-
-/*
- * Initialize the event notifier error accounting system.
- * `buffer_size_kernel` and `buffer_size_ust` represent the number of buckets
- * to be allocated for each domain.
- */
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_init(uint64_t buffer_size_kernel,
-               uint64_t buffer_size_ust);
-
-/*
- * Register the kernel event notifier group.
- * This allocates the counter object on the kernel side.
- */
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_register_kernel(
-               int kernel_event_notifier_group_fd);
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-/*
- * Register a UST application.
- *
- * This reuses (or creates) the counter object of the app UID.
- */
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_register_app(struct ust_app *app);
-
-/*
- * Unregister a UST application.
- */
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_unregister_app(struct ust_app *app);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_register_app(
-               struct ust_app *app __attribute__((unused)))
-{
-       return EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
-}
-
-static inline
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_unregister_app(
-               struct ust_app *app __attribute__((unused)))
-{
-       return EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
-}
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-/*
- * Allocates, reserves and returns the error counter index for that trigger.
- */
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_register_event_notifier(
-               const struct lttng_trigger *trigger,
-               uint64_t *error_counter_index);
-
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_get_count(
-               const struct lttng_trigger *trigger,
-               uint64_t *count);
-
-void event_notifier_error_accounting_unregister_event_notifier(
-               const struct lttng_trigger *trigger);
-
-void event_notifier_error_accounting_fini(void);
-
-#endif /* _EVENT_NOTIFIER_ERROR_ACCOUNTING_H */
diff --git a/src/bin/lttng-sessiond/event-notifier-error-accounting.hpp b/src/bin/lttng-sessiond/event-notifier-error-accounting.hpp
new file mode 100644 (file)
index 0000000..89466bd
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _EVENT_NOTIFIER_ERROR_ACCOUNTING_H
+#define _EVENT_NOTIFIER_ERROR_ACCOUNTING_H
+
+#include <stdint.h>
+
+#include <lttng/trigger/trigger.h>
+
+#include "ust-app.hpp"
+
+enum event_notifier_error_accounting_status {
+       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK,
+       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR,
+       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOT_FOUND,
+       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM,
+       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE,
+       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD,
+       EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_UNSUPPORTED,
+};
+
+/*
+ * Initialize the event notifier error accounting system.
+ * `buffer_size_kernel` and `buffer_size_ust` represent the number of buckets
+ * to be allocated for each domain.
+ */
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_init(uint64_t buffer_size_kernel,
+               uint64_t buffer_size_ust);
+
+/*
+ * Register the kernel event notifier group.
+ * This allocates the counter object on the kernel side.
+ */
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_register_kernel(
+               int kernel_event_notifier_group_fd);
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+/*
+ * Register a UST application.
+ *
+ * This reuses (or creates) the counter object of the app UID.
+ */
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_register_app(struct ust_app *app);
+
+/*
+ * Unregister a UST application.
+ */
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_unregister_app(struct ust_app *app);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_register_app(
+               struct ust_app *app __attribute__((unused)))
+{
+       return EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
+}
+
+static inline
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_unregister_app(
+               struct ust_app *app __attribute__((unused)))
+{
+       return EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
+}
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+/*
+ * Allocates, reserves and returns the error counter index for that trigger.
+ */
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_register_event_notifier(
+               const struct lttng_trigger *trigger,
+               uint64_t *error_counter_index);
+
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_get_count(
+               const struct lttng_trigger *trigger,
+               uint64_t *count);
+
+void event_notifier_error_accounting_unregister_event_notifier(
+               const struct lttng_trigger *trigger);
+
+void event_notifier_error_accounting_fini(void);
+
+#endif /* _EVENT_NOTIFIER_ERROR_ACCOUNTING_H */
index 924df3af175e19bc1e4eedce455ef37487ae0cfa..797219dff8cf893be2c5055b6026aea15e3a2b3a 100644 (file)
 #include <urcu/list.h>
 #include <string.h>
 
-#include <common/compat/errno.h>
+#include <common/compat/errno.hpp>
 #include <lttng/lttng.h>
 #include <lttng/condition/condition.h>
 #include <lttng/condition/event-rule-matches.h>
 #include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <common/bytecode/bytecode.h>
-#include <common/error.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/filter.h>
-#include <common/context.h>
-
-#include "channel.h"
-#include "event.h"
-#include "kernel.h"
-#include "lttng-sessiond.h"
-#include "lttng-ust-ctl.h"
-#include "lttng-ust-error.h"
-#include "ust-app.h"
-#include "trace-kernel.h"
-#include "trace-ust.h"
-#include "agent.h"
-#include "utils.h"
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <common/bytecode/bytecode.hpp>
+#include <common/error.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/filter.hpp>
+#include <common/context.hpp>
+
+#include "channel.hpp"
+#include "event.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "lttng-ust-error.hpp"
+#include "ust-app.hpp"
+#include "trace-kernel.hpp"
+#include "trace-ust.hpp"
+#include "agent.hpp"
+#include "utils.hpp"
 
 /*
  * Add unique UST event based on the event name, filter bytecode and loglevel.
diff --git a/src/bin/lttng-sessiond/event.h b/src/bin/lttng-sessiond/event.h
deleted file mode 100644 (file)
index 01be565..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_EVENT_H
-#define _LTT_EVENT_H
-
-#include "trace-kernel.h"
-
-struct agent;
-
-int event_kernel_disable_event(struct ltt_kernel_channel *kchan,
-               const char *event_name, enum lttng_event_type event_type);
-
-int event_kernel_enable_event(struct ltt_kernel_channel *kchan,
-               struct lttng_event *event, char *filter_expression,
-               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_bytecode *filter,
-               struct lttng_event_exclusion *exclusion,
-               bool internal_event);
-int event_ust_disable_tracepoint(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan, const char *event_name);
-
-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_bytecode *filter,
-               char *filter_expression);
-int event_agent_enable_all(struct ltt_ust_session *usess, struct agent *agt,
-               struct lttng_event *event, struct lttng_bytecode *filter,
-               char *filter_expression);
-
-int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt,
-               const char *event_name);
-int event_agent_disable_all(struct ltt_ust_session *usess, struct agent *agt);
-
-int trigger_agent_enable(
-               const struct lttng_trigger *trigger, struct agent *agt);
-int trigger_agent_disable(
-               const struct lttng_trigger *trigger, struct agent *agt);
-
-const char *event_get_default_agent_ust_name(enum lttng_domain_type domain);
-
-#endif /* _LTT_EVENT_H */
diff --git a/src/bin/lttng-sessiond/event.hpp b/src/bin/lttng-sessiond/event.hpp
new file mode 100644 (file)
index 0000000..efc4ad5
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_EVENT_H
+#define _LTT_EVENT_H
+
+#include "trace-kernel.hpp"
+
+struct agent;
+
+int event_kernel_disable_event(struct ltt_kernel_channel *kchan,
+               const char *event_name, enum lttng_event_type event_type);
+
+int event_kernel_enable_event(struct ltt_kernel_channel *kchan,
+               struct lttng_event *event, char *filter_expression,
+               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_bytecode *filter,
+               struct lttng_event_exclusion *exclusion,
+               bool internal_event);
+int event_ust_disable_tracepoint(struct ltt_ust_session *usess,
+               struct ltt_ust_channel *uchan, const char *event_name);
+
+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_bytecode *filter,
+               char *filter_expression);
+int event_agent_enable_all(struct ltt_ust_session *usess, struct agent *agt,
+               struct lttng_event *event, struct lttng_bytecode *filter,
+               char *filter_expression);
+
+int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt,
+               const char *event_name);
+int event_agent_disable_all(struct ltt_ust_session *usess, struct agent *agt);
+
+int trigger_agent_enable(
+               const struct lttng_trigger *trigger, struct agent *agt);
+int trigger_agent_disable(
+               const struct lttng_trigger *trigger, struct agent *agt);
+
+const char *event_get_default_agent_ust_name(enum lttng_domain_type domain);
+
+#endif /* _LTT_EVENT_H */
index 684332e9f6d88fd47e43a5676f97d6d058782f9c..ac5c83f4b19775beed137606c483d20dadb3ecd9 100644 (file)
@@ -10,9 +10,9 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <stdio.h>
-#include "fd-limit.h"
-#include <common/error.h>
-#include <common/compat/errno.h>
+#include "fd-limit.hpp"
+#include <common/error.hpp>
+#include <common/compat/errno.hpp>
 
 /* total count of fd. */
 static long fd_count;
diff --git a/src/bin/lttng-sessiond/fd-limit.h b/src/bin/lttng-sessiond/fd-limit.h
deleted file mode 100644 (file)
index 8666cdc..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _LTTNG_FD_LIMIT_H
-#define _LTTNG_FD_LIMIT_H
-
-/*
- * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-enum lttng_fd_type {
-       LTTNG_FD_APPS,
-       LTTNG_FD_NR_TYPES,
-};
-
-int lttng_fd_get(enum lttng_fd_type type, unsigned int nr);
-void lttng_fd_put(enum lttng_fd_type type, unsigned int nr);
-void lttng_fd_init(void);
-
-#endif /* _LTTNG_FD_LIMIT_H */
diff --git a/src/bin/lttng-sessiond/fd-limit.hpp b/src/bin/lttng-sessiond/fd-limit.hpp
new file mode 100644 (file)
index 0000000..8666cdc
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef _LTTNG_FD_LIMIT_H
+#define _LTTNG_FD_LIMIT_H
+
+/*
+ * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+enum lttng_fd_type {
+       LTTNG_FD_APPS,
+       LTTNG_FD_NR_TYPES,
+};
+
+int lttng_fd_get(enum lttng_fd_type type, unsigned int nr);
+void lttng_fd_put(enum lttng_fd_type type, unsigned int nr);
+void lttng_fd_init(void);
+
+#endif /* _LTTNG_FD_LIMIT_H */
index d0747831691bc8ca8b49662ffa15370508565c78..c8710d62abeac9764e31c2b04d3d98139ba77d5d 100644 (file)
@@ -7,8 +7,8 @@
  *
  */
 
-#include "lttng-sessiond.h"
-#include <common/uuid.h>
+#include "lttng-sessiond.hpp"
+#include <common/uuid.hpp>
 
 lttng_uuid the_sessiond_uuid;
 
diff --git a/src/bin/lttng-sessiond/health-sessiond.h b/src/bin/lttng-sessiond/health-sessiond.h
deleted file mode 100644 (file)
index 163676a..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef HEALTH_SESSIOND_H
-#define HEALTH_SESSIOND_H
-
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <lttng/health-internal.h>
-#include <stdbool.h>
-
-enum health_type_sessiond {
-       HEALTH_SESSIOND_TYPE_CMD                = 0,
-       HEALTH_SESSIOND_TYPE_APP_MANAGE         = 1,
-       HEALTH_SESSIOND_TYPE_APP_REG            = 2,
-       HEALTH_SESSIOND_TYPE_KERNEL             = 3,
-       HEALTH_SESSIOND_TYPE_CONSUMER           = 4,
-       HEALTH_SESSIOND_TYPE_APP_MANAGE_NOTIFY  = 6,
-       HEALTH_SESSIOND_TYPE_APP_REG_DISPATCH   = 7,
-       HEALTH_SESSIOND_TYPE_NOTIFICATION       = 8,
-       HEALTH_SESSIOND_TYPE_ROTATION           = 9,
-       HEALTH_SESSIOND_TYPE_TIMER              = 10,
-       HEALTH_SESSIOND_TYPE_ACTION_EXECUTOR    = 11,
-
-       NR_HEALTH_SESSIOND_TYPES,
-};
-
-/* Application health monitoring */
-extern struct health_app *the_health_sessiond;
-
-bool launch_health_management_thread(void);
-
-#endif /* HEALTH_SESSIOND_H */
diff --git a/src/bin/lttng-sessiond/health-sessiond.hpp b/src/bin/lttng-sessiond/health-sessiond.hpp
new file mode 100644 (file)
index 0000000..52f38e2
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef HEALTH_SESSIOND_H
+#define HEALTH_SESSIOND_H
+
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <lttng/health-internal.hpp>
+#include <stdbool.h>
+
+enum health_type_sessiond {
+       HEALTH_SESSIOND_TYPE_CMD                = 0,
+       HEALTH_SESSIOND_TYPE_APP_MANAGE         = 1,
+       HEALTH_SESSIOND_TYPE_APP_REG            = 2,
+       HEALTH_SESSIOND_TYPE_KERNEL             = 3,
+       HEALTH_SESSIOND_TYPE_CONSUMER           = 4,
+       HEALTH_SESSIOND_TYPE_APP_MANAGE_NOTIFY  = 6,
+       HEALTH_SESSIOND_TYPE_APP_REG_DISPATCH   = 7,
+       HEALTH_SESSIOND_TYPE_NOTIFICATION       = 8,
+       HEALTH_SESSIOND_TYPE_ROTATION           = 9,
+       HEALTH_SESSIOND_TYPE_TIMER              = 10,
+       HEALTH_SESSIOND_TYPE_ACTION_EXECUTOR    = 11,
+
+       NR_HEALTH_SESSIOND_TYPES,
+};
+
+/* Application health monitoring */
+extern struct health_app *the_health_sessiond;
+
+bool launch_health_management_thread(void);
+
+#endif /* HEALTH_SESSIOND_H */
index 53b9ee01f0e362171dcee85fcb888f26da49c8a5..a7f4bdcbb534dc82ae6b6cebaae876043a8f71f5 100644 (file)
@@ -6,16 +6,16 @@
  *
  */
 
-#include "lttng-sessiond.h"
-#include "health-sessiond.h"
-#include <common/macros.h>
-#include <common/error.h>
-#include <common/utils.h>
-#include <common/pipe.h>
+#include "lttng-sessiond.hpp"
+#include "health-sessiond.hpp"
+#include <common/macros.hpp>
+#include <common/error.hpp>
+#include <common/utils.hpp>
+#include <common/pipe.hpp>
 #include <inttypes.h>
 #include <sys/stat.h>
-#include "utils.h"
-#include "thread.h"
+#include "utils.hpp"
+#include "thread.hpp"
 
 struct thread_notifiers {
        struct lttng_pipe *quit_pipe;
diff --git a/src/bin/lttng-sessiond/kern-modules.h b/src/bin/lttng-sessiond/kern-modules.h
deleted file mode 100644 (file)
index d914362..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _KERN_MODULES_H
-#define _KERN_MODULES_H
-
-/*
- * Compatible lttng-modules version.
- */
-#define KERN_MODULES_PRE_MAJOR     1
-#define KERN_MODULES_PRE_MINOR     9
-
-#define KERN_MODULES_MAJOR         2
-#define KERN_MODULES_MINOR         0
-
-enum kernel_module_property_load_policy {
-       KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED = 0,
-       KERNEL_MODULE_PROPERTY_LOAD_POLICY_OPTIONAL = 1,
-};
-
-struct kern_modules_param {
-       char *name;
-    enum kernel_module_property_load_policy load_policy;
-       bool loaded;
-};
-
-#endif /* _KERN_MODULES_H */
diff --git a/src/bin/lttng-sessiond/kern-modules.hpp b/src/bin/lttng-sessiond/kern-modules.hpp
new file mode 100644 (file)
index 0000000..d914362
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _KERN_MODULES_H
+#define _KERN_MODULES_H
+
+/*
+ * Compatible lttng-modules version.
+ */
+#define KERN_MODULES_PRE_MAJOR     1
+#define KERN_MODULES_PRE_MINOR     9
+
+#define KERN_MODULES_MAJOR         2
+#define KERN_MODULES_MINOR         0
+
+enum kernel_module_property_load_policy {
+       KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED = 0,
+       KERNEL_MODULE_PROPERTY_LOAD_POLICY_OPTIONAL = 1,
+};
+
+struct kern_modules_param {
+       char *name;
+    enum kernel_module_property_load_policy load_policy;
+       bool loaded;
+};
+
+#endif /* _KERN_MODULES_H */
index d224b4cb741545daabcb653cd9944893620dbf6e..844f535416a80ee02dd055083e3555964b29b9f1 100644 (file)
 #include <unistd.h>
 #include <inttypes.h>
 
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/compat/string.h>
-
-#include "consumer.h"
-#include "health-sessiond.h"
-#include "kernel-consumer.h"
-#include "notification-thread-commands.h"
-#include "session.h"
-#include "lttng-sessiond.h"
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/compat/string.hpp>
+
+#include "consumer.hpp"
+#include "health-sessiond.hpp"
+#include "kernel-consumer.hpp"
+#include "notification-thread-commands.hpp"
+#include "session.hpp"
+#include "lttng-sessiond.hpp"
 
 static char *create_channel_path(struct consumer_output *consumer,
                size_t *consumer_path_offset)
diff --git a/src/bin/lttng-sessiond/kernel-consumer.h b/src/bin/lttng-sessiond/kernel-consumer.h
deleted file mode 100644 (file)
index 3177170..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <sys/types.h>
-
-#include <common/sessiond-comm/sessiond-comm.h>
-
-#include "trace-kernel.h"
-
-int kernel_consumer_send_channel_streams(struct consumer_socket *sock,
-               struct ltt_kernel_channel *channel, struct ltt_kernel_session *session,
-               unsigned int monitor);
-
-int kernel_consumer_send_session(struct consumer_socket *sock,
-               struct ltt_kernel_session *session);
-
-int kernel_consumer_add_metadata(struct consumer_socket *sock,
-               struct ltt_kernel_session *session, unsigned int monitor);
-
-int kernel_consumer_destroy_channel(struct consumer_socket *socket,
-               struct ltt_kernel_channel *channel);
-
-int kernel_consumer_destroy_metadata(struct consumer_socket *socket,
-               struct ltt_kernel_metadata *metadata);
-
-int kernel_consumer_streams_sent(struct consumer_socket *sock,
-               struct ltt_kernel_session *session, uint64_t channel_key);
diff --git a/src/bin/lttng-sessiond/kernel-consumer.hpp b/src/bin/lttng-sessiond/kernel-consumer.hpp
new file mode 100644 (file)
index 0000000..276312e
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <sys/types.h>
+
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include "trace-kernel.hpp"
+
+int kernel_consumer_send_channel_streams(struct consumer_socket *sock,
+               struct ltt_kernel_channel *channel, struct ltt_kernel_session *session,
+               unsigned int monitor);
+
+int kernel_consumer_send_session(struct consumer_socket *sock,
+               struct ltt_kernel_session *session);
+
+int kernel_consumer_add_metadata(struct consumer_socket *sock,
+               struct ltt_kernel_session *session, unsigned int monitor);
+
+int kernel_consumer_destroy_channel(struct consumer_socket *socket,
+               struct ltt_kernel_channel *channel);
+
+int kernel_consumer_destroy_metadata(struct consumer_socket *socket,
+               struct ltt_kernel_metadata *metadata);
+
+int kernel_consumer_streams_sent(struct consumer_socket *sock,
+               struct ltt_kernel_session *session, uint64_t channel_key);
index c4662af0d011a8aa43e14221e372253d139fda52..9d256e2075373c7dbb1de925a2f759129e6742bd 100644 (file)
 #include <inttypes.h>
 #include <sys/types.h>
 
-#include <common/common.h>
-#include <common/hashtable/utils.h>
-#include <common/trace-chunk.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/kernel-ctl/kernel-ioctl.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/tracker.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/kernel-ctl/kernel-ioctl.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/tracker.hpp>
+#include <common/utils.hpp>
 #include <lttng/event.h>
 #include <lttng/lttng-error.h>
 #include <lttng/tracker.h>
 
 #include <lttng/userspace-probe.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/userspace-probe-internal.hpp>
 #include <lttng/condition/event-rule-matches.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/event-rule-matches-internal.hpp>
 #include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-uprobe-internal.h>
-
-#include "event-notifier-error-accounting.h"
-#include "lttng-sessiond.h"
-#include "lttng-syscall.h"
-#include "condition-internal.h"
-#include "consumer.h"
-#include "kernel.h"
-#include "kernel-consumer.h"
-#include "kern-modules.h"
-#include "sessiond-config.h"
-#include "utils.h"
-#include "rotate.h"
-#include "modprobe.h"
-#include "tracker.h"
-#include "notification-thread-commands.h"
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-uprobe-internal.hpp>
+
+#include "event-notifier-error-accounting.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng-syscall.hpp"
+#include "condition-internal.hpp"
+#include "consumer.hpp"
+#include "kernel.hpp"
+#include "kernel-consumer.hpp"
+#include "kern-modules.hpp"
+#include "sessiond-config.hpp"
+#include "utils.hpp"
+#include "rotate.hpp"
+#include "modprobe.hpp"
+#include "tracker.hpp"
+#include "notification-thread-commands.hpp"
 
 /*
  * Key used to reference a channel between the sessiond and the consumer. This
diff --git a/src/bin/lttng-sessiond/kernel.h b/src/bin/lttng-sessiond/kernel.h
deleted file mode 100644 (file)
index 4eb788d..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_KERNEL_CTL_H
-#define _LTT_KERNEL_CTL_H
-
-#include "lttng/lttng-error.h"
-#include "lttng/tracker.h"
-#include "session.h"
-#include "snapshot.h"
-#include "trace-kernel.h"
-
-/*
- * Default size for the event list when kernel_list_events is called. This size
- * value is based on the initial LTTng 2.0 version set of tracepoints.
- *
- * This is NOT an upper bound because if the real event list size is bigger,
- * dynamic reallocation is performed.
- */
-#define KERNEL_EVENT_INIT_LIST_SIZE 64
-
-int kernel_add_channel_context(struct ltt_kernel_channel *chan,
-               struct ltt_kernel_context *ctx);
-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_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);
-int kernel_enable_channel(struct ltt_kernel_channel *chan);
-enum lttng_error_code kernel_process_attr_tracker_set_tracking_policy(
-               struct ltt_kernel_session *session,
-               enum lttng_process_attr process_attr,
-               enum lttng_tracking_policy policy);
-enum lttng_error_code kernel_process_attr_tracker_inclusion_set_add_value(
-               struct ltt_kernel_session *session,
-               enum lttng_process_attr process_attr,
-               const struct process_attr_value *value);
-enum lttng_error_code kernel_process_attr_tracker_inclusion_set_remove_value(
-               struct ltt_kernel_session *session,
-               enum lttng_process_attr process_attr,
-               const struct process_attr_value *value);
-const struct process_attr_tracker *kernel_get_process_attr_tracker(
-               struct ltt_kernel_session *session,
-               enum lttng_process_attr process_attr);
-int kernel_open_metadata(struct ltt_kernel_session *session);
-int kernel_open_metadata_stream(struct ltt_kernel_session *session);
-int kernel_open_channel_stream(struct ltt_kernel_channel *channel);
-int kernel_flush_buffer(struct ltt_kernel_channel *channel);
-int kernel_metadata_flush_buffer(int fd);
-int kernel_start_session(struct ltt_kernel_session *session);
-int kernel_stop_session(struct ltt_kernel_session *session);
-ssize_t kernel_list_events(struct lttng_event **event_list);
-void kernel_wait_quiescent(void);
-int kernel_validate_version(struct lttng_kernel_abi_tracer_version *kernel_tracer_version,
-               struct lttng_kernel_abi_tracer_abi_version *kernel_tracer_abi_version);
-void kernel_destroy_session(struct ltt_kernel_session *ksess);
-void kernel_free_session(struct ltt_kernel_session *ksess);
-void kernel_destroy_channel(struct ltt_kernel_channel *kchan);
-enum lttng_error_code kernel_snapshot_record(
-               struct ltt_kernel_session *ksess,
-               const struct consumer_output *output,
-               uint64_t nb_packets_per_stream);
-int kernel_syscall_mask(int chan_fd, char **syscall_mask, uint32_t *nr_bits);
-enum lttng_error_code kernel_rotate_session(struct ltt_session *session);
-enum lttng_error_code kernel_clear_session(struct ltt_session *session);
-
-int init_kernel_workarounds(void);
-int kernel_supports_ring_buffer_snapshot_sample_positions(void);
-int kernel_supports_ring_buffer_packet_sequence_number(void);
-int kernel_supports_event_notifiers(void);
-int init_kernel_tracer(void);
-void cleanup_kernel_tracer(void);
-bool kernel_tracer_is_initialized(void);
-
-enum lttng_error_code kernel_create_channel_subdirectories(
-               const struct ltt_kernel_session *ksess);
-
-enum lttng_error_code kernel_create_event_notifier_group_notification_fd(
-               int *event_notifier_group_notification_fd);
-enum lttng_error_code kernel_destroy_event_notifier_group_notification_fd(
-               int event_notifier_group_notification_fd);
-
-enum lttng_error_code kernel_register_event_notifier(
-               struct lttng_trigger *trigger,
-               const struct lttng_credentials *cmd_creds);
-enum lttng_error_code kernel_unregister_event_notifier(
-               const struct lttng_trigger *trigger);
-
-int kernel_get_notification_fd(void);
-
-#endif /* _LTT_KERNEL_CTL_H */
diff --git a/src/bin/lttng-sessiond/kernel.hpp b/src/bin/lttng-sessiond/kernel.hpp
new file mode 100644 (file)
index 0000000..bb01651
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_KERNEL_CTL_H
+#define _LTT_KERNEL_CTL_H
+
+#include "lttng/lttng-error.h"
+#include "lttng/tracker.h"
+#include "session.hpp"
+#include "snapshot.hpp"
+#include "trace-kernel.hpp"
+
+/*
+ * Default size for the event list when kernel_list_events is called. This size
+ * value is based on the initial LTTng 2.0 version set of tracepoints.
+ *
+ * This is NOT an upper bound because if the real event list size is bigger,
+ * dynamic reallocation is performed.
+ */
+#define KERNEL_EVENT_INIT_LIST_SIZE 64
+
+int kernel_add_channel_context(struct ltt_kernel_channel *chan,
+               struct ltt_kernel_context *ctx);
+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_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);
+int kernel_enable_channel(struct ltt_kernel_channel *chan);
+enum lttng_error_code kernel_process_attr_tracker_set_tracking_policy(
+               struct ltt_kernel_session *session,
+               enum lttng_process_attr process_attr,
+               enum lttng_tracking_policy policy);
+enum lttng_error_code kernel_process_attr_tracker_inclusion_set_add_value(
+               struct ltt_kernel_session *session,
+               enum lttng_process_attr process_attr,
+               const struct process_attr_value *value);
+enum lttng_error_code kernel_process_attr_tracker_inclusion_set_remove_value(
+               struct ltt_kernel_session *session,
+               enum lttng_process_attr process_attr,
+               const struct process_attr_value *value);
+const struct process_attr_tracker *kernel_get_process_attr_tracker(
+               struct ltt_kernel_session *session,
+               enum lttng_process_attr process_attr);
+int kernel_open_metadata(struct ltt_kernel_session *session);
+int kernel_open_metadata_stream(struct ltt_kernel_session *session);
+int kernel_open_channel_stream(struct ltt_kernel_channel *channel);
+int kernel_flush_buffer(struct ltt_kernel_channel *channel);
+int kernel_metadata_flush_buffer(int fd);
+int kernel_start_session(struct ltt_kernel_session *session);
+int kernel_stop_session(struct ltt_kernel_session *session);
+ssize_t kernel_list_events(struct lttng_event **event_list);
+void kernel_wait_quiescent(void);
+int kernel_validate_version(struct lttng_kernel_abi_tracer_version *kernel_tracer_version,
+               struct lttng_kernel_abi_tracer_abi_version *kernel_tracer_abi_version);
+void kernel_destroy_session(struct ltt_kernel_session *ksess);
+void kernel_free_session(struct ltt_kernel_session *ksess);
+void kernel_destroy_channel(struct ltt_kernel_channel *kchan);
+enum lttng_error_code kernel_snapshot_record(
+               struct ltt_kernel_session *ksess,
+               const struct consumer_output *output,
+               uint64_t nb_packets_per_stream);
+int kernel_syscall_mask(int chan_fd, char **syscall_mask, uint32_t *nr_bits);
+enum lttng_error_code kernel_rotate_session(struct ltt_session *session);
+enum lttng_error_code kernel_clear_session(struct ltt_session *session);
+
+int init_kernel_workarounds(void);
+int kernel_supports_ring_buffer_snapshot_sample_positions(void);
+int kernel_supports_ring_buffer_packet_sequence_number(void);
+int kernel_supports_event_notifiers(void);
+int init_kernel_tracer(void);
+void cleanup_kernel_tracer(void);
+bool kernel_tracer_is_initialized(void);
+
+enum lttng_error_code kernel_create_channel_subdirectories(
+               const struct ltt_kernel_session *ksess);
+
+enum lttng_error_code kernel_create_event_notifier_group_notification_fd(
+               int *event_notifier_group_notification_fd);
+enum lttng_error_code kernel_destroy_event_notifier_group_notification_fd(
+               int event_notifier_group_notification_fd);
+
+enum lttng_error_code kernel_register_event_notifier(
+               struct lttng_trigger *trigger,
+               const struct lttng_credentials *cmd_creds);
+enum lttng_error_code kernel_unregister_event_notifier(
+               const struct lttng_trigger *trigger);
+
+int kernel_get_notification_fd(void);
+
+#endif /* _LTT_KERNEL_CTL_H */
diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h
deleted file mode 100644 (file)
index 5dad32f..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2013 Raphaël Beamonte <raphael.beamonte@gmail.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_SESSIOND_H
-#define _LTT_SESSIOND_H
-
-#include <urcu.h>
-#include <urcu/wfcqueue.h>
-
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/payload.h>
-#include <common/compat/poll.h>
-#include <common/compat/socket.h>
-#include <common/uuid.h>
-
-#include "session.h"
-#include "ust-app.h"
-#include "notification-thread.h"
-#include "sessiond-config.h"
-
-/*
- * Consumer daemon state which is changed when spawning it, killing it or in
- * case of a fatal error.
- */
-enum consumerd_state {
-       CONSUMER_STARTED = 1,
-       CONSUMER_STOPPED = 2,
-       CONSUMER_ERROR   = 3,
-};
-
-/* Unique identifier of a session daemon instance. */
-extern lttng_uuid the_sessiond_uuid;
-
-/*
- * This consumer daemon state is used to validate if a client command will be
- * able to reach the consumer. If not, the client is informed. For instance,
- * doing a "lttng start" when the consumer state is set to ERROR will return an
- * error to the client.
- *
- * The following example shows a possible race condition of this scheme:
- *
- * consumer thread error happens
- *                                    client cmd arrives
- *                                    client cmd checks state -> still OK
- * consumer thread exit, sets error
- *                                    client cmd try to talk to consumer
- *                                    ...
- *
- * However, since the consumer is a different daemon, we have no way of making
- * sure the command will reach it safely even with this state flag. This is why
- * we consider that up to the state validation during command processing, the
- * command is safe. After that, we can not guarantee the correctness of the
- * client request vis-a-vis the consumer.
- */
-extern enum consumerd_state the_ust_consumerd_state;
-extern enum consumerd_state the_kernel_consumerd_state;
-
-/* Set in main.c at boot time of the daemon */
-extern struct lttng_kernel_abi_tracer_version the_kernel_tracer_version;
-extern struct lttng_kernel_abi_tracer_abi_version the_kernel_tracer_abi_version;
-
-/* Notification thread handle. */
-extern struct notification_thread_handle *the_notification_thread_handle;
-
-/*
- * This contains extra data needed for processing a command received by the
- * session daemon from the lttng client.
- */
-struct command_ctx {
-       unsigned int lttng_msg_size;
-       struct ltt_session *session;
-       /* Input message */
-       struct lttcomm_session_msg lsm;
-       /* Reply content, starts with an lttcomm_lttng_msg header. */
-       struct lttng_payload reply_payload;
-       lttng_sock_cred creds;
-};
-
-struct ust_command {
-       int sock;
-       struct ust_register_msg reg_msg;
-       struct cds_wfcq_node node;
-};
-
-/*
- * Queue used to enqueue UST registration request (ust_command) and synchronized
- * by a futex with a scheme N wakers / 1 waiters. See futex.c/.h
- */
-struct ust_cmd_queue {
-       int32_t futex;
-       struct cds_wfcq_head head;
-       struct cds_wfcq_tail tail;
-};
-
-/*
- * This is the wait queue containing wait nodes during the application
- * registration process.
- */
-struct ust_reg_wait_queue {
-       unsigned long count;
-       struct cds_list_head head;
-};
-
-/*
- * Use by the dispatch registration to queue UST command socket to wait for the
- * notify socket.
- */
-struct ust_reg_wait_node {
-       struct ust_app *app;
-       struct cds_list_head head;
-};
-
-extern int the_kernel_poll_pipe[2];
-
-/*
- * Populated when the daemon starts with the current page size of the system.
- * Set in main() with the current page size.
- */
-extern long the_page_size;
-
-/* Application health monitoring */
-extern struct health_app *the_health_sessiond;
-
-extern struct sessiond_config the_config;
-
-extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
-
-/* Parent PID for --sig-parent option */
-extern pid_t the_ppid;
-/* Internal parent PID use with daemonize. */
-extern pid_t the_child_ppid;
-
-/* Consumer daemon specific control data. */
-extern struct consumer_data the_ustconsumer32_data;
-extern struct consumer_data the_ustconsumer64_data;
-extern struct consumer_data the_kconsumer_data;
-
-int sessiond_init_thread_quit_pipe(void);
-int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
-int sessiond_wait_for_quit_pipe(int timeout_ms);
-int sessiond_notify_quit_pipe(void);
-void sessiond_close_quit_pipe(void);
-
-int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
-void sessiond_signal_parents(void);
-
-void sessiond_set_client_thread_state(bool running);
-void sessiond_wait_client_thread_stopped(void);
-
-void *thread_manage_consumer(void *data);
-
-#endif /* _LTT_SESSIOND_H */
diff --git a/src/bin/lttng-sessiond/lttng-sessiond.hpp b/src/bin/lttng-sessiond/lttng-sessiond.hpp
new file mode 100644 (file)
index 0000000..fa4601d
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2013 Raphaël Beamonte <raphael.beamonte@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_SESSIOND_H
+#define _LTT_SESSIOND_H
+
+#include <urcu.h>
+#include <urcu/wfcqueue.h>
+
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/payload.hpp>
+#include <common/compat/poll.hpp>
+#include <common/compat/socket.hpp>
+#include <common/uuid.hpp>
+
+#include "session.hpp"
+#include "ust-app.hpp"
+#include "notification-thread.hpp"
+#include "sessiond-config.hpp"
+
+/*
+ * Consumer daemon state which is changed when spawning it, killing it or in
+ * case of a fatal error.
+ */
+enum consumerd_state {
+       CONSUMER_STARTED = 1,
+       CONSUMER_STOPPED = 2,
+       CONSUMER_ERROR   = 3,
+};
+
+/* Unique identifier of a session daemon instance. */
+extern lttng_uuid the_sessiond_uuid;
+
+/*
+ * This consumer daemon state is used to validate if a client command will be
+ * able to reach the consumer. If not, the client is informed. For instance,
+ * doing a "lttng start" when the consumer state is set to ERROR will return an
+ * error to the client.
+ *
+ * The following example shows a possible race condition of this scheme:
+ *
+ * consumer thread error happens
+ *                                    client cmd arrives
+ *                                    client cmd checks state -> still OK
+ * consumer thread exit, sets error
+ *                                    client cmd try to talk to consumer
+ *                                    ...
+ *
+ * However, since the consumer is a different daemon, we have no way of making
+ * sure the command will reach it safely even with this state flag. This is why
+ * we consider that up to the state validation during command processing, the
+ * command is safe. After that, we can not guarantee the correctness of the
+ * client request vis-a-vis the consumer.
+ */
+extern enum consumerd_state the_ust_consumerd_state;
+extern enum consumerd_state the_kernel_consumerd_state;
+
+/* Set in main.c at boot time of the daemon */
+extern struct lttng_kernel_abi_tracer_version the_kernel_tracer_version;
+extern struct lttng_kernel_abi_tracer_abi_version the_kernel_tracer_abi_version;
+
+/* Notification thread handle. */
+extern struct notification_thread_handle *the_notification_thread_handle;
+
+/*
+ * This contains extra data needed for processing a command received by the
+ * session daemon from the lttng client.
+ */
+struct command_ctx {
+       unsigned int lttng_msg_size;
+       struct ltt_session *session;
+       /* Input message */
+       struct lttcomm_session_msg lsm;
+       /* Reply content, starts with an lttcomm_lttng_msg header. */
+       struct lttng_payload reply_payload;
+       lttng_sock_cred creds;
+};
+
+struct ust_command {
+       int sock;
+       struct ust_register_msg reg_msg;
+       struct cds_wfcq_node node;
+};
+
+/*
+ * Queue used to enqueue UST registration request (ust_command) and synchronized
+ * by a futex with a scheme N wakers / 1 waiters. See futex.c/.h
+ */
+struct ust_cmd_queue {
+       int32_t futex;
+       struct cds_wfcq_head head;
+       struct cds_wfcq_tail tail;
+};
+
+/*
+ * This is the wait queue containing wait nodes during the application
+ * registration process.
+ */
+struct ust_reg_wait_queue {
+       unsigned long count;
+       struct cds_list_head head;
+};
+
+/*
+ * Use by the dispatch registration to queue UST command socket to wait for the
+ * notify socket.
+ */
+struct ust_reg_wait_node {
+       struct ust_app *app;
+       struct cds_list_head head;
+};
+
+extern int the_kernel_poll_pipe[2];
+
+/*
+ * Populated when the daemon starts with the current page size of the system.
+ * Set in main() with the current page size.
+ */
+extern long the_page_size;
+
+/* Application health monitoring */
+extern struct health_app *the_health_sessiond;
+
+extern struct sessiond_config the_config;
+
+extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
+
+/* Parent PID for --sig-parent option */
+extern pid_t the_ppid;
+/* Internal parent PID use with daemonize. */
+extern pid_t the_child_ppid;
+
+/* Consumer daemon specific control data. */
+extern struct consumer_data the_ustconsumer32_data;
+extern struct consumer_data the_ustconsumer64_data;
+extern struct consumer_data the_kconsumer_data;
+
+int sessiond_init_thread_quit_pipe(void);
+int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
+int sessiond_wait_for_quit_pipe(int timeout_ms);
+int sessiond_notify_quit_pipe(void);
+void sessiond_close_quit_pipe(void);
+
+int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
+void sessiond_signal_parents(void);
+
+void sessiond_set_client_thread_state(bool running);
+void sessiond_wait_client_thread_stopped(void);
+
+void *thread_manage_consumer(void *data);
+
+#endif /* _LTT_SESSIOND_H */
index 42e902b5e2eccb3c964f8cd033a1d0306fd49d93..d7f6327ae788cbce1cd536ed45861f66c978da39 100644 (file)
@@ -8,13 +8,13 @@
 #define _LGPL_SOURCE
 #include <stdbool.h>
 
-#include <common/common.h>
-#include <common/kernel-ctl/kernel-ctl.h>
+#include <common/common.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
 
-#include "lttng-sessiond.h"
-#include "kernel.h"
-#include "lttng-syscall.h"
-#include "utils.h"
+#include "lttng-sessiond.hpp"
+#include "kernel.hpp"
+#include "lttng-syscall.hpp"
+#include "utils.hpp"
 
 /* Global syscall table. */
 struct syscall *syscall_table;
diff --git a/src/bin/lttng-sessiond/lttng-syscall.h b/src/bin/lttng-sessiond/lttng-syscall.h
deleted file mode 100644 (file)
index fa77c70..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_SYSCALL_H
-#define LTTNG_SYSCALL_H
-
-#include <common/hashtable/hashtable.h>
-#include <lttng/event.h>
-
-#include "trace-kernel.h"
-
-/*
- * Default size of the kernel system call array. With this size, we usually
- * reallocate twice considering a 32 bit compat layer also.
- */
-#define SYSCALL_TABLE_INIT_SIZE    256
-
-/* Maximum length of a syscall name. */
-#define SYSCALL_NAME_LEN           255
-
-/*
- * Represent a kernel syscall and used when we are populating the internal
- * list.
- */
-struct syscall {
-       uint32_t index;
-       uint32_t bitness;
-       char name[SYSCALL_NAME_LEN];
-       /* Used by the list syscalls command. */
-       struct lttng_ht_node_str node;
-};
-
-/*
- * Allocated once when listing all syscalls at boot time. This is an array
- * indexed by the syscall index provided in the listing.
- */
-extern struct syscall *syscall_table;
-
-/* Use to list kernel system calls. */
-int syscall_init_table(int tracer_fd);
-ssize_t syscall_table_list(struct lttng_event **events);
-
-#endif /* LTTNG_SYSCALL_H */
diff --git a/src/bin/lttng-sessiond/lttng-syscall.hpp b/src/bin/lttng-sessiond/lttng-syscall.hpp
new file mode 100644 (file)
index 0000000..78691f9
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_SYSCALL_H
+#define LTTNG_SYSCALL_H
+
+#include <common/hashtable/hashtable.hpp>
+#include <lttng/event.h>
+
+#include "trace-kernel.hpp"
+
+/*
+ * Default size of the kernel system call array. With this size, we usually
+ * reallocate twice considering a 32 bit compat layer also.
+ */
+#define SYSCALL_TABLE_INIT_SIZE    256
+
+/* Maximum length of a syscall name. */
+#define SYSCALL_NAME_LEN           255
+
+/*
+ * Represent a kernel syscall and used when we are populating the internal
+ * list.
+ */
+struct syscall {
+       uint32_t index;
+       uint32_t bitness;
+       char name[SYSCALL_NAME_LEN];
+       /* Used by the list syscalls command. */
+       struct lttng_ht_node_str node;
+};
+
+/*
+ * Allocated once when listing all syscalls at boot time. This is an array
+ * indexed by the syscall index provided in the listing.
+ */
+extern struct syscall *syscall_table;
+
+/* Use to list kernel system calls. */
+int syscall_init_table(int tracer_fd);
+ssize_t syscall_table_list(struct lttng_event **events);
+
+#endif /* LTTNG_SYSCALL_H */
diff --git a/src/bin/lttng-sessiond/lttng-ust-abi.h b/src/bin/lttng-sessiond/lttng-ust-abi.h
deleted file mode 100644 (file)
index e2b8cf9..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_ABI_H
-#define LTTNG_UST_ABI_H
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-#include <lttng/ust-abi.h>
-#else /* HAVE_LIBLTTNG_UST_CTL */
-/* Use local copy of the LTTng-UST header. */
-#include "ust-abi-internal.h"
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* LTTNG_UST_ABI_H */
diff --git a/src/bin/lttng-sessiond/lttng-ust-abi.hpp b/src/bin/lttng-sessiond/lttng-ust-abi.hpp
new file mode 100644 (file)
index 0000000..faf2321
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_ABI_H
+#define LTTNG_UST_ABI_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+#include <lttng/ust-abi.h>
+#else /* HAVE_LIBLTTNG_UST_CTL */
+/* Use local copy of the LTTng-UST header. */
+#include "ust-abi-internal.hpp"
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_UST_ABI_H */
diff --git a/src/bin/lttng-sessiond/lttng-ust-ctl.h b/src/bin/lttng-sessiond/lttng-ust-ctl.h
deleted file mode 100644 (file)
index 7e5713b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_CTL_H
-#define LTTNG_UST_CTL_H
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-#include <lttng/ust-ctl.h>
-#else /* HAVE_LIBLTTNG_UST_CTL */
-/* Use local copy of the LTTng-UST header. */
-#include "ust-ctl-internal.h"
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* LTTNG_UST_CTL_H */
diff --git a/src/bin/lttng-sessiond/lttng-ust-ctl.hpp b/src/bin/lttng-sessiond/lttng-ust-ctl.hpp
new file mode 100644 (file)
index 0000000..dcd6bf6
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_CTL_H
+#define LTTNG_UST_CTL_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+#include <lttng/ust-ctl.h>
+#else /* HAVE_LIBLTTNG_UST_CTL */
+/* Use local copy of the LTTng-UST header. */
+#include "ust-ctl-internal.hpp"
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_UST_CTL_H */
diff --git a/src/bin/lttng-sessiond/lttng-ust-error.h b/src/bin/lttng-sessiond/lttng-ust-error.h
deleted file mode 100644 (file)
index 326383b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_ERROR_H
-#define LTTNG_UST_ERROR_H
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-#include <lttng/ust-error.h>
-#else /* HAVE_LIBLTTNG_UST_CTL */
-/* Use local copy of the LTTng-UST header. */
-#include "ust-error-internal.h"
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* LTTNG_UST_ERROR_H */
diff --git a/src/bin/lttng-sessiond/lttng-ust-error.hpp b/src/bin/lttng-sessiond/lttng-ust-error.hpp
new file mode 100644 (file)
index 0000000..173908e
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_ERROR_H
+#define LTTNG_UST_ERROR_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+#include <lttng/ust-error.h>
+#else /* HAVE_LIBLTTNG_UST_CTL */
+/* Use local copy of the LTTng-UST header. */
+#include "ust-error-internal.hpp"
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_UST_ERROR_H */
index 34e881c4d219aee6aea0d237982920fe0b2e4ba6..cf7aa9e9e67bc94c971982133ef8ea49ed7fd128 100644 (file)
 #include <unistd.h>
 #include <ctype.h>
 
-#include <common/common.h>
-#include <common/compat/socket.h>
-#include <common/compat/getenv.h>
-#include <common/defaults.h>
-#include <common/kernel-consumer/kernel-consumer.h>
-#include <common/futex.h>
-#include <common/relayd/relayd.h>
-#include <common/utils.h>
-#include <common/path.h>
-#include <common/daemonize.h>
-#include <common/config/session-config.h>
-#include <common/ini-config/ini-config.h>
-#include <common/dynamic-buffer.h>
-#include <lttng/event-internal.h>
-
-#include "lttng-sessiond.h"
-#include "buffer-registry.h"
-#include "channel.h"
-#include "cmd.h"
-#include "consumer.h"
-#include "context.h"
-#include "event.h"
-#include "event-notifier-error-accounting.h"
-#include "kernel.h"
-#include "kernel-consumer.h"
-#include "lttng-ust-ctl.h"
-#include "ust-consumer.h"
-#include "utils.h"
-#include "fd-limit.h"
-#include "health-sessiond.h"
-#include "testpoint.h"
-#include "notify-apps.h"
-#include "agent-thread.h"
-#include "save.h"
-#include "notification-thread.h"
-#include "notification-thread-commands.h"
-#include "rotation-thread.h"
-#include "agent.h"
-#include "sessiond-config.h"
-#include "timer.h"
-#include "thread.h"
-#include "client.h"
-#include "dispatch.h"
-#include "register.h"
-#include "manage-apps.h"
-#include "manage-kernel.h"
-#include "modprobe.h"
-#include "ust-sigbus.h"
+#include <common/common.hpp>
+#include <common/compat/socket.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/defaults.hpp>
+#include <common/kernel-consumer/kernel-consumer.hpp>
+#include <common/futex.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
+#include <common/daemonize.hpp>
+#include <common/config/session-config.hpp>
+#include <common/ini-config/ini-config.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <lttng/event-internal.hpp>
+#include "lttng-sessiond.hpp"
+#include "buffer-registry.hpp"
+#include "channel.hpp"
+#include "cmd.hpp"
+#include "consumer.hpp"
+#include "context.hpp"
+#include "event.hpp"
+#include "event-notifier-error-accounting.hpp"
+#include "kernel.hpp"
+#include "kernel-consumer.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "ust-consumer.hpp"
+#include "utils.hpp"
+#include "fd-limit.hpp"
+#include "health-sessiond.hpp"
+#include "testpoint.hpp"
+#include "notify-apps.hpp"
+#include "agent-thread.hpp"
+#include "save.hpp"
+#include "notification-thread.hpp"
+#include "notification-thread-commands.hpp"
+#include "rotation-thread.hpp"
+#include "agent.hpp"
+#include "sessiond-config.hpp"
+#include "timer.hpp"
+#include "thread.hpp"
+#include "client.hpp"
+#include "dispatch.hpp"
+#include "register.hpp"
+#include "manage-apps.hpp"
+#include "manage-kernel.hpp"
+#include "modprobe.hpp"
+#include "ust-sigbus.hpp"
 
 static const char *help_msg =
 #ifdef LTTNG_EMBED_HELP
index 588e83b6c495ef4f1b8c50f805e46e86c97fea5c..4ee3538b2b9e70703edf7f02d2f9a5adf79767b8 100644 (file)
@@ -7,11 +7,11 @@
  *
  */
 
-#include "manage-apps.h"
-#include "testpoint.h"
-#include "health-sessiond.h"
-#include "utils.h"
-#include "thread.h"
+#include "manage-apps.hpp"
+#include "testpoint.hpp"
+#include "health-sessiond.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
 
 struct thread_notifiers {
        struct lttng_pipe *quit_pipe;
diff --git a/src/bin/lttng-sessiond/manage-apps.h b/src/bin/lttng-sessiond/manage-apps.h
deleted file mode 100644 (file)
index 3cd3b9c..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_APPLICATION_MANAGEMENT_THREAD_H
-#define SESSIOND_APPLICATION_MANAGEMENT_THREAD_H
-
-#include <stdbool.h>
-#include "lttng-sessiond.h"
-
-bool launch_application_management_thread(int apps_cmd_pipe_read_fd);
-
-#endif /* SESSIOND_APPLICATION_MANAGEMENT_THREAD_H */
diff --git a/src/bin/lttng-sessiond/manage-apps.hpp b/src/bin/lttng-sessiond/manage-apps.hpp
new file mode 100644 (file)
index 0000000..a865d9a
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_APPLICATION_MANAGEMENT_THREAD_H
+#define SESSIOND_APPLICATION_MANAGEMENT_THREAD_H
+
+#include <stdbool.h>
+#include "lttng-sessiond.hpp"
+
+bool launch_application_management_thread(int apps_cmd_pipe_read_fd);
+
+#endif /* SESSIOND_APPLICATION_MANAGEMENT_THREAD_H */
index cce48526e681309de3cb17bc0ea111b83abcba54..4a3e3b4ab9ec2adc991be079bee4b72478b5420a 100644 (file)
@@ -9,15 +9,15 @@
 
 #include <signal.h>
 
-#include <common/pipe.h>
-#include <common/utils.h>
-
-#include "manage-consumer.h"
-#include "testpoint.h"
-#include "health-sessiond.h"
-#include "utils.h"
-#include "thread.h"
-#include "ust-consumer.h"
+#include <common/pipe.hpp>
+#include <common/utils.hpp>
+
+#include "manage-consumer.hpp"
+#include "testpoint.hpp"
+#include "health-sessiond.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
+#include "ust-consumer.hpp"
 
 struct thread_notifiers {
        struct lttng_pipe *quit_pipe;
diff --git a/src/bin/lttng-sessiond/manage-consumer.h b/src/bin/lttng-sessiond/manage-consumer.h
deleted file mode 100644 (file)
index 16eb62d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_CONSUMER_MANAGEMENT_THREAD_H
-#define SESSIOND_CONSUMER_MANAGEMENT_THREAD_H
-
-#include <stdbool.h>
-#include "lttng-sessiond.h"
-
-bool launch_consumer_management_thread(struct consumer_data *consumer_data);
-
-#endif /* SESSIOND_CONSUMER_MANAGEMENT_THREAD_H */
diff --git a/src/bin/lttng-sessiond/manage-consumer.hpp b/src/bin/lttng-sessiond/manage-consumer.hpp
new file mode 100644 (file)
index 0000000..9e35a90
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_CONSUMER_MANAGEMENT_THREAD_H
+#define SESSIOND_CONSUMER_MANAGEMENT_THREAD_H
+
+#include <stdbool.h>
+#include "lttng-sessiond.hpp"
+
+bool launch_consumer_management_thread(struct consumer_data *consumer_data);
+
+#endif /* SESSIOND_CONSUMER_MANAGEMENT_THREAD_H */
index a789a0b29573ab830264d36799d78a8bcf1bc3f2..a5d21b0fe52ac10267b154671f55a8eadd4836d5 100644 (file)
@@ -7,16 +7,16 @@
  *
  */
 
-#include <common/pipe.h>
-#include <common/utils.h>
-
-#include "manage-kernel.h"
-#include "testpoint.h"
-#include "health-sessiond.h"
-#include "utils.h"
-#include "thread.h"
-#include "kernel.h"
-#include "kernel-consumer.h"
+#include <common/pipe.hpp>
+#include <common/utils.hpp>
+
+#include "manage-kernel.hpp"
+#include "testpoint.hpp"
+#include "health-sessiond.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
+#include "kernel.hpp"
+#include "kernel-consumer.hpp"
 
 struct thread_notifiers {
        struct lttng_pipe *quit_pipe;
diff --git a/src/bin/lttng-sessiond/manage-kernel.h b/src/bin/lttng-sessiond/manage-kernel.h
deleted file mode 100644 (file)
index 3be6658..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_KERNEL_MANAGEMENT_THREAD_H
-#define SESSIOND_KERNEL_MANAGEMENT_THREAD_H
-
-#include <stdbool.h>
-#include "lttng-sessiond.h"
-
-bool launch_kernel_management_thread(int kernel_poll_pipe_read_fd);
-
-#endif /* SESSIOND_KERNEL_MANAGEMENT_THREAD_H */
diff --git a/src/bin/lttng-sessiond/manage-kernel.hpp b/src/bin/lttng-sessiond/manage-kernel.hpp
new file mode 100644 (file)
index 0000000..fe0d8b0
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_KERNEL_MANAGEMENT_THREAD_H
+#define SESSIOND_KERNEL_MANAGEMENT_THREAD_H
+
+#include <stdbool.h>
+#include "lttng-sessiond.hpp"
+
+bool launch_kernel_management_thread(int kernel_poll_pipe_read_fd);
+
+#endif /* SESSIOND_KERNEL_MANAGEMENT_THREAD_H */
index 782dcc6b2714d334b0397cdee548abd0d83642a9..0dc123de156eb23247d8196eb0971493b3a99b1a 100644 (file)
 #include <stdlib.h>
 #include <sys/wait.h>
 
-#include <common/common.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/utils.hpp>
 
-#include "modprobe.h"
-#include "kern-modules.h"
-#include "lttng-sessiond.h"
+#include "modprobe.hpp"
+#include "kern-modules.hpp"
+#include "lttng-sessiond.hpp"
 
 /* LTTng kernel tracer mandatory core modules list */
 struct kern_modules_param kern_modules_control_core[] = {
diff --git a/src/bin/lttng-sessiond/modprobe.h b/src/bin/lttng-sessiond/modprobe.h
deleted file mode 100644 (file)
index f0ad01c..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _MODPROBE_H
-#define _MODPROBE_H
-
-void modprobe_remove_lttng_all(void);
-void modprobe_remove_lttng_control(void);
-void modprobe_remove_lttng_data(void);
-int modprobe_lttng_control(void);
-int modprobe_lttng_data(void);
-
-#endif /* _MODPROBE_H */
diff --git a/src/bin/lttng-sessiond/modprobe.hpp b/src/bin/lttng-sessiond/modprobe.hpp
new file mode 100644 (file)
index 0000000..f0ad01c
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _MODPROBE_H
+#define _MODPROBE_H
+
+void modprobe_remove_lttng_all(void);
+void modprobe_remove_lttng_control(void);
+void modprobe_remove_lttng_data(void);
+int modprobe_lttng_control(void);
+int modprobe_lttng_data(void);
+
+#endif /* _MODPROBE_H */
index 60095115947e5e8c362415b046e5d6816b5bda56..ce499eb1cb3418ac10085f1ac98baa3cf2bf2d56 100644 (file)
@@ -7,9 +7,9 @@
 
 #include <lttng/trigger/trigger.h>
 #include <lttng/lttng-error.h>
-#include "notification-thread.h"
-#include "notification-thread-commands.h"
-#include <common/error.h>
+#include "notification-thread.hpp"
+#include "notification-thread-commands.hpp"
+#include <common/error.hpp>
 #include <unistd.h>
 #include <stdint.h>
 #include <inttypes.h>
diff --git a/src/bin/lttng-sessiond/notification-thread-commands.h b/src/bin/lttng-sessiond/notification-thread-commands.h
deleted file mode 100644 (file)
index 643b0e6..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef NOTIFICATION_THREAD_COMMANDS_H
-#define NOTIFICATION_THREAD_COMMANDS_H
-
-#include <lttng/domain.h>
-#include <lttng/lttng-error.h>
-#include <urcu/rculfhash.h>
-#include "notification-thread.h"
-#include "notification-thread-internal.h"
-#include "notification-thread-events.h"
-#include <common/waiter.h>
-#include <stdbool.h>
-
-struct notification_thread_data;
-struct lttng_trigger;
-
-enum notification_thread_command_type {
-       NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER,
-       NOTIFICATION_COMMAND_TYPE_UNREGISTER_TRIGGER,
-       NOTIFICATION_COMMAND_TYPE_ADD_CHANNEL,
-       NOTIFICATION_COMMAND_TYPE_REMOVE_CHANNEL,
-       NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING,
-       NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED,
-       NOTIFICATION_COMMAND_TYPE_ADD_TRACER_EVENT_SOURCE,
-       NOTIFICATION_COMMAND_TYPE_REMOVE_TRACER_EVENT_SOURCE,
-       NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS,
-       NOTIFICATION_COMMAND_TYPE_QUIT,
-       NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE,
-       NOTIFICATION_COMMAND_TYPE_GET_TRIGGER,
-};
-
-struct notification_thread_command {
-       struct cds_list_head cmd_list_node;
-
-       enum notification_thread_command_type type;
-       union {
-               /* Register trigger. */
-               struct {
-                       struct lttng_trigger *trigger;
-                       bool is_trigger_anonymous;
-               } register_trigger;
-               /* Unregister trigger. */
-               struct {
-                       const struct lttng_trigger *trigger;
-               } unregister_trigger;
-               /* Add channel. */
-               struct {
-                       struct {
-                               const char *name;
-                               uid_t uid;
-                               gid_t gid;
-                       } session;
-                       struct {
-                               const char *name;
-                               enum lttng_domain_type domain;
-                               uint64_t key;
-                               uint64_t capacity;
-                       } channel;
-               } add_channel;
-               /* Remove channel. */
-               struct {
-                       uint64_t key;
-                       enum lttng_domain_type domain;
-               } remove_channel;
-               struct {
-                       const char *session_name;
-                       uid_t uid;
-                       gid_t gid;
-                       uint64_t trace_archive_chunk_id;
-                       /* Weak reference. */
-                       struct lttng_trace_archive_location *location;
-               } session_rotation;
-               /* Add/Remove tracer event source fd. */
-               struct {
-                       int tracer_event_source_fd;
-                       enum lttng_domain_type domain;
-               } tracer_event_source;
-               /* List triggers. */
-               struct {
-                       /* Credentials of the requesting user. */
-                       uid_t uid;
-               } list_triggers;
-               /* Client communication update. */
-               struct {
-                       notification_client_id id;
-                       enum client_transmission_status status;
-               } client_communication_update;
-
-               struct {
-                       const struct lttng_trigger *trigger;
-               } get_trigger;
-
-       } parameters;
-
-       union {
-               struct {
-                       struct lttng_triggers *triggers;
-               } list_triggers;
-               struct {
-                       struct lttng_trigger *trigger;
-               } get_trigger;
-       } reply;
-       /* lttng_waiter on which to wait for command reply (optional). */
-       struct lttng_waiter reply_waiter;
-       enum lttng_error_code reply_code;
-       bool is_async;
-};
-
-enum lttng_error_code notification_thread_command_register_trigger(
-               struct notification_thread_handle *handle,
-               struct lttng_trigger *trigger,
-               bool is_anonymous_trigger);
-
-enum lttng_error_code notification_thread_command_unregister_trigger(
-               struct notification_thread_handle *handle,
-               const struct lttng_trigger *trigger);
-
-enum lttng_error_code notification_thread_command_add_channel(
-               struct notification_thread_handle *handle,
-               char *session_name, uid_t session_uid, gid_t session_gid,
-               char *channel_name, uint64_t key,
-               enum lttng_domain_type domain, uint64_t capacity);
-
-enum lttng_error_code notification_thread_command_remove_channel(
-               struct notification_thread_handle *handle,
-               uint64_t key, enum lttng_domain_type domain);
-
-enum lttng_error_code notification_thread_command_session_rotation_ongoing(
-               struct notification_thread_handle *handle,
-               const char *session_name, uid_t session_uid, gid_t session_gid,
-               uint64_t trace_archive_chunk_id);
-
-/* Ownership of location is transferred. */
-enum lttng_error_code notification_thread_command_session_rotation_completed(
-               struct notification_thread_handle *handle,
-               const char *session_name, uid_t session_uid, gid_t session_gid,
-               uint64_t trace_archive_chunk_id,
-               struct lttng_trace_archive_location *location);
-
-/*
- * Return the set of triggers visible to a given client.
- *
- * The trigger objects contained in the set are the actual trigger instances
- * used by the notification subsystem (i.e. not a copy). Given that the command
- * is only used to serialize the triggers, this is fine: the properties that
- * are serialized are immutable over the lifetime of the triggers.
- *
- * Moreover, the lifetime of the trigger instances is protected through
- * reference counting (references are held by the trigger set).
- *
- * The caller has the exclusive ownership of the returned trigger set.
- */
-enum lttng_error_code notification_thread_command_list_triggers(
-               struct notification_thread_handle *handle,
-               uid_t client_uid,
-               struct lttng_triggers **triggers);
-
-/*
- * The ownership of trigger_event_application_pipe is _not_ transferred to
- * the notification thread.
- */
-enum lttng_error_code notification_thread_command_add_tracer_event_source(
-               struct notification_thread_handle *handle,
-               int tracer_event_source_fd,
-               enum lttng_domain_type domain);
-
-enum lttng_error_code notification_thread_command_remove_tracer_event_source(
-               struct notification_thread_handle *handle,
-               int tracer_event_source_fd);
-
-void notification_thread_command_quit(
-               struct notification_thread_handle *handle);
-
-enum lttng_error_code notification_thread_command_get_trigger(
-               struct notification_thread_handle *handle,
-               const struct lttng_trigger *trigger,
-               struct lttng_trigger **real_trigger);
-
-#endif /* NOTIFICATION_THREAD_COMMANDS_H */
diff --git a/src/bin/lttng-sessiond/notification-thread-commands.hpp b/src/bin/lttng-sessiond/notification-thread-commands.hpp
new file mode 100644 (file)
index 0000000..98b0abc
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef NOTIFICATION_THREAD_COMMANDS_H
+#define NOTIFICATION_THREAD_COMMANDS_H
+
+#include <lttng/domain.h>
+#include <lttng/lttng-error.h>
+#include <urcu/rculfhash.h>
+#include "notification-thread.hpp"
+#include "notification-thread-internal.hpp"
+#include "notification-thread-events.hpp"
+#include <common/waiter.hpp>
+#include <stdbool.h>
+
+struct notification_thread_data;
+struct lttng_trigger;
+
+enum notification_thread_command_type {
+       NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER,
+       NOTIFICATION_COMMAND_TYPE_UNREGISTER_TRIGGER,
+       NOTIFICATION_COMMAND_TYPE_ADD_CHANNEL,
+       NOTIFICATION_COMMAND_TYPE_REMOVE_CHANNEL,
+       NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING,
+       NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED,
+       NOTIFICATION_COMMAND_TYPE_ADD_TRACER_EVENT_SOURCE,
+       NOTIFICATION_COMMAND_TYPE_REMOVE_TRACER_EVENT_SOURCE,
+       NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS,
+       NOTIFICATION_COMMAND_TYPE_QUIT,
+       NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE,
+       NOTIFICATION_COMMAND_TYPE_GET_TRIGGER,
+};
+
+struct notification_thread_command {
+       struct cds_list_head cmd_list_node;
+
+       enum notification_thread_command_type type;
+       union {
+               /* Register trigger. */
+               struct {
+                       struct lttng_trigger *trigger;
+                       bool is_trigger_anonymous;
+               } register_trigger;
+               /* Unregister trigger. */
+               struct {
+                       const struct lttng_trigger *trigger;
+               } unregister_trigger;
+               /* Add channel. */
+               struct {
+                       struct {
+                               const char *name;
+                               uid_t uid;
+                               gid_t gid;
+                       } session;
+                       struct {
+                               const char *name;
+                               enum lttng_domain_type domain;
+                               uint64_t key;
+                               uint64_t capacity;
+                       } channel;
+               } add_channel;
+               /* Remove channel. */
+               struct {
+                       uint64_t key;
+                       enum lttng_domain_type domain;
+               } remove_channel;
+               struct {
+                       const char *session_name;
+                       uid_t uid;
+                       gid_t gid;
+                       uint64_t trace_archive_chunk_id;
+                       /* Weak reference. */
+                       struct lttng_trace_archive_location *location;
+               } session_rotation;
+               /* Add/Remove tracer event source fd. */
+               struct {
+                       int tracer_event_source_fd;
+                       enum lttng_domain_type domain;
+               } tracer_event_source;
+               /* List triggers. */
+               struct {
+                       /* Credentials of the requesting user. */
+                       uid_t uid;
+               } list_triggers;
+               /* Client communication update. */
+               struct {
+                       notification_client_id id;
+                       enum client_transmission_status status;
+               } client_communication_update;
+
+               struct {
+                       const struct lttng_trigger *trigger;
+               } get_trigger;
+
+       } parameters;
+
+       union {
+               struct {
+                       struct lttng_triggers *triggers;
+               } list_triggers;
+               struct {
+                       struct lttng_trigger *trigger;
+               } get_trigger;
+       } reply;
+       /* lttng_waiter on which to wait for command reply (optional). */
+       struct lttng_waiter reply_waiter;
+       enum lttng_error_code reply_code;
+       bool is_async;
+};
+
+enum lttng_error_code notification_thread_command_register_trigger(
+               struct notification_thread_handle *handle,
+               struct lttng_trigger *trigger,
+               bool is_anonymous_trigger);
+
+enum lttng_error_code notification_thread_command_unregister_trigger(
+               struct notification_thread_handle *handle,
+               const struct lttng_trigger *trigger);
+
+enum lttng_error_code notification_thread_command_add_channel(
+               struct notification_thread_handle *handle,
+               char *session_name, uid_t session_uid, gid_t session_gid,
+               char *channel_name, uint64_t key,
+               enum lttng_domain_type domain, uint64_t capacity);
+
+enum lttng_error_code notification_thread_command_remove_channel(
+               struct notification_thread_handle *handle,
+               uint64_t key, enum lttng_domain_type domain);
+
+enum lttng_error_code notification_thread_command_session_rotation_ongoing(
+               struct notification_thread_handle *handle,
+               const char *session_name, uid_t session_uid, gid_t session_gid,
+               uint64_t trace_archive_chunk_id);
+
+/* Ownership of location is transferred. */
+enum lttng_error_code notification_thread_command_session_rotation_completed(
+               struct notification_thread_handle *handle,
+               const char *session_name, uid_t session_uid, gid_t session_gid,
+               uint64_t trace_archive_chunk_id,
+               struct lttng_trace_archive_location *location);
+
+/*
+ * Return the set of triggers visible to a given client.
+ *
+ * The trigger objects contained in the set are the actual trigger instances
+ * used by the notification subsystem (i.e. not a copy). Given that the command
+ * is only used to serialize the triggers, this is fine: the properties that
+ * are serialized are immutable over the lifetime of the triggers.
+ *
+ * Moreover, the lifetime of the trigger instances is protected through
+ * reference counting (references are held by the trigger set).
+ *
+ * The caller has the exclusive ownership of the returned trigger set.
+ */
+enum lttng_error_code notification_thread_command_list_triggers(
+               struct notification_thread_handle *handle,
+               uid_t client_uid,
+               struct lttng_triggers **triggers);
+
+/*
+ * The ownership of trigger_event_application_pipe is _not_ transferred to
+ * the notification thread.
+ */
+enum lttng_error_code notification_thread_command_add_tracer_event_source(
+               struct notification_thread_handle *handle,
+               int tracer_event_source_fd,
+               enum lttng_domain_type domain);
+
+enum lttng_error_code notification_thread_command_remove_tracer_event_source(
+               struct notification_thread_handle *handle,
+               int tracer_event_source_fd);
+
+void notification_thread_command_quit(
+               struct notification_thread_handle *handle);
+
+enum lttng_error_code notification_thread_command_get_trigger(
+               struct notification_thread_handle *handle,
+               const struct lttng_trigger *trigger,
+               struct lttng_trigger **real_trigger);
+
+#endif /* NOTIFICATION_THREAD_COMMANDS_H */
index 9e1aa5300b8416e68fdc4672da8beedce66fc985..67fca2a357bb3fcac0814d150313e49ae38532a2 100644 (file)
@@ -6,46 +6,46 @@
  */
 
 #include "lttng/action/action.h"
-#include "lttng/trigger/trigger-internal.h"
+#include "lttng/trigger/trigger-internal.hpp"
 #define _LGPL_SOURCE
 #include <urcu.h>
 #include <urcu/rculfhash.h>
 
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/futex.h>
-#include <common/unix.h>
-#include <common/dynamic-buffer.h>
-#include <common/hashtable/utils.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/macros.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/futex.hpp>
+#include <common/unix.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/macros.hpp>
 #include <lttng/condition/condition.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/list-internal.h>
-#include <lttng/domain-internal.h>
-#include <lttng/notification/notification-internal.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <lttng/condition/session-consumed-size-internal.h>
-#include <lttng/condition/session-rotation-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
-#include <lttng/domain-internal.h>
-#include <lttng/notification/channel-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/list-internal.hpp>
+#include <lttng/domain-internal.hpp>
+#include <lttng/notification/notification-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/session-consumed-size-internal.hpp>
+#include <lttng/condition/session-rotation-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
+#include <lttng/domain-internal.hpp>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
 
 #include <time.h>
 #include <unistd.h>
 #include <inttypes.h>
 #include <fcntl.h>
 
-#include "condition-internal.h"
-#include "event-notifier-error-accounting.h"
-#include "notification-thread.h"
-#include "notification-thread-events.h"
-#include "notification-thread-commands.h"
-#include "lttng-sessiond.h"
-#include "kernel.h"
+#include "condition-internal.hpp"
+#include "event-notifier-error-accounting.hpp"
+#include "notification-thread.hpp"
+#include "notification-thread-events.hpp"
+#include "notification-thread-commands.hpp"
+#include "lttng-sessiond.hpp"
+#include "kernel.hpp"
 
 #define CLIENT_POLL_MASK_IN (LPOLLIN | LPOLLERR | LPOLLHUP | LPOLLRDHUP)
 #define CLIENT_POLL_MASK_IN_OUT (CLIENT_POLL_MASK_IN | LPOLLOUT)
diff --git a/src/bin/lttng-sessiond/notification-thread-events.h b/src/bin/lttng-sessiond/notification-thread-events.h
deleted file mode 100644 (file)
index 2657191..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef NOTIFICATION_THREAD_EVENTS_H
-#define NOTIFICATION_THREAD_EVENTS_H
-
-#include <lttng/domain.h>
-#include "notification-thread.h"
-
-/**
- * Event handling function shall only return an error if
- * the thread should be stopped.
- */
-int handle_notification_thread_command(
-               struct notification_thread_handle *handle,
-               struct notification_thread_state *state);
-
-int handle_notification_thread_client_connect(
-               struct notification_thread_state *state);
-
-int handle_notification_thread_client_disconnect(
-               int client_fd,
-               struct notification_thread_state *state);
-
-int handle_notification_thread_client_disconnect_all(
-               struct notification_thread_state *state);
-
-int handle_notification_thread_trigger_unregister_all(
-               struct notification_thread_state *state);
-
-int handle_notification_thread_tracer_event_source_died(
-               struct notification_thread_state *state,
-               int tracer_event_source_fd);
-
-int handle_notification_thread_client_in(
-               struct notification_thread_state *state,
-               int socket);
-
-int handle_notification_thread_client_out(
-               struct notification_thread_state *state,
-               int socket);
-
-int handle_notification_thread_channel_sample(
-               struct notification_thread_state *state, int pipe,
-               enum lttng_domain_type domain);
-
-int handle_notification_thread_event_notification(
-               struct notification_thread_state *state, int pipe,
-               enum lttng_domain_type domain);
-
-#endif /* NOTIFICATION_THREAD_EVENTS_H */
diff --git a/src/bin/lttng-sessiond/notification-thread-events.hpp b/src/bin/lttng-sessiond/notification-thread-events.hpp
new file mode 100644 (file)
index 0000000..50abad9
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef NOTIFICATION_THREAD_EVENTS_H
+#define NOTIFICATION_THREAD_EVENTS_H
+
+#include <lttng/domain.h>
+#include "notification-thread.hpp"
+
+/**
+ * Event handling function shall only return an error if
+ * the thread should be stopped.
+ */
+int handle_notification_thread_command(
+               struct notification_thread_handle *handle,
+               struct notification_thread_state *state);
+
+int handle_notification_thread_client_connect(
+               struct notification_thread_state *state);
+
+int handle_notification_thread_client_disconnect(
+               int client_fd,
+               struct notification_thread_state *state);
+
+int handle_notification_thread_client_disconnect_all(
+               struct notification_thread_state *state);
+
+int handle_notification_thread_trigger_unregister_all(
+               struct notification_thread_state *state);
+
+int handle_notification_thread_tracer_event_source_died(
+               struct notification_thread_state *state,
+               int tracer_event_source_fd);
+
+int handle_notification_thread_client_in(
+               struct notification_thread_state *state,
+               int socket);
+
+int handle_notification_thread_client_out(
+               struct notification_thread_state *state,
+               int socket);
+
+int handle_notification_thread_channel_sample(
+               struct notification_thread_state *state, int pipe,
+               enum lttng_domain_type domain);
+
+int handle_notification_thread_event_notification(
+               struct notification_thread_state *state, int pipe,
+               enum lttng_domain_type domain);
+
+#endif /* NOTIFICATION_THREAD_EVENTS_H */
diff --git a/src/bin/lttng-sessiond/notification-thread-internal.h b/src/bin/lttng-sessiond/notification-thread-internal.h
deleted file mode 100644 (file)
index 9e7059a..0000000
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef NOTIFICATION_THREAD_INTERNAL_H
-#define NOTIFICATION_THREAD_INTERNAL_H
-
-#include <common/compat/socket.h>
-#include <common/credentials.h>
-#include <common/payload.h>
-#include <lttng/notification/channel-internal.h>
-#include <lttng/ref-internal.h>
-#include <stdbool.h>
-#include <unistd.h>
-#include <urcu/rculfhash.h>
-#include <urcu/ref.h>
-#include <urcu/call-rcu.h>
-#include "notification-thread.h"
-
-struct lttng_evaluation;
-struct notification_thread_handle;
-
-struct channel_key {
-       uint64_t key;
-       enum lttng_domain_type domain;
-};
-
-struct session_info {
-       struct lttng_ref ref;
-       char *name;
-       uid_t uid;
-       gid_t gid;
-       /*
-        * Hashtable containing back-refs (weak) to all channels in this session.
-        * The hashtable's key is a hash of (struct channel_key) and
-        * the value is of type (struct channel_info *).
-        */
-       struct cds_lfht *channel_infos_ht;
-       struct lttng_session_trigger_list *trigger_list;
-       /* Node in the notification thread state's sessions_ht. */
-       struct cds_lfht_node sessions_ht_node;
-       /*
-        * Weak reference to the thread state's sessions_ht. Used for removal on
-        * destruction.
-        */
-       struct cds_lfht *sessions_ht;
-       uint64_t consumed_data_size;
-       struct {
-               /* Whether a rotation is ongoing for this session. */
-               bool ongoing;
-               /* Identifier of the currently ongoing rotation. */
-               uint64_t id;
-       } rotation;
-       /* call_rcu delayed reclaim. */
-       struct rcu_head rcu_node;
-};
-
-struct channel_info {
-       struct channel_key key;
-       char *name;
-       uint64_t capacity;
-       /*
-        * A channel info holds a reference (lttng_ref) on session_info.
-        * session_info, in return, holds a weak reference to the channel.
-        */
-       struct session_info *session_info;
-       /* Node in the notification thread state's channels_ht. */
-       struct cds_lfht_node channels_ht_node;
-       /* Node in the session_info's channels_ht. */
-       struct cds_lfht_node session_info_channels_ht_node;
-       /* call_rcu delayed reclaim. */
-       struct rcu_head rcu_node;
-};
-
-/*
- * Facilities to carry the different notifications type in the action
- * processing code path.
- */
-struct lttng_event_notifier_notification {
-       uint64_t tracer_token;
-       enum lttng_domain_type type;
-       size_t capture_buf_size;
-       char *capture_buffer;
-};
-
-struct notification_client_list_element {
-       struct notification_client *client;
-       struct cds_list_head node;
-};
-
-/*
- * Thread safety of notification_client and notification_client_list.
- *
- * The notification thread (main thread) and the action executor
- * interact through client lists. Hence, when the action executor
- * thread looks-up the list of clients subscribed to a given
- * condition, it will acquire a reference to the list and lock it
- * while attempting to communicate with the various clients.
- *
- * It is not necessary to reference-count clients as they are guaranteed
- * to be 'alive' if they are present in a list and that list is locked. Indeed,
- * removing references to the client from those subscription lists is part of
- * the work performed on destruction of a client.
- *
- * No provision for other access scenarios are taken into account;
- * this is the bare minimum to make these accesses safe and the
- * notification thread's state is _not_ "thread-safe" in any general
- * sense.
- */
-struct notification_client_list {
-       pthread_mutex_t lock;
-       struct urcu_ref ref;
-       struct lttng_condition *condition;
-       /* List of triggers that have an identical condition than `condition`. */
-       struct cds_list_head triggers_list;
-       struct cds_list_head clients_list;
-       /* Weak reference to container. */
-       struct cds_lfht *notification_trigger_clients_ht;
-       struct cds_lfht_node notification_trigger_clients_ht_node;
-       /* call_rcu delayed reclaim. */
-       struct rcu_head rcu_node;
-};
-
-struct notification_client {
-       /*
-        * Nests within the notification_client_list lock.
-        *
-        * Protects the outbound communication and the active flag which
-        * is used by both the notification and action executor threads.
-        *
-        * The remaining fields of the object can be used without any
-        * synchronization as they are either immutable (id, creds, version) or
-        * only accessed by the notification thread.
-        */
-       pthread_mutex_t lock;
-       notification_client_id id;
-       int socket;
-       /* Client protocol version. */
-       uint8_t major, minor;
-       uid_t uid;
-       gid_t gid;
-       bool is_sessiond;
-       /*
-        * Indicates if the credentials and versions of the client have been
-        * checked.
-        */
-       bool validated;
-       /*
-        * Conditions to which the client's notification channel is subscribed.
-        * List of struct lttng_condition_list_node. The condition member is
-        * owned by the client.
-        */
-       struct cds_list_head condition_list;
-       struct cds_lfht_node client_socket_ht_node;
-       struct cds_lfht_node client_id_ht_node;
-       struct {
-               /*
-                * If a client's communication is inactive, it means that a
-                * fatal error has occurred (could be either a protocol error or
-                * the socket API returned a fatal error). No further
-                * communication should be attempted; the client is queued for
-                * clean-up.
-                */
-               bool active;
-               struct {
-                       /*
-                        * During the reception of a message, the reception
-                        * buffers' "size" is set to contain the current
-                        * message's complete payload.
-                        */
-                       struct lttng_payload payload;
-                       /* Bytes left to receive for the current message. */
-                       size_t bytes_to_receive;
-                       /* FDs left to receive for the current message. */
-                       int fds_to_receive;
-                       /* Type of the message being received. */
-                       enum lttng_notification_channel_message_type msg_type;
-                       /*
-                        * Indicates whether or not credentials are expected
-                        * from the client.
-                        */
-                       bool expect_creds;
-                       /*
-                        * Indicates whether or not credentials were received
-                        * from the client.
-                        */
-                       bool creds_received;
-                       /* Only used during credentials reception. */
-                       lttng_sock_cred creds;
-               } inbound;
-               struct {
-                       /*
-                        * Indicates whether or not a notification addressed to
-                        * this client was dropped because a command reply was
-                        * already buffered.
-                        *
-                        * A notification is dropped whenever the buffer is not
-                        * empty.
-                        */
-                       bool dropped_notification;
-                       /*
-                        * Indicates whether or not a command reply is already
-                        * buffered. In this case, it means that the client is
-                        * not consuming command replies before emitting a new
-                        * one. This could be caused by a protocol error or a
-                        * misbehaving/malicious client.
-                        */
-                       bool queued_command_reply;
-                       struct lttng_payload payload;
-               } outbound;
-       } communication;
-       /* call_rcu delayed reclaim. */
-       struct rcu_head rcu_node;
-};
-
-enum client_transmission_status {
-       CLIENT_TRANSMISSION_STATUS_COMPLETE,
-       CLIENT_TRANSMISSION_STATUS_QUEUED,
-       /* Communication failure. */
-       CLIENT_TRANSMISSION_STATUS_FAIL,
-       /* Fatal error. */
-       CLIENT_TRANSMISSION_STATUS_ERROR,
-};
-
-bool notification_client_list_get(struct notification_client_list *list);
-
-void notification_client_list_put(struct notification_client_list *list);
-
-/* Only returns a non-zero value if a fatal error occurred. */
-typedef int (*report_client_transmission_result_cb)(
-               struct notification_client *client,
-               enum client_transmission_status status,
-               void *user_data);
-
-int notification_client_list_send_evaluation(
-               struct notification_client_list *list,
-               const struct lttng_trigger *trigger,
-               const struct lttng_evaluation *evaluation,
-               const struct lttng_credentials *source_object_creds,
-               report_client_transmission_result_cb client_report,
-               void *user_data);
-
-int notification_thread_client_communication_update(
-               struct notification_thread_handle *handle,
-               notification_client_id id,
-               enum client_transmission_status transmission_status);
-
-/*
- * Takes ownership of the payload if present.
- */
-struct lttng_event_notifier_notification *lttng_event_notifier_notification_create(
-               uint64_t tracer_token,
-               enum lttng_domain_type domain,
-               char *payload,
-               size_t payload_size);
-
-void lttng_event_notifier_notification_destroy(
-               struct lttng_event_notifier_notification *event_notifier_notification);
-
-#endif /* NOTIFICATION_THREAD_INTERNAL_H */
diff --git a/src/bin/lttng-sessiond/notification-thread-internal.hpp b/src/bin/lttng-sessiond/notification-thread-internal.hpp
new file mode 100644 (file)
index 0000000..497484b
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef NOTIFICATION_THREAD_INTERNAL_H
+#define NOTIFICATION_THREAD_INTERNAL_H
+
+#include <common/compat/socket.hpp>
+#include <common/credentials.hpp>
+#include <common/payload.hpp>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/ref-internal.hpp>
+#include <stdbool.h>
+#include <unistd.h>
+#include <urcu/rculfhash.h>
+#include <urcu/ref.h>
+#include <urcu/call-rcu.h>
+#include "notification-thread.hpp"
+
+struct lttng_evaluation;
+struct notification_thread_handle;
+
+struct channel_key {
+       uint64_t key;
+       enum lttng_domain_type domain;
+};
+
+struct session_info {
+       struct lttng_ref ref;
+       char *name;
+       uid_t uid;
+       gid_t gid;
+       /*
+        * Hashtable containing back-refs (weak) to all channels in this session.
+        * The hashtable's key is a hash of (struct channel_key) and
+        * the value is of type (struct channel_info *).
+        */
+       struct cds_lfht *channel_infos_ht;
+       struct lttng_session_trigger_list *trigger_list;
+       /* Node in the notification thread state's sessions_ht. */
+       struct cds_lfht_node sessions_ht_node;
+       /*
+        * Weak reference to the thread state's sessions_ht. Used for removal on
+        * destruction.
+        */
+       struct cds_lfht *sessions_ht;
+       uint64_t consumed_data_size;
+       struct {
+               /* Whether a rotation is ongoing for this session. */
+               bool ongoing;
+               /* Identifier of the currently ongoing rotation. */
+               uint64_t id;
+       } rotation;
+       /* call_rcu delayed reclaim. */
+       struct rcu_head rcu_node;
+};
+
+struct channel_info {
+       struct channel_key key;
+       char *name;
+       uint64_t capacity;
+       /*
+        * A channel info holds a reference (lttng_ref) on session_info.
+        * session_info, in return, holds a weak reference to the channel.
+        */
+       struct session_info *session_info;
+       /* Node in the notification thread state's channels_ht. */
+       struct cds_lfht_node channels_ht_node;
+       /* Node in the session_info's channels_ht. */
+       struct cds_lfht_node session_info_channels_ht_node;
+       /* call_rcu delayed reclaim. */
+       struct rcu_head rcu_node;
+};
+
+/*
+ * Facilities to carry the different notifications type in the action
+ * processing code path.
+ */
+struct lttng_event_notifier_notification {
+       uint64_t tracer_token;
+       enum lttng_domain_type type;
+       size_t capture_buf_size;
+       char *capture_buffer;
+};
+
+struct notification_client_list_element {
+       struct notification_client *client;
+       struct cds_list_head node;
+};
+
+/*
+ * Thread safety of notification_client and notification_client_list.
+ *
+ * The notification thread (main thread) and the action executor
+ * interact through client lists. Hence, when the action executor
+ * thread looks-up the list of clients subscribed to a given
+ * condition, it will acquire a reference to the list and lock it
+ * while attempting to communicate with the various clients.
+ *
+ * It is not necessary to reference-count clients as they are guaranteed
+ * to be 'alive' if they are present in a list and that list is locked. Indeed,
+ * removing references to the client from those subscription lists is part of
+ * the work performed on destruction of a client.
+ *
+ * No provision for other access scenarios are taken into account;
+ * this is the bare minimum to make these accesses safe and the
+ * notification thread's state is _not_ "thread-safe" in any general
+ * sense.
+ */
+struct notification_client_list {
+       pthread_mutex_t lock;
+       struct urcu_ref ref;
+       struct lttng_condition *condition;
+       /* List of triggers that have an identical condition than `condition`. */
+       struct cds_list_head triggers_list;
+       struct cds_list_head clients_list;
+       /* Weak reference to container. */
+       struct cds_lfht *notification_trigger_clients_ht;
+       struct cds_lfht_node notification_trigger_clients_ht_node;
+       /* call_rcu delayed reclaim. */
+       struct rcu_head rcu_node;
+};
+
+struct notification_client {
+       /*
+        * Nests within the notification_client_list lock.
+        *
+        * Protects the outbound communication and the active flag which
+        * is used by both the notification and action executor threads.
+        *
+        * The remaining fields of the object can be used without any
+        * synchronization as they are either immutable (id, creds, version) or
+        * only accessed by the notification thread.
+        */
+       pthread_mutex_t lock;
+       notification_client_id id;
+       int socket;
+       /* Client protocol version. */
+       uint8_t major, minor;
+       uid_t uid;
+       gid_t gid;
+       bool is_sessiond;
+       /*
+        * Indicates if the credentials and versions of the client have been
+        * checked.
+        */
+       bool validated;
+       /*
+        * Conditions to which the client's notification channel is subscribed.
+        * List of struct lttng_condition_list_node. The condition member is
+        * owned by the client.
+        */
+       struct cds_list_head condition_list;
+       struct cds_lfht_node client_socket_ht_node;
+       struct cds_lfht_node client_id_ht_node;
+       struct {
+               /*
+                * If a client's communication is inactive, it means that a
+                * fatal error has occurred (could be either a protocol error or
+                * the socket API returned a fatal error). No further
+                * communication should be attempted; the client is queued for
+                * clean-up.
+                */
+               bool active;
+               struct {
+                       /*
+                        * During the reception of a message, the reception
+                        * buffers' "size" is set to contain the current
+                        * message's complete payload.
+                        */
+                       struct lttng_payload payload;
+                       /* Bytes left to receive for the current message. */
+                       size_t bytes_to_receive;
+                       /* FDs left to receive for the current message. */
+                       int fds_to_receive;
+                       /* Type of the message being received. */
+                       enum lttng_notification_channel_message_type msg_type;
+                       /*
+                        * Indicates whether or not credentials are expected
+                        * from the client.
+                        */
+                       bool expect_creds;
+                       /*
+                        * Indicates whether or not credentials were received
+                        * from the client.
+                        */
+                       bool creds_received;
+                       /* Only used during credentials reception. */
+                       lttng_sock_cred creds;
+               } inbound;
+               struct {
+                       /*
+                        * Indicates whether or not a notification addressed to
+                        * this client was dropped because a command reply was
+                        * already buffered.
+                        *
+                        * A notification is dropped whenever the buffer is not
+                        * empty.
+                        */
+                       bool dropped_notification;
+                       /*
+                        * Indicates whether or not a command reply is already
+                        * buffered. In this case, it means that the client is
+                        * not consuming command replies before emitting a new
+                        * one. This could be caused by a protocol error or a
+                        * misbehaving/malicious client.
+                        */
+                       bool queued_command_reply;
+                       struct lttng_payload payload;
+               } outbound;
+       } communication;
+       /* call_rcu delayed reclaim. */
+       struct rcu_head rcu_node;
+};
+
+enum client_transmission_status {
+       CLIENT_TRANSMISSION_STATUS_COMPLETE,
+       CLIENT_TRANSMISSION_STATUS_QUEUED,
+       /* Communication failure. */
+       CLIENT_TRANSMISSION_STATUS_FAIL,
+       /* Fatal error. */
+       CLIENT_TRANSMISSION_STATUS_ERROR,
+};
+
+bool notification_client_list_get(struct notification_client_list *list);
+
+void notification_client_list_put(struct notification_client_list *list);
+
+/* Only returns a non-zero value if a fatal error occurred. */
+typedef int (*report_client_transmission_result_cb)(
+               struct notification_client *client,
+               enum client_transmission_status status,
+               void *user_data);
+
+int notification_client_list_send_evaluation(
+               struct notification_client_list *list,
+               const struct lttng_trigger *trigger,
+               const struct lttng_evaluation *evaluation,
+               const struct lttng_credentials *source_object_creds,
+               report_client_transmission_result_cb client_report,
+               void *user_data);
+
+int notification_thread_client_communication_update(
+               struct notification_thread_handle *handle,
+               notification_client_id id,
+               enum client_transmission_status transmission_status);
+
+/*
+ * Takes ownership of the payload if present.
+ */
+struct lttng_event_notifier_notification *lttng_event_notifier_notification_create(
+               uint64_t tracer_token,
+               enum lttng_domain_type domain,
+               char *payload,
+               size_t payload_size);
+
+void lttng_event_notifier_notification_destroy(
+               struct lttng_event_notifier_notification *event_notifier_notification);
+
+#endif /* NOTIFICATION_THREAD_INTERNAL_H */
index 867fc7c044c679d658c331c3c94420bd8b1bf2e2..74e37902db0056d5599fa57dd4da4a72678451ea 100644 (file)
@@ -7,30 +7,30 @@
 
 #define _LGPL_SOURCE
 #include <lttng/trigger/trigger.h>
-#include <lttng/notification/channel-internal.h>
-#include <lttng/notification/notification-internal.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <common/error.h>
-#include <common/config/session-config.h>
-#include <common/defaults.h>
-#include <common/utils.h>
-#include <common/align.h>
-#include <common/time.h>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/notification/notification-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <common/error.hpp>
+#include <common/config/session-config.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
+#include <common/align.hpp>
+#include <common/time.hpp>
 #include <sys/stat.h>
 #include <time.h>
 #include <signal.h>
 
-#include "notification-thread.h"
-#include "notification-thread-events.h"
-#include "notification-thread-commands.h"
-#include "lttng-sessiond.h"
-#include "health-sessiond.h"
-#include "thread.h"
-#include "testpoint.h"
+#include "notification-thread.hpp"
+#include "notification-thread-events.hpp"
+#include "notification-thread-commands.hpp"
+#include "lttng-sessiond.hpp"
+#include "health-sessiond.hpp"
+#include "thread.hpp"
+#include "testpoint.hpp"
 
-#include "kernel.h"
-#include <common/kernel-ctl/kernel-ctl.h>
+#include "kernel.hpp"
+#include <common/kernel-ctl/kernel-ctl.hpp>
 
 #include <urcu.h>
 #include <urcu/list.h>
diff --git a/src/bin/lttng-sessiond/notification-thread.h b/src/bin/lttng-sessiond/notification-thread.h
deleted file mode 100644 (file)
index 8b4c7af..0000000
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef NOTIFICATION_THREAD_H
-#define NOTIFICATION_THREAD_H
-
-#include "action-executor.h"
-#include "thread.h"
-#include <common/compat/poll.h>
-#include <common/hashtable/hashtable.h>
-#include <common/pipe.h>
-#include <lttng/trigger/trigger.h>
-#include <lttng/domain.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <urcu.h>
-#include <urcu/list.h>
-#include <urcu/rculfhash.h>
-
-typedef uint64_t notification_client_id;
-
-/*
- * The notification thread holds no ownership of the tracer event source pipe
- * file descriptor. The tracer management logic must remove the event source
- * from the notification thread (see external commands) before releasing
- * this file descriptor.
- */
-struct notification_event_tracer_event_source_element {
-       int fd;
-       /*
-        * A tracer event source can be removed from the notification thread's
-        * poll set before the end of its lifetime (for instance, when an error
-        * or hang-up is detected on its file descriptor). This is done to
-        * allow the notification thread to ignore follow-up events on this
-        * file descriptors.
-        *
-        * Under such circumstances, the notification thread still expects
-        * the normal clean-up to occur through the 'REMOVE_TRACER_EVENT_SOURCE'
-        * command.
-        */
-       bool is_fd_in_poll_set;
-       enum lttng_domain_type domain;
-       struct cds_list_head node;
-};
-
-struct notification_trigger_tokens_ht_element {
-       uint64_t token;
-       /* Weak reference to the trigger. */
-       struct lttng_trigger *trigger;
-       struct cds_lfht_node node;
-       /* call_rcu delayed reclaim. */
-       struct rcu_head rcu_node;
-};
-
-struct notification_thread_handle {
-       /*
-        * Queue of struct notification command.
-        * event_pipe must be WRITE(2) to signal that a new command
-        * has been enqueued.
-        */
-       struct {
-               struct lttng_pipe *event_pipe;
-               struct cds_list_head list;
-               pthread_mutex_t lock;
-       } cmd_queue;
-       /*
-        * Read side of pipes used to receive channel status info collected
-        * by the various consumer daemons.
-        */
-       struct {
-               int ust32_consumer;
-               int ust64_consumer;
-               int kernel_consumer;
-       } channel_monitoring_pipes;
-       /* Used to wait for the launch of the notification thread. */
-       sem_t ready;
-};
-
-/**
- * This thread maintains an internal state associating clients and triggers.
- *
- * In order to speed-up and simplify queries, hash tables providing the
- * following associations are maintained:
- *
- *   - client_socket_ht: associate a client's socket (fd) to its
- *             "struct notification_client".
- *             This hash table owns the "struct notification_client" which must
- *             thus be disposed-of on removal from the hash table.
- *
- *   - client_id_ht: associate a client's id to its "struct notification_client"
- *             This hash table holds a _weak_ reference to the
- *             "struct notification_client".
- *
- *   - channel_triggers_ht:
- *             associates a channel key to a list of
- *             struct lttng_trigger_list_nodes. The triggers in this list are
- *             those that have conditions that apply to a particular channel.
- *             A channel entry is only created when a channel is added; the
- *             list of triggers applying to such a channel is built at that
- *             moment.
- *             This hash table owns the list, but not the triggers themselves.
- *
- *   - session_triggers_ht:
- *             associates a session name to a list of
- *             struct lttng_trigger_list_nodes. The triggers in this list are
- *             those that have conditions that apply to a particular session.
- *             A session entry is only created when a session is created; the
- *             list of triggers applying to this new session is built at that
- *             moment. This happens at the time of creation of a session_info.
- *             Likewise, the list is destroyed at the time of the session_info's
- *             destruction.
- *
- *   - channel_state_ht:
- *             associates a pair (channel key, channel domain) to its last
- *             sampled state received from the consumer daemon
- *             (struct channel_state).
- *             This previous sample is kept to implement edge-triggered
- *             conditions as we need to detect the state transitions.
- *             This hash table owns the channel state.
- *
- *   - notification_trigger_clients_ht:
- *             associates notification-emitting triggers to clients
- *             (struct notification_client_list) subscribed to those
- *             conditions.
- *             The condition's hash and match functions are used directly since
- *             all triggers in this hash table have the "notify" action.
- *             This hash table holds no ownership.
- *
- *   - channels_ht:
- *             associates a channel_key to a struct channel_info. The hash table
- *             holds the ownership of the struct channel_info.
- *
- *   - sessions_ht:
- *             associates a session_name (hash) to a struct session_info. The
- *             hash table holds no ownership of the struct session_info;
- *             the session_info structure is owned by the session's various
- *             channels through their struct channel_info (ref-counting is used).
- *
- *   - triggers_ht:
- *             associates a trigger to a struct lttng_trigger_ht_element.
- *             The hash table holds the ownership of the
- *             lttng_trigger_ht_elements along with the triggers themselves.
- *   - triggers_by_name_uid_ht:
- *             associates a trigger (name, uid) tuple to
- *             a struct lttng_trigger_ht_element.
- *             The hash table does not hold any ownership and is used strictly
- *             for lookup on registration.
- *   - tracer_event_sources_list:
- *             A list of tracer event source (read side fd) of type
-*              struct notification_event_tracer_event_source_element.
-*
- *
- * The thread reacts to the following internal events:
- *   1) creation of a tracing channel,
- *   2) destruction of a tracing channel,
- *   3) registration of a trigger,
- *   4) unregistration of a trigger,
- *   5) reception of a channel monitor sample from the consumer daemon,
- *   6) Session rotation ongoing,
- *   7) Session rotation completed,
- *   8) registration of a tracer event source,
- *   9) unregistration of a tracer event source,
- *
- * Events specific to notification-emitting triggers:
- *   9) connection of a notification client,
- *   10) disconnection of a notification client,
- *   11) subscription of a client to a conditions' notifications,
- *   12) unsubscription of a client from a conditions' notifications,
- *
- *
- * 1) Creation of a tracing channel
- *    - notification_trigger_clients_ht is traversed to identify
- *      triggers which apply to this new channel,
- *      - triggers identified are added to the channel_triggers_ht.
- *    - add channel to channels_ht
- *    - if it is the first channel of a session, a session_info is created and
- *      added to the sessions_ht. A list of the triggers associated with that
- *      session is built, and it is added to session_triggers_ht.
- *
- * 2) Destruction of a tracing channel
- *    - remove entry from channel_triggers_ht, releasing the list wrapper and
- *      elements,
- *    - remove entry from the channel_state_ht.
- *    - remove channel from channels_ht
- *    - if it was the last known channel of a session, the session_info
- *      structure is torndown, which in return destroys the list of triggers
- *      applying to that session.
- *
- * 3) Registration of a trigger
- *    - if the trigger's action is of type "notify",
- *      - traverse the list of conditions of every client to build a list of
- *        clients which have to be notified when this trigger's condition is met,
- *        - add list of clients (even if it is empty) to the
- *          notification_trigger_clients_ht,
- *    - add trigger to channel_triggers_ht (if applicable),
- *    - add trigger to session_triggers_ht (if applicable),
- *    - add trigger to triggers_by_name_uid_ht
- *    - add trigger to triggers_ht
- *    - evaluate the trigger's condition right away to react if that condition
- *      is true from the beginning.
- *
- * 4) Unregistration of a trigger
- *    - if the trigger's action is of type "notify",
- *      - remove the trigger from the notification_trigger_clients_ht,
- *    - remove trigger from channel_triggers_ht (if applicable),
- *    - remove trigger from session_triggers_ht (if applicable),
- *    - remove trigger from triggers_by_name_uid_ht
- *    - remove trigger from triggers_ht
- *
- * 5) Reception of a channel monitor sample from the consumer daemon
- *    - evaluate the conditions associated with the triggers found in
- *      the channel_triggers_ht,
- *      - if a condition evaluates to "true" and the condition is of type
- *        "notify", query the notification_trigger_clients_ht and send
- *        a notification to the clients.
- *
- * 6) Session rotation ongoing
- *
- * 7) Session rotation completed
- *
- * 8) Registration of a tracer event source
- *    - Add the tracer event source of the application to
- *      tracer_event_sources_list,
- *    - Add the trace event source to the pollset.
- *
- * 8) Unregistration of a tracer event source
- *    - Remove the tracer event source of the application from
- *      tracer_event_sources_list,
- *    - Remove the trace event source from the pollset.
- *
- * 10) Connection of a client
- *    - add client socket to the client_socket_ht,
- *    - add client socket to the client_id_ht.
- *
- * 11) Disconnection of a client
- *    - remove client socket from the client_id_ht,
- *    - remove client socket from the client_socket_ht,
- *    - traverse all conditions to which the client is subscribed and remove
- *      the client from the notification_trigger_clients_ht.
- *
- * 12) Subscription of a client to a condition's notifications
- *    - Add the condition to the client's list of subscribed conditions,
- *    - Look-up notification_trigger_clients_ht and add the client to
- *      list of clients.
- *    - Evaluate the condition for the client that subscribed if the trigger
- *      was already registered.
- *
- * 13) Unsubscription of a client to a condition's notifications
- *    - Remove the condition from the client's list of subscribed conditions,
- *    - Look-up notification_trigger_clients_ht and remove the client
- *      from the list of clients.
- */
-struct notification_thread_state {
-       int notification_channel_socket;
-       struct lttng_poll_event events;
-       struct cds_lfht *client_socket_ht;
-       struct cds_lfht *client_id_ht;
-       struct cds_lfht *channel_triggers_ht;
-       struct cds_lfht *session_triggers_ht;
-       struct cds_lfht *channel_state_ht;
-       struct cds_lfht *notification_trigger_clients_ht;
-       struct cds_lfht *channels_ht;
-       struct cds_lfht *sessions_ht;
-       struct cds_lfht *triggers_ht;
-       struct cds_lfht *triggers_by_name_uid_ht;
-       struct cds_lfht *trigger_tokens_ht;
-       struct {
-               uint64_t next_tracer_token;
-               uint64_t name_offset;
-       } trigger_id;
-       /*
-        * Read side of the pipes used to receive tracer events. As their name
-        * implies, tracer event source activity originate from either
-        * registered applications (user space tracer) or from the kernel
-        * tracer.
-        *
-        * The list is not protected by a lock since add and remove operations
-        * are currently done only by the notification thread through in
-        * response to blocking commands.
-        */
-       struct cds_list_head tracer_event_sources_list;
-       notification_client_id next_notification_client_id;
-       struct action_executor *executor;
-
-       /*
-        * Indicates the thread to break for the poll event processing loop and
-        * call _poll_wait() again.
-        *
-        * This is necessary because some events on one fd might trigger the
-        * consumption of another fd.
-        * For example, a single _poll_wait() call can return notification
-        * thread commands and events from the tracer event source (event
-        * notifier).
-        * Picture a scenario where we receive two events:
-        *  the first one is a _REMOVE_TRACER_EVENT_SOURCE command, and
-        *  the second is an POLLIN on the tracer event source fd.
-        *
-        * The _REMOVE_TRACER_EVENT_SOURCE will read all the data of the
-        * removed tracer event source.
-        *
-        * The second event is now invalid has we consumed all the data for
-        * which we received the POLLIN.
-        *
-        * For this reason, we need to break for the event processing loop and
-        * call _poll_wait() again to get a clean view of the activity on the
-        * fds.
-        */
-       bool restart_poll;
-};
-
-/* notification_thread_data takes ownership of the channel monitor pipes. */
-struct notification_thread_handle *notification_thread_handle_create(
-               struct lttng_pipe *ust32_channel_monitor_pipe,
-               struct lttng_pipe *ust64_channel_monitor_pipe,
-               struct lttng_pipe *kernel_channel_monitor_pipe);
-void notification_thread_handle_destroy(
-               struct notification_thread_handle *handle);
-struct lttng_thread *launch_notification_thread(
-               struct notification_thread_handle *handle);
-
-#endif /* NOTIFICATION_THREAD_H */
diff --git a/src/bin/lttng-sessiond/notification-thread.hpp b/src/bin/lttng-sessiond/notification-thread.hpp
new file mode 100644 (file)
index 0000000..3444af9
--- /dev/null
@@ -0,0 +1,325 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef NOTIFICATION_THREAD_H
+#define NOTIFICATION_THREAD_H
+
+#include "action-executor.hpp"
+#include "thread.hpp"
+#include <common/compat/poll.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/pipe.hpp>
+#include <lttng/trigger/trigger.h>
+#include <lttng/domain.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <urcu.h>
+#include <urcu/list.h>
+#include <urcu/rculfhash.h>
+
+typedef uint64_t notification_client_id;
+
+/*
+ * The notification thread holds no ownership of the tracer event source pipe
+ * file descriptor. The tracer management logic must remove the event source
+ * from the notification thread (see external commands) before releasing
+ * this file descriptor.
+ */
+struct notification_event_tracer_event_source_element {
+       int fd;
+       /*
+        * A tracer event source can be removed from the notification thread's
+        * poll set before the end of its lifetime (for instance, when an error
+        * or hang-up is detected on its file descriptor). This is done to
+        * allow the notification thread to ignore follow-up events on this
+        * file descriptors.
+        *
+        * Under such circumstances, the notification thread still expects
+        * the normal clean-up to occur through the 'REMOVE_TRACER_EVENT_SOURCE'
+        * command.
+        */
+       bool is_fd_in_poll_set;
+       enum lttng_domain_type domain;
+       struct cds_list_head node;
+};
+
+struct notification_trigger_tokens_ht_element {
+       uint64_t token;
+       /* Weak reference to the trigger. */
+       struct lttng_trigger *trigger;
+       struct cds_lfht_node node;
+       /* call_rcu delayed reclaim. */
+       struct rcu_head rcu_node;
+};
+
+struct notification_thread_handle {
+       /*
+        * Queue of struct notification command.
+        * event_pipe must be WRITE(2) to signal that a new command
+        * has been enqueued.
+        */
+       struct {
+               struct lttng_pipe *event_pipe;
+               struct cds_list_head list;
+               pthread_mutex_t lock;
+       } cmd_queue;
+       /*
+        * Read side of pipes used to receive channel status info collected
+        * by the various consumer daemons.
+        */
+       struct {
+               int ust32_consumer;
+               int ust64_consumer;
+               int kernel_consumer;
+       } channel_monitoring_pipes;
+       /* Used to wait for the launch of the notification thread. */
+       sem_t ready;
+};
+
+/**
+ * This thread maintains an internal state associating clients and triggers.
+ *
+ * In order to speed-up and simplify queries, hash tables providing the
+ * following associations are maintained:
+ *
+ *   - client_socket_ht: associate a client's socket (fd) to its
+ *             "struct notification_client".
+ *             This hash table owns the "struct notification_client" which must
+ *             thus be disposed-of on removal from the hash table.
+ *
+ *   - client_id_ht: associate a client's id to its "struct notification_client"
+ *             This hash table holds a _weak_ reference to the
+ *             "struct notification_client".
+ *
+ *   - channel_triggers_ht:
+ *             associates a channel key to a list of
+ *             struct lttng_trigger_list_nodes. The triggers in this list are
+ *             those that have conditions that apply to a particular channel.
+ *             A channel entry is only created when a channel is added; the
+ *             list of triggers applying to such a channel is built at that
+ *             moment.
+ *             This hash table owns the list, but not the triggers themselves.
+ *
+ *   - session_triggers_ht:
+ *             associates a session name to a list of
+ *             struct lttng_trigger_list_nodes. The triggers in this list are
+ *             those that have conditions that apply to a particular session.
+ *             A session entry is only created when a session is created; the
+ *             list of triggers applying to this new session is built at that
+ *             moment. This happens at the time of creation of a session_info.
+ *             Likewise, the list is destroyed at the time of the session_info's
+ *             destruction.
+ *
+ *   - channel_state_ht:
+ *             associates a pair (channel key, channel domain) to its last
+ *             sampled state received from the consumer daemon
+ *             (struct channel_state).
+ *             This previous sample is kept to implement edge-triggered
+ *             conditions as we need to detect the state transitions.
+ *             This hash table owns the channel state.
+ *
+ *   - notification_trigger_clients_ht:
+ *             associates notification-emitting triggers to clients
+ *             (struct notification_client_list) subscribed to those
+ *             conditions.
+ *             The condition's hash and match functions are used directly since
+ *             all triggers in this hash table have the "notify" action.
+ *             This hash table holds no ownership.
+ *
+ *   - channels_ht:
+ *             associates a channel_key to a struct channel_info. The hash table
+ *             holds the ownership of the struct channel_info.
+ *
+ *   - sessions_ht:
+ *             associates a session_name (hash) to a struct session_info. The
+ *             hash table holds no ownership of the struct session_info;
+ *             the session_info structure is owned by the session's various
+ *             channels through their struct channel_info (ref-counting is used).
+ *
+ *   - triggers_ht:
+ *             associates a trigger to a struct lttng_trigger_ht_element.
+ *             The hash table holds the ownership of the
+ *             lttng_trigger_ht_elements along with the triggers themselves.
+ *   - triggers_by_name_uid_ht:
+ *             associates a trigger (name, uid) tuple to
+ *             a struct lttng_trigger_ht_element.
+ *             The hash table does not hold any ownership and is used strictly
+ *             for lookup on registration.
+ *   - tracer_event_sources_list:
+ *             A list of tracer event source (read side fd) of type
+*              struct notification_event_tracer_event_source_element.
+*
+ *
+ * The thread reacts to the following internal events:
+ *   1) creation of a tracing channel,
+ *   2) destruction of a tracing channel,
+ *   3) registration of a trigger,
+ *   4) unregistration of a trigger,
+ *   5) reception of a channel monitor sample from the consumer daemon,
+ *   6) Session rotation ongoing,
+ *   7) Session rotation completed,
+ *   8) registration of a tracer event source,
+ *   9) unregistration of a tracer event source,
+ *
+ * Events specific to notification-emitting triggers:
+ *   9) connection of a notification client,
+ *   10) disconnection of a notification client,
+ *   11) subscription of a client to a conditions' notifications,
+ *   12) unsubscription of a client from a conditions' notifications,
+ *
+ *
+ * 1) Creation of a tracing channel
+ *    - notification_trigger_clients_ht is traversed to identify
+ *      triggers which apply to this new channel,
+ *      - triggers identified are added to the channel_triggers_ht.
+ *    - add channel to channels_ht
+ *    - if it is the first channel of a session, a session_info is created and
+ *      added to the sessions_ht. A list of the triggers associated with that
+ *      session is built, and it is added to session_triggers_ht.
+ *
+ * 2) Destruction of a tracing channel
+ *    - remove entry from channel_triggers_ht, releasing the list wrapper and
+ *      elements,
+ *    - remove entry from the channel_state_ht.
+ *    - remove channel from channels_ht
+ *    - if it was the last known channel of a session, the session_info
+ *      structure is torndown, which in return destroys the list of triggers
+ *      applying to that session.
+ *
+ * 3) Registration of a trigger
+ *    - if the trigger's action is of type "notify",
+ *      - traverse the list of conditions of every client to build a list of
+ *        clients which have to be notified when this trigger's condition is met,
+ *        - add list of clients (even if it is empty) to the
+ *          notification_trigger_clients_ht,
+ *    - add trigger to channel_triggers_ht (if applicable),
+ *    - add trigger to session_triggers_ht (if applicable),
+ *    - add trigger to triggers_by_name_uid_ht
+ *    - add trigger to triggers_ht
+ *    - evaluate the trigger's condition right away to react if that condition
+ *      is true from the beginning.
+ *
+ * 4) Unregistration of a trigger
+ *    - if the trigger's action is of type "notify",
+ *      - remove the trigger from the notification_trigger_clients_ht,
+ *    - remove trigger from channel_triggers_ht (if applicable),
+ *    - remove trigger from session_triggers_ht (if applicable),
+ *    - remove trigger from triggers_by_name_uid_ht
+ *    - remove trigger from triggers_ht
+ *
+ * 5) Reception of a channel monitor sample from the consumer daemon
+ *    - evaluate the conditions associated with the triggers found in
+ *      the channel_triggers_ht,
+ *      - if a condition evaluates to "true" and the condition is of type
+ *        "notify", query the notification_trigger_clients_ht and send
+ *        a notification to the clients.
+ *
+ * 6) Session rotation ongoing
+ *
+ * 7) Session rotation completed
+ *
+ * 8) Registration of a tracer event source
+ *    - Add the tracer event source of the application to
+ *      tracer_event_sources_list,
+ *    - Add the trace event source to the pollset.
+ *
+ * 8) Unregistration of a tracer event source
+ *    - Remove the tracer event source of the application from
+ *      tracer_event_sources_list,
+ *    - Remove the trace event source from the pollset.
+ *
+ * 10) Connection of a client
+ *    - add client socket to the client_socket_ht,
+ *    - add client socket to the client_id_ht.
+ *
+ * 11) Disconnection of a client
+ *    - remove client socket from the client_id_ht,
+ *    - remove client socket from the client_socket_ht,
+ *    - traverse all conditions to which the client is subscribed and remove
+ *      the client from the notification_trigger_clients_ht.
+ *
+ * 12) Subscription of a client to a condition's notifications
+ *    - Add the condition to the client's list of subscribed conditions,
+ *    - Look-up notification_trigger_clients_ht and add the client to
+ *      list of clients.
+ *    - Evaluate the condition for the client that subscribed if the trigger
+ *      was already registered.
+ *
+ * 13) Unsubscription of a client to a condition's notifications
+ *    - Remove the condition from the client's list of subscribed conditions,
+ *    - Look-up notification_trigger_clients_ht and remove the client
+ *      from the list of clients.
+ */
+struct notification_thread_state {
+       int notification_channel_socket;
+       struct lttng_poll_event events;
+       struct cds_lfht *client_socket_ht;
+       struct cds_lfht *client_id_ht;
+       struct cds_lfht *channel_triggers_ht;
+       struct cds_lfht *session_triggers_ht;
+       struct cds_lfht *channel_state_ht;
+       struct cds_lfht *notification_trigger_clients_ht;
+       struct cds_lfht *channels_ht;
+       struct cds_lfht *sessions_ht;
+       struct cds_lfht *triggers_ht;
+       struct cds_lfht *triggers_by_name_uid_ht;
+       struct cds_lfht *trigger_tokens_ht;
+       struct {
+               uint64_t next_tracer_token;
+               uint64_t name_offset;
+       } trigger_id;
+       /*
+        * Read side of the pipes used to receive tracer events. As their name
+        * implies, tracer event source activity originate from either
+        * registered applications (user space tracer) or from the kernel
+        * tracer.
+        *
+        * The list is not protected by a lock since add and remove operations
+        * are currently done only by the notification thread through in
+        * response to blocking commands.
+        */
+       struct cds_list_head tracer_event_sources_list;
+       notification_client_id next_notification_client_id;
+       struct action_executor *executor;
+
+       /*
+        * Indicates the thread to break for the poll event processing loop and
+        * call _poll_wait() again.
+        *
+        * This is necessary because some events on one fd might trigger the
+        * consumption of another fd.
+        * For example, a single _poll_wait() call can return notification
+        * thread commands and events from the tracer event source (event
+        * notifier).
+        * Picture a scenario where we receive two events:
+        *  the first one is a _REMOVE_TRACER_EVENT_SOURCE command, and
+        *  the second is an POLLIN on the tracer event source fd.
+        *
+        * The _REMOVE_TRACER_EVENT_SOURCE will read all the data of the
+        * removed tracer event source.
+        *
+        * The second event is now invalid has we consumed all the data for
+        * which we received the POLLIN.
+        *
+        * For this reason, we need to break for the event processing loop and
+        * call _poll_wait() again to get a clean view of the activity on the
+        * fds.
+        */
+       bool restart_poll;
+};
+
+/* notification_thread_data takes ownership of the channel monitor pipes. */
+struct notification_thread_handle *notification_thread_handle_create(
+               struct lttng_pipe *ust32_channel_monitor_pipe,
+               struct lttng_pipe *ust64_channel_monitor_pipe,
+               struct lttng_pipe *kernel_channel_monitor_pipe);
+void notification_thread_handle_destroy(
+               struct notification_thread_handle *handle);
+struct lttng_thread *launch_notification_thread(
+               struct notification_thread_handle *handle);
+
+#endif /* NOTIFICATION_THREAD_H */
index 0e799ff261a5b11d0822004e5293f0b0c96d1a77..8e238e5c15ba4a68a471979fead43753061954b5 100644 (file)
@@ -7,16 +7,16 @@
 
 #define _LGPL_SOURCE
 
-#include <common/common.h>
-#include <common/utils.h>
-
-#include "fd-limit.h"
-#include "lttng-sessiond.h"
-#include "notify-apps.h"
-#include "health-sessiond.h"
-#include "testpoint.h"
-#include "utils.h"
-#include "thread.h"
+#include <common/common.hpp>
+#include <common/utils.hpp>
+
+#include "fd-limit.hpp"
+#include "lttng-sessiond.hpp"
+#include "notify-apps.hpp"
+#include "health-sessiond.hpp"
+#include "testpoint.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
 
 struct thread_notifiers {
        struct lttng_pipe *quit_pipe;
diff --git a/src/bin/lttng-sessiond/notify-apps.h b/src/bin/lttng-sessiond/notify-apps.h
deleted file mode 100644 (file)
index 152a52a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef UST_THREAD_H
-#define UST_THREAD_H
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-bool launch_application_notification_thread(int apps_cmd_notify_pipe_read_fd);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static
-bool launch_application_notification_thread(
-               int apps_cmd_notify_pipe_read_fd __attribute__((unused)))
-{
-       return true;
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* UST_THREAD_H */
diff --git a/src/bin/lttng-sessiond/notify-apps.hpp b/src/bin/lttng-sessiond/notify-apps.hpp
new file mode 100644 (file)
index 0000000..152a52a
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef UST_THREAD_H
+#define UST_THREAD_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+bool launch_application_notification_thread(int apps_cmd_notify_pipe_read_fd);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static
+bool launch_application_notification_thread(
+               int apps_cmd_notify_pipe_read_fd __attribute__((unused)))
+{
+       return true;
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* UST_THREAD_H */
index d2e52172e53195b3a7f48be91de2e02237db1809..a3122da758395bb4a3a0db341e0f6df81a72c03f 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include <signal.h>
-#include "lttng-sessiond.h"
+#include "lttng-sessiond.hpp"
 
 /* Notify parents that we are ready for cmd and health check */
 void sessiond_signal_parents(void)
index a20db57f6606a88e95ced320ec03eeaa0cf19cce..36a29d86316586487d90851f37fbf1092c5d44aa 100644 (file)
 #include <stddef.h>
 #include <stdlib.h>
 #include <urcu.h>
-#include <common/futex.h>
-#include <common/macros.h>
-#include <common/shm.h>
-#include <common/utils.h>
+#include <common/futex.hpp>
+#include <common/macros.hpp>
+#include <common/shm.hpp>
+#include <common/utils.hpp>
 #include <sys/stat.h>
 
-#include "register.h"
-#include "lttng-sessiond.h"
-#include "testpoint.h"
-#include "health-sessiond.h"
-#include "fd-limit.h"
-#include "utils.h"
-#include "thread.h"
+#include "register.hpp"
+#include "lttng-sessiond.hpp"
+#include "testpoint.hpp"
+#include "health-sessiond.hpp"
+#include "fd-limit.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
 
 struct thread_state {
        struct lttng_pipe *quit_pipe;
diff --git a/src/bin/lttng-sessiond/register.h b/src/bin/lttng-sessiond/register.h
deleted file mode 100644 (file)
index 8b51ad4..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_APPLICATION_REGISTRATION_THREAD_H
-#define SESSIOND_APPLICATION_REGISTRATION_THREAD_H
-
-#include <stdbool.h>
-#include "lttng-sessiond.h"
-
-struct lttng_thread *launch_application_registration_thread(
-               struct ust_cmd_queue *cmd_queue);
-
-#endif /* SESSIOND_APPLICATION_REGISTRATION_THREAD_H */
diff --git a/src/bin/lttng-sessiond/register.hpp b/src/bin/lttng-sessiond/register.hpp
new file mode 100644 (file)
index 0000000..ef82a2c
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_APPLICATION_REGISTRATION_THREAD_H
+#define SESSIOND_APPLICATION_REGISTRATION_THREAD_H
+
+#include <stdbool.h>
+#include "lttng-sessiond.hpp"
+
+struct lttng_thread *launch_application_registration_thread(
+               struct ust_cmd_queue *cmd_queue);
+
+#endif /* SESSIOND_APPLICATION_REGISTRATION_THREAD_H */
index cdf95f353dbbfa2cb0ba276cdba6292d26dc92ae..51fc5e8aad81a6e94f73bdb5984beaaea45f4412 100644 (file)
@@ -8,32 +8,32 @@
 
 #define _LGPL_SOURCE
 #include <lttng/trigger/trigger.h>
-#include <common/error.h>
-#include <common/config/session-config.h>
-#include <common/defaults.h>
-#include <common/utils.h>
-#include <common/futex.h>
-#include <common/align.h>
-#include <common/time.h>
-#include <common/hashtable/utils.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/credentials.h>
+#include <common/error.hpp>
+#include <common/config/session-config.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
+#include <common/futex.hpp>
+#include <common/align.hpp>
+#include <common/time.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/credentials.hpp>
 #include <sys/stat.h>
 #include <time.h>
 #include <signal.h>
 #include <inttypes.h>
 
-#include <lttng/notification/channel-internal.h>
-#include <lttng/rotate-internal.h>
-
-#include "session.h"
-#include "rotate.h"
-#include "rotation-thread.h"
-#include "lttng-sessiond.h"
-#include "health-sessiond.h"
-#include "cmd.h"
-#include "utils.h"
-#include "notification-thread-commands.h"
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/rotate-internal.hpp>
+
+#include "session.hpp"
+#include "rotate.hpp"
+#include "rotation-thread.hpp"
+#include "lttng-sessiond.hpp"
+#include "health-sessiond.hpp"
+#include "cmd.hpp"
+#include "utils.hpp"
+#include "notification-thread-commands.hpp"
 
 #include <urcu.h>
 #include <urcu/list.h>
diff --git a/src/bin/lttng-sessiond/rotate.h b/src/bin/lttng-sessiond/rotate.h
deleted file mode 100644 (file)
index a2adaf0..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef ROTATE_H
-#define ROTATE_H
-
-#include "rotation-thread.h"
-#include <stdint.h>
-
-/*
- * Subscribe/unsubscribe the notification_channel from the rotation_thread to
- * session usage notifications to perform size-based rotations.
- */
-int subscribe_session_consumed_size_rotation(struct ltt_session *session,
-               uint64_t size,
-               struct notification_thread_handle *notification_thread_handle);
-int unsubscribe_session_consumed_size_rotation(struct ltt_session *session,
-               struct notification_thread_handle *notification_thread_handle);
-
-#endif /* ROTATE_H */
diff --git a/src/bin/lttng-sessiond/rotate.hpp b/src/bin/lttng-sessiond/rotate.hpp
new file mode 100644 (file)
index 0000000..965a8c7
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef ROTATE_H
+#define ROTATE_H
+
+#include "rotation-thread.hpp"
+#include <stdint.h>
+
+/*
+ * Subscribe/unsubscribe the notification_channel from the rotation_thread to
+ * session usage notifications to perform size-based rotations.
+ */
+int subscribe_session_consumed_size_rotation(struct ltt_session *session,
+               uint64_t size,
+               struct notification_thread_handle *notification_thread_handle);
+int unsubscribe_session_consumed_size_rotation(struct ltt_session *session,
+               struct notification_thread_handle *notification_thread_handle);
+
+#endif /* ROTATE_H */
index 9c873aec5b6c1e028806e478f2e16e398a8d2249..2f89fbc64ee875f8e94f5efc78b34e6a57648575 100644 (file)
@@ -8,35 +8,35 @@
 
 #define _LGPL_SOURCE
 #include <lttng/trigger/trigger.h>
-#include <common/error.h>
-#include <common/config/session-config.h>
-#include <common/defaults.h>
-#include <common/utils.h>
-#include <common/futex.h>
-#include <common/align.h>
-#include <common/time.h>
-#include <common/hashtable/utils.h>
+#include <common/error.hpp>
+#include <common/config/session-config.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
+#include <common/futex.hpp>
+#include <common/align.hpp>
+#include <common/time.hpp>
+#include <common/hashtable/utils.hpp>
 #include <sys/stat.h>
 #include <time.h>
 #include <signal.h>
 #include <inttypes.h>
 
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <lttng/notification/channel-internal.h>
-#include <lttng/rotate-internal.h>
-#include <lttng/location-internal.h>
-#include <lttng/condition/condition-internal.h>
-
-#include "rotation-thread.h"
-#include "lttng-sessiond.h"
-#include "health-sessiond.h"
-#include "rotate.h"
-#include "cmd.h"
-#include "session.h"
-#include "timer.h"
-#include "notification-thread-commands.h"
-#include "utils.h"
-#include "thread.h"
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/rotate-internal.hpp>
+#include <lttng/location-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+
+#include "rotation-thread.hpp"
+#include "lttng-sessiond.hpp"
+#include "health-sessiond.hpp"
+#include "rotate.hpp"
+#include "cmd.hpp"
+#include "session.hpp"
+#include "timer.hpp"
+#include "notification-thread-commands.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
 
 #include <urcu.h>
 #include <urcu/list.h>
diff --git a/src/bin/lttng-sessiond/rotation-thread.h b/src/bin/lttng-sessiond/rotation-thread.h
deleted file mode 100644 (file)
index 27ef395..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef ROTATION_THREAD_H
-#define ROTATION_THREAD_H
-
-#include <urcu/list.h>
-#include <urcu.h>
-#include <urcu/rculfhash.h>
-#include <lttng/domain.h>
-#include <common/pipe.h>
-#include <common/compat/poll.h>
-#include <common/hashtable/hashtable.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include "session.h"
-#include "notification-thread.h"
-
-extern struct lttng_notification_channel *rotate_notification_channel;
-
-enum rotation_thread_job_type {
-       ROTATION_THREAD_JOB_TYPE_SCHEDULED_ROTATION,
-       ROTATION_THREAD_JOB_TYPE_CHECK_PENDING_ROTATION
-};
-
-struct rotation_thread_timer_queue;
-struct rotation_thread_handle;
-
-struct rotation_thread_timer_queue *rotation_thread_timer_queue_create(void);
-void rotation_thread_timer_queue_destroy(
-               struct rotation_thread_timer_queue *queue);
-
-struct rotation_thread_handle *rotation_thread_handle_create(
-               struct rotation_thread_timer_queue *rotation_timer_queue,
-               struct notification_thread_handle *notification_thread_handle);
-
-void rotation_thread_handle_destroy(
-               struct rotation_thread_handle *handle);
-
-void rotation_thread_enqueue_job(struct rotation_thread_timer_queue *queue,
-               enum rotation_thread_job_type job_type,
-               struct ltt_session *session);
-
-bool launch_rotation_thread(struct rotation_thread_handle *handle);
-
-#endif /* ROTATION_THREAD_H */
diff --git a/src/bin/lttng-sessiond/rotation-thread.hpp b/src/bin/lttng-sessiond/rotation-thread.hpp
new file mode 100644 (file)
index 0000000..d2bbf29
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef ROTATION_THREAD_H
+#define ROTATION_THREAD_H
+
+#include <urcu/list.h>
+#include <urcu.h>
+#include <urcu/rculfhash.h>
+#include <lttng/domain.h>
+#include <common/pipe.hpp>
+#include <common/compat/poll.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <pthread.h>
+#include <semaphore.h>
+#include "session.hpp"
+#include "notification-thread.hpp"
+
+extern struct lttng_notification_channel *rotate_notification_channel;
+
+enum rotation_thread_job_type {
+       ROTATION_THREAD_JOB_TYPE_SCHEDULED_ROTATION,
+       ROTATION_THREAD_JOB_TYPE_CHECK_PENDING_ROTATION
+};
+
+struct rotation_thread_timer_queue;
+struct rotation_thread_handle;
+
+struct rotation_thread_timer_queue *rotation_thread_timer_queue_create(void);
+void rotation_thread_timer_queue_destroy(
+               struct rotation_thread_timer_queue *queue);
+
+struct rotation_thread_handle *rotation_thread_handle_create(
+               struct rotation_thread_timer_queue *rotation_timer_queue,
+               struct notification_thread_handle *notification_thread_handle);
+
+void rotation_thread_handle_destroy(
+               struct rotation_thread_handle *handle);
+
+void rotation_thread_enqueue_job(struct rotation_thread_timer_queue *queue,
+               enum rotation_thread_job_type job_type,
+               struct ltt_session *session);
+
+bool launch_rotation_thread(struct rotation_thread_handle *handle);
+
+#endif /* ROTATION_THREAD_H */
index 2055e867de5eac86496a7cd599c0aee488510026..16b2705149e9fd59ce1ffedfa63ae8b32fa1922b 100644 (file)
 #include <urcu/uatomic.h>
 #include <unistd.h>
 
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/config/session-config.h>
-#include <common/utils.h>
-#include <common/runas.h>
-#include <lttng/save-internal.h>
-
-#include "kernel.h"
-#include "save.h"
-#include "session.h"
-#include "lttng-syscall.h"
-#include "trace-ust.h"
-#include "agent.h"
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/config/session-config.hpp>
+#include <common/utils.hpp>
+#include <common/runas.hpp>
+#include <lttng/save-internal.hpp>
+
+#include "kernel.hpp"
+#include "save.hpp"
+#include "session.hpp"
+#include "lttng-syscall.hpp"
+#include "trace-ust.hpp"
+#include "agent.hpp"
 
 /* Return LTTNG_OK on success else a LTTNG_ERR* code. */
 static
diff --git a/src/bin/lttng-sessiond/save.h b/src/bin/lttng-sessiond/save.h
deleted file mode 100644 (file)
index a39a12a..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SAVE_H
-#define SAVE_H
-
-#include <lttng/save.h>
-#include <common/compat/socket.h>
-
-int cmd_save_sessions(struct lttng_save_session_attr *attr,
-       lttng_sock_cred *creds);
-
-#endif /* SAVE_H */
diff --git a/src/bin/lttng-sessiond/save.hpp b/src/bin/lttng-sessiond/save.hpp
new file mode 100644 (file)
index 0000000..367b41c
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SAVE_H
+#define SAVE_H
+
+#include <lttng/save.h>
+#include <common/compat/socket.hpp>
+
+int cmd_save_sessions(struct lttng_save_session_attr *attr,
+       lttng_sock_cred *creds);
+
+#endif /* SAVE_H */
index 14de5468c7979f523cd98d0504e3fed70d54764c..bcab0147d70fbd7ee05c503a33fdeb5f2326c100 100644 (file)
 #include <sys/types.h>
 #include <pthread.h>
 
-#include <common/common.h>
-#include <common/utils.h>
-#include <common/trace-chunk.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/location-internal.h>
-#include "lttng-sessiond.h"
-#include "kernel.h"
-
-#include "session.h"
-#include "utils.h"
-#include "trace-ust.h"
-#include "timer.h"
-#include "cmd.h"
+#include <common/common.hpp>
+#include <common/utils.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/location-internal.hpp>
+#include "lttng-sessiond.hpp"
+#include "kernel.hpp"
+
+#include "session.hpp"
+#include "utils.hpp"
+#include "trace-ust.hpp"
+#include "timer.hpp"
+#include "cmd.hpp"
 
 struct ltt_session_destroy_notifier_element {
        ltt_session_destroy_notifier notifier;
diff --git a/src/bin/lttng-sessiond/session.h b/src/bin/lttng-sessiond/session.h
deleted file mode 100644 (file)
index 1a68d8e..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_SESSION_H
-#define _LTT_SESSION_H
-
-#include <limits.h>
-#include <stdbool.h>
-#include <urcu/list.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/dynamic-array.h>
-#include <lttng/rotation.h>
-#include <lttng/location.h>
-#include <lttng/lttng-error.h>
-
-#include "snapshot.h"
-#include "trace-kernel.h"
-#include "consumer.h"
-
-struct ltt_ust_session;
-
-typedef void (*ltt_session_destroy_notifier)(const struct ltt_session *session,
-               void *user_data);
-typedef void (*ltt_session_clear_notifier)(const struct ltt_session *session,
-               void *user_data);
-
-/*
- * Tracing session list
- *
- * Statically declared in session.c and can be accessed by using
- * session_get_list() function that returns the pointer to the list.
- */
-struct ltt_session_list {
-       /*
-        * This lock protects any read/write access to the list and
-        * next_uuid. All public functions in session.c acquire this
-        * lock and release it before returning. If none of those
-        * functions are used, the lock MUST be acquired in order to
-        * iterate or/and do any actions on that list.
-        */
-       pthread_mutex_t lock;
-       /*
-        * This condition variable is signaled on every removal from
-        * the session list.
-        */
-       pthread_cond_t removal_cond;
-
-       /*
-        * Session unique ID generator. The session list lock MUST be
-        * upon update and read of this counter.
-        */
-       uint64_t next_uuid;
-
-       /* Linked list head */
-       struct cds_list_head head;
-};
-
-/*
- * This data structure contains information needed to identify a tracing
- * session for both LTTng and UST.
- */
-struct ltt_session {
-       char name[NAME_MAX];
-       bool has_auto_generated_name;
-       bool name_contains_creation_time;
-       char hostname[LTTNG_HOST_NAME_MAX]; /* Local hostname. */
-       /* Path of the last closed chunk. */
-       char last_chunk_path[LTTNG_PATH_MAX];
-       time_t creation_time;
-       struct ltt_kernel_session *kernel_session;
-       struct ltt_ust_session *ust_session;
-       struct urcu_ref ref;
-       /*
-        * Protect any read/write on this session data structure. This lock must be
-        * acquired *before* using any public functions declared below. Use
-        * session_lock() and session_unlock() for that.
-        */
-       pthread_mutex_t lock;
-       struct cds_list_head list;
-       uint64_t id;            /* session unique identifier */
-       /* Indicates if the session has been added to the session list and ht.*/
-       bool published;
-       /* Indicates if a destroy command has been applied to this session. */
-       bool destroyed;
-       /* UID/GID of the user owning the session */
-       uid_t uid;
-       gid_t gid;
-       /*
-        * Network session handle. A value of 0 means that there is no remote
-        * session established.
-        */
-       uint64_t net_handle;
-       /*
-        * This consumer is only set when the create_session_uri call is made.
-        * This contains the temporary information for a consumer output. Upon
-        * creation of the UST or kernel session, this consumer, if available, is
-        * copied into those sessions.
-        */
-       struct consumer_output *consumer;
-       /*
-        * Indicates whether or not the user has specified an output directory
-        * or if it was configured using the default configuration.
-        */
-       bool has_user_specified_directory;
-       /* Did at least ONE start command has been triggered?. */
-       unsigned int has_been_started:1;
-       /*
-        * Is the session active? Start trace command sets this to 1 and the stop
-        * command reset it to 0.
-        */
-       unsigned int active:1;
-
-       /* Snapshot representation in a session. */
-       struct snapshot snapshot;
-       /* Indicate if the session has to output the traces or not. */
-       unsigned int output_traces;
-       /*
-        * This session is in snapshot mode. This means that channels enabled
-        * will be set in overwrite mode by default and must be in mmap
-        * output mode. Note that snapshots can be taken on a session that
-        * is not in "snapshot_mode". This parameter only affects channel
-        * creation defaults.
-        */
-       unsigned int snapshot_mode;
-       /*
-        * A session that has channels that don't use 'mmap' output can't be
-        * used to capture snapshots. This is set to true whenever a
-        * 'splice' kernel channel is enabled.
-        */
-       bool has_non_mmap_channel;
-       /*
-        * Timer set when the session is created for live reading.
-        */
-       unsigned int live_timer;
-       /*
-        * Path where to keep the shared memory files.
-        */
-       char shm_path[PATH_MAX];
-       /*
-        * Node in ltt_sessions_ht_by_id.
-        */
-       struct lttng_ht_node_u64 node;
-       /*
-        * Node in ltt_sessions_ht_by_name.
-        */
-       struct lttng_ht_node_str node_by_name;
-       /*
-        * Timer to check periodically if a relay and/or consumer has completed
-        * the last rotation.
-        */
-       bool rotation_pending_check_timer_enabled;
-       timer_t rotation_pending_check_timer;
-       /* Timer to periodically rotate a session. */
-       bool rotation_schedule_timer_enabled;
-       timer_t rotation_schedule_timer;
-       /* Value for periodic rotations, 0 if disabled. */
-       uint64_t rotate_timer_period;
-       /* Value for size-based rotations, 0 if disabled. */
-       uint64_t rotate_size;
-       /*
-        * Keep a state if this session was rotated after the last stop command.
-        * We only allow one rotation after a stop. At destroy, we also need to
-        * know if a rotation occurred since the last stop to rename the current
-        * chunk. After a stop followed by rotate, all subsequent clear
-        * (without prior start) will succeed, but will be effect-less.
-        */
-       bool rotated_after_last_stop;
-       /*
-        * Track whether the session was cleared after last stop. All subsequent
-        * clear (without prior start) will succeed, but will be effect-less. A
-        * subsequent rotate (without prior start) will return an error.
-        */
-       bool cleared_after_last_stop;
-       /*
-        * True if the session has had an explicit non-quiet rotation.
-        */
-       bool rotated;
-       /*
-        * Condition and trigger for size-based rotations.
-        */
-       struct lttng_condition *rotate_condition;
-       struct lttng_trigger *rotate_trigger;
-       LTTNG_OPTIONAL(uint64_t) most_recent_chunk_id;
-       struct lttng_trace_chunk *current_trace_chunk;
-       struct lttng_trace_chunk *chunk_being_archived;
-       /* Current state of a rotation. */
-       enum lttng_rotation_state rotation_state;
-       bool quiet_rotation;
-       char *last_archived_chunk_name;
-       LTTNG_OPTIONAL(uint64_t) last_archived_chunk_id;
-       struct lttng_dynamic_array destroy_notifiers;
-       struct lttng_dynamic_array clear_notifiers;
-       /* Session base path override. Set non-null. */
-       char *base_path;
-};
-
-enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
-               struct ltt_session **out_session);
-void session_lock(struct ltt_session *session);
-void session_unlock(struct ltt_session *session);
-
-/*
- * The session list lock covers more ground than its name implies. While
- * it does protect against concurent mutations of the session list, it is
- * also used as a multi-session lock when synchronizing newly-registered
- * 'user space tracer' and 'agent' applications.
- *
- * In other words, it prevents tracer configurations from changing while they
- * are being transmitted to the various applications.
- */
-void session_lock_list(void);
-int session_trylock_list(void);
-void session_unlock_list(void);
-
-void session_destroy(struct ltt_session *session);
-int session_add_destroy_notifier(struct ltt_session *session,
-               ltt_session_destroy_notifier notifier, void *user_data);
-
-int session_add_clear_notifier(struct ltt_session *session,
-               ltt_session_clear_notifier notifier, void *user_data);
-void session_notify_clear(struct ltt_session *session);
-
-bool session_get(struct ltt_session *session);
-void session_put(struct ltt_session *session);
-
-enum consumer_dst_type session_get_consumer_destination_type(
-               const struct ltt_session *session);
-const char *session_get_net_consumer_hostname(
-               const struct ltt_session *session);
-void session_get_net_consumer_ports(
-               const struct ltt_session *session,
-               uint16_t *control_port, uint16_t *data_port);
-struct lttng_trace_archive_location *session_get_trace_archive_location(
-               const struct ltt_session *session);
-
-struct ltt_session *session_find_by_name(const char *name);
-struct ltt_session *session_find_by_id(uint64_t id);
-
-struct ltt_session_list *session_get_list(void);
-void session_list_wait_empty(void);
-
-bool session_access_ok(struct ltt_session *session, uid_t uid);
-
-int session_reset_rotation_state(struct ltt_session *session,
-               enum lttng_rotation_state result);
-
-/* Create a new trace chunk object from the session's configuration. */
-struct lttng_trace_chunk *session_create_new_trace_chunk(
-               const struct ltt_session *session,
-               const struct consumer_output *consumer_output_override,
-               const char *session_base_path_override,
-               const char *chunk_name_override);
-
-/*
- * Set `new_trace_chunk` as the session's current trace chunk. A reference
- * to `new_trace_chunk` is acquired by the session. The chunk is created
- * on remote peers (consumer and relay daemons).
- *
- * A reference to the session's current trace chunk is returned through
- * `current_session_trace_chunk` on success.
- */
-int session_set_trace_chunk(struct ltt_session *session,
-               struct lttng_trace_chunk *new_trace_chunk,
-               struct lttng_trace_chunk **current_session_trace_chunk);
-
-/*
- * Close a chunk on the remote peers of a session. Has no effect on the
- * ltt_session itself.
- */
-int session_close_trace_chunk(struct ltt_session *session,
-               struct lttng_trace_chunk *trace_chunk,
-               enum lttng_trace_chunk_command_type close_command,
-               char *path);
-
-/* Open a packet in all channels of a given session. */
-enum lttng_error_code session_open_packets(struct ltt_session *session);
-
-bool session_output_supports_trace_chunks(const struct ltt_session *session);
-
-/*
- * Sample the id of a session looked up via its name.
- * Here the term "sampling" hint the caller that this return the id at a given
- * point in time with no guarantee that the session for which the id was
- * sampled still exist at that point.
- *
- * Return 0 when the session is not found,
- * Return 1 when the session is found and set `id`.
- */
-bool sample_session_id_by_name(const char *name, uint64_t *id);
-
-#endif /* _LTT_SESSION_H */
diff --git a/src/bin/lttng-sessiond/session.hpp b/src/bin/lttng-sessiond/session.hpp
new file mode 100644 (file)
index 0000000..85450b6
--- /dev/null
@@ -0,0 +1,296 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_SESSION_H
+#define _LTT_SESSION_H
+
+#include <limits.h>
+#include <stdbool.h>
+#include <urcu/list.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/dynamic-array.hpp>
+#include <lttng/rotation.h>
+#include <lttng/location.h>
+#include <lttng/lttng-error.h>
+
+#include "snapshot.hpp"
+#include "trace-kernel.hpp"
+#include "consumer.hpp"
+
+struct ltt_ust_session;
+
+typedef void (*ltt_session_destroy_notifier)(const struct ltt_session *session,
+               void *user_data);
+typedef void (*ltt_session_clear_notifier)(const struct ltt_session *session,
+               void *user_data);
+
+/*
+ * Tracing session list
+ *
+ * Statically declared in session.c and can be accessed by using
+ * session_get_list() function that returns the pointer to the list.
+ */
+struct ltt_session_list {
+       /*
+        * This lock protects any read/write access to the list and
+        * next_uuid. All public functions in session.c acquire this
+        * lock and release it before returning. If none of those
+        * functions are used, the lock MUST be acquired in order to
+        * iterate or/and do any actions on that list.
+        */
+       pthread_mutex_t lock;
+       /*
+        * This condition variable is signaled on every removal from
+        * the session list.
+        */
+       pthread_cond_t removal_cond;
+
+       /*
+        * Session unique ID generator. The session list lock MUST be
+        * upon update and read of this counter.
+        */
+       uint64_t next_uuid;
+
+       /* Linked list head */
+       struct cds_list_head head;
+};
+
+/*
+ * This data structure contains information needed to identify a tracing
+ * session for both LTTng and UST.
+ */
+struct ltt_session {
+       char name[NAME_MAX];
+       bool has_auto_generated_name;
+       bool name_contains_creation_time;
+       char hostname[LTTNG_HOST_NAME_MAX]; /* Local hostname. */
+       /* Path of the last closed chunk. */
+       char last_chunk_path[LTTNG_PATH_MAX];
+       time_t creation_time;
+       struct ltt_kernel_session *kernel_session;
+       struct ltt_ust_session *ust_session;
+       struct urcu_ref ref;
+       /*
+        * Protect any read/write on this session data structure. This lock must be
+        * acquired *before* using any public functions declared below. Use
+        * session_lock() and session_unlock() for that.
+        */
+       pthread_mutex_t lock;
+       struct cds_list_head list;
+       uint64_t id;            /* session unique identifier */
+       /* Indicates if the session has been added to the session list and ht.*/
+       bool published;
+       /* Indicates if a destroy command has been applied to this session. */
+       bool destroyed;
+       /* UID/GID of the user owning the session */
+       uid_t uid;
+       gid_t gid;
+       /*
+        * Network session handle. A value of 0 means that there is no remote
+        * session established.
+        */
+       uint64_t net_handle;
+       /*
+        * This consumer is only set when the create_session_uri call is made.
+        * This contains the temporary information for a consumer output. Upon
+        * creation of the UST or kernel session, this consumer, if available, is
+        * copied into those sessions.
+        */
+       struct consumer_output *consumer;
+       /*
+        * Indicates whether or not the user has specified an output directory
+        * or if it was configured using the default configuration.
+        */
+       bool has_user_specified_directory;
+       /* Did at least ONE start command has been triggered?. */
+       unsigned int has_been_started:1;
+       /*
+        * Is the session active? Start trace command sets this to 1 and the stop
+        * command reset it to 0.
+        */
+       unsigned int active:1;
+
+       /* Snapshot representation in a session. */
+       struct snapshot snapshot;
+       /* Indicate if the session has to output the traces or not. */
+       unsigned int output_traces;
+       /*
+        * This session is in snapshot mode. This means that channels enabled
+        * will be set in overwrite mode by default and must be in mmap
+        * output mode. Note that snapshots can be taken on a session that
+        * is not in "snapshot_mode". This parameter only affects channel
+        * creation defaults.
+        */
+       unsigned int snapshot_mode;
+       /*
+        * A session that has channels that don't use 'mmap' output can't be
+        * used to capture snapshots. This is set to true whenever a
+        * 'splice' kernel channel is enabled.
+        */
+       bool has_non_mmap_channel;
+       /*
+        * Timer set when the session is created for live reading.
+        */
+       unsigned int live_timer;
+       /*
+        * Path where to keep the shared memory files.
+        */
+       char shm_path[PATH_MAX];
+       /*
+        * Node in ltt_sessions_ht_by_id.
+        */
+       struct lttng_ht_node_u64 node;
+       /*
+        * Node in ltt_sessions_ht_by_name.
+        */
+       struct lttng_ht_node_str node_by_name;
+       /*
+        * Timer to check periodically if a relay and/or consumer has completed
+        * the last rotation.
+        */
+       bool rotation_pending_check_timer_enabled;
+       timer_t rotation_pending_check_timer;
+       /* Timer to periodically rotate a session. */
+       bool rotation_schedule_timer_enabled;
+       timer_t rotation_schedule_timer;
+       /* Value for periodic rotations, 0 if disabled. */
+       uint64_t rotate_timer_period;
+       /* Value for size-based rotations, 0 if disabled. */
+       uint64_t rotate_size;
+       /*
+        * Keep a state if this session was rotated after the last stop command.
+        * We only allow one rotation after a stop. At destroy, we also need to
+        * know if a rotation occurred since the last stop to rename the current
+        * chunk. After a stop followed by rotate, all subsequent clear
+        * (without prior start) will succeed, but will be effect-less.
+        */
+       bool rotated_after_last_stop;
+       /*
+        * Track whether the session was cleared after last stop. All subsequent
+        * clear (without prior start) will succeed, but will be effect-less. A
+        * subsequent rotate (without prior start) will return an error.
+        */
+       bool cleared_after_last_stop;
+       /*
+        * True if the session has had an explicit non-quiet rotation.
+        */
+       bool rotated;
+       /*
+        * Condition and trigger for size-based rotations.
+        */
+       struct lttng_condition *rotate_condition;
+       struct lttng_trigger *rotate_trigger;
+       LTTNG_OPTIONAL(uint64_t) most_recent_chunk_id;
+       struct lttng_trace_chunk *current_trace_chunk;
+       struct lttng_trace_chunk *chunk_being_archived;
+       /* Current state of a rotation. */
+       enum lttng_rotation_state rotation_state;
+       bool quiet_rotation;
+       char *last_archived_chunk_name;
+       LTTNG_OPTIONAL(uint64_t) last_archived_chunk_id;
+       struct lttng_dynamic_array destroy_notifiers;
+       struct lttng_dynamic_array clear_notifiers;
+       /* Session base path override. Set non-null. */
+       char *base_path;
+};
+
+enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
+               struct ltt_session **out_session);
+void session_lock(struct ltt_session *session);
+void session_unlock(struct ltt_session *session);
+
+/*
+ * The session list lock covers more ground than its name implies. While
+ * it does protect against concurent mutations of the session list, it is
+ * also used as a multi-session lock when synchronizing newly-registered
+ * 'user space tracer' and 'agent' applications.
+ *
+ * In other words, it prevents tracer configurations from changing while they
+ * are being transmitted to the various applications.
+ */
+void session_lock_list(void);
+int session_trylock_list(void);
+void session_unlock_list(void);
+
+void session_destroy(struct ltt_session *session);
+int session_add_destroy_notifier(struct ltt_session *session,
+               ltt_session_destroy_notifier notifier, void *user_data);
+
+int session_add_clear_notifier(struct ltt_session *session,
+               ltt_session_clear_notifier notifier, void *user_data);
+void session_notify_clear(struct ltt_session *session);
+
+bool session_get(struct ltt_session *session);
+void session_put(struct ltt_session *session);
+
+enum consumer_dst_type session_get_consumer_destination_type(
+               const struct ltt_session *session);
+const char *session_get_net_consumer_hostname(
+               const struct ltt_session *session);
+void session_get_net_consumer_ports(
+               const struct ltt_session *session,
+               uint16_t *control_port, uint16_t *data_port);
+struct lttng_trace_archive_location *session_get_trace_archive_location(
+               const struct ltt_session *session);
+
+struct ltt_session *session_find_by_name(const char *name);
+struct ltt_session *session_find_by_id(uint64_t id);
+
+struct ltt_session_list *session_get_list(void);
+void session_list_wait_empty(void);
+
+bool session_access_ok(struct ltt_session *session, uid_t uid);
+
+int session_reset_rotation_state(struct ltt_session *session,
+               enum lttng_rotation_state result);
+
+/* Create a new trace chunk object from the session's configuration. */
+struct lttng_trace_chunk *session_create_new_trace_chunk(
+               const struct ltt_session *session,
+               const struct consumer_output *consumer_output_override,
+               const char *session_base_path_override,
+               const char *chunk_name_override);
+
+/*
+ * Set `new_trace_chunk` as the session's current trace chunk. A reference
+ * to `new_trace_chunk` is acquired by the session. The chunk is created
+ * on remote peers (consumer and relay daemons).
+ *
+ * A reference to the session's current trace chunk is returned through
+ * `current_session_trace_chunk` on success.
+ */
+int session_set_trace_chunk(struct ltt_session *session,
+               struct lttng_trace_chunk *new_trace_chunk,
+               struct lttng_trace_chunk **current_session_trace_chunk);
+
+/*
+ * Close a chunk on the remote peers of a session. Has no effect on the
+ * ltt_session itself.
+ */
+int session_close_trace_chunk(struct ltt_session *session,
+               struct lttng_trace_chunk *trace_chunk,
+               enum lttng_trace_chunk_command_type close_command,
+               char *path);
+
+/* Open a packet in all channels of a given session. */
+enum lttng_error_code session_open_packets(struct ltt_session *session);
+
+bool session_output_supports_trace_chunks(const struct ltt_session *session);
+
+/*
+ * Sample the id of a session looked up via its name.
+ * Here the term "sampling" hint the caller that this return the id at a given
+ * point in time with no guarantee that the session for which the id was
+ * sampled still exist at that point.
+ *
+ * Return 0 when the session is not found,
+ * Return 1 when the session is found and set `id`.
+ */
+bool sample_session_id_by_name(const char *name, uint64_t *id);
+
+#endif /* _LTT_SESSION_H */
index 228d9c16b0f37be117be5f0abca0a9e8b6a0b62d..8ebb2a07c3c674dc6c9d0436a9b6382d8244d87c 100644 (file)
@@ -5,17 +5,17 @@
  *
  */
 
-#include "version.h"
-#include "sessiond-config.h"
-#include "lttng-ust-ctl.h"
-#include <common/defaults.h>
+#include "version.hpp"
+#include "sessiond-config.hpp"
+#include "lttng-ust-ctl.hpp"
+#include <common/defaults.hpp>
 #include <limits.h>
 #include <ctype.h>
-#include <common/error.h>
-#include <common/utils.h>
-#include <common/path.h>
-#include <common/compat/errno.h>
-#include <common/compat/getenv.h>
+#include <common/error.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/getenv.hpp>
 
 static
 struct sessiond_config sessiond_config_build_defaults = {
diff --git a/src/bin/lttng-sessiond/sessiond-config.h b/src/bin/lttng-sessiond/sessiond-config.h
deleted file mode 100644 (file)
index 136ca95..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_SESSIOND_CONFIG_H
-#define LTTNG_SESSIOND_CONFIG_H
-
-#include <common/macros.h>
-#include <stdbool.h>
-
-struct config_string {
-       char *value;
-       bool should_free;
-};
-
-struct config_int_range {
-       int begin, end;
-};
-
-/* Config string takes ownership of value. */
-void config_string_set(struct config_string *string, char *value);
-
-struct sessiond_config {
-       int verbose;
-       int verbose_consumer;
-       /* Agent TCP port range for registration. Used by the agent thread. */
-       struct config_int_range agent_tcp_port;
-
-       int event_notifier_buffer_size_kernel;
-       int event_notifier_buffer_size_userspace;
-       /* Socket timeout for receiving and sending (in seconds). */
-       int app_socket_timeout;
-
-       bool quiet;
-       bool no_kernel;
-       bool background;
-       bool daemonize;
-       bool sig_parent;
-
-       struct config_string tracing_group_name;
-
-       struct config_string kmod_probes_list;
-       struct config_string kmod_extra_probes_list;
-
-       struct config_string rundir;
-
-       /* Global application Unix socket path */
-       struct config_string apps_unix_sock_path;
-       /* Global client Unix socket path */
-       struct config_string client_unix_sock_path;
-       /* Global wait shm path for UST */
-       struct config_string wait_shm_path;
-       /* Global health check unix path */
-       struct config_string health_unix_sock_path;
-       /*
-        * LTTNG_UST_CLOCK_PLUGIN environment variable to be passed to spawned
-        * consumer daemons.
-        */
-       struct config_string lttng_ust_clock_plugin;
-       struct config_string pid_file_path;
-       struct config_string lock_file_path;
-       struct config_string load_session_path;
-       struct config_string agent_port_file_path;
-
-       struct config_string consumerd32_path;
-       struct config_string consumerd32_bin_path;
-       struct config_string consumerd32_lib_dir;
-       struct config_string consumerd32_err_unix_sock_path;
-       struct config_string consumerd32_cmd_unix_sock_path;
-
-       struct config_string consumerd64_path;
-       struct config_string consumerd64_bin_path;
-       struct config_string consumerd64_lib_dir;
-       struct config_string consumerd64_err_unix_sock_path;
-       struct config_string consumerd64_cmd_unix_sock_path;
-
-       struct config_string kconsumerd_path;
-       struct config_string kconsumerd_err_unix_sock_path;
-       struct config_string kconsumerd_cmd_unix_sock_path;
-};
-
-/* Initialize the sessiond_config values to build-defaults. */
-int sessiond_config_init(struct sessiond_config *config);
-
-/* Override sessiond_config values with values specified by the environment. */
-int sessiond_config_apply_env_config(struct sessiond_config *config);
-
-void sessiond_config_fini(struct sessiond_config *config);
-
-int sessiond_config_resolve_paths(struct sessiond_config *config);
-
-void sessiond_config_log(struct sessiond_config *config);
-
-#endif /* LTTNG_SESSIOND_CONFIG_H */
diff --git a/src/bin/lttng-sessiond/sessiond-config.hpp b/src/bin/lttng-sessiond/sessiond-config.hpp
new file mode 100644 (file)
index 0000000..fa0bfeb
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_SESSIOND_CONFIG_H
+#define LTTNG_SESSIOND_CONFIG_H
+
+#include <common/macros.hpp>
+#include <stdbool.h>
+
+struct config_string {
+       char *value;
+       bool should_free;
+};
+
+struct config_int_range {
+       int begin, end;
+};
+
+/* Config string takes ownership of value. */
+void config_string_set(struct config_string *string, char *value);
+
+struct sessiond_config {
+       int verbose;
+       int verbose_consumer;
+       /* Agent TCP port range for registration. Used by the agent thread. */
+       struct config_int_range agent_tcp_port;
+
+       int event_notifier_buffer_size_kernel;
+       int event_notifier_buffer_size_userspace;
+       /* Socket timeout for receiving and sending (in seconds). */
+       int app_socket_timeout;
+
+       bool quiet;
+       bool no_kernel;
+       bool background;
+       bool daemonize;
+       bool sig_parent;
+
+       struct config_string tracing_group_name;
+
+       struct config_string kmod_probes_list;
+       struct config_string kmod_extra_probes_list;
+
+       struct config_string rundir;
+
+       /* Global application Unix socket path */
+       struct config_string apps_unix_sock_path;
+       /* Global client Unix socket path */
+       struct config_string client_unix_sock_path;
+       /* Global wait shm path for UST */
+       struct config_string wait_shm_path;
+       /* Global health check unix path */
+       struct config_string health_unix_sock_path;
+       /*
+        * LTTNG_UST_CLOCK_PLUGIN environment variable to be passed to spawned
+        * consumer daemons.
+        */
+       struct config_string lttng_ust_clock_plugin;
+       struct config_string pid_file_path;
+       struct config_string lock_file_path;
+       struct config_string load_session_path;
+       struct config_string agent_port_file_path;
+
+       struct config_string consumerd32_path;
+       struct config_string consumerd32_bin_path;
+       struct config_string consumerd32_lib_dir;
+       struct config_string consumerd32_err_unix_sock_path;
+       struct config_string consumerd32_cmd_unix_sock_path;
+
+       struct config_string consumerd64_path;
+       struct config_string consumerd64_bin_path;
+       struct config_string consumerd64_lib_dir;
+       struct config_string consumerd64_err_unix_sock_path;
+       struct config_string consumerd64_cmd_unix_sock_path;
+
+       struct config_string kconsumerd_path;
+       struct config_string kconsumerd_err_unix_sock_path;
+       struct config_string kconsumerd_cmd_unix_sock_path;
+};
+
+/* Initialize the sessiond_config values to build-defaults. */
+int sessiond_config_init(struct sessiond_config *config);
+
+/* Override sessiond_config values with values specified by the environment. */
+int sessiond_config_apply_env_config(struct sessiond_config *config);
+
+void sessiond_config_fini(struct sessiond_config *config);
+
+int sessiond_config_resolve_paths(struct sessiond_config *config);
+
+void sessiond_config_log(struct sessiond_config *config);
+
+#endif /* LTTNG_SESSIOND_CONFIG_H */
index 727dc5db8967bad758a7ac11ed4d6611967cb2d7..f7821da95da978ac54f1111d7622a4080e8b31ca 100644 (file)
 #include <string.h>
 #include <urcu/uatomic.h>
 
-#include <common/defaults.h>
+#include <common/defaults.hpp>
 
-#include "snapshot.h"
-#include "utils.h"
+#include "snapshot.hpp"
+#include "utils.hpp"
 
 /*
  * Return the atomically incremented value of next_output_id.
diff --git a/src/bin/lttng-sessiond/snapshot.h b/src/bin/lttng-sessiond/snapshot.h
deleted file mode 100644 (file)
index 027b098..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SNAPSHOT_H
-#define SNAPSHOT_H
-
-#include <limits.h>
-#include <stdint.h>
-
-#include <common/common.h>
-#include <common/hashtable/hashtable.h>
-#include <common/uri.h>
-
-#include "consumer.h"
-
-struct consumer_output;
-struct ltt_session;
-
-struct snapshot_output {
-       uint32_t id;
-       uint64_t max_size;
-       /* Number of snapshot taken with that output. */
-       uint64_t nb_snapshot;
-       char name[NAME_MAX];
-       struct consumer_output *consumer;
-       int kernel_sockets_copied;
-       int ust_sockets_copied;
-       /*
-        * Contains the string with "<date>-<time>" for when the snapshot command
-        * is triggered. This is to make sure every streams will use the same time
-        * for the directory output.
-        */
-       char datetime[16];
-
-       /* Indexed by ID. */
-       struct lttng_ht_node_ulong node;
-};
-
-struct snapshot {
-       unsigned long next_output_id;
-       size_t nb_output;
-       /*
-        * Number of snapshot taken for that object. This value is used with a
-        * temporary output of a snapshot record.
-        */
-       uint64_t nb_snapshot;
-       struct lttng_ht *output_ht;
-};
-
-/* Snapshot object. */
-struct snapshot *snapshot_alloc(void);
-void snapshot_destroy(struct snapshot *obj);
-int snapshot_init(struct snapshot *obj);
-void snapshot_delete_output(struct snapshot *snapshot,
-               struct snapshot_output *output);
-void snapshot_add_output(struct snapshot *snapshot,
-               struct snapshot_output *output);
-
-/* Snapshot output object. */
-struct snapshot_output *snapshot_output_alloc(void);
-void snapshot_output_destroy(struct snapshot_output *obj);
-int snapshot_output_init(const struct ltt_session *session,
-               uint64_t max_size, const char *name,
-               const char *ctrl_url, const char *data_url,
-               struct consumer_output *consumer, struct snapshot_output *output,
-               struct snapshot *snapshot);
-int snapshot_output_init_with_uri(const struct ltt_session *session,
-               uint64_t max_size, const char *name,
-               struct lttng_uri *uris, size_t nb_uri,
-               struct consumer_output *consumer, struct snapshot_output *output,
-               struct snapshot *snapshot);
-struct snapshot_output *snapshot_find_output_by_id(uint32_t id,
-               struct snapshot *snapshot);
-struct snapshot_output *snapshot_find_output_by_name(const char *name,
-               struct snapshot *snapshot);
-
-#endif /* SNAPSHOT_H */
diff --git a/src/bin/lttng-sessiond/snapshot.hpp b/src/bin/lttng-sessiond/snapshot.hpp
new file mode 100644 (file)
index 0000000..6aa06dd
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SNAPSHOT_H
+#define SNAPSHOT_H
+
+#include <limits.h>
+#include <stdint.h>
+
+#include <common/common.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/uri.hpp>
+
+#include "consumer.hpp"
+
+struct consumer_output;
+struct ltt_session;
+
+struct snapshot_output {
+       uint32_t id;
+       uint64_t max_size;
+       /* Number of snapshot taken with that output. */
+       uint64_t nb_snapshot;
+       char name[NAME_MAX];
+       struct consumer_output *consumer;
+       int kernel_sockets_copied;
+       int ust_sockets_copied;
+       /*
+        * Contains the string with "<date>-<time>" for when the snapshot command
+        * is triggered. This is to make sure every streams will use the same time
+        * for the directory output.
+        */
+       char datetime[16];
+
+       /* Indexed by ID. */
+       struct lttng_ht_node_ulong node;
+};
+
+struct snapshot {
+       unsigned long next_output_id;
+       size_t nb_output;
+       /*
+        * Number of snapshot taken for that object. This value is used with a
+        * temporary output of a snapshot record.
+        */
+       uint64_t nb_snapshot;
+       struct lttng_ht *output_ht;
+};
+
+/* Snapshot object. */
+struct snapshot *snapshot_alloc(void);
+void snapshot_destroy(struct snapshot *obj);
+int snapshot_init(struct snapshot *obj);
+void snapshot_delete_output(struct snapshot *snapshot,
+               struct snapshot_output *output);
+void snapshot_add_output(struct snapshot *snapshot,
+               struct snapshot_output *output);
+
+/* Snapshot output object. */
+struct snapshot_output *snapshot_output_alloc(void);
+void snapshot_output_destroy(struct snapshot_output *obj);
+int snapshot_output_init(const struct ltt_session *session,
+               uint64_t max_size, const char *name,
+               const char *ctrl_url, const char *data_url,
+               struct consumer_output *consumer, struct snapshot_output *output,
+               struct snapshot *snapshot);
+int snapshot_output_init_with_uri(const struct ltt_session *session,
+               uint64_t max_size, const char *name,
+               struct lttng_uri *uris, size_t nb_uri,
+               struct consumer_output *consumer, struct snapshot_output *output,
+               struct snapshot *snapshot);
+struct snapshot_output *snapshot_find_output_by_id(uint32_t id,
+               struct snapshot *snapshot);
+struct snapshot_output *snapshot_find_output_by_name(const char *name,
+               struct snapshot *snapshot);
+
+#endif /* SNAPSHOT_H */
diff --git a/src/bin/lttng-sessiond/testpoint.h b/src/bin/lttng-sessiond/testpoint.h
deleted file mode 100644 (file)
index 6c35d29..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_TESTPOINT_H
-#define SESSIOND_TESTPOINT_H
-
-#include <common/testpoint/testpoint.h>
-
-/* Testpoints, internal use only */
-TESTPOINT_DECL(sessiond_thread_manage_clients);
-TESTPOINT_DECL(sessiond_thread_manage_clients_before_loop);
-TESTPOINT_DECL(sessiond_thread_registration_apps);
-TESTPOINT_DECL(sessiond_thread_manage_apps);
-TESTPOINT_DECL(sessiond_thread_manage_apps_before_loop);
-TESTPOINT_DECL(sessiond_thread_manage_kernel);
-TESTPOINT_DECL(sessiond_thread_manage_kernel_before_loop);
-TESTPOINT_DECL(sessiond_thread_manage_consumer);
-TESTPOINT_DECL(sessiond_thread_app_manage_notify);
-TESTPOINT_DECL(sessiond_thread_app_reg_dispatch);
-TESTPOINT_DECL(sessiond_thread_notification);
-TESTPOINT_DECL(sessiond_handle_notifier_event_pipe);
-
-#endif /* SESSIOND_TESTPOINT_H */
diff --git a/src/bin/lttng-sessiond/testpoint.hpp b/src/bin/lttng-sessiond/testpoint.hpp
new file mode 100644 (file)
index 0000000..f50d9f8
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_TESTPOINT_H
+#define SESSIOND_TESTPOINT_H
+
+#include <common/testpoint/testpoint.hpp>
+
+/* Testpoints, internal use only */
+TESTPOINT_DECL(sessiond_thread_manage_clients);
+TESTPOINT_DECL(sessiond_thread_manage_clients_before_loop);
+TESTPOINT_DECL(sessiond_thread_registration_apps);
+TESTPOINT_DECL(sessiond_thread_manage_apps);
+TESTPOINT_DECL(sessiond_thread_manage_apps_before_loop);
+TESTPOINT_DECL(sessiond_thread_manage_kernel);
+TESTPOINT_DECL(sessiond_thread_manage_kernel_before_loop);
+TESTPOINT_DECL(sessiond_thread_manage_consumer);
+TESTPOINT_DECL(sessiond_thread_app_manage_notify);
+TESTPOINT_DECL(sessiond_thread_app_reg_dispatch);
+TESTPOINT_DECL(sessiond_thread_notification);
+TESTPOINT_DECL(sessiond_handle_notifier_event_pipe);
+
+#endif /* SESSIOND_TESTPOINT_H */
index 2d8f8b78913415efd120efdcd1fa2935a181fc30..e28106e785d99aa52a4d5f8d4dc3a40d95524c53 100644 (file)
@@ -7,9 +7,9 @@
  *
  */
 
-#include "lttng-sessiond.h"
-#include "utils.h"
-#include <common/utils.h>
+#include "lttng-sessiond.hpp"
+#include "utils.hpp"
+#include <common/utils.hpp>
 #include <pthread.h>
 
 /*
index 446a8c9d2e52276dd5972cf869884c57ec22bb78..9ce539b816a99732cf0a6c3ed5c3901584e8e44a 100644 (file)
@@ -5,13 +5,13 @@
  *
  */
 
-#include "thread.h"
+#include "thread.hpp"
 #include <urcu/list.h>
 #include <urcu/ref.h>
 #include <pthread.h>
-#include <common/macros.h>
-#include <common/error.h>
-#include <common/defaults.h>
+#include <common/macros.hpp>
+#include <common/error.hpp>
+#include <common/defaults.hpp>
 
 static struct thread_list {
        struct cds_list_head head;
diff --git a/src/bin/lttng-sessiond/thread.h b/src/bin/lttng-sessiond/thread.h
deleted file mode 100644 (file)
index 530f72a..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <stdbool.h>
-
-#ifndef THREAD_H
-#define THREAD_H
-
-struct lttng_thread;
-
-/* Main function of the new thread. */
-typedef void *(*lttng_thread_entry_point)(void *);
-
-/* Callback invoked to initiate the shutdown a thread. */
-typedef bool (*lttng_thread_shutdown_cb)(void *);
-
-/*
- * Callback invoked to clean-up the thread data.
- * Invoked when the thread is destroyed to ensure there is no
- * race between a use by the "thread shutdown callback" and
- * a use by the thread itself.
- */
-typedef void (*lttng_thread_cleanup_cb)(void *);
-
-/*
- * Returns a reference to the newly-created thread.
- * The shutdown and cleanup callbacks are optional.
- */
-struct lttng_thread *lttng_thread_create(const char *name,
-               lttng_thread_entry_point entry,
-               lttng_thread_shutdown_cb shutdown,
-               lttng_thread_cleanup_cb cleanup,
-               void *thread_data);
-
-bool lttng_thread_get(struct lttng_thread *thread);
-void lttng_thread_put(struct lttng_thread *thread);
-
-const char *lttng_thread_get_name(const struct lttng_thread *thread);
-
-/*
- * Explicitly shutdown a thread. This function returns once the
- * thread has returned and been joined.
- *
- * It is invalid to call this function more than once on a thread.
- *
- * Returns true on success, false on error.
- */
-bool lttng_thread_shutdown(struct lttng_thread *thread);
-
-/*
- * Shutdown all orphaned threads (threads to which no external reference
- * exist).
- *
- * Returns once all orphaned threads have been joined.
- */
-void lttng_thread_list_shutdown_orphans(void);
-
-#endif /* THREAD_H */
diff --git a/src/bin/lttng-sessiond/thread.hpp b/src/bin/lttng-sessiond/thread.hpp
new file mode 100644 (file)
index 0000000..530f72a
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <stdbool.h>
+
+#ifndef THREAD_H
+#define THREAD_H
+
+struct lttng_thread;
+
+/* Main function of the new thread. */
+typedef void *(*lttng_thread_entry_point)(void *);
+
+/* Callback invoked to initiate the shutdown a thread. */
+typedef bool (*lttng_thread_shutdown_cb)(void *);
+
+/*
+ * Callback invoked to clean-up the thread data.
+ * Invoked when the thread is destroyed to ensure there is no
+ * race between a use by the "thread shutdown callback" and
+ * a use by the thread itself.
+ */
+typedef void (*lttng_thread_cleanup_cb)(void *);
+
+/*
+ * Returns a reference to the newly-created thread.
+ * The shutdown and cleanup callbacks are optional.
+ */
+struct lttng_thread *lttng_thread_create(const char *name,
+               lttng_thread_entry_point entry,
+               lttng_thread_shutdown_cb shutdown,
+               lttng_thread_cleanup_cb cleanup,
+               void *thread_data);
+
+bool lttng_thread_get(struct lttng_thread *thread);
+void lttng_thread_put(struct lttng_thread *thread);
+
+const char *lttng_thread_get_name(const struct lttng_thread *thread);
+
+/*
+ * Explicitly shutdown a thread. This function returns once the
+ * thread has returned and been joined.
+ *
+ * It is invalid to call this function more than once on a thread.
+ *
+ * Returns true on success, false on error.
+ */
+bool lttng_thread_shutdown(struct lttng_thread *thread);
+
+/*
+ * Shutdown all orphaned threads (threads to which no external reference
+ * exist).
+ *
+ * Returns once all orphaned threads have been joined.
+ */
+void lttng_thread_list_shutdown_orphans(void);
+
+#endif /* THREAD_H */
index 9635dea81a426c4774cf85640e12b2e0efa83c37..4e8b8026b2ee7534f01a95826b8f92f89f6b4dd3 100644 (file)
 #include <inttypes.h>
 #include <signal.h>
 
-#include "timer.h"
-#include "health-sessiond.h"
-#include "rotation-thread.h"
-#include "thread.h"
+#include "timer.hpp"
+#include "health-sessiond.hpp"
+#include "rotation-thread.hpp"
+#include "thread.hpp"
 
 #define LTTNG_SESSIOND_SIG_QS                          SIGRTMIN + 10
 #define LTTNG_SESSIOND_SIG_EXIT                                SIGRTMIN + 11
diff --git a/src/bin/lttng-sessiond/timer.h b/src/bin/lttng-sessiond/timer.h
deleted file mode 100644 (file)
index c958794..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_TIMER_H
-#define SESSIOND_TIMER_H
-
-#include <pthread.h>
-#include <stdbool.h>
-
-#include "session.h"
-
-struct timer_thread_parameters {
-       struct rotation_thread_timer_queue *rotation_thread_job_queue;
-};
-
-int timer_signal_init(void);
-
-/* Start a session's rotation pending check timer (one-shot mode). */
-int timer_session_rotation_pending_check_start(struct ltt_session *session,
-               unsigned int interval_us);
-/* Stop a session's rotation pending check timer. */
-int timer_session_rotation_pending_check_stop(struct ltt_session *session);
-
-/* Start a session's rotation schedule timer. */
-int timer_session_rotation_schedule_timer_start(struct ltt_session *session,
-               unsigned int interval_us);
-/* Stop a session's rotation schedule timer. */
-int timer_session_rotation_schedule_timer_stop(struct ltt_session *session);
-
-bool launch_timer_thread(
-               struct timer_thread_parameters *timer_thread_parameters);
-
-#endif /* SESSIOND_TIMER_H */
diff --git a/src/bin/lttng-sessiond/timer.hpp b/src/bin/lttng-sessiond/timer.hpp
new file mode 100644 (file)
index 0000000..f746f0e
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_TIMER_H
+#define SESSIOND_TIMER_H
+
+#include <pthread.h>
+#include <stdbool.h>
+
+#include "session.hpp"
+
+struct timer_thread_parameters {
+       struct rotation_thread_timer_queue *rotation_thread_job_queue;
+};
+
+int timer_signal_init(void);
+
+/* Start a session's rotation pending check timer (one-shot mode). */
+int timer_session_rotation_pending_check_start(struct ltt_session *session,
+               unsigned int interval_us);
+/* Stop a session's rotation pending check timer. */
+int timer_session_rotation_pending_check_stop(struct ltt_session *session);
+
+/* Start a session's rotation schedule timer. */
+int timer_session_rotation_schedule_timer_start(struct ltt_session *session,
+               unsigned int interval_us);
+/* Stop a session's rotation schedule timer. */
+int timer_session_rotation_schedule_timer_stop(struct ltt_session *session);
+
+bool launch_timer_thread(
+               struct timer_thread_parameters *timer_thread_parameters);
+
+#endif /* SESSIOND_TIMER_H */
index 1a1620aaa78605b195756dc05c269ef021f5180e..8466304829cb9109f94755ec4e0a6a138384b7ef 100644 (file)
 #include <lttng/lttng-error.h>
 #include <lttng/kernel-probe.h>
 #include <lttng/userspace-probe.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/userspace-probe-internal.hpp>
 #include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
 #include <lttng/event-rule/kernel-kprobe.h>
-#include <lttng/event-rule/kernel-kprobe-internal.h>
+#include <lttng/event-rule/kernel-kprobe-internal.hpp>
 #include <lttng/event-rule/kernel-syscall.h>
-#include <lttng/event-rule/kernel-syscall-internal.h>
+#include <lttng/event-rule/kernel-syscall-internal.hpp>
 #include <lttng/event-rule/kernel-tracepoint.h>
-#include <lttng/event-rule/kernel-tracepoint-internal.h>
+#include <lttng/event-rule/kernel-tracepoint-internal.hpp>
 #include <lttng/event-rule/kernel-uprobe.h>
-#include <lttng/event-rule/kernel-uprobe-internal.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/trace-chunk.h>
-#include <common/macros.h>
-
-#include "consumer.h"
-#include "trace-kernel.h"
-#include "lttng-sessiond.h"
-#include "notification-thread-commands.h"
+#include <lttng/event-rule/kernel-uprobe-internal.hpp>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/macros.hpp>
+
+#include "consumer.hpp"
+#include "trace-kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-commands.hpp"
 
 /*
  * Find the channel name for the given kernel session.
diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h
deleted file mode 100644 (file)
index 83608b2..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_TRACE_KERNEL_H
-#define _LTT_TRACE_KERNEL_H
-
-#include <urcu/list.h>
-
-#include <lttng/lttng.h>
-#include <common/lttng-kernel.h>
-#include <common/lttng-kernel-old.h>
-#include <common/defaults.h>
-
-#include "consumer.h"
-#include "tracker.h"
-
-/* Kernel event list */
-struct ltt_kernel_event_list {
-       struct cds_list_head head;
-};
-
-/* Channel stream list */
-struct ltt_kernel_stream_list {
-       struct cds_list_head head;
-};
-
-/* Channel list */
-struct ltt_kernel_channel_list {
-       struct cds_list_head head;
-};
-
-struct ltt_kernel_context {
-       struct lttng_kernel_abi_context ctx;
-       struct cds_list_head list;
-       /* Indicates whether or not the context is in a list. */
-       bool in_list;
-};
-
-/* Kernel event */
-struct ltt_kernel_event {
-       int fd;
-       int enabled;
-       enum lttng_event_type type;
-       struct lttng_kernel_abi_event *event;
-       struct cds_list_head list;
-       char *filter_expression;
-       struct lttng_bytecode *filter;
-       struct lttng_userspace_probe_location *userspace_probe_location;
-};
-
-/* Kernel event */
-struct ltt_kernel_event_notifier_rule {
-       int fd;
-       uint64_t error_counter_index;
-       int enabled;
-       enum lttng_event_type type;
-       struct lttng_trigger *trigger;
-       uint64_t token;
-       const struct lttng_bytecode *filter;
-       struct lttng_userspace_probe_location *userspace_probe_location;
-       struct cds_lfht_node ht_node;
-       /* call_rcu delayed reclaim. */
-       struct rcu_head rcu_node;
-};
-
-/* Kernel channel */
-struct ltt_kernel_channel {
-       int fd;
-       uint64_t key; /* Key to reference this channel with the consumer. */
-       int enabled;
-       unsigned int stream_count;
-       unsigned int event_count;
-       bool published_to_notification_thread;
-       struct cds_list_head ctx_list;
-       struct lttng_channel *channel;
-       struct ltt_kernel_event_list events_list;
-       struct ltt_kernel_stream_list stream_list;
-       struct cds_list_head list;
-       /* Session pointer which has a reference to this object. */
-       struct ltt_kernel_session *session;
-       bool sent_to_consumer;
-};
-
-/* Metadata */
-struct ltt_kernel_metadata {
-       int fd;
-       uint64_t key; /* Key to reference this channel with the consumer. */
-       struct lttng_channel *conf;
-};
-
-/* Channel stream */
-struct ltt_kernel_stream {
-       int fd;
-       int state;
-       int cpu;
-       bool sent_to_consumer;
-       /* Format is %s_%d respectively channel name and CPU number. */
-       char name[DEFAULT_STREAM_NAME_LEN];
-       uint64_t tracefile_size;
-       uint64_t tracefile_count;
-       struct cds_list_head list;
-};
-
-/* Kernel session */
-struct ltt_kernel_session {
-       int fd;
-       int metadata_stream_fd;
-       int consumer_fds_sent;
-       unsigned int channel_count;
-       unsigned int stream_count_global;
-       struct ltt_kernel_metadata *metadata;
-       struct ltt_kernel_channel_list channel_list;
-       /* UID/GID of the user owning the session */
-       uid_t uid;
-       gid_t gid;
-       struct consumer_output *consumer;
-       /* Tracing session id */
-       uint64_t id;
-       /* Session is active or not meaning it has been started or stopped. */
-       unsigned int active:1;
-       /* Tell or not if the session has to output the traces. */
-       unsigned int output_traces;
-       unsigned int snapshot_mode;
-       unsigned int has_non_default_channel;
-       bool is_live_session;
-       /* Current trace chunk of the ltt_session. */
-       struct lttng_trace_chunk *current_trace_chunk;
-       /* Tracker lists */
-       struct process_attr_tracker *tracker_pid;
-       struct process_attr_tracker *tracker_vpid;
-       struct process_attr_tracker *tracker_uid;
-       struct process_attr_tracker *tracker_vuid;
-       struct process_attr_tracker *tracker_gid;
-       struct process_attr_tracker *tracker_vgid;
-};
-
-/*
- * Lookup functions. NULL is returned if not found.
- */
-struct ltt_kernel_event *trace_kernel_get_event_by_name(
-               char *name, struct ltt_kernel_channel *channel,
-               enum lttng_event_type type);
-struct ltt_kernel_event *trace_kernel_find_event(
-               char *name, struct ltt_kernel_channel *channel,
-               enum lttng_event_type type,
-               struct lttng_bytecode *filter);
-struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
-               const char *name, struct ltt_kernel_session *session);
-
-/*
- * Create functions malloc() the data structure.
- */
-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_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,
-               unsigned int count);
-struct ltt_kernel_context *trace_kernel_create_context(
-               struct lttng_kernel_abi_context *ctx);
-/* Trigger is only non-const to acquire a reference. */
-enum lttng_error_code trace_kernel_create_event_notifier_rule(
-               struct lttng_trigger *trigger,
-               uint64_t token,
-               uint64_t error_counter_index,
-               struct ltt_kernel_event_notifier_rule **event_notifier_rule);
-struct ltt_kernel_context *trace_kernel_copy_context(
-               struct ltt_kernel_context *ctx);
-enum lttng_error_code trace_kernel_init_event_notifier_from_event_rule(
-               const struct lttng_event_rule *rule,
-               struct lttng_kernel_abi_event_notifier *kernel_event_notifier);
-
-/*
- * Destroy functions free() the data structure and remove from linked list if
- * it's applies.
- */
-void trace_kernel_destroy_session(struct ltt_kernel_session *session);
-void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata);
-void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel);
-void trace_kernel_destroy_event(struct ltt_kernel_event *event);
-void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream);
-void trace_kernel_destroy_context(struct ltt_kernel_context *ctx);
-void trace_kernel_destroy_event_notifier_rule(struct ltt_kernel_event_notifier_rule *rule);
-void trace_kernel_free_session(struct ltt_kernel_session *session);
-
-#endif /* _LTT_TRACE_KERNEL_H */
diff --git a/src/bin/lttng-sessiond/trace-kernel.hpp b/src/bin/lttng-sessiond/trace-kernel.hpp
new file mode 100644 (file)
index 0000000..50a5866
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_TRACE_KERNEL_H
+#define _LTT_TRACE_KERNEL_H
+
+#include <urcu/list.h>
+
+#include <lttng/lttng.h>
+#include <common/lttng-kernel.hpp>
+#include <common/lttng-kernel-old.hpp>
+#include <common/defaults.hpp>
+
+#include "consumer.hpp"
+#include "tracker.hpp"
+
+/* Kernel event list */
+struct ltt_kernel_event_list {
+       struct cds_list_head head;
+};
+
+/* Channel stream list */
+struct ltt_kernel_stream_list {
+       struct cds_list_head head;
+};
+
+/* Channel list */
+struct ltt_kernel_channel_list {
+       struct cds_list_head head;
+};
+
+struct ltt_kernel_context {
+       struct lttng_kernel_abi_context ctx;
+       struct cds_list_head list;
+       /* Indicates whether or not the context is in a list. */
+       bool in_list;
+};
+
+/* Kernel event */
+struct ltt_kernel_event {
+       int fd;
+       int enabled;
+       enum lttng_event_type type;
+       struct lttng_kernel_abi_event *event;
+       struct cds_list_head list;
+       char *filter_expression;
+       struct lttng_bytecode *filter;
+       struct lttng_userspace_probe_location *userspace_probe_location;
+};
+
+/* Kernel event */
+struct ltt_kernel_event_notifier_rule {
+       int fd;
+       uint64_t error_counter_index;
+       int enabled;
+       enum lttng_event_type type;
+       struct lttng_trigger *trigger;
+       uint64_t token;
+       const struct lttng_bytecode *filter;
+       struct lttng_userspace_probe_location *userspace_probe_location;
+       struct cds_lfht_node ht_node;
+       /* call_rcu delayed reclaim. */
+       struct rcu_head rcu_node;
+};
+
+/* Kernel channel */
+struct ltt_kernel_channel {
+       int fd;
+       uint64_t key; /* Key to reference this channel with the consumer. */
+       int enabled;
+       unsigned int stream_count;
+       unsigned int event_count;
+       bool published_to_notification_thread;
+       struct cds_list_head ctx_list;
+       struct lttng_channel *channel;
+       struct ltt_kernel_event_list events_list;
+       struct ltt_kernel_stream_list stream_list;
+       struct cds_list_head list;
+       /* Session pointer which has a reference to this object. */
+       struct ltt_kernel_session *session;
+       bool sent_to_consumer;
+};
+
+/* Metadata */
+struct ltt_kernel_metadata {
+       int fd;
+       uint64_t key; /* Key to reference this channel with the consumer. */
+       struct lttng_channel *conf;
+};
+
+/* Channel stream */
+struct ltt_kernel_stream {
+       int fd;
+       int state;
+       int cpu;
+       bool sent_to_consumer;
+       /* Format is %s_%d respectively channel name and CPU number. */
+       char name[DEFAULT_STREAM_NAME_LEN];
+       uint64_t tracefile_size;
+       uint64_t tracefile_count;
+       struct cds_list_head list;
+};
+
+/* Kernel session */
+struct ltt_kernel_session {
+       int fd;
+       int metadata_stream_fd;
+       int consumer_fds_sent;
+       unsigned int channel_count;
+       unsigned int stream_count_global;
+       struct ltt_kernel_metadata *metadata;
+       struct ltt_kernel_channel_list channel_list;
+       /* UID/GID of the user owning the session */
+       uid_t uid;
+       gid_t gid;
+       struct consumer_output *consumer;
+       /* Tracing session id */
+       uint64_t id;
+       /* Session is active or not meaning it has been started or stopped. */
+       unsigned int active:1;
+       /* Tell or not if the session has to output the traces. */
+       unsigned int output_traces;
+       unsigned int snapshot_mode;
+       unsigned int has_non_default_channel;
+       bool is_live_session;
+       /* Current trace chunk of the ltt_session. */
+       struct lttng_trace_chunk *current_trace_chunk;
+       /* Tracker lists */
+       struct process_attr_tracker *tracker_pid;
+       struct process_attr_tracker *tracker_vpid;
+       struct process_attr_tracker *tracker_uid;
+       struct process_attr_tracker *tracker_vuid;
+       struct process_attr_tracker *tracker_gid;
+       struct process_attr_tracker *tracker_vgid;
+};
+
+/*
+ * Lookup functions. NULL is returned if not found.
+ */
+struct ltt_kernel_event *trace_kernel_get_event_by_name(
+               char *name, struct ltt_kernel_channel *channel,
+               enum lttng_event_type type);
+struct ltt_kernel_event *trace_kernel_find_event(
+               char *name, struct ltt_kernel_channel *channel,
+               enum lttng_event_type type,
+               struct lttng_bytecode *filter);
+struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
+               const char *name, struct ltt_kernel_session *session);
+
+/*
+ * Create functions malloc() the data structure.
+ */
+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_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,
+               unsigned int count);
+struct ltt_kernel_context *trace_kernel_create_context(
+               struct lttng_kernel_abi_context *ctx);
+/* Trigger is only non-const to acquire a reference. */
+enum lttng_error_code trace_kernel_create_event_notifier_rule(
+               struct lttng_trigger *trigger,
+               uint64_t token,
+               uint64_t error_counter_index,
+               struct ltt_kernel_event_notifier_rule **event_notifier_rule);
+struct ltt_kernel_context *trace_kernel_copy_context(
+               struct ltt_kernel_context *ctx);
+enum lttng_error_code trace_kernel_init_event_notifier_from_event_rule(
+               const struct lttng_event_rule *rule,
+               struct lttng_kernel_abi_event_notifier *kernel_event_notifier);
+
+/*
+ * Destroy functions free() the data structure and remove from linked list if
+ * it's applies.
+ */
+void trace_kernel_destroy_session(struct ltt_kernel_session *session);
+void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata);
+void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel);
+void trace_kernel_destroy_event(struct ltt_kernel_event *event);
+void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream);
+void trace_kernel_destroy_context(struct ltt_kernel_context *ctx);
+void trace_kernel_destroy_event_notifier_rule(struct ltt_kernel_event_notifier_rule *rule);
+void trace_kernel_free_session(struct ltt_kernel_session *session);
+
+#endif /* _LTT_TRACE_KERNEL_H */
index f3303efd7c1a55980541e39253cfb5b7d1e34b41..285ff0811f3a9f5be3573cad48893d9985ad244d 100644 (file)
 #include <unistd.h>
 #include <inttypes.h>
 
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/trace-chunk.h>
-#include <common/utils.h>
-
-#include "buffer-registry.h"
-#include "trace-ust.h"
-#include "utils.h"
-#include "ust-app.h"
-#include "agent.h"
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/utils.hpp>
+
+#include "buffer-registry.hpp"
+#include "trace-ust.hpp"
+#include "utils.hpp"
+#include "ust-app.hpp"
+#include "agent.hpp"
 
 /*
  * Match function for the events hash table lookup.
diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h
deleted file mode 100644 (file)
index d4df48d..0000000
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_TRACE_UST_H
-#define _LTT_TRACE_UST_H
-
-#include <limits.h>
-#include <urcu/list.h>
-
-#include <common/defaults.h>
-#include <common/hashtable/hashtable.h>
-#include <common/tracker.h>
-#include <lttng/lttng.h>
-
-#include "consumer.h"
-#include "lttng-ust-ctl.h"
-
-struct agent;
-
-struct ltt_ust_ht_key {
-       const char *name;
-       const struct lttng_bytecode *filter;
-       enum lttng_ust_abi_loglevel_type loglevel_type;
-       int loglevel_value;
-       const struct lttng_event_exclusion *exclusion;
-};
-
-/* Context hash table nodes */
-struct ltt_ust_context {
-       struct lttng_ust_context_attr ctx;
-       struct lttng_ht_node_ulong node;
-       struct cds_list_head list;
-};
-
-/* UST event */
-struct ltt_ust_event {
-       unsigned int enabled;
-       struct lttng_ust_abi_event attr;
-       struct lttng_ht_node_str node;
-       char *filter_expression;
-       struct lttng_bytecode *filter;
-       struct lttng_event_exclusion *exclusion;
-       /*
-        * An internal event is an event which was created by the session daemon
-        * through which, for example, events emitted in Agent domains are
-        * "funelled". This is used to hide internal events from external
-        * clients as they should never be modified by the external world.
-        */
-       bool internal;
-};
-
-/* UST channel */
-struct ltt_ust_channel {
-       uint64_t id;    /* unique id per session. */
-       unsigned int enabled;
-       /*
-        * A UST channel can be part of a userspace sub-domain such as JUL,
-        * Log4j, Python.
-        */
-       enum lttng_domain_type domain;
-       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
-       struct lttng_ust_abi_channel_attr attr;
-       struct lttng_ht *ctx;
-       struct cds_list_head ctx_list;
-       struct lttng_ht *events;
-       struct lttng_ht_node_str node;
-       uint64_t tracefile_size;
-       uint64_t tracefile_count;
-       uint64_t per_pid_closed_app_discarded;
-       uint64_t per_pid_closed_app_lost;
-       uint64_t monitor_timer_interval;
-};
-
-/* UST domain global (LTTNG_DOMAIN_UST) */
-struct ltt_ust_domain_global {
-       struct lttng_ht *channels;
-       struct cds_list_head registry_buffer_uid_list;
-};
-
-struct ust_id_tracker_node {
-       struct lttng_ht_node_ulong node;
-};
-
-struct ust_id_tracker {
-       struct lttng_ht *ht;
-};
-
-/* UST session */
-struct ltt_ust_session {
-       uint64_t id;    /* Unique identifier of session */
-       struct ltt_ust_domain_global domain_global;
-       /* Hash table of agent indexed by agent domain. */
-       struct lttng_ht *agents;
-       /* UID/GID of the user owning the session */
-       uid_t uid;
-       gid_t gid;
-       /* Is the session active meaning has is been started or stopped. */
-       unsigned int active:1;
-       struct consumer_output *consumer;
-       /* Sequence number for filters so the tracer knows the ordering. */
-       uint64_t filter_seq_num;
-       /* This indicates which type of buffer this session is set for. */
-       enum lttng_buffer_type buffer_type;
-       /* If set to 1, the buffer_type can not be changed anymore. */
-       int buffer_type_changed;
-       /* For per UID buffer, every buffer reg object is kept of this session */
-       struct cds_list_head buffer_reg_uid_list;
-       /* Next channel ID available for a newly registered channel. */
-       uint64_t next_channel_id;
-       /* Once this value reaches UINT32_MAX, no more id can be allocated. */
-       uint64_t used_channel_id;
-       /* Tell or not if the session has to output the traces. */
-       unsigned int output_traces;
-       unsigned int snapshot_mode;
-       unsigned int has_non_default_channel;
-       unsigned int live_timer_interval;       /* usec */
-
-       /* Metadata channel attributes. */
-       struct lttng_ust_abi_channel_attr metadata_attr;
-
-       /*
-        * Path where to keep the shared memory files.
-        */
-       char root_shm_path[PATH_MAX];
-       char shm_path[PATH_MAX];
-
-       /* Current trace chunk of the ltt_session. */
-       struct lttng_trace_chunk *current_trace_chunk;
-
-       /* Trackers used for actual lookup on app registration. */
-       struct ust_id_tracker vpid_tracker;
-       struct ust_id_tracker vuid_tracker;
-       struct ust_id_tracker vgid_tracker;
-
-       /* Tracker list of keys requested by users. */
-       struct process_attr_tracker *tracker_vpid;
-       struct process_attr_tracker *tracker_vuid;
-       struct process_attr_tracker *tracker_vgid;
-};
-
-/*
- * Validate that the id has reached the maximum allowed or not.
- *
- * Return 0 if NOT else 1.
- */
-static inline int trace_ust_is_max_id(uint64_t id)
-{
-       return (id == UINT64_MAX) ? 1 : 0;
-}
-
-/*
- * Return next available channel id and increment the used counter. The
- * trace_ust_is_max_id function MUST be called before in order to validate if
- * the maximum number of IDs have been reached. If not, it is safe to call this
- * function.
- *
- * Return a unique channel ID. If max is reached, the used_channel_id counter
- * is returned.
- */
-static inline uint64_t trace_ust_get_next_chan_id(struct ltt_ust_session *s)
-{
-       if (trace_ust_is_max_id(s->used_channel_id)) {
-               return s->used_channel_id;
-       }
-
-       s->used_channel_id++;
-       return s->next_channel_id++;
-}
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key);
-int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node,
-               const void *_key);
-
-/*
- * Lookup functions. NULL is returned if not found.
- */
-struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
-               char *name, struct lttng_bytecode *filter,
-               enum lttng_ust_abi_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,
-               const char *name);
-struct agent *trace_ust_find_agent(struct ltt_ust_session *session,
-               enum lttng_domain_type domain_type);
-
-/*
- * Create functions malloc() the data structure.
- */
-struct ltt_ust_session *trace_ust_create_session(uint64_t session_id);
-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_bytecode *filter,
-               struct lttng_event_exclusion *exclusion,
-               bool internal_event, struct ltt_ust_event **ust_event);
-struct ltt_ust_context *trace_ust_create_context(
-               const struct lttng_event_context *ctx);
-int trace_ust_match_context(const struct ltt_ust_context *uctx,
-               const struct lttng_event_context *ctx);
-void trace_ust_delete_channel(struct lttng_ht *ht,
-               struct ltt_ust_channel *channel);
-
-/*
- * Destroy functions free() the data structure and remove from linked list if
- * it's applies.
- */
-void trace_ust_destroy_session(struct ltt_ust_session *session);
-void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
-void trace_ust_destroy_event(struct ltt_ust_event *event);
-void trace_ust_destroy_context(struct ltt_ust_context *ctx);
-void trace_ust_free_session(struct ltt_ust_session *session);
-
-int trace_ust_id_tracker_lookup(enum lttng_process_attr process_attr,
-               struct ltt_ust_session *session,
-               int id);
-enum lttng_error_code trace_ust_process_attr_tracker_set_tracking_policy(
-               struct ltt_ust_session *session,
-               enum lttng_process_attr process_attr,
-               enum lttng_tracking_policy policy);
-enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_add_value(
-               struct ltt_ust_session *session,
-               enum lttng_process_attr process_attr,
-               const struct process_attr_value *value);
-enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_remove_value(
-               struct ltt_ust_session *session,
-               enum lttng_process_attr process_attr,
-               const struct process_attr_value *value);
-const struct process_attr_tracker *trace_ust_get_process_attr_tracker(
-               struct ltt_ust_session *session,
-               enum lttng_process_attr process_attr);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline int trace_ust_ht_match_event(
-               struct cds_lfht_node *node __attribute__((unused)),
-               const void *_key __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline int trace_ust_ht_match_event_by_name(
-               struct cds_lfht_node *node __attribute__((unused)),
-               const void *_key __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-struct ltt_ust_channel *trace_ust_find_channel_by_name(
-               struct lttng_ht *ht __attribute__((unused)),
-               const char *name __attribute__((unused)))
-{
-       return NULL;
-}
-
-static inline
-struct ltt_ust_session *trace_ust_create_session(
-               unsigned int session_id __attribute__((unused)))
-{
-       return NULL;
-}
-
-static inline
-struct ltt_ust_channel *trace_ust_create_channel(
-               struct lttng_channel *attr __attribute__((unused)),
-               enum lttng_domain_type domain __attribute__((unused)))
-{
-       return NULL;
-}
-
-static inline
-enum lttng_error_code trace_ust_create_event(
-               struct lttng_event *ev __attribute__((unused)),
-               const char *filter_expression __attribute__((unused)),
-               struct lttng_bytecode *filter __attribute__((unused)),
-               struct lttng_event_exclusion *exclusion __attribute__((unused)),
-               bool internal_event __attribute__((unused)),
-               struct ltt_ust_event **ust_event __attribute__((unused)))
-{
-       return LTTNG_ERR_NO_UST;
-}
-
-static inline
-void trace_ust_destroy_session(
-               struct ltt_ust_session *session __attribute__((unused)))
-{
-}
-
-static inline
-void trace_ust_destroy_channel(
-               struct ltt_ust_channel *channel __attribute__((unused)))
-{
-}
-
-static inline
-void trace_ust_destroy_event(
-               struct ltt_ust_event *event __attribute__((unused)))
-{
-}
-
-static inline
-void trace_ust_free_session(
-               struct ltt_ust_session *session __attribute__((unused)))
-{
-}
-
-static inline
-struct ltt_ust_context *trace_ust_create_context(
-               const struct lttng_event_context *ctx __attribute__((unused)))
-{
-       return NULL;
-}
-
-static inline
-int trace_ust_match_context(
-               const struct ltt_ust_context *uctx __attribute__((unused)),
-               const struct lttng_event_context *ctx __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-struct ltt_ust_event *trace_ust_find_event(
-               struct lttng_ht *ht __attribute__((unused)),
-               char *name __attribute__((unused)),
-               struct lttng_bytecode *filter __attribute__((unused)),
-               enum lttng_ust_abi_loglevel_type loglevel_type __attribute__((unused)),
-               int loglevel_value __attribute__((unused)),
-               struct lttng_event_exclusion *exclusion __attribute__((unused)))
-{
-       return NULL;
-}
-
-static inline
-void trace_ust_delete_channel(
-               struct lttng_ht *ht __attribute__((unused)),
-               struct ltt_ust_channel *channel __attribute__((unused)))
-{
-       return;
-}
-
-static inline
-struct agent *trace_ust_find_agent(
-               struct ltt_ust_session *session __attribute__((unused)),
-               enum lttng_domain_type domain_type __attribute__((unused)))
-{
-       return NULL;
-}
-
-static inline int trace_ust_id_tracker_lookup(
-               enum lttng_process_attr process_attr __attribute__((unused)),
-               struct ltt_ust_session *session __attribute__((unused)),
-               int id __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline enum lttng_error_code
-trace_ust_process_attr_tracker_set_tracking_policy(
-               struct ltt_ust_session *session __attribute__((unused)),
-               enum lttng_process_attr process_attr __attribute__((unused)),
-               enum lttng_tracking_policy policy __attribute__((unused)))
-{
-       return LTTNG_OK;
-}
-
-static inline enum lttng_error_code
-trace_ust_process_attr_tracker_inclusion_set_add_value(
-               struct ltt_ust_session *session __attribute__((unused)),
-               enum lttng_process_attr process_attr __attribute__((unused)),
-               const struct process_attr_value *value __attribute__((unused)))
-{
-       return LTTNG_OK;
-}
-
-static inline enum lttng_error_code
-trace_ust_process_attr_tracker_inclusion_set_remove_value(
-               struct ltt_ust_session *session __attribute__((unused)),
-               enum lttng_process_attr process_attr __attribute__((unused)),
-               const struct process_attr_value *value __attribute__((unused)))
-{
-       return LTTNG_OK;
-}
-
-static inline const struct process_attr_tracker *
-trace_ust_get_process_attr_tracker(
-               struct ltt_ust_session *session __attribute__((unused)),
-               enum lttng_process_attr process_attr __attribute__((unused)))
-{
-       return NULL;
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* _LTT_TRACE_UST_H */
diff --git a/src/bin/lttng-sessiond/trace-ust.hpp b/src/bin/lttng-sessiond/trace-ust.hpp
new file mode 100644 (file)
index 0000000..9999537
--- /dev/null
@@ -0,0 +1,404 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_TRACE_UST_H
+#define _LTT_TRACE_UST_H
+
+#include <limits.h>
+#include <urcu/list.h>
+
+#include <common/defaults.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/tracker.hpp>
+#include <lttng/lttng.h>
+
+#include "consumer.hpp"
+#include "lttng-ust-ctl.hpp"
+
+struct agent;
+
+struct ltt_ust_ht_key {
+       const char *name;
+       const struct lttng_bytecode *filter;
+       enum lttng_ust_abi_loglevel_type loglevel_type;
+       int loglevel_value;
+       const struct lttng_event_exclusion *exclusion;
+};
+
+/* Context hash table nodes */
+struct ltt_ust_context {
+       struct lttng_ust_context_attr ctx;
+       struct lttng_ht_node_ulong node;
+       struct cds_list_head list;
+};
+
+/* UST event */
+struct ltt_ust_event {
+       unsigned int enabled;
+       struct lttng_ust_abi_event attr;
+       struct lttng_ht_node_str node;
+       char *filter_expression;
+       struct lttng_bytecode *filter;
+       struct lttng_event_exclusion *exclusion;
+       /*
+        * An internal event is an event which was created by the session daemon
+        * through which, for example, events emitted in Agent domains are
+        * "funelled". This is used to hide internal events from external
+        * clients as they should never be modified by the external world.
+        */
+       bool internal;
+};
+
+/* UST channel */
+struct ltt_ust_channel {
+       uint64_t id;    /* unique id per session. */
+       unsigned int enabled;
+       /*
+        * A UST channel can be part of a userspace sub-domain such as JUL,
+        * Log4j, Python.
+        */
+       enum lttng_domain_type domain;
+       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+       struct lttng_ust_abi_channel_attr attr;
+       struct lttng_ht *ctx;
+       struct cds_list_head ctx_list;
+       struct lttng_ht *events;
+       struct lttng_ht_node_str node;
+       uint64_t tracefile_size;
+       uint64_t tracefile_count;
+       uint64_t per_pid_closed_app_discarded;
+       uint64_t per_pid_closed_app_lost;
+       uint64_t monitor_timer_interval;
+};
+
+/* UST domain global (LTTNG_DOMAIN_UST) */
+struct ltt_ust_domain_global {
+       struct lttng_ht *channels;
+       struct cds_list_head registry_buffer_uid_list;
+};
+
+struct ust_id_tracker_node {
+       struct lttng_ht_node_ulong node;
+};
+
+struct ust_id_tracker {
+       struct lttng_ht *ht;
+};
+
+/* UST session */
+struct ltt_ust_session {
+       uint64_t id;    /* Unique identifier of session */
+       struct ltt_ust_domain_global domain_global;
+       /* Hash table of agent indexed by agent domain. */
+       struct lttng_ht *agents;
+       /* UID/GID of the user owning the session */
+       uid_t uid;
+       gid_t gid;
+       /* Is the session active meaning has is been started or stopped. */
+       unsigned int active:1;
+       struct consumer_output *consumer;
+       /* Sequence number for filters so the tracer knows the ordering. */
+       uint64_t filter_seq_num;
+       /* This indicates which type of buffer this session is set for. */
+       enum lttng_buffer_type buffer_type;
+       /* If set to 1, the buffer_type can not be changed anymore. */
+       int buffer_type_changed;
+       /* For per UID buffer, every buffer reg object is kept of this session */
+       struct cds_list_head buffer_reg_uid_list;
+       /* Next channel ID available for a newly registered channel. */
+       uint64_t next_channel_id;
+       /* Once this value reaches UINT32_MAX, no more id can be allocated. */
+       uint64_t used_channel_id;
+       /* Tell or not if the session has to output the traces. */
+       unsigned int output_traces;
+       unsigned int snapshot_mode;
+       unsigned int has_non_default_channel;
+       unsigned int live_timer_interval;       /* usec */
+
+       /* Metadata channel attributes. */
+       struct lttng_ust_abi_channel_attr metadata_attr;
+
+       /*
+        * Path where to keep the shared memory files.
+        */
+       char root_shm_path[PATH_MAX];
+       char shm_path[PATH_MAX];
+
+       /* Current trace chunk of the ltt_session. */
+       struct lttng_trace_chunk *current_trace_chunk;
+
+       /* Trackers used for actual lookup on app registration. */
+       struct ust_id_tracker vpid_tracker;
+       struct ust_id_tracker vuid_tracker;
+       struct ust_id_tracker vgid_tracker;
+
+       /* Tracker list of keys requested by users. */
+       struct process_attr_tracker *tracker_vpid;
+       struct process_attr_tracker *tracker_vuid;
+       struct process_attr_tracker *tracker_vgid;
+};
+
+/*
+ * Validate that the id has reached the maximum allowed or not.
+ *
+ * Return 0 if NOT else 1.
+ */
+static inline int trace_ust_is_max_id(uint64_t id)
+{
+       return (id == UINT64_MAX) ? 1 : 0;
+}
+
+/*
+ * Return next available channel id and increment the used counter. The
+ * trace_ust_is_max_id function MUST be called before in order to validate if
+ * the maximum number of IDs have been reached. If not, it is safe to call this
+ * function.
+ *
+ * Return a unique channel ID. If max is reached, the used_channel_id counter
+ * is returned.
+ */
+static inline uint64_t trace_ust_get_next_chan_id(struct ltt_ust_session *s)
+{
+       if (trace_ust_is_max_id(s->used_channel_id)) {
+               return s->used_channel_id;
+       }
+
+       s->used_channel_id++;
+       return s->next_channel_id++;
+}
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key);
+int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node,
+               const void *_key);
+
+/*
+ * Lookup functions. NULL is returned if not found.
+ */
+struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
+               char *name, struct lttng_bytecode *filter,
+               enum lttng_ust_abi_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,
+               const char *name);
+struct agent *trace_ust_find_agent(struct ltt_ust_session *session,
+               enum lttng_domain_type domain_type);
+
+/*
+ * Create functions malloc() the data structure.
+ */
+struct ltt_ust_session *trace_ust_create_session(uint64_t session_id);
+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_bytecode *filter,
+               struct lttng_event_exclusion *exclusion,
+               bool internal_event, struct ltt_ust_event **ust_event);
+struct ltt_ust_context *trace_ust_create_context(
+               const struct lttng_event_context *ctx);
+int trace_ust_match_context(const struct ltt_ust_context *uctx,
+               const struct lttng_event_context *ctx);
+void trace_ust_delete_channel(struct lttng_ht *ht,
+               struct ltt_ust_channel *channel);
+
+/*
+ * Destroy functions free() the data structure and remove from linked list if
+ * it's applies.
+ */
+void trace_ust_destroy_session(struct ltt_ust_session *session);
+void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
+void trace_ust_destroy_event(struct ltt_ust_event *event);
+void trace_ust_destroy_context(struct ltt_ust_context *ctx);
+void trace_ust_free_session(struct ltt_ust_session *session);
+
+int trace_ust_id_tracker_lookup(enum lttng_process_attr process_attr,
+               struct ltt_ust_session *session,
+               int id);
+enum lttng_error_code trace_ust_process_attr_tracker_set_tracking_policy(
+               struct ltt_ust_session *session,
+               enum lttng_process_attr process_attr,
+               enum lttng_tracking_policy policy);
+enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_add_value(
+               struct ltt_ust_session *session,
+               enum lttng_process_attr process_attr,
+               const struct process_attr_value *value);
+enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_remove_value(
+               struct ltt_ust_session *session,
+               enum lttng_process_attr process_attr,
+               const struct process_attr_value *value);
+const struct process_attr_tracker *trace_ust_get_process_attr_tracker(
+               struct ltt_ust_session *session,
+               enum lttng_process_attr process_attr);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline int trace_ust_ht_match_event(
+               struct cds_lfht_node *node __attribute__((unused)),
+               const void *_key __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline int trace_ust_ht_match_event_by_name(
+               struct cds_lfht_node *node __attribute__((unused)),
+               const void *_key __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+struct ltt_ust_channel *trace_ust_find_channel_by_name(
+               struct lttng_ht *ht __attribute__((unused)),
+               const char *name __attribute__((unused)))
+{
+       return NULL;
+}
+
+static inline
+struct ltt_ust_session *trace_ust_create_session(
+               unsigned int session_id __attribute__((unused)))
+{
+       return NULL;
+}
+
+static inline
+struct ltt_ust_channel *trace_ust_create_channel(
+               struct lttng_channel *attr __attribute__((unused)),
+               enum lttng_domain_type domain __attribute__((unused)))
+{
+       return NULL;
+}
+
+static inline
+enum lttng_error_code trace_ust_create_event(
+               struct lttng_event *ev __attribute__((unused)),
+               const char *filter_expression __attribute__((unused)),
+               struct lttng_bytecode *filter __attribute__((unused)),
+               struct lttng_event_exclusion *exclusion __attribute__((unused)),
+               bool internal_event __attribute__((unused)),
+               struct ltt_ust_event **ust_event __attribute__((unused)))
+{
+       return LTTNG_ERR_NO_UST;
+}
+
+static inline
+void trace_ust_destroy_session(
+               struct ltt_ust_session *session __attribute__((unused)))
+{
+}
+
+static inline
+void trace_ust_destroy_channel(
+               struct ltt_ust_channel *channel __attribute__((unused)))
+{
+}
+
+static inline
+void trace_ust_destroy_event(
+               struct ltt_ust_event *event __attribute__((unused)))
+{
+}
+
+static inline
+void trace_ust_free_session(
+               struct ltt_ust_session *session __attribute__((unused)))
+{
+}
+
+static inline
+struct ltt_ust_context *trace_ust_create_context(
+               const struct lttng_event_context *ctx __attribute__((unused)))
+{
+       return NULL;
+}
+
+static inline
+int trace_ust_match_context(
+               const struct ltt_ust_context *uctx __attribute__((unused)),
+               const struct lttng_event_context *ctx __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+struct ltt_ust_event *trace_ust_find_event(
+               struct lttng_ht *ht __attribute__((unused)),
+               char *name __attribute__((unused)),
+               struct lttng_bytecode *filter __attribute__((unused)),
+               enum lttng_ust_abi_loglevel_type loglevel_type __attribute__((unused)),
+               int loglevel_value __attribute__((unused)),
+               struct lttng_event_exclusion *exclusion __attribute__((unused)))
+{
+       return NULL;
+}
+
+static inline
+void trace_ust_delete_channel(
+               struct lttng_ht *ht __attribute__((unused)),
+               struct ltt_ust_channel *channel __attribute__((unused)))
+{
+       return;
+}
+
+static inline
+struct agent *trace_ust_find_agent(
+               struct ltt_ust_session *session __attribute__((unused)),
+               enum lttng_domain_type domain_type __attribute__((unused)))
+{
+       return NULL;
+}
+
+static inline int trace_ust_id_tracker_lookup(
+               enum lttng_process_attr process_attr __attribute__((unused)),
+               struct ltt_ust_session *session __attribute__((unused)),
+               int id __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline enum lttng_error_code
+trace_ust_process_attr_tracker_set_tracking_policy(
+               struct ltt_ust_session *session __attribute__((unused)),
+               enum lttng_process_attr process_attr __attribute__((unused)),
+               enum lttng_tracking_policy policy __attribute__((unused)))
+{
+       return LTTNG_OK;
+}
+
+static inline enum lttng_error_code
+trace_ust_process_attr_tracker_inclusion_set_add_value(
+               struct ltt_ust_session *session __attribute__((unused)),
+               enum lttng_process_attr process_attr __attribute__((unused)),
+               const struct process_attr_value *value __attribute__((unused)))
+{
+       return LTTNG_OK;
+}
+
+static inline enum lttng_error_code
+trace_ust_process_attr_tracker_inclusion_set_remove_value(
+               struct ltt_ust_session *session __attribute__((unused)),
+               enum lttng_process_attr process_attr __attribute__((unused)),
+               const struct process_attr_value *value __attribute__((unused)))
+{
+       return LTTNG_OK;
+}
+
+static inline const struct process_attr_tracker *
+trace_ust_get_process_attr_tracker(
+               struct ltt_ust_session *session __attribute__((unused)),
+               enum lttng_process_attr process_attr __attribute__((unused)))
+{
+       return NULL;
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* _LTT_TRACE_UST_H */
index 1cae40350cbcd8c6466ce628fa6a00944539491c..204ade426316b288afd6e59d1ceade61f82a706f 100644 (file)
@@ -7,8 +7,8 @@
  */
 
 #include "lttng/tracker.h"
-#include "common/dynamic-array.h"
-#include "common/macros.h"
+#include "common/dynamic-array.hpp"
+#include "common/macros.hpp"
 #define _LGPL_SOURCE
 #include <grp.h>
 #include <pwd.h>
 #include <urcu/list.h>
 #include <urcu/rculfhash.h>
 
-#include "tracker.h"
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/tracker.h>
+#include "tracker.hpp"
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/tracker.hpp>
 #include <lttng/lttng-error.h>
 
 struct process_attr_tracker_value_node {
diff --git a/src/bin/lttng-sessiond/tracker.h b/src/bin/lttng-sessiond/tracker.h
deleted file mode 100644 (file)
index a45a250..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2018 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_TRACKER_H
-#define _LTT_TRACKER_H
-
-#include <common/tracker.h>
-#include <lttng/tracker.h>
-
-struct process_attr_tracker;
-
-enum process_attr_tracker_status {
-       PROCESS_ATTR_TRACKER_STATUS_OK,
-       PROCESS_ATTR_TRACKER_STATUS_ERROR,
-       PROCESS_ATTR_TRACKER_STATUS_EXISTS,
-       PROCESS_ATTR_TRACKER_STATUS_MISSING,
-       PROCESS_ATTR_TRACKER_STATUS_INVALID_TRACKING_POLICY,
-};
-
-struct process_attr_tracker *process_attr_tracker_create(void);
-void process_attr_tracker_destroy(struct process_attr_tracker *tracker);
-
-enum lttng_tracking_policy process_attr_tracker_get_tracking_policy(
-               const struct process_attr_tracker *tracker);
-int process_attr_tracker_set_tracking_policy(
-               struct process_attr_tracker *tracker,
-               enum lttng_tracking_policy tracking_policy);
-
-enum process_attr_tracker_status process_attr_tracker_inclusion_set_add_value(
-               struct process_attr_tracker *tracker,
-               const struct process_attr_value *value);
-enum process_attr_tracker_status
-process_attr_tracker_inclusion_set_remove_value(
-               struct process_attr_tracker *tracker,
-               const struct process_attr_value *value);
-
-enum process_attr_tracker_status process_attr_tracker_get_inclusion_set(
-               const struct process_attr_tracker *tracker,
-               struct lttng_process_attr_values **values);
-
-#endif /* _LTT_TRACKER_H */
diff --git a/src/bin/lttng-sessiond/tracker.hpp b/src/bin/lttng-sessiond/tracker.hpp
new file mode 100644 (file)
index 0000000..c3f6b96
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_TRACKER_H
+#define _LTT_TRACKER_H
+
+#include <common/tracker.hpp>
+#include <lttng/tracker.h>
+
+struct process_attr_tracker;
+
+enum process_attr_tracker_status {
+       PROCESS_ATTR_TRACKER_STATUS_OK,
+       PROCESS_ATTR_TRACKER_STATUS_ERROR,
+       PROCESS_ATTR_TRACKER_STATUS_EXISTS,
+       PROCESS_ATTR_TRACKER_STATUS_MISSING,
+       PROCESS_ATTR_TRACKER_STATUS_INVALID_TRACKING_POLICY,
+};
+
+struct process_attr_tracker *process_attr_tracker_create(void);
+void process_attr_tracker_destroy(struct process_attr_tracker *tracker);
+
+enum lttng_tracking_policy process_attr_tracker_get_tracking_policy(
+               const struct process_attr_tracker *tracker);
+int process_attr_tracker_set_tracking_policy(
+               struct process_attr_tracker *tracker,
+               enum lttng_tracking_policy tracking_policy);
+
+enum process_attr_tracker_status process_attr_tracker_inclusion_set_add_value(
+               struct process_attr_tracker *tracker,
+               const struct process_attr_value *value);
+enum process_attr_tracker_status
+process_attr_tracker_inclusion_set_remove_value(
+               struct process_attr_tracker *tracker,
+               const struct process_attr_value *value);
+
+enum process_attr_tracker_status process_attr_tracker_get_inclusion_set(
+               const struct process_attr_tracker *tracker,
+               struct lttng_process_attr_values **values);
+
+#endif /* _LTT_TRACKER_H */
index 5bf6128900b87a8a9b6ff063495f7c25a9f2a97e..63941a8abe05d71018c40c26aa4fdec996a44d3a 100644 (file)
@@ -5,10 +5,10 @@
  *
  */
 
-#include "event-notifier-error-accounting.h"
-#include <lttng/error-query-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/action/action-internal.h>
+#include "event-notifier-error-accounting.hpp"
+#include <lttng/error-query-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <lttng/action/action-internal.hpp>
 
 enum lttng_trigger_status lttng_trigger_add_error_results(
                const struct lttng_trigger *trigger __attribute__((unused)),
diff --git a/src/bin/lttng-sessiond/ust-abi-internal.h b/src/bin/lttng-sessiond/ust-abi-internal.h
deleted file mode 100644 (file)
index 652e476..0000000
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * Copyright 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- * Copied from LTTng-UST lttng/ust-abi.h
- *
- * LTTng-UST ABI header
- *
- */
-
-#ifndef LTTNG_UST_ABI_INTERNAL_H
-#define LTTNG_UST_ABI_INTERNAL_H
-
-#include <stdint.h>
-#include <common/macros.h>
-
-#ifndef LTTNG_PACKED
-#error "LTTNG_PACKED should be defined"
-#endif
-
-#ifndef __ust_stringify
-#define __ust_stringify1(x)    #x
-#define __ust_stringify(x)     __ust_stringify1(x)
-#endif /* __ust_stringify */
-
-#define LTTNG_UST_ABI_SYM_NAME_LEN             256
-#define LTTNG_UST_ABI_PROCNAME_LEN             16
-
-/* UST comm magic number, used to validate protocol and endianness. */
-#define LTTNG_UST_ABI_COMM_MAGIC                       0xC57C57C5
-
-/* Version for ABI between liblttng-ust, sessiond, consumerd */
-#define LTTNG_UST_ABI_MAJOR_VERSION                    9
-#define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE  8
-#define LTTNG_UST_ABI_MINOR_VERSION            0
-
-enum lttng_ust_abi_instrumentation {
-       LTTNG_UST_ABI_TRACEPOINT        = 0,
-       LTTNG_UST_ABI_PROBE             = 1,
-       LTTNG_UST_ABI_FUNCTION          = 2,
-};
-
-enum lttng_ust_abi_loglevel_type {
-       LTTNG_UST_ABI_LOGLEVEL_ALL      = 0,
-       LTTNG_UST_ABI_LOGLEVEL_RANGE    = 1,
-       LTTNG_UST_ABI_LOGLEVEL_SINGLE   = 2,
-};
-
-enum lttng_ust_abi_output {
-       LTTNG_UST_ABI_MMAP              = 0,
-};
-
-enum lttng_ust_abi_chan_type {
-       LTTNG_UST_ABI_CHAN_PER_CPU = 0,
-       LTTNG_UST_ABI_CHAN_METADATA = 1,
-};
-
-struct lttng_ust_abi_tracer_version {
-       uint32_t major;
-       uint32_t minor;
-       uint32_t patchlevel;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_CHANNEL_PADDING  (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-/*
- * Given that the consumerd is limited to 64k file descriptors, we
- * cannot expect much more than 1MB channel structure size. This size is
- * depends on the number of streams within a channel, which depends on
- * the number of possible CPUs on the system.
- */
-#define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN     1048576U
-struct lttng_ust_abi_channel {
-       uint64_t len;
-       int32_t type;   /* enum lttng_ust_abi_chan_type */
-       char padding[LTTNG_UST_ABI_CHANNEL_PADDING];
-       char data[];    /* variable sized data */
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_STREAM_PADDING1  (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_stream {
-       uint64_t len;           /* shm len */
-       uint32_t stream_nr;     /* stream number */
-       char padding[LTTNG_UST_ABI_STREAM_PADDING1];
-       /*
-        * shm_fd and wakeup_fd are send over unix socket as file
-        * descriptors after this structure.
-        */
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_COUNTER_DIMENSION_MAX 4
-
-enum lttng_ust_abi_counter_arithmetic {
-       LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
-       LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION = 1,
-};
-
-enum lttng_ust_abi_counter_bitness {
-       LTTNG_UST_ABI_COUNTER_BITNESS_32 = 0,
-       LTTNG_UST_ABI_COUNTER_BITNESS_64 = 1,
-};
-
-struct lttng_ust_abi_counter_dimension {
-       uint64_t size;
-       uint64_t underflow_index;
-       uint64_t overflow_index;
-       uint8_t has_underflow;
-       uint8_t has_overflow;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_COUNTER_CONF_PADDING1 67
-struct lttng_ust_abi_counter_conf {
-       uint32_t arithmetic;    /* enum lttng_ust_abi_counter_arithmetic */
-       uint32_t bitness;       /* enum lttng_ust_abi_counter_bitness */
-       uint32_t number_dimensions;
-       int64_t global_sum_step;
-       struct lttng_ust_abi_counter_dimension dimensions[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
-       uint8_t coalesce_hits;
-       char padding[LTTNG_UST_ABI_COUNTER_CONF_PADDING1];
-} LTTNG_PACKED;
-
-struct lttng_ust_abi_counter_value {
-       uint32_t number_dimensions;
-       uint64_t dimension_indexes[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
-       int64_t value;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_EVENT_PADDING1   8
-#define LTTNG_UST_ABI_EVENT_PADDING2   (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_event {
-       int32_t instrumentation;                /* enum lttng_ust_abi_instrumentation */
-       char name[LTTNG_UST_ABI_SYM_NAME_LEN];  /* event name */
-
-       int32_t loglevel_type;                  /* enum lttng_ust_abi_loglevel_type */
-       int32_t loglevel;                       /* value, -1: all */
-       uint64_t token;                         /* User-provided token */
-       char padding[LTTNG_UST_ABI_EVENT_PADDING1];
-
-       /* Per instrumentation type configuration */
-       union {
-               char padding[LTTNG_UST_ABI_EVENT_PADDING2];
-       } u;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING   32
-struct lttng_ust_abi_event_notifier {
-       struct lttng_ust_abi_event event;
-       uint64_t error_counter_index;
-       char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
-struct lttng_ust_abi_event_notifier_notification {
-       uint64_t token;
-       uint16_t capture_buf_size;
-       char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_COUNTER_PADDING1         (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-#define LTTNG_UST_ABI_COUNTER_DATA_MAX_LEN     4096U
-struct lttng_ust_abi_counter {
-       uint64_t len;
-       char padding[LTTNG_UST_ABI_COUNTER_PADDING1];
-       char data[];    /* variable sized data */
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1  (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_counter_global {
-       uint64_t len;           /* shm len */
-       char padding[LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_COUNTER_CPU_PADDING1     (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_counter_cpu {
-       uint64_t len;           /* shm len */
-       uint32_t cpu_nr;
-       char padding[LTTNG_UST_ABI_COUNTER_CPU_PADDING1];
-} LTTNG_PACKED;
-
-enum lttng_ust_abi_field_type {
-       LTTNG_UST_ABI_FIELD_OTHER                       = 0,
-       LTTNG_UST_ABI_FIELD_INTEGER                     = 1,
-       LTTNG_UST_ABI_FIELD_ENUM                        = 2,
-       LTTNG_UST_ABI_FIELD_FLOAT                       = 3,
-       LTTNG_UST_ABI_FIELD_STRING                      = 4,
-};
-
-#define LTTNG_UST_ABI_FIELD_ITER_PADDING       (LTTNG_UST_ABI_SYM_NAME_LEN + 28)
-struct lttng_ust_abi_field_iter {
-       char event_name[LTTNG_UST_ABI_SYM_NAME_LEN];
-       char field_name[LTTNG_UST_ABI_SYM_NAME_LEN];
-       int32_t type;                           /* enum lttng_ust_abi_field_type */
-       int loglevel;                           /* event loglevel */
-       int nowrite;
-       char padding[LTTNG_UST_ABI_FIELD_ITER_PADDING];
-} LTTNG_PACKED;
-
-enum lttng_ust_abi_context_type {
-       LTTNG_UST_ABI_CONTEXT_VTID                      = 0,
-       LTTNG_UST_ABI_CONTEXT_VPID                      = 1,
-       LTTNG_UST_ABI_CONTEXT_PTHREAD_ID                = 2,
-       LTTNG_UST_ABI_CONTEXT_PROCNAME                  = 3,
-       LTTNG_UST_ABI_CONTEXT_IP                        = 4,
-       LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER       = 5,
-       LTTNG_UST_ABI_CONTEXT_CPU_ID                    = 6,
-       LTTNG_UST_ABI_CONTEXT_APP_CONTEXT               = 7,
-       LTTNG_UST_ABI_CONTEXT_CGROUP_NS                 = 8,
-       LTTNG_UST_ABI_CONTEXT_IPC_NS                    = 9,
-       LTTNG_UST_ABI_CONTEXT_MNT_NS                    = 10,
-       LTTNG_UST_ABI_CONTEXT_NET_NS                    = 11,
-       LTTNG_UST_ABI_CONTEXT_PID_NS                    = 12,
-       LTTNG_UST_ABI_CONTEXT_USER_NS                   = 13,
-       LTTNG_UST_ABI_CONTEXT_UTS_NS                    = 14,
-       LTTNG_UST_ABI_CONTEXT_VUID                      = 15,
-       LTTNG_UST_ABI_CONTEXT_VEUID                     = 16,
-       LTTNG_UST_ABI_CONTEXT_VSUID                     = 17,
-       LTTNG_UST_ABI_CONTEXT_VGID                      = 18,
-       LTTNG_UST_ABI_CONTEXT_VEGID                     = 19,
-       LTTNG_UST_ABI_CONTEXT_VSGID                     = 20,
-       LTTNG_UST_ABI_CONTEXT_TIME_NS                   = 21,
-};
-
-struct lttng_ust_abi_perf_counter_ctx {
-       uint32_t type;
-       uint64_t config;
-       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_CONTEXT_PADDING1 16
-#define LTTNG_UST_ABI_CONTEXT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_context {
-       int32_t ctx;     /* enum lttng_ust_abi_context_type */
-       char padding[LTTNG_UST_ABI_CONTEXT_PADDING1];
-
-       union {
-               struct lttng_ust_abi_perf_counter_ctx perf_counter;
-               struct {
-                       /* Includes trailing '\0'. */
-                       uint32_t provider_name_len;
-                       uint32_t ctx_name_len;
-               } app_ctx;
-               char padding[LTTNG_UST_ABI_CONTEXT_PADDING2];
-       } u;
-} LTTNG_PACKED;
-
-/*
- * Tracer channel attributes.
- */
-#define LTTNG_UST_ABI_CHANNEL_ATTR_PADDING     (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_channel_attr {
-       uint64_t subbuf_size;                   /* bytes */
-       uint64_t num_subbuf;                    /* power of 2 */
-       int overwrite;                          /* 1: overwrite, 0: discard */
-       unsigned int switch_timer_interval;     /* usec */
-       unsigned int read_timer_interval;       /* usec */
-       int32_t output;                         /* enum lttng_ust_abi_output */
-       union {
-               struct {
-                       int64_t blocking_timeout;       /* Blocking timeout (usec) */
-               } s;
-               char padding[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING];
-       } u;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING  16
-struct lttng_ust_abi_tracepoint_iter {
-       char name[LTTNG_UST_ABI_SYM_NAME_LEN];  /* provider:name */
-       int loglevel;
-       char padding[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING];
-} LTTNG_PACKED;
-
-enum lttng_ust_abi_object_type {
-       LTTNG_UST_ABI_OBJECT_TYPE_UNKNOWN = -1,
-       LTTNG_UST_ABI_OBJECT_TYPE_CHANNEL = 0,
-       LTTNG_UST_ABI_OBJECT_TYPE_STREAM = 1,
-       LTTNG_UST_ABI_OBJECT_TYPE_EVENT = 2,
-       LTTNG_UST_ABI_OBJECT_TYPE_CONTEXT = 3,
-       LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER_GROUP = 4,
-       LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER = 5,
-       LTTNG_UST_ABI_OBJECT_TYPE_COUNTER = 6,
-       LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_GLOBAL = 7,
-       LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_CPU = 8,
-};
-
-#define LTTNG_UST_ABI_OBJECT_DATA_PADDING1     32
-#define LTTNG_UST_ABI_OBJECT_DATA_PADDING2     (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-
-struct lttng_ust_abi_object_data {
-       int32_t type;   /* enum lttng_ust_abi_object_type */
-       int handle;
-       uint64_t size;
-       char padding1[LTTNG_UST_ABI_OBJECT_DATA_PADDING1];
-       union {
-               struct {
-                       void *data;
-                       int32_t type;   /* enum lttng_ust_abi_chan_type */
-                       int wakeup_fd;
-               } channel;
-               struct {
-                       int shm_fd;
-                       int wakeup_fd;
-                       uint32_t stream_nr;
-               } stream;
-               struct {
-                       void *data;
-               } counter;
-               struct {
-                       int shm_fd;
-               } counter_global;
-               struct {
-                       int shm_fd;
-                       uint32_t cpu_nr;
-               } counter_cpu;
-               char padding2[LTTNG_UST_ABI_OBJECT_DATA_PADDING2];
-       } u;
-} LTTNG_PACKED;
-
-enum lttng_ust_abi_calibrate_type {
-       LTTNG_UST_ABI_CALIBRATE_TRACEPOINT,
-};
-
-#define LTTNG_UST_ABI_CALIBRATE_PADDING1       16
-#define LTTNG_UST_ABI_CALIBRATE_PADDING2       (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_calibrate {
-       enum lttng_ust_abi_calibrate_type type;         /* type (input) */
-       char padding[LTTNG_UST_ABI_CALIBRATE_PADDING1];
-
-       union {
-               char padding[LTTNG_UST_ABI_CALIBRATE_PADDING2];
-       } u;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_FILTER_BYTECODE_MAX_LEN  65536
-#define LTTNG_UST_ABI_FILTER_PADDING           32
-struct lttng_ust_abi_filter_bytecode {
-       uint32_t len;
-       uint32_t reloc_offset;
-       uint64_t seqnum;
-       char padding[LTTNG_UST_ABI_FILTER_PADDING];
-       char data[0];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
-#define LTTNG_UST_ABI_CAPTURE_PADDING          32
-struct lttng_ust_abi_capture_bytecode {
-       uint32_t len;
-       uint32_t reloc_offset;
-       uint64_t seqnum;
-       char padding[LTTNG_UST_ABI_CAPTURE_PADDING];
-       char data[0];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_EXCLUSION_PADDING        32
-struct lttng_ust_abi_event_exclusion {
-       uint32_t count;
-       char padding[LTTNG_UST_ABI_EXCLUSION_PADDING];
-       char names[LTTNG_UST_ABI_SYM_NAME_LEN][0];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_CMD(minor)               (minor)
-#define LTTNG_UST_ABI_CMDR(minor, type)                (minor)
-#define LTTNG_UST_ABI_CMDW(minor, type)                (minor)
-
-/* Handled by object descriptor */
-#define LTTNG_UST_ABI_RELEASE                  LTTNG_UST_ABI_CMD(0x1)
-
-/* Handled by object cmd */
-
-/* LTTng-UST commands */
-#define LTTNG_UST_ABI_SESSION                  LTTNG_UST_ABI_CMD(0x40)
-#define LTTNG_UST_ABI_TRACER_VERSION           \
-       LTTNG_UST_ABI_CMDR(0x41, struct lttng_ust_abi_tracer_version)
-#define LTTNG_UST_ABI_TRACEPOINT_LIST          LTTNG_UST_ABI_CMD(0x42)
-#define LTTNG_UST_ABI_WAIT_QUIESCENT           LTTNG_UST_ABI_CMD(0x43)
-#define LTTNG_UST_ABI_REGISTER_DONE            LTTNG_UST_ABI_CMD(0x44)
-#define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST    LTTNG_UST_ABI_CMD(0x45)
-#define LTTNG_UST_ABI_EVENT_NOTIFIER_GROUP_CREATE \
-       LTTNG_UST_ABI_CMD(0x46)
-
-/* Session commands */
-#define LTTNG_UST_ABI_CHANNEL                  \
-       LTTNG_UST_ABI_CMDW(0x51, struct lttng_ust_abi_channel)
-#define LTTNG_UST_ABI_SESSION_START            LTTNG_UST_ABI_CMD(0x52)
-#define LTTNG_UST_ABI_SESSION_STOP             LTTNG_UST_ABI_CMD(0x53)
-#define LTTNG_UST_ABI_SESSION_STATEDUMP                LTTNG_UST_ABI_CMD(0x54)
-
-/* Channel commands */
-#define LTTNG_UST_ABI_STREAM                   LTTNG_UST_ABI_CMD(0x60)
-#define LTTNG_UST_ABI_EVENT                    \
-       LTTNG_UST_ABI_CMDW(0x61, struct lttng_ust_abi_event)
-
-/* Event and channel commands */
-#define LTTNG_UST_ABI_CONTEXT                  \
-       LTTNG_UST_ABI_CMDW(0x70, struct lttng_ust_abi_context)
-#define LTTNG_UST_ABI_FLUSH_BUFFER             \
-       LTTNG_UST_ABI_CMD(0x71)
-
-/* Event, event notifier, channel and session commands */
-#define LTTNG_UST_ABI_ENABLE                   LTTNG_UST_ABI_CMD(0x80)
-#define LTTNG_UST_ABI_DISABLE                  LTTNG_UST_ABI_CMD(0x81)
-
-/* Tracepoint list commands */
-#define LTTNG_UST_ABI_TRACEPOINT_LIST_GET      LTTNG_UST_ABI_CMD(0x90)
-#define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST_GET        LTTNG_UST_ABI_CMD(0x91)
-
-/* Event and event notifier commands */
-#define LTTNG_UST_ABI_FILTER                   LTTNG_UST_ABI_CMD(0xA0)
-#define LTTNG_UST_ABI_EXCLUSION                        LTTNG_UST_ABI_CMD(0xA1)
-
-/* Event notifier group commands */
-#define LTTNG_UST_ABI_EVENT_NOTIFIER_CREATE    \
-       LTTNG_UST_ABI_CMDW(0xB0, struct lttng_ust_abi_event_notifier)
-
-/* Event notifier commands */
-#define LTTNG_UST_ABI_CAPTURE                  LTTNG_UST_ABI_CMD(0xB6)
-
-/* Session and event notifier group commands */
-#define LTTNG_UST_ABI_COUNTER                  \
-       LTTNG_UST_ABI_CMDW(0xC0, struct lttng_ust_abi_counter)
-
-/* Counter commands */
-#define LTTNG_UST_ABI_COUNTER_GLOBAL           \
-       LTTNG_UST_ABI_CMDW(0xD0, struct lttng_ust_abi_counter_global)
-#define LTTNG_UST_ABI_COUNTER_CPU              \
-       LTTNG_UST_ABI_CMDW(0xD1, struct lttng_ust_abi_counter_cpu)
-
-#define LTTNG_UST_ABI_ROOT_HANDLE      0
-
-#endif /* LTTNG_UST_ABI_INTERNAL_H */
diff --git a/src/bin/lttng-sessiond/ust-abi-internal.hpp b/src/bin/lttng-sessiond/ust-abi-internal.hpp
new file mode 100644 (file)
index 0000000..343be56
--- /dev/null
@@ -0,0 +1,429 @@
+/*
+ * Copyright 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Copied from LTTng-UST lttng/ust-abi.h
+ *
+ * LTTng-UST ABI header
+ *
+ */
+
+#ifndef LTTNG_UST_ABI_INTERNAL_H
+#define LTTNG_UST_ABI_INTERNAL_H
+
+#include <stdint.h>
+#include <common/macros.hpp>
+
+#ifndef LTTNG_PACKED
+#error "LTTNG_PACKED should be defined"
+#endif
+
+#ifndef __ust_stringify
+#define __ust_stringify1(x)    #x
+#define __ust_stringify(x)     __ust_stringify1(x)
+#endif /* __ust_stringify */
+
+#define LTTNG_UST_ABI_SYM_NAME_LEN             256
+#define LTTNG_UST_ABI_PROCNAME_LEN             16
+
+/* UST comm magic number, used to validate protocol and endianness. */
+#define LTTNG_UST_ABI_COMM_MAGIC                       0xC57C57C5
+
+/* Version for ABI between liblttng-ust, sessiond, consumerd */
+#define LTTNG_UST_ABI_MAJOR_VERSION                    9
+#define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE  8
+#define LTTNG_UST_ABI_MINOR_VERSION            0
+
+enum lttng_ust_abi_instrumentation {
+       LTTNG_UST_ABI_TRACEPOINT        = 0,
+       LTTNG_UST_ABI_PROBE             = 1,
+       LTTNG_UST_ABI_FUNCTION          = 2,
+};
+
+enum lttng_ust_abi_loglevel_type {
+       LTTNG_UST_ABI_LOGLEVEL_ALL      = 0,
+       LTTNG_UST_ABI_LOGLEVEL_RANGE    = 1,
+       LTTNG_UST_ABI_LOGLEVEL_SINGLE   = 2,
+};
+
+enum lttng_ust_abi_output {
+       LTTNG_UST_ABI_MMAP              = 0,
+};
+
+enum lttng_ust_abi_chan_type {
+       LTTNG_UST_ABI_CHAN_PER_CPU = 0,
+       LTTNG_UST_ABI_CHAN_METADATA = 1,
+};
+
+struct lttng_ust_abi_tracer_version {
+       uint32_t major;
+       uint32_t minor;
+       uint32_t patchlevel;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_CHANNEL_PADDING  (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+/*
+ * Given that the consumerd is limited to 64k file descriptors, we
+ * cannot expect much more than 1MB channel structure size. This size is
+ * depends on the number of streams within a channel, which depends on
+ * the number of possible CPUs on the system.
+ */
+#define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN     1048576U
+struct lttng_ust_abi_channel {
+       uint64_t len;
+       int32_t type;   /* enum lttng_ust_abi_chan_type */
+       char padding[LTTNG_UST_ABI_CHANNEL_PADDING];
+       char data[];    /* variable sized data */
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_STREAM_PADDING1  (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_stream {
+       uint64_t len;           /* shm len */
+       uint32_t stream_nr;     /* stream number */
+       char padding[LTTNG_UST_ABI_STREAM_PADDING1];
+       /*
+        * shm_fd and wakeup_fd are send over unix socket as file
+        * descriptors after this structure.
+        */
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_COUNTER_DIMENSION_MAX 4
+
+enum lttng_ust_abi_counter_arithmetic {
+       LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
+       LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION = 1,
+};
+
+enum lttng_ust_abi_counter_bitness {
+       LTTNG_UST_ABI_COUNTER_BITNESS_32 = 0,
+       LTTNG_UST_ABI_COUNTER_BITNESS_64 = 1,
+};
+
+struct lttng_ust_abi_counter_dimension {
+       uint64_t size;
+       uint64_t underflow_index;
+       uint64_t overflow_index;
+       uint8_t has_underflow;
+       uint8_t has_overflow;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_COUNTER_CONF_PADDING1 67
+struct lttng_ust_abi_counter_conf {
+       uint32_t arithmetic;    /* enum lttng_ust_abi_counter_arithmetic */
+       uint32_t bitness;       /* enum lttng_ust_abi_counter_bitness */
+       uint32_t number_dimensions;
+       int64_t global_sum_step;
+       struct lttng_ust_abi_counter_dimension dimensions[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
+       uint8_t coalesce_hits;
+       char padding[LTTNG_UST_ABI_COUNTER_CONF_PADDING1];
+} LTTNG_PACKED;
+
+struct lttng_ust_abi_counter_value {
+       uint32_t number_dimensions;
+       uint64_t dimension_indexes[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
+       int64_t value;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_EVENT_PADDING1   8
+#define LTTNG_UST_ABI_EVENT_PADDING2   (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_event {
+       int32_t instrumentation;                /* enum lttng_ust_abi_instrumentation */
+       char name[LTTNG_UST_ABI_SYM_NAME_LEN];  /* event name */
+
+       int32_t loglevel_type;                  /* enum lttng_ust_abi_loglevel_type */
+       int32_t loglevel;                       /* value, -1: all */
+       uint64_t token;                         /* User-provided token */
+       char padding[LTTNG_UST_ABI_EVENT_PADDING1];
+
+       /* Per instrumentation type configuration */
+       union {
+               char padding[LTTNG_UST_ABI_EVENT_PADDING2];
+       } u;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING   32
+struct lttng_ust_abi_event_notifier {
+       struct lttng_ust_abi_event event;
+       uint64_t error_counter_index;
+       char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
+struct lttng_ust_abi_event_notifier_notification {
+       uint64_t token;
+       uint16_t capture_buf_size;
+       char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_COUNTER_PADDING1         (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+#define LTTNG_UST_ABI_COUNTER_DATA_MAX_LEN     4096U
+struct lttng_ust_abi_counter {
+       uint64_t len;
+       char padding[LTTNG_UST_ABI_COUNTER_PADDING1];
+       char data[];    /* variable sized data */
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1  (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_counter_global {
+       uint64_t len;           /* shm len */
+       char padding[LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_COUNTER_CPU_PADDING1     (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_counter_cpu {
+       uint64_t len;           /* shm len */
+       uint32_t cpu_nr;
+       char padding[LTTNG_UST_ABI_COUNTER_CPU_PADDING1];
+} LTTNG_PACKED;
+
+enum lttng_ust_abi_field_type {
+       LTTNG_UST_ABI_FIELD_OTHER                       = 0,
+       LTTNG_UST_ABI_FIELD_INTEGER                     = 1,
+       LTTNG_UST_ABI_FIELD_ENUM                        = 2,
+       LTTNG_UST_ABI_FIELD_FLOAT                       = 3,
+       LTTNG_UST_ABI_FIELD_STRING                      = 4,
+};
+
+#define LTTNG_UST_ABI_FIELD_ITER_PADDING       (LTTNG_UST_ABI_SYM_NAME_LEN + 28)
+struct lttng_ust_abi_field_iter {
+       char event_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+       char field_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+       int32_t type;                           /* enum lttng_ust_abi_field_type */
+       int loglevel;                           /* event loglevel */
+       int nowrite;
+       char padding[LTTNG_UST_ABI_FIELD_ITER_PADDING];
+} LTTNG_PACKED;
+
+enum lttng_ust_abi_context_type {
+       LTTNG_UST_ABI_CONTEXT_VTID                      = 0,
+       LTTNG_UST_ABI_CONTEXT_VPID                      = 1,
+       LTTNG_UST_ABI_CONTEXT_PTHREAD_ID                = 2,
+       LTTNG_UST_ABI_CONTEXT_PROCNAME                  = 3,
+       LTTNG_UST_ABI_CONTEXT_IP                        = 4,
+       LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER       = 5,
+       LTTNG_UST_ABI_CONTEXT_CPU_ID                    = 6,
+       LTTNG_UST_ABI_CONTEXT_APP_CONTEXT               = 7,
+       LTTNG_UST_ABI_CONTEXT_CGROUP_NS                 = 8,
+       LTTNG_UST_ABI_CONTEXT_IPC_NS                    = 9,
+       LTTNG_UST_ABI_CONTEXT_MNT_NS                    = 10,
+       LTTNG_UST_ABI_CONTEXT_NET_NS                    = 11,
+       LTTNG_UST_ABI_CONTEXT_PID_NS                    = 12,
+       LTTNG_UST_ABI_CONTEXT_USER_NS                   = 13,
+       LTTNG_UST_ABI_CONTEXT_UTS_NS                    = 14,
+       LTTNG_UST_ABI_CONTEXT_VUID                      = 15,
+       LTTNG_UST_ABI_CONTEXT_VEUID                     = 16,
+       LTTNG_UST_ABI_CONTEXT_VSUID                     = 17,
+       LTTNG_UST_ABI_CONTEXT_VGID                      = 18,
+       LTTNG_UST_ABI_CONTEXT_VEGID                     = 19,
+       LTTNG_UST_ABI_CONTEXT_VSGID                     = 20,
+       LTTNG_UST_ABI_CONTEXT_TIME_NS                   = 21,
+};
+
+struct lttng_ust_abi_perf_counter_ctx {
+       uint32_t type;
+       uint64_t config;
+       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_CONTEXT_PADDING1 16
+#define LTTNG_UST_ABI_CONTEXT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_context {
+       int32_t ctx;     /* enum lttng_ust_abi_context_type */
+       char padding[LTTNG_UST_ABI_CONTEXT_PADDING1];
+
+       union {
+               struct lttng_ust_abi_perf_counter_ctx perf_counter;
+               struct {
+                       /* Includes trailing '\0'. */
+                       uint32_t provider_name_len;
+                       uint32_t ctx_name_len;
+               } app_ctx;
+               char padding[LTTNG_UST_ABI_CONTEXT_PADDING2];
+       } u;
+} LTTNG_PACKED;
+
+/*
+ * Tracer channel attributes.
+ */
+#define LTTNG_UST_ABI_CHANNEL_ATTR_PADDING     (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_channel_attr {
+       uint64_t subbuf_size;                   /* bytes */
+       uint64_t num_subbuf;                    /* power of 2 */
+       int overwrite;                          /* 1: overwrite, 0: discard */
+       unsigned int switch_timer_interval;     /* usec */
+       unsigned int read_timer_interval;       /* usec */
+       int32_t output;                         /* enum lttng_ust_abi_output */
+       union {
+               struct {
+                       int64_t blocking_timeout;       /* Blocking timeout (usec) */
+               } s;
+               char padding[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING];
+       } u;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING  16
+struct lttng_ust_abi_tracepoint_iter {
+       char name[LTTNG_UST_ABI_SYM_NAME_LEN];  /* provider:name */
+       int loglevel;
+       char padding[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING];
+} LTTNG_PACKED;
+
+enum lttng_ust_abi_object_type {
+       LTTNG_UST_ABI_OBJECT_TYPE_UNKNOWN = -1,
+       LTTNG_UST_ABI_OBJECT_TYPE_CHANNEL = 0,
+       LTTNG_UST_ABI_OBJECT_TYPE_STREAM = 1,
+       LTTNG_UST_ABI_OBJECT_TYPE_EVENT = 2,
+       LTTNG_UST_ABI_OBJECT_TYPE_CONTEXT = 3,
+       LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER_GROUP = 4,
+       LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER = 5,
+       LTTNG_UST_ABI_OBJECT_TYPE_COUNTER = 6,
+       LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_GLOBAL = 7,
+       LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_CPU = 8,
+};
+
+#define LTTNG_UST_ABI_OBJECT_DATA_PADDING1     32
+#define LTTNG_UST_ABI_OBJECT_DATA_PADDING2     (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+
+struct lttng_ust_abi_object_data {
+       int32_t type;   /* enum lttng_ust_abi_object_type */
+       int handle;
+       uint64_t size;
+       char padding1[LTTNG_UST_ABI_OBJECT_DATA_PADDING1];
+       union {
+               struct {
+                       void *data;
+                       int32_t type;   /* enum lttng_ust_abi_chan_type */
+                       int wakeup_fd;
+               } channel;
+               struct {
+                       int shm_fd;
+                       int wakeup_fd;
+                       uint32_t stream_nr;
+               } stream;
+               struct {
+                       void *data;
+               } counter;
+               struct {
+                       int shm_fd;
+               } counter_global;
+               struct {
+                       int shm_fd;
+                       uint32_t cpu_nr;
+               } counter_cpu;
+               char padding2[LTTNG_UST_ABI_OBJECT_DATA_PADDING2];
+       } u;
+} LTTNG_PACKED;
+
+enum lttng_ust_abi_calibrate_type {
+       LTTNG_UST_ABI_CALIBRATE_TRACEPOINT,
+};
+
+#define LTTNG_UST_ABI_CALIBRATE_PADDING1       16
+#define LTTNG_UST_ABI_CALIBRATE_PADDING2       (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_calibrate {
+       enum lttng_ust_abi_calibrate_type type;         /* type (input) */
+       char padding[LTTNG_UST_ABI_CALIBRATE_PADDING1];
+
+       union {
+               char padding[LTTNG_UST_ABI_CALIBRATE_PADDING2];
+       } u;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_FILTER_BYTECODE_MAX_LEN  65536
+#define LTTNG_UST_ABI_FILTER_PADDING           32
+struct lttng_ust_abi_filter_bytecode {
+       uint32_t len;
+       uint32_t reloc_offset;
+       uint64_t seqnum;
+       char padding[LTTNG_UST_ABI_FILTER_PADDING];
+       char data[0];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
+#define LTTNG_UST_ABI_CAPTURE_PADDING          32
+struct lttng_ust_abi_capture_bytecode {
+       uint32_t len;
+       uint32_t reloc_offset;
+       uint64_t seqnum;
+       char padding[LTTNG_UST_ABI_CAPTURE_PADDING];
+       char data[0];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_EXCLUSION_PADDING        32
+struct lttng_ust_abi_event_exclusion {
+       uint32_t count;
+       char padding[LTTNG_UST_ABI_EXCLUSION_PADDING];
+       char names[LTTNG_UST_ABI_SYM_NAME_LEN][0];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_CMD(minor)               (minor)
+#define LTTNG_UST_ABI_CMDR(minor, type)                (minor)
+#define LTTNG_UST_ABI_CMDW(minor, type)                (minor)
+
+/* Handled by object descriptor */
+#define LTTNG_UST_ABI_RELEASE                  LTTNG_UST_ABI_CMD(0x1)
+
+/* Handled by object cmd */
+
+/* LTTng-UST commands */
+#define LTTNG_UST_ABI_SESSION                  LTTNG_UST_ABI_CMD(0x40)
+#define LTTNG_UST_ABI_TRACER_VERSION           \
+       LTTNG_UST_ABI_CMDR(0x41, struct lttng_ust_abi_tracer_version)
+#define LTTNG_UST_ABI_TRACEPOINT_LIST          LTTNG_UST_ABI_CMD(0x42)
+#define LTTNG_UST_ABI_WAIT_QUIESCENT           LTTNG_UST_ABI_CMD(0x43)
+#define LTTNG_UST_ABI_REGISTER_DONE            LTTNG_UST_ABI_CMD(0x44)
+#define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST    LTTNG_UST_ABI_CMD(0x45)
+#define LTTNG_UST_ABI_EVENT_NOTIFIER_GROUP_CREATE \
+       LTTNG_UST_ABI_CMD(0x46)
+
+/* Session commands */
+#define LTTNG_UST_ABI_CHANNEL                  \
+       LTTNG_UST_ABI_CMDW(0x51, struct lttng_ust_abi_channel)
+#define LTTNG_UST_ABI_SESSION_START            LTTNG_UST_ABI_CMD(0x52)
+#define LTTNG_UST_ABI_SESSION_STOP             LTTNG_UST_ABI_CMD(0x53)
+#define LTTNG_UST_ABI_SESSION_STATEDUMP                LTTNG_UST_ABI_CMD(0x54)
+
+/* Channel commands */
+#define LTTNG_UST_ABI_STREAM                   LTTNG_UST_ABI_CMD(0x60)
+#define LTTNG_UST_ABI_EVENT                    \
+       LTTNG_UST_ABI_CMDW(0x61, struct lttng_ust_abi_event)
+
+/* Event and channel commands */
+#define LTTNG_UST_ABI_CONTEXT                  \
+       LTTNG_UST_ABI_CMDW(0x70, struct lttng_ust_abi_context)
+#define LTTNG_UST_ABI_FLUSH_BUFFER             \
+       LTTNG_UST_ABI_CMD(0x71)
+
+/* Event, event notifier, channel and session commands */
+#define LTTNG_UST_ABI_ENABLE                   LTTNG_UST_ABI_CMD(0x80)
+#define LTTNG_UST_ABI_DISABLE                  LTTNG_UST_ABI_CMD(0x81)
+
+/* Tracepoint list commands */
+#define LTTNG_UST_ABI_TRACEPOINT_LIST_GET      LTTNG_UST_ABI_CMD(0x90)
+#define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST_GET        LTTNG_UST_ABI_CMD(0x91)
+
+/* Event and event notifier commands */
+#define LTTNG_UST_ABI_FILTER                   LTTNG_UST_ABI_CMD(0xA0)
+#define LTTNG_UST_ABI_EXCLUSION                        LTTNG_UST_ABI_CMD(0xA1)
+
+/* Event notifier group commands */
+#define LTTNG_UST_ABI_EVENT_NOTIFIER_CREATE    \
+       LTTNG_UST_ABI_CMDW(0xB0, struct lttng_ust_abi_event_notifier)
+
+/* Event notifier commands */
+#define LTTNG_UST_ABI_CAPTURE                  LTTNG_UST_ABI_CMD(0xB6)
+
+/* Session and event notifier group commands */
+#define LTTNG_UST_ABI_COUNTER                  \
+       LTTNG_UST_ABI_CMDW(0xC0, struct lttng_ust_abi_counter)
+
+/* Counter commands */
+#define LTTNG_UST_ABI_COUNTER_GLOBAL           \
+       LTTNG_UST_ABI_CMDW(0xD0, struct lttng_ust_abi_counter_global)
+#define LTTNG_UST_ABI_COUNTER_CPU              \
+       LTTNG_UST_ABI_CMDW(0xD1, struct lttng_ust_abi_counter_cpu)
+
+#define LTTNG_UST_ABI_ROOT_HANDLE      0
+
+#endif /* LTTNG_UST_ABI_INTERNAL_H */
index 1006f7f640ae1f381d469905fd8f09dd75660876..5cffdc9741012ec6cdc562ff56c2a11c8f75c8fa 100644 (file)
 #include <urcu/compiler.h>
 #include <signal.h>
 
-#include <common/bytecode/bytecode.h>
-#include <common/compat/errno.h>
-#include <common/common.h>
-#include <common/hashtable/utils.h>
+#include <common/bytecode/bytecode.hpp>
+#include <common/compat/errno.hpp>
+#include <common/common.hpp>
+#include <common/hashtable/utils.hpp>
 #include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
 #include <lttng/event-rule/user-tracepoint.h>
 #include <lttng/condition/condition.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/event-rule-matches-internal.hpp>
 #include <lttng/condition/event-rule-matches.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-
-#include "buffer-registry.h"
-#include "condition-internal.h"
-#include "fd-limit.h"
-#include "health-sessiond.h"
-#include "ust-app.h"
-#include "ust-consumer.h"
-#include "lttng-ust-ctl.h"
-#include "lttng-ust-error.h"
-#include "utils.h"
-#include "session.h"
-#include "lttng-sessiond.h"
-#include "notification-thread-commands.h"
-#include "rotate.h"
-#include "event.h"
-#include "event-notifier-error-accounting.h"
-#include "ust-field-utils.h"
+#include <lttng/trigger/trigger-internal.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include "buffer-registry.hpp"
+#include "condition-internal.hpp"
+#include "fd-limit.hpp"
+#include "health-sessiond.hpp"
+#include "ust-app.hpp"
+#include "ust-consumer.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "lttng-ust-error.hpp"
+#include "utils.hpp"
+#include "session.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-commands.hpp"
+#include "rotate.hpp"
+#include "event.hpp"
+#include "event-notifier-error-accounting.hpp"
+#include "ust-field-utils.hpp"
 
 struct lttng_ht *ust_app_ht;
 struct lttng_ht *ust_app_ht_by_sock;
diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h
deleted file mode 100644 (file)
index 8ad9085..0000000
+++ /dev/null
@@ -1,765 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_UST_APP_H
-#define _LTT_UST_APP_H
-
-#include <stdint.h>
-
-#include <common/index-allocator.h>
-#include <common/uuid.h>
-
-#include "trace-ust.h"
-#include "ust-registry.h"
-#include "session.h"
-
-#define UST_APP_EVENT_LIST_SIZE 32
-
-/* Process name (short). */
-#define UST_APP_PROCNAME_LEN   16
-
-struct lttng_bytecode;
-struct lttng_ust_filter_bytecode;
-
-extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
-
-/*
- * Object used to close the notify socket in a call_rcu(). Since the
- * application might not be found, we need an independant object containing the
- * notify socket fd.
- */
-struct ust_app_notify_sock_obj {
-       int fd;
-       struct rcu_head head;
-};
-
-struct ust_app_ht_key {
-       const char *name;
-       const struct lttng_bytecode *filter;
-       enum lttng_ust_abi_loglevel_type loglevel_type;
-       const struct lttng_event_exclusion *exclusion;
-};
-
-/*
- * Application registration data structure.
- */
-struct ust_register_msg {
-       enum lttng_ust_ctl_socket_type type;
-       uint32_t major;
-       uint32_t minor;
-       uint32_t abi_major;
-       uint32_t abi_minor;
-       pid_t pid;
-       pid_t ppid;
-       uid_t uid;
-       gid_t gid;
-       uint32_t bits_per_long;
-       uint32_t uint8_t_alignment;
-       uint32_t uint16_t_alignment;
-       uint32_t uint32_t_alignment;
-       uint32_t uint64_t_alignment;
-       uint32_t long_alignment;
-       int byte_order;         /* BIG_ENDIAN or LITTLE_ENDIAN */
-       char name[LTTNG_UST_ABI_PROCNAME_LEN];
-};
-
-/*
- * Global applications HT used by the session daemon. This table is indexed by
- * PID using the pid_n node and pid value of an ust_app.
- */
-extern struct lttng_ht *ust_app_ht;
-
-/*
- * Global applications HT used by the session daemon. This table is indexed by
- * socket using the sock_n node and sock value of an ust_app.
- *
- * The 'sock' in question here is the 'command' socket.
- */
-extern struct lttng_ht *ust_app_ht_by_sock;
-
-/*
- * Global applications HT used by the session daemon. This table is indexed by
- * socket using the notify_sock_n node and notify_sock value of an ust_app.
- */
-extern struct lttng_ht *ust_app_ht_by_notify_sock;
-
-/* Stream list containing ust_app_stream. */
-struct ust_app_stream_list {
-       unsigned int count;
-       struct cds_list_head head;
-};
-
-struct ust_app_ctx {
-       int handle;
-       struct lttng_ust_context_attr ctx;
-       struct lttng_ust_abi_object_data *obj;
-       struct lttng_ht_node_ulong node;
-       struct cds_list_head list;
-};
-
-struct ust_app_event {
-       int enabled;
-       int handle;
-       struct lttng_ust_abi_object_data *obj;
-       struct lttng_ust_abi_event attr;
-       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
-       struct lttng_ht_node_str node;
-       struct lttng_bytecode *filter;
-       struct lttng_event_exclusion *exclusion;
-};
-
-struct ust_app_event_notifier_rule {
-       int enabled;
-       uint64_t error_counter_index;
-       int handle;
-       struct lttng_ust_abi_object_data *obj;
-       /* Holds a strong reference. */
-       struct lttng_trigger *trigger;
-       /* Unique ID returned by the tracer to identify this event notifier. */
-       uint64_t token;
-       struct lttng_ht_node_u64 node;
-       /* The trigger object owns the filter. */
-       const struct lttng_bytecode *filter;
-       /* Owned by this. */
-       struct lttng_event_exclusion *exclusion;
-       /* For delayed reclaim. */
-       struct rcu_head rcu_head;
-};
-
-struct ust_app_stream {
-       int handle;
-       char pathname[PATH_MAX];
-       /* Format is %s_%d respectively channel name and CPU number. */
-       char name[DEFAULT_STREAM_NAME_LEN];
-       struct lttng_ust_abi_object_data *obj;
-       /* Using a list of streams to keep order. */
-       struct cds_list_head list;
-};
-
-struct ust_app_channel {
-       int enabled;
-       int handle;
-       /* Channel and streams were sent to the UST tracer. */
-       int is_sent;
-       /*
-        * Unique key used to identify the channel on the consumer side.
-        * 0 is a reserved 'invalid' value used to indicate that the consumer
-        * does not know about this channel (i.e. an error occurred).
-        */
-       uint64_t key;
-       /* Id of the tracing channel set on creation. */
-       uint64_t tracing_channel_id;
-       /* Number of stream that this channel is expected to receive. */
-       unsigned int expected_stream_count;
-       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
-       struct lttng_ust_abi_object_data *obj;
-       struct lttng_ust_ctl_consumer_channel_attr attr;
-       struct ust_app_stream_list streams;
-       /* Session pointer that owns this object. */
-       struct ust_app_session *session;
-       /*
-        * Contexts are kept in a hash table for fast lookup and in an ordered list
-        * so we are able to enable them on the tracer side in the same order the
-        * user added them.
-        */
-       struct lttng_ht *ctx;
-       struct cds_list_head ctx_list;
-
-       struct lttng_ht *events;
-       uint64_t tracefile_size;
-       uint64_t tracefile_count;
-       uint64_t monitor_timer_interval;
-       /*
-        * Node indexed by channel name in the channels' hash table of a session.
-        */
-       struct lttng_ht_node_str node;
-       /*
-        * Node indexed by UST channel object descriptor (handle). Stored in the
-        * ust_objd hash table in the ust_app object.
-        */
-       struct lttng_ht_node_ulong ust_objd_node;
-       /* For delayed reclaim */
-       struct rcu_head rcu_head;
-};
-
-struct ust_app_session {
-       /*
-        * Lock protecting this session's ust app interaction. Held
-        * across command send/recv to/from app. Never nests within the
-        * session registry lock.
-        */
-       pthread_mutex_t lock;
-
-       int enabled;
-       /* started: has the session been in started state at any time ? */
-       int started;  /* allows detection of start vs restart. */
-       int handle;   /* used has unique identifier for app session */
-
-       bool deleted;   /* Session deleted flag. Check with lock held. */
-
-       /*
-        * Tracing session ID. Multiple ust app session can have the same tracing
-        * session id making this value NOT unique to the object.
-        */
-       uint64_t tracing_id;
-       uint64_t id;    /* Unique session identifier */
-       struct lttng_ht *channels; /* Registered channels */
-       struct lttng_ht_node_u64 node;
-       /*
-        * Node indexed by UST session object descriptor (handle). Stored in the
-        * ust_sessions_objd hash table in the ust_app object.
-        */
-       struct lttng_ht_node_ulong ust_objd_node;
-       /* Starts with 'ust'; no leading slash. */
-       char path[PATH_MAX];
-       /* UID/GID of the application owning the session */
-       struct lttng_credentials real_credentials;
-       /* Effective UID and GID. Same as the tracing session. */
-       struct lttng_credentials effective_credentials;
-       struct cds_list_head teardown_node;
-       /*
-        * Once at least *one* session is created onto the application, the
-        * corresponding consumer is set so we can use it on unregistration.
-        */
-       struct consumer_output *consumer;
-       enum lttng_buffer_type buffer_type;
-       /* ABI of the session. Same value as the application. */
-       uint32_t bits_per_long;
-       /* For delayed reclaim */
-       struct rcu_head rcu_head;
-       /* If the channel's streams have to be outputed or not. */
-       unsigned int output_traces;
-       unsigned int live_timer_interval;       /* usec */
-
-       /* Metadata channel attributes. */
-       struct lttng_ust_ctl_consumer_channel_attr metadata_attr;
-
-       char root_shm_path[PATH_MAX];
-       char shm_path[PATH_MAX];
-};
-
-/*
- * Registered traceable applications. Libust registers to the session daemon
- * and a linked list is kept of all running traceable app.
- */
-struct ust_app {
-       int sock;
-       pthread_mutex_t sock_lock;      /* Protects sock protocol. */
-
-       int notify_sock;
-       pid_t pid;
-       pid_t ppid;
-       uid_t uid;           /* User ID that owns the apps */
-       gid_t gid;           /* Group ID that owns the apps */
-
-       /* App ABI */
-       uint32_t bits_per_long;
-       uint32_t uint8_t_alignment;
-       uint32_t uint16_t_alignment;
-       uint32_t uint32_t_alignment;
-       uint32_t uint64_t_alignment;
-       uint32_t long_alignment;
-       int byte_order;         /* BIG_ENDIAN or LITTLE_ENDIAN */
-
-       int compatible; /* If the lttng-ust tracer version does not match the
-                                          supported version of the session daemon, this flag is
-                                          set to 0 (NOT compatible) else 1. */
-       struct lttng_ust_abi_tracer_version version;
-       uint32_t v_major;    /* Version major number */
-       uint32_t v_minor;    /* Version minor number */
-       /* Extra for the NULL byte. */
-       char name[UST_APP_PROCNAME_LEN + 1];
-       /* Type of buffer this application uses. */
-       enum lttng_buffer_type buffer_type;
-       struct lttng_ht *sessions;
-       struct lttng_ht_node_ulong pid_n;
-       struct lttng_ht_node_ulong sock_n;
-       struct lttng_ht_node_ulong notify_sock_n;
-       /*
-        * This is a list of ust app session that, once the app is going into
-        * teardown mode, in the RCU call, each node in this list is removed and
-        * deleted.
-        *
-        * Element of the list are added when an application unregisters after each
-        * ht_del of ust_app_session associated to this app. This list is NOT used
-        * when a session is destroyed.
-        */
-       struct cds_list_head teardown_head;
-       /*
-        * Hash table containing ust_app_channel indexed by channel objd.
-        */
-       struct lttng_ht *ust_objd;
-       /*
-        * Hash table containing ust_app_session indexed by objd.
-        */
-       struct lttng_ht *ust_sessions_objd;
-
-       /*
-        * If this application is of the agent domain and this is non negative then
-        * a lookup MUST be done to acquire a read side reference to the
-        * corresponding agent app object. If the lookup fails, this should be set
-        * to a negative value indicating that the agent application is gone.
-        */
-       int agent_app_sock;
-       /*
-        * Time at which the app is registred.
-        * Used for path creation
-        */
-       time_t registration_time;
-       /*
-        * Event notifier
-        */
-       struct {
-               /*
-                * Handle to the lttng_ust object representing the event
-                * notifier group.
-                */
-               struct lttng_ust_abi_object_data *object;
-               struct lttng_pipe *event_pipe;
-               struct lttng_ust_abi_object_data *counter;
-               struct lttng_ust_abi_object_data **counter_cpu;
-               int nr_counter_cpu;
-       } event_notifier_group;
-       /*
-        * Hashtable indexing the application's event notifier rule's
-        * (ust_app_event_notifier_rule) by their token's value.
-        */
-       struct lttng_ht *token_to_event_notifier_rule_ht;
-};
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-int ust_app_register(struct ust_register_msg *msg, int sock);
-int ust_app_register_done(struct ust_app *app);
-int ust_app_version(struct ust_app *app);
-void ust_app_unregister(int sock);
-int ust_app_start_trace_all(struct ltt_ust_session *usess);
-int ust_app_stop_trace_all(struct ltt_ust_session *usess);
-int ust_app_destroy_trace_all(struct ltt_ust_session *usess);
-int ust_app_list_events(struct lttng_event **events);
-int ust_app_list_event_fields(struct lttng_event_field **fields);
-int ust_app_create_event_glb(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
-int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan);
-int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan);
-int ust_app_enable_event_glb(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
-int ust_app_disable_event_glb(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
-int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx);
-void ust_app_global_update(struct ltt_ust_session *usess, struct ust_app *app);
-void ust_app_global_update_all(struct ltt_ust_session *usess);
-void ust_app_global_update_event_notifier_rules(struct ust_app *app);
-void ust_app_global_update_all_event_notifier_rules(void);
-
-void ust_app_clean_list(void);
-int ust_app_ht_alloc(void);
-struct ust_app *ust_app_find_by_pid(pid_t pid);
-struct ust_app_stream *ust_app_alloc_stream(void);
-int ust_app_recv_registration(int sock, struct ust_register_msg *msg);
-int ust_app_recv_notify(int sock);
-void ust_app_add(struct ust_app *app);
-struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock);
-void ust_app_notify_sock_unregister(int sock);
-ssize_t ust_app_push_metadata(struct ust_registry_session *registry,
-               struct consumer_socket *socket, int send_zero_data);
-void ust_app_destroy(struct ust_app *app);
-enum lttng_error_code ust_app_snapshot_record(
-               const struct ltt_ust_session *usess,
-               const struct consumer_output *output,
-               uint64_t nb_packets_per_stream);
-uint64_t ust_app_get_size_one_more_packet_per_stream(
-               const struct ltt_ust_session *usess, uint64_t cur_nr_packets);
-struct ust_app *ust_app_find_by_sock(int sock);
-int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id,
-               struct cds_list_head *buffer_reg_uid_list,
-               struct consumer_output *consumer, uint64_t uchan_id,
-               int overwrite, uint64_t *discarded, uint64_t *lost);
-int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan,
-               struct consumer_output *consumer,
-               int overwrite, uint64_t *discarded, uint64_t *lost);
-int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess);
-enum lttng_error_code ust_app_rotate_session(struct ltt_session *session);
-enum lttng_error_code ust_app_create_channel_subdirectories(
-               const struct ltt_ust_session *session);
-int ust_app_release_object(struct ust_app *app,
-               struct lttng_ust_abi_object_data *data);
-enum lttng_error_code ust_app_clear_session(struct ltt_session *session);
-enum lttng_error_code ust_app_open_packets(struct ltt_session *session);
-
-int ust_app_setup_event_notifier_group(struct ust_app *app);
-
-static inline
-int ust_app_supported(void)
-{
-       return 1;
-}
-
-bool ust_app_supports_notifiers(const struct ust_app *app);
-bool ust_app_supports_counters(const struct ust_app *app);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline
-int ust_app_destroy_trace_all(
-               struct ltt_ust_session *usess __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_start_trace(
-               struct ltt_ust_session *usess __attribute__((unused)),
-               struct ust_app *app __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_start_trace_all(
-               struct ltt_ust_session *usess __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_stop_trace_all(
-               struct ltt_ust_session *usess __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_list_events(
-               struct lttng_event **events __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int ust_app_list_event_fields(
-               struct lttng_event_field **fields __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int ust_app_register(
-               struct ust_register_msg *msg __attribute__((unused)),
-               int sock __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int ust_app_register_done(struct ust_app *app __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int ust_app_version(struct ust_app *app __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-void ust_app_unregister(int sock __attribute__((unused)))
-{
-}
-
-static inline
-void ust_app_clean_list(void)
-{
-}
-
-static inline
-struct ust_app_list *ust_app_get_list(void)
-{
-       return NULL;
-}
-
-static inline
-struct ust_app *ust_app_get_by_pid(pid_t pid __attribute__((unused)))
-{
-       return NULL;
-}
-
-static inline
-int ust_app_ht_alloc(void)
-{
-       return 0;
-}
-
-static inline
-void ust_app_global_update(
-               struct ltt_ust_session *usess __attribute__((unused)),
-               struct ust_app *app __attribute__((unused)))
-{}
-
-static inline
-void ust_app_global_update_event_notifier_rules(
-               struct ust_app *app __attribute__((unused)))
-{}
-
-static inline
-void ust_app_global_update_all_event_notifier_rules(void)
-{}
-
-static inline
-int ust_app_setup_event_notifier_group(
-               struct ust_app *app __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_disable_channel_glb(
-               struct ltt_ust_session *usess __attribute__((unused)),
-               struct ltt_ust_channel *uchan __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_enable_channel_glb(
-               struct ltt_ust_session *usess __attribute__((unused)),
-               struct ltt_ust_channel *uchan __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_create_event_glb(
-               struct ltt_ust_session *usess __attribute__((unused)),
-               struct ltt_ust_channel *uchan __attribute__((unused)),
-               struct ltt_ust_event *uevent __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_disable_event_glb(
-               struct ltt_ust_session *usess __attribute__((unused)),
-               struct ltt_ust_channel *uchan __attribute__((unused)),
-               struct ltt_ust_event *uevent __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_enable_event_glb(
-               struct ltt_ust_session *usess __attribute__((unused)),
-               struct ltt_ust_channel *uchan __attribute__((unused)),
-               struct ltt_ust_event *uevent __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_add_ctx_channel_glb(
-               struct ltt_ust_session *usess __attribute__((unused)),
-               struct ltt_ust_channel *uchan __attribute__((unused)),
-               struct ltt_ust_context *uctx __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_enable_event_pid(
-               struct ltt_ust_session *usess __attribute__((unused)),
-               struct ltt_ust_channel *uchan __attribute__((unused)),
-               struct ltt_ust_event *uevent __attribute__((unused)),
-               pid_t pid __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_recv_registration(
-               int sock __attribute__((unused)),
-               struct ust_register_msg *msg __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_recv_notify(int sock __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-struct ust_app *ust_app_create(
-               struct ust_register_msg *msg __attribute__((unused)),
-               int sock __attribute__((unused)))
-{
-       return NULL;
-}
-
-static inline
-void ust_app_add(struct ust_app *app __attribute__((unused)))
-{
-}
-
-static inline
-void ust_app_notify_sock_unregister(int sock __attribute__((unused)))
-{
-}
-
-static inline
-ssize_t ust_app_push_metadata(
-               struct ust_registry_session *registry __attribute__((unused)),
-               struct consumer_socket *socket __attribute__((unused)),
-               int send_zero_data __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-void ust_app_destroy(struct ust_app *app __attribute__((unused)))
-{
-       return;
-}
-
-static inline
-enum lttng_error_code ust_app_snapshot_record(
-               struct ltt_ust_session *usess __attribute__((unused)),
-               const struct consumer_output *output __attribute__((unused)),
-               uint64_t max_stream_size __attribute__((unused)))
-{
-       return LTTNG_ERR_UNK;
-}
-
-static inline
-unsigned int ust_app_get_nb_stream(
-               struct ltt_ust_session *usess __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-void ust_app_update_event_notifier_error_count(
-               struct lttng_trigger *lttng_trigger __attribute__((unused)))
-{
-       return;
-}
-
-static inline
-int ust_app_supported(void)
-{
-       return 0;
-}
-
-static inline
-bool ust_app_supports_notifiers(
-               const struct ust_app *app __attribute__((unused)))
-{
-       return false;
-}
-
-static inline
-bool ust_app_supports_counters(
-               const struct ust_app *app __attribute__((unused)))
-{
-       return false;
-}
-
-static inline
-struct ust_app *ust_app_find_by_sock(int sock __attribute__((unused)))
-{
-       return NULL;
-}
-
-static inline
-struct ust_app *ust_app_find_by_pid(pid_t pid __attribute__((unused)))
-{
-       return NULL;
-}
-
-static inline
-uint64_t ust_app_get_size_one_more_packet_per_stream(
-               const struct ltt_ust_session *usess __attribute__((unused)),
-               uint64_t cur_nr_packets __attribute__((unused))) {
-       return 0;
-}
-
-static inline
-int ust_app_uid_get_channel_runtime_stats(
-               uint64_t ust_session_id __attribute__((unused)),
-               struct cds_list_head *buffer_reg_uid_list __attribute__((unused)),
-               struct consumer_output *consumer __attribute__((unused)),
-               int overwrite __attribute__((unused)),
-               uint64_t uchan_id __attribute__((unused)),
-               uint64_t *discarded __attribute__((unused)),
-               uint64_t *lost __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_pid_get_channel_runtime_stats(
-               struct ltt_ust_session *usess __attribute__((unused)),
-               struct ltt_ust_channel *uchan __attribute__((unused)),
-               struct consumer_output *consumer __attribute__((unused)),
-               int overwrite __attribute__((unused)),
-               uint64_t *discarded __attribute__((unused)),
-               uint64_t *lost __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_app_regenerate_statedump_all(
-               struct ltt_ust_session *usess __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-enum lttng_error_code ust_app_rotate_session(
-               struct ltt_session *session __attribute__((unused)))
-{
-       return LTTNG_ERR_UNK;
-}
-
-static inline
-enum lttng_error_code ust_app_create_channel_subdirectories(
-               const struct ltt_ust_session *session __attribute__((unused)))
-{
-       return LTTNG_ERR_UNK;
-}
-
-static inline
-int ust_app_release_object(struct ust_app *app __attribute__((unused)),
-               struct lttng_ust_abi_object_data *data __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-enum lttng_error_code ust_app_clear_session(
-               struct ltt_session *session __attribute__((unused)))
-{
-       return LTTNG_ERR_UNK;
-}
-
-static inline
-enum lttng_error_code ust_app_open_packets(
-               struct ltt_session *session __attribute__((unused)))
-{
-       return LTTNG_ERR_UNK;
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* _LTT_UST_APP_H */
diff --git a/src/bin/lttng-sessiond/ust-app.hpp b/src/bin/lttng-sessiond/ust-app.hpp
new file mode 100644 (file)
index 0000000..88a923e
--- /dev/null
@@ -0,0 +1,765 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_UST_APP_H
+#define _LTT_UST_APP_H
+
+#include <stdint.h>
+
+#include <common/index-allocator.hpp>
+#include <common/uuid.hpp>
+
+#include "trace-ust.hpp"
+#include "ust-registry.hpp"
+#include "session.hpp"
+
+#define UST_APP_EVENT_LIST_SIZE 32
+
+/* Process name (short). */
+#define UST_APP_PROCNAME_LEN   16
+
+struct lttng_bytecode;
+struct lttng_ust_filter_bytecode;
+
+extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
+
+/*
+ * Object used to close the notify socket in a call_rcu(). Since the
+ * application might not be found, we need an independant object containing the
+ * notify socket fd.
+ */
+struct ust_app_notify_sock_obj {
+       int fd;
+       struct rcu_head head;
+};
+
+struct ust_app_ht_key {
+       const char *name;
+       const struct lttng_bytecode *filter;
+       enum lttng_ust_abi_loglevel_type loglevel_type;
+       const struct lttng_event_exclusion *exclusion;
+};
+
+/*
+ * Application registration data structure.
+ */
+struct ust_register_msg {
+       enum lttng_ust_ctl_socket_type type;
+       uint32_t major;
+       uint32_t minor;
+       uint32_t abi_major;
+       uint32_t abi_minor;
+       pid_t pid;
+       pid_t ppid;
+       uid_t uid;
+       gid_t gid;
+       uint32_t bits_per_long;
+       uint32_t uint8_t_alignment;
+       uint32_t uint16_t_alignment;
+       uint32_t uint32_t_alignment;
+       uint32_t uint64_t_alignment;
+       uint32_t long_alignment;
+       int byte_order;         /* BIG_ENDIAN or LITTLE_ENDIAN */
+       char name[LTTNG_UST_ABI_PROCNAME_LEN];
+};
+
+/*
+ * Global applications HT used by the session daemon. This table is indexed by
+ * PID using the pid_n node and pid value of an ust_app.
+ */
+extern struct lttng_ht *ust_app_ht;
+
+/*
+ * Global applications HT used by the session daemon. This table is indexed by
+ * socket using the sock_n node and sock value of an ust_app.
+ *
+ * The 'sock' in question here is the 'command' socket.
+ */
+extern struct lttng_ht *ust_app_ht_by_sock;
+
+/*
+ * Global applications HT used by the session daemon. This table is indexed by
+ * socket using the notify_sock_n node and notify_sock value of an ust_app.
+ */
+extern struct lttng_ht *ust_app_ht_by_notify_sock;
+
+/* Stream list containing ust_app_stream. */
+struct ust_app_stream_list {
+       unsigned int count;
+       struct cds_list_head head;
+};
+
+struct ust_app_ctx {
+       int handle;
+       struct lttng_ust_context_attr ctx;
+       struct lttng_ust_abi_object_data *obj;
+       struct lttng_ht_node_ulong node;
+       struct cds_list_head list;
+};
+
+struct ust_app_event {
+       int enabled;
+       int handle;
+       struct lttng_ust_abi_object_data *obj;
+       struct lttng_ust_abi_event attr;
+       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+       struct lttng_ht_node_str node;
+       struct lttng_bytecode *filter;
+       struct lttng_event_exclusion *exclusion;
+};
+
+struct ust_app_event_notifier_rule {
+       int enabled;
+       uint64_t error_counter_index;
+       int handle;
+       struct lttng_ust_abi_object_data *obj;
+       /* Holds a strong reference. */
+       struct lttng_trigger *trigger;
+       /* Unique ID returned by the tracer to identify this event notifier. */
+       uint64_t token;
+       struct lttng_ht_node_u64 node;
+       /* The trigger object owns the filter. */
+       const struct lttng_bytecode *filter;
+       /* Owned by this. */
+       struct lttng_event_exclusion *exclusion;
+       /* For delayed reclaim. */
+       struct rcu_head rcu_head;
+};
+
+struct ust_app_stream {
+       int handle;
+       char pathname[PATH_MAX];
+       /* Format is %s_%d respectively channel name and CPU number. */
+       char name[DEFAULT_STREAM_NAME_LEN];
+       struct lttng_ust_abi_object_data *obj;
+       /* Using a list of streams to keep order. */
+       struct cds_list_head list;
+};
+
+struct ust_app_channel {
+       int enabled;
+       int handle;
+       /* Channel and streams were sent to the UST tracer. */
+       int is_sent;
+       /*
+        * Unique key used to identify the channel on the consumer side.
+        * 0 is a reserved 'invalid' value used to indicate that the consumer
+        * does not know about this channel (i.e. an error occurred).
+        */
+       uint64_t key;
+       /* Id of the tracing channel set on creation. */
+       uint64_t tracing_channel_id;
+       /* Number of stream that this channel is expected to receive. */
+       unsigned int expected_stream_count;
+       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+       struct lttng_ust_abi_object_data *obj;
+       struct lttng_ust_ctl_consumer_channel_attr attr;
+       struct ust_app_stream_list streams;
+       /* Session pointer that owns this object. */
+       struct ust_app_session *session;
+       /*
+        * Contexts are kept in a hash table for fast lookup and in an ordered list
+        * so we are able to enable them on the tracer side in the same order the
+        * user added them.
+        */
+       struct lttng_ht *ctx;
+       struct cds_list_head ctx_list;
+
+       struct lttng_ht *events;
+       uint64_t tracefile_size;
+       uint64_t tracefile_count;
+       uint64_t monitor_timer_interval;
+       /*
+        * Node indexed by channel name in the channels' hash table of a session.
+        */
+       struct lttng_ht_node_str node;
+       /*
+        * Node indexed by UST channel object descriptor (handle). Stored in the
+        * ust_objd hash table in the ust_app object.
+        */
+       struct lttng_ht_node_ulong ust_objd_node;
+       /* For delayed reclaim */
+       struct rcu_head rcu_head;
+};
+
+struct ust_app_session {
+       /*
+        * Lock protecting this session's ust app interaction. Held
+        * across command send/recv to/from app. Never nests within the
+        * session registry lock.
+        */
+       pthread_mutex_t lock;
+
+       int enabled;
+       /* started: has the session been in started state at any time ? */
+       int started;  /* allows detection of start vs restart. */
+       int handle;   /* used has unique identifier for app session */
+
+       bool deleted;   /* Session deleted flag. Check with lock held. */
+
+       /*
+        * Tracing session ID. Multiple ust app session can have the same tracing
+        * session id making this value NOT unique to the object.
+        */
+       uint64_t tracing_id;
+       uint64_t id;    /* Unique session identifier */
+       struct lttng_ht *channels; /* Registered channels */
+       struct lttng_ht_node_u64 node;
+       /*
+        * Node indexed by UST session object descriptor (handle). Stored in the
+        * ust_sessions_objd hash table in the ust_app object.
+        */
+       struct lttng_ht_node_ulong ust_objd_node;
+       /* Starts with 'ust'; no leading slash. */
+       char path[PATH_MAX];
+       /* UID/GID of the application owning the session */
+       struct lttng_credentials real_credentials;
+       /* Effective UID and GID. Same as the tracing session. */
+       struct lttng_credentials effective_credentials;
+       struct cds_list_head teardown_node;
+       /*
+        * Once at least *one* session is created onto the application, the
+        * corresponding consumer is set so we can use it on unregistration.
+        */
+       struct consumer_output *consumer;
+       enum lttng_buffer_type buffer_type;
+       /* ABI of the session. Same value as the application. */
+       uint32_t bits_per_long;
+       /* For delayed reclaim */
+       struct rcu_head rcu_head;
+       /* If the channel's streams have to be outputed or not. */
+       unsigned int output_traces;
+       unsigned int live_timer_interval;       /* usec */
+
+       /* Metadata channel attributes. */
+       struct lttng_ust_ctl_consumer_channel_attr metadata_attr;
+
+       char root_shm_path[PATH_MAX];
+       char shm_path[PATH_MAX];
+};
+
+/*
+ * Registered traceable applications. Libust registers to the session daemon
+ * and a linked list is kept of all running traceable app.
+ */
+struct ust_app {
+       int sock;
+       pthread_mutex_t sock_lock;      /* Protects sock protocol. */
+
+       int notify_sock;
+       pid_t pid;
+       pid_t ppid;
+       uid_t uid;           /* User ID that owns the apps */
+       gid_t gid;           /* Group ID that owns the apps */
+
+       /* App ABI */
+       uint32_t bits_per_long;
+       uint32_t uint8_t_alignment;
+       uint32_t uint16_t_alignment;
+       uint32_t uint32_t_alignment;
+       uint32_t uint64_t_alignment;
+       uint32_t long_alignment;
+       int byte_order;         /* BIG_ENDIAN or LITTLE_ENDIAN */
+
+       int compatible; /* If the lttng-ust tracer version does not match the
+                                          supported version of the session daemon, this flag is
+                                          set to 0 (NOT compatible) else 1. */
+       struct lttng_ust_abi_tracer_version version;
+       uint32_t v_major;    /* Version major number */
+       uint32_t v_minor;    /* Version minor number */
+       /* Extra for the NULL byte. */
+       char name[UST_APP_PROCNAME_LEN + 1];
+       /* Type of buffer this application uses. */
+       enum lttng_buffer_type buffer_type;
+       struct lttng_ht *sessions;
+       struct lttng_ht_node_ulong pid_n;
+       struct lttng_ht_node_ulong sock_n;
+       struct lttng_ht_node_ulong notify_sock_n;
+       /*
+        * This is a list of ust app session that, once the app is going into
+        * teardown mode, in the RCU call, each node in this list is removed and
+        * deleted.
+        *
+        * Element of the list are added when an application unregisters after each
+        * ht_del of ust_app_session associated to this app. This list is NOT used
+        * when a session is destroyed.
+        */
+       struct cds_list_head teardown_head;
+       /*
+        * Hash table containing ust_app_channel indexed by channel objd.
+        */
+       struct lttng_ht *ust_objd;
+       /*
+        * Hash table containing ust_app_session indexed by objd.
+        */
+       struct lttng_ht *ust_sessions_objd;
+
+       /*
+        * If this application is of the agent domain and this is non negative then
+        * a lookup MUST be done to acquire a read side reference to the
+        * corresponding agent app object. If the lookup fails, this should be set
+        * to a negative value indicating that the agent application is gone.
+        */
+       int agent_app_sock;
+       /*
+        * Time at which the app is registred.
+        * Used for path creation
+        */
+       time_t registration_time;
+       /*
+        * Event notifier
+        */
+       struct {
+               /*
+                * Handle to the lttng_ust object representing the event
+                * notifier group.
+                */
+               struct lttng_ust_abi_object_data *object;
+               struct lttng_pipe *event_pipe;
+               struct lttng_ust_abi_object_data *counter;
+               struct lttng_ust_abi_object_data **counter_cpu;
+               int nr_counter_cpu;
+       } event_notifier_group;
+       /*
+        * Hashtable indexing the application's event notifier rule's
+        * (ust_app_event_notifier_rule) by their token's value.
+        */
+       struct lttng_ht *token_to_event_notifier_rule_ht;
+};
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+int ust_app_register(struct ust_register_msg *msg, int sock);
+int ust_app_register_done(struct ust_app *app);
+int ust_app_version(struct ust_app *app);
+void ust_app_unregister(int sock);
+int ust_app_start_trace_all(struct ltt_ust_session *usess);
+int ust_app_stop_trace_all(struct ltt_ust_session *usess);
+int ust_app_destroy_trace_all(struct ltt_ust_session *usess);
+int ust_app_list_events(struct lttng_event **events);
+int ust_app_list_event_fields(struct lttng_event_field **fields);
+int ust_app_create_event_glb(struct ltt_ust_session *usess,
+               struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
+int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
+               struct ltt_ust_channel *uchan);
+int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
+               struct ltt_ust_channel *uchan);
+int ust_app_enable_event_glb(struct ltt_ust_session *usess,
+               struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
+int ust_app_disable_event_glb(struct ltt_ust_session *usess,
+               struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
+int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess,
+               struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx);
+void ust_app_global_update(struct ltt_ust_session *usess, struct ust_app *app);
+void ust_app_global_update_all(struct ltt_ust_session *usess);
+void ust_app_global_update_event_notifier_rules(struct ust_app *app);
+void ust_app_global_update_all_event_notifier_rules(void);
+
+void ust_app_clean_list(void);
+int ust_app_ht_alloc(void);
+struct ust_app *ust_app_find_by_pid(pid_t pid);
+struct ust_app_stream *ust_app_alloc_stream(void);
+int ust_app_recv_registration(int sock, struct ust_register_msg *msg);
+int ust_app_recv_notify(int sock);
+void ust_app_add(struct ust_app *app);
+struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock);
+void ust_app_notify_sock_unregister(int sock);
+ssize_t ust_app_push_metadata(struct ust_registry_session *registry,
+               struct consumer_socket *socket, int send_zero_data);
+void ust_app_destroy(struct ust_app *app);
+enum lttng_error_code ust_app_snapshot_record(
+               const struct ltt_ust_session *usess,
+               const struct consumer_output *output,
+               uint64_t nb_packets_per_stream);
+uint64_t ust_app_get_size_one_more_packet_per_stream(
+               const struct ltt_ust_session *usess, uint64_t cur_nr_packets);
+struct ust_app *ust_app_find_by_sock(int sock);
+int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id,
+               struct cds_list_head *buffer_reg_uid_list,
+               struct consumer_output *consumer, uint64_t uchan_id,
+               int overwrite, uint64_t *discarded, uint64_t *lost);
+int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess,
+               struct ltt_ust_channel *uchan,
+               struct consumer_output *consumer,
+               int overwrite, uint64_t *discarded, uint64_t *lost);
+int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess);
+enum lttng_error_code ust_app_rotate_session(struct ltt_session *session);
+enum lttng_error_code ust_app_create_channel_subdirectories(
+               const struct ltt_ust_session *session);
+int ust_app_release_object(struct ust_app *app,
+               struct lttng_ust_abi_object_data *data);
+enum lttng_error_code ust_app_clear_session(struct ltt_session *session);
+enum lttng_error_code ust_app_open_packets(struct ltt_session *session);
+
+int ust_app_setup_event_notifier_group(struct ust_app *app);
+
+static inline
+int ust_app_supported(void)
+{
+       return 1;
+}
+
+bool ust_app_supports_notifiers(const struct ust_app *app);
+bool ust_app_supports_counters(const struct ust_app *app);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+int ust_app_destroy_trace_all(
+               struct ltt_ust_session *usess __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_start_trace(
+               struct ltt_ust_session *usess __attribute__((unused)),
+               struct ust_app *app __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_start_trace_all(
+               struct ltt_ust_session *usess __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_stop_trace_all(
+               struct ltt_ust_session *usess __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_list_events(
+               struct lttng_event **events __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int ust_app_list_event_fields(
+               struct lttng_event_field **fields __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int ust_app_register(
+               struct ust_register_msg *msg __attribute__((unused)),
+               int sock __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int ust_app_register_done(struct ust_app *app __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int ust_app_version(struct ust_app *app __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+void ust_app_unregister(int sock __attribute__((unused)))
+{
+}
+
+static inline
+void ust_app_clean_list(void)
+{
+}
+
+static inline
+struct ust_app_list *ust_app_get_list(void)
+{
+       return NULL;
+}
+
+static inline
+struct ust_app *ust_app_get_by_pid(pid_t pid __attribute__((unused)))
+{
+       return NULL;
+}
+
+static inline
+int ust_app_ht_alloc(void)
+{
+       return 0;
+}
+
+static inline
+void ust_app_global_update(
+               struct ltt_ust_session *usess __attribute__((unused)),
+               struct ust_app *app __attribute__((unused)))
+{}
+
+static inline
+void ust_app_global_update_event_notifier_rules(
+               struct ust_app *app __attribute__((unused)))
+{}
+
+static inline
+void ust_app_global_update_all_event_notifier_rules(void)
+{}
+
+static inline
+int ust_app_setup_event_notifier_group(
+               struct ust_app *app __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_disable_channel_glb(
+               struct ltt_ust_session *usess __attribute__((unused)),
+               struct ltt_ust_channel *uchan __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_enable_channel_glb(
+               struct ltt_ust_session *usess __attribute__((unused)),
+               struct ltt_ust_channel *uchan __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_create_event_glb(
+               struct ltt_ust_session *usess __attribute__((unused)),
+               struct ltt_ust_channel *uchan __attribute__((unused)),
+               struct ltt_ust_event *uevent __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_disable_event_glb(
+               struct ltt_ust_session *usess __attribute__((unused)),
+               struct ltt_ust_channel *uchan __attribute__((unused)),
+               struct ltt_ust_event *uevent __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_enable_event_glb(
+               struct ltt_ust_session *usess __attribute__((unused)),
+               struct ltt_ust_channel *uchan __attribute__((unused)),
+               struct ltt_ust_event *uevent __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_add_ctx_channel_glb(
+               struct ltt_ust_session *usess __attribute__((unused)),
+               struct ltt_ust_channel *uchan __attribute__((unused)),
+               struct ltt_ust_context *uctx __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_enable_event_pid(
+               struct ltt_ust_session *usess __attribute__((unused)),
+               struct ltt_ust_channel *uchan __attribute__((unused)),
+               struct ltt_ust_event *uevent __attribute__((unused)),
+               pid_t pid __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_recv_registration(
+               int sock __attribute__((unused)),
+               struct ust_register_msg *msg __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_recv_notify(int sock __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+struct ust_app *ust_app_create(
+               struct ust_register_msg *msg __attribute__((unused)),
+               int sock __attribute__((unused)))
+{
+       return NULL;
+}
+
+static inline
+void ust_app_add(struct ust_app *app __attribute__((unused)))
+{
+}
+
+static inline
+void ust_app_notify_sock_unregister(int sock __attribute__((unused)))
+{
+}
+
+static inline
+ssize_t ust_app_push_metadata(
+               struct ust_registry_session *registry __attribute__((unused)),
+               struct consumer_socket *socket __attribute__((unused)),
+               int send_zero_data __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+void ust_app_destroy(struct ust_app *app __attribute__((unused)))
+{
+       return;
+}
+
+static inline
+enum lttng_error_code ust_app_snapshot_record(
+               struct ltt_ust_session *usess __attribute__((unused)),
+               const struct consumer_output *output __attribute__((unused)),
+               uint64_t max_stream_size __attribute__((unused)))
+{
+       return LTTNG_ERR_UNK;
+}
+
+static inline
+unsigned int ust_app_get_nb_stream(
+               struct ltt_ust_session *usess __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+void ust_app_update_event_notifier_error_count(
+               struct lttng_trigger *lttng_trigger __attribute__((unused)))
+{
+       return;
+}
+
+static inline
+int ust_app_supported(void)
+{
+       return 0;
+}
+
+static inline
+bool ust_app_supports_notifiers(
+               const struct ust_app *app __attribute__((unused)))
+{
+       return false;
+}
+
+static inline
+bool ust_app_supports_counters(
+               const struct ust_app *app __attribute__((unused)))
+{
+       return false;
+}
+
+static inline
+struct ust_app *ust_app_find_by_sock(int sock __attribute__((unused)))
+{
+       return NULL;
+}
+
+static inline
+struct ust_app *ust_app_find_by_pid(pid_t pid __attribute__((unused)))
+{
+       return NULL;
+}
+
+static inline
+uint64_t ust_app_get_size_one_more_packet_per_stream(
+               const struct ltt_ust_session *usess __attribute__((unused)),
+               uint64_t cur_nr_packets __attribute__((unused))) {
+       return 0;
+}
+
+static inline
+int ust_app_uid_get_channel_runtime_stats(
+               uint64_t ust_session_id __attribute__((unused)),
+               struct cds_list_head *buffer_reg_uid_list __attribute__((unused)),
+               struct consumer_output *consumer __attribute__((unused)),
+               int overwrite __attribute__((unused)),
+               uint64_t uchan_id __attribute__((unused)),
+               uint64_t *discarded __attribute__((unused)),
+               uint64_t *lost __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_pid_get_channel_runtime_stats(
+               struct ltt_ust_session *usess __attribute__((unused)),
+               struct ltt_ust_channel *uchan __attribute__((unused)),
+               struct consumer_output *consumer __attribute__((unused)),
+               int overwrite __attribute__((unused)),
+               uint64_t *discarded __attribute__((unused)),
+               uint64_t *lost __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_app_regenerate_statedump_all(
+               struct ltt_ust_session *usess __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+enum lttng_error_code ust_app_rotate_session(
+               struct ltt_session *session __attribute__((unused)))
+{
+       return LTTNG_ERR_UNK;
+}
+
+static inline
+enum lttng_error_code ust_app_create_channel_subdirectories(
+               const struct ltt_ust_session *session __attribute__((unused)))
+{
+       return LTTNG_ERR_UNK;
+}
+
+static inline
+int ust_app_release_object(struct ust_app *app __attribute__((unused)),
+               struct lttng_ust_abi_object_data *data __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+enum lttng_error_code ust_app_clear_session(
+               struct ltt_session *session __attribute__((unused)))
+{
+       return LTTNG_ERR_UNK;
+}
+
+static inline
+enum lttng_error_code ust_app_open_packets(
+               struct ltt_session *session __attribute__((unused)))
+{
+       return LTTNG_ERR_UNK;
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* _LTT_UST_APP_H */
diff --git a/src/bin/lttng-sessiond/ust-clock.h b/src/bin/lttng-sessiond/ust-clock.h
deleted file mode 100644 (file)
index 91cbbe6..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2010 Pierre-Marc Fournier
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _UST_CLOCK_H
-#define _UST_CLOCK_H
-
-#include <common/compat/time.h>
-#include <sys/time.h>
-#include <stdint.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <urcu/system.h>
-#include <urcu/arch.h>
-#include <lttng/ust-clock.h>
-
-#include <common/uuid.h>
-
-static __inline__
-uint64_t trace_clock_read64(void)
-{
-       uint64_t clock_value = 0;
-       lttng_ust_clock_read64_function read64_cb;
-
-       if (lttng_ust_trace_clock_get_read64_cb(&read64_cb)) {
-               goto end;
-       }
-
-       clock_value = read64_cb();
-end:
-       return clock_value;
-}
-
-static __inline__
-uint64_t trace_clock_freq(void)
-{
-       uint64_t frequency = 0;
-       lttng_ust_clock_freq_function get_freq_cb;
-
-       if (lttng_ust_trace_clock_get_freq_cb(&get_freq_cb)) {
-               goto end;
-       }
-
-       frequency = get_freq_cb();
-end:
-       return frequency;
-}
-
-static __inline__
-int trace_clock_uuid(char *uuid)
-{
-       int ret;
-       lttng_ust_clock_uuid_function get_uuid_cb;
-
-       if (lttng_ust_trace_clock_get_uuid_cb(&get_uuid_cb)) {
-               ret = -EINVAL;
-               goto end;
-       }
-
-       ret = get_uuid_cb(uuid);
-end:
-       return ret;
-
-}
-
-static __inline__
-const char *trace_clock_name(void)
-{
-       const char *name;
-       lttng_ust_clock_name_function get_name_cb;
-
-       if (lttng_ust_trace_clock_get_name_cb(&get_name_cb)) {
-               name = NULL;
-               goto end;
-       }
-
-       name = get_name_cb();
-end:
-       return name;
-}
-
-static __inline__
-const char *trace_clock_description(void)
-{
-       const char *description;
-       lttng_ust_clock_description_function get_description_cb;
-
-       if (lttng_ust_trace_clock_get_description_cb(&get_description_cb)) {
-               description = NULL;
-               goto end;
-       }
-
-       description = get_description_cb();
-end:
-       return description;
-}
-
-#endif /* _UST_CLOCK_H */
diff --git a/src/bin/lttng-sessiond/ust-clock.hpp b/src/bin/lttng-sessiond/ust-clock.hpp
new file mode 100644 (file)
index 0000000..3807f40
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _UST_CLOCK_H
+#define _UST_CLOCK_H
+
+#include <common/compat/time.hpp>
+#include <sys/time.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <urcu/system.h>
+#include <urcu/arch.h>
+#include <lttng/ust-clock.h>
+
+#include <common/uuid.hpp>
+
+static __inline__
+uint64_t trace_clock_read64(void)
+{
+       uint64_t clock_value = 0;
+       lttng_ust_clock_read64_function read64_cb;
+
+       if (lttng_ust_trace_clock_get_read64_cb(&read64_cb)) {
+               goto end;
+       }
+
+       clock_value = read64_cb();
+end:
+       return clock_value;
+}
+
+static __inline__
+uint64_t trace_clock_freq(void)
+{
+       uint64_t frequency = 0;
+       lttng_ust_clock_freq_function get_freq_cb;
+
+       if (lttng_ust_trace_clock_get_freq_cb(&get_freq_cb)) {
+               goto end;
+       }
+
+       frequency = get_freq_cb();
+end:
+       return frequency;
+}
+
+static __inline__
+int trace_clock_uuid(char *uuid)
+{
+       int ret;
+       lttng_ust_clock_uuid_function get_uuid_cb;
+
+       if (lttng_ust_trace_clock_get_uuid_cb(&get_uuid_cb)) {
+               ret = -EINVAL;
+               goto end;
+       }
+
+       ret = get_uuid_cb(uuid);
+end:
+       return ret;
+
+}
+
+static __inline__
+const char *trace_clock_name(void)
+{
+       const char *name;
+       lttng_ust_clock_name_function get_name_cb;
+
+       if (lttng_ust_trace_clock_get_name_cb(&get_name_cb)) {
+               name = NULL;
+               goto end;
+       }
+
+       name = get_name_cb();
+end:
+       return name;
+}
+
+static __inline__
+const char *trace_clock_description(void)
+{
+       const char *description;
+       lttng_ust_clock_description_function get_description_cb;
+
+       if (lttng_ust_trace_clock_get_description_cb(&get_description_cb)) {
+               description = NULL;
+               goto end;
+       }
+
+       description = get_description_cb();
+end:
+       return description;
+}
+
+#endif /* _UST_CLOCK_H */
index df9bb013ac3bf175b0651ffbc891af0897928d9a..86b96a9bd5e9505002e0413da7970dd9d30520ee 100644 (file)
 #include <unistd.h>
 #include <inttypes.h>
 
-#include <common/compat/errno.h>
-#include <common/common.h>
-#include <common/consumer/consumer.h>
-#include <common/defaults.h>
-
-#include "consumer.h"
-#include "health-sessiond.h"
-#include "ust-consumer.h"
-#include "lttng-ust-error.h"
-#include "buffer-registry.h"
-#include "session.h"
-#include "lttng-sessiond.h"
+#include <common/compat/errno.hpp>
+#include <common/common.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/defaults.hpp>
+
+#include "consumer.hpp"
+#include "health-sessiond.hpp"
+#include "ust-consumer.hpp"
+#include "lttng-ust-error.hpp"
+#include "buffer-registry.hpp"
+#include "session.hpp"
+#include "lttng-sessiond.hpp"
 
 /*
  * Send a single channel to the consumer using command ASK_CHANNEL_CREATION.
diff --git a/src/bin/lttng-sessiond/ust-consumer.h b/src/bin/lttng-sessiond/ust-consumer.h
deleted file mode 100644 (file)
index 63d8eb2..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _UST_CONSUMER_H
-#define _UST_CONSUMER_H
-
-#include "consumer.h"
-#include "ust-app.h"
-#include <stdint.h>
-#include <common/trace-chunk.h>
-
-int ust_consumer_ask_channel(struct ust_app_session *ua_sess,
-               struct ust_app_channel *ua_chan,
-               struct consumer_output *consumer,
-               struct consumer_socket *socket,
-               struct ust_registry_session *registry,
-               struct lttng_trace_chunk *trace_chunk);
-
-int ust_consumer_get_channel(struct consumer_socket *socket,
-               struct ust_app_channel *ua_chan);
-
-int ust_consumer_destroy_channel(struct consumer_socket *socket,
-               struct ust_app_channel *ua_chan);
-
-int ust_consumer_send_stream_to_ust(struct ust_app *app,
-               struct ust_app_channel *channel, struct ust_app_stream *stream);
-
-int ust_consumer_send_channel_to_ust(struct ust_app *app,
-               struct ust_app_session *ua_sess, struct ust_app_channel *channel);
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-int ust_consumer_metadata_request(struct consumer_socket *sock);
-#else
-static inline
-int ust_consumer_metadata_request(
-               struct consumer_socket *sock __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* _UST_CONSUMER_H */
diff --git a/src/bin/lttng-sessiond/ust-consumer.hpp b/src/bin/lttng-sessiond/ust-consumer.hpp
new file mode 100644 (file)
index 0000000..8409137
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _UST_CONSUMER_H
+#define _UST_CONSUMER_H
+
+#include "consumer.hpp"
+#include "ust-app.hpp"
+#include <stdint.h>
+#include <common/trace-chunk.hpp>
+
+int ust_consumer_ask_channel(struct ust_app_session *ua_sess,
+               struct ust_app_channel *ua_chan,
+               struct consumer_output *consumer,
+               struct consumer_socket *socket,
+               struct ust_registry_session *registry,
+               struct lttng_trace_chunk *trace_chunk);
+
+int ust_consumer_get_channel(struct consumer_socket *socket,
+               struct ust_app_channel *ua_chan);
+
+int ust_consumer_destroy_channel(struct consumer_socket *socket,
+               struct ust_app_channel *ua_chan);
+
+int ust_consumer_send_stream_to_ust(struct ust_app *app,
+               struct ust_app_channel *channel, struct ust_app_stream *stream);
+
+int ust_consumer_send_channel_to_ust(struct ust_app *app,
+               struct ust_app_session *ua_sess, struct ust_app_channel *channel);
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+int ust_consumer_metadata_request(struct consumer_socket *sock);
+#else
+static inline
+int ust_consumer_metadata_request(
+               struct consumer_socket *sock __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* _UST_CONSUMER_H */
diff --git a/src/bin/lttng-sessiond/ust-ctl-internal.h b/src/bin/lttng-sessiond/ust-ctl-internal.h
deleted file mode 100644 (file)
index 6bd21d8..0000000
+++ /dev/null
@@ -1,658 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_CTL_INTERNAL_H
-#define LTTNG_UST_CTL_INTERNAL_H
-
-#include <sys/types.h>
-#include <limits.h>
-
-#include "lttng-ust-abi.h"
-
-#ifndef LTTNG_UST_UUID_LEN
-#define LTTNG_UST_UUID_LEN     16
-#endif
-
-/* Default unix socket path */
-#define LTTNG_UST_SOCK_FILENAME                                        \
-       "lttng-ust-sock-"                                       \
-       __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE)
-
-/*
- * Shared memory files path are automatically related to shm root, e.g.
- * /dev/shm under linux.
- */
-#define LTTNG_UST_WAIT_FILENAME                                        \
-       "lttng-ust-wait-"                                       \
-       __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE)
-
-struct lttng_ust_shm_handle;
-struct lttng_ust_lib_ring_buffer;
-
-struct lttng_ust_ctl_consumer_channel_attr {
-       enum lttng_ust_abi_chan_type type;
-       uint64_t subbuf_size;                   /* bytes */
-       uint64_t num_subbuf;                    /* power of 2 */
-       int overwrite;                          /* 1: overwrite, 0: discard */
-       unsigned int switch_timer_interval;     /* usec */
-       unsigned int read_timer_interval;       /* usec */
-       enum lttng_ust_abi_output output;       /* splice, mmap */
-       uint32_t chan_id;                       /* channel ID */
-       unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
-       int64_t blocking_timeout;                       /* Blocking timeout (usec) */
-} LTTNG_PACKED;
-
-/*
- * API used by sessiond.
- */
-
-struct lttng_ust_context_attr {
-       enum lttng_ust_abi_context_type ctx;
-       union {
-               struct lttng_ust_abi_perf_counter_ctx perf_counter;
-               struct {
-                       char *provider_name;
-                       char *ctx_name;
-               } app_ctx;
-       } u;
-};
-
-/*
- * Error values: all the following functions return:
- * >= 0: Success (LTTNG_UST_OK)
- * < 0: error code.
- */
-int lttng_ust_ctl_register_done(int sock);
-int lttng_ust_ctl_create_session(int sock);
-int lttng_ust_ctl_create_event(int sock, struct lttng_ust_abi_event *ev,
-               struct lttng_ust_abi_object_data *channel_data,
-               struct lttng_ust_abi_object_data **event_data);
-int lttng_ust_ctl_add_context(int sock, struct lttng_ust_context_attr *ctx,
-               struct lttng_ust_abi_object_data *obj_data,
-               struct lttng_ust_abi_object_data **context_data);
-int lttng_ust_ctl_set_filter(int sock, struct lttng_ust_abi_filter_bytecode *bytecode,
-               struct lttng_ust_abi_object_data *obj_data);
-int lttng_ust_ctl_set_capture(int sock, struct lttng_ust_abi_capture_bytecode *bytecode,
-               struct lttng_ust_abi_object_data *obj_data);
-int lttng_ust_ctl_set_exclusion(int sock, struct lttng_ust_abi_event_exclusion *exclusion,
-               struct lttng_ust_abi_object_data *obj_data);
-
-int lttng_ust_ctl_enable(int sock, struct lttng_ust_abi_object_data *object);
-int lttng_ust_ctl_disable(int sock, struct lttng_ust_abi_object_data *object);
-int lttng_ust_ctl_start_session(int sock, int handle);
-int lttng_ust_ctl_stop_session(int sock, int handle);
-
-/*
- * lttng_ust_ctl_create_event notifier_group creates a event notifier group. It
- * establishes the connection with the application by providing a file
- * descriptor of the pipe to be used by the application when a event notifier
- * of that group is fired. It returns a handle to be used when creating event
- * notifier in that group.
- */
-int lttng_ust_ctl_create_event_notifier_group(int sock, int pipe_fd,
-               struct lttng_ust_abi_object_data **event_notifier_group);
-
-/*
- * lttng_ust_ctl_create_event notifier creates a event notifier in a event notifier
- * group giving a event notifier description and a event notifier group handle.
- * It returns a event notifier handle to be used when enabling the event
- * notifier, attaching filter, attaching exclusion, and disabling the event
- * notifier.
- */
-int lttng_ust_ctl_create_event_notifier(int sock,
-               struct lttng_ust_abi_event_notifier *event_notifier,
-               struct lttng_ust_abi_object_data *event_notifier_group,
-               struct lttng_ust_abi_object_data **event_notifier_data);
-
-/*
- * lttng_ust_ctl_tracepoint_list returns a tracepoint list handle, or negative
- * error value.
- */
-int lttng_ust_ctl_tracepoint_list(int sock);
-
-/*
- * lttng_ust_ctl_tracepoint_list_get is used to iterate on the tp list
- * handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
- * returned.
- */
-int lttng_ust_ctl_tracepoint_list_get(int sock, int tp_list_handle,
-               struct lttng_ust_abi_tracepoint_iter *iter);
-
-/*
- * lttng_ust_ctl_tracepoint_field_list returns a tracepoint field list handle,
- * or negative error value.
- */
-int lttng_ust_ctl_tracepoint_field_list(int sock);
-
-/*
- * lttng_ust_ctl_tracepoint_field_list_get is used to iterate on the tp field
- * list handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
- * returned.
- */
-int lttng_ust_ctl_tracepoint_field_list_get(int sock, int tp_field_list_handle,
-               struct lttng_ust_abi_field_iter *iter);
-
-int lttng_ust_ctl_tracer_version(int sock, struct lttng_ust_abi_tracer_version *v);
-int lttng_ust_ctl_wait_quiescent(int sock);
-
-int lttng_ust_ctl_sock_flush_buffer(int sock, struct lttng_ust_abi_object_data *object);
-
-int lttng_ust_ctl_calibrate(int sock, struct lttng_ust_abi_calibrate *calibrate);
-
-/* Release object created by members of this API. */
-int lttng_ust_ctl_release_object(int sock, struct lttng_ust_abi_object_data *data);
-/* Release handle returned by create session. */
-int lttng_ust_ctl_release_handle(int sock, int handle);
-
-int lttng_ust_ctl_recv_channel_from_consumer(int sock,
-               struct lttng_ust_abi_object_data **channel_data);
-int lttng_ust_ctl_recv_stream_from_consumer(int sock,
-               struct lttng_ust_abi_object_data **stream_data);
-int lttng_ust_ctl_send_channel_to_ust(int sock, int session_handle,
-               struct lttng_ust_abi_object_data *channel_data);
-int lttng_ust_ctl_send_stream_to_ust(int sock,
-               struct lttng_ust_abi_object_data *channel_data,
-               struct lttng_ust_abi_object_data *stream_data);
-
-/*
- * lttng_ust_ctl_duplicate_ust_object_data allocated a new object in "dest" if
- * it succeeds (returns 0). It must be released using
- * lttng_ust_ctl_release_object() and then freed with free().
- */
-int lttng_ust_ctl_duplicate_ust_object_data(struct lttng_ust_abi_object_data **dest,
-               struct lttng_ust_abi_object_data *src);
-
-/*
- * API used by consumer.
- */
-
-struct lttng_ust_ctl_consumer_channel;
-struct lttng_ust_ctl_consumer_stream;
-struct lttng_ust_ctl_consumer_channel_attr;
-
-int lttng_ust_ctl_get_nr_stream_per_channel(void);
-
-struct lttng_ust_ctl_consumer_channel *
-       lttng_ust_ctl_create_channel(struct lttng_ust_ctl_consumer_channel_attr *attr,
-               const int *stream_fds, int nr_stream_fds);
-/*
- * Each stream created needs to be destroyed before calling
- * lttng_ust_ctl_destroy_channel().
- */
-void lttng_ust_ctl_destroy_channel(struct lttng_ust_ctl_consumer_channel *chan);
-
-int lttng_ust_ctl_send_channel_to_sessiond(int sock,
-               struct lttng_ust_ctl_consumer_channel *channel);
-int lttng_ust_ctl_channel_close_wait_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
-int lttng_ust_ctl_channel_close_wakeup_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
-int lttng_ust_ctl_channel_get_wait_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
-int lttng_ust_ctl_channel_get_wakeup_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
-
-int lttng_ust_ctl_write_metadata_to_channel(
-               struct lttng_ust_ctl_consumer_channel *channel,
-               const char *metadata_str,       /* NOT null-terminated */
-               size_t len);                    /* metadata length */
-ssize_t lttng_ust_ctl_write_one_packet_to_channel(
-               struct lttng_ust_ctl_consumer_channel *channel,
-               const char *metadata_str,       /* NOT null-terminated */
-               size_t len);                    /* metadata length */
-
-/*
- * Send a NULL stream to finish iteration over all streams of a given
- * channel.
- */
-int lttng_ust_ctl_send_stream_to_sessiond(int sock,
-               struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_stream_close_wait_fd(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_stream_close_wakeup_fd(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_stream_get_wait_fd(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_stream_get_wakeup_fd(struct lttng_ust_ctl_consumer_stream *stream);
-
-/* Create/destroy stream buffers for read */
-struct lttng_ust_ctl_consumer_stream *
-       lttng_ust_ctl_create_stream(struct lttng_ust_ctl_consumer_channel *channel,
-                       int cpu);
-void lttng_ust_ctl_destroy_stream(struct lttng_ust_ctl_consumer_stream *stream);
-
-/* For mmap mode, readable without "get" operation */
-int lttng_ust_ctl_get_mmap_len(struct lttng_ust_ctl_consumer_stream *stream,
-               unsigned long *len);
-int lttng_ust_ctl_get_max_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
-               unsigned long *len);
-
-/*
- * For mmap mode, operate on the current packet (between get/put or
- * get_next/put_next).
- */
-void *lttng_ust_ctl_get_mmap_base(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_get_mmap_read_offset(struct lttng_ust_ctl_consumer_stream *stream,
-               unsigned long *off);
-int lttng_ust_ctl_get_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
-               unsigned long *len);
-int lttng_ust_ctl_get_padded_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
-               unsigned long *len);
-int lttng_ust_ctl_get_next_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_put_next_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
-
-/* snapshot */
-
-int lttng_ust_ctl_snapshot(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_snapshot_sample_positions(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_snapshot_get_consumed(struct lttng_ust_ctl_consumer_stream *stream,
-               unsigned long *pos);
-int lttng_ust_ctl_snapshot_get_produced(struct lttng_ust_ctl_consumer_stream *stream,
-               unsigned long *pos);
-int lttng_ust_ctl_get_subbuf(struct lttng_ust_ctl_consumer_stream *stream,
-               unsigned long *pos);
-int lttng_ust_ctl_put_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
-
-int lttng_ust_ctl_flush_buffer(struct lttng_ust_ctl_consumer_stream *stream,
-               int producer_active);
-int lttng_ust_ctl_clear_buffer(struct lttng_ust_ctl_consumer_stream *stream);
-
-/* index */
-
-/*
- * Getters which need to be used on the current packet (between get/put
- * or get_next/put_next.
- */
-
-int lttng_ust_ctl_get_timestamp_begin(struct lttng_ust_ctl_consumer_stream *stream,
-               uint64_t *timestamp_begin);
-int lttng_ust_ctl_get_timestamp_end(struct lttng_ust_ctl_consumer_stream *stream,
-       uint64_t *timestamp_end);
-int lttng_ust_ctl_get_events_discarded(struct lttng_ust_ctl_consumer_stream *stream,
-       uint64_t *events_discarded);
-int lttng_ust_ctl_get_content_size(struct lttng_ust_ctl_consumer_stream *stream,
-       uint64_t *content_size);
-int lttng_ust_ctl_get_packet_size(struct lttng_ust_ctl_consumer_stream *stream,
-       uint64_t *packet_size);
-int lttng_ust_ctl_get_sequence_number(struct lttng_ust_ctl_consumer_stream *stream,
-               uint64_t *seq);
-
-/*
- * Getter returning state invariant for the stream, which can be used
- * without "get" operation.
- */
-
-int lttng_ust_ctl_get_stream_id(struct lttng_ust_ctl_consumer_stream *stream,
-               uint64_t *stream_id);
-int lttng_ust_ctl_get_instance_id(struct lttng_ust_ctl_consumer_stream *stream,
-               uint64_t *id);
-
-/*
- * Getter returning the current timestamp as perceived from the
- * tracer.
- */
-int lttng_ust_ctl_get_current_timestamp(struct lttng_ust_ctl_consumer_stream *stream,
-               uint64_t *ts);
-
-/* returns whether UST has perf counters support. */
-int lttng_ust_ctl_has_perf_counters(void);
-
-/* Regenerate the statedump. */
-int lttng_ust_ctl_regenerate_statedump(int sock, int handle);
-
-/* event registry management */
-
-enum lttng_ust_ctl_socket_type {
-       LTTNG_UST_CTL_SOCKET_CMD = 0,
-       LTTNG_UST_CTL_SOCKET_NOTIFY = 1,
-};
-
-enum lttng_ust_ctl_notify_cmd {
-       LTTNG_UST_CTL_NOTIFY_CMD_EVENT = 0,
-       LTTNG_UST_CTL_NOTIFY_CMD_CHANNEL = 1,
-       LTTNG_UST_CTL_NOTIFY_CMD_ENUM = 2,
-};
-
-enum lttng_ust_ctl_channel_header {
-       LTTNG_UST_CTL_CHANNEL_HEADER_UNKNOWN = 0,
-       LTTNG_UST_CTL_CHANNEL_HEADER_COMPACT = 1,
-       LTTNG_UST_CTL_CHANNEL_HEADER_LARGE = 2,
-};
-
-/* event type structures */
-
-enum lttng_ust_ctl_abstract_types {
-       lttng_ust_ctl_atype_integer,
-       lttng_ust_ctl_atype_enum,       /* legacy */
-       lttng_ust_ctl_atype_array,      /* legacy */
-       lttng_ust_ctl_atype_sequence,   /* legacy */
-       lttng_ust_ctl_atype_string,
-       lttng_ust_ctl_atype_float,
-       lttng_ust_ctl_atype_variant,    /* legacy */
-       lttng_ust_ctl_atype_struct,     /* legacy */
-       lttng_ust_ctl_atype_enum_nestable,
-       lttng_ust_ctl_atype_array_nestable,
-       lttng_ust_ctl_atype_sequence_nestable,
-       lttng_ust_ctl_atype_struct_nestable,
-       lttng_ust_ctl_atype_variant_nestable,
-       NR_LTTNG_UST_CTL_ABSTRACT_TYPES,
-};
-
-enum lttng_ust_ctl_string_encodings {
-       lttng_ust_ctl_encode_none = 0,
-       lttng_ust_ctl_encode_UTF8 = 1,
-       lttng_ust_ctl_encode_ASCII = 2,
-       NR_LTTNG_UST_CTL_STRING_ENCODINGS,
-};
-
-#define LTTNG_UST_CTL_UST_INTEGER_TYPE_PADDING 24
-struct lttng_ust_ctl_integer_type {
-       uint32_t size;          /* in bits */
-       uint32_t signedness;
-       uint32_t reverse_byte_order;
-       uint32_t base;          /* 2, 8, 10, 16, for pretty print */
-       int32_t encoding;       /* enum lttng_ust_ctl_string_encodings */
-       uint16_t alignment;     /* in bits */
-       char padding[LTTNG_UST_CTL_UST_INTEGER_TYPE_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_CTL_UST_FLOAT_TYPE_PADDING   24
-struct lttng_ust_ctl_float_type {
-       uint32_t exp_dig;               /* exponent digits, in bits */
-       uint32_t mant_dig;              /* mantissa digits, in bits */
-       uint32_t reverse_byte_order;
-       uint16_t alignment;     /* in bits */
-       char padding[LTTNG_UST_CTL_UST_FLOAT_TYPE_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_CTL_UST_ENUM_VALUE_PADDING   15
-struct lttng_ust_ctl_enum_value {
-       uint64_t value;
-       uint8_t signedness;
-       char padding[LTTNG_UST_CTL_UST_ENUM_VALUE_PADDING];
-} LTTNG_PACKED;
-
-enum lttng_ust_ctl_ust_enum_entry_options {
-       LTTNG_UST_CTL_UST_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
-};
-
-#define LTTNG_UST_CTL_UST_ENUM_ENTRY_PADDING   32
-struct lttng_ust_ctl_enum_entry {
-       struct lttng_ust_ctl_enum_value start, end; /* start and end are inclusive */
-       char string[LTTNG_UST_ABI_SYM_NAME_LEN];
-       union {
-               struct {
-                       uint32_t options;
-               } LTTNG_PACKED extra;
-               char padding[LTTNG_UST_CTL_UST_ENUM_ENTRY_PADDING];
-       } u;
-} LTTNG_PACKED;
-
-/* legacy */
-#define LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING   296
-union _lttng_ust_ctl_basic_type {
-       struct lttng_ust_ctl_integer_type integer;
-       struct {
-               char name[LTTNG_UST_ABI_SYM_NAME_LEN];
-               struct lttng_ust_ctl_integer_type container_type;
-               uint64_t id;    /* enum ID in sessiond. */
-       } enumeration;
-       struct {
-               int32_t encoding;       /* enum lttng_ust_ctl_string_encodings */
-       } string;
-       struct lttng_ust_ctl_float_type _float;
-       char padding[LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING];
-} LTTNG_PACKED;
-
-/* legacy */
-struct lttng_ust_ctl_basic_type {
-       enum lttng_ust_ctl_abstract_types atype;
-       union {
-               union _lttng_ust_ctl_basic_type basic;
-       } u;
-} LTTNG_PACKED;
-
-/*
- * Padding is derived from largest member: u.legacy.sequence which
- * contains two basic types, each with LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING.
- */
-#define LTTNG_UST_CTL_UST_TYPE_PADDING (2 * LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING)
-struct lttng_ust_ctl_type {
-       enum lttng_ust_ctl_abstract_types atype;
-       union {
-               struct lttng_ust_ctl_integer_type integer;
-               struct lttng_ust_ctl_float_type _float;
-               struct {
-                       int32_t encoding;       /* enum lttng_ust_ctl_string_encodings */
-               } string;
-               struct {
-                       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
-                       uint64_t id;    /* enum ID in sessiond. */
-                       /* container_type follows after this struct lttng_ust_ctl_field. */
-               } enum_nestable;
-               struct {
-                       uint32_t length;                /* num. elems. */
-                       uint32_t alignment;
-                       /* elem_type follows after this struct lttng_ust_ctl_field. */
-               } array_nestable;
-               struct {
-                       char length_name[LTTNG_UST_ABI_SYM_NAME_LEN];
-                       uint32_t alignment;             /* Alignment before elements. */
-                       /* elem_type follows after the length_type. */
-               } sequence_nestable;
-               struct {
-                       uint32_t nr_fields;
-                       uint32_t alignment;
-                       /* Followed by nr_fields struct lttng_ust_ctl_field. */
-               } struct_nestable;
-               struct {
-                       uint32_t nr_choices;
-                       char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN];
-                       uint32_t alignment;
-                       /* Followed by nr_choices struct lttng_ust_ctl_field. */
-               } variant_nestable;
-
-               /* Legacy ABI */
-               union {
-                       union _lttng_ust_ctl_basic_type basic;
-                       struct {
-                               struct lttng_ust_ctl_basic_type elem_type;
-                               uint32_t length;                /* num. elems. */
-                       } array;
-                       struct {
-                               struct lttng_ust_ctl_basic_type length_type;
-                               struct lttng_ust_ctl_basic_type elem_type;
-                       } sequence;
-                       struct {
-                               uint32_t nr_fields;
-                               /* Followed by nr_fields struct lttng_ust_ctl_field. */
-                       } _struct;
-                       struct {
-                               uint32_t nr_choices;
-                               char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN];
-                               /* Followed by nr_choices struct lttng_ust_ctl_field. */
-                       } variant;
-               } legacy;
-               char padding[LTTNG_UST_CTL_UST_TYPE_PADDING];
-       } u;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_CTL_UST_FIELD_PADDING        28
-struct lttng_ust_ctl_field {
-       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
-       struct lttng_ust_ctl_type type;
-       char padding[LTTNG_UST_CTL_UST_FIELD_PADDING];
-} LTTNG_PACKED;
-
-/*
- * Returns 0 on success, negative error value on error.
- * If an error other than -LTTNG_UST_ERR_UNSUP_MAJOR is returned,
- * the output fields are not populated.
- */
-int lttng_ust_ctl_recv_reg_msg(int sock,
-       enum lttng_ust_ctl_socket_type *type,
-       uint32_t *major,
-       uint32_t *minor,
-       uint32_t *pid,
-       uint32_t *ppid,
-       uint32_t *uid,
-       uint32_t *gid,
-       uint32_t *bits_per_long,
-       uint32_t *uint8_t_alignment,
-       uint32_t *uint16_t_alignment,
-       uint32_t *uint32_t_alignment,
-       uint32_t *uint64_t_alignment,
-       uint32_t *long_alignment,
-       int *byte_order,
-       char *name);    /* size LTTNG_UST_ABI_PROCNAME_LEN */
-
-/*
- * Returns 0 on success, negative UST or system error value on error.
- * Receive the notification command. The "notify_cmd" can then be used
- * by the caller to find out which lttng_ust_ctl_recv_* function should be
- * called to receive the notification, and which lttng_ust_ctl_reply_* is
- * appropriate.
- */
-int lttng_ust_ctl_recv_notify(int sock, enum lttng_ust_ctl_notify_cmd *notify_cmd);
-
-/*
- * Returns 0 on success, negative UST or system error value on error.
- */
-int lttng_ust_ctl_recv_register_event(int sock,
-       int *session_objd,              /* session descriptor (output) */
-       int *channel_objd,              /* channel descriptor (output) */
-       char *event_name,               /*
-                                        * event name (output,
-                                        * size LTTNG_UST_ABI_SYM_NAME_LEN)
-                                        */
-       int *loglevel,
-       char **signature,               /*
-                                        * event signature
-                                        * (output, dynamically
-                                        * allocated, must be free(3)'d
-                                        * by the caller if function
-                                        * returns success.)
-                                        */
-       size_t *nr_fields,
-       struct lttng_ust_ctl_field **fields,
-       char **model_emf_uri);
-
-/*
- * Returns 0 on success, negative error value on error.
- */
-int lttng_ust_ctl_reply_register_event(int sock,
-       uint32_t id,                    /* event id (input) */
-       int ret_code);                  /* return code. 0 ok, negative error */
-
-/*
- * Returns 0 on success, negative UST or system error value on error.
- */
-int lttng_ust_ctl_recv_register_enum(int sock,
-       int *session_objd,
-       char *enum_name,
-       struct lttng_ust_ctl_enum_entry **entries,
-       size_t *nr_entries);
-
-/*
- * Returns 0 on success, negative error value on error.
- */
-int lttng_ust_ctl_reply_register_enum(int sock,
-       uint64_t id,                    /* enum id (input) */
-       int ret_code);
-
-/*
- * Returns 0 on success, negative UST or system error value on error.
- */
-int lttng_ust_ctl_recv_register_channel(int sock,
-       int *session_objd,              /* session descriptor (output) */
-       int *channel_objd,              /* channel descriptor (output) */
-       size_t *nr_fields,              /* context fields */
-       struct lttng_ust_ctl_field **fields);
-
-/*
- * Returns 0 on success, negative error value on error.
- */
-int lttng_ust_ctl_reply_register_channel(int sock,
-       uint32_t chan_id,
-       enum lttng_ust_ctl_channel_header header_type,
-       int ret_code);                  /* return code. 0 ok, negative error */
-
-/*
- * Counter API.
- */
-
-enum lttng_ust_ctl_counter_bitness {
-       LTTNG_UST_CTL_COUNTER_BITNESS_32 = 0,
-       LTTNG_UST_CTL_COUNTER_BITNESS_64 = 1,
-};
-
-enum lttng_ust_ctl_counter_arithmetic {
-       LTTNG_UST_CTL_COUNTER_ARITHMETIC_MODULAR        = 0,
-       LTTNG_UST_CTL_COUNTER_ARITHMETIC_SATURATION     = 1,
-};
-
-/* Used as alloc flags. */
-enum lttng_ust_ctl_counter_alloc {
-       LTTNG_UST_CTL_COUNTER_ALLOC_PER_CPU = (1 << 0),
-       LTTNG_UST_CTL_COUNTER_ALLOC_GLOBAL = (1 << 1),
-};
-
-struct lttng_ust_ctl_daemon_counter;
-
-int lttng_ust_ctl_get_nr_cpu_per_counter(void);
-
-struct lttng_ust_ctl_counter_dimension {
-       uint64_t size;
-       uint64_t underflow_index;
-       uint64_t overflow_index;
-       uint8_t has_underflow;
-       uint8_t has_overflow;
-};
-
-struct lttng_ust_ctl_daemon_counter *
-       lttng_ust_ctl_create_counter(size_t nr_dimensions,
-               const struct lttng_ust_ctl_counter_dimension *dimensions,
-               int64_t global_sum_step,
-               int global_counter_fd,
-               int nr_counter_cpu_fds,
-               const int *counter_cpu_fds,
-               enum lttng_ust_ctl_counter_bitness bitness,
-               enum lttng_ust_ctl_counter_arithmetic arithmetic,
-               uint32_t alloc_flags,
-               bool coalesce_hits);
-
-int lttng_ust_ctl_create_counter_data(struct lttng_ust_ctl_daemon_counter *counter,
-               struct lttng_ust_abi_object_data **counter_data);
-
-int lttng_ust_ctl_create_counter_global_data(struct lttng_ust_ctl_daemon_counter *counter,
-               struct lttng_ust_abi_object_data **counter_global_data);
-int lttng_ust_ctl_create_counter_cpu_data(struct lttng_ust_ctl_daemon_counter *counter, int cpu,
-               struct lttng_ust_abi_object_data **counter_cpu_data);
-
-/*
- * Each counter data and counter cpu data created need to be destroyed
- * before calling lttng_ust_ctl_destroy_counter().
- */
-void lttng_ust_ctl_destroy_counter(struct lttng_ust_ctl_daemon_counter *counter);
-
-int lttng_ust_ctl_send_counter_data_to_ust(int sock, int parent_handle,
-               struct lttng_ust_abi_object_data *counter_data);
-int lttng_ust_ctl_send_counter_global_data_to_ust(int sock,
-               struct lttng_ust_abi_object_data *counter_data,
-               struct lttng_ust_abi_object_data *counter_global_data);
-int lttng_ust_ctl_send_counter_cpu_data_to_ust(int sock,
-               struct lttng_ust_abi_object_data *counter_data,
-               struct lttng_ust_abi_object_data *counter_cpu_data);
-
-int lttng_ust_ctl_counter_read(struct lttng_ust_ctl_daemon_counter *counter,
-               const size_t *dimension_indexes,
-               int cpu, int64_t *value,
-               bool *overflow, bool *underflow);
-int lttng_ust_ctl_counter_aggregate(struct lttng_ust_ctl_daemon_counter *counter,
-               const size_t *dimension_indexes,
-               int64_t *value,
-               bool *overflow, bool *underflow);
-int lttng_ust_ctl_counter_clear(struct lttng_ust_ctl_daemon_counter *counter,
-               const size_t *dimension_indexes);
-
-void lttng_ust_ctl_sigbus_handle(void *addr);
-
-#endif /* LTTNG_UST_CTL_INTERNAL_H */
diff --git a/src/bin/lttng-sessiond/ust-ctl-internal.hpp b/src/bin/lttng-sessiond/ust-ctl-internal.hpp
new file mode 100644 (file)
index 0000000..aee3cd5
--- /dev/null
@@ -0,0 +1,658 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_CTL_INTERNAL_H
+#define LTTNG_UST_CTL_INTERNAL_H
+
+#include <sys/types.h>
+#include <limits.h>
+
+#include "lttng-ust-abi.hpp"
+
+#ifndef LTTNG_UST_UUID_LEN
+#define LTTNG_UST_UUID_LEN     16
+#endif
+
+/* Default unix socket path */
+#define LTTNG_UST_SOCK_FILENAME                                        \
+       "lttng-ust-sock-"                                       \
+       __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE)
+
+/*
+ * Shared memory files path are automatically related to shm root, e.g.
+ * /dev/shm under linux.
+ */
+#define LTTNG_UST_WAIT_FILENAME                                        \
+       "lttng-ust-wait-"                                       \
+       __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE)
+
+struct lttng_ust_shm_handle;
+struct lttng_ust_lib_ring_buffer;
+
+struct lttng_ust_ctl_consumer_channel_attr {
+       enum lttng_ust_abi_chan_type type;
+       uint64_t subbuf_size;                   /* bytes */
+       uint64_t num_subbuf;                    /* power of 2 */
+       int overwrite;                          /* 1: overwrite, 0: discard */
+       unsigned int switch_timer_interval;     /* usec */
+       unsigned int read_timer_interval;       /* usec */
+       enum lttng_ust_abi_output output;       /* splice, mmap */
+       uint32_t chan_id;                       /* channel ID */
+       unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
+       int64_t blocking_timeout;                       /* Blocking timeout (usec) */
+} LTTNG_PACKED;
+
+/*
+ * API used by sessiond.
+ */
+
+struct lttng_ust_context_attr {
+       enum lttng_ust_abi_context_type ctx;
+       union {
+               struct lttng_ust_abi_perf_counter_ctx perf_counter;
+               struct {
+                       char *provider_name;
+                       char *ctx_name;
+               } app_ctx;
+       } u;
+};
+
+/*
+ * Error values: all the following functions return:
+ * >= 0: Success (LTTNG_UST_OK)
+ * < 0: error code.
+ */
+int lttng_ust_ctl_register_done(int sock);
+int lttng_ust_ctl_create_session(int sock);
+int lttng_ust_ctl_create_event(int sock, struct lttng_ust_abi_event *ev,
+               struct lttng_ust_abi_object_data *channel_data,
+               struct lttng_ust_abi_object_data **event_data);
+int lttng_ust_ctl_add_context(int sock, struct lttng_ust_context_attr *ctx,
+               struct lttng_ust_abi_object_data *obj_data,
+               struct lttng_ust_abi_object_data **context_data);
+int lttng_ust_ctl_set_filter(int sock, struct lttng_ust_abi_filter_bytecode *bytecode,
+               struct lttng_ust_abi_object_data *obj_data);
+int lttng_ust_ctl_set_capture(int sock, struct lttng_ust_abi_capture_bytecode *bytecode,
+               struct lttng_ust_abi_object_data *obj_data);
+int lttng_ust_ctl_set_exclusion(int sock, struct lttng_ust_abi_event_exclusion *exclusion,
+               struct lttng_ust_abi_object_data *obj_data);
+
+int lttng_ust_ctl_enable(int sock, struct lttng_ust_abi_object_data *object);
+int lttng_ust_ctl_disable(int sock, struct lttng_ust_abi_object_data *object);
+int lttng_ust_ctl_start_session(int sock, int handle);
+int lttng_ust_ctl_stop_session(int sock, int handle);
+
+/*
+ * lttng_ust_ctl_create_event notifier_group creates a event notifier group. It
+ * establishes the connection with the application by providing a file
+ * descriptor of the pipe to be used by the application when a event notifier
+ * of that group is fired. It returns a handle to be used when creating event
+ * notifier in that group.
+ */
+int lttng_ust_ctl_create_event_notifier_group(int sock, int pipe_fd,
+               struct lttng_ust_abi_object_data **event_notifier_group);
+
+/*
+ * lttng_ust_ctl_create_event notifier creates a event notifier in a event notifier
+ * group giving a event notifier description and a event notifier group handle.
+ * It returns a event notifier handle to be used when enabling the event
+ * notifier, attaching filter, attaching exclusion, and disabling the event
+ * notifier.
+ */
+int lttng_ust_ctl_create_event_notifier(int sock,
+               struct lttng_ust_abi_event_notifier *event_notifier,
+               struct lttng_ust_abi_object_data *event_notifier_group,
+               struct lttng_ust_abi_object_data **event_notifier_data);
+
+/*
+ * lttng_ust_ctl_tracepoint_list returns a tracepoint list handle, or negative
+ * error value.
+ */
+int lttng_ust_ctl_tracepoint_list(int sock);
+
+/*
+ * lttng_ust_ctl_tracepoint_list_get is used to iterate on the tp list
+ * handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
+ * returned.
+ */
+int lttng_ust_ctl_tracepoint_list_get(int sock, int tp_list_handle,
+               struct lttng_ust_abi_tracepoint_iter *iter);
+
+/*
+ * lttng_ust_ctl_tracepoint_field_list returns a tracepoint field list handle,
+ * or negative error value.
+ */
+int lttng_ust_ctl_tracepoint_field_list(int sock);
+
+/*
+ * lttng_ust_ctl_tracepoint_field_list_get is used to iterate on the tp field
+ * list handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
+ * returned.
+ */
+int lttng_ust_ctl_tracepoint_field_list_get(int sock, int tp_field_list_handle,
+               struct lttng_ust_abi_field_iter *iter);
+
+int lttng_ust_ctl_tracer_version(int sock, struct lttng_ust_abi_tracer_version *v);
+int lttng_ust_ctl_wait_quiescent(int sock);
+
+int lttng_ust_ctl_sock_flush_buffer(int sock, struct lttng_ust_abi_object_data *object);
+
+int lttng_ust_ctl_calibrate(int sock, struct lttng_ust_abi_calibrate *calibrate);
+
+/* Release object created by members of this API. */
+int lttng_ust_ctl_release_object(int sock, struct lttng_ust_abi_object_data *data);
+/* Release handle returned by create session. */
+int lttng_ust_ctl_release_handle(int sock, int handle);
+
+int lttng_ust_ctl_recv_channel_from_consumer(int sock,
+               struct lttng_ust_abi_object_data **channel_data);
+int lttng_ust_ctl_recv_stream_from_consumer(int sock,
+               struct lttng_ust_abi_object_data **stream_data);
+int lttng_ust_ctl_send_channel_to_ust(int sock, int session_handle,
+               struct lttng_ust_abi_object_data *channel_data);
+int lttng_ust_ctl_send_stream_to_ust(int sock,
+               struct lttng_ust_abi_object_data *channel_data,
+               struct lttng_ust_abi_object_data *stream_data);
+
+/*
+ * lttng_ust_ctl_duplicate_ust_object_data allocated a new object in "dest" if
+ * it succeeds (returns 0). It must be released using
+ * lttng_ust_ctl_release_object() and then freed with free().
+ */
+int lttng_ust_ctl_duplicate_ust_object_data(struct lttng_ust_abi_object_data **dest,
+               struct lttng_ust_abi_object_data *src);
+
+/*
+ * API used by consumer.
+ */
+
+struct lttng_ust_ctl_consumer_channel;
+struct lttng_ust_ctl_consumer_stream;
+struct lttng_ust_ctl_consumer_channel_attr;
+
+int lttng_ust_ctl_get_nr_stream_per_channel(void);
+
+struct lttng_ust_ctl_consumer_channel *
+       lttng_ust_ctl_create_channel(struct lttng_ust_ctl_consumer_channel_attr *attr,
+               const int *stream_fds, int nr_stream_fds);
+/*
+ * Each stream created needs to be destroyed before calling
+ * lttng_ust_ctl_destroy_channel().
+ */
+void lttng_ust_ctl_destroy_channel(struct lttng_ust_ctl_consumer_channel *chan);
+
+int lttng_ust_ctl_send_channel_to_sessiond(int sock,
+               struct lttng_ust_ctl_consumer_channel *channel);
+int lttng_ust_ctl_channel_close_wait_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
+int lttng_ust_ctl_channel_close_wakeup_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
+int lttng_ust_ctl_channel_get_wait_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
+int lttng_ust_ctl_channel_get_wakeup_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
+
+int lttng_ust_ctl_write_metadata_to_channel(
+               struct lttng_ust_ctl_consumer_channel *channel,
+               const char *metadata_str,       /* NOT null-terminated */
+               size_t len);                    /* metadata length */
+ssize_t lttng_ust_ctl_write_one_packet_to_channel(
+               struct lttng_ust_ctl_consumer_channel *channel,
+               const char *metadata_str,       /* NOT null-terminated */
+               size_t len);                    /* metadata length */
+
+/*
+ * Send a NULL stream to finish iteration over all streams of a given
+ * channel.
+ */
+int lttng_ust_ctl_send_stream_to_sessiond(int sock,
+               struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_stream_close_wait_fd(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_stream_close_wakeup_fd(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_stream_get_wait_fd(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_stream_get_wakeup_fd(struct lttng_ust_ctl_consumer_stream *stream);
+
+/* Create/destroy stream buffers for read */
+struct lttng_ust_ctl_consumer_stream *
+       lttng_ust_ctl_create_stream(struct lttng_ust_ctl_consumer_channel *channel,
+                       int cpu);
+void lttng_ust_ctl_destroy_stream(struct lttng_ust_ctl_consumer_stream *stream);
+
+/* For mmap mode, readable without "get" operation */
+int lttng_ust_ctl_get_mmap_len(struct lttng_ust_ctl_consumer_stream *stream,
+               unsigned long *len);
+int lttng_ust_ctl_get_max_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
+               unsigned long *len);
+
+/*
+ * For mmap mode, operate on the current packet (between get/put or
+ * get_next/put_next).
+ */
+void *lttng_ust_ctl_get_mmap_base(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_get_mmap_read_offset(struct lttng_ust_ctl_consumer_stream *stream,
+               unsigned long *off);
+int lttng_ust_ctl_get_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
+               unsigned long *len);
+int lttng_ust_ctl_get_padded_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
+               unsigned long *len);
+int lttng_ust_ctl_get_next_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_put_next_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
+
+/* snapshot */
+
+int lttng_ust_ctl_snapshot(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_snapshot_sample_positions(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_snapshot_get_consumed(struct lttng_ust_ctl_consumer_stream *stream,
+               unsigned long *pos);
+int lttng_ust_ctl_snapshot_get_produced(struct lttng_ust_ctl_consumer_stream *stream,
+               unsigned long *pos);
+int lttng_ust_ctl_get_subbuf(struct lttng_ust_ctl_consumer_stream *stream,
+               unsigned long *pos);
+int lttng_ust_ctl_put_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
+
+int lttng_ust_ctl_flush_buffer(struct lttng_ust_ctl_consumer_stream *stream,
+               int producer_active);
+int lttng_ust_ctl_clear_buffer(struct lttng_ust_ctl_consumer_stream *stream);
+
+/* index */
+
+/*
+ * Getters which need to be used on the current packet (between get/put
+ * or get_next/put_next.
+ */
+
+int lttng_ust_ctl_get_timestamp_begin(struct lttng_ust_ctl_consumer_stream *stream,
+               uint64_t *timestamp_begin);
+int lttng_ust_ctl_get_timestamp_end(struct lttng_ust_ctl_consumer_stream *stream,
+       uint64_t *timestamp_end);
+int lttng_ust_ctl_get_events_discarded(struct lttng_ust_ctl_consumer_stream *stream,
+       uint64_t *events_discarded);
+int lttng_ust_ctl_get_content_size(struct lttng_ust_ctl_consumer_stream *stream,
+       uint64_t *content_size);
+int lttng_ust_ctl_get_packet_size(struct lttng_ust_ctl_consumer_stream *stream,
+       uint64_t *packet_size);
+int lttng_ust_ctl_get_sequence_number(struct lttng_ust_ctl_consumer_stream *stream,
+               uint64_t *seq);
+
+/*
+ * Getter returning state invariant for the stream, which can be used
+ * without "get" operation.
+ */
+
+int lttng_ust_ctl_get_stream_id(struct lttng_ust_ctl_consumer_stream *stream,
+               uint64_t *stream_id);
+int lttng_ust_ctl_get_instance_id(struct lttng_ust_ctl_consumer_stream *stream,
+               uint64_t *id);
+
+/*
+ * Getter returning the current timestamp as perceived from the
+ * tracer.
+ */
+int lttng_ust_ctl_get_current_timestamp(struct lttng_ust_ctl_consumer_stream *stream,
+               uint64_t *ts);
+
+/* returns whether UST has perf counters support. */
+int lttng_ust_ctl_has_perf_counters(void);
+
+/* Regenerate the statedump. */
+int lttng_ust_ctl_regenerate_statedump(int sock, int handle);
+
+/* event registry management */
+
+enum lttng_ust_ctl_socket_type {
+       LTTNG_UST_CTL_SOCKET_CMD = 0,
+       LTTNG_UST_CTL_SOCKET_NOTIFY = 1,
+};
+
+enum lttng_ust_ctl_notify_cmd {
+       LTTNG_UST_CTL_NOTIFY_CMD_EVENT = 0,
+       LTTNG_UST_CTL_NOTIFY_CMD_CHANNEL = 1,
+       LTTNG_UST_CTL_NOTIFY_CMD_ENUM = 2,
+};
+
+enum lttng_ust_ctl_channel_header {
+       LTTNG_UST_CTL_CHANNEL_HEADER_UNKNOWN = 0,
+       LTTNG_UST_CTL_CHANNEL_HEADER_COMPACT = 1,
+       LTTNG_UST_CTL_CHANNEL_HEADER_LARGE = 2,
+};
+
+/* event type structures */
+
+enum lttng_ust_ctl_abstract_types {
+       lttng_ust_ctl_atype_integer,
+       lttng_ust_ctl_atype_enum,       /* legacy */
+       lttng_ust_ctl_atype_array,      /* legacy */
+       lttng_ust_ctl_atype_sequence,   /* legacy */
+       lttng_ust_ctl_atype_string,
+       lttng_ust_ctl_atype_float,
+       lttng_ust_ctl_atype_variant,    /* legacy */
+       lttng_ust_ctl_atype_struct,     /* legacy */
+       lttng_ust_ctl_atype_enum_nestable,
+       lttng_ust_ctl_atype_array_nestable,
+       lttng_ust_ctl_atype_sequence_nestable,
+       lttng_ust_ctl_atype_struct_nestable,
+       lttng_ust_ctl_atype_variant_nestable,
+       NR_LTTNG_UST_CTL_ABSTRACT_TYPES,
+};
+
+enum lttng_ust_ctl_string_encodings {
+       lttng_ust_ctl_encode_none = 0,
+       lttng_ust_ctl_encode_UTF8 = 1,
+       lttng_ust_ctl_encode_ASCII = 2,
+       NR_LTTNG_UST_CTL_STRING_ENCODINGS,
+};
+
+#define LTTNG_UST_CTL_UST_INTEGER_TYPE_PADDING 24
+struct lttng_ust_ctl_integer_type {
+       uint32_t size;          /* in bits */
+       uint32_t signedness;
+       uint32_t reverse_byte_order;
+       uint32_t base;          /* 2, 8, 10, 16, for pretty print */
+       int32_t encoding;       /* enum lttng_ust_ctl_string_encodings */
+       uint16_t alignment;     /* in bits */
+       char padding[LTTNG_UST_CTL_UST_INTEGER_TYPE_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_CTL_UST_FLOAT_TYPE_PADDING   24
+struct lttng_ust_ctl_float_type {
+       uint32_t exp_dig;               /* exponent digits, in bits */
+       uint32_t mant_dig;              /* mantissa digits, in bits */
+       uint32_t reverse_byte_order;
+       uint16_t alignment;     /* in bits */
+       char padding[LTTNG_UST_CTL_UST_FLOAT_TYPE_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_CTL_UST_ENUM_VALUE_PADDING   15
+struct lttng_ust_ctl_enum_value {
+       uint64_t value;
+       uint8_t signedness;
+       char padding[LTTNG_UST_CTL_UST_ENUM_VALUE_PADDING];
+} LTTNG_PACKED;
+
+enum lttng_ust_ctl_ust_enum_entry_options {
+       LTTNG_UST_CTL_UST_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
+};
+
+#define LTTNG_UST_CTL_UST_ENUM_ENTRY_PADDING   32
+struct lttng_ust_ctl_enum_entry {
+       struct lttng_ust_ctl_enum_value start, end; /* start and end are inclusive */
+       char string[LTTNG_UST_ABI_SYM_NAME_LEN];
+       union {
+               struct {
+                       uint32_t options;
+               } LTTNG_PACKED extra;
+               char padding[LTTNG_UST_CTL_UST_ENUM_ENTRY_PADDING];
+       } u;
+} LTTNG_PACKED;
+
+/* legacy */
+#define LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING   296
+union _lttng_ust_ctl_basic_type {
+       struct lttng_ust_ctl_integer_type integer;
+       struct {
+               char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+               struct lttng_ust_ctl_integer_type container_type;
+               uint64_t id;    /* enum ID in sessiond. */
+       } enumeration;
+       struct {
+               int32_t encoding;       /* enum lttng_ust_ctl_string_encodings */
+       } string;
+       struct lttng_ust_ctl_float_type _float;
+       char padding[LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING];
+} LTTNG_PACKED;
+
+/* legacy */
+struct lttng_ust_ctl_basic_type {
+       enum lttng_ust_ctl_abstract_types atype;
+       union {
+               union _lttng_ust_ctl_basic_type basic;
+       } u;
+} LTTNG_PACKED;
+
+/*
+ * Padding is derived from largest member: u.legacy.sequence which
+ * contains two basic types, each with LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING.
+ */
+#define LTTNG_UST_CTL_UST_TYPE_PADDING (2 * LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING)
+struct lttng_ust_ctl_type {
+       enum lttng_ust_ctl_abstract_types atype;
+       union {
+               struct lttng_ust_ctl_integer_type integer;
+               struct lttng_ust_ctl_float_type _float;
+               struct {
+                       int32_t encoding;       /* enum lttng_ust_ctl_string_encodings */
+               } string;
+               struct {
+                       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+                       uint64_t id;    /* enum ID in sessiond. */
+                       /* container_type follows after this struct lttng_ust_ctl_field. */
+               } enum_nestable;
+               struct {
+                       uint32_t length;                /* num. elems. */
+                       uint32_t alignment;
+                       /* elem_type follows after this struct lttng_ust_ctl_field. */
+               } array_nestable;
+               struct {
+                       char length_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+                       uint32_t alignment;             /* Alignment before elements. */
+                       /* elem_type follows after the length_type. */
+               } sequence_nestable;
+               struct {
+                       uint32_t nr_fields;
+                       uint32_t alignment;
+                       /* Followed by nr_fields struct lttng_ust_ctl_field. */
+               } struct_nestable;
+               struct {
+                       uint32_t nr_choices;
+                       char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+                       uint32_t alignment;
+                       /* Followed by nr_choices struct lttng_ust_ctl_field. */
+               } variant_nestable;
+
+               /* Legacy ABI */
+               union {
+                       union _lttng_ust_ctl_basic_type basic;
+                       struct {
+                               struct lttng_ust_ctl_basic_type elem_type;
+                               uint32_t length;                /* num. elems. */
+                       } array;
+                       struct {
+                               struct lttng_ust_ctl_basic_type length_type;
+                               struct lttng_ust_ctl_basic_type elem_type;
+                       } sequence;
+                       struct {
+                               uint32_t nr_fields;
+                               /* Followed by nr_fields struct lttng_ust_ctl_field. */
+                       } _struct;
+                       struct {
+                               uint32_t nr_choices;
+                               char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+                               /* Followed by nr_choices struct lttng_ust_ctl_field. */
+                       } variant;
+               } legacy;
+               char padding[LTTNG_UST_CTL_UST_TYPE_PADDING];
+       } u;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_CTL_UST_FIELD_PADDING        28
+struct lttng_ust_ctl_field {
+       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+       struct lttng_ust_ctl_type type;
+       char padding[LTTNG_UST_CTL_UST_FIELD_PADDING];
+} LTTNG_PACKED;
+
+/*
+ * Returns 0 on success, negative error value on error.
+ * If an error other than -LTTNG_UST_ERR_UNSUP_MAJOR is returned,
+ * the output fields are not populated.
+ */
+int lttng_ust_ctl_recv_reg_msg(int sock,
+       enum lttng_ust_ctl_socket_type *type,
+       uint32_t *major,
+       uint32_t *minor,
+       uint32_t *pid,
+       uint32_t *ppid,
+       uint32_t *uid,
+       uint32_t *gid,
+       uint32_t *bits_per_long,
+       uint32_t *uint8_t_alignment,
+       uint32_t *uint16_t_alignment,
+       uint32_t *uint32_t_alignment,
+       uint32_t *uint64_t_alignment,
+       uint32_t *long_alignment,
+       int *byte_order,
+       char *name);    /* size LTTNG_UST_ABI_PROCNAME_LEN */
+
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ * Receive the notification command. The "notify_cmd" can then be used
+ * by the caller to find out which lttng_ust_ctl_recv_* function should be
+ * called to receive the notification, and which lttng_ust_ctl_reply_* is
+ * appropriate.
+ */
+int lttng_ust_ctl_recv_notify(int sock, enum lttng_ust_ctl_notify_cmd *notify_cmd);
+
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ */
+int lttng_ust_ctl_recv_register_event(int sock,
+       int *session_objd,              /* session descriptor (output) */
+       int *channel_objd,              /* channel descriptor (output) */
+       char *event_name,               /*
+                                        * event name (output,
+                                        * size LTTNG_UST_ABI_SYM_NAME_LEN)
+                                        */
+       int *loglevel,
+       char **signature,               /*
+                                        * event signature
+                                        * (output, dynamically
+                                        * allocated, must be free(3)'d
+                                        * by the caller if function
+                                        * returns success.)
+                                        */
+       size_t *nr_fields,
+       struct lttng_ust_ctl_field **fields,
+       char **model_emf_uri);
+
+/*
+ * Returns 0 on success, negative error value on error.
+ */
+int lttng_ust_ctl_reply_register_event(int sock,
+       uint32_t id,                    /* event id (input) */
+       int ret_code);                  /* return code. 0 ok, negative error */
+
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ */
+int lttng_ust_ctl_recv_register_enum(int sock,
+       int *session_objd,
+       char *enum_name,
+       struct lttng_ust_ctl_enum_entry **entries,
+       size_t *nr_entries);
+
+/*
+ * Returns 0 on success, negative error value on error.
+ */
+int lttng_ust_ctl_reply_register_enum(int sock,
+       uint64_t id,                    /* enum id (input) */
+       int ret_code);
+
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ */
+int lttng_ust_ctl_recv_register_channel(int sock,
+       int *session_objd,              /* session descriptor (output) */
+       int *channel_objd,              /* channel descriptor (output) */
+       size_t *nr_fields,              /* context fields */
+       struct lttng_ust_ctl_field **fields);
+
+/*
+ * Returns 0 on success, negative error value on error.
+ */
+int lttng_ust_ctl_reply_register_channel(int sock,
+       uint32_t chan_id,
+       enum lttng_ust_ctl_channel_header header_type,
+       int ret_code);                  /* return code. 0 ok, negative error */
+
+/*
+ * Counter API.
+ */
+
+enum lttng_ust_ctl_counter_bitness {
+       LTTNG_UST_CTL_COUNTER_BITNESS_32 = 0,
+       LTTNG_UST_CTL_COUNTER_BITNESS_64 = 1,
+};
+
+enum lttng_ust_ctl_counter_arithmetic {
+       LTTNG_UST_CTL_COUNTER_ARITHMETIC_MODULAR        = 0,
+       LTTNG_UST_CTL_COUNTER_ARITHMETIC_SATURATION     = 1,
+};
+
+/* Used as alloc flags. */
+enum lttng_ust_ctl_counter_alloc {
+       LTTNG_UST_CTL_COUNTER_ALLOC_PER_CPU = (1 << 0),
+       LTTNG_UST_CTL_COUNTER_ALLOC_GLOBAL = (1 << 1),
+};
+
+struct lttng_ust_ctl_daemon_counter;
+
+int lttng_ust_ctl_get_nr_cpu_per_counter(void);
+
+struct lttng_ust_ctl_counter_dimension {
+       uint64_t size;
+       uint64_t underflow_index;
+       uint64_t overflow_index;
+       uint8_t has_underflow;
+       uint8_t has_overflow;
+};
+
+struct lttng_ust_ctl_daemon_counter *
+       lttng_ust_ctl_create_counter(size_t nr_dimensions,
+               const struct lttng_ust_ctl_counter_dimension *dimensions,
+               int64_t global_sum_step,
+               int global_counter_fd,
+               int nr_counter_cpu_fds,
+               const int *counter_cpu_fds,
+               enum lttng_ust_ctl_counter_bitness bitness,
+               enum lttng_ust_ctl_counter_arithmetic arithmetic,
+               uint32_t alloc_flags,
+               bool coalesce_hits);
+
+int lttng_ust_ctl_create_counter_data(struct lttng_ust_ctl_daemon_counter *counter,
+               struct lttng_ust_abi_object_data **counter_data);
+
+int lttng_ust_ctl_create_counter_global_data(struct lttng_ust_ctl_daemon_counter *counter,
+               struct lttng_ust_abi_object_data **counter_global_data);
+int lttng_ust_ctl_create_counter_cpu_data(struct lttng_ust_ctl_daemon_counter *counter, int cpu,
+               struct lttng_ust_abi_object_data **counter_cpu_data);
+
+/*
+ * Each counter data and counter cpu data created need to be destroyed
+ * before calling lttng_ust_ctl_destroy_counter().
+ */
+void lttng_ust_ctl_destroy_counter(struct lttng_ust_ctl_daemon_counter *counter);
+
+int lttng_ust_ctl_send_counter_data_to_ust(int sock, int parent_handle,
+               struct lttng_ust_abi_object_data *counter_data);
+int lttng_ust_ctl_send_counter_global_data_to_ust(int sock,
+               struct lttng_ust_abi_object_data *counter_data,
+               struct lttng_ust_abi_object_data *counter_global_data);
+int lttng_ust_ctl_send_counter_cpu_data_to_ust(int sock,
+               struct lttng_ust_abi_object_data *counter_data,
+               struct lttng_ust_abi_object_data *counter_cpu_data);
+
+int lttng_ust_ctl_counter_read(struct lttng_ust_ctl_daemon_counter *counter,
+               const size_t *dimension_indexes,
+               int cpu, int64_t *value,
+               bool *overflow, bool *underflow);
+int lttng_ust_ctl_counter_aggregate(struct lttng_ust_ctl_daemon_counter *counter,
+               const size_t *dimension_indexes,
+               int64_t *value,
+               bool *overflow, bool *underflow);
+int lttng_ust_ctl_counter_clear(struct lttng_ust_ctl_daemon_counter *counter,
+               const size_t *dimension_indexes);
+
+void lttng_ust_ctl_sigbus_handle(void *addr);
+
+#endif /* LTTNG_UST_CTL_INTERNAL_H */
diff --git a/src/bin/lttng-sessiond/ust-error-internal.h b/src/bin/lttng-sessiond/ust-error-internal.h
deleted file mode 100644 (file)
index a5f345f..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _LTTNG_UST_ERROR_H
-#define _LTTNG_UST_ERROR_H
-
-/*
- * This header is meant for liblttng and libust internal use ONLY.
- * These declarations should NOT be considered stable API.
- */
-
-#include <limits.h>
-#include <unistd.h>
-
-#include "lttng-ust-abi.h"
-
-/*
- * ustcomm error code.
- */
-enum lttng_ust_error_code {
-       LTTNG_UST_OK = 0,                       /* Ok */
-       LTTNG_UST_ERR = 1024,                   /* Unknown Error */
-       LTTNG_UST_ERR_NOENT = 1025,             /* No entry */
-       LTTNG_UST_ERR_EXIST = 1026,             /* Object exists */
-       LTTNG_UST_ERR_INVAL = 1027,             /* Invalid argument */
-       LTTNG_UST_ERR_PERM  = 1028,             /* Permission denied */
-       LTTNG_UST_ERR_NOSYS = 1029,             /* Not implemented */
-       LTTNG_UST_ERR_EXITING = 1030,           /* Process is exiting */
-
-       LTTNG_UST_ERR_INVAL_MAGIC = 1031,       /* Invalid magic number */
-       LTTNG_UST_ERR_INVAL_SOCKET_TYPE = 1032, /* Invalid socket type */
-       LTTNG_UST_ERR_UNSUP_MAJOR = 1033,       /* Unsupported major version */
-
-       /* MUST be last element */
-       LTTNG_UST_ERR_NR,                       /* Last element */
-};
-
-/*
- * Return a human-readable error message for an lttng-ust error code.
- * code must be a positive value (or 0).
- */
-extern const char *lttng_ust_strerror(int code);
-
-#endif /* _LTTNG_UST_ERROR_H */
diff --git a/src/bin/lttng-sessiond/ust-error-internal.hpp b/src/bin/lttng-sessiond/ust-error-internal.hpp
new file mode 100644 (file)
index 0000000..1cf05f2
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _LTTNG_UST_ERROR_H
+#define _LTTNG_UST_ERROR_H
+
+/*
+ * This header is meant for liblttng and libust internal use ONLY.
+ * These declarations should NOT be considered stable API.
+ */
+
+#include <limits.h>
+#include <unistd.h>
+
+#include "lttng-ust-abi.hpp"
+
+/*
+ * ustcomm error code.
+ */
+enum lttng_ust_error_code {
+       LTTNG_UST_OK = 0,                       /* Ok */
+       LTTNG_UST_ERR = 1024,                   /* Unknown Error */
+       LTTNG_UST_ERR_NOENT = 1025,             /* No entry */
+       LTTNG_UST_ERR_EXIST = 1026,             /* Object exists */
+       LTTNG_UST_ERR_INVAL = 1027,             /* Invalid argument */
+       LTTNG_UST_ERR_PERM  = 1028,             /* Permission denied */
+       LTTNG_UST_ERR_NOSYS = 1029,             /* Not implemented */
+       LTTNG_UST_ERR_EXITING = 1030,           /* Process is exiting */
+
+       LTTNG_UST_ERR_INVAL_MAGIC = 1031,       /* Invalid magic number */
+       LTTNG_UST_ERR_INVAL_SOCKET_TYPE = 1032, /* Invalid socket type */
+       LTTNG_UST_ERR_UNSUP_MAJOR = 1033,       /* Unsupported major version */
+
+       /* MUST be last element */
+       LTTNG_UST_ERR_NR,                       /* Last element */
+};
+
+/*
+ * Return a human-readable error message for an lttng-ust error code.
+ * code must be a positive value (or 0).
+ */
+extern const char *lttng_ust_strerror(int code);
+
+#endif /* _LTTNG_UST_ERROR_H */
index a8f3da2ba7a96c088d54f373962e56311033697b..27d3070d2f453897c1112e4dedb9e173df72937d 100644 (file)
@@ -8,7 +8,7 @@
 #include <stdbool.h>
 #include <string.h>
 
-#include "ust-field-utils.h"
+#include "ust-field-utils.hpp"
 
 /*
  * The lttng_ust_ctl_field is made of a combination of C basic types
diff --git a/src/bin/lttng-sessiond/ust-field-utils.h b/src/bin/lttng-sessiond/ust-field-utils.h
deleted file mode 100644 (file)
index 39cd50b..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2018 Francis Deslauriers francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_FIELD_UTILS_H
-#define LTTNG_UST_FIELD_UTILS_H
-
-#include "lttng-ust-ctl.h"
-
-/*
- * Compare two UST fields.
- * Return 1 if both fields have identical definition, 0 otherwise.
- */
-int match_lttng_ust_ctl_field(const struct lttng_ust_ctl_field *first,
-               const struct lttng_ust_ctl_field *second);
-
-/*
- * Compare two arrays of UST fields.
- * Return true if both arrays have identical field definitions, false otherwise.
- */
-bool match_lttng_ust_ctl_field_array(const struct lttng_ust_ctl_field *first,
-               size_t nr_first,
-               const struct lttng_ust_ctl_field *second,
-               size_t nr_second);
-
-#endif /* LTTNG_UST_FIELD_UTILS_H */
diff --git a/src/bin/lttng-sessiond/ust-field-utils.hpp b/src/bin/lttng-sessiond/ust-field-utils.hpp
new file mode 100644 (file)
index 0000000..886ae52
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2018 Francis Deslauriers francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_FIELD_UTILS_H
+#define LTTNG_UST_FIELD_UTILS_H
+
+#include "lttng-ust-ctl.hpp"
+
+/*
+ * Compare two UST fields.
+ * Return 1 if both fields have identical definition, 0 otherwise.
+ */
+int match_lttng_ust_ctl_field(const struct lttng_ust_ctl_field *first,
+               const struct lttng_ust_ctl_field *second);
+
+/*
+ * Compare two arrays of UST fields.
+ * Return true if both arrays have identical field definitions, false otherwise.
+ */
+bool match_lttng_ust_ctl_field_array(const struct lttng_ust_ctl_field *first,
+               size_t nr_first,
+               const struct lttng_ust_ctl_field *second,
+               size_t nr_second);
+
+#endif /* LTTNG_UST_FIELD_UTILS_H */
index 7e6b1aba0810933f725a32b64986d8c29e9f1e82..f5c5e7a2136c9cb2a533e4f90a6f1cfa08aef811 100644 (file)
 #include <limits.h>
 #include <unistd.h>
 #include <inttypes.h>
-#include <common/common.h>
-#include <common/time.h>
+#include <common/common.hpp>
+#include <common/time.hpp>
 
-#include "ust-registry.h"
-#include "ust-clock.h"
-#include "ust-app.h"
+#include "ust-registry.hpp"
+#include "ust-clock.hpp"
+#include "ust-app.hpp"
 
 #ifndef max_t
 #define max_t(type, a, b)      ((type) ((a) > (b) ? (a) : (b)))
index 7de5336754c8adc02a71b1ba180168b72164319b..effb319994e98a89cabf01f2ad97bad9e37fe8c3 100644 (file)
@@ -8,16 +8,16 @@
 #define _LGPL_SOURCE
 #include <inttypes.h>
 
-#include <common/common.h>
-#include <common/hashtable/utils.h>
+#include <common/common.hpp>
+#include <common/hashtable/utils.hpp>
 #include <lttng/lttng.h>
 
-#include "ust-registry.h"
-#include "ust-app.h"
-#include "ust-field-utils.h"
-#include "utils.h"
-#include "lttng-sessiond.h"
-#include "notification-thread-commands.h"
+#include "ust-registry.hpp"
+#include "ust-app.hpp"
+#include "ust-field-utils.hpp"
+#include "utils.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-commands.hpp"
 
 /*
  * Hash table match function for event in the registry.
diff --git a/src/bin/lttng-sessiond/ust-registry.h b/src/bin/lttng-sessiond/ust-registry.h
deleted file mode 100644 (file)
index b77b1d8..0000000
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_REGISTRY_H
-#define LTTNG_UST_REGISTRY_H
-
-#include <pthread.h>
-#include <stdint.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/uuid.h>
-
-#include "lttng-ust-ctl.h"
-
-#define CTF_SPEC_MAJOR 1
-#define CTF_SPEC_MINOR 8
-
-struct ust_app;
-
-struct ust_registry_session {
-       /*
-        * With multiple writers and readers, use this lock to access
-        * the registry. Can nest within the ust app session lock.
-        * Also acts as a registry serialization lock. Used by registry
-        * readers to serialize the registry information sent from the
-        * sessiond to the consumerd.
-        * The consumer socket lock nests within this lock.
-        */
-       pthread_mutex_t lock;
-       /* Next channel ID available for a newly registered channel. */
-       uint32_t next_channel_id;
-       /* Once this value reaches UINT32_MAX, no more id can be allocated. */
-       uint32_t used_channel_id;
-       /* Next enumeration ID available. */
-       uint64_t next_enum_id;
-       /* Universal unique identifier used by the tracer. */
-       unsigned char uuid[LTTNG_UUID_LEN];
-
-       /* session ABI description */
-
-       /* Size of long, in bits */
-       unsigned int bits_per_long;
-       /* Alignment, in bits */
-       unsigned int uint8_t_alignment,
-               uint16_t_alignment,
-               uint32_t_alignment,
-               uint64_t_alignment,
-               long_alignment;
-       /* endianness */
-       int byte_order; /* BIG_ENDIAN or LITTLE_ENDIAN */
-
-       /* Generated metadata. */
-       char *metadata;         /* NOT null-terminated ! Use memcpy. */
-       size_t metadata_len, metadata_alloc_len;
-       /* Length of bytes sent to the consumer. */
-       size_t metadata_len_sent;
-       /* Current version of the metadata. */
-       uint64_t metadata_version;
-
-       /*
-        * Those fields are only used when a session is created with
-        * the --shm-path option. In this case, the metadata is output
-        * twice: once to the consumer, as ususal, but a second time
-        * also in the shm path directly. This is done so that a copy
-        * of the metadata that is as fresh as possible is available
-        * on the event of a crash.
-        *
-        * root_shm_path contains the shm-path provided by the user, along with
-        * the session's name and timestamp:
-        *   e.g. /tmp/my_shm/my_session-20180612-135822
-        *
-        * shm_path contains the full path of the memory buffers:
-        *   e.g. /tmp/my_shm/my_session-20180612-135822/ust/uid/1000/64-bit
-        *
-        * metadata_path contains the full path to the metadata file that
-        * is kept for the "crash buffer" extraction:
-        *  e.g. /tmp/my_shm/my_session-20180612-135822/ust/uid/1000/64-bit/metadata
-        *
-        * Note that this is not the trace's final metadata file. It is
-        * only meant to be used to read the contents of the ring buffers
-        * in the event of a crash.
-        *
-        * metadata_fd is a file descriptor that points to the file at
-        * 'metadata_path'.
-        */
-       char root_shm_path[PATH_MAX];
-       char shm_path[PATH_MAX];
-       char metadata_path[PATH_MAX];
-       int metadata_fd;        /* file-backed metadata FD */
-
-       /*
-        * Hash table containing channels sent by the UST tracer. MUST
-        * be accessed with a RCU read side lock acquired.
-        */
-       struct lttng_ht *channels;
-       /*
-        * Unique key to identify the metadata on the consumer side.
-        */
-       uint64_t metadata_key;
-       /*
-        * Indicates if the metadata is closed on the consumer side. This is to
-        * avoid double close of metadata when an application unregisters AND
-        * deletes its sessions.
-        */
-       unsigned int metadata_closed;
-
-       /* User and group owning the session. */
-       uid_t uid;
-       gid_t gid;
-
-       /* Enumerations table. */
-       struct lttng_ht *enums;
-
-       /*
-        * Copy of the tracer version when the first app is registered.
-        * It is used if we need to regenerate the metadata.
-        */
-       uint32_t major;
-       uint32_t minor;
-
-       /* The id of the parent session */
-       uint64_t tracing_id;
-       uid_t tracing_uid;
-};
-
-struct ust_registry_channel {
-       uint64_t key;
-       uint64_t consumer_key;
-       /* Id set when replying to a register channel. */
-       uint32_t chan_id;
-       enum lttng_ust_ctl_channel_header header_type;
-
-       /*
-        * Flag for this channel if the metadata was dumped once during
-        * registration. 0 means no, 1 yes.
-        */
-       unsigned int metadata_dumped;
-       /* Indicates if this channel registry has already been registered. */
-       unsigned int register_done;
-
-       /*
-        * Hash table containing events sent by the UST tracer. MUST be accessed
-        * with a RCU read side lock acquired.
-        */
-       struct lttng_ht *ht;
-       /* Next event ID available for a newly registered event. */
-       uint32_t next_event_id;
-       /* Once this value reaches UINT32_MAX, no more id can be allocated. */
-       uint32_t used_event_id;
-       /*
-        * Context fields of the registry. Context are per channel. Allocated by a
-        * register channel notification from the UST tracer.
-        */
-       size_t nr_ctx_fields;
-       struct lttng_ust_ctl_field *ctx_fields;
-       struct lttng_ht_node_u64 node;
-       /* For delayed reclaim */
-       struct rcu_head rcu_head;
-};
-
-/*
- * Event registered from a UST tracer sent to the session daemon. This is
- * indexed and matched by <event_name/signature>.
- */
-struct ust_registry_event {
-       int id;
-       /* Both objd are set by the tracer. */
-       int session_objd;
-       int channel_objd;
-       /* Name of the event returned by the tracer. */
-       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
-       char *signature;
-       int loglevel_value;
-       size_t nr_fields;
-       struct lttng_ust_ctl_field *fields;
-       char *model_emf_uri;
-       /*
-        * Flag for this channel if the metadata was dumped once during
-        * registration. 0 means no, 1 yes.
-        */
-       unsigned int metadata_dumped;
-       /*
-        * Node in the ust-registry hash table. The event name is used to
-        * initialize the node and the event_name/signature for the match function.
-        */
-       struct lttng_ht_node_u64 node;
-};
-
-struct ust_registry_enum {
-       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
-       struct lttng_ust_ctl_enum_entry *entries;
-       size_t nr_entries;
-       uint64_t id;    /* enum id in session */
-       /* Enumeration node in session hash table. */
-       struct lttng_ht_node_str node;
-       /* For delayed reclaim. */
-       struct rcu_head rcu_head;
-};
-
-/*
- * Validate that the id has reached the maximum allowed or not.
- *
- * Return 0 if NOT else 1.
- */
-static inline int ust_registry_is_max_id(uint32_t id)
-{
-       return (id == UINT32_MAX) ? 1 : 0;
-}
-
-/*
- * Return next available event id and increment the used counter. The
- * ust_registry_is_max_id function MUST be called before in order to validate
- * if the maximum number of IDs have been reached. If not, it is safe to call
- * this function.
- *
- * Return a unique channel ID. If max is reached, the used_event_id counter is
- * returned.
- */
-static inline uint32_t ust_registry_get_next_event_id(
-               struct ust_registry_channel *r)
-{
-       if (ust_registry_is_max_id(r->used_event_id)) {
-               return r->used_event_id;
-       }
-
-       r->used_event_id++;
-       return r->next_event_id++;
-}
-
-/*
- * Return next available channel id and increment the used counter. The
- * ust_registry_is_max_id function MUST be called before in order to validate
- * if the maximum number of IDs have been reached. If not, it is safe to call
- * this function.
- *
- * Return a unique channel ID. If max is reached, the used_channel_id counter
- * is returned.
- */
-static inline uint32_t ust_registry_get_next_chan_id(
-               struct ust_registry_session *r)
-{
-       if (ust_registry_is_max_id(r->used_channel_id)) {
-               return r->used_channel_id;
-       }
-
-       r->used_channel_id++;
-       return r->next_channel_id++;
-}
-
-/*
- * Return registry event count. This is read atomically.
- */
-static inline uint32_t ust_registry_get_event_count(
-               struct ust_registry_channel *r)
-{
-       return (uint32_t) uatomic_read(&r->used_event_id);
-}
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-void ust_registry_channel_destroy(struct ust_registry_session *session,
-               struct ust_registry_channel *chan);
-struct ust_registry_channel *ust_registry_channel_find(
-               struct ust_registry_session *session, uint64_t key);
-int ust_registry_channel_add(struct ust_registry_session *session,
-               uint64_t key);
-void ust_registry_channel_del_free(struct ust_registry_session *session,
-               uint64_t key, bool notif);
-
-int ust_registry_session_init(struct ust_registry_session **sessionp,
-               struct ust_app *app,
-               uint32_t bits_per_long,
-               uint32_t uint8_t_alignment,
-               uint32_t uint16_t_alignment,
-               uint32_t uint32_t_alignment,
-               uint32_t uint64_t_alignment,
-               uint32_t long_alignment,
-               int byte_order,
-               uint32_t major,
-               uint32_t minor,
-               const char *root_shm_path,
-               const char *shm_path,
-               uid_t euid,
-               gid_t egid,
-               uint64_t tracing_id,
-               uid_t tracing_uid);
-void ust_registry_session_destroy(struct ust_registry_session *session);
-
-int ust_registry_create_event(struct ust_registry_session *session,
-               uint64_t chan_key, int session_objd, int channel_objd, char *name,
-               char *sig, size_t nr_fields, struct lttng_ust_ctl_field *fields,
-               int loglevel_value, char *model_emf_uri, int buffer_type,
-               uint32_t *event_id_p, struct ust_app *app);
-struct ust_registry_event *ust_registry_find_event(
-               struct ust_registry_channel *chan, char *name, char *sig);
-void ust_registry_destroy_event(struct ust_registry_channel *chan,
-               struct ust_registry_event *event);
-
-/* app can be NULL for registry shared across applications. */
-int ust_metadata_session_statedump(struct ust_registry_session *session,
-               struct ust_app *app, uint32_t major, uint32_t minor);
-int ust_metadata_channel_statedump(struct ust_registry_session *session,
-               struct ust_registry_channel *chan);
-int ust_metadata_event_statedump(struct ust_registry_session *session,
-               struct ust_registry_channel *chan,
-               struct ust_registry_event *event);
-int ust_registry_create_or_find_enum(struct ust_registry_session *session,
-               int session_objd, char *name,
-               struct lttng_ust_ctl_enum_entry *entries, size_t nr_entries,
-               uint64_t *enum_id);
-struct ust_registry_enum *
-       ust_registry_lookup_enum_by_id(struct ust_registry_session *session,
-               const char *name, uint64_t id);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline
-void ust_registry_channel_destroy(
-               struct ust_registry_session *session __attribute__((unused)),
-               struct ust_registry_channel *chan __attribute__((unused)))
-{}
-
-static inline
-struct ust_registry_channel *ust_registry_channel_find(
-               struct ust_registry_session *session __attribute__((unused)),
-               uint64_t key __attribute__((unused)))
-{
-       return NULL;
-}
-
-static inline
-int ust_registry_channel_add(
-               struct ust_registry_session *session __attribute__((unused)),
-               uint64_t key __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-void ust_registry_channel_del_free(
-               struct ust_registry_session *session __attribute__((unused)),
-               uint64_t key __attribute__((unused)),
-               bool notif __attribute__((unused)))
-{}
-
-static inline
-int ust_registry_session_init(
-               struct ust_registry_session **sessionp __attribute__((unused)),
-               struct ust_app *app __attribute__((unused)),
-               uint32_t bits_per_long __attribute__((unused)),
-               uint32_t uint8_t_alignment __attribute__((unused)),
-               uint32_t uint16_t_alignment __attribute__((unused)),
-               uint32_t uint32_t_alignment __attribute__((unused)),
-               uint32_t uint64_t_alignment __attribute__((unused)),
-               uint32_t long_alignment __attribute__((unused)),
-               int byte_order __attribute__((unused)),
-               uint32_t major __attribute__((unused)),
-               uint32_t minor __attribute__((unused)),
-               const char *root_shm_path __attribute__((unused)),
-               const char *shm_path __attribute__((unused)),
-               uid_t euid __attribute__((unused)),
-               gid_t egid __attribute__((unused)),
-               uint64_t tracing_id __attribute__((unused)),
-               uid_t tracing_uid __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-void ust_registry_session_destroy(
-               struct ust_registry_session *session __attribute__((unused)))
-{}
-
-static inline
-int ust_registry_create_event(
-               struct ust_registry_session *session __attribute__((unused)),
-               uint64_t chan_key __attribute__((unused)),
-               int session_objd __attribute__((unused)),
-               int channel_objd __attribute__((unused)),
-               char *name __attribute__((unused)),
-               char *sig __attribute__((unused)),
-               size_t nr_fields __attribute__((unused)),
-               struct lttng_ust_ctl_field *fields __attribute__((unused)),
-               int loglevel_value __attribute__((unused)),
-               char *model_emf_uri __attribute__((unused)),
-               int buffer_type __attribute__((unused)),
-               uint32_t *event_id_p __attribute__((unused)))
-{
-       return 0;
-}
-static inline
-struct ust_registry_event *ust_registry_find_event(
-               struct ust_registry_channel *chan __attribute__((unused)),
-               char *name __attribute__((unused)),
-               char *sig __attribute__((unused)))
-{
-       return NULL;
-}
-
-static inline
-void ust_registry_destroy_event(
-               struct ust_registry_channel *chan __attribute__((unused)),
-               struct ust_registry_event *event __attribute__((unused)))
-{}
-
-/* The app object can be NULL for registry shared across applications. */
-static inline
-int ust_metadata_session_statedump(
-               struct ust_registry_session *session __attribute__((unused)),
-               struct ust_app *app __attribute__((unused)),
-               uint32_t major __attribute__((unused)),
-               uint32_t minor __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_metadata_channel_statedump(
-               struct ust_registry_session *session __attribute__((unused)),
-               struct ust_registry_channel *chan __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_metadata_event_statedump(
-               struct ust_registry_session *session __attribute__((unused)),
-               struct ust_registry_channel *chan __attribute__((unused)),
-               struct ust_registry_event *event __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-int ust_registry_create_or_find_enum(
-               struct ust_registry_session *session __attribute__((unused)),
-               int session_objd __attribute__((unused)),
-               char *name __attribute__((unused)),
-               struct lttng_ust_ctl_enum_entry *entries __attribute__((unused)),
-               size_t nr_entries __attribute__((unused)),
-               uint64_t *enum_id __attribute__((unused)))
-{
-       return 0;
-}
-
-static inline
-struct ust_registry_enum *
-       ust_registry_lookup_enum_by_id(
-               struct ust_registry_session *session __attribute__((unused)),
-               const char *name __attribute__((unused)),
-               uint64_t id __attribute__((unused)))
-{
-       return NULL;
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* LTTNG_UST_REGISTRY_H */
diff --git a/src/bin/lttng-sessiond/ust-registry.hpp b/src/bin/lttng-sessiond/ust-registry.hpp
new file mode 100644 (file)
index 0000000..3bf439f
--- /dev/null
@@ -0,0 +1,462 @@
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_REGISTRY_H
+#define LTTNG_UST_REGISTRY_H
+
+#include <pthread.h>
+#include <stdint.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/uuid.hpp>
+
+#include "lttng-ust-ctl.hpp"
+
+#define CTF_SPEC_MAJOR 1
+#define CTF_SPEC_MINOR 8
+
+struct ust_app;
+
+struct ust_registry_session {
+       /*
+        * With multiple writers and readers, use this lock to access
+        * the registry. Can nest within the ust app session lock.
+        * Also acts as a registry serialization lock. Used by registry
+        * readers to serialize the registry information sent from the
+        * sessiond to the consumerd.
+        * The consumer socket lock nests within this lock.
+        */
+       pthread_mutex_t lock;
+       /* Next channel ID available for a newly registered channel. */
+       uint32_t next_channel_id;
+       /* Once this value reaches UINT32_MAX, no more id can be allocated. */
+       uint32_t used_channel_id;
+       /* Next enumeration ID available. */
+       uint64_t next_enum_id;
+       /* Universal unique identifier used by the tracer. */
+       unsigned char uuid[LTTNG_UUID_LEN];
+
+       /* session ABI description */
+
+       /* Size of long, in bits */
+       unsigned int bits_per_long;
+       /* Alignment, in bits */
+       unsigned int uint8_t_alignment,
+               uint16_t_alignment,
+               uint32_t_alignment,
+               uint64_t_alignment,
+               long_alignment;
+       /* endianness */
+       int byte_order; /* BIG_ENDIAN or LITTLE_ENDIAN */
+
+       /* Generated metadata. */
+       char *metadata;         /* NOT null-terminated ! Use memcpy. */
+       size_t metadata_len, metadata_alloc_len;
+       /* Length of bytes sent to the consumer. */
+       size_t metadata_len_sent;
+       /* Current version of the metadata. */
+       uint64_t metadata_version;
+
+       /*
+        * Those fields are only used when a session is created with
+        * the --shm-path option. In this case, the metadata is output
+        * twice: once to the consumer, as ususal, but a second time
+        * also in the shm path directly. This is done so that a copy
+        * of the metadata that is as fresh as possible is available
+        * on the event of a crash.
+        *
+        * root_shm_path contains the shm-path provided by the user, along with
+        * the session's name and timestamp:
+        *   e.g. /tmp/my_shm/my_session-20180612-135822
+        *
+        * shm_path contains the full path of the memory buffers:
+        *   e.g. /tmp/my_shm/my_session-20180612-135822/ust/uid/1000/64-bit
+        *
+        * metadata_path contains the full path to the metadata file that
+        * is kept for the "crash buffer" extraction:
+        *  e.g. /tmp/my_shm/my_session-20180612-135822/ust/uid/1000/64-bit/metadata
+        *
+        * Note that this is not the trace's final metadata file. It is
+        * only meant to be used to read the contents of the ring buffers
+        * in the event of a crash.
+        *
+        * metadata_fd is a file descriptor that points to the file at
+        * 'metadata_path'.
+        */
+       char root_shm_path[PATH_MAX];
+       char shm_path[PATH_MAX];
+       char metadata_path[PATH_MAX];
+       int metadata_fd;        /* file-backed metadata FD */
+
+       /*
+        * Hash table containing channels sent by the UST tracer. MUST
+        * be accessed with a RCU read side lock acquired.
+        */
+       struct lttng_ht *channels;
+       /*
+        * Unique key to identify the metadata on the consumer side.
+        */
+       uint64_t metadata_key;
+       /*
+        * Indicates if the metadata is closed on the consumer side. This is to
+        * avoid double close of metadata when an application unregisters AND
+        * deletes its sessions.
+        */
+       unsigned int metadata_closed;
+
+       /* User and group owning the session. */
+       uid_t uid;
+       gid_t gid;
+
+       /* Enumerations table. */
+       struct lttng_ht *enums;
+
+       /*
+        * Copy of the tracer version when the first app is registered.
+        * It is used if we need to regenerate the metadata.
+        */
+       uint32_t major;
+       uint32_t minor;
+
+       /* The id of the parent session */
+       uint64_t tracing_id;
+       uid_t tracing_uid;
+};
+
+struct ust_registry_channel {
+       uint64_t key;
+       uint64_t consumer_key;
+       /* Id set when replying to a register channel. */
+       uint32_t chan_id;
+       enum lttng_ust_ctl_channel_header header_type;
+
+       /*
+        * Flag for this channel if the metadata was dumped once during
+        * registration. 0 means no, 1 yes.
+        */
+       unsigned int metadata_dumped;
+       /* Indicates if this channel registry has already been registered. */
+       unsigned int register_done;
+
+       /*
+        * Hash table containing events sent by the UST tracer. MUST be accessed
+        * with a RCU read side lock acquired.
+        */
+       struct lttng_ht *ht;
+       /* Next event ID available for a newly registered event. */
+       uint32_t next_event_id;
+       /* Once this value reaches UINT32_MAX, no more id can be allocated. */
+       uint32_t used_event_id;
+       /*
+        * Context fields of the registry. Context are per channel. Allocated by a
+        * register channel notification from the UST tracer.
+        */
+       size_t nr_ctx_fields;
+       struct lttng_ust_ctl_field *ctx_fields;
+       struct lttng_ht_node_u64 node;
+       /* For delayed reclaim */
+       struct rcu_head rcu_head;
+};
+
+/*
+ * Event registered from a UST tracer sent to the session daemon. This is
+ * indexed and matched by <event_name/signature>.
+ */
+struct ust_registry_event {
+       int id;
+       /* Both objd are set by the tracer. */
+       int session_objd;
+       int channel_objd;
+       /* Name of the event returned by the tracer. */
+       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+       char *signature;
+       int loglevel_value;
+       size_t nr_fields;
+       struct lttng_ust_ctl_field *fields;
+       char *model_emf_uri;
+       /*
+        * Flag for this channel if the metadata was dumped once during
+        * registration. 0 means no, 1 yes.
+        */
+       unsigned int metadata_dumped;
+       /*
+        * Node in the ust-registry hash table. The event name is used to
+        * initialize the node and the event_name/signature for the match function.
+        */
+       struct lttng_ht_node_u64 node;
+};
+
+struct ust_registry_enum {
+       char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+       struct lttng_ust_ctl_enum_entry *entries;
+       size_t nr_entries;
+       uint64_t id;    /* enum id in session */
+       /* Enumeration node in session hash table. */
+       struct lttng_ht_node_str node;
+       /* For delayed reclaim. */
+       struct rcu_head rcu_head;
+};
+
+/*
+ * Validate that the id has reached the maximum allowed or not.
+ *
+ * Return 0 if NOT else 1.
+ */
+static inline int ust_registry_is_max_id(uint32_t id)
+{
+       return (id == UINT32_MAX) ? 1 : 0;
+}
+
+/*
+ * Return next available event id and increment the used counter. The
+ * ust_registry_is_max_id function MUST be called before in order to validate
+ * if the maximum number of IDs have been reached. If not, it is safe to call
+ * this function.
+ *
+ * Return a unique channel ID. If max is reached, the used_event_id counter is
+ * returned.
+ */
+static inline uint32_t ust_registry_get_next_event_id(
+               struct ust_registry_channel *r)
+{
+       if (ust_registry_is_max_id(r->used_event_id)) {
+               return r->used_event_id;
+       }
+
+       r->used_event_id++;
+       return r->next_event_id++;
+}
+
+/*
+ * Return next available channel id and increment the used counter. The
+ * ust_registry_is_max_id function MUST be called before in order to validate
+ * if the maximum number of IDs have been reached. If not, it is safe to call
+ * this function.
+ *
+ * Return a unique channel ID. If max is reached, the used_channel_id counter
+ * is returned.
+ */
+static inline uint32_t ust_registry_get_next_chan_id(
+               struct ust_registry_session *r)
+{
+       if (ust_registry_is_max_id(r->used_channel_id)) {
+               return r->used_channel_id;
+       }
+
+       r->used_channel_id++;
+       return r->next_channel_id++;
+}
+
+/*
+ * Return registry event count. This is read atomically.
+ */
+static inline uint32_t ust_registry_get_event_count(
+               struct ust_registry_channel *r)
+{
+       return (uint32_t) uatomic_read(&r->used_event_id);
+}
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+void ust_registry_channel_destroy(struct ust_registry_session *session,
+               struct ust_registry_channel *chan);
+struct ust_registry_channel *ust_registry_channel_find(
+               struct ust_registry_session *session, uint64_t key);
+int ust_registry_channel_add(struct ust_registry_session *session,
+               uint64_t key);
+void ust_registry_channel_del_free(struct ust_registry_session *session,
+               uint64_t key, bool notif);
+
+int ust_registry_session_init(struct ust_registry_session **sessionp,
+               struct ust_app *app,
+               uint32_t bits_per_long,
+               uint32_t uint8_t_alignment,
+               uint32_t uint16_t_alignment,
+               uint32_t uint32_t_alignment,
+               uint32_t uint64_t_alignment,
+               uint32_t long_alignment,
+               int byte_order,
+               uint32_t major,
+               uint32_t minor,
+               const char *root_shm_path,
+               const char *shm_path,
+               uid_t euid,
+               gid_t egid,
+               uint64_t tracing_id,
+               uid_t tracing_uid);
+void ust_registry_session_destroy(struct ust_registry_session *session);
+
+int ust_registry_create_event(struct ust_registry_session *session,
+               uint64_t chan_key, int session_objd, int channel_objd, char *name,
+               char *sig, size_t nr_fields, struct lttng_ust_ctl_field *fields,
+               int loglevel_value, char *model_emf_uri, int buffer_type,
+               uint32_t *event_id_p, struct ust_app *app);
+struct ust_registry_event *ust_registry_find_event(
+               struct ust_registry_channel *chan, char *name, char *sig);
+void ust_registry_destroy_event(struct ust_registry_channel *chan,
+               struct ust_registry_event *event);
+
+/* app can be NULL for registry shared across applications. */
+int ust_metadata_session_statedump(struct ust_registry_session *session,
+               struct ust_app *app, uint32_t major, uint32_t minor);
+int ust_metadata_channel_statedump(struct ust_registry_session *session,
+               struct ust_registry_channel *chan);
+int ust_metadata_event_statedump(struct ust_registry_session *session,
+               struct ust_registry_channel *chan,
+               struct ust_registry_event *event);
+int ust_registry_create_or_find_enum(struct ust_registry_session *session,
+               int session_objd, char *name,
+               struct lttng_ust_ctl_enum_entry *entries, size_t nr_entries,
+               uint64_t *enum_id);
+struct ust_registry_enum *
+       ust_registry_lookup_enum_by_id(struct ust_registry_session *session,
+               const char *name, uint64_t id);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+void ust_registry_channel_destroy(
+               struct ust_registry_session *session __attribute__((unused)),
+               struct ust_registry_channel *chan __attribute__((unused)))
+{}
+
+static inline
+struct ust_registry_channel *ust_registry_channel_find(
+               struct ust_registry_session *session __attribute__((unused)),
+               uint64_t key __attribute__((unused)))
+{
+       return NULL;
+}
+
+static inline
+int ust_registry_channel_add(
+               struct ust_registry_session *session __attribute__((unused)),
+               uint64_t key __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+void ust_registry_channel_del_free(
+               struct ust_registry_session *session __attribute__((unused)),
+               uint64_t key __attribute__((unused)),
+               bool notif __attribute__((unused)))
+{}
+
+static inline
+int ust_registry_session_init(
+               struct ust_registry_session **sessionp __attribute__((unused)),
+               struct ust_app *app __attribute__((unused)),
+               uint32_t bits_per_long __attribute__((unused)),
+               uint32_t uint8_t_alignment __attribute__((unused)),
+               uint32_t uint16_t_alignment __attribute__((unused)),
+               uint32_t uint32_t_alignment __attribute__((unused)),
+               uint32_t uint64_t_alignment __attribute__((unused)),
+               uint32_t long_alignment __attribute__((unused)),
+               int byte_order __attribute__((unused)),
+               uint32_t major __attribute__((unused)),
+               uint32_t minor __attribute__((unused)),
+               const char *root_shm_path __attribute__((unused)),
+               const char *shm_path __attribute__((unused)),
+               uid_t euid __attribute__((unused)),
+               gid_t egid __attribute__((unused)),
+               uint64_t tracing_id __attribute__((unused)),
+               uid_t tracing_uid __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+void ust_registry_session_destroy(
+               struct ust_registry_session *session __attribute__((unused)))
+{}
+
+static inline
+int ust_registry_create_event(
+               struct ust_registry_session *session __attribute__((unused)),
+               uint64_t chan_key __attribute__((unused)),
+               int session_objd __attribute__((unused)),
+               int channel_objd __attribute__((unused)),
+               char *name __attribute__((unused)),
+               char *sig __attribute__((unused)),
+               size_t nr_fields __attribute__((unused)),
+               struct lttng_ust_ctl_field *fields __attribute__((unused)),
+               int loglevel_value __attribute__((unused)),
+               char *model_emf_uri __attribute__((unused)),
+               int buffer_type __attribute__((unused)),
+               uint32_t *event_id_p __attribute__((unused)))
+{
+       return 0;
+}
+static inline
+struct ust_registry_event *ust_registry_find_event(
+               struct ust_registry_channel *chan __attribute__((unused)),
+               char *name __attribute__((unused)),
+               char *sig __attribute__((unused)))
+{
+       return NULL;
+}
+
+static inline
+void ust_registry_destroy_event(
+               struct ust_registry_channel *chan __attribute__((unused)),
+               struct ust_registry_event *event __attribute__((unused)))
+{}
+
+/* The app object can be NULL for registry shared across applications. */
+static inline
+int ust_metadata_session_statedump(
+               struct ust_registry_session *session __attribute__((unused)),
+               struct ust_app *app __attribute__((unused)),
+               uint32_t major __attribute__((unused)),
+               uint32_t minor __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_metadata_channel_statedump(
+               struct ust_registry_session *session __attribute__((unused)),
+               struct ust_registry_channel *chan __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_metadata_event_statedump(
+               struct ust_registry_session *session __attribute__((unused)),
+               struct ust_registry_channel *chan __attribute__((unused)),
+               struct ust_registry_event *event __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+int ust_registry_create_or_find_enum(
+               struct ust_registry_session *session __attribute__((unused)),
+               int session_objd __attribute__((unused)),
+               char *name __attribute__((unused)),
+               struct lttng_ust_ctl_enum_entry *entries __attribute__((unused)),
+               size_t nr_entries __attribute__((unused)),
+               uint64_t *enum_id __attribute__((unused)))
+{
+       return 0;
+}
+
+static inline
+struct ust_registry_enum *
+       ust_registry_lookup_enum_by_id(
+               struct ust_registry_session *session __attribute__((unused)),
+               const char *name __attribute__((unused)),
+               uint64_t id __attribute__((unused)))
+{
+       return NULL;
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_UST_REGISTRY_H */
index 93a974eb30a34b22343f487385c7b931aa80b8cf..cecaf4d584d244a5a54c2123dc9ce88e0d62c281 100644 (file)
@@ -8,7 +8,7 @@
 #include <lttng/ust-sigbus.h>
 #include <lttng/ust-ctl.h>
 #include <lttng/lttng-export.h>
-#include "ust-sigbus.h"
+#include "ust-sigbus.hpp"
 
 LTTNG_EXPORT DEFINE_LTTNG_UST_SIGBUS_STATE();
 
diff --git a/src/bin/lttng-sessiond/ust-sigbus.h b/src/bin/lttng-sessiond/ust-sigbus.h
deleted file mode 100644 (file)
index 5c1ff2e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_SIGBUS_H
-#define LTTNG_UST_SIGBUS_H
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-void lttng_ust_handle_sigbus(void *address);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline
-void lttng_ust_handle_sigbus(void *address __attribute__((unused)))
-{
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* LTTNG_UST_SIGBUS_H */
diff --git a/src/bin/lttng-sessiond/ust-sigbus.hpp b/src/bin/lttng-sessiond/ust-sigbus.hpp
new file mode 100644 (file)
index 0000000..5c1ff2e
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_SIGBUS_H
+#define LTTNG_UST_SIGBUS_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+void lttng_ust_handle_sigbus(void *address);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+void lttng_ust_handle_sigbus(void *address __attribute__((unused)))
+{
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_UST_SIGBUS_H */
index 20b2232888195296fd0f279ba41ab17238a0ae6b..f3446bc26c5b660a18e2611617f6c2fb4e7ce17b 100644 (file)
 #include <stdlib.h>
 #include <unistd.h>
 
-#include <common/error.h>
+#include <common/error.hpp>
 
-#include "utils.h"
-#include "snapshot.h"
-#include "lttng-sessiond.h"
+#include "utils.hpp"
+#include "snapshot.hpp"
+#include "lttng-sessiond.hpp"
 
 /*
  * Write to writable pipe used to notify a thread.
diff --git a/src/bin/lttng-sessiond/utils.h b/src/bin/lttng-sessiond/utils.h
deleted file mode 100644 (file)
index 5cbf748..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_UTILS_H
-#define _LTT_UTILS_H
-
-struct lttng_ht;
-struct ltt_session;
-struct consumer_output;
-
-const char *get_home_dir(void);
-int notify_thread_pipe(int wpipe);
-int loglevels_match(int a_loglevel_type, int a_loglevel_value,
-       int b_loglevel_type, int b_loglevel_value, int loglevel_all_type);
-const char *session_get_base_path(const struct ltt_session *session);
-const char *consumer_output_get_base_path(const struct consumer_output *output);
-
-#endif /* _LTT_UTILS_H */
diff --git a/src/bin/lttng-sessiond/utils.hpp b/src/bin/lttng-sessiond/utils.hpp
new file mode 100644 (file)
index 0000000..5cbf748
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_UTILS_H
+#define _LTT_UTILS_H
+
+struct lttng_ht;
+struct ltt_session;
+struct consumer_output;
+
+const char *get_home_dir(void);
+int notify_thread_pipe(int wpipe);
+int loglevels_match(int a_loglevel_type, int a_loglevel_value,
+       int b_loglevel_type, int b_loglevel_value, int loglevel_all_type);
+const char *session_get_base_path(const struct ltt_session *session);
+const char *consumer_output_get_base_path(const struct consumer_output *output);
+
+#endif /* _LTT_UTILS_H */
index 67bd92097ecb4ce83f51a9cc9d54c42aa6379ebd..09c5171d8f99f7b055b4bf7c7f25a1d57426c3fa 100644 (file)
@@ -10,7 +10,7 @@ AUTOMAKE_OPTIONS = subdir-objects
 
 bin_PROGRAMS = lttng
 
-lttng_SOURCES = command.h conf.cpp conf.h commands/start.cpp \
+lttng_SOURCES = command.hpp conf.cpp conf.hpp commands/start.cpp \
                                commands/list.cpp commands/create.cpp commands/destroy.cpp \
                                commands/stop.cpp commands/enable_events.cpp \
                                commands/disable_events.cpp commands/enable_channels.cpp \
@@ -29,12 +29,12 @@ lttng_SOURCES = command.h conf.cpp conf.h commands/start.cpp \
                                commands/enable_rotation.cpp \
                                commands/disable_rotation.cpp \
                                commands/clear.cpp \
-                               loglevel.cpp loglevel.h \
+                               loglevel.cpp loglevel.hpp \
                                commands/add_trigger.cpp \
                                commands/list_triggers.cpp \
                                commands/remove_trigger.cpp \
-                               utils.cpp utils.h lttng.cpp \
-                               uprobe.cpp uprobe.h
+                               utils.cpp utils.hpp lttng.cpp \
+                               uprobe.cpp uprobe.hpp
 
 lttng_CXXFLAGS = $(AM_CXXFLAGS) $(POPT_CFLAGS)
 
diff --git a/src/bin/lttng/command.h b/src/bin/lttng/command.h
deleted file mode 100644 (file)
index d2e1eff..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_CMD_H
-#define _LTTNG_CMD_H
-
-#include <lttng/lttng.h>
-#include <common/common.h>
-#include <common/defaults.h>
-
-#include "conf.h"
-#include "utils.h"
-
-#define DECL_COMMAND(_name) \
-       extern int cmd_##_name(int, const char **)
-
-#ifdef LTTNG_EMBED_HELP
-# define HELP_MSG_NAME         help_msg
-# define SHOW_HELP_ERROR_LINE  ERR("Cannot show --help for `lttng-%s`", argv[0]);
-#else
-# define HELP_MSG_NAME         NULL
-# define SHOW_HELP_ERROR_LINE  ;
-#endif
-
-#define SHOW_HELP()                                                    \
-       do {                                                            \
-               ret = show_cmd_help(argv[0], HELP_MSG_NAME);            \
-                                                                       \
-               if (ret) {                                              \
-                       SHOW_HELP_ERROR_LINE                            \
-                       ret = CMD_ERROR;                                \
-               }                                                       \
-       } while (0)
-
-enum cmd_error_code {
-       CMD_SUCCESS = 0,
-       CMD_ERROR,
-       CMD_UNDEFINED,
-       CMD_FATAL,
-       CMD_WARNING,
-       CMD_UNSUPPORTED,
-};
-
-struct cmd_struct {
-       const char *name;
-       int (*func)(int argc, const char **argv);
-};
-
-DECL_COMMAND(list);
-DECL_COMMAND(status);
-DECL_COMMAND(create);
-DECL_COMMAND(destroy);
-DECL_COMMAND(start);
-DECL_COMMAND(stop);
-DECL_COMMAND(enable_events);
-DECL_COMMAND(disable_events);
-DECL_COMMAND(enable_channels);
-DECL_COMMAND(disable_channels);
-DECL_COMMAND(add_context);
-DECL_COMMAND(set_session);
-DECL_COMMAND(version);
-DECL_COMMAND(view);
-DECL_COMMAND(enable_consumer);
-DECL_COMMAND(disable_consumer);
-DECL_COMMAND(snapshot);
-DECL_COMMAND(save);
-DECL_COMMAND(load);
-DECL_COMMAND(track);
-DECL_COMMAND(untrack);
-DECL_COMMAND(metadata);
-DECL_COMMAND(regenerate);
-DECL_COMMAND(rotate);
-DECL_COMMAND(enable_rotation);
-DECL_COMMAND(disable_rotation);
-DECL_COMMAND(clear);
-DECL_COMMAND(add_trigger);
-DECL_COMMAND(list_triggers);
-DECL_COMMAND(remove_trigger);
-
-extern int cmd_help(int argc, const char **argv,
-               const struct cmd_struct commands[]);
-
-#endif /* _LTTNG_CMD_H */
diff --git a/src/bin/lttng/command.hpp b/src/bin/lttng/command.hpp
new file mode 100644 (file)
index 0000000..c707267
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_CMD_H
+#define _LTTNG_CMD_H
+
+#include <lttng/lttng.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+
+#include "conf.hpp"
+#include "utils.hpp"
+
+#define DECL_COMMAND(_name) \
+       extern int cmd_##_name(int, const char **)
+
+#ifdef LTTNG_EMBED_HELP
+# define HELP_MSG_NAME         help_msg
+# define SHOW_HELP_ERROR_LINE  ERR("Cannot show --help for `lttng-%s`", argv[0]);
+#else
+# define HELP_MSG_NAME         NULL
+# define SHOW_HELP_ERROR_LINE  ;
+#endif
+
+#define SHOW_HELP()                                                    \
+       do {                                                            \
+               ret = show_cmd_help(argv[0], HELP_MSG_NAME);            \
+                                                                       \
+               if (ret) {                                              \
+                       SHOW_HELP_ERROR_LINE                            \
+                       ret = CMD_ERROR;                                \
+               }                                                       \
+       } while (0)
+
+enum cmd_error_code {
+       CMD_SUCCESS = 0,
+       CMD_ERROR,
+       CMD_UNDEFINED,
+       CMD_FATAL,
+       CMD_WARNING,
+       CMD_UNSUPPORTED,
+};
+
+struct cmd_struct {
+       const char *name;
+       int (*func)(int argc, const char **argv);
+};
+
+DECL_COMMAND(list);
+DECL_COMMAND(status);
+DECL_COMMAND(create);
+DECL_COMMAND(destroy);
+DECL_COMMAND(start);
+DECL_COMMAND(stop);
+DECL_COMMAND(enable_events);
+DECL_COMMAND(disable_events);
+DECL_COMMAND(enable_channels);
+DECL_COMMAND(disable_channels);
+DECL_COMMAND(add_context);
+DECL_COMMAND(set_session);
+DECL_COMMAND(version);
+DECL_COMMAND(view);
+DECL_COMMAND(enable_consumer);
+DECL_COMMAND(disable_consumer);
+DECL_COMMAND(snapshot);
+DECL_COMMAND(save);
+DECL_COMMAND(load);
+DECL_COMMAND(track);
+DECL_COMMAND(untrack);
+DECL_COMMAND(metadata);
+DECL_COMMAND(regenerate);
+DECL_COMMAND(rotate);
+DECL_COMMAND(enable_rotation);
+DECL_COMMAND(disable_rotation);
+DECL_COMMAND(clear);
+DECL_COMMAND(add_trigger);
+DECL_COMMAND(list_triggers);
+DECL_COMMAND(remove_trigger);
+
+extern int cmd_help(int argc, const char **argv,
+               const struct cmd_struct commands[]);
+
+#endif /* _LTTNG_CMD_H */
index 4e4bb9fac110d5823247f56983455fad38bcf523..27d932c340ab8622225df5badd8ca1d99e5b3cce 100644 (file)
 
 #include <urcu/list.h>
 
-#include <lttng/domain-internal.h>
-#include <common/mi-lttng.h>
+#include <lttng/domain-internal.hpp>
+#include <common/mi-lttng.hpp>
 
-#include "../command.h"
+#include "../command.hpp"
 
 static char *opt_channel_name;
 static char *opt_session_name;
index 82b2c016215ce714e789ca3dbbf5abd04249eb24..acaa50c7dfff3bfb183651e3f33c5c6e33f325bc 100644 (file)
 #include <string.h>
 #include <stdarg.h>
 
-#include "../command.h"
-#include "../loglevel.h"
-#include "../uprobe.h"
+#include "../command.hpp"
+#include "../loglevel.hpp"
+#include "../uprobe.hpp"
 
 #include "common/argpar/argpar.h"
-#include "common/argpar-utils/argpar-utils.h"
-#include "common/dynamic-array.h"
-#include "common/mi-lttng.h"
-#include "common/string-utils/string-utils.h"
-#include "common/utils.h"
-#include <lttng/domain-internal.h>
+#include "common/argpar-utils/argpar-utils.hpp"
+#include "common/dynamic-array.hpp"
+#include "common/mi-lttng.hpp"
+#include "common/string-utils/string-utils.hpp"
+#include "common/utils.hpp"
+#include <lttng/domain-internal.hpp>
 /* For lttng_event_rule_type_str(). */
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
 #include <lttng/lttng.h>
-#include "common/filter/filter-ast.h"
-#include "common/filter/filter-ir.h"
-#include "common/dynamic-array.h"
+#include "common/filter/filter-ast.hpp"
+#include "common/filter/filter-ir.hpp"
+#include "common/dynamic-array.hpp"
 
 #if (LTTNG_SYMBOL_NAME_LEN == 256)
 #define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
index 61879d61d1d9fd06751c736f5fd813be57bf94f2..6c2399181105cae25aa366ccf3d71f7a8de11082 100644 (file)
 #include <stdbool.h>
 #include <lttng/lttng.h>
 
-#include "../command.h"
+#include "../command.hpp"
 
-#include <common/mi-lttng.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
 
 static int opt_clear_all;
 
index 2385fd70e8216a8fd6ef7bc0b4817305e3f9a3b7..c5c918ce98d0df51abbdeef7ff44eb148b988e6c 100644 (file)
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
 #include <unistd.h>
 #include <signal.h>
 #include <sys/wait.h>
 
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
 
-#include "../command.h"
-#include "../utils.h"
+#include "../command.hpp"
+#include "../utils.hpp"
 
-#include <common/defaults.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-#include <common/utils.h>
-#include <common/path.h>
+#include <common/defaults.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
 #include <lttng/lttng.h>
 
 static char *opt_output_path;
index ed09b650937055fd4e990a4335797cc18e6c3444..3ab9b224849180052f9755036abd279ab794fe6b 100644 (file)
 #include <stdbool.h>
 #include <lttng/lttng.h>
 
-#include "../command.h"
+#include "../command.hpp"
 
-#include <common/mi-lttng.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
 
 static char *opt_session_name;
 static int opt_destroy_all;
index 843fecd878b8d20afb032928ee626c11036486f1..df9eb13fac04a52f8334efbedab5ae2f38cd73b6 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/mi-lttng.h>
-#include <lttng/domain-internal.h>
+#include <common/mi-lttng.hpp>
+#include <lttng/domain-internal.hpp>
 
-#include "../command.h"
+#include "../command.hpp"
 
 static char *opt_channels;
 static int opt_kernel;
index b269f138cbb4060f2812a7b35cc05b94e5fc45e5..d2948ac041928814f51a7ebd0610b5811fcecfee 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/mi-lttng.h>
-#include <lttng/domain-internal.h>
+#include <common/mi-lttng.hpp>
+#include <lttng/domain-internal.hpp>
 
-#include "../command.h"
+#include "../command.hpp"
 
 static char *opt_event_list;
 static int opt_kernel;
index 8229f63e01bb4608d337759e7132c3a7f6160344..c2b6728ae758f0da0117213d5027d7b3ed7a0a01 100644 (file)
 #include <inttypes.h>
 #include <ctype.h>
 
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/mi-lttng.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/mi-lttng.hpp>
 
-#include "../command.h"
+#include "../command.hpp"
 #include <lttng/lttng.h>
 
 static char *opt_session_name;
index d62aa8656c51a84b395bda2f461e3b98b632a8ea..25327473f86109c3b736902942da9429b7c8bfa8 100644 (file)
 #include <inttypes.h>
 #include <ctype.h>
 
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
-#include <common/mi-lttng.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+#include <common/mi-lttng.hpp>
 
-#include <lttng/domain-internal.h>
+#include <lttng/domain-internal.hpp>
 
-#include "../command.h"
-#include "../utils.h"
+#include "../command.hpp"
+#include "../utils.hpp"
 
 
 static struct lttng_channel chan_opts;
index a2db2cbc22884f3a51c2c1355e42478075deb2d3..9d9a28ab86486cdd1c1bcb9b9e113094a5101f64 100644 (file)
 #include <inttypes.h>
 #include <ctype.h>
 
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/compat/string.h>
-#include <common/compat/getenv.h>
-#include <common/string-utils/string-utils.h>
-#include <common/utils.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/compat/string.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <common/utils.hpp>
 
 /* Mi dependancy */
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
 
-#include <lttng/domain-internal.h>
-#include <lttng/event-internal.h>
+#include <lttng/domain-internal.hpp>
+#include <lttng/event-internal.hpp>
 
-#include "../command.h"
-#include "../loglevel.h"
-#include "../uprobe.h"
+#include "../command.hpp"
+#include "../loglevel.hpp"
+#include "../uprobe.hpp"
 
 #if (LTTNG_SYMBOL_NAME_LEN == 256)
 #define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API    "255"
index 1719f3ac243dd166f3a347399afefcbeea08539a..223d47ccafe583e2736b4ce30db1f043bdb45de1 100644 (file)
 #include <inttypes.h>
 #include <ctype.h>
 
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/mi-lttng.h>
-#include <common/utils.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/utils.hpp>
 
-#include "../command.h"
+#include "../command.hpp"
 #include <lttng/lttng.h>
 
 static char *opt_session_name;
index a9a01e7f14a65db8084e5b8cdbdaa6c0ad038c8d..74b64964443aa184eb8ac7762491f4cac2e37037 100644 (file)
@@ -11,8 +11,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "../command.h"
-#include <common/utils.h>
+#include "../command.hpp"
+#include <common/utils.hpp>
 
 #ifdef LTTNG_EMBED_HELP
 static const char *help_msg =
index 9046c465885424160ffe63ae878c92b35ce42fa1..444a96b40a5e4957177109777196360c7ce9adf7 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#include <common/mi-lttng.h>
-#include <common/time.h>
-#include <common/tracker.h>
-#include <lttng/domain-internal.h>
+#include <common/mi-lttng.hpp>
+#include <common/time.hpp>
+#include <common/tracker.hpp>
+#include <lttng/domain-internal.hpp>
 #include <lttng/lttng.h>
 
-#include "../command.h"
+#include "../command.hpp"
 
 static int opt_userspace;
 static int opt_kernel;
index e6860380f2a8db0bbbe0cd99c6c1e585fa2200b5..e7075844520eaeb7da3a90f086545e047969ac5c 100644 (file)
@@ -7,21 +7,21 @@
 
 #include <stdio.h>
 
-#include "../command.h"
+#include "../command.hpp"
 
 #include "common/argpar/argpar.h"
-#include "common/argpar-utils/argpar-utils.h"
-#include "common/dynamic-array.h"
-#include "common/mi-lttng.h"
+#include "common/argpar-utils/argpar-utils.hpp"
+#include "common/dynamic-array.hpp"
+#include "common/mi-lttng.hpp"
 /* For lttng_condition_type_str(). */
-#include "lttng/condition/condition-internal.h"
+#include "lttng/condition/condition-internal.hpp"
 #include "lttng/condition/event-rule-matches.h"
-#include "lttng/condition/event-rule-matches-internal.h"
+#include "lttng/condition/event-rule-matches-internal.hpp"
 /* For lttng_domain_type_str(). */
-#include "lttng/domain-internal.h"
+#include "lttng/domain-internal.hpp"
 /* For lttng_event_rule_kernel_syscall_emission_site_str() */
-#include "lttng/event-rule/kernel-syscall-internal.h"
-#include "../loglevel.h"
+#include "lttng/event-rule/kernel-syscall-internal.hpp"
+#include "../loglevel.hpp"
 #include <lttng/lttng.h>
 
 #ifdef LTTNG_EMBED_HELP
index cdc3905168a7b12ee37c8f34f99d88364c4315ff..2ab005f2a3a029546a370e8141e0cf1af9c3531f 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#include <common/mi-lttng.h>
-#include <common/config/session-config.h>
+#include <common/mi-lttng.hpp>
+#include <common/config/session-config.hpp>
 #include <lttng/lttng.h>
 
-#include "../command.h"
+#include "../command.hpp"
 
 static char *the_opt_input_path;
 static char *the_opt_override_url;
index 8f4d8df632235c508cbdc3657f32bff7c28322d6..38e99b4a408a2891298c729c6f28319732bdcd1b 100644 (file)
@@ -13,9 +13,9 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
 
-#include "../command.h"
+#include "../command.hpp"
 
 static char *opt_session_name;
 static char *session_name = NULL;
index d25e883d54574a1ef947f8c6e7365c79237885a5..936b7d7ca3111247ece764c2ae981714151f1eff 100644 (file)
@@ -13,9 +13,9 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
 
-#include "../command.h"
+#include "../command.hpp"
 
 static char *opt_session_name;
 static char *session_name = NULL;
index a84b552dfb1d3aab583ebac0fbe525f828c7f3dd..65b5e79a9b4b18b562e536772b87bfd4f94e0a89 100644 (file)
@@ -5,10 +5,10 @@
  *
  */
 
-#include "../command.h"
+#include "../command.hpp"
 #include "common/argpar/argpar.h"
-#include "common/argpar-utils/argpar-utils.h"
-#include "common/mi-lttng.h"
+#include "common/argpar-utils/argpar-utils.hpp"
+#include "common/mi-lttng.hpp"
 #include <lttng/lttng.h>
 #include <stdio.h>
 
index 63cf3882a55a9b6b4a00453c531dfa5c18bd3fd4..339e39598891505d3b62eafffc123be901b445dd 100644 (file)
 #include <inttypes.h>
 #include <ctype.h>
 
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/mi-lttng.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/mi-lttng.hpp>
 
-#include "../command.h"
+#include "../command.hpp"
 #include <lttng/lttng.h>
 
 static char *opt_session_name;
index 4231922ad3f724f5ac36995184efd5c6053e7cdb..9b939102ccb8c8d8511c7cbefedd6c8c702645d6 100644 (file)
@@ -12,9 +12,9 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
 
-#include "../command.h"
+#include "../command.hpp"
 #include <lttng/lttng.h>
 
 static char *opt_output_path;
index ed1b1640f21d7ce008dabb8894d980415c0d7030..770921292996ac1151584b95db361a1a8bc0901e 100644 (file)
@@ -14,9 +14,9 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
 
-#include "../command.h"
+#include "../command.hpp"
 
 static char *opt_session_name;
 
index a5cbbfe759f5c16c25ea0a87bf8789a8e9627576..bc0dd8b4ecfe52eeeed87c5897c23b69bb8607ba 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/utils.h>
-#include <common/mi-lttng.h>
+#include <common/utils.hpp>
+#include <common/mi-lttng.hpp>
 #include <lttng/lttng.h>
 
-#include "../command.h"
+#include "../command.hpp"
 
 static const char *opt_session_name;
 static const char *opt_output_name;
index 69bd9221fe475cb93668964efc29620688e315e2..4d2b40a5064f5977c900f6a9f014867801d97fff 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/mi-lttng.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/mi-lttng.hpp>
 
-#include "../command.h"
+#include "../command.hpp"
 
 
 static char *opt_session_name;
index 23e8c03d390bc8fa2007cd82e7e271ec5bcda810..a77830ece028d002ba0cf97ac30019ff585d7267 100644 (file)
@@ -14,8 +14,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "../command.h"
-#include "../utils.h"
+#include "../command.hpp"
+#include "../utils.hpp"
 #include <config.h>
 
 #ifdef LTTNG_EMBED_HELP
index ec7da898c4b28c13a71cdbcd1038e125d4ff5504..6107dc15808abd883c08c0de245e3a80ed2d18b3 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/mi-lttng.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/mi-lttng.hpp>
 
-#include "../command.h"
+#include "../command.hpp"
 
 static char *opt_session_name;
 static int opt_no_wait;
index de377430ca51388968f040eb128e36a998ba458a..f7b268f71d11edbb7087771d27e829e498f89467 100644 (file)
 
 #include <urcu/list.h>
 
-#include <common/dynamic-array.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/dynamic-buffer.h>
-#include <common/tracker.h>
+#include <common/dynamic-array.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/tracker.hpp>
 
 #include <lttng/lttng.h>
 
-#include "../command.h"
+#include "../command.hpp"
 
 struct process_attr_command_args {
        enum lttng_process_attr process_attr;
index 2126e20b7959fe9fe0acaba86a0e8bf26d19a6f0..e4aed95ad8ac3ad442442240098598c9e05ffe95 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
 
-#include "../command.h"
-#include "version.h"
+#include "../command.hpp"
+#include "version.hpp"
 
 #ifdef LTTNG_EMBED_HELP
 static const char help_msg[] =
index a2623fe49e0ccb66b4baecbf1f27552d22ffad43..1bf2648714193fd9270c57ef30931224c759ed09 100644 (file)
@@ -14,8 +14,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/spawn-viewer.h>
-#include "../command.h"
+#include <common/spawn-viewer.hpp>
+#include "../command.hpp"
 
 static char *opt_session_name;
 static char *opt_viewer;
index 4e22ca005c3202917c9f3dbb04a65df1ea7d3d28..d79fba989f1368bc75cfcb2575f8b459b232b7cb 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/compat/errno.h>
-#include <common/common.h>
-#include <common/utils.h>
+#include <common/compat/errno.hpp>
+#include <common/common.hpp>
+#include <common/utils.hpp>
 
-#include "conf.h"
+#include "conf.hpp"
 
 /*
  * Returns the path with '/CONFIG_FILENAME' added to it;
diff --git a/src/bin/lttng/conf.h b/src/bin/lttng/conf.h
deleted file mode 100644 (file)
index e1260c7..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_CONFIG_H
-#define _LTTNG_CONFIG_H
-
-#define CONFIG_FILENAME ".lttngrc"
-
-void config_destroy(const char *path);
-void config_destroy_default(void);
-int config_exists(const char *path);
-int config_init(const char *path);
-int config_add_session_name(const char *path, const char *name);
-
-/* Must free() the return pointer */
-char *config_read_session_name(const char *path);
-char *config_read_session_name_quiet(const char *path);
-char *config_get_file_path(const char *path);
-
-#endif /* _LTTNG_CONFIG_H */
diff --git a/src/bin/lttng/conf.hpp b/src/bin/lttng/conf.hpp
new file mode 100644 (file)
index 0000000..e1260c7
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_CONFIG_H
+#define _LTTNG_CONFIG_H
+
+#define CONFIG_FILENAME ".lttngrc"
+
+void config_destroy(const char *path);
+void config_destroy_default(void);
+int config_exists(const char *path);
+int config_init(const char *path);
+int config_add_session_name(const char *path, const char *name);
+
+/* Must free() the return pointer */
+char *config_read_session_name(const char *path);
+char *config_read_session_name_quiet(const char *path);
+char *config_get_file_path(const char *path);
+
+#endif /* _LTTNG_CONFIG_H */
index 83c7b3048f02b1202f1aee312b7cff2ebcc15628..fe588bd8e01d957727e2acd7a3e04d42c23cc994 100644 (file)
@@ -5,7 +5,7 @@
  *
  */
 
-#include "loglevel.h"
+#include "loglevel.hpp"
 #include <string.h>
 #include <strings.h>
 #include <ctype.h>
diff --git a/src/bin/lttng/loglevel.h b/src/bin/lttng/loglevel.h
deleted file mode 100644 (file)
index 43ae8e4..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_LOGLEVEL_UTILS_H
-#define _LTTNG_LOGLEVEL_UTILS_H
-
-#include <lttng/lttng.h>
-#include <common/macros.h>
-
-int loglevel_name_to_value(const char *name, enum lttng_loglevel *loglevel);
-
-bool loglevel_parse_range_string(const char *str,
-               enum lttng_loglevel *min,
-               enum lttng_loglevel *max);
-
-int loglevel_log4j_name_to_value(
-               const char *name, enum lttng_loglevel_log4j *loglevel);
-
-bool loglevel_log4j_parse_range_string(const char *str,
-               enum lttng_loglevel_log4j *min,
-               enum lttng_loglevel_log4j *max);
-
-int loglevel_jul_name_to_value(
-               const char *name, enum lttng_loglevel_jul *loglevel);
-
-bool loglevel_jul_parse_range_string(const char *str,
-               enum lttng_loglevel_jul *min,
-               enum lttng_loglevel_jul *max);
-
-int loglevel_python_name_to_value(
-               const char *name, enum lttng_loglevel_python *loglevel);
-
-bool loglevel_python_parse_range_string(const char *str,
-               enum lttng_loglevel_python *min,
-               enum lttng_loglevel_python *max);
-
-const char *loglevel_value_to_name(int loglevel);
-
-const char *loglevel_log4j_value_to_name(int loglevel);
-
-const char *loglevel_jul_value_to_name(int loglevel);
-
-const char *loglevel_python_value_to_name(int loglevel);
-
-#endif /* _LTTNG_LOGLEVEL_UTILS_H */
diff --git a/src/bin/lttng/loglevel.hpp b/src/bin/lttng/loglevel.hpp
new file mode 100644 (file)
index 0000000..f2cc913
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_LOGLEVEL_UTILS_H
+#define _LTTNG_LOGLEVEL_UTILS_H
+
+#include <lttng/lttng.h>
+#include <common/macros.hpp>
+
+int loglevel_name_to_value(const char *name, enum lttng_loglevel *loglevel);
+
+bool loglevel_parse_range_string(const char *str,
+               enum lttng_loglevel *min,
+               enum lttng_loglevel *max);
+
+int loglevel_log4j_name_to_value(
+               const char *name, enum lttng_loglevel_log4j *loglevel);
+
+bool loglevel_log4j_parse_range_string(const char *str,
+               enum lttng_loglevel_log4j *min,
+               enum lttng_loglevel_log4j *max);
+
+int loglevel_jul_name_to_value(
+               const char *name, enum lttng_loglevel_jul *loglevel);
+
+bool loglevel_jul_parse_range_string(const char *str,
+               enum lttng_loglevel_jul *min,
+               enum lttng_loglevel_jul *max);
+
+int loglevel_python_name_to_value(
+               const char *name, enum lttng_loglevel_python *loglevel);
+
+bool loglevel_python_parse_range_string(const char *str,
+               enum lttng_loglevel_python *min,
+               enum lttng_loglevel_python *max);
+
+const char *loglevel_value_to_name(int loglevel);
+
+const char *loglevel_log4j_value_to_name(int loglevel);
+
+const char *loglevel_jul_value_to_name(int loglevel);
+
+const char *loglevel_python_value_to_name(int loglevel);
+
+#endif /* _LTTNG_LOGLEVEL_UTILS_H */
index 27e332e07b8b1ee57ed5da2979e4c8b6306e146c..7e70c3afce4f9e22b03e628bdda0b6344635d6ae 100644 (file)
 #include <ctype.h>
 
 #include <lttng/lttng.h>
-#include <common/error.h>
-#include <common/compat/getenv.h>
-#include <common/utils.h>
+#include <common/error.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/utils.hpp>
 
-#include "command.h"
-#include "version.h"
+#include "command.hpp"
+#include "version.hpp"
 
 static const char *help_msg =
 #ifdef LTTNG_EMBED_HELP
index 21b5e90e6b2bcc60173ab9954ac03c84084e3785..07ac5d5fa5ab6d9d30fadf31f8492455f9f689b8 100644 (file)
@@ -5,19 +5,19 @@
  *
  */
 
-#include "uprobe.h"
+#include "uprobe.hpp"
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include "common/compat/getenv.h"
-#include "common/string-utils/string-utils.h"
-#include "common/utils.h"
-#include "common/path.h"
+#include "common/compat/getenv.hpp"
+#include "common/string-utils/string-utils.hpp"
+#include "common/utils.hpp"
+#include "common/path.hpp"
 #include "lttng/constant.h"
 
-#include "command.h"
+#include "command.hpp"
 
 /*
  * Walk the directories in the PATH environment variable to find the target
diff --git a/src/bin/lttng/uprobe.h b/src/bin/lttng/uprobe.h
deleted file mode 100644 (file)
index 54dc674..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2020 EfficiOS, Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SRC_BIN_LTTNG_UPROBE_H
-#define SRC_BIN_LTTNG_UPROBE_H
-
-#include <common/macros.h>
-
-struct lttng_userspace_probe_location;
-
-int parse_userspace_probe_opts(const char *opt,
-               struct lttng_userspace_probe_location **uprobe_loc);
-
-#endif /* SRC_BIN_LTTNG_UPROBE_H */
diff --git a/src/bin/lttng/uprobe.hpp b/src/bin/lttng/uprobe.hpp
new file mode 100644 (file)
index 0000000..8373312
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2020 EfficiOS, Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SRC_BIN_LTTNG_UPROBE_H
+#define SRC_BIN_LTTNG_UPROBE_H
+
+#include <common/macros.hpp>
+
+struct lttng_userspace_probe_location;
+
+int parse_userspace_probe_opts(const char *opt,
+               struct lttng_userspace_probe_location **uprobe_loc);
+
+#endif /* SRC_BIN_LTTNG_UPROBE_H */
index 528318b2af6bf10f442447720641da59c344df7e..9a9f39bf2529b1cd6328f5052b73672715d12663 100644 (file)
 #include <inttypes.h>
 #include <unistd.h>
 
-#include <common/error.h>
-#include <common/utils.h>
-#include <common/defaults.h>
+#include <common/error.hpp>
+#include <common/utils.hpp>
+#include <common/defaults.hpp>
 
-#include "conf.h"
-#include "utils.h"
-#include "command.h"
+#include "conf.hpp"
+#include "utils.hpp"
+#include "command.hpp"
 
 static const char *str_all = "ALL";
 static const char *str_tracepoint = "Tracepoint";
diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h
deleted file mode 100644 (file)
index 0cf01db..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_UTILS_H
-#define _LTTNG_UTILS_H
-
-#include <popt.h>
-#include <common/argpar/argpar.h>
-#include <common/dynamic-array.h>
-
-#include <lttng/lttng.h>
-
-extern char *opt_relayd_path;
-extern int opt_no_sessiond;
-extern char * opt_sessiond_path;
-extern pid_t sessiond_pid;
-
-struct cmd_struct;
-
-char *get_session_name(void);
-char *get_session_name_quiet(void);
-void list_commands(struct cmd_struct *commands, FILE *ofp);
-void list_cmd_options(FILE *ofp, struct poptOption *options);
-void list_cmd_options_argpar(FILE *ofp, const struct argpar_opt_descr *options);
-
-/*
- * Return the minimum order for which x <= (1UL << order).
- * Return -1 if x is 0.
- */
-int get_count_order_u32(uint32_t x);
-
-/*
- * Return the minimum order for which x <= (1UL << order).
- * Return -1 if x is 0.
- */
-int get_count_order_u64(uint64_t x);
-
-/*
- * Return the minimum order for which x <= (1UL << order).
- * Return -1 if x is 0.
- */
-int get_count_order_ulong(unsigned long x);
-
-const char *get_event_type_str(enum lttng_event_type event_type);
-
-int print_missing_or_multiple_domains(unsigned int domain_count,
-               bool include_agent_domains);
-
-int spawn_relayd(const char *pathname, int port);
-int check_relayd(void);
-void print_session_stats(const char *session_name);
-int get_session_stats_str(const char *session_name, char **str);
-int show_cmd_help(const char *cmd_name, const char *help_msg);
-
-int print_trace_archive_location(
-               const struct lttng_trace_archive_location *location,
-               const char *session_name);
-
-int validate_exclusion_list(const char *event_name,
-               const struct lttng_dynamic_pointer_array *exclusions);
-
-#endif /* _LTTNG_UTILS_H */
diff --git a/src/bin/lttng/utils.hpp b/src/bin/lttng/utils.hpp
new file mode 100644 (file)
index 0000000..bb1c2cd
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_UTILS_H
+#define _LTTNG_UTILS_H
+
+#include <popt.h>
+#include <common/argpar/argpar.h>
+#include <common/dynamic-array.hpp>
+
+#include <lttng/lttng.h>
+
+extern char *opt_relayd_path;
+extern int opt_no_sessiond;
+extern char * opt_sessiond_path;
+extern pid_t sessiond_pid;
+
+struct cmd_struct;
+
+char *get_session_name(void);
+char *get_session_name_quiet(void);
+void list_commands(struct cmd_struct *commands, FILE *ofp);
+void list_cmd_options(FILE *ofp, struct poptOption *options);
+void list_cmd_options_argpar(FILE *ofp, const struct argpar_opt_descr *options);
+
+/*
+ * Return the minimum order for which x <= (1UL << order).
+ * Return -1 if x is 0.
+ */
+int get_count_order_u32(uint32_t x);
+
+/*
+ * Return the minimum order for which x <= (1UL << order).
+ * Return -1 if x is 0.
+ */
+int get_count_order_u64(uint64_t x);
+
+/*
+ * Return the minimum order for which x <= (1UL << order).
+ * Return -1 if x is 0.
+ */
+int get_count_order_ulong(unsigned long x);
+
+const char *get_event_type_str(enum lttng_event_type event_type);
+
+int print_missing_or_multiple_domains(unsigned int domain_count,
+               bool include_agent_domains);
+
+int spawn_relayd(const char *pathname, int port);
+int check_relayd(void);
+void print_session_stats(const char *session_name);
+int get_session_stats_str(const char *session_name, char **str);
+int show_cmd_help(const char *cmd_name, const char *help_msg);
+
+int print_trace_archive_location(
+               const struct lttng_trace_archive_location *location,
+               const char *session_name);
+
+int validate_exclusion_list(const char *event_name,
+               const struct lttng_dynamic_pointer_array *exclusions);
+
+#endif /* _LTTNG_UTILS_H */
index 9d3ca129432c25db185b8bea77671ff465ca049e..b0191dd472aa9aae5f22e337864e73545b1e08c9 100644 (file)
@@ -6,17 +6,17 @@ noinst_LTLIBRARIES =
 BUILT_SOURCES =
 
 noinst_HEADERS = \
-       align.h \
-       bug.h \
-       defaults.h \
-       error.h \
-       futex.h \
-       lttng-kernel.h \
-       lttng-kernel-old.h \
-       macros.h \
-       time.h \
-       uri.h \
-       utils.h
+       align.hpp \
+       bug.hpp \
+       defaults.hpp \
+       error.hpp \
+       futex.hpp \
+       lttng-kernel.hpp \
+       lttng-kernel-old.hpp \
+       macros.hpp \
+       time.hpp \
+       uri.hpp \
+       utils.hpp
 
 
 # libargpar
@@ -30,14 +30,14 @@ libargpar_la_SOURCES = \
 noinst_LTLIBRARIES += libargpar-utils.la
 libargpar_utils_la_SOURCES = \
        argpar-utils/argpar-utils.cpp \
-       argpar-utils/argpar-utils.h
+       argpar-utils/argpar-utils.hpp
 
 
 # libbytecode
 noinst_LTLIBRARIES += libbytecode.la
 libbytecode_la_SOURCES = \
        bytecode/bytecode.cpp \
-       bytecode/bytecode.h
+       bytecode/bytecode.hpp
 
 
 # The libcommon-lgpl static archive contains only LGPLv2.1 code. It is
@@ -55,20 +55,20 @@ libcommon_lgpl_la_SOURCES = \
        actions/start-session.cpp \
        actions/stop-session.cpp \
        actions/rate-policy.cpp \
-       buffer-view.h buffer-view.cpp \
+       buffer-view.hpp buffer-view.cpp \
        channel.cpp \
        conditions/buffer-usage.cpp \
        conditions/condition.cpp \
        conditions/event-rule-matches.cpp \
        conditions/session-consumed-size.cpp \
        conditions/session-rotation.cpp \
-       credentials.cpp credentials.h \
+       credentials.cpp credentials.hpp \
        defaults.cpp \
        domain.cpp \
-       dynamic-array.cpp dynamic-array.h \
-       dynamic-buffer.cpp dynamic-buffer.h \
+       dynamic-array.cpp dynamic-array.hpp \
+       dynamic-buffer.cpp dynamic-buffer.hpp \
        endpoint.cpp \
-       error.cpp error.h \
+       error.cpp error.hpp \
        error-query.cpp \
        evaluation.cpp \
        event.cpp \
@@ -83,31 +83,31 @@ libcommon_lgpl_la_SOURCES = \
        event-rule/log4j-logging.cpp \
        event-rule/jul-logging.cpp \
        event-rule/python-logging.cpp \
-       fd-handle.cpp fd-handle.h \
+       fd-handle.cpp fd-handle.hpp\
        kernel-probe.cpp \
        location.cpp \
        log-level-rule.cpp \
-       mi-lttng.cpp mi-lttng.h \
+       mi-lttng.cpp mi-lttng.hpp \
        notification.cpp \
-       payload.cpp payload.h \
-       payload-view.cpp payload-view.h \
-       readwrite.cpp readwrite.h \
-       runas.cpp runas.h \
+       payload.cpp payload.hpp \
+       payload-view.cpp payload-view.hpp \
+       readwrite.cpp readwrite.hpp \
+       runas.cpp runas.hpp \
        session-descriptor.cpp \
-       snapshot.cpp snapshot.h \
-       spawn-viewer.cpp spawn-viewer.h \
-       thread.cpp thread.h \
+       snapshot.cpp snapshot.hpp \
+       spawn-viewer.cpp spawn-viewer.hpp \
+       thread.cpp thread.hpp \
        time.cpp \
-       tracker.cpp tracker.h \
+       tracker.cpp tracker.hpp \
        trigger.cpp \
-       unix.cpp unix.h \
-       uri.cpp uri.h \
+       unix.cpp unix.hpp \
+       uri.cpp uri.hpp \
        userspace-probe.cpp \
-       utils.cpp utils.h
+       utils.cpp utils.hpp
 
 if HAVE_ELF_H
 libcommon_lgpl_la_SOURCES += \
-       lttng-elf.cpp lttng-elf.h
+       lttng-elf.cpp lttng-elf.hpp
 endif
 
 libcommon_lgpl_la_LIBADD = \
@@ -123,27 +123,27 @@ libcommon_lgpl_la_LIBADD = \
 # meant to be used by GPL executables.
 noinst_LTLIBRARIES += libpath.la
 libpath_la_SOURCES = \
-       path.cpp path.h
+       path.cpp path.hpp
 
 
 # The libcommon-gpl static archive contains GPLv2 compatible code. It is
 # meant to be used by GPL executables.
 noinst_LTLIBRARIES += libcommon-gpl.la
 libcommon_gpl_la_SOURCES = \
-       common.h \
-       context.cpp context.h \
-       daemonize.cpp daemonize.h \
-       filter.cpp filter.h \
-       fs-handle.cpp fs-handle.h fs-handle-internal.h \
-       futex.cpp futex.h \
-       index-allocator.cpp index-allocator.h \
-       optional.h \
-       pipe.cpp pipe.h \
-       shm.cpp shm.h \
-       trace-chunk.cpp trace-chunk.h \
-       trace-chunk-registry.h \
-       uuid.cpp uuid.h \
-       waiter.cpp waiter.h
+       common.hpp \
+       context.cpp context.hpp \
+       daemonize.cpp daemonize.hpp \
+       filter.cpp filter.hpp \
+       fs-handle.cpp fs-handle.hpp fs-handle-internal.hpp \
+       futex.cpp futex.hpp \
+       index-allocator.cpp index-allocator.hpp \
+       optional.hpp \
+       pipe.cpp pipe.hpp \
+       shm.cpp shm.hpp \
+       trace-chunk.cpp trace-chunk.hpp \
+       trace-chunk-registry.hpp \
+       uuid.cpp uuid.hpp \
+       waiter.cpp waiter.hpp
 
 libcommon_gpl_la_LIBADD = \
        libcommon-lgpl.la \
@@ -158,32 +158,32 @@ noinst_LTLIBRARIES += libcompat.la
 libcompat_la_SOURCES = \
         compat/compat-fcntl.cpp \
         compat/directory-handle.cpp \
-        compat/directory-handle.h \
-        compat/dirent.h \
-        compat/endian.h \
-        compat/errno.h \
-        compat/fcntl.h \
-        compat/getenv.h \
-        compat/mman.h \
-        compat/netdb.h \
-        compat/path.h \
-        compat/paths.h \
+        compat/directory-handle.hpp \
+        compat/dirent.hpp \
+        compat/endian.hpp \
+        compat/errno.hpp \
+        compat/fcntl.hpp \
+        compat/getenv.hpp \
+        compat/mman.hpp \
+        compat/netdb.hpp \
+        compat/path.hpp \
+        compat/paths.hpp \
         compat/poll.cpp \
-        compat/poll.h \
-        compat/pthread.h \
-        compat/socket.h \
-        compat/string.h \
-        compat/tid.h \
-        compat/time.h
+        compat/poll.hpp \
+        compat/pthread.hpp \
+        compat/socket.hpp \
+        compat/string.hpp \
+        compat/tid.hpp \
+        compat/time.hpp
 
 
 # libconfig
 noinst_LTLIBRARIES += libconfig.la
 libconfig_la_SOURCES = \
-       config/config-internal.h \
-       config/config-session-abi.h \
+       config/config-internal.hpp \
+       config/config-session-abi.hpp \
        config/session-config.cpp \
-       config/session-config.h
+       config/session-config.hpp
 
 libconfig_la_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS)
 libconfig_la_LIBADD = ${libxml2_LIBS}
@@ -194,16 +194,16 @@ noinst_LTLIBRARIES += libconsumer.la
 
 libconsumer_la_SOURCES = \
        consumer/consumer.cpp \
-       consumer/consumer.h \
+       consumer/consumer.hpp \
        consumer/consumer-metadata-cache.cpp \
-       consumer/consumer-metadata-cache.h \
+       consumer/consumer-metadata-cache.hpp \
        consumer/consumer-stream.cpp \
-       consumer/consumer-stream.h \
-       consumer/consumer-testpoint.h \
+       consumer/consumer-stream.hpp \
+       consumer/consumer-testpoint.hpp \
        consumer/consumer-timer.cpp \
-       consumer/consumer-timer.h \
+       consumer/consumer-timer.hpp \
        consumer/metadata-bucket.cpp \
-       consumer/metadata-bucket.h
+       consumer/metadata-bucket.hpp
 
 libconsumer_la_LIBADD = \
        libkernel-consumer.la \
@@ -221,11 +221,11 @@ endif # BUILD_LIB_CONSUMER
 noinst_LTLIBRARIES += libfd-tracker.la
 libfd_tracker_la_SOURCES = \
        fd-tracker/fd-tracker.cpp \
-       fd-tracker/fd-tracker.h \
+       fd-tracker/fd-tracker.hpp \
        fd-tracker/inode.cpp \
-       fd-tracker/inode.h \
+       fd-tracker/inode.hpp \
        fd-tracker/utils.cpp \
-       fd-tracker/utils.h \
+       fd-tracker/utils.hpp \
        fd-tracker/utils-poll.cpp
 
 
@@ -233,11 +233,11 @@ libfd_tracker_la_SOURCES = \
 noinst_LTLIBRARIES += libfilter.la
 
 libfilter_la_SOURCES = \
-       filter/filter-ast.h \
-       filter/filter-ir.h \
+       filter/filter-ast.hpp \
+       filter/filter-ir.hpp \
        filter/filter-lexer.lpp \
        filter/filter-parser.ypp \
-       filter/filter-symbols.h \
+       filter/filter-symbols.hpp \
        filter/filter-visitor-generate-bytecode.cpp \
        filter/filter-visitor-generate-ir.cpp \
        filter/filter-visitor-ir-check-binary-op-nesting.cpp \
@@ -245,7 +245,7 @@ libfilter_la_SOURCES = \
        filter/filter-visitor-ir-validate-globbing.cpp \
        filter/filter-visitor-ir-validate-string.cpp \
        filter/filter-visitor-xml.cpp \
-       filter/memstream.h
+       filter/memstream.hpp
 
 BUILT_SOURCES += filter/filter-parser.hpp
 
@@ -256,7 +256,7 @@ FILTER_WARN_FLAGS = \
        -Wno-unused-parameter
 
 libfilter_la_CFLAGS = $(AM_CFLAGS) $(FILTER_WARN_FLAGS)
-libfilter_la_CXXFLAGS = -include filter-symbols.h $(AM_CXXFLAGS) $(FILTER_WARN_FLAGS)
+libfilter_la_CXXFLAGS = -include filter-symbols.hpp $(AM_CXXFLAGS) $(FILTER_WARN_FLAGS)
 libfilter_la_CPPFLAGS = -I$(srcdir)/filter -I$(builddir)/filter $(AM_CPPFLAGS)
 libfilter_la_LIBADD = libstring-utils.la
 
@@ -301,14 +301,14 @@ noinst_LTLIBRARIES += libhashtable-lgpl.la
 libhashtable_lgpl_la_SOURCES = \
        hashtable/seed.cpp \
        hashtable/utils.cpp \
-       hashtable/utils.h
+       hashtable/utils.hpp
 
 
 noinst_LTLIBRARIES += libhashtable-gpl.la
 libhashtable_gpl_la_SOURCES = \
        hashtable/hashtable.cpp \
-       hashtable/hashtable.h \
-       hashtable/hashtable-symbols.h
+       hashtable/hashtable.hpp \
+       hashtable/hashtable-symbols.hpp
 
 libhashtable_gpl_la_LIBADD = \
        $(URCU_LIBS) \
@@ -327,18 +327,18 @@ endif
 noinst_LTLIBRARIES += libini-config.la
 libini_config_la_SOURCES = \
        ini-config/ini.cpp \
-       ini-config/ini.h \
+       ini-config/ini.hpp \
        ini-config/ini-config.cpp \
-       ini-config/ini-config.h
+       ini-config/ini-config.hpp
 
 
 if BUILD_LIB_INDEX
 noinst_LTLIBRARIES += libindex.la
 
 libindex_la_SOURCES = \
-       index/ctf-index.h \
+       index/ctf-index.hpp \
        index/index.cpp \
-       index/index.h
+       index/index.hpp
 endif
 
 
@@ -347,22 +347,22 @@ noinst_LTLIBRARIES += libkernel-ctl.la
 
 libkernel_ctl_la_SOURCES = \
        kernel-ctl/kernel-ctl.cpp \
-       kernel-ctl/kernel-ctl.h \
-       kernel-ctl/kernel-ioctl.h
+       kernel-ctl/kernel-ctl.hpp \
+       kernel-ctl/kernel-ioctl.hpp
 endif
 
 if BUILD_LIB_SESSIOND_COMM
 noinst_LTLIBRARIES += libsessiond-comm.la
 
 libsessiond_comm_la_SOURCES = \
-       sessiond-comm/agent.h \
+       sessiond-comm/agent.hpp \
        sessiond-comm/inet.cpp \
-       sessiond-comm/inet.h \
+       sessiond-comm/inet.hpp \
        sessiond-comm/inet6.cpp \
-       sessiond-comm/inet6.h \
-       sessiond-comm/relayd.h \
+       sessiond-comm/inet6.hpp \
+       sessiond-comm/relayd.hpp \
        sessiond-comm/sessiond-comm.cpp \
-       sessiond-comm/sessiond-comm.h
+       sessiond-comm/sessiond-comm.hpp
 endif
 
 if BUILD_LIB_RELAYD
@@ -370,7 +370,7 @@ noinst_LTLIBRARIES += librelayd.la
 
 librelayd_la_SOURCES = \
        relayd/relayd.cpp \
-       relayd/relayd.h
+       relayd/relayd.hpp
 
 librelayd_la_LIBADD = libsessiond-comm.la
 endif
@@ -381,7 +381,7 @@ noinst_LTLIBRARIES += libkernel-consumer.la
 
 libkernel_consumer_la_SOURCES = \
        kernel-consumer/kernel-consumer.cpp \
-       kernel-consumer/kernel-consumer.h
+       kernel-consumer/kernel-consumer.hpp
 
 libkernel_consumer_la_LIBADD = \
        libkernel-ctl.la
@@ -393,7 +393,7 @@ noinst_LTLIBRARIES += libust-consumer.la
 
 libust_consumer_la_SOURCES = \
        ust-consumer/ust-consumer.cpp \
-       ust-consumer/ust-consumer.h
+       ust-consumer/ust-consumer.hpp
 
 libust_consumer_la_LIBADD = \
        $(UST_CTL_LIBS)
@@ -405,7 +405,7 @@ noinst_LTLIBRARIES += libtestpoint.la
 
 libtestpoint_la_SOURCES = \
        testpoint/testpoint.cpp \
-       testpoint/testpoint.h
+       testpoint/testpoint.hpp
 
 libtestpoint_la_LIBADD = $(DL_LIBS)
 endif
@@ -414,9 +414,9 @@ endif
 # libstring-utils
 noinst_LTLIBRARIES += libstring-utils.la
 libstring_utils_la_SOURCES = \
-       string-utils/format.h \
+       string-utils/format.hpp \
        string-utils/string-utils.cpp \
-       string-utils/string-utils.h
+       string-utils/string-utils.hpp
 
 
 noinst_PROGRAMS = filter-grammar-test
index b71538b3f477d10a4dbf9b8de29d97ebf289edd3..74dec1247468324df9c42d57ccff7567a740c697 100644 (file)
@@ -5,17 +5,17 @@
  *
  */
 
-#include <common/error.h>
-#include <common/mi-lttng.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/list-internal.h>
-#include <lttng/action/notify-internal.h>
-#include <lttng/action/rate-policy-internal.h>
-#include <lttng/action/rotate-session-internal.h>
-#include <lttng/action/snapshot-session-internal.h>
-#include <lttng/action/start-session-internal.h>
-#include <lttng/action/stop-session-internal.h>
-#include <lttng/error-query-internal.h>
+#include <common/error.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/list-internal.hpp>
+#include <lttng/action/notify-internal.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
+#include <lttng/action/rotate-session-internal.hpp>
+#include <lttng/action/snapshot-session-internal.hpp>
+#include <lttng/action/start-session-internal.hpp>
+#include <lttng/action/stop-session-internal.hpp>
+#include <lttng/error-query-internal.hpp>
 
 const char *lttng_action_type_string(enum lttng_action_type action_type)
 {
index 42d3d653e1bce7a53f351693467e9e8a51bbb7da..c80832570d2dab694a4e77c61a33adffc84cdd26 100644 (file)
@@ -5,14 +5,14 @@
  *
  */
 
-#include <common/dynamic-array.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/list-internal.h>
+#include <common/dynamic-array.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/list-internal.hpp>
 #include <lttng/action/list.h>
 
 #define IS_LIST_ACTION(action) \
index e3f837adeabaca6288c79770b4060b2ba3f37b1a..8ee51c31617a6370b776a5415230056bfa9f2901 100644 (file)
@@ -5,12 +5,12 @@
  *
  */
 
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/notify-internal.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/notify-internal.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
 #include <lttng/lttng-error.h>
 
 #define IS_NOTIFY_ACTION(action) \
index 816f2cd219cd49d865270136e68cacf2617a8c7d..0c8181896dfc612614baebf3775d5a37c250c2e7 100644 (file)
@@ -5,7 +5,7 @@
  *
  */
 
-#include <lttng/action/path-internal.h>
+#include <lttng/action/path-internal.hpp>
 
 struct lttng_action_path_comm {
        uint32_t index_count;
index d0834dd732e14c2f203897b7dc743dbb137307bf..58db624d8312814bff23b1fec56e78ee4d5c698a 100644 (file)
@@ -5,15 +5,15 @@
  *
  */
 
-#include <common/buffer-view.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
+#include <common/buffer-view.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
 #include <limits.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <lttng/action/rate-policy-internal.hpp>
 #include <lttng/action/rate-policy.h>
 #include <stdbool.h>
 #include <sys/types.h>
index 985036acc84bc26818444b45b63c30add3126716..ad2f9e2938c1d7bc228adce90cb7d8800e90bdfe 100644 (file)
@@ -5,13 +5,13 @@
  *
  */
 
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
 #include <lttng/action/rate-policy.h>
-#include <lttng/action/rotate-session-internal.h>
+#include <lttng/action/rotate-session-internal.hpp>
 #include <lttng/action/rotate-session.h>
 
 #define IS_ROTATE_SESSION_ACTION(action) \
index 0f3da782fd1c37832ca21697821e4434ec99617c..600d803e3610b1d065a23cbe82e7fc79e2151596 100644 (file)
@@ -5,19 +5,19 @@
  *
  */
 
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/snapshot.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/snapshot.hpp>
 #include <inttypes.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
 #include <lttng/action/rate-policy.h>
-#include <lttng/action/snapshot-session-internal.h>
+#include <lttng/action/snapshot-session-internal.hpp>
 #include <lttng/action/snapshot-session.h>
-#include <lttng/snapshot-internal.h>
+#include <lttng/snapshot-internal.hpp>
 #include <lttng/snapshot.h>
 
 #define IS_SNAPSHOT_SESSION_ACTION(action) \
index 1312e5ec5f278e3026893089e080fe87f8dbc6ca..739540189e24dbb3882345007b6579103e572552 100644 (file)
@@ -5,13 +5,13 @@
  *
  */
 
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
 #include <lttng/action/rate-policy.h>
-#include <lttng/action/start-session-internal.h>
+#include <lttng/action/start-session-internal.hpp>
 #include <lttng/action/start-session.h>
 
 #define IS_START_SESSION_ACTION(action) \
index 55f1a55ed239df31bcfa40771c6d0f48bb4fa6f6..3cffb4a553b8a774684b0a438856273544609052 100644 (file)
@@ -5,13 +5,13 @@
  *
  */
 
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
 #include <lttng/action/rate-policy.h>
-#include <lttng/action/stop-session-internal.h>
+#include <lttng/action/stop-session-internal.hpp>
 #include <lttng/action/stop-session.h>
 
 #define IS_STOP_SESSION_ACTION(action) \
diff --git a/src/common/align.h b/src/common/align.h
deleted file mode 100644 (file)
index dff6c91..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _LTTNG_ALIGN_H
-#define _LTTNG_ALIGN_H
-
-#include "bug.h"
-
-/*
- * Align value to the next multiple of align. Returns val if it already is a
- * multiple of align. Align must be a power of two.
- */
-#define __lttng_align_ceil_mask(v, mask)       (((v) + (mask)) & ~(mask))
-
-#define lttng_align_ceil(v, align) \
-       __lttng_align_ceil_mask(v, (__typeof__(v)) (align) - 1)
-
-/*
- * Align value to the previous multiple of align. Returns val if it already is a
- * multiple of align. Align must be a power of two.
- */
-#define __lttng_align_floor_mask(v, mask)      ((v) & ~(mask))
-
-#define lttng_align_floor(v, align) \
-       __lttng_align_floor_mask(v, (__typeof__(v)) (align) - 1)
-
-/**
- * lttng_offset_align - Calculate the offset needed to align an object on its natural
- *                alignment towards higher addresses.
- * @align_drift:  object offset from an "alignment"-aligned address.
- * @alignment:    natural object alignment. Must be non-zero, power of 2.
- *
- * Returns the offset that must be added to align towards higher
- * addresses.
- */
-#define lttng_offset_align(align_drift, alignment)                                    \
-       ({                                                                     \
-               LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0                    \
-                                  || ((alignment) & ((alignment) - 1)));      \
-               (((alignment) - (align_drift)) & ((alignment) - 1));           \
-       })
-
-/**
- * lttng_offset_align_floor - Calculate the offset needed to align an object
- *                      on its natural alignment towards lower addresses.
- * @align_drift:  object offset from an "alignment"-aligned address.
- * @alignment:    natural object alignment. Must be non-zero, power of 2.
- *
- * Returns the offset that must be substracted to align towards lower addresses.
- */
-#define lttng_offset_align_floor(align_drift, alignment)                              \
-       ({                                                                     \
-               LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0                    \
-                                  || ((alignment) & ((alignment) - 1)));      \
-               (((align_drift) - (alignment)) & ((alignment) - 1));           \
-       })
-
-#endif /* _LTTNG_ALIGN_H */
diff --git a/src/common/align.hpp b/src/common/align.hpp
new file mode 100644 (file)
index 0000000..c957824
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _LTTNG_ALIGN_H
+#define _LTTNG_ALIGN_H
+
+#include "bug.hpp"
+
+/*
+ * Align value to the next multiple of align. Returns val if it already is a
+ * multiple of align. Align must be a power of two.
+ */
+#define __lttng_align_ceil_mask(v, mask)       (((v) + (mask)) & ~(mask))
+
+#define lttng_align_ceil(v, align) \
+       __lttng_align_ceil_mask(v, (__typeof__(v)) (align) - 1)
+
+/*
+ * Align value to the previous multiple of align. Returns val if it already is a
+ * multiple of align. Align must be a power of two.
+ */
+#define __lttng_align_floor_mask(v, mask)      ((v) & ~(mask))
+
+#define lttng_align_floor(v, align) \
+       __lttng_align_floor_mask(v, (__typeof__(v)) (align) - 1)
+
+/**
+ * lttng_offset_align - Calculate the offset needed to align an object on its natural
+ *                alignment towards higher addresses.
+ * @align_drift:  object offset from an "alignment"-aligned address.
+ * @alignment:    natural object alignment. Must be non-zero, power of 2.
+ *
+ * Returns the offset that must be added to align towards higher
+ * addresses.
+ */
+#define lttng_offset_align(align_drift, alignment)                                    \
+       ({                                                                     \
+               LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0                    \
+                                  || ((alignment) & ((alignment) - 1)));      \
+               (((alignment) - (align_drift)) & ((alignment) - 1));           \
+       })
+
+/**
+ * lttng_offset_align_floor - Calculate the offset needed to align an object
+ *                      on its natural alignment towards lower addresses.
+ * @align_drift:  object offset from an "alignment"-aligned address.
+ * @alignment:    natural object alignment. Must be non-zero, power of 2.
+ *
+ * Returns the offset that must be substracted to align towards lower addresses.
+ */
+#define lttng_offset_align_floor(align_drift, alignment)                              \
+       ({                                                                     \
+               LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0                    \
+                                  || ((alignment) & ((alignment) - 1)));      \
+               (((align_drift) - (alignment)) & ((alignment) - 1));           \
+       })
+
+#endif /* _LTTNG_ALIGN_H */
index 493598693632ec32556a0260488a7d16662c8a84..0beff92adfc7598bb02cc2389a406e517a84ae52 100644 (file)
@@ -5,12 +5,12 @@
  *
  */
 
-#include "argpar-utils.h"
+#include "argpar-utils.hpp"
 
 #include <stdio.h>
 
-#include <common/error.h>
-#include <common/string-utils/string-utils.h>
+#include <common/error.hpp>
+#include <common/string-utils/string-utils.hpp>
 
 /*
  * Given argpar error status `status` and error `error`, return a formatted
diff --git a/src/common/argpar-utils/argpar-utils.h b/src/common/argpar-utils/argpar-utils.h
deleted file mode 100644 (file)
index 1bdff7e..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2021 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef COMMON_ARGPAR_UTILS_H
-#define COMMON_ARGPAR_UTILS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdarg.h>
-
-#include <common/macros.h>
-#include <common/argpar/argpar.h>
-#include <common/string-utils/format.h>
-
-#define WHILE_PARSING_ARG_N_ARG_FMT "While parsing argument #%d (`%s`): "
-
-enum parse_next_item_status
-{
-       PARSE_NEXT_ITEM_STATUS_OK = 0,
-       PARSE_NEXT_ITEM_STATUS_END = 1,
-       PARSE_NEXT_ITEM_STATUS_ERROR = -1,
-       PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY = -2,
-};
-
-/*
- * Parse the next argpar item using `iter`.
- *
- * The item in `*item` is always freed and cleared on entry.
- *
- * If an item is parsed successfully, return the new item in `*item` and return
- * PARSE_NEXT_ITEM_STATUS_OK.
- *
- * If the end of the argument list is reached, return
- * PARSE_NEXT_ITEM_STATUS_END.
- *
- * On error, print a descriptive error message and return
- * PARSE_NEXT_ITEM_STATUS_ERROR.  If `context_fmt` is non-NULL, it is formatted
- * using the following arguments and prepended to the error message.
- * Add `argc_offset` to the argument index mentioned in the error message.
- *
- * If `unknown_opt_is_error` is true, an unknown option is considered an error.
- * Otherwise, it is considered as the end of the argument list.
- *
- * If `error_out` is given and PARSE_NEXT_ITEM_STATUS_ERROR is returned, set
- * `*error_out` to the argpar_error object corresponding to the error.  The
- * caller must free the object with `argpar_error_destroy`.
- */
-ATTR_FORMAT_PRINTF(7, 8)
-enum parse_next_item_status parse_next_item(struct argpar_iter *iter,
-               const struct argpar_item **item, int argc_offset,
-               const char **argv, bool unknown_opt_is_error,
-               const struct argpar_error **error_out,
-               const char *context_fmt, ...);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/src/common/argpar-utils/argpar-utils.hpp b/src/common/argpar-utils/argpar-utils.hpp
new file mode 100644 (file)
index 0000000..ea77345
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2021 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef COMMON_ARGPAR_UTILS_H
+#define COMMON_ARGPAR_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdarg.h>
+
+#include <common/macros.hpp>
+#include <common/argpar/argpar.h>
+#include <common/string-utils/format.hpp>
+
+#define WHILE_PARSING_ARG_N_ARG_FMT "While parsing argument #%d (`%s`): "
+
+enum parse_next_item_status
+{
+       PARSE_NEXT_ITEM_STATUS_OK = 0,
+       PARSE_NEXT_ITEM_STATUS_END = 1,
+       PARSE_NEXT_ITEM_STATUS_ERROR = -1,
+       PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY = -2,
+};
+
+/*
+ * Parse the next argpar item using `iter`.
+ *
+ * The item in `*item` is always freed and cleared on entry.
+ *
+ * If an item is parsed successfully, return the new item in `*item` and return
+ * PARSE_NEXT_ITEM_STATUS_OK.
+ *
+ * If the end of the argument list is reached, return
+ * PARSE_NEXT_ITEM_STATUS_END.
+ *
+ * On error, print a descriptive error message and return
+ * PARSE_NEXT_ITEM_STATUS_ERROR.  If `context_fmt` is non-NULL, it is formatted
+ * using the following arguments and prepended to the error message.
+ * Add `argc_offset` to the argument index mentioned in the error message.
+ *
+ * If `unknown_opt_is_error` is true, an unknown option is considered an error.
+ * Otherwise, it is considered as the end of the argument list.
+ *
+ * If `error_out` is given and PARSE_NEXT_ITEM_STATUS_ERROR is returned, set
+ * `*error_out` to the argpar_error object corresponding to the error.  The
+ * caller must free the object with `argpar_error_destroy`.
+ */
+ATTR_FORMAT_PRINTF(7, 8)
+enum parse_next_item_status parse_next_item(struct argpar_iter *iter,
+               const struct argpar_item **item, int argc_offset,
+               const char **argv, bool unknown_opt_is_error,
+               const struct argpar_error **error_out,
+               const char *context_fmt, ...);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
index ebe6869852f90a2bec8e7f1283e24cd130e2f04e..9498423cae64efb38d1b5e55fbccd1db879bdd82 100644 (file)
@@ -5,9 +5,9 @@
  *
  */
 
-#include <common/buffer-view.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
+#include <common/buffer-view.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
 
 struct lttng_buffer_view lttng_buffer_view_init(
                const char *src, size_t offset, ptrdiff_t len)
diff --git a/src/common/buffer-view.h b/src/common/buffer-view.h
deleted file mode 100644 (file)
index 58f1ede..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_BUFFER_VIEW_H
-#define LTTNG_BUFFER_VIEW_H
-
-#include <common/macros.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-
-struct lttng_dynamic_buffer;
-
-struct lttng_buffer_view {
-       const char *data;
-       size_t size;
-};
-
-/**
- * Return a buffer view referencing a subset of the memory referenced by a raw
- * pointer.
- *
- * @src                Source buffer to reference
- * @offset     Offset to apply to the source memory buffer
- * @len                Length of the memory contents to reference.
- *
- * Note that a buffer view never assumes the ownership of the memory it
- * references.
- */
-struct lttng_buffer_view lttng_buffer_view_init(
-               const char *src, size_t offset, ptrdiff_t len);
-
-/**
- * Checks if a buffer view is safe to access.
- *
- * After calling the buffer view creation functions, callers should verify
- * if the resquested length (if any is explicitly provided) could be mapped
- * to a new view.
- *
- * @view       Buffer view to validate
- */
-bool lttng_buffer_view_is_valid(const struct lttng_buffer_view *view);
-
-/**
- * Return a buffer view referencing a subset of the memory referenced by another
- * view.
- *
- * @src                Source view to reference
- * @offset     Offset to apply to the source memory content
- * @len                Length of the memory contents to reference. Passing -1 will
- *             cause the view to reference the whole view from the offset
- *             provided.
- *
- * Note that a buffer view never assumes the ownership of the memory it
- * references.
- */
-struct lttng_buffer_view lttng_buffer_view_from_view(
-               const struct lttng_buffer_view *src, size_t offset,
-               ptrdiff_t len);
-
-/**
- * Return a buffer view referencing a subset of the memory referenced by a
- * dynamic buffer.
- *
- * @src                Source dynamic buffer to reference
- * @offset     Offset to apply to the source memory content
- * @len                Length of the memory contents to reference. Passing -1 will
- *             cause the view to reference the whole dynamic buffer from the
- *             offset provided.
- *
- * Note that a buffer view never assumes the ownership of the memory it
- * references.
- */
-struct lttng_buffer_view lttng_buffer_view_from_dynamic_buffer(
-               const struct lttng_dynamic_buffer *src, size_t offset,
-               ptrdiff_t len);
-
-/**
- * Verify that `buf` contains a string starting at `str` of length
- * `len_with_null_terminator`.
- *
- * @buf                                The buffer view
- * @str                                The start of the string
- * @len_with_null_terminator   Expected length of the string, including the
- *                             NULL terminator.
- */
-bool lttng_buffer_view_contains_string(const struct lttng_buffer_view *buf,
-               const char *str,
-               size_t len_with_null_terminator);
-
-#endif /* LTTNG_BUFFER_VIEW_H */
diff --git a/src/common/buffer-view.hpp b/src/common/buffer-view.hpp
new file mode 100644 (file)
index 0000000..7e638c0
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_BUFFER_VIEW_H
+#define LTTNG_BUFFER_VIEW_H
+
+#include <common/macros.hpp>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+struct lttng_dynamic_buffer;
+
+struct lttng_buffer_view {
+       const char *data;
+       size_t size;
+};
+
+/**
+ * Return a buffer view referencing a subset of the memory referenced by a raw
+ * pointer.
+ *
+ * @src                Source buffer to reference
+ * @offset     Offset to apply to the source memory buffer
+ * @len                Length of the memory contents to reference.
+ *
+ * Note that a buffer view never assumes the ownership of the memory it
+ * references.
+ */
+struct lttng_buffer_view lttng_buffer_view_init(
+               const char *src, size_t offset, ptrdiff_t len);
+
+/**
+ * Checks if a buffer view is safe to access.
+ *
+ * After calling the buffer view creation functions, callers should verify
+ * if the resquested length (if any is explicitly provided) could be mapped
+ * to a new view.
+ *
+ * @view       Buffer view to validate
+ */
+bool lttng_buffer_view_is_valid(const struct lttng_buffer_view *view);
+
+/**
+ * Return a buffer view referencing a subset of the memory referenced by another
+ * view.
+ *
+ * @src                Source view to reference
+ * @offset     Offset to apply to the source memory content
+ * @len                Length of the memory contents to reference. Passing -1 will
+ *             cause the view to reference the whole view from the offset
+ *             provided.
+ *
+ * Note that a buffer view never assumes the ownership of the memory it
+ * references.
+ */
+struct lttng_buffer_view lttng_buffer_view_from_view(
+               const struct lttng_buffer_view *src, size_t offset,
+               ptrdiff_t len);
+
+/**
+ * Return a buffer view referencing a subset of the memory referenced by a
+ * dynamic buffer.
+ *
+ * @src                Source dynamic buffer to reference
+ * @offset     Offset to apply to the source memory content
+ * @len                Length of the memory contents to reference. Passing -1 will
+ *             cause the view to reference the whole dynamic buffer from the
+ *             offset provided.
+ *
+ * Note that a buffer view never assumes the ownership of the memory it
+ * references.
+ */
+struct lttng_buffer_view lttng_buffer_view_from_dynamic_buffer(
+               const struct lttng_dynamic_buffer *src, size_t offset,
+               ptrdiff_t len);
+
+/**
+ * Verify that `buf` contains a string starting at `str` of length
+ * `len_with_null_terminator`.
+ *
+ * @buf                                The buffer view
+ * @str                                The start of the string
+ * @len_with_null_terminator   Expected length of the string, including the
+ *                             NULL terminator.
+ */
+bool lttng_buffer_view_contains_string(const struct lttng_buffer_view *buf,
+               const char *str,
+               size_t len_with_null_terminator);
+
+#endif /* LTTNG_BUFFER_VIEW_H */
diff --git a/src/common/bug.h b/src/common/bug.h
deleted file mode 100644 (file)
index f77c775..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _LTTNG_BUG_H
-#define _LTTNG_BUG_H
-
-#include <urcu/compiler.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define LTTNG_BUG_ON(condition)                                                \
-       do {                                                            \
-               if (caa_unlikely(condition)) {                          \
-                       fprintf(stderr,                                 \
-                               "LTTng BUG in file %s, line %d.\n",     \
-                               __FILE__, __LINE__);                    \
-                       exit(EXIT_FAILURE);                             \
-               }                                                       \
-       } while (0)
-
-#define LTTNG_BUILD_BUG_ON(condition)                                  \
-       ((void) sizeof(char[-!!(condition)]))
-
-/**
- * LTTNG_BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime
- * @condition: the condition which should be false.
- *
- * If the condition is a constant and true, the compiler will generate a build
- * error. If the condition is not constant, a BUG will be triggered at runtime
- * if the condition is ever true. If the condition is constant and false, no
- * code is emitted.
- */
-#define LTTNG_BUILD_RUNTIME_BUG_ON(condition)                  \
-       do {                                                    \
-               if (__builtin_constant_p(condition))            \
-                       LTTNG_BUILD_BUG_ON(condition);          \
-               else                                            \
-                       LTTNG_BUG_ON(condition);                \
-       } while (0)
-
-#endif
diff --git a/src/common/bug.hpp b/src/common/bug.hpp
new file mode 100644 (file)
index 0000000..f77c775
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _LTTNG_BUG_H
+#define _LTTNG_BUG_H
+
+#include <urcu/compiler.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define LTTNG_BUG_ON(condition)                                                \
+       do {                                                            \
+               if (caa_unlikely(condition)) {                          \
+                       fprintf(stderr,                                 \
+                               "LTTng BUG in file %s, line %d.\n",     \
+                               __FILE__, __LINE__);                    \
+                       exit(EXIT_FAILURE);                             \
+               }                                                       \
+       } while (0)
+
+#define LTTNG_BUILD_BUG_ON(condition)                                  \
+       ((void) sizeof(char[-!!(condition)]))
+
+/**
+ * LTTNG_BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime
+ * @condition: the condition which should be false.
+ *
+ * If the condition is a constant and true, the compiler will generate a build
+ * error. If the condition is not constant, a BUG will be triggered at runtime
+ * if the condition is ever true. If the condition is constant and false, no
+ * code is emitted.
+ */
+#define LTTNG_BUILD_RUNTIME_BUG_ON(condition)                  \
+       do {                                                    \
+               if (__builtin_constant_p(condition))            \
+                       LTTNG_BUILD_BUG_ON(condition);          \
+               else                                            \
+                       LTTNG_BUG_ON(condition);                \
+       } while (0)
+
+#endif
index 6100892b718554c762a5a398c4431f6cc682bde5..707394229e947cad92d4dfa0a542d62762ceaa71 100644 (file)
@@ -5,12 +5,12 @@
  *
  */
 
-#include "bytecode.h"
+#include "bytecode.hpp"
 
 #include <errno.h>
 #include <algorithm>
 
-#include "common/align.h"
+#include "common/align.hpp"
 
 #define INIT_ALLOC_SIZE 4
 
diff --git a/src/common/bytecode/bytecode.h b/src/common/bytecode/bytecode.h
deleted file mode 100644 (file)
index 386f582..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright 2020 EfficiOS, Inc.
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_COMMON_BYTECODE_H
-#define LTTNG_COMMON_BYTECODE_H
-
-#include <stdint.h>
-
-#include "common/macros.h"
-#include "common/sessiond-comm/sessiond-comm.h"
-
-/*
- * offsets are absolute from start of bytecode.
- */
-
-struct field_ref {
-       /* Initially, symbol offset. After link, field offset. */
-       uint16_t offset;
-} LTTNG_PACKED;
-
-struct get_symbol {
-       /* Symbol offset. */
-       uint16_t offset;
-} LTTNG_PACKED;
-
-struct get_index_u16 {
-       uint16_t index;
-} LTTNG_PACKED;
-
-struct get_index_u64 {
-       uint64_t index;
-} LTTNG_PACKED;
-
-struct literal_numeric {
-       int64_t v;
-} LTTNG_PACKED;
-
-struct literal_double {
-       double v;
-} LTTNG_PACKED;
-
-enum bytecode_op {
-       BYTECODE_OP_UNKNOWN                             = 0,
-
-       BYTECODE_OP_RETURN                              = 1,
-
-       /* binary */
-       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 */
-       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  */
-       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 */
-       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 */
-       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 */
-       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 */
-       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 */
-       BYTECODE_OP_AND                                 = 57,
-       BYTECODE_OP_OR                                  = 58,
-
-       /* load field ref */
-       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 */
-       BYTECODE_OP_LOAD_STRING                         = 64,
-       BYTECODE_OP_LOAD_S64                            = 65,
-       BYTECODE_OP_LOAD_DOUBLE                         = 66,
-
-       /* cast */
-       BYTECODE_OP_CAST_TO_S64                         = 67,
-       BYTECODE_OP_CAST_DOUBLE_TO_S64                  = 68,
-       BYTECODE_OP_CAST_NOP                            = 69,
-
-       /* get context ref */
-       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 */
-       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
-        */
-       BYTECODE_OP_LOAD_STAR_GLOB_STRING               = 76,
-
-       /* globbing pattern binary operator: apply to */
-       BYTECODE_OP_EQ_STAR_GLOB_STRING                 = 77,
-       BYTECODE_OP_NE_STAR_GLOB_STRING                 = 78,
-
-       /*
-        * Instructions for recursive traversal through composed types.
-        */
-       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 bytecode_opcode_t;
-
-struct load_op {
-       bytecode_opcode_t op;
-
-       /*
-        * data to load. Size known by enum bytecode_opcode_t and null-term
-        * char.
-        */
-       char data[0];
-} LTTNG_PACKED;
-
-struct binary_op {
-       bytecode_opcode_t op;
-} LTTNG_PACKED;
-
-struct unary_op {
-       bytecode_opcode_t op;
-} LTTNG_PACKED;
-
-/* skip_offset is absolute from start of bytecode */
-struct logical_op {
-       bytecode_opcode_t op;
-       uint16_t skip_offset;   /* bytecode insn, if skip second test */
-} LTTNG_PACKED;
-
-struct cast_op {
-       bytecode_opcode_t op;
-} LTTNG_PACKED;
-
-struct return_op {
-       bytecode_opcode_t op;
-} LTTNG_PACKED;
-
-struct lttng_bytecode_alloc {
-       uint32_t alloc_len;
-       struct lttng_bytecode b;
-};
-
-int bytecode_init(struct lttng_bytecode_alloc **fb);
-int bytecode_push(struct lttng_bytecode_alloc **fb,
-               const void *data, uint32_t align, uint32_t len);
-int bytecode_push_logical(struct lttng_bytecode_alloc **fb,
-               struct logical_op *data, uint32_t align, uint32_t len,
-               uint16_t *skip_offset);
-struct lttng_bytecode *lttng_bytecode_copy(
-               const struct lttng_bytecode *orig_f);
-
-int bytecode_push_get_payload_root(
-               struct lttng_bytecode_alloc **bytecode);
-int bytecode_push_get_context_root(
-               struct lttng_bytecode_alloc **bytecode);
-int bytecode_push_get_app_context_root(
-               struct lttng_bytecode_alloc **bytecode);
-int bytecode_push_get_index_u64(
-               struct lttng_bytecode_alloc **bytecode, uint64_t index);
-int bytecode_push_get_symbol(
-               struct lttng_bytecode_alloc **bytecode,
-               struct lttng_bytecode_alloc **bytecode_reloc,
-               const char *symbol);
-
-static inline
-unsigned int bytecode_get_len(struct lttng_bytecode *bytecode)
-{
-       return bytecode->len;
-}
-
-#endif /* LTTNG_COMMON_BYTECODE_H */
diff --git a/src/common/bytecode/bytecode.hpp b/src/common/bytecode/bytecode.hpp
new file mode 100644 (file)
index 0000000..4ed51dc
--- /dev/null
@@ -0,0 +1,261 @@
+/*
+ * Copyright 2020 EfficiOS, Inc.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_COMMON_BYTECODE_H
+#define LTTNG_COMMON_BYTECODE_H
+
+#include <stdint.h>
+
+#include "common/macros.hpp"
+#include "common/sessiond-comm/sessiond-comm.hpp"
+
+/*
+ * offsets are absolute from start of bytecode.
+ */
+
+struct field_ref {
+       /* Initially, symbol offset. After link, field offset. */
+       uint16_t offset;
+} LTTNG_PACKED;
+
+struct get_symbol {
+       /* Symbol offset. */
+       uint16_t offset;
+} LTTNG_PACKED;
+
+struct get_index_u16 {
+       uint16_t index;
+} LTTNG_PACKED;
+
+struct get_index_u64 {
+       uint64_t index;
+} LTTNG_PACKED;
+
+struct literal_numeric {
+       int64_t v;
+} LTTNG_PACKED;
+
+struct literal_double {
+       double v;
+} LTTNG_PACKED;
+
+enum bytecode_op {
+       BYTECODE_OP_UNKNOWN                             = 0,
+
+       BYTECODE_OP_RETURN                              = 1,
+
+       /* binary */
+       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 */
+       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  */
+       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 */
+       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 */
+       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 */
+       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 */
+       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 */
+       BYTECODE_OP_AND                                 = 57,
+       BYTECODE_OP_OR                                  = 58,
+
+       /* load field ref */
+       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 */
+       BYTECODE_OP_LOAD_STRING                         = 64,
+       BYTECODE_OP_LOAD_S64                            = 65,
+       BYTECODE_OP_LOAD_DOUBLE                         = 66,
+
+       /* cast */
+       BYTECODE_OP_CAST_TO_S64                         = 67,
+       BYTECODE_OP_CAST_DOUBLE_TO_S64                  = 68,
+       BYTECODE_OP_CAST_NOP                            = 69,
+
+       /* get context ref */
+       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 */
+       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
+        */
+       BYTECODE_OP_LOAD_STAR_GLOB_STRING               = 76,
+
+       /* globbing pattern binary operator: apply to */
+       BYTECODE_OP_EQ_STAR_GLOB_STRING                 = 77,
+       BYTECODE_OP_NE_STAR_GLOB_STRING                 = 78,
+
+       /*
+        * Instructions for recursive traversal through composed types.
+        */
+       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 bytecode_opcode_t;
+
+struct load_op {
+       bytecode_opcode_t op;
+
+       /*
+        * data to load. Size known by enum bytecode_opcode_t and null-term
+        * char.
+        */
+       char data[0];
+} LTTNG_PACKED;
+
+struct binary_op {
+       bytecode_opcode_t op;
+} LTTNG_PACKED;
+
+struct unary_op {
+       bytecode_opcode_t op;
+} LTTNG_PACKED;
+
+/* skip_offset is absolute from start of bytecode */
+struct logical_op {
+       bytecode_opcode_t op;
+       uint16_t skip_offset;   /* bytecode insn, if skip second test */
+} LTTNG_PACKED;
+
+struct cast_op {
+       bytecode_opcode_t op;
+} LTTNG_PACKED;
+
+struct return_op {
+       bytecode_opcode_t op;
+} LTTNG_PACKED;
+
+struct lttng_bytecode_alloc {
+       uint32_t alloc_len;
+       struct lttng_bytecode b;
+};
+
+int bytecode_init(struct lttng_bytecode_alloc **fb);
+int bytecode_push(struct lttng_bytecode_alloc **fb,
+               const void *data, uint32_t align, uint32_t len);
+int bytecode_push_logical(struct lttng_bytecode_alloc **fb,
+               struct logical_op *data, uint32_t align, uint32_t len,
+               uint16_t *skip_offset);
+struct lttng_bytecode *lttng_bytecode_copy(
+               const struct lttng_bytecode *orig_f);
+
+int bytecode_push_get_payload_root(
+               struct lttng_bytecode_alloc **bytecode);
+int bytecode_push_get_context_root(
+               struct lttng_bytecode_alloc **bytecode);
+int bytecode_push_get_app_context_root(
+               struct lttng_bytecode_alloc **bytecode);
+int bytecode_push_get_index_u64(
+               struct lttng_bytecode_alloc **bytecode, uint64_t index);
+int bytecode_push_get_symbol(
+               struct lttng_bytecode_alloc **bytecode,
+               struct lttng_bytecode_alloc **bytecode_reloc,
+               const char *symbol);
+
+static inline
+unsigned int bytecode_get_len(struct lttng_bytecode *bytecode)
+{
+       return bytecode->len;
+}
+
+#endif /* LTTNG_COMMON_BYTECODE_H */
index ac2f915d8ec4208b41145edc53c91471ad774193..be3b62343ec447bdb45b619a79452e55e0796772 100644 (file)
@@ -5,18 +5,16 @@
  *
  */
 
-#include <common/macros.h>
+#include <common/buffer-view.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/channel-internal.hpp>
 #include <lttng/channel.h>
 #include <lttng/constant.h>
-#include <lttng/channel-internal.h>
-#include <lttng/userspace-probe-internal.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
-#include <assert.h>
-#include <string.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/dynamic-array.h>
-#include <common/buffer-view.h>
+#include <lttng/userspace-probe-internal.hpp>
 
 static enum lttng_error_code flatten_lttng_channels(
                struct lttng_dynamic_pointer_array *channels,
diff --git a/src/common/common.h b/src/common/common.h
deleted file mode 100644 (file)
index 58b2669..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _COMMON_H
-#define _COMMON_H
-
-#include "error.h"
-#include "macros.h"
-#include "runas.h"
-#include "readwrite.h"
-#include "time.h"
-
-#endif /* _COMMON_H */
diff --git a/src/common/common.hpp b/src/common/common.hpp
new file mode 100644 (file)
index 0000000..926ebf3
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _COMMON_H
+#define _COMMON_H
+
+#include "error.hpp"
+#include "macros.hpp"
+#include "runas.hpp"
+#include "readwrite.hpp"
+#include "time.hpp"
+
+#endif /* _COMMON_H */
index 004939a3d3d247220b44f6e71b8673dad5e510a5..13ba512b8884699d325d90aad36e22e1d9c41c70 100644 (file)
@@ -6,8 +6,8 @@
  */
 
 #define _LGPL_SOURCE
-#include <common/compat/fcntl.h>
-#include <common/macros.h>
+#include <common/compat/fcntl.hpp>
+#include <common/macros.hpp>
 #include <unistd.h>
 
 #ifdef __linux__
index 5bfb4b9eee2a94c03af9ec4f94e1d4b840740e86..ba5c6925c49feb3667f61e60ea0450507e19fe71 100644 (file)
@@ -5,13 +5,13 @@
  *
  */
 
-#include <common/compat/directory-handle.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/runas.h>
-#include <common/credentials.h>
+#include <common/compat/directory-handle.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/runas.hpp>
+#include <common/credentials.hpp>
 #include <lttng/constant.h>
-#include <common/dynamic-array.h>
+#include <common/dynamic-array.hpp>
 
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/src/common/compat/directory-handle.h b/src/common/compat/directory-handle.h
deleted file mode 100644 (file)
index 4a9b657..0000000
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_DIRECTORY_HANDLE_H
-#define _COMPAT_DIRECTORY_HANDLE_H
-
-#include <common/credentials.h>
-#include <common/macros.h>
-#include <sys/stat.h>
-#include <urcu/ref.h>
-
-enum lttng_directory_handle_rmdir_recursive_flags {
-       LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG = (1U << 0),
-       LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG = (1U << 1),
-};
-
-/*
- * Some platforms, such as Solaris 10, do not support directory file descriptors
- * and their associated functions (*at(...)), which are defined in POSIX.2008.
- *
- * This wrapper provides a handle that is either a copy of a directory's path
- * or a directory file descriptors, depending on the platform's capabilities.
- */
-#ifdef HAVE_DIRFD
-
-struct lttng_directory_handle;
-
-typedef void (*lttng_directory_handle_destroy_cb)(
-               struct lttng_directory_handle *handle, void *data);
-
-struct lttng_directory_handle {
-       struct urcu_ref ref;
-       ino_t directory_inode;
-       int dirfd;
-       lttng_directory_handle_destroy_cb destroy_cb;
-       void *destroy_cb_data;
-};
-
-static inline
-int lttng_directory_handle_get_dirfd(
-               const struct lttng_directory_handle *handle)
-{
-       return handle->dirfd;
-}
-
-#else
-struct lttng_directory_handle {
-       struct urcu_ref ref;
-       char *base_path;
-};
-#endif
-
-/*
- * Create a directory handle to the provided path. Passing a NULL path
- * returns a handle to the current working directory.
- *
- * The reference to the directory handle must be released using
- * lttng_directory_handle_put().
- */
-struct lttng_directory_handle *lttng_directory_handle_create(
-               const char *path);
-
-/*
- * Create a new directory handle to a path relative to an existing handle.
- *
- * The provided path must already exist. Note that the creation of a
- * subdirectory and the creation of a handle are kept as separate operations
- * to highlight the fact that there is an inherent race between the creation of
- * a directory and the creation of a handle to it.
- *
- * Passing a NULL path effectively copies the original handle.
- *
- * The reference to the directory handle must be released using
- * lttng_directory_handle_put().
- */
-struct lttng_directory_handle *lttng_directory_handle_create_from_handle(
-               const char *path,
-               const struct lttng_directory_handle *ref_handle);
-
-/*
- * Create a new directory handle from an existing directory fd.
- *
- * The new directory handle assumes the ownership of the directory fd.
- * Note that this method should only be used in very specific cases, such as
- * re-creating a directory handle from a dirfd passed over a unix socket.
- *
- * The reference to the directory handle must be released using
- * lttng_directory_handle_put().
- */
-struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd(
-               int dirfd);
-
-/*
- * Copy a directory handle.
- *
- * The reference to the directory handle must be released using
- * lttng_directory_handle_put().
- */
-struct lttng_directory_handle *lttng_directory_handle_copy(
-               const struct lttng_directory_handle *handle);
-
-/*
- * Acquire a reference to a directory handle.
- */
-bool lttng_directory_handle_get(struct lttng_directory_handle *handle);
-
-/*
- * Release a reference to a directory handle.
- */
-void lttng_directory_handle_put(struct lttng_directory_handle *handle);
-
-/*
- * Create a subdirectory relative to a directory handle.
- */
-int lttng_directory_handle_create_subdirectory(
-               const struct lttng_directory_handle *handle,
-               const char *subdirectory,
-               mode_t mode);
-
-/*
- * Create a subdirectory relative to a directory handle
- * as a given user.
- */
-int lttng_directory_handle_create_subdirectory_as_user(
-               const struct lttng_directory_handle *handle,
-               const char *subdirectory,
-               mode_t mode, const struct lttng_credentials *creds);
-
-/*
- * Recursively create a directory relative to a directory handle.
- */
-int lttng_directory_handle_create_subdirectory_recursive(
-               const struct lttng_directory_handle *handle,
-               const char *subdirectory_path,
-               mode_t mode);
-
-/*
- * Recursively create a directory relative to a directory handle
- * as a given user.
- */
-int lttng_directory_handle_create_subdirectory_recursive_as_user(
-               const struct lttng_directory_handle *handle,
-               const char *subdirectory_path,
-               mode_t mode, const struct lttng_credentials *creds);
-
-/*
- * Open a file descriptor to a path relative to a directory handle.
- */
-int lttng_directory_handle_open_file(
-               const struct lttng_directory_handle *handle,
-               const char *filename,
-               int flags, mode_t mode);
-
-/*
- * Open a file descriptor to a path relative to a directory handle
- * as a given user.
- */
-int lttng_directory_handle_open_file_as_user(
-               const struct lttng_directory_handle *handle,
-               const char *filename,
-               int flags, mode_t mode,
-               const struct lttng_credentials *creds);
-
-/*
- * Unlink a file to a path relative to a directory handle.
- */
-int lttng_directory_handle_unlink_file(
-               const struct lttng_directory_handle *handle,
-               const char *filename);
-
-/*
- * Unlink a file to a path relative to a directory handle as a given user.
- */
-int lttng_directory_handle_unlink_file_as_user(
-               const struct lttng_directory_handle *handle,
-               const char *filename,
-               const struct lttng_credentials *creds);
-
-/*
- * Rename a file from a path relative to a directory handle to a new
- * name relative to another directory handle.
- */
-int lttng_directory_handle_rename(
-               const struct lttng_directory_handle *old_handle,
-               const char *old_name,
-               const struct lttng_directory_handle *new_handle,
-               const char *new_name);
-
-/*
- * Rename a file from a path relative to a directory handle to a new
- * name relative to another directory handle as a given user.
- */
-int lttng_directory_handle_rename_as_user(
-               const struct lttng_directory_handle *old_handle,
-               const char *old_name,
-               const struct lttng_directory_handle *new_handle,
-               const char *new_name,
-               const struct lttng_credentials *creds);
-
-/*
- * Remove a subdirectory relative to a directory handle.
- */
-int lttng_directory_handle_remove_subdirectory(
-               const struct lttng_directory_handle *handle,
-               const char *name);
-
-/*
- * Remove a subdirectory relative to a directory handle as a given user.
- */
-int lttng_directory_handle_remove_subdirectory_as_user(
-               const struct lttng_directory_handle *handle,
-               const char *name,
-               const struct lttng_credentials *creds);
-
-/*
- * Remove a subdirectory and remove its contents if it only
- * consists in empty directories.
- * @flags: enum lttng_directory_handle_rmdir_recursive_flags
- */
-int lttng_directory_handle_remove_subdirectory_recursive(
-               const struct lttng_directory_handle *handle,
-               const char *name, int flags);
-
-/*
- * Remove a subdirectory and remove its contents if it only
- * consists in empty directories as a given user.
- * @flags: enum lttng_directory_handle_rmdir_recursive_flags
- */
-int lttng_directory_handle_remove_subdirectory_recursive_as_user(
-               const struct lttng_directory_handle *handle,
-               const char *name,
-               const struct lttng_credentials *creds,
-               int flags);
-
-/*
- * stat() a file relative to a directory handle.
- */
-int lttng_directory_handle_stat(
-               const struct lttng_directory_handle *handle,
-               const char *name,
-               struct stat *stat_buf);
-
-/*
- * Returns true if this directory handle is backed by a file
- * descriptor, false otherwise.
- */
-bool lttng_directory_handle_uses_fd(
-               const struct lttng_directory_handle *handle);
-
-/*
- * Compare two directory handles.
- *
- * Returns true if the two directory handles are equal, false otherwise.
- */
-bool lttng_directory_handle_equals(const struct lttng_directory_handle *lhs,
-               const struct lttng_directory_handle *rhs);
-
-
-#endif /* _COMPAT_PATH_HANDLE_H */
diff --git a/src/common/compat/directory-handle.hpp b/src/common/compat/directory-handle.hpp
new file mode 100644 (file)
index 0000000..0f96955
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_DIRECTORY_HANDLE_H
+#define _COMPAT_DIRECTORY_HANDLE_H
+
+#include <common/credentials.hpp>
+#include <common/macros.hpp>
+#include <sys/stat.h>
+#include <urcu/ref.h>
+
+enum lttng_directory_handle_rmdir_recursive_flags {
+       LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG = (1U << 0),
+       LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG = (1U << 1),
+};
+
+/*
+ * Some platforms, such as Solaris 10, do not support directory file descriptors
+ * and their associated functions (*at(...)), which are defined in POSIX.2008.
+ *
+ * This wrapper provides a handle that is either a copy of a directory's path
+ * or a directory file descriptors, depending on the platform's capabilities.
+ */
+#ifdef HAVE_DIRFD
+
+struct lttng_directory_handle;
+
+typedef void (*lttng_directory_handle_destroy_cb)(
+               struct lttng_directory_handle *handle, void *data);
+
+struct lttng_directory_handle {
+       struct urcu_ref ref;
+       ino_t directory_inode;
+       int dirfd;
+       lttng_directory_handle_destroy_cb destroy_cb;
+       void *destroy_cb_data;
+};
+
+static inline
+int lttng_directory_handle_get_dirfd(
+               const struct lttng_directory_handle *handle)
+{
+       return handle->dirfd;
+}
+
+#else
+struct lttng_directory_handle {
+       struct urcu_ref ref;
+       char *base_path;
+};
+#endif
+
+/*
+ * Create a directory handle to the provided path. Passing a NULL path
+ * returns a handle to the current working directory.
+ *
+ * The reference to the directory handle must be released using
+ * lttng_directory_handle_put().
+ */
+struct lttng_directory_handle *lttng_directory_handle_create(
+               const char *path);
+
+/*
+ * Create a new directory handle to a path relative to an existing handle.
+ *
+ * The provided path must already exist. Note that the creation of a
+ * subdirectory and the creation of a handle are kept as separate operations
+ * to highlight the fact that there is an inherent race between the creation of
+ * a directory and the creation of a handle to it.
+ *
+ * Passing a NULL path effectively copies the original handle.
+ *
+ * The reference to the directory handle must be released using
+ * lttng_directory_handle_put().
+ */
+struct lttng_directory_handle *lttng_directory_handle_create_from_handle(
+               const char *path,
+               const struct lttng_directory_handle *ref_handle);
+
+/*
+ * Create a new directory handle from an existing directory fd.
+ *
+ * The new directory handle assumes the ownership of the directory fd.
+ * Note that this method should only be used in very specific cases, such as
+ * re-creating a directory handle from a dirfd passed over a unix socket.
+ *
+ * The reference to the directory handle must be released using
+ * lttng_directory_handle_put().
+ */
+struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd(
+               int dirfd);
+
+/*
+ * Copy a directory handle.
+ *
+ * The reference to the directory handle must be released using
+ * lttng_directory_handle_put().
+ */
+struct lttng_directory_handle *lttng_directory_handle_copy(
+               const struct lttng_directory_handle *handle);
+
+/*
+ * Acquire a reference to a directory handle.
+ */
+bool lttng_directory_handle_get(struct lttng_directory_handle *handle);
+
+/*
+ * Release a reference to a directory handle.
+ */
+void lttng_directory_handle_put(struct lttng_directory_handle *handle);
+
+/*
+ * Create a subdirectory relative to a directory handle.
+ */
+int lttng_directory_handle_create_subdirectory(
+               const struct lttng_directory_handle *handle,
+               const char *subdirectory,
+               mode_t mode);
+
+/*
+ * Create a subdirectory relative to a directory handle
+ * as a given user.
+ */
+int lttng_directory_handle_create_subdirectory_as_user(
+               const struct lttng_directory_handle *handle,
+               const char *subdirectory,
+               mode_t mode, const struct lttng_credentials *creds);
+
+/*
+ * Recursively create a directory relative to a directory handle.
+ */
+int lttng_directory_handle_create_subdirectory_recursive(
+               const struct lttng_directory_handle *handle,
+               const char *subdirectory_path,
+               mode_t mode);
+
+/*
+ * Recursively create a directory relative to a directory handle
+ * as a given user.
+ */
+int lttng_directory_handle_create_subdirectory_recursive_as_user(
+               const struct lttng_directory_handle *handle,
+               const char *subdirectory_path,
+               mode_t mode, const struct lttng_credentials *creds);
+
+/*
+ * Open a file descriptor to a path relative to a directory handle.
+ */
+int lttng_directory_handle_open_file(
+               const struct lttng_directory_handle *handle,
+               const char *filename,
+               int flags, mode_t mode);
+
+/*
+ * Open a file descriptor to a path relative to a directory handle
+ * as a given user.
+ */
+int lttng_directory_handle_open_file_as_user(
+               const struct lttng_directory_handle *handle,
+               const char *filename,
+               int flags, mode_t mode,
+               const struct lttng_credentials *creds);
+
+/*
+ * Unlink a file to a path relative to a directory handle.
+ */
+int lttng_directory_handle_unlink_file(
+               const struct lttng_directory_handle *handle,
+               const char *filename);
+
+/*
+ * Unlink a file to a path relative to a directory handle as a given user.
+ */
+int lttng_directory_handle_unlink_file_as_user(
+               const struct lttng_directory_handle *handle,
+               const char *filename,
+               const struct lttng_credentials *creds);
+
+/*
+ * Rename a file from a path relative to a directory handle to a new
+ * name relative to another directory handle.
+ */
+int lttng_directory_handle_rename(
+               const struct lttng_directory_handle *old_handle,
+               const char *old_name,
+               const struct lttng_directory_handle *new_handle,
+               const char *new_name);
+
+/*
+ * Rename a file from a path relative to a directory handle to a new
+ * name relative to another directory handle as a given user.
+ */
+int lttng_directory_handle_rename_as_user(
+               const struct lttng_directory_handle *old_handle,
+               const char *old_name,
+               const struct lttng_directory_handle *new_handle,
+               const char *new_name,
+               const struct lttng_credentials *creds);
+
+/*
+ * Remove a subdirectory relative to a directory handle.
+ */
+int lttng_directory_handle_remove_subdirectory(
+               const struct lttng_directory_handle *handle,
+               const char *name);
+
+/*
+ * Remove a subdirectory relative to a directory handle as a given user.
+ */
+int lttng_directory_handle_remove_subdirectory_as_user(
+               const struct lttng_directory_handle *handle,
+               const char *name,
+               const struct lttng_credentials *creds);
+
+/*
+ * Remove a subdirectory and remove its contents if it only
+ * consists in empty directories.
+ * @flags: enum lttng_directory_handle_rmdir_recursive_flags
+ */
+int lttng_directory_handle_remove_subdirectory_recursive(
+               const struct lttng_directory_handle *handle,
+               const char *name, int flags);
+
+/*
+ * Remove a subdirectory and remove its contents if it only
+ * consists in empty directories as a given user.
+ * @flags: enum lttng_directory_handle_rmdir_recursive_flags
+ */
+int lttng_directory_handle_remove_subdirectory_recursive_as_user(
+               const struct lttng_directory_handle *handle,
+               const char *name,
+               const struct lttng_credentials *creds,
+               int flags);
+
+/*
+ * stat() a file relative to a directory handle.
+ */
+int lttng_directory_handle_stat(
+               const struct lttng_directory_handle *handle,
+               const char *name,
+               struct stat *stat_buf);
+
+/*
+ * Returns true if this directory handle is backed by a file
+ * descriptor, false otherwise.
+ */
+bool lttng_directory_handle_uses_fd(
+               const struct lttng_directory_handle *handle);
+
+/*
+ * Compare two directory handles.
+ *
+ * Returns true if the two directory handles are equal, false otherwise.
+ */
+bool lttng_directory_handle_equals(const struct lttng_directory_handle *lhs,
+               const struct lttng_directory_handle *rhs);
+
+
+#endif /* _COMPAT_PATH_HANDLE_H */
diff --git a/src/common/compat/dirent.h b/src/common/compat/dirent.h
deleted file mode 100644 (file)
index b760ed2..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _COMPAT_DIRENT_H
-#define _COMPAT_DIRENT_H
-
-#include <dirent.h>
-
-#ifdef HAVE_DIRFD
-static inline
-int lttng_dirfd(DIR *dir) {
-       return dirfd(dir);
-}
-#else
-# ifndef __XOPEN_OR_POSIX
-static inline
-int lttng_dirfd(DIR *dir) {
-       return dir->dd_fd;
-}
-# else
-static inline
-int lttng_dirfd(DIR *dir) {
-       return dir->d_fd;
-}
-# endif
-#endif
-
-#endif /* _COMPAT_DIRENT_H */
diff --git a/src/common/compat/dirent.hpp b/src/common/compat/dirent.hpp
new file mode 100644 (file)
index 0000000..b760ed2
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _COMPAT_DIRENT_H
+#define _COMPAT_DIRENT_H
+
+#include <dirent.h>
+
+#ifdef HAVE_DIRFD
+static inline
+int lttng_dirfd(DIR *dir) {
+       return dirfd(dir);
+}
+#else
+# ifndef __XOPEN_OR_POSIX
+static inline
+int lttng_dirfd(DIR *dir) {
+       return dir->dd_fd;
+}
+# else
+static inline
+int lttng_dirfd(DIR *dir) {
+       return dir->d_fd;
+}
+# endif
+#endif
+
+#endif /* _COMPAT_DIRENT_H */
diff --git a/src/common/compat/endian.h b/src/common/compat/endian.h
deleted file mode 100644 (file)
index ff38376..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-/*
- * This compat header provides the following defines:
- *
- *  LITTLE_ENDIAN
- *  BIG_ENDIAN
- *  BYTE_ORDER
- *
- * And functions / macros :
- *
- *  bswap_16()
- *  bswap_32()
- *  bswap_64()
- *
- *  htobe16()
- *  htole16()
- *  be16toh()
- *  le16toh()
- *
- *  htobe32()
- *  htole32()
- *  be32toh()
- *  le32toh()
- *
- *  htobe64()
- *  htole64()
- *  be64toh()
- *  le64toh()
- */
-
-#ifndef _COMPAT_ENDIAN_H
-#define _COMPAT_ENDIAN_H
-
-#if defined(__linux__) || defined(__CYGWIN__)
-#include <endian.h>
-#include <byteswap.h>
-
-/*
- * htobe/betoh are not defined for glibc <2.9, so add them
- * explicitly if they are missing.
- */
-#ifdef __USE_BSD
-/* Conversion interfaces. */
-# include <byteswap.h>
-
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-#  ifndef htobe16
-#   define htobe16(x) __bswap_16(x)
-#  endif
-#  ifndef htole16
-#   define htole16(x) (x)
-#  endif
-#  ifndef be16toh
-#   define be16toh(x) __bswap_16(x)
-#  endif
-#  ifndef le16toh
-#   define le16toh(x) (x)
-#  endif
-
-#  ifndef htobe32
-#   define htobe32(x) __bswap_32(x)
-#  endif
-#  ifndef htole32
-#   define htole32(x) (x)
-#  endif
-#  ifndef be32toh
-#   define be32toh(x) __bswap_32(x)
-#  endif
-#  ifndef le32toh
-#   define le32toh(x) (x)
-#  endif
-
-#  ifndef htobe64
-#   define htobe64(x) __bswap_64(x)
-#  endif
-#  ifndef htole64
-#   define htole64(x) (x)
-#  endif
-#  ifndef be64toh
-#   define be64toh(x) __bswap_64(x)
-#  endif
-#  ifndef le64toh
-#   define le64toh(x) (x)
-#  endif
-
-# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
-#  ifndef htobe16
-#   define htobe16(x) (x)
-#  endif
-#  ifndef htole16
-#   define htole16(x) __bswap_16(x)
-#  endif
-#  ifndef be16toh
-#   define be16toh(x) (x)
-#  endif
-#  ifndef le16toh
-#   define le16toh(x) __bswap_16(x)
-#  endif
-
-#  ifndef htobe32
-#   define htobe32(x) (x)
-#  endif
-#  ifndef htole32
-#   define htole32(x) __bswap_32(x)
-#  endif
-#  ifndef be32toh
-#   define be32toh(x) (x)
-#  endif
-#  ifndef le32toh
-#   define le32toh(x) __bswap_32(x)
-#  endif
-
-#  ifndef htobe64
-#   define htobe64(x) (x)
-#  endif
-#  ifndef htole64
-#   define htole64(x) __bswap_64(x)
-#  endif
-#  ifndef be64toh
-#   define be64toh(x) (x)
-#  endif
-#  ifndef le64toh
-#   define le64toh(x) __bswap_64(x)
-#  endif
-
-# endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
-#endif /* __USE_BSD */
-
-#elif defined(__FreeBSD__)
-#include <sys/endian.h>
-
-#define bswap_16(x)    bswap16(x)
-#define bswap_32(x)    bswap32(x)
-#define bswap_64(x)    bswap64(x)
-
-#elif defined(__sun__)
-#include <sys/byteorder.h>
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN 4321
-#endif /* __BIG_ENDIAN */
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN 1234
-#endif /* __LITTLE_ENDIAN */
-
-#ifdef _LITTLE_ENDIAN
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif /* _LITTLE_ENDIAN */
-#ifdef _BIG_ENDIAN
-#define __BYTE_ORDER __BIG_ENDIAN
-#endif /* _BIG_ENDIAN */
-
-#define LITTLE_ENDIAN  __LITTLE_ENDIAN
-#define BIG_ENDIAN     __BIG_ENDIAN
-#define BYTE_ORDER     __BYTE_ORDER
-
-#define betoh16(x) BE_16(x)
-#define letoh16(x) LE_16(x)
-#define betoh32(x) BE_32(x)
-#define letoh32(x) LE_32(x)
-#define betoh64(x) BE_64(x)
-#define letoh64(x) LE_64(x)
-#define htobe16(x) BE_16(x)
-#define be16toh(x) BE_16(x)
-#define htobe32(x) BE_32(x)
-#define be32toh(x) BE_32(x)
-#define htobe64(x) BE_64(x)
-#define be64toh(x) BE_64(x)
-
-#elif defined(__APPLE__)
-# include <machine/endian.h>
-# include <libkern/OSByteOrder.h>
-
-# if BYTE_ORDER == LITTLE_ENDIAN
-#  define htobe16(x) OSSwapConstInt16(x)
-#  define htole16(x) (x)
-#  define be16toh(x) OSSwapConstInt16(x)
-#  define le16toh(x) (x)
-
-#  define htobe32(x) OSSwapConstInt32(x)
-#  define htole32(x) (x)
-#  define be32toh(x) OSSwapConstInt32(x)
-#  define le32toh(x) (x)
-
-#  define htobe64(x) OSSwapConstInt64(x)
-#  define htole64(x) (x)
-#  define be64toh(x) OSSwapConstInt64(x)
-#  define le64toh(x) (x)
-
-# else /* BYTE_ORDER == LITTLE_ENDIAN */
-#  define htobe16(x) (x)
-#  define htole16(x) OSSwapConstInt16(x)
-#  define be16toh(x) (x)
-#  define le16toh(x) OSSwapConstInt16(x)
-
-#  define htobe32(x) (x)
-#  define htole32(x) OSSwapConstInt32(x)
-#  define be32toh(x) (x)
-#  define le32toh(x) OSSwapConstInt32(x)
-
-#  define htobe64(x) (x)
-#  define htole64(x) OSSwapConstInt64(x)
-#  define be64toh(x) (x)
-#  define le64toh(x) OSSwapConstInt64(x)
-# endif
-
-#else
-#error "Please add support for your OS."
-#endif
-
-#endif /* _COMPAT_ENDIAN_H */
diff --git a/src/common/compat/endian.hpp b/src/common/compat/endian.hpp
new file mode 100644 (file)
index 0000000..ff38376
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+/*
+ * This compat header provides the following defines:
+ *
+ *  LITTLE_ENDIAN
+ *  BIG_ENDIAN
+ *  BYTE_ORDER
+ *
+ * And functions / macros :
+ *
+ *  bswap_16()
+ *  bswap_32()
+ *  bswap_64()
+ *
+ *  htobe16()
+ *  htole16()
+ *  be16toh()
+ *  le16toh()
+ *
+ *  htobe32()
+ *  htole32()
+ *  be32toh()
+ *  le32toh()
+ *
+ *  htobe64()
+ *  htole64()
+ *  be64toh()
+ *  le64toh()
+ */
+
+#ifndef _COMPAT_ENDIAN_H
+#define _COMPAT_ENDIAN_H
+
+#if defined(__linux__) || defined(__CYGWIN__)
+#include <endian.h>
+#include <byteswap.h>
+
+/*
+ * htobe/betoh are not defined for glibc <2.9, so add them
+ * explicitly if they are missing.
+ */
+#ifdef __USE_BSD
+/* Conversion interfaces. */
+# include <byteswap.h>
+
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+#  ifndef htobe16
+#   define htobe16(x) __bswap_16(x)
+#  endif
+#  ifndef htole16
+#   define htole16(x) (x)
+#  endif
+#  ifndef be16toh
+#   define be16toh(x) __bswap_16(x)
+#  endif
+#  ifndef le16toh
+#   define le16toh(x) (x)
+#  endif
+
+#  ifndef htobe32
+#   define htobe32(x) __bswap_32(x)
+#  endif
+#  ifndef htole32
+#   define htole32(x) (x)
+#  endif
+#  ifndef be32toh
+#   define be32toh(x) __bswap_32(x)
+#  endif
+#  ifndef le32toh
+#   define le32toh(x) (x)
+#  endif
+
+#  ifndef htobe64
+#   define htobe64(x) __bswap_64(x)
+#  endif
+#  ifndef htole64
+#   define htole64(x) (x)
+#  endif
+#  ifndef be64toh
+#   define be64toh(x) __bswap_64(x)
+#  endif
+#  ifndef le64toh
+#   define le64toh(x) (x)
+#  endif
+
+# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
+#  ifndef htobe16
+#   define htobe16(x) (x)
+#  endif
+#  ifndef htole16
+#   define htole16(x) __bswap_16(x)
+#  endif
+#  ifndef be16toh
+#   define be16toh(x) (x)
+#  endif
+#  ifndef le16toh
+#   define le16toh(x) __bswap_16(x)
+#  endif
+
+#  ifndef htobe32
+#   define htobe32(x) (x)
+#  endif
+#  ifndef htole32
+#   define htole32(x) __bswap_32(x)
+#  endif
+#  ifndef be32toh
+#   define be32toh(x) (x)
+#  endif
+#  ifndef le32toh
+#   define le32toh(x) __bswap_32(x)
+#  endif
+
+#  ifndef htobe64
+#   define htobe64(x) (x)
+#  endif
+#  ifndef htole64
+#   define htole64(x) __bswap_64(x)
+#  endif
+#  ifndef be64toh
+#   define be64toh(x) (x)
+#  endif
+#  ifndef le64toh
+#   define le64toh(x) __bswap_64(x)
+#  endif
+
+# endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
+#endif /* __USE_BSD */
+
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>
+
+#define bswap_16(x)    bswap16(x)
+#define bswap_32(x)    bswap32(x)
+#define bswap_64(x)    bswap64(x)
+
+#elif defined(__sun__)
+#include <sys/byteorder.h>
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN 4321
+#endif /* __BIG_ENDIAN */
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN 1234
+#endif /* __LITTLE_ENDIAN */
+
+#ifdef _LITTLE_ENDIAN
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif /* _LITTLE_ENDIAN */
+#ifdef _BIG_ENDIAN
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif /* _BIG_ENDIAN */
+
+#define LITTLE_ENDIAN  __LITTLE_ENDIAN
+#define BIG_ENDIAN     __BIG_ENDIAN
+#define BYTE_ORDER     __BYTE_ORDER
+
+#define betoh16(x) BE_16(x)
+#define letoh16(x) LE_16(x)
+#define betoh32(x) BE_32(x)
+#define letoh32(x) LE_32(x)
+#define betoh64(x) BE_64(x)
+#define letoh64(x) LE_64(x)
+#define htobe16(x) BE_16(x)
+#define be16toh(x) BE_16(x)
+#define htobe32(x) BE_32(x)
+#define be32toh(x) BE_32(x)
+#define htobe64(x) BE_64(x)
+#define be64toh(x) BE_64(x)
+
+#elif defined(__APPLE__)
+# include <machine/endian.h>
+# include <libkern/OSByteOrder.h>
+
+# if BYTE_ORDER == LITTLE_ENDIAN
+#  define htobe16(x) OSSwapConstInt16(x)
+#  define htole16(x) (x)
+#  define be16toh(x) OSSwapConstInt16(x)
+#  define le16toh(x) (x)
+
+#  define htobe32(x) OSSwapConstInt32(x)
+#  define htole32(x) (x)
+#  define be32toh(x) OSSwapConstInt32(x)
+#  define le32toh(x) (x)
+
+#  define htobe64(x) OSSwapConstInt64(x)
+#  define htole64(x) (x)
+#  define be64toh(x) OSSwapConstInt64(x)
+#  define le64toh(x) (x)
+
+# else /* BYTE_ORDER == LITTLE_ENDIAN */
+#  define htobe16(x) (x)
+#  define htole16(x) OSSwapConstInt16(x)
+#  define be16toh(x) (x)
+#  define le16toh(x) OSSwapConstInt16(x)
+
+#  define htobe32(x) (x)
+#  define htole32(x) OSSwapConstInt32(x)
+#  define be32toh(x) (x)
+#  define le32toh(x) OSSwapConstInt32(x)
+
+#  define htobe64(x) (x)
+#  define htole64(x) OSSwapConstInt64(x)
+#  define be64toh(x) (x)
+#  define le64toh(x) OSSwapConstInt64(x)
+# endif
+
+#else
+#error "Please add support for your OS."
+#endif
+
+#endif /* _COMPAT_ENDIAN_H */
diff --git a/src/common/compat/errno.h b/src/common/compat/errno.h
deleted file mode 100644 (file)
index 2044439..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_ERRNO_H
-#define _COMPAT_ERRNO_H
-
-#include <errno.h>
-
-/* Missing on FreeBSD */
-#ifndef ENODATA
-#define ENODATA ENOATTR
-#endif
-
-#endif /* _COMPAT_ERRNO_H */
diff --git a/src/common/compat/errno.hpp b/src/common/compat/errno.hpp
new file mode 100644 (file)
index 0000000..2044439
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_ERRNO_H
+#define _COMPAT_ERRNO_H
+
+#include <errno.h>
+
+/* Missing on FreeBSD */
+#ifndef ENODATA
+#define ENODATA ENOATTR
+#endif
+
+#endif /* _COMPAT_ERRNO_H */
diff --git a/src/common/compat/fcntl.h b/src/common/compat/fcntl.h
deleted file mode 100644 (file)
index 9fca7f0..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_FCNTL_H
-#define _COMPAT_FCNTL_H
-
-#include <fcntl.h>
-#include <sys/types.h>
-
-#include <common/compat/errno.h>
-
-#if (defined(__CYGWIN__))
-typedef long long off64_t;
-#endif
-
-#if (defined(__FreeBSD__) || defined(__sun__))
-typedef off64_t loff_t;
-#endif
-
-#ifdef __linux__
-extern int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
-               unsigned int flags);
-#define lttng_sync_file_range(fd, offset, nbytes, flags) \
-       compat_sync_file_range(fd, offset, nbytes, flags)
-
-#endif /* __linux__ */
-
-#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
-/*
- * Possible flags under Linux. Simply nullify them and avoid wrapper.
- */
-#define SYNC_FILE_RANGE_WAIT_AFTER    0
-#define SYNC_FILE_RANGE_WAIT_BEFORE   0
-#define SYNC_FILE_RANGE_WRITE         0
-
-static inline int lttng_sync_file_range(
-               int fd __attribute__((unused)),
-               off64_t offset __attribute__((unused)),
-               off64_t nbytes __attribute__((unused)),
-               unsigned int flags __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-#endif
-
-#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
-/*
- * Possible flags under Linux. Simply nullify them and avoid wrappers.
- */
-#define SPLICE_F_MOVE       0
-#define SPLICE_F_NONBLOCK   0
-#define SPLICE_F_MORE       0
-#define SPLICE_F_GIFT       0
-
-static inline ssize_t splice(
-               int fd_in __attribute__((unused)),
-               loff_t *off_in __attribute__((unused)),
-               int fd_out __attribute__((unused)),
-               loff_t *off_out __attribute__((unused)),
-               size_t len __attribute__((unused)),
-               unsigned int flags __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-#endif
-
-#if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
-#error "Please add support for your OS."
-#endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */
-
-#endif /* _COMPAT_FCNTL_H */
diff --git a/src/common/compat/fcntl.hpp b/src/common/compat/fcntl.hpp
new file mode 100644 (file)
index 0000000..a526ca5
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_FCNTL_H
+#define _COMPAT_FCNTL_H
+
+#include <fcntl.h>
+#include <sys/types.h>
+
+#include <common/compat/errno.hpp>
+
+#if (defined(__CYGWIN__))
+typedef long long off64_t;
+#endif
+
+#if (defined(__FreeBSD__) || defined(__sun__))
+typedef off64_t loff_t;
+#endif
+
+#ifdef __linux__
+extern int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
+               unsigned int flags);
+#define lttng_sync_file_range(fd, offset, nbytes, flags) \
+       compat_sync_file_range(fd, offset, nbytes, flags)
+
+#endif /* __linux__ */
+
+#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
+/*
+ * Possible flags under Linux. Simply nullify them and avoid wrapper.
+ */
+#define SYNC_FILE_RANGE_WAIT_AFTER    0
+#define SYNC_FILE_RANGE_WAIT_BEFORE   0
+#define SYNC_FILE_RANGE_WRITE         0
+
+static inline int lttng_sync_file_range(
+               int fd __attribute__((unused)),
+               off64_t offset __attribute__((unused)),
+               off64_t nbytes __attribute__((unused)),
+               unsigned int flags __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+#endif
+
+#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
+/*
+ * Possible flags under Linux. Simply nullify them and avoid wrappers.
+ */
+#define SPLICE_F_MOVE       0
+#define SPLICE_F_NONBLOCK   0
+#define SPLICE_F_MORE       0
+#define SPLICE_F_GIFT       0
+
+static inline ssize_t splice(
+               int fd_in __attribute__((unused)),
+               loff_t *off_in __attribute__((unused)),
+               int fd_out __attribute__((unused)),
+               loff_t *off_out __attribute__((unused)),
+               size_t len __attribute__((unused)),
+               unsigned int flags __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+#endif
+
+#if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
+#error "Please add support for your OS."
+#endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */
+
+#endif /* _COMPAT_FCNTL_H */
diff --git a/src/common/compat/getenv.h b/src/common/compat/getenv.h
deleted file mode 100644 (file)
index 2a6c003..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef _COMPAT_GETENV_H
-#define _COMPAT_GETENV_H
-
-/*
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <common/error.h>
-
-static inline
-int lttng_is_setuid_setgid(void)
-{
-       return geteuid() != getuid() || getegid() != getgid();
-}
-
-static inline
-char *lttng_secure_getenv(const char *name)
-{
-       if (lttng_is_setuid_setgid()) {
-               WARN("Getting environment variable '%s' from setuid/setgid binary refused for security reasons.",
-                       name);
-               return NULL;
-       }
-       return getenv(name);
-}
-
-#endif /* _COMPAT_GETENV_H */
diff --git a/src/common/compat/getenv.hpp b/src/common/compat/getenv.hpp
new file mode 100644 (file)
index 0000000..7a31fef
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef _COMPAT_GETENV_H
+#define _COMPAT_GETENV_H
+
+/*
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <common/error.hpp>
+
+static inline
+int lttng_is_setuid_setgid(void)
+{
+       return geteuid() != getuid() || getegid() != getgid();
+}
+
+static inline
+char *lttng_secure_getenv(const char *name)
+{
+       if (lttng_is_setuid_setgid()) {
+               WARN("Getting environment variable '%s' from setuid/setgid binary refused for security reasons.",
+                       name);
+               return NULL;
+       }
+       return getenv(name);
+}
+
+#endif /* _COMPAT_GETENV_H */
diff --git a/src/common/compat/mman.h b/src/common/compat/mman.h
deleted file mode 100644 (file)
index 61d27b8..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_MMAN_H
-#define _COMPAT_MMAN_H
-
-#include <sys/mman.h>
-
-#ifdef __linux__
-
-#elif defined(__FreeBSD__)
-
-#define MAP_GROWSDOWN 0
-#define MAP_ANONYMOUS MAP_ANON
-
-#elif defined(__CYGWIN__) || defined(__sun__)
-
-#define MAP_GROWSDOWN 0
-
-#else
-#error "Please add support for your OS."
-#endif /* __linux__ */
-
-#endif /* _COMPAT_MMAN_H */
diff --git a/src/common/compat/mman.hpp b/src/common/compat/mman.hpp
new file mode 100644 (file)
index 0000000..61d27b8
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_MMAN_H
+#define _COMPAT_MMAN_H
+
+#include <sys/mman.h>
+
+#ifdef __linux__
+
+#elif defined(__FreeBSD__)
+
+#define MAP_GROWSDOWN 0
+#define MAP_ANONYMOUS MAP_ANON
+
+#elif defined(__CYGWIN__) || defined(__sun__)
+
+#define MAP_GROWSDOWN 0
+
+#else
+#error "Please add support for your OS."
+#endif /* __linux__ */
+
+#endif /* _COMPAT_MMAN_H */
diff --git a/src/common/compat/netdb.h b/src/common/compat/netdb.h
deleted file mode 100644 (file)
index a8bf7e2..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _COMPAT_NETDB_H
-#define _COMPAT_NETDB_H
-
-#include <netdb.h>
-
-#ifdef HAVE_GETHOSTBYNAME2
-static inline
-struct hostent *lttng_gethostbyname2(const char *name, int af) {
-       return gethostbyname2(name, af);
-}
-#elif HAVE_GETIPNODEBYNAME
-static inline
-struct hostent *lttng_gethostbyname2(const char *name, int af) {
-       int unused;
-
-       return getipnodebyname(name, af, AI_DEFAULT, &unused);
-}
-#else
-# error "Missing compat for gethostbyname2()"
-#endif
-
-#endif /* _COMPAT_NETDB_H */
diff --git a/src/common/compat/netdb.hpp b/src/common/compat/netdb.hpp
new file mode 100644 (file)
index 0000000..a8bf7e2
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _COMPAT_NETDB_H
+#define _COMPAT_NETDB_H
+
+#include <netdb.h>
+
+#ifdef HAVE_GETHOSTBYNAME2
+static inline
+struct hostent *lttng_gethostbyname2(const char *name, int af) {
+       return gethostbyname2(name, af);
+}
+#elif HAVE_GETIPNODEBYNAME
+static inline
+struct hostent *lttng_gethostbyname2(const char *name, int af) {
+       int unused;
+
+       return getipnodebyname(name, af, AI_DEFAULT, &unused);
+}
+#else
+# error "Missing compat for gethostbyname2()"
+#endif
+
+#endif /* _COMPAT_NETDB_H */
diff --git a/src/common/compat/path.h b/src/common/compat/path.h
deleted file mode 100644 (file)
index 8c3d1de..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_PATH_H
-#define _COMPAT_PATH_H
-
-/* Build platform's preferred path separator. */
-#if defined(_WIN32) || defined(__CYGWIN__)
-#define LTTNG_PATH_SEPARATOR '\\'
-#else
-#define LTTNG_PATH_SEPARATOR '/'
-#endif
-
-#endif /* _COMPAT_PATH_H */
diff --git a/src/common/compat/path.hpp b/src/common/compat/path.hpp
new file mode 100644 (file)
index 0000000..8c3d1de
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_PATH_H
+#define _COMPAT_PATH_H
+
+/* Build platform's preferred path separator. */
+#if defined(_WIN32) || defined(__CYGWIN__)
+#define LTTNG_PATH_SEPARATOR '\\'
+#else
+#define LTTNG_PATH_SEPARATOR '/'
+#endif
+
+#endif /* _COMPAT_PATH_H */
diff --git a/src/common/compat/paths.h b/src/common/compat/paths.h
deleted file mode 100644 (file)
index 0203ae8..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_PATHS_H
-#define _COMPAT_PATHS_H
-
-#ifdef HAVE_PATHS_H
-#include <paths.h>
-#else
-# define _PATH_DEVNULL "/dev/null"
-#endif
-
-#endif /* _COMPAT_PATHS_H */
diff --git a/src/common/compat/paths.hpp b/src/common/compat/paths.hpp
new file mode 100644 (file)
index 0000000..0203ae8
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_PATHS_H
+#define _COMPAT_PATHS_H
+
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#else
+# define _PATH_DEVNULL "/dev/null"
+#endif
+
+#endif /* _COMPAT_PATHS_H */
index 910b0f62aee469dfc1691e3b7eb212c01d1fdeb7..4f532a26d66715adc77cafce1ba30481112449b8 100644 (file)
 #include <stdlib.h>
 #include <stdbool.h>
 
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/utils.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/utils.hpp>
 
-#include "poll.h"
+#include "poll.hpp"
 
 #ifdef HAVE_EPOLL
 
diff --git a/src/common/compat/poll.h b/src/common/compat/poll.h
deleted file mode 100644 (file)
index cc2aab8..0000000
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _LTT_POLL_H
-#define _LTT_POLL_H
-
-#include <string.h>
-#include <unistd.h>
-
-#include <common/common.h>
-
-/*
- * Used by lttng_poll_clean to free the events structure in a lttng_poll_event.
- */
-static inline void __lttng_poll_free(void *events)
-{
-       free(events);
-}
-
-/*
- * epoll(7) implementation.
- */
-#ifdef HAVE_EPOLL
-#include <sys/epoll.h>
-#include <stdio.h>
-#include <features.h>
-#include <common/compat/fcntl.h>
-
-/* See man epoll(7) for this define path */
-#define COMPAT_EPOLL_PROC_PATH "/proc/sys/fs/epoll/max_user_watches"
-
-enum {
-       /* Polling variables compatibility for epoll */
-       LPOLLIN = EPOLLIN,
-       LPOLLPRI = EPOLLPRI,
-       LPOLLOUT = EPOLLOUT,
-       LPOLLRDNORM = EPOLLRDNORM,
-       LPOLLRDBAND = EPOLLRDBAND,
-       LPOLLWRNORM = EPOLLWRNORM,
-       LPOLLWRBAND = EPOLLWRBAND,
-       LPOLLMSG = EPOLLMSG,
-       LPOLLERR = EPOLLERR,
-       LPOLLHUP = EPOLLHUP,
-       LPOLLNVAL = EPOLLHUP,
-       LPOLLRDHUP = EPOLLRDHUP,
-       /* Close on exec feature of epoll */
-#if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
-       LTTNG_CLOEXEC = EPOLL_CLOEXEC,
-#else
-       /*
-        * EPOLL_CLOEXEC was added in glibc 2.8 (usually used in conjunction with
-        * epoll_create1(..)), but since neither EPOLL_CLOEXEC exists nor
-        * epoll_create1(..), we set it to FD_CLOEXEC so that we can pass it
-        * directly to fcntl(..) instead.
-        */
-       LTTNG_CLOEXEC = FD_CLOEXEC,
-#endif
-};
-
-struct compat_epoll_event {
-       int epfd;
-       uint32_t nb_fd;       /* Current number of fd in events */
-       uint32_t alloc_size; /* Size of events array */
-       uint32_t init_size;     /* Initial size of events array */
-       struct epoll_event *events;
-};
-#define lttng_poll_event compat_epoll_event
-
-static inline int __lttng_epoll_get_prev_fd(struct lttng_poll_event *events,
-               int index, uint32_t nb_fd)
-{
-       LTTNG_ASSERT(events);
-       LTTNG_ASSERT(index != nb_fd);
-
-       if (index == 0 || nb_fd == 0) {
-               return -1;
-       } else {
-               return events->events[index - 1].data.fd;
-       }
-}
-
-/*
- * For the following calls, consider 'e' to be a lttng_poll_event pointer and i
- * being the index of the events array.
- */
-#define LTTNG_POLL_GETFD(e, i) LTTNG_REF(e)->events[i].data.fd
-#define LTTNG_POLL_GETEV(e, i) LTTNG_REF(e)->events[i].events
-#define LTTNG_POLL_GETNB(e) LTTNG_REF(e)->nb_fd
-#define LTTNG_POLL_GETSZ(e) LTTNG_REF(e)->events_size
-#define LTTNG_POLL_GET_PREV_FD(e, i, nb_fd) \
-       __lttng_epoll_get_prev_fd(LTTNG_REF(e), i, nb_fd)
-
-/* Create the epoll set. */
-extern int compat_epoll_create(struct lttng_poll_event *events,
-               int size, int flags);
-#define lttng_poll_create(events, size, flags) \
-       compat_epoll_create(events, size, flags)
-
-#if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
-static inline int compat_glibc_epoll_create(int size __attribute__((unused)),
-               int flags)
-{
-       return epoll_create1(flags);
-}
-#else
-static inline int compat_glibc_epoll_create(int size, int flags)
-{
-       /*
-        * epoll_create1 was added in glibc 2.9, but unfortunatly reverting to
-        * epoll_create(..) also means that we lose the possibility to
-        * directly set the EPOLL_CLOEXEC, so try and do it anyway but through
-        * fcntl(..).
-        */
-       int efd = epoll_create(size);
-       LTTNG_ASSERT(fcntl(efd, F_SETFD, flags) != -1);
-       return efd;
-}
-#endif
-
-/*
- * Wait on epoll set with the number of fd registered to the lttng_poll_event
- * data structure (events).
- */
-extern int compat_epoll_wait(struct lttng_poll_event *events, int timeout,
-               bool interruptible);
-#define lttng_poll_wait(events, timeout) \
-       compat_epoll_wait(events, timeout, false)
-#define lttng_poll_wait_interruptible(events, timeout) \
-       compat_epoll_wait(events, timeout, true)
-
-/*
- * Add a fd to the epoll set and resize the epoll_event structure if needed.
- */
-extern int compat_epoll_add(struct lttng_poll_event *events,
-               int fd, uint32_t req_events);
-#define lttng_poll_add(events, fd, req_events) \
-       compat_epoll_add(events, fd, req_events)
-
-/*
- * Remove a fd from the epoll set.
- */
-extern int compat_epoll_del(struct lttng_poll_event *events, int fd);
-#define lttng_poll_del(events, fd) \
-       compat_epoll_del(events, fd)
-
-/*
- * Modify an fd's events in the epoll set.
- */
-extern int compat_epoll_mod(struct lttng_poll_event *events,
-               int fd, uint32_t req_events);
-#define lttng_poll_mod(events, fd, req_events) \
-       compat_epoll_mod(events, fd, req_events)
-
-/*
- * Set up the poll set limits variable poll_max_size
- */
-extern int compat_epoll_set_max_size(void);
-#define lttng_poll_set_max_size() \
-       compat_epoll_set_max_size()
-
-/*
- * This function memset with zero the structure since it can be reused at each
- * round of a main loop. Being in a loop and using a non static number of fds,
- * this function must be called to insure coherent events with associted fds.
- */
-static inline void lttng_poll_reset(struct lttng_poll_event *events)
-{
-       if (events && events->events) {
-               memset(events->events, 0,
-                               events->nb_fd * sizeof(struct epoll_event));
-       }
-}
-
-/*
- * Initialize an already allocated poll event data structure. For epoll(), the
- * epfd is set to -1 to indicate that it's not usable.
- */
-static inline void lttng_poll_init(struct lttng_poll_event *events)
-{
-       memset(events, 0, sizeof(struct lttng_poll_event));
-       /* Set fd to -1 so if clean before created, we don't close 0. */
-       events->epfd = -1;
-}
-
-/*
- * Clean the events structure of a lttng_poll_event. It's the caller
- * responsability to free the lttng_poll_event memory.
- */
-static inline void lttng_poll_clean(struct lttng_poll_event *events)
-{
-       int ret;
-
-       if (!events) {
-               return;
-       }
-
-       if (events->epfd >= 0) {
-               ret = close(events->epfd);
-               if (ret) {
-                       PERROR("close");
-               }
-       }
-
-       __lttng_poll_free((void *) events->events);
-}
-
-#else  /* HAVE_EPOLL */
-/*
- * Fallback on poll(2) API
- */
-
-/* Needed for some poll event values */
-#ifndef __USE_XOPEN
-#define __USE_XOPEN
-#endif
-
-/* Needed for some poll event values */
-#ifndef __USE_GNU
-#define __USE_GNU
-#endif
-
-#include <poll.h>
-#include <stdint.h>
-
-enum {
-       /* Polling variables compatibility for poll */
-       LPOLLIN = POLLIN,
-       LPOLLPRI = POLLPRI,
-       LPOLLOUT = POLLOUT,
-       LPOLLRDNORM = POLLRDNORM,
-       LPOLLRDBAND = POLLRDBAND,
-       LPOLLWRNORM = POLLWRNORM,
-       LPOLLWRBAND = POLLWRBAND,
-#ifdef __linux__
-       LPOLLMSG = POLLMSG,
-       LPOLLRDHUP = POLLRDHUP,
-#elif (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
-       LPOLLMSG = 0,
-       LPOLLRDHUP = 0,
-#else
-#error "Please add support for your OS."
-#endif /* __linux__ */
-       LPOLLERR = POLLERR,
-       LPOLLHUP = POLLHUP | POLLNVAL,
-       /* Close on exec feature does not exist for poll(2) */
-       LTTNG_CLOEXEC = 0xdead,
-};
-
-struct compat_poll_event_array {
-       uint32_t nb_fd;       /* Current number of fd in events */
-       uint32_t alloc_size; /* Size of events array */
-       /* Initial size of the pollset. We never shrink below that. */
-       uint32_t init_size;
-       struct pollfd *events;
-};
-
-struct compat_poll_event {
-       /*
-        * Modified by the wait action. Updated using current fields if the
-        * need_update flag is set.
-        */
-       struct compat_poll_event_array wait;
-       /*
-        * This is modified by add/del actions being the _current_ flow of
-        * execution before a poll wait is done.
-        */
-       struct compat_poll_event_array current;
-
-       /* Indicate if wait.events need to be updated from current. */
-       int need_update:1;
-};
-#define lttng_poll_event compat_poll_event
-
-static inline int __lttng_poll_get_prev_fd(struct lttng_poll_event *events,
-               int index, uint32_t nb_fd)
-{
-       LTTNG_ASSERT(events);
-       LTTNG_ASSERT(index != nb_fd);
-
-       if (index == 0 || nb_fd == 0) {
-               return -1;
-       } else {
-               return events->current.events[index - 1].fd;
-       }
-}
-
-/*
- * For the following calls, consider 'e' to be a lttng_poll_event pointer and i
- * being the index of the events array.
- * LTTNG_POLL_GETNB is always used after lttng_poll_wait, thus we can use the
- * current list for test compatibility purposes.
- */
-#define LTTNG_POLL_GETFD(e, i) LTTNG_REF(e)->wait.events[i].fd
-#define LTTNG_POLL_GETEV(e, i) LTTNG_REF(e)->wait.events[i].revents
-#define LTTNG_POLL_GETNB(e) LTTNG_REF(e)->current.nb_fd
-#define LTTNG_POLL_GETSZ(e) LTTNG_REF(e)->wait.events_size
-#define LTTNG_POLL_GET_PREV_FD(e, i, nb_fd) \
-       __lttng_poll_get_prev_fd(LTTNG_REF(e), i, nb_fd)
-
-/*
- * Create a pollfd structure of size 'size'.
- */
-extern int compat_poll_create(struct lttng_poll_event *events, int size);
-#define lttng_poll_create(events, size, flags) \
-       compat_poll_create(events, size)
-
-/*
- * Wait on poll(2) event with nb_fd registered to the lttng_poll_event data
- * structure.
- */
-extern int compat_poll_wait(struct lttng_poll_event *events, int timeout,
-               bool interruptible);
-#define lttng_poll_wait(events, timeout) \
-       compat_poll_wait(events, timeout, false)
-#define lttng_poll_wait_interruptible(events, timeout) \
-       compat_poll_wait(events, timeout, true)
-
-/*
- * Add the fd to the pollfd structure. Resize if needed.
- */
-extern int compat_poll_add(struct lttng_poll_event *events,
-               int fd, uint32_t req_events);
-#define lttng_poll_add(events, fd, req_events) \
-       compat_poll_add(events, fd, req_events)
-
-/*
- * Remove the fd from the pollfd. Memory allocation is done to recreate a new
- * pollfd, data is copied from the old pollfd to the new and, finally, the old
- * one is freed().
- */
-extern int compat_poll_del(struct lttng_poll_event *events, int fd);
-#define lttng_poll_del(events, fd) \
-       compat_poll_del(events, fd)
-
-/*
- * Modify an fd's events in the poll set.
- */
-extern int compat_poll_mod(struct lttng_poll_event *events,
-               int fd, uint32_t req_events);
-#define lttng_poll_mod(events, fd, req_events) \
-       compat_poll_mod(events, fd, req_events)
-
-/*
- * Set up the poll set limits variable poll_max_size
- */
-extern int compat_poll_set_max_size(void);
-#define lttng_poll_set_max_size() \
-       compat_poll_set_max_size()
-
-/*
- * No need to reset a pollfd structure for poll(2)
- */
-static inline void lttng_poll_reset(
-               struct lttng_poll_event *events __attribute__((unused)))
-{}
-
-/*
- * Initialize an already allocated poll event data structure.
- */
-static inline void lttng_poll_init(struct lttng_poll_event *events)
-{
-       memset(events, 0, sizeof(struct lttng_poll_event));
-}
-
-/*
- * Clean the events structure of a lttng_poll_event. It's the caller
- * responsability to free the lttng_poll_event memory.
- */
-static inline void lttng_poll_clean(struct lttng_poll_event *events)
-{
-       if (events) {
-               __lttng_poll_free((void *) events->wait.events);
-               __lttng_poll_free((void *) events->current.events);
-       }
-}
-
-#endif /* HAVE_EPOLL */
-
-#endif /* _LTT_POLL_H */
diff --git a/src/common/compat/poll.hpp b/src/common/compat/poll.hpp
new file mode 100644 (file)
index 0000000..3cb07bf
--- /dev/null
@@ -0,0 +1,383 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _LTT_POLL_H
+#define _LTT_POLL_H
+
+#include <string.h>
+#include <unistd.h>
+
+#include <common/common.hpp>
+
+/*
+ * Used by lttng_poll_clean to free the events structure in a lttng_poll_event.
+ */
+static inline void __lttng_poll_free(void *events)
+{
+       free(events);
+}
+
+/*
+ * epoll(7) implementation.
+ */
+#ifdef HAVE_EPOLL
+#include <sys/epoll.h>
+#include <stdio.h>
+#include <features.h>
+#include <common/compat/fcntl.hpp>
+
+/* See man epoll(7) for this define path */
+#define COMPAT_EPOLL_PROC_PATH "/proc/sys/fs/epoll/max_user_watches"
+
+enum {
+       /* Polling variables compatibility for epoll */
+       LPOLLIN = EPOLLIN,
+       LPOLLPRI = EPOLLPRI,
+       LPOLLOUT = EPOLLOUT,
+       LPOLLRDNORM = EPOLLRDNORM,
+       LPOLLRDBAND = EPOLLRDBAND,
+       LPOLLWRNORM = EPOLLWRNORM,
+       LPOLLWRBAND = EPOLLWRBAND,
+       LPOLLMSG = EPOLLMSG,
+       LPOLLERR = EPOLLERR,
+       LPOLLHUP = EPOLLHUP,
+       LPOLLNVAL = EPOLLHUP,
+       LPOLLRDHUP = EPOLLRDHUP,
+       /* Close on exec feature of epoll */
+#if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
+       LTTNG_CLOEXEC = EPOLL_CLOEXEC,
+#else
+       /*
+        * EPOLL_CLOEXEC was added in glibc 2.8 (usually used in conjunction with
+        * epoll_create1(..)), but since neither EPOLL_CLOEXEC exists nor
+        * epoll_create1(..), we set it to FD_CLOEXEC so that we can pass it
+        * directly to fcntl(..) instead.
+        */
+       LTTNG_CLOEXEC = FD_CLOEXEC,
+#endif
+};
+
+struct compat_epoll_event {
+       int epfd;
+       uint32_t nb_fd;       /* Current number of fd in events */
+       uint32_t alloc_size; /* Size of events array */
+       uint32_t init_size;     /* Initial size of events array */
+       struct epoll_event *events;
+};
+#define lttng_poll_event compat_epoll_event
+
+static inline int __lttng_epoll_get_prev_fd(struct lttng_poll_event *events,
+               int index, uint32_t nb_fd)
+{
+       LTTNG_ASSERT(events);
+       LTTNG_ASSERT(index != nb_fd);
+
+       if (index == 0 || nb_fd == 0) {
+               return -1;
+       } else {
+               return events->events[index - 1].data.fd;
+       }
+}
+
+/*
+ * For the following calls, consider 'e' to be a lttng_poll_event pointer and i
+ * being the index of the events array.
+ */
+#define LTTNG_POLL_GETFD(e, i) LTTNG_REF(e)->events[i].data.fd
+#define LTTNG_POLL_GETEV(e, i) LTTNG_REF(e)->events[i].events
+#define LTTNG_POLL_GETNB(e) LTTNG_REF(e)->nb_fd
+#define LTTNG_POLL_GETSZ(e) LTTNG_REF(e)->events_size
+#define LTTNG_POLL_GET_PREV_FD(e, i, nb_fd) \
+       __lttng_epoll_get_prev_fd(LTTNG_REF(e), i, nb_fd)
+
+/* Create the epoll set. */
+extern int compat_epoll_create(struct lttng_poll_event *events,
+               int size, int flags);
+#define lttng_poll_create(events, size, flags) \
+       compat_epoll_create(events, size, flags)
+
+#if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
+static inline int compat_glibc_epoll_create(int size __attribute__((unused)),
+               int flags)
+{
+       return epoll_create1(flags);
+}
+#else
+static inline int compat_glibc_epoll_create(int size, int flags)
+{
+       /*
+        * epoll_create1 was added in glibc 2.9, but unfortunatly reverting to
+        * epoll_create(..) also means that we lose the possibility to
+        * directly set the EPOLL_CLOEXEC, so try and do it anyway but through
+        * fcntl(..).
+        */
+       int efd = epoll_create(size);
+       LTTNG_ASSERT(fcntl(efd, F_SETFD, flags) != -1);
+       return efd;
+}
+#endif
+
+/*
+ * Wait on epoll set with the number of fd registered to the lttng_poll_event
+ * data structure (events).
+ */
+extern int compat_epoll_wait(struct lttng_poll_event *events, int timeout,
+               bool interruptible);
+#define lttng_poll_wait(events, timeout) \
+       compat_epoll_wait(events, timeout, false)
+#define lttng_poll_wait_interruptible(events, timeout) \
+       compat_epoll_wait(events, timeout, true)
+
+/*
+ * Add a fd to the epoll set and resize the epoll_event structure if needed.
+ */
+extern int compat_epoll_add(struct lttng_poll_event *events,
+               int fd, uint32_t req_events);
+#define lttng_poll_add(events, fd, req_events) \
+       compat_epoll_add(events, fd, req_events)
+
+/*
+ * Remove a fd from the epoll set.
+ */
+extern int compat_epoll_del(struct lttng_poll_event *events, int fd);
+#define lttng_poll_del(events, fd) \
+       compat_epoll_del(events, fd)
+
+/*
+ * Modify an fd's events in the epoll set.
+ */
+extern int compat_epoll_mod(struct lttng_poll_event *events,
+               int fd, uint32_t req_events);
+#define lttng_poll_mod(events, fd, req_events) \
+       compat_epoll_mod(events, fd, req_events)
+
+/*
+ * Set up the poll set limits variable poll_max_size
+ */
+extern int compat_epoll_set_max_size(void);
+#define lttng_poll_set_max_size() \
+       compat_epoll_set_max_size()
+
+/*
+ * This function memset with zero the structure since it can be reused at each
+ * round of a main loop. Being in a loop and using a non static number of fds,
+ * this function must be called to insure coherent events with associted fds.
+ */
+static inline void lttng_poll_reset(struct lttng_poll_event *events)
+{
+       if (events && events->events) {
+               memset(events->events, 0,
+                               events->nb_fd * sizeof(struct epoll_event));
+       }
+}
+
+/*
+ * Initialize an already allocated poll event data structure. For epoll(), the
+ * epfd is set to -1 to indicate that it's not usable.
+ */
+static inline void lttng_poll_init(struct lttng_poll_event *events)
+{
+       memset(events, 0, sizeof(struct lttng_poll_event));
+       /* Set fd to -1 so if clean before created, we don't close 0. */
+       events->epfd = -1;
+}
+
+/*
+ * Clean the events structure of a lttng_poll_event. It's the caller
+ * responsability to free the lttng_poll_event memory.
+ */
+static inline void lttng_poll_clean(struct lttng_poll_event *events)
+{
+       int ret;
+
+       if (!events) {
+               return;
+       }
+
+       if (events->epfd >= 0) {
+               ret = close(events->epfd);
+               if (ret) {
+                       PERROR("close");
+               }
+       }
+
+       __lttng_poll_free((void *) events->events);
+}
+
+#else  /* HAVE_EPOLL */
+/*
+ * Fallback on poll(2) API
+ */
+
+/* Needed for some poll event values */
+#ifndef __USE_XOPEN
+#define __USE_XOPEN
+#endif
+
+/* Needed for some poll event values */
+#ifndef __USE_GNU
+#define __USE_GNU
+#endif
+
+#include <poll.h>
+#include <stdint.h>
+
+enum {
+       /* Polling variables compatibility for poll */
+       LPOLLIN = POLLIN,
+       LPOLLPRI = POLLPRI,
+       LPOLLOUT = POLLOUT,
+       LPOLLRDNORM = POLLRDNORM,
+       LPOLLRDBAND = POLLRDBAND,
+       LPOLLWRNORM = POLLWRNORM,
+       LPOLLWRBAND = POLLWRBAND,
+#ifdef __linux__
+       LPOLLMSG = POLLMSG,
+       LPOLLRDHUP = POLLRDHUP,
+#elif (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
+       LPOLLMSG = 0,
+       LPOLLRDHUP = 0,
+#else
+#error "Please add support for your OS."
+#endif /* __linux__ */
+       LPOLLERR = POLLERR,
+       LPOLLHUP = POLLHUP | POLLNVAL,
+       /* Close on exec feature does not exist for poll(2) */
+       LTTNG_CLOEXEC = 0xdead,
+};
+
+struct compat_poll_event_array {
+       uint32_t nb_fd;       /* Current number of fd in events */
+       uint32_t alloc_size; /* Size of events array */
+       /* Initial size of the pollset. We never shrink below that. */
+       uint32_t init_size;
+       struct pollfd *events;
+};
+
+struct compat_poll_event {
+       /*
+        * Modified by the wait action. Updated using current fields if the
+        * need_update flag is set.
+        */
+       struct compat_poll_event_array wait;
+       /*
+        * This is modified by add/del actions being the _current_ flow of
+        * execution before a poll wait is done.
+        */
+       struct compat_poll_event_array current;
+
+       /* Indicate if wait.events need to be updated from current. */
+       int need_update:1;
+};
+#define lttng_poll_event compat_poll_event
+
+static inline int __lttng_poll_get_prev_fd(struct lttng_poll_event *events,
+               int index, uint32_t nb_fd)
+{
+       LTTNG_ASSERT(events);
+       LTTNG_ASSERT(index != nb_fd);
+
+       if (index == 0 || nb_fd == 0) {
+               return -1;
+       } else {
+               return events->current.events[index - 1].fd;
+       }
+}
+
+/*
+ * For the following calls, consider 'e' to be a lttng_poll_event pointer and i
+ * being the index of the events array.
+ * LTTNG_POLL_GETNB is always used after lttng_poll_wait, thus we can use the
+ * current list for test compatibility purposes.
+ */
+#define LTTNG_POLL_GETFD(e, i) LTTNG_REF(e)->wait.events[i].fd
+#define LTTNG_POLL_GETEV(e, i) LTTNG_REF(e)->wait.events[i].revents
+#define LTTNG_POLL_GETNB(e) LTTNG_REF(e)->current.nb_fd
+#define LTTNG_POLL_GETSZ(e) LTTNG_REF(e)->wait.events_size
+#define LTTNG_POLL_GET_PREV_FD(e, i, nb_fd) \
+       __lttng_poll_get_prev_fd(LTTNG_REF(e), i, nb_fd)
+
+/*
+ * Create a pollfd structure of size 'size'.
+ */
+extern int compat_poll_create(struct lttng_poll_event *events, int size);
+#define lttng_poll_create(events, size, flags) \
+       compat_poll_create(events, size)
+
+/*
+ * Wait on poll(2) event with nb_fd registered to the lttng_poll_event data
+ * structure.
+ */
+extern int compat_poll_wait(struct lttng_poll_event *events, int timeout,
+               bool interruptible);
+#define lttng_poll_wait(events, timeout) \
+       compat_poll_wait(events, timeout, false)
+#define lttng_poll_wait_interruptible(events, timeout) \
+       compat_poll_wait(events, timeout, true)
+
+/*
+ * Add the fd to the pollfd structure. Resize if needed.
+ */
+extern int compat_poll_add(struct lttng_poll_event *events,
+               int fd, uint32_t req_events);
+#define lttng_poll_add(events, fd, req_events) \
+       compat_poll_add(events, fd, req_events)
+
+/*
+ * Remove the fd from the pollfd. Memory allocation is done to recreate a new
+ * pollfd, data is copied from the old pollfd to the new and, finally, the old
+ * one is freed().
+ */
+extern int compat_poll_del(struct lttng_poll_event *events, int fd);
+#define lttng_poll_del(events, fd) \
+       compat_poll_del(events, fd)
+
+/*
+ * Modify an fd's events in the poll set.
+ */
+extern int compat_poll_mod(struct lttng_poll_event *events,
+               int fd, uint32_t req_events);
+#define lttng_poll_mod(events, fd, req_events) \
+       compat_poll_mod(events, fd, req_events)
+
+/*
+ * Set up the poll set limits variable poll_max_size
+ */
+extern int compat_poll_set_max_size(void);
+#define lttng_poll_set_max_size() \
+       compat_poll_set_max_size()
+
+/*
+ * No need to reset a pollfd structure for poll(2)
+ */
+static inline void lttng_poll_reset(
+               struct lttng_poll_event *events __attribute__((unused)))
+{}
+
+/*
+ * Initialize an already allocated poll event data structure.
+ */
+static inline void lttng_poll_init(struct lttng_poll_event *events)
+{
+       memset(events, 0, sizeof(struct lttng_poll_event));
+}
+
+/*
+ * Clean the events structure of a lttng_poll_event. It's the caller
+ * responsability to free the lttng_poll_event memory.
+ */
+static inline void lttng_poll_clean(struct lttng_poll_event *events)
+{
+       if (events) {
+               __lttng_poll_free((void *) events->wait.events);
+               __lttng_poll_free((void *) events->current.events);
+       }
+}
+
+#endif /* HAVE_EPOLL */
+
+#endif /* _LTT_POLL_H */
diff --git a/src/common/compat/pthread.h b/src/common/compat/pthread.h
deleted file mode 100644 (file)
index dd30c8b..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_PTHREAD_H
-#define _COMPAT_PTHREAD_H
-
-#include <pthread.h>
-#include <common/compat/errno.h>
-#include <string.h>
-
-#ifdef __FreeBSD__
-#include <pthread_np.h>
-#endif
-
-#define LTTNG_PTHREAD_NAMELEN 16
-
-#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
-       /*
-        * Some implementations don't error out, replicate this behavior for
-        * consistency.
-        */
-       if (strnlen(name, LTTNG_PTHREAD_NAMELEN) >= LTTNG_PTHREAD_NAMELEN) {
-               return ERANGE;
-       }
-
-       return pthread_setname_np(pthread_self(), name);
-}
-#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
-       return pthread_setname_np(name);
-}
-#elif defined(HAVE_PTHREAD_SET_NAME_NP_WITH_TID)
-
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
-       /* Replicate pthread_setname_np's behavior. */
-       if (strnlen(name, LTTNG_PTHREAD_NAMELEN) >= LTTNG_PTHREAD_NAMELEN) {
-               return ERANGE;
-       }
-
-       pthread_set_name_np(pthread_self(), name);
-       return 0;
-}
-#elif defined(__linux__)
-
-/* Fallback on prtctl on Linux */
-#include <sys/prctl.h>
-
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
-       /* Replicate pthread_setname_np's behavior. */
-       if (strnlen(name, LTTNG_UST_ABI_PROCNAME_LEN) >= LTTNG_UST_ABI_PROCNAME_LEN) {
-               return ERANGE;
-       }
-       return prctl(PR_SET_NAME, name, 0, 0, 0);
-}
-#else
-/*
- * For platforms without thread name support, do nothing.
- */
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
-       return -ENOSYS;
-}
-#endif
-
-
-#if defined(HAVE_PTHREAD_GETNAME_NP_WITH_TID)
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
-       return pthread_getname_np(pthread_self(), name, len);
-}
-#elif defined(HAVE_PTHREAD_GETNAME_NP_WITHOUT_TID)
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
-       return pthread_getname_np(name, len);
-}
-#elif defined(HAVE_PTHREAD_GET_NAME_NP_WITH_TID)
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
-       pthread_get_name_np(pthread_self(), name, len);
-       return 0;
-}
-#elif defined(__linux__)
-
-/* Fallback on prtctl on Linux */
-#include <sys/prctl.h>
-
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
-       return prctl(PR_GET_NAME, name, 0, 0, 0);
-}
-#else
-/*
- * For platforms without thread name support, do nothing.
- */
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
-       return -ENOSYS;
-}
-#endif
-
-#endif /* _COMPAT_PTHREAD_H */
diff --git a/src/common/compat/pthread.hpp b/src/common/compat/pthread.hpp
new file mode 100644 (file)
index 0000000..209cd27
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_PTHREAD_H
+#define _COMPAT_PTHREAD_H
+
+#include <pthread.h>
+#include <common/compat/errno.hpp>
+#include <string.h>
+
+#ifdef __FreeBSD__
+#include <pthread_np.h>
+#endif
+
+#define LTTNG_PTHREAD_NAMELEN 16
+
+#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+       /*
+        * Some implementations don't error out, replicate this behavior for
+        * consistency.
+        */
+       if (strnlen(name, LTTNG_PTHREAD_NAMELEN) >= LTTNG_PTHREAD_NAMELEN) {
+               return ERANGE;
+       }
+
+       return pthread_setname_np(pthread_self(), name);
+}
+#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+       return pthread_setname_np(name);
+}
+#elif defined(HAVE_PTHREAD_SET_NAME_NP_WITH_TID)
+
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+       /* Replicate pthread_setname_np's behavior. */
+       if (strnlen(name, LTTNG_PTHREAD_NAMELEN) >= LTTNG_PTHREAD_NAMELEN) {
+               return ERANGE;
+       }
+
+       pthread_set_name_np(pthread_self(), name);
+       return 0;
+}
+#elif defined(__linux__)
+
+/* Fallback on prtctl on Linux */
+#include <sys/prctl.h>
+
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+       /* Replicate pthread_setname_np's behavior. */
+       if (strnlen(name, LTTNG_UST_ABI_PROCNAME_LEN) >= LTTNG_UST_ABI_PROCNAME_LEN) {
+               return ERANGE;
+       }
+       return prctl(PR_SET_NAME, name, 0, 0, 0);
+}
+#else
+/*
+ * For platforms without thread name support, do nothing.
+ */
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+       return -ENOSYS;
+}
+#endif
+
+
+#if defined(HAVE_PTHREAD_GETNAME_NP_WITH_TID)
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+       return pthread_getname_np(pthread_self(), name, len);
+}
+#elif defined(HAVE_PTHREAD_GETNAME_NP_WITHOUT_TID)
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+       return pthread_getname_np(name, len);
+}
+#elif defined(HAVE_PTHREAD_GET_NAME_NP_WITH_TID)
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+       pthread_get_name_np(pthread_self(), name, len);
+       return 0;
+}
+#elif defined(__linux__)
+
+/* Fallback on prtctl on Linux */
+#include <sys/prctl.h>
+
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+       return prctl(PR_GET_NAME, name, 0, 0, 0);
+}
+#else
+/*
+ * For platforms without thread name support, do nothing.
+ */
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+       return -ENOSYS;
+}
+#endif
+
+#endif /* _COMPAT_PTHREAD_H */
diff --git a/src/common/compat/socket.h b/src/common/compat/socket.h
deleted file mode 100644 (file)
index ee475a1..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_SOCKET_H
-#define _COMPAT_SOCKET_H
-
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <unistd.h>
-
-#include <common/macros.h>
-
-#ifndef MSG_NOSIGNAL
-# ifdef SO_NOSIGPIPE
-#   define MSG_NOSIGNAL SO_NOSIGPIPE
-# endif
-#endif
-
-#if defined(MSG_NOSIGNAL)
-static inline
-ssize_t lttng_recvmsg_nosigpipe(int sockfd, struct msghdr *msg)
-{
-       return recvmsg(sockfd, msg, MSG_NOSIGNAL);
-}
-#else
-
-#include <signal.h>
-#include <common/compat/errno.h>
-
-static inline
-ssize_t lttng_recvmsg_nosigpipe(int sockfd, struct msghdr *msg)
-{
-       ssize_t received;
-       int saved_err;
-       sigset_t sigpipe_set, pending_set, old_set;
-       int sigpipe_was_pending;
-
-       /*
-        * Discard the SIGPIPE from send(), not disturbing any SIGPIPE
-        * that might be already pending. If a bogus SIGPIPE is sent to
-        * the entire process concurrently by a malicious user, it may
-        * be simply discarded.
-        */
-       if (sigemptyset(&pending_set)) {
-               return -1;
-       }
-       /*
-        * sigpending returns the mask of signals that are _both_
-        * blocked for the thread _and_ pending for either the thread or
-        * the entire process.
-        */
-       if (sigpending(&pending_set)) {
-               return -1;
-       }
-       sigpipe_was_pending = sigismember(&pending_set, SIGPIPE);
-       /*
-        * If sigpipe was pending, it means it was already blocked, so
-        * no need to block it.
-        */
-       if (!sigpipe_was_pending) {
-               if (sigemptyset(&sigpipe_set)) {
-                       return -1;
-               }
-               if (sigaddset(&sigpipe_set, SIGPIPE)) {
-                       return -1;
-               }
-               if (pthread_sigmask(SIG_BLOCK, &sigpipe_set, &old_set)) {
-                       return -1;
-               }
-       }
-
-       /* Send and save errno. */
-       received = recvmsg(sockfd, msg, 0);
-       saved_err = errno;
-
-       if (received == -1 && errno == EPIPE && !sigpipe_was_pending) {
-               struct timespec timeout = { 0, 0 };
-               int ret;
-
-               do {
-                       ret = sigtimedwait(&sigpipe_set, NULL,
-                               &timeout);
-               } while (ret == -1 && errno == EINTR);
-       }
-       if (!sigpipe_was_pending) {
-               if (pthread_sigmask(SIG_SETMASK, &old_set, NULL)) {
-                       return -1;
-               }
-       }
-       /* Restore send() errno */
-       errno = saved_err;
-
-       return received;
-}
-#endif
-
-#ifdef __sun__
-
-# ifndef CMSG_ALIGN
-#  ifdef _CMSG_DATA_ALIGN
-#   define CMSG_ALIGN(len) _CMSG_DATA_ALIGN(len)
-#  else
-    /* aligning to sizeof (long) is assumed to be portable (fd.o#40235) */
-#   define CMSG_ALIGN(len) (((len) + sizeof (long) - 1) & ~(sizeof (long) - 1))
-#  endif
-#  ifndef CMSG_SPACE
-#    define CMSG_SPACE(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + CMSG_ALIGN (len))
-#  endif
-#  ifndef CMSG_LEN
-#    define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
-#  endif
-# endif
-
-#include <ucred.h>
-
-static inline
-int getpeereid(int s, uid_t *euid, gid_t *gid)
-{
-       int ret = 0;
-       ucred_t *ucred = NULL;
-
-       ret = getpeerucred(s, &ucred);
-       if (ret == -1) {
-               goto end;
-       }
-
-       ret = ucred_geteuid(ucred);
-       if (ret == -1) {
-               goto free;
-       }
-       *euid = ret;
-
-       ret = ucred_getrgid(ucred);
-       if (ret == -1) {
-               goto free;
-       }
-       *gid = ret;
-
-       ret = 0;
-free:
-       ucred_free(ucred);
-end:
-       return ret;
-}
-#endif /* __sun__ */
-
-
-#if defined(__linux__) || defined(__CYGWIN__)
-
-#define LTTNG_SOCK_CREDS SCM_CREDENTIALS
-
-typedef struct ucred lttng_sock_cred;
-
-#define LTTNG_SOCK_SET_UID_CRED(c, u) LTTNG_REF(c)->uid = u
-#define LTTNG_SOCK_SET_GID_CRED(c, g) LTTNG_REF(c)->gid = g
-#define LTTNG_SOCK_SET_PID_CRED(c, p) LTTNG_REF(c)->pid = p
-
-#define LTTNG_SOCK_GET_UID_CRED(c) LTTNG_REF(c)->uid
-#define LTTNG_SOCK_GET_GID_CRED(c) LTTNG_REF(c)->gid
-#define LTTNG_SOCK_GET_PID_CRED(c) LTTNG_REF(c)->pid
-
-#elif (defined(__FreeBSD__) || defined(__sun__) || defined(__APPLE__))
-
-struct lttng_sock_cred {
-       uid_t uid;
-       gid_t gid;
-       pid_t pid;
-};
-
-typedef struct lttng_sock_cred lttng_sock_cred;
-
-#define LTTNG_SOCK_SET_UID_CRED(c, u) LTTNG_REF(c)->uid = u
-#define LTTNG_SOCK_SET_GID_CRED(c, g) LTTNG_REF(c)->gid = g
-#define LTTNG_SOCK_SET_PID_CRED(c, p) LTTNG_REF(c)->pid = p
-
-#define LTTNG_SOCK_GET_UID_CRED(c) LTTNG_REF(c)->uid
-#define LTTNG_SOCK_GET_GID_CRED(c) LTTNG_REF(c)->gid
-#define LTTNG_SOCK_GET_PID_CRED(c) LTTNG_REF(c)->pid
-
-#ifdef __APPLE__
-
-static inline
-int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
-{
-       socklen_t pid_len = (socklen_t) sizeof(*pid);
-
-       /* The getsockopt LOCAL_PEERPID option is available since macOS 10.8. */
-       return getsockopt(socket_fd, SOL_LOCAL, LOCAL_PEERPID, pid, &pid_len);
-}
-
-#elif defined(__sun__)
-
-/* Use the getpeerucreds interface on Solaris. */
-static inline
-int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
-{
-       int ret = 0;
-       ucred_t *ucred = NULL;
-
-       ret = getpeerucred(s, &ucred);
-       if (ret == -1) {
-               goto end;
-       }
-
-       ret = ucred_getpid(ucred);
-       if (ret == -1) {
-               goto free;
-       }
-
-       *pid = ret;
-       ret = 0;
-free:
-       ucred_free(ucred);
-end:
-       return ret;
-}
-
-#elif defined(__FreeBSD__)
-
-#include <sys/ucred.h>
-
-static inline
-int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
-{
-       int ret;
-       struct xucred sock_creds = {};
-
-       /* Only available in FreeBSD 13.0 and up. */
-       ret = getsockopt(socket_fd, SOL_LOCAL, LOCAL_PEERCRED, &sock_creds,
-                       &((socklen_t) {sizeof(sock_creds)}));
-       if (ret) {
-               goto end;
-       }
-
-       *pid = sock_creds.cr_pid;
-end:
-       return ret;
-}
-
-#endif /* __APPLE__ */
-
-
-static inline
-int lttng_get_unix_socket_peer_creds(int socket_fd, struct lttng_sock_cred *creds)
-{
-       int ret;
-
-       /* This is a BSD extension that is supported by Cygwin. */
-       ret = getpeereid(socket_fd, &creds->uid, &creds->gid);
-       if (ret) {
-               goto end;
-       }
-
-       /*
-        * Getting a peer's PID is a bit more troublesome as it is platform
-        * specific.
-        */
-       ret = lttng_get_unix_socket_peer_pid(socket_fd, &creds->pid);
-end:
-       return ret;
-}
-
-#else
-#error "Please add support for your OS."
-#endif /* __linux__ , __FreeBSD__, __APPLE__ */
-
-#endif /* _COMPAT_SOCKET_H */
diff --git a/src/common/compat/socket.hpp b/src/common/compat/socket.hpp
new file mode 100644 (file)
index 0000000..599998e
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+ * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_SOCKET_H
+#define _COMPAT_SOCKET_H
+
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+#include <common/macros.hpp>
+
+#ifndef MSG_NOSIGNAL
+# ifdef SO_NOSIGPIPE
+#   define MSG_NOSIGNAL SO_NOSIGPIPE
+# endif
+#endif
+
+#if defined(MSG_NOSIGNAL)
+static inline
+ssize_t lttng_recvmsg_nosigpipe(int sockfd, struct msghdr *msg)
+{
+       return recvmsg(sockfd, msg, MSG_NOSIGNAL);
+}
+#else
+
+#include <signal.h>
+#include <common/compat/errno.hpp>
+
+static inline
+ssize_t lttng_recvmsg_nosigpipe(int sockfd, struct msghdr *msg)
+{
+       ssize_t received;
+       int saved_err;
+       sigset_t sigpipe_set, pending_set, old_set;
+       int sigpipe_was_pending;
+
+       /*
+        * Discard the SIGPIPE from send(), not disturbing any SIGPIPE
+        * that might be already pending. If a bogus SIGPIPE is sent to
+        * the entire process concurrently by a malicious user, it may
+        * be simply discarded.
+        */
+       if (sigemptyset(&pending_set)) {
+               return -1;
+       }
+       /*
+        * sigpending returns the mask of signals that are _both_
+        * blocked for the thread _and_ pending for either the thread or
+        * the entire process.
+        */
+       if (sigpending(&pending_set)) {
+               return -1;
+       }
+       sigpipe_was_pending = sigismember(&pending_set, SIGPIPE);
+       /*
+        * If sigpipe was pending, it means it was already blocked, so
+        * no need to block it.
+        */
+       if (!sigpipe_was_pending) {
+               if (sigemptyset(&sigpipe_set)) {
+                       return -1;
+               }
+               if (sigaddset(&sigpipe_set, SIGPIPE)) {
+                       return -1;
+               }
+               if (pthread_sigmask(SIG_BLOCK, &sigpipe_set, &old_set)) {
+                       return -1;
+               }
+       }
+
+       /* Send and save errno. */
+       received = recvmsg(sockfd, msg, 0);
+       saved_err = errno;
+
+       if (received == -1 && errno == EPIPE && !sigpipe_was_pending) {
+               struct timespec timeout = { 0, 0 };
+               int ret;
+
+               do {
+                       ret = sigtimedwait(&sigpipe_set, NULL,
+                               &timeout);
+               } while (ret == -1 && errno == EINTR);
+       }
+       if (!sigpipe_was_pending) {
+               if (pthread_sigmask(SIG_SETMASK, &old_set, NULL)) {
+                       return -1;
+               }
+       }
+       /* Restore send() errno */
+       errno = saved_err;
+
+       return received;
+}
+#endif
+
+#ifdef __sun__
+
+# ifndef CMSG_ALIGN
+#  ifdef _CMSG_DATA_ALIGN
+#   define CMSG_ALIGN(len) _CMSG_DATA_ALIGN(len)
+#  else
+    /* aligning to sizeof (long) is assumed to be portable (fd.o#40235) */
+#   define CMSG_ALIGN(len) (((len) + sizeof (long) - 1) & ~(sizeof (long) - 1))
+#  endif
+#  ifndef CMSG_SPACE
+#    define CMSG_SPACE(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + CMSG_ALIGN (len))
+#  endif
+#  ifndef CMSG_LEN
+#    define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
+#  endif
+# endif
+
+#include <ucred.h>
+
+static inline
+int getpeereid(int s, uid_t *euid, gid_t *gid)
+{
+       int ret = 0;
+       ucred_t *ucred = NULL;
+
+       ret = getpeerucred(s, &ucred);
+       if (ret == -1) {
+               goto end;
+       }
+
+       ret = ucred_geteuid(ucred);
+       if (ret == -1) {
+               goto free;
+       }
+       *euid = ret;
+
+       ret = ucred_getrgid(ucred);
+       if (ret == -1) {
+               goto free;
+       }
+       *gid = ret;
+
+       ret = 0;
+free:
+       ucred_free(ucred);
+end:
+       return ret;
+}
+#endif /* __sun__ */
+
+
+#if defined(__linux__) || defined(__CYGWIN__)
+
+#define LTTNG_SOCK_CREDS SCM_CREDENTIALS
+
+typedef struct ucred lttng_sock_cred;
+
+#define LTTNG_SOCK_SET_UID_CRED(c, u) LTTNG_REF(c)->uid = u
+#define LTTNG_SOCK_SET_GID_CRED(c, g) LTTNG_REF(c)->gid = g
+#define LTTNG_SOCK_SET_PID_CRED(c, p) LTTNG_REF(c)->pid = p
+
+#define LTTNG_SOCK_GET_UID_CRED(c) LTTNG_REF(c)->uid
+#define LTTNG_SOCK_GET_GID_CRED(c) LTTNG_REF(c)->gid
+#define LTTNG_SOCK_GET_PID_CRED(c) LTTNG_REF(c)->pid
+
+#elif (defined(__FreeBSD__) || defined(__sun__) || defined(__APPLE__))
+
+struct lttng_sock_cred {
+       uid_t uid;
+       gid_t gid;
+       pid_t pid;
+};
+
+typedef struct lttng_sock_cred lttng_sock_cred;
+
+#define LTTNG_SOCK_SET_UID_CRED(c, u) LTTNG_REF(c)->uid = u
+#define LTTNG_SOCK_SET_GID_CRED(c, g) LTTNG_REF(c)->gid = g
+#define LTTNG_SOCK_SET_PID_CRED(c, p) LTTNG_REF(c)->pid = p
+
+#define LTTNG_SOCK_GET_UID_CRED(c) LTTNG_REF(c)->uid
+#define LTTNG_SOCK_GET_GID_CRED(c) LTTNG_REF(c)->gid
+#define LTTNG_SOCK_GET_PID_CRED(c) LTTNG_REF(c)->pid
+
+#ifdef __APPLE__
+
+static inline
+int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
+{
+       socklen_t pid_len = (socklen_t) sizeof(*pid);
+
+       /* The getsockopt LOCAL_PEERPID option is available since macOS 10.8. */
+       return getsockopt(socket_fd, SOL_LOCAL, LOCAL_PEERPID, pid, &pid_len);
+}
+
+#elif defined(__sun__)
+
+/* Use the getpeerucreds interface on Solaris. */
+static inline
+int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
+{
+       int ret = 0;
+       ucred_t *ucred = NULL;
+
+       ret = getpeerucred(s, &ucred);
+       if (ret == -1) {
+               goto end;
+       }
+
+       ret = ucred_getpid(ucred);
+       if (ret == -1) {
+               goto free;
+       }
+
+       *pid = ret;
+       ret = 0;
+free:
+       ucred_free(ucred);
+end:
+       return ret;
+}
+
+#elif defined(__FreeBSD__)
+
+#include <sys/ucred.h>
+
+static inline
+int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
+{
+       int ret;
+       struct xucred sock_creds = {};
+
+       /* Only available in FreeBSD 13.0 and up. */
+       ret = getsockopt(socket_fd, SOL_LOCAL, LOCAL_PEERCRED, &sock_creds,
+                       &((socklen_t) {sizeof(sock_creds)}));
+       if (ret) {
+               goto end;
+       }
+
+       *pid = sock_creds.cr_pid;
+end:
+       return ret;
+}
+
+#endif /* __APPLE__ */
+
+
+static inline
+int lttng_get_unix_socket_peer_creds(int socket_fd, struct lttng_sock_cred *creds)
+{
+       int ret;
+
+       /* This is a BSD extension that is supported by Cygwin. */
+       ret = getpeereid(socket_fd, &creds->uid, &creds->gid);
+       if (ret) {
+               goto end;
+       }
+
+       /*
+        * Getting a peer's PID is a bit more troublesome as it is platform
+        * specific.
+        */
+       ret = lttng_get_unix_socket_peer_pid(socket_fd, &creds->pid);
+end:
+       return ret;
+}
+
+#else
+#error "Please add support for your OS."
+#endif /* __linux__ , __FreeBSD__, __APPLE__ */
+
+#endif /* _COMPAT_SOCKET_H */
diff --git a/src/common/compat/string.h b/src/common/compat/string.h
deleted file mode 100644 (file)
index 4a96cb1..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _COMPAT_STRING_H
-#define _COMPAT_STRING_H
-
-#include <string.h>
-#include <stdlib.h>
-
-#ifdef HAVE_STRNLEN
-static inline
-size_t lttng_strnlen(const char *str, size_t max)
-{
-       return strnlen(str, max);
-}
-#else
-static inline
-size_t lttng_strnlen(const char *str, size_t max)
-{
-       size_t ret;
-       const char *end;
-
-       end = (const char *) memchr(str, 0, max);
-
-       if (end) {
-               ret = (size_t) (end - str);
-       } else {
-               ret = max;
-       }
-
-       return ret;
-}
-#endif /* HAVE_STRNLEN */
-
-#ifdef HAVE_STRNDUP
-static inline
-char *lttng_strndup(const char *s, size_t n)
-{
-       return strndup(s, n);
-}
-#else
-static inline
-char *lttng_strndup(const char *s, size_t n)
-{
-       char *ret;
-       size_t navail;
-
-       if (!s) {
-               ret = NULL;
-               goto end;
-       }
-
-       /* min() */
-       navail = strlen(s) + 1;
-       if ((n + 1) < navail) {
-               navail = n + 1;
-       }
-
-       ret = (char *) malloc(navail);
-       if (!ret) {
-               goto end;
-       }
-
-       memcpy(ret, s, navail);
-       ret[navail - 1] = '\0';
-end:
-       return ret;
-}
-#endif /* HAVE_STRNDUP */
-
-#ifdef HAVE_FLS
-static inline int lttng_fls(int val)
-{
-       return fls(val);
-}
-#else
-static inline int lttng_fls(int val)
-{
-       int r = 32;
-       unsigned int x = (unsigned int) val;
-
-       if (!x)
-               return 0;
-       if (!(x & 0xFFFF0000U)) {
-               x <<= 16;
-               r -= 16;
-       }
-       if (!(x & 0xFF000000U)) {
-               x <<= 8;
-               r -= 8;
-       }
-       if (!(x & 0xF0000000U)) {
-               x <<= 4;
-               r -= 4;
-       }
-       if (!(x & 0xC0000000U)) {
-               x <<= 2;
-               r -= 2;
-       }
-       if (!(x & 0x80000000U)) {
-               r -= 1;
-       }
-       return r;
-}
-#endif /* HAVE_FLS */
-
-#ifdef HAVE_MEMRCHR
-static inline
-void *lttng_memrchr(const void *s, int c, size_t n)
-{
-       return (void *) memrchr(s, c, n);
-}
-#else
-static inline
-void *lttng_memrchr(const void *s, int c, size_t n)
-{
-       int i;
-       const char *str = (const char *) s;
-       for (i = n-1; i >= 0; i--) {
-               if (str[i] == (char)c) {
-                       return (void *)(str+i);
-               }
-       }
-       return NULL;
-}
-#endif /* HAVE_MEMRCHR */
-
-#endif /* _COMPAT_STRING_H */
diff --git a/src/common/compat/string.hpp b/src/common/compat/string.hpp
new file mode 100644 (file)
index 0000000..4a96cb1
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _COMPAT_STRING_H
+#define _COMPAT_STRING_H
+
+#include <string.h>
+#include <stdlib.h>
+
+#ifdef HAVE_STRNLEN
+static inline
+size_t lttng_strnlen(const char *str, size_t max)
+{
+       return strnlen(str, max);
+}
+#else
+static inline
+size_t lttng_strnlen(const char *str, size_t max)
+{
+       size_t ret;
+       const char *end;
+
+       end = (const char *) memchr(str, 0, max);
+
+       if (end) {
+               ret = (size_t) (end - str);
+       } else {
+               ret = max;
+       }
+
+       return ret;
+}
+#endif /* HAVE_STRNLEN */
+
+#ifdef HAVE_STRNDUP
+static inline
+char *lttng_strndup(const char *s, size_t n)
+{
+       return strndup(s, n);
+}
+#else
+static inline
+char *lttng_strndup(const char *s, size_t n)
+{
+       char *ret;
+       size_t navail;
+
+       if (!s) {
+               ret = NULL;
+               goto end;
+       }
+
+       /* min() */
+       navail = strlen(s) + 1;
+       if ((n + 1) < navail) {
+               navail = n + 1;
+       }
+
+       ret = (char *) malloc(navail);
+       if (!ret) {
+               goto end;
+       }
+
+       memcpy(ret, s, navail);
+       ret[navail - 1] = '\0';
+end:
+       return ret;
+}
+#endif /* HAVE_STRNDUP */
+
+#ifdef HAVE_FLS
+static inline int lttng_fls(int val)
+{
+       return fls(val);
+}
+#else
+static inline int lttng_fls(int val)
+{
+       int r = 32;
+       unsigned int x = (unsigned int) val;
+
+       if (!x)
+               return 0;
+       if (!(x & 0xFFFF0000U)) {
+               x <<= 16;
+               r -= 16;
+       }
+       if (!(x & 0xFF000000U)) {
+               x <<= 8;
+               r -= 8;
+       }
+       if (!(x & 0xF0000000U)) {
+               x <<= 4;
+               r -= 4;
+       }
+       if (!(x & 0xC0000000U)) {
+               x <<= 2;
+               r -= 2;
+       }
+       if (!(x & 0x80000000U)) {
+               r -= 1;
+       }
+       return r;
+}
+#endif /* HAVE_FLS */
+
+#ifdef HAVE_MEMRCHR
+static inline
+void *lttng_memrchr(const void *s, int c, size_t n)
+{
+       return (void *) memrchr(s, c, n);
+}
+#else
+static inline
+void *lttng_memrchr(const void *s, int c, size_t n)
+{
+       int i;
+       const char *str = (const char *) s;
+       for (i = n-1; i >= 0; i--) {
+               if (str[i] == (char)c) {
+                       return (void *)(str+i);
+               }
+       }
+       return NULL;
+}
+#endif /* HAVE_MEMRCHR */
+
+#endif /* _COMPAT_STRING_H */
diff --git a/src/common/compat/tid.h b/src/common/compat/tid.h
deleted file mode 100644 (file)
index 4a6ff74..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2012 (C) Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef LTTNG_TID_H
-#define LTTNG_TID_H
-
-#ifdef __linux__
-#include <syscall.h>
-#endif
-
-#if defined(__NR_gettid)
-
-#include <unistd.h>
-static inline pid_t lttng_gettid(void)
-{
-       return syscall(__NR_gettid);
-}
-
-#else
-
-#include <sys/types.h>
-#include <unistd.h>
-
-/* Fall-back on getpid for tid if not available. */
-static inline pid_t lttng_gettid(void)
-{
-       return getpid();
-}
-
-#endif
-
-#endif /* LTTNG_TID_H */
diff --git a/src/common/compat/tid.hpp b/src/common/compat/tid.hpp
new file mode 100644 (file)
index 0000000..4a6ff74
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2012 (C) Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef LTTNG_TID_H
+#define LTTNG_TID_H
+
+#ifdef __linux__
+#include <syscall.h>
+#endif
+
+#if defined(__NR_gettid)
+
+#include <unistd.h>
+static inline pid_t lttng_gettid(void)
+{
+       return syscall(__NR_gettid);
+}
+
+#else
+
+#include <sys/types.h>
+#include <unistd.h>
+
+/* Fall-back on getpid for tid if not available. */
+static inline pid_t lttng_gettid(void)
+{
+       return getpid();
+}
+
+#endif
+
+#endif /* LTTNG_TID_H */
diff --git a/src/common/compat/time.h b/src/common/compat/time.h
deleted file mode 100644 (file)
index 72a9aff..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2016 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _COMPAT_TIME_H
-#define _COMPAT_TIME_H
-
-#include <time.h>
-
-#ifdef __APPLE__
-
-typedef uint64_t timer_t;
-
-#include <mach/mach.h>
-#include <mach/clock.h>
-#include <common/compat/errno.h>
-
-#undef NSEC_PER_SEC
-#undef NSEC_PER_MSEC
-#undef NSEC_PER_USEC
-#undef USEC_PER_SEC
-
-#endif /* __APPLE__ */
-
-/* macOS/OS X 10.12 (Sierra) and up provide clock_gettime() */
-#if defined(__APPLE__) && !defined(LTTNG_HAVE_CLOCK_GETTIME)
-
-typedef int clockid_t;
-#define CLOCK_REALTIME CALENDAR_CLOCK
-#define CLOCK_MONOTONIC SYSTEM_CLOCK
-
-static inline
-int lttng_clock_gettime(clockid_t clk_id, struct timespec *tp)
-{
-       int ret = 0;
-       clock_serv_t clock;
-       mach_timespec_t now;
-
-       if (clk_id != CLOCK_REALTIME && clk_id != CLOCK_MONOTONIC) {
-               ret = -1;
-               errno = EINVAL;
-               goto end;
-       }
-
-       host_get_clock_service(mach_host_self(), clk_id, &clock);
-
-       ret = clock_get_time(clock, &now);
-       if (ret != KERN_SUCCESS) {
-               ret = -1;
-               goto deallocate;
-       }
-
-       tp->tv_sec = now.tv_sec;
-       tp->tv_nsec = now.tv_nsec;
-
-deallocate:
-       mach_port_deallocate(mach_task_self(), clock);
-end:
-       return ret;
-}
-
-#else /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */
-
-static inline
-int lttng_clock_gettime(clockid_t clk_id, struct timespec *tp)
-{
-       return clock_gettime(clk_id, tp);
-}
-
-#endif /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */
-
-#endif /* _COMPAT_TIME_H */
diff --git a/src/common/compat/time.hpp b/src/common/compat/time.hpp
new file mode 100644 (file)
index 0000000..37f472a
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2016 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _COMPAT_TIME_H
+#define _COMPAT_TIME_H
+
+#include <time.h>
+
+#ifdef __APPLE__
+
+typedef uint64_t timer_t;
+
+#include <mach/mach.h>
+#include <mach/clock.h>
+#include <common/compat/errno.hpp>
+
+#undef NSEC_PER_SEC
+#undef NSEC_PER_MSEC
+#undef NSEC_PER_USEC
+#undef USEC_PER_SEC
+
+#endif /* __APPLE__ */
+
+/* macOS/OS X 10.12 (Sierra) and up provide clock_gettime() */
+#if defined(__APPLE__) && !defined(LTTNG_HAVE_CLOCK_GETTIME)
+
+typedef int clockid_t;
+#define CLOCK_REALTIME CALENDAR_CLOCK
+#define CLOCK_MONOTONIC SYSTEM_CLOCK
+
+static inline
+int lttng_clock_gettime(clockid_t clk_id, struct timespec *tp)
+{
+       int ret = 0;
+       clock_serv_t clock;
+       mach_timespec_t now;
+
+       if (clk_id != CLOCK_REALTIME && clk_id != CLOCK_MONOTONIC) {
+               ret = -1;
+               errno = EINVAL;
+               goto end;
+       }
+
+       host_get_clock_service(mach_host_self(), clk_id, &clock);
+
+       ret = clock_get_time(clock, &now);
+       if (ret != KERN_SUCCESS) {
+               ret = -1;
+               goto deallocate;
+       }
+
+       tp->tv_sec = now.tv_sec;
+       tp->tv_nsec = now.tv_nsec;
+
+deallocate:
+       mach_port_deallocate(mach_task_self(), clock);
+end:
+       return ret;
+}
+
+#else /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */
+
+static inline
+int lttng_clock_gettime(clockid_t clk_id, struct timespec *tp)
+{
+       return clock_gettime(clk_id, tp);
+}
+
+#endif /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */
+
+#endif /* _COMPAT_TIME_H */
index fa28db65b9ad3deca1b4944258da77f7342676dc..b1d001dc4ae599332546a61eab3940a13a58ad4a 100644 (file)
@@ -5,12 +5,12 @@
  *
  */
 
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
 #include <float.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <lttng/condition/condition-internal.h>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
 #include <math.h>
 #include <time.h>
 
index 18b756dce4c489e2a88f8ef318c366c03c41ce2e..525932eb2f06d43dcbf183e2239a8a7ed7dbe641 100644 (file)
@@ -5,17 +5,17 @@
  *
  */
 
-#include <common/buffer-view.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
-#include <lttng/condition/session-consumed-size-internal.h>
-#include <lttng/condition/session-rotation-internal.h>
-#include <lttng/error-query-internal.h>
+#include <common/buffer-view.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
+#include <lttng/condition/session-consumed-size-internal.hpp>
+#include <lttng/condition/session-rotation-internal.hpp>
+#include <lttng/error-query-internal.hpp>
 #include <stdbool.h>
 
 enum lttng_condition_type lttng_condition_get_type(
index 3e7776f46cbd5d5449cfed4af2482a7d83031bdc..033dbca48a040b46131d7b9b5615e6f06e7e946f 100644 (file)
@@ -5,18 +5,18 @@
  *
  */
 
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
 #include <inttypes.h>
 #include <limits.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
 #include <lttng/condition/event-rule-matches.h>
-#include <lttng/event-expr-internal.h>
+#include <lttng/event-expr-internal.hpp>
 #include <lttng/event-expr.h>
-#include <lttng/event-field-value-internal.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-field-value-internal.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
 #include <lttng/lttng-error.h>
 #include <stdbool.h>
 #include <stdint.h>
index 86a7f332a513c9cb469c9003f776da703dc5952f..8bc70abf61fab875ff67f87944dac9de7895b62e 100644 (file)
@@ -5,12 +5,12 @@
  *
  */
 
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
 #include <float.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/session-consumed-size-internal.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/session-consumed-size-internal.hpp>
 #include <lttng/constant.h>
 #include <math.h>
 #include <time.h>
index 390123a4ec59146680e08c44b7a2a8355d4a5bef..094d1ea9421fa000007540359541ce92218c01c6 100644 (file)
@@ -5,12 +5,12 @@
  *
  */
 
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/session-rotation-internal.h>
-#include <lttng/location-internal.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/session-rotation-internal.hpp>
+#include <lttng/location-internal.hpp>
 #include <stdbool.h>
 
 static
diff --git a/src/common/config/config-internal.h b/src/common/config/config-internal.h
deleted file mode 100644 (file)
index 30f7226..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <libxml/xmlwriter.h>
-#include <stdio.h>
-
-struct config_writer {
-       xmlTextWriterPtr writer;
-};
diff --git a/src/common/config/config-internal.hpp b/src/common/config/config-internal.hpp
new file mode 100644 (file)
index 0000000..30f7226
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <libxml/xmlwriter.h>
+#include <stdio.h>
+
+struct config_writer {
+       xmlTextWriterPtr writer;
+};
diff --git a/src/common/config/config-session-abi.h b/src/common/config/config-session-abi.h
deleted file mode 100644 (file)
index f921a73..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (C) 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef CONFIG_SESSION_INTERNAL_H
-#define CONFIG_SESSION_INTERNAL_H
-
-#include <lttng/lttng-export.h>
-
-extern const char * const config_element_all;
-LTTNG_EXPORT extern const char * const config_element_channel;
-LTTNG_EXPORT extern const char * const config_element_channels;
-LTTNG_EXPORT extern const char * const config_element_domain;
-LTTNG_EXPORT extern const char * const config_element_domains;
-LTTNG_EXPORT extern const char * const config_element_event;
-LTTNG_EXPORT extern const char * const config_element_events;
-LTTNG_EXPORT extern const char * const config_element_context;
-LTTNG_EXPORT extern const char * const config_element_contexts;
-LTTNG_EXPORT extern const char * const config_element_attributes;
-LTTNG_EXPORT extern const char * const config_element_exclusion;
-LTTNG_EXPORT extern const char * const config_element_exclusions;
-LTTNG_EXPORT extern const char * const config_element_function_attributes;
-LTTNG_EXPORT extern const char * const config_element_probe_attributes;
-LTTNG_EXPORT extern const char * const config_element_symbol_name;
-LTTNG_EXPORT extern const char * const config_element_address;
-LTTNG_EXPORT extern const char * const config_element_offset;
-extern const char * const config_element_userspace_probe_lookup;
-extern const char * const config_element_userspace_probe_lookup_function_default;
-extern const char * const config_element_userspace_probe_lookup_function_elf;
-extern const char * const config_element_userspace_probe_lookup_tracepoint_sdt;
-extern const char * const config_element_userspace_probe_location_binary_path;
-extern const char * const config_element_userspace_probe_function_attributes;
-extern const char * const config_element_userspace_probe_function_location_function_name;
-extern const char * const config_element_userspace_probe_tracepoint_attributes;
-extern const char * const config_element_userspace_probe_tracepoint_location_provider_name;
-extern const char * const config_element_userspace_probe_tracepoint_location_probe_name;
-extern const char * const config_element_name;
-LTTNG_EXPORT extern const char * const config_element_enabled;
-LTTNG_EXPORT extern const char * const config_element_overwrite_mode;
-LTTNG_EXPORT extern const char * const config_element_subbuf_size;
-LTTNG_EXPORT extern const char * const config_element_num_subbuf;
-LTTNG_EXPORT extern const char * const config_element_switch_timer_interval;
-LTTNG_EXPORT extern const char * const config_element_read_timer_interval;
-extern const char * const config_element_monitor_timer_interval;
-extern const char * const config_element_blocking_timeout;
-LTTNG_EXPORT extern const char * const config_element_output;
-LTTNG_EXPORT extern const char * const config_element_output_type;
-LTTNG_EXPORT extern const char * const config_element_tracefile_size;
-LTTNG_EXPORT extern const char * const config_element_tracefile_count;
-LTTNG_EXPORT extern const char * const config_element_live_timer_interval;
-extern const char * const config_element_discarded_events;
-extern const char * const config_element_lost_packets;
-LTTNG_EXPORT extern const char * const config_element_type;
-LTTNG_EXPORT extern const char * const config_element_buffer_type;
-LTTNG_EXPORT extern const char * const config_element_session;
-LTTNG_EXPORT extern const char * const config_element_sessions;
-extern const char * const config_element_context_perf;
-extern const char * const config_element_context_app;
-extern const char * const config_element_context_app_provider_name;
-extern const char * const config_element_context_app_ctx_name;
-LTTNG_EXPORT extern const char * const config_element_config;
-LTTNG_EXPORT extern const char * const config_element_started;
-LTTNG_EXPORT extern const char * const config_element_snapshot_mode;
-LTTNG_EXPORT extern const char * const config_element_loglevel;
-LTTNG_EXPORT extern const char * const config_element_loglevel_type;
-LTTNG_EXPORT extern const char * const config_element_filter;
-extern const char * const config_element_filter_expression;
-LTTNG_EXPORT extern const char * const config_element_snapshot_outputs;
-LTTNG_EXPORT extern const char * const config_element_consumer_output;
-LTTNG_EXPORT extern const char * const config_element_destination;
-LTTNG_EXPORT extern const char * const config_element_path;
-LTTNG_EXPORT extern const char * const config_element_net_output;
-LTTNG_EXPORT extern const char * const config_element_control_uri;
-LTTNG_EXPORT extern const char * const config_element_data_uri;
-LTTNG_EXPORT extern const char * const config_element_max_size;
-LTTNG_EXPORT extern const char * const config_element_pid;
-extern const char * const config_element_process_attr_id;
-LTTNG_EXPORT extern const char * const config_element_pids;
-LTTNG_EXPORT extern const char * const config_element_name;
-LTTNG_EXPORT extern const char * const config_element_shared_memory_path;
-extern const char * const config_element_process_attr_tracker_pid;
-extern const char * const config_element_process_attr_tracker_vpid;
-extern const char * const config_element_process_attr_tracker_uid;
-extern const char * const config_element_process_attr_tracker_vuid;
-extern const char * const config_element_process_attr_tracker_gid;
-extern const char * const config_element_process_attr_tracker_vgid;
-extern const char * const config_element_process_attr_trackers;
-extern const char * const config_element_process_attr_values;
-extern const char * const config_element_process_attr_value_type;
-extern const char * const config_element_process_attr_pid_value;
-extern const char * const config_element_process_attr_vpid_value;
-extern const char * const config_element_process_attr_uid_value;
-extern const char * const config_element_process_attr_vuid_value;
-extern const char * const config_element_process_attr_gid_value;
-extern const char * const config_element_process_attr_vgid_value;
-extern const char * const config_element_process_attr_tracker_type;
-extern const char * const config_element_rotation_timer_interval;
-extern const char * const config_element_rotation_size;
-extern const char * const config_element_rotation_schedule;
-
-LTTNG_EXPORT extern const char * const config_domain_type_kernel;
-LTTNG_EXPORT extern const char * const config_domain_type_ust;
-LTTNG_EXPORT extern const char * const config_domain_type_jul;
-LTTNG_EXPORT extern const char * const config_domain_type_log4j;
-LTTNG_EXPORT extern const char * const config_domain_type_python;
-
-LTTNG_EXPORT extern const char * const config_buffer_type_per_pid;
-LTTNG_EXPORT extern const char * const config_buffer_type_per_uid;
-LTTNG_EXPORT extern const char * const config_buffer_type_global;
-
-LTTNG_EXPORT extern const char * const config_overwrite_mode_discard;
-LTTNG_EXPORT extern const char * const config_overwrite_mode_overwrite;
-
-LTTNG_EXPORT extern const char * const config_output_type_splice;
-LTTNG_EXPORT extern const char * const config_output_type_mmap;
-
-LTTNG_EXPORT extern const char * const config_loglevel_type_all;
-LTTNG_EXPORT extern const char * const config_loglevel_type_range;
-LTTNG_EXPORT extern const char * const config_loglevel_type_single;
-
-LTTNG_EXPORT extern const char * const config_event_type_all;
-LTTNG_EXPORT extern const char * const config_event_type_tracepoint;
-LTTNG_EXPORT extern const char * const config_event_type_probe;
-extern const char * const config_event_type_userspace_probe;
-LTTNG_EXPORT extern const char * const config_event_type_function;
-LTTNG_EXPORT extern const char * const config_event_type_function_entry;
-LTTNG_EXPORT extern const char * const config_event_type_noop;
-LTTNG_EXPORT extern const char * const config_event_type_syscall;
-LTTNG_EXPORT extern const char * const config_event_type_kprobe;
-LTTNG_EXPORT extern const char * const config_event_type_kretprobe;
-
-LTTNG_EXPORT extern const char * const config_event_context_pid;
-LTTNG_EXPORT extern const char * const config_event_context_procname;
-LTTNG_EXPORT extern const char * const config_event_context_prio;
-LTTNG_EXPORT extern const char * const config_event_context_nice;
-LTTNG_EXPORT extern const char * const config_event_context_vpid;
-LTTNG_EXPORT extern const char * const config_event_context_tid;
-LTTNG_EXPORT extern const char * const config_event_context_vtid;
-LTTNG_EXPORT extern const char * const config_event_context_ppid;
-LTTNG_EXPORT extern const char * const config_event_context_vppid;
-LTTNG_EXPORT extern const char * const config_event_context_pthread_id;
-LTTNG_EXPORT extern const char * const config_event_context_hostname;
-LTTNG_EXPORT extern const char * const config_event_context_ip;
-LTTNG_EXPORT extern const char * const config_event_context_perf_thread_counter;
-extern const char * const config_event_context_app;
-extern const char * const config_event_context_interruptible;
-extern const char * const config_event_context_preemptible;
-extern const char * const config_event_context_need_reschedule;
-extern const char * const config_event_context_migratable;
-extern const char * const config_event_context_callstack_user;
-extern const char * const config_event_context_callstack_kernel;
-
-extern const char * const config_element_rotation_schedules;
-extern const char * const config_element_rotation_schedule_periodic;
-extern const char * const config_element_rotation_schedule_periodic_time_us;
-extern const char * const config_element_rotation_schedule_size_threshold;
-extern const char * const config_element_rotation_schedule_size_threshold_bytes;
-extern const char * const config_event_context_cgroup_ns;
-extern const char * const config_event_context_ipc_ns;
-extern const char * const config_event_context_mnt_ns;
-extern const char * const config_event_context_net_ns;
-extern const char * const config_event_context_pid_ns;
-extern const char * const config_event_context_time_ns;
-extern const char * const config_event_context_user_ns;
-extern const char * const config_event_context_uts_ns;
-extern const char * const config_event_context_uid;
-extern const char * const config_event_context_euid;
-extern const char * const config_event_context_suid;
-extern const char * const config_event_context_gid;
-extern const char * const config_event_context_egid;
-extern const char * const config_event_context_sgid;
-extern const char * const config_event_context_vuid;
-extern const char * const config_event_context_veuid;
-extern const char * const config_event_context_vsuid;
-extern const char * const config_event_context_vgid;
-extern const char * const config_event_context_vegid;
-extern const char * const config_event_context_vsgid;
-
-#endif /* CONFIG_SESSION_INTERNAL_H */
diff --git a/src/common/config/config-session-abi.hpp b/src/common/config/config-session-abi.hpp
new file mode 100644 (file)
index 0000000..f921a73
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef CONFIG_SESSION_INTERNAL_H
+#define CONFIG_SESSION_INTERNAL_H
+
+#include <lttng/lttng-export.h>
+
+extern const char * const config_element_all;
+LTTNG_EXPORT extern const char * const config_element_channel;
+LTTNG_EXPORT extern const char * const config_element_channels;
+LTTNG_EXPORT extern const char * const config_element_domain;
+LTTNG_EXPORT extern const char * const config_element_domains;
+LTTNG_EXPORT extern const char * const config_element_event;
+LTTNG_EXPORT extern const char * const config_element_events;
+LTTNG_EXPORT extern const char * const config_element_context;
+LTTNG_EXPORT extern const char * const config_element_contexts;
+LTTNG_EXPORT extern const char * const config_element_attributes;
+LTTNG_EXPORT extern const char * const config_element_exclusion;
+LTTNG_EXPORT extern const char * const config_element_exclusions;
+LTTNG_EXPORT extern const char * const config_element_function_attributes;
+LTTNG_EXPORT extern const char * const config_element_probe_attributes;
+LTTNG_EXPORT extern const char * const config_element_symbol_name;
+LTTNG_EXPORT extern const char * const config_element_address;
+LTTNG_EXPORT extern const char * const config_element_offset;
+extern const char * const config_element_userspace_probe_lookup;
+extern const char * const config_element_userspace_probe_lookup_function_default;
+extern const char * const config_element_userspace_probe_lookup_function_elf;
+extern const char * const config_element_userspace_probe_lookup_tracepoint_sdt;
+extern const char * const config_element_userspace_probe_location_binary_path;
+extern const char * const config_element_userspace_probe_function_attributes;
+extern const char * const config_element_userspace_probe_function_location_function_name;
+extern const char * const config_element_userspace_probe_tracepoint_attributes;
+extern const char * const config_element_userspace_probe_tracepoint_location_provider_name;
+extern const char * const config_element_userspace_probe_tracepoint_location_probe_name;
+extern const char * const config_element_name;
+LTTNG_EXPORT extern const char * const config_element_enabled;
+LTTNG_EXPORT extern const char * const config_element_overwrite_mode;
+LTTNG_EXPORT extern const char * const config_element_subbuf_size;
+LTTNG_EXPORT extern const char * const config_element_num_subbuf;
+LTTNG_EXPORT extern const char * const config_element_switch_timer_interval;
+LTTNG_EXPORT extern const char * const config_element_read_timer_interval;
+extern const char * const config_element_monitor_timer_interval;
+extern const char * const config_element_blocking_timeout;
+LTTNG_EXPORT extern const char * const config_element_output;
+LTTNG_EXPORT extern const char * const config_element_output_type;
+LTTNG_EXPORT extern const char * const config_element_tracefile_size;
+LTTNG_EXPORT extern const char * const config_element_tracefile_count;
+LTTNG_EXPORT extern const char * const config_element_live_timer_interval;
+extern const char * const config_element_discarded_events;
+extern const char * const config_element_lost_packets;
+LTTNG_EXPORT extern const char * const config_element_type;
+LTTNG_EXPORT extern const char * const config_element_buffer_type;
+LTTNG_EXPORT extern const char * const config_element_session;
+LTTNG_EXPORT extern const char * const config_element_sessions;
+extern const char * const config_element_context_perf;
+extern const char * const config_element_context_app;
+extern const char * const config_element_context_app_provider_name;
+extern const char * const config_element_context_app_ctx_name;
+LTTNG_EXPORT extern const char * const config_element_config;
+LTTNG_EXPORT extern const char * const config_element_started;
+LTTNG_EXPORT extern const char * const config_element_snapshot_mode;
+LTTNG_EXPORT extern const char * const config_element_loglevel;
+LTTNG_EXPORT extern const char * const config_element_loglevel_type;
+LTTNG_EXPORT extern const char * const config_element_filter;
+extern const char * const config_element_filter_expression;
+LTTNG_EXPORT extern const char * const config_element_snapshot_outputs;
+LTTNG_EXPORT extern const char * const config_element_consumer_output;
+LTTNG_EXPORT extern const char * const config_element_destination;
+LTTNG_EXPORT extern const char * const config_element_path;
+LTTNG_EXPORT extern const char * const config_element_net_output;
+LTTNG_EXPORT extern const char * const config_element_control_uri;
+LTTNG_EXPORT extern const char * const config_element_data_uri;
+LTTNG_EXPORT extern const char * const config_element_max_size;
+LTTNG_EXPORT extern const char * const config_element_pid;
+extern const char * const config_element_process_attr_id;
+LTTNG_EXPORT extern const char * const config_element_pids;
+LTTNG_EXPORT extern const char * const config_element_name;
+LTTNG_EXPORT extern const char * const config_element_shared_memory_path;
+extern const char * const config_element_process_attr_tracker_pid;
+extern const char * const config_element_process_attr_tracker_vpid;
+extern const char * const config_element_process_attr_tracker_uid;
+extern const char * const config_element_process_attr_tracker_vuid;
+extern const char * const config_element_process_attr_tracker_gid;
+extern const char * const config_element_process_attr_tracker_vgid;
+extern const char * const config_element_process_attr_trackers;
+extern const char * const config_element_process_attr_values;
+extern const char * const config_element_process_attr_value_type;
+extern const char * const config_element_process_attr_pid_value;
+extern const char * const config_element_process_attr_vpid_value;
+extern const char * const config_element_process_attr_uid_value;
+extern const char * const config_element_process_attr_vuid_value;
+extern const char * const config_element_process_attr_gid_value;
+extern const char * const config_element_process_attr_vgid_value;
+extern const char * const config_element_process_attr_tracker_type;
+extern const char * const config_element_rotation_timer_interval;
+extern const char * const config_element_rotation_size;
+extern const char * const config_element_rotation_schedule;
+
+LTTNG_EXPORT extern const char * const config_domain_type_kernel;
+LTTNG_EXPORT extern const char * const config_domain_type_ust;
+LTTNG_EXPORT extern const char * const config_domain_type_jul;
+LTTNG_EXPORT extern const char * const config_domain_type_log4j;
+LTTNG_EXPORT extern const char * const config_domain_type_python;
+
+LTTNG_EXPORT extern const char * const config_buffer_type_per_pid;
+LTTNG_EXPORT extern const char * const config_buffer_type_per_uid;
+LTTNG_EXPORT extern const char * const config_buffer_type_global;
+
+LTTNG_EXPORT extern const char * const config_overwrite_mode_discard;
+LTTNG_EXPORT extern const char * const config_overwrite_mode_overwrite;
+
+LTTNG_EXPORT extern const char * const config_output_type_splice;
+LTTNG_EXPORT extern const char * const config_output_type_mmap;
+
+LTTNG_EXPORT extern const char * const config_loglevel_type_all;
+LTTNG_EXPORT extern const char * const config_loglevel_type_range;
+LTTNG_EXPORT extern const char * const config_loglevel_type_single;
+
+LTTNG_EXPORT extern const char * const config_event_type_all;
+LTTNG_EXPORT extern const char * const config_event_type_tracepoint;
+LTTNG_EXPORT extern const char * const config_event_type_probe;
+extern const char * const config_event_type_userspace_probe;
+LTTNG_EXPORT extern const char * const config_event_type_function;
+LTTNG_EXPORT extern const char * const config_event_type_function_entry;
+LTTNG_EXPORT extern const char * const config_event_type_noop;
+LTTNG_EXPORT extern const char * const config_event_type_syscall;
+LTTNG_EXPORT extern const char * const config_event_type_kprobe;
+LTTNG_EXPORT extern const char * const config_event_type_kretprobe;
+
+LTTNG_EXPORT extern const char * const config_event_context_pid;
+LTTNG_EXPORT extern const char * const config_event_context_procname;
+LTTNG_EXPORT extern const char * const config_event_context_prio;
+LTTNG_EXPORT extern const char * const config_event_context_nice;
+LTTNG_EXPORT extern const char * const config_event_context_vpid;
+LTTNG_EXPORT extern const char * const config_event_context_tid;
+LTTNG_EXPORT extern const char * const config_event_context_vtid;
+LTTNG_EXPORT extern const char * const config_event_context_ppid;
+LTTNG_EXPORT extern const char * const config_event_context_vppid;
+LTTNG_EXPORT extern const char * const config_event_context_pthread_id;
+LTTNG_EXPORT extern const char * const config_event_context_hostname;
+LTTNG_EXPORT extern const char * const config_event_context_ip;
+LTTNG_EXPORT extern const char * const config_event_context_perf_thread_counter;
+extern const char * const config_event_context_app;
+extern const char * const config_event_context_interruptible;
+extern const char * const config_event_context_preemptible;
+extern const char * const config_event_context_need_reschedule;
+extern const char * const config_event_context_migratable;
+extern const char * const config_event_context_callstack_user;
+extern const char * const config_event_context_callstack_kernel;
+
+extern const char * const config_element_rotation_schedules;
+extern const char * const config_element_rotation_schedule_periodic;
+extern const char * const config_element_rotation_schedule_periodic_time_us;
+extern const char * const config_element_rotation_schedule_size_threshold;
+extern const char * const config_element_rotation_schedule_size_threshold_bytes;
+extern const char * const config_event_context_cgroup_ns;
+extern const char * const config_event_context_ipc_ns;
+extern const char * const config_event_context_mnt_ns;
+extern const char * const config_event_context_net_ns;
+extern const char * const config_event_context_pid_ns;
+extern const char * const config_event_context_time_ns;
+extern const char * const config_event_context_user_ns;
+extern const char * const config_event_context_uts_ns;
+extern const char * const config_event_context_uid;
+extern const char * const config_event_context_euid;
+extern const char * const config_event_context_suid;
+extern const char * const config_event_context_gid;
+extern const char * const config_event_context_egid;
+extern const char * const config_event_context_sgid;
+extern const char * const config_event_context_vuid;
+extern const char * const config_event_context_veuid;
+extern const char * const config_event_context_vsuid;
+extern const char * const config_event_context_vgid;
+extern const char * const config_event_context_vegid;
+extern const char * const config_event_context_vsgid;
+
+#endif /* CONFIG_SESSION_INTERNAL_H */
index 143f8365e9baf6b59ceed4c87160b10e877c153d..dfbddf2913d25550c7058ca96b9d7e54757501e9 100644 (file)
 #include <sys/stat.h>
 #include <stdbool.h>
 
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/utils.h>
-#include <common/dynamic-buffer.h>
-#include <common/compat/getenv.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/utils.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/compat/getenv.hpp>
 #include <lttng/lttng-error.h>
 #include <libxml/parser.h>
 #include <libxml/valid.h>
@@ -34,8 +34,8 @@
 #include <lttng/rotation.h>
 #include <lttng/userspace-probe.h>
 
-#include "session-config.h"
-#include "config-internal.h"
+#include "session-config.hpp"
+#include "config-internal.hpp"
 
 #define CONFIG_USERSPACE_PROBE_LOOKUP_METHOD_NAME_MAX_LEN 7
 
diff --git a/src/common/config/session-config.h b/src/common/config/session-config.h
deleted file mode 100644 (file)
index e7bb7ef..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _CONFIG_H
-#define _CONFIG_H
-
-#include <common/config/config-session-abi.h>
-#include <common/macros.h>
-#include <stdint.h>
-
-struct config_load_session_override_attr {
-       char *path_url;
-       char *ctrl_url;
-       char *data_url;
-       char *session_name;
-};
-
-/* Instance of a configuration writer. */
-struct config_writer;
-
-/*
- * Create an instance of a configuration writer.
- *
- * fd_output File to which the XML content must be written. fd_output is
- * owned by the caller.
- *
- * indent If other than 0 the XML will be pretty printed
- * with indentation and newline.
- *
- * Returns an instance of a configuration writer on success, NULL on
- * error.
- */
-struct config_writer *config_writer_create(int fd_output, int indent);
-
-/*
- * Destroy an instance of a configuration writer.
- *
- * writer An instance of a configuration writer.
- *
- * Returns zero if the XML document could be closed cleanly. Negative values
- * indicate an error.
- */
-int config_writer_destroy(struct config_writer *writer);
-
-/*
- * Open an element tag.
- *
- * writer An instance of a configuration writer.
- *
- * element_name Element tag name.
- *
- * Returns zero if the XML element could be opened.
- * Negative values indicate an error.
- */
-int config_writer_open_element(struct config_writer *writer,
-               const char *element_name);
-
-/*
- * Write an element tag attribute.
- *
- * writer An instance of a configuration writer.
- *
- * name Attribute name.
- *
- * Returns zero if the XML element's attribute could be written.
- * Negative values indicate an error.
- */
-int config_writer_write_attribute(struct config_writer *writer,
-               const char *name, const char *value);
-
-/*
- * Close the current element tag.
- *
- * writer An instance of a configuration writer.
- *
- * Returns zero if the XML document could be closed cleanly.
- * Negative values indicate an error.
- */
-int config_writer_close_element(struct config_writer *writer);
-
-/*
- * Write an element of type unsigned int.
- *
- * writer An instance of a configuration writer.
- *
- * element_name Element name.
- *
- * value Unsigned int value of the element
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int config_writer_write_element_unsigned_int(struct config_writer *writer,
-               const char *element_name, uint64_t value);
-
-/*
- * Write an element of type signed int.
- *
- * writer An instance of a configuration writer.
- *
- * element_name Element name.
- *
- * value Signed int value of the element
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int config_writer_write_element_signed_int(struct config_writer *writer,
-               const char *element_name, int64_t value);
-
-/*
- * Write an element of type boolean.
- *
- * writer An instance of a configuration writer.
- *
- * element_name Element name.
- *
- * value Boolean value of the element
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int config_writer_write_element_bool(struct config_writer *writer,
-               const char *element_name, int value);
-
-/*
- * Write an element of type string.
- *
- * writer An instance of a configuration writer.
- *
- * element_name Element name.
- *
- * value String value of the element
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int config_writer_write_element_string(struct config_writer *writer,
-               const char *element_name, const char *value);
-
-/*
- * Write an element of type double.
- *
- * writer An instance of a configuration writer.
- *
- * element_name Element name.
- *
- * value Double value of the element
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int config_writer_write_element_double(struct config_writer *writer,
-               const char *element_name,
-               double value);
-
-/*
- * Load session configurations from a file.
- *
- * path Path to an LTTng session configuration file. All *.lttng files
- * will be loaded if path is a directory. If path is NULL, the default
- * paths will be searched in the following order:
- *     1) $HOME/.lttng/sessions
- *     2) /etc/lttng/sessions
- *
- * session_name Name of the session to load. Will load all
- * sessions from path if NULL.
- *
- * overwrite Overwrite current session configuration if it exists.
- * autoload Tell to load the auto session(s).
- * overrides The override attribute structure specifying override parameters.
- *
- * Returns zero if the session could be loaded successfully. Returns
- * a negative LTTNG_ERR code on error.
- */
-int config_load_session(const char *path, const char *session_name,
-               int overwrite, unsigned int autoload,
-               const struct config_load_session_override_attr *overrides);
-
-#endif /* _CONFIG_H */
diff --git a/src/common/config/session-config.hpp b/src/common/config/session-config.hpp
new file mode 100644 (file)
index 0000000..71270a4
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+
+#include <common/config/config-session-abi.hpp>
+#include <common/macros.hpp>
+#include <stdint.h>
+
+struct config_load_session_override_attr {
+       char *path_url;
+       char *ctrl_url;
+       char *data_url;
+       char *session_name;
+};
+
+/* Instance of a configuration writer. */
+struct config_writer;
+
+/*
+ * Create an instance of a configuration writer.
+ *
+ * fd_output File to which the XML content must be written. fd_output is
+ * owned by the caller.
+ *
+ * indent If other than 0 the XML will be pretty printed
+ * with indentation and newline.
+ *
+ * Returns an instance of a configuration writer on success, NULL on
+ * error.
+ */
+struct config_writer *config_writer_create(int fd_output, int indent);
+
+/*
+ * Destroy an instance of a configuration writer.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * Returns zero if the XML document could be closed cleanly. Negative values
+ * indicate an error.
+ */
+int config_writer_destroy(struct config_writer *writer);
+
+/*
+ * Open an element tag.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * element_name Element tag name.
+ *
+ * Returns zero if the XML element could be opened.
+ * Negative values indicate an error.
+ */
+int config_writer_open_element(struct config_writer *writer,
+               const char *element_name);
+
+/*
+ * Write an element tag attribute.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * name Attribute name.
+ *
+ * Returns zero if the XML element's attribute could be written.
+ * Negative values indicate an error.
+ */
+int config_writer_write_attribute(struct config_writer *writer,
+               const char *name, const char *value);
+
+/*
+ * Close the current element tag.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int config_writer_close_element(struct config_writer *writer);
+
+/*
+ * Write an element of type unsigned int.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * element_name Element name.
+ *
+ * value Unsigned int value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int config_writer_write_element_unsigned_int(struct config_writer *writer,
+               const char *element_name, uint64_t value);
+
+/*
+ * Write an element of type signed int.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * element_name Element name.
+ *
+ * value Signed int value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int config_writer_write_element_signed_int(struct config_writer *writer,
+               const char *element_name, int64_t value);
+
+/*
+ * Write an element of type boolean.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * element_name Element name.
+ *
+ * value Boolean value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int config_writer_write_element_bool(struct config_writer *writer,
+               const char *element_name, int value);
+
+/*
+ * Write an element of type string.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * element_name Element name.
+ *
+ * value String value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int config_writer_write_element_string(struct config_writer *writer,
+               const char *element_name, const char *value);
+
+/*
+ * Write an element of type double.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * element_name Element name.
+ *
+ * value Double value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int config_writer_write_element_double(struct config_writer *writer,
+               const char *element_name,
+               double value);
+
+/*
+ * Load session configurations from a file.
+ *
+ * path Path to an LTTng session configuration file. All *.lttng files
+ * will be loaded if path is a directory. If path is NULL, the default
+ * paths will be searched in the following order:
+ *     1) $HOME/.lttng/sessions
+ *     2) /etc/lttng/sessions
+ *
+ * session_name Name of the session to load. Will load all
+ * sessions from path if NULL.
+ *
+ * overwrite Overwrite current session configuration if it exists.
+ * autoload Tell to load the auto session(s).
+ * overrides The override attribute structure specifying override parameters.
+ *
+ * Returns zero if the session could be loaded successfully. Returns
+ * a negative LTTNG_ERR code on error.
+ */
+int config_load_session(const char *path, const char *session_name,
+               int overwrite, unsigned int autoload,
+               const struct config_load_session_override_attr *overrides);
+
+#endif /* _CONFIG_H */
index fdda6be8b5f4027a94cb14597a0a8f2aa855764f..a810c7dab9eea84bbac194d6f1afa304603ee100 100644 (file)
 #include <unistd.h>
 #include <inttypes.h>
 
-#include <common/common.h>
-#include <common/utils.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/ust-consumer/ust-consumer.h>
-#include <common/consumer/consumer.h>
+#include <common/common.hpp>
+#include <common/utils.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/ust-consumer/ust-consumer.hpp>
+#include <common/consumer/consumer.hpp>
 
-#include "consumer-metadata-cache.h"
+#include "consumer-metadata-cache.hpp"
 
 enum metadata_cache_update_version_status {
        METADATA_CACHE_UPDATE_STATUS_VERSION_UPDATED,
diff --git a/src/common/consumer/consumer-metadata-cache.h b/src/common/consumer/consumer-metadata-cache.h
deleted file mode 100644 (file)
index b8f4efa..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef CONSUMER_METADATA_CACHE_H
-#define CONSUMER_METADATA_CACHE_H
-
-#include <common/consumer/consumer.h>
-#include <common/dynamic-buffer.h>
-
-enum consumer_metadata_cache_write_status {
-       CONSUMER_METADATA_CACHE_WRITE_STATUS_ERROR = -1,
-       /*
-        * New metadata content was appended to the cache successfully.
-        * Previously available content remains valid.
-        */
-       CONSUMER_METADATA_CACHE_WRITE_STATUS_APPENDED_CONTENT = 0,
-       /*
-        * The new content pushed to the cache invalidated the content that
-        * was already present. The contents of the cache should be re-read.
-        */
-       CONSUMER_METADATA_CACHE_WRITE_STATUS_INVALIDATED,
-       /*
-        * A metadata cache write can simply overwrite an already existing
-        * section of the cache (and it should be a write-through with identical
-        * data). From the caller's standpoint, there is no change to the state
-        * of the cache.
-        */
-       CONSUMER_METADATA_CACHE_WRITE_STATUS_NO_CHANGE,
-};
-
-struct consumer_metadata_cache {
-       /* Current version of the metadata cache. */
-       uint64_t version;
-       /*
-        * Size is the upper-limit of data written inside the buffer.
-        * All cached data is contiguous.
-        */
-       struct lttng_dynamic_buffer contents;
-       /*
-        * Lock to update the metadata cache and push into the ring_buffer
-        * (lttng_ust_ctl_write_metadata_to_channel).
-        *
-        * This is nested INSIDE the consumer_data lock.
-        */
-       pthread_mutex_t lock;
-};
-
-enum consumer_metadata_cache_write_status
-consumer_metadata_cache_write(struct consumer_metadata_cache *cache,
-               unsigned int offset, unsigned int len, uint64_t version,
-               const char *data);
-int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel);
-void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel);
-int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
-               uint64_t offset, int timer);
-
-#endif /* CONSUMER_METADATA_CACHE_H */
diff --git a/src/common/consumer/consumer-metadata-cache.hpp b/src/common/consumer/consumer-metadata-cache.hpp
new file mode 100644 (file)
index 0000000..6e60e5c
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef CONSUMER_METADATA_CACHE_H
+#define CONSUMER_METADATA_CACHE_H
+
+#include <common/consumer/consumer.hpp>
+#include <common/dynamic-buffer.hpp>
+
+enum consumer_metadata_cache_write_status {
+       CONSUMER_METADATA_CACHE_WRITE_STATUS_ERROR = -1,
+       /*
+        * New metadata content was appended to the cache successfully.
+        * Previously available content remains valid.
+        */
+       CONSUMER_METADATA_CACHE_WRITE_STATUS_APPENDED_CONTENT = 0,
+       /*
+        * The new content pushed to the cache invalidated the content that
+        * was already present. The contents of the cache should be re-read.
+        */
+       CONSUMER_METADATA_CACHE_WRITE_STATUS_INVALIDATED,
+       /*
+        * A metadata cache write can simply overwrite an already existing
+        * section of the cache (and it should be a write-through with identical
+        * data). From the caller's standpoint, there is no change to the state
+        * of the cache.
+        */
+       CONSUMER_METADATA_CACHE_WRITE_STATUS_NO_CHANGE,
+};
+
+struct consumer_metadata_cache {
+       /* Current version of the metadata cache. */
+       uint64_t version;
+       /*
+        * Size is the upper-limit of data written inside the buffer.
+        * All cached data is contiguous.
+        */
+       struct lttng_dynamic_buffer contents;
+       /*
+        * Lock to update the metadata cache and push into the ring_buffer
+        * (lttng_ust_ctl_write_metadata_to_channel).
+        *
+        * This is nested INSIDE the consumer_data lock.
+        */
+       pthread_mutex_t lock;
+};
+
+enum consumer_metadata_cache_write_status
+consumer_metadata_cache_write(struct consumer_metadata_cache *cache,
+               unsigned int offset, unsigned int len, uint64_t version,
+               const char *data);
+int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel);
+void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel);
+int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
+               uint64_t offset, int timer);
+
+#endif /* CONSUMER_METADATA_CACHE_H */
index ebbd66a8ba06abc8b871001a272d2e888cd1a0c0..f57e37ab81379027daf318acc58d2b90b710b41d 100644 (file)
 #include <sys/mman.h>
 #include <unistd.h>
 
-#include <common/common.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/metadata-bucket.h>
-#include <common/consumer/metadata-bucket.h>
-#include <common/index/index.h>
-#include <common/kernel-consumer/kernel-consumer.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/macros.h>
-#include <common/relayd/relayd.h>
-#include <common/ust-consumer/ust-consumer.h>
-#include <common/utils.h>
-
-#include "consumer-stream.h"
+#include <common/common.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/consumer/metadata-bucket.hpp>
+#include <common/consumer/metadata-bucket.hpp>
+#include <common/index/index.hpp>
+#include <common/kernel-consumer/kernel-consumer.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/macros.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/ust-consumer/ust-consumer.hpp>
+#include <common/utils.hpp>
+
+#include "consumer-stream.hpp"
 
 /*
  * RCU call to free stream. MUST only be used with call_rcu().
diff --git a/src/common/consumer/consumer-stream.h b/src/common/consumer/consumer-stream.h
deleted file mode 100644 (file)
index 021742e..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_CONSUMER_STREAM_H
-#define LTTNG_CONSUMER_STREAM_H
-
-#include "consumer.h"
-
-enum consumer_stream_open_packet_status {
-       CONSUMER_STREAM_OPEN_PACKET_STATUS_OPENED,
-       CONSUMER_STREAM_OPEN_PACKET_STATUS_NO_SPACE,
-       CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR,
-};
-
-/*
- * Create a consumer stream.
- *
- * The channel lock MUST be acquired.
- */
-struct lttng_consumer_stream *consumer_stream_create(
-               struct lttng_consumer_channel *channel,
-               uint64_t channel_key,
-               uint64_t stream_key,
-               const char *channel_name,
-               uint64_t relayd_id,
-               uint64_t session_id,
-               struct lttng_trace_chunk *trace_chunk,
-               int cpu,
-               int *alloc_ret,
-               enum consumer_channel_type type,
-               unsigned int monitor);
-
-/*
- * Close stream's file descriptors and, if needed, close stream also on the
- * relayd side.
- *
- * The stream lock MUST be acquired.
- * The consumer data lock MUST be acquired.
- */
-void consumer_stream_close(struct lttng_consumer_stream *stream);
-
-/*
- * Close stream on the relayd side. This call can destroy a relayd if the
- * conditions are met.
- *
- * A RCU read side lock MUST be acquired if the relayd object was looked up in
- * a hash table before calling this.
- */
-void consumer_stream_relayd_close(struct lttng_consumer_stream *stream,
-               struct consumer_relayd_sock_pair *relayd);
-
-/*
- * Delete the stream from all possible hash tables.
- *
- * The consumer data lock MUST be acquired.
- */
-void consumer_stream_delete(struct lttng_consumer_stream *stream,
-               struct lttng_ht *ht);
-
-/*
- * Free the given stream within a RCU call.
- */
-void consumer_stream_free(struct lttng_consumer_stream *stream);
-
-/*
- * Destroy a stream completely. This will delete, close and free the stream.
- * Once return, the stream is NO longer usable. Its channel may get destroyed
- * if conditions are met.
- *
- * This MUST be called WITHOUT the consumer data and stream lock acquired.
- */
-void consumer_stream_destroy(struct lttng_consumer_stream *stream,
-               struct lttng_ht *ht);
-
-/*
- * Destroy the stream's buffers on the tracer side. This is also called in a
- * stream destroy.
- */
-void consumer_stream_destroy_buffers(struct lttng_consumer_stream *stream);
-
-/*
- * Write index of a specific stream either on the relayd or local disk.
- */
-int consumer_stream_write_index(struct lttng_consumer_stream *stream,
-               struct ctf_packet_index *index);
-
-int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx,
-               uint64_t session_id);
-
-/*
- * Create the output files of a local stream.
- *
- * This must be called with the channel's and the stream's lock held.
- */
-int consumer_stream_create_output_files(struct lttng_consumer_stream *stream,
-               bool create_index);
-
-/*
- * Rotate the output files of a local stream. This will change the
- * active output files of both the binary and index in accordance
- * with the stream's configuration (stream file count).
- *
- * This must be called with the channel's and the stream's lock held.
- */
-int consumer_stream_rotate_output_files(struct lttng_consumer_stream *stream);
-
-/*
- * Indicates whether or not a stream is logically deleted. A deleted stream
- * should no longer be used; its existence is only garanteed by the RCU lock
- * held by the caller.
- *
- * This function must be called with the RCU read side lock held.
- */
-bool consumer_stream_is_deleted(struct lttng_consumer_stream *stream);
-
-/*
- * Enable metadata bucketization. This must only be enabled if the tracer
- * provides a reliable metadata `coherent` flag.
- *
- * This must be called on initialization before any subbuffer is consumed.
- */
-int consumer_stream_enable_metadata_bucketization(
-               struct lttng_consumer_stream *stream);
-
-/*
- * Set the version of a metadata stream (i.e. following a metadata
- * regeneration).
- *
- * Changing the version of a metadata stream will cause any bucketized metadata
- * to be discarded and will mark the metadata stream for future `reset`.
- */
-void consumer_stream_metadata_set_version(
-               struct lttng_consumer_stream *stream, uint64_t new_version);
-
-/*
- * Attempt to open a packet in a stream.
- *
- * This function must be called with the stream and channel locks held.
- */
-enum consumer_stream_open_packet_status consumer_stream_open_packet(
-               struct lttng_consumer_stream *stream);
-
-/*
- * Flush a stream's buffer.
- *
- * producer_active: if true, causes a flush to occur only if there is
- * content present in the current sub-buffer. If false, forces a flush to take
- * place (otherwise known as "flush_empty").
- *
- * This function must be called with the stream and channel locks held.
- */
-int consumer_stream_flush_buffer(struct lttng_consumer_stream *stream,
-               bool producer_active);
-
-#endif /* LTTNG_CONSUMER_STREAM_H */
diff --git a/src/common/consumer/consumer-stream.hpp b/src/common/consumer/consumer-stream.hpp
new file mode 100644 (file)
index 0000000..a8e5ddd
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_CONSUMER_STREAM_H
+#define LTTNG_CONSUMER_STREAM_H
+
+#include "consumer.hpp"
+
+enum consumer_stream_open_packet_status {
+       CONSUMER_STREAM_OPEN_PACKET_STATUS_OPENED,
+       CONSUMER_STREAM_OPEN_PACKET_STATUS_NO_SPACE,
+       CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR,
+};
+
+/*
+ * Create a consumer stream.
+ *
+ * The channel lock MUST be acquired.
+ */
+struct lttng_consumer_stream *consumer_stream_create(
+               struct lttng_consumer_channel *channel,
+               uint64_t channel_key,
+               uint64_t stream_key,
+               const char *channel_name,
+               uint64_t relayd_id,
+               uint64_t session_id,
+               struct lttng_trace_chunk *trace_chunk,
+               int cpu,
+               int *alloc_ret,
+               enum consumer_channel_type type,
+               unsigned int monitor);
+
+/*
+ * Close stream's file descriptors and, if needed, close stream also on the
+ * relayd side.
+ *
+ * The stream lock MUST be acquired.
+ * The consumer data lock MUST be acquired.
+ */
+void consumer_stream_close(struct lttng_consumer_stream *stream);
+
+/*
+ * Close stream on the relayd side. This call can destroy a relayd if the
+ * conditions are met.
+ *
+ * A RCU read side lock MUST be acquired if the relayd object was looked up in
+ * a hash table before calling this.
+ */
+void consumer_stream_relayd_close(struct lttng_consumer_stream *stream,
+               struct consumer_relayd_sock_pair *relayd);
+
+/*
+ * Delete the stream from all possible hash tables.
+ *
+ * The consumer data lock MUST be acquired.
+ */
+void consumer_stream_delete(struct lttng_consumer_stream *stream,
+               struct lttng_ht *ht);
+
+/*
+ * Free the given stream within a RCU call.
+ */
+void consumer_stream_free(struct lttng_consumer_stream *stream);
+
+/*
+ * Destroy a stream completely. This will delete, close and free the stream.
+ * Once return, the stream is NO longer usable. Its channel may get destroyed
+ * if conditions are met.
+ *
+ * This MUST be called WITHOUT the consumer data and stream lock acquired.
+ */
+void consumer_stream_destroy(struct lttng_consumer_stream *stream,
+               struct lttng_ht *ht);
+
+/*
+ * Destroy the stream's buffers on the tracer side. This is also called in a
+ * stream destroy.
+ */
+void consumer_stream_destroy_buffers(struct lttng_consumer_stream *stream);
+
+/*
+ * Write index of a specific stream either on the relayd or local disk.
+ */
+int consumer_stream_write_index(struct lttng_consumer_stream *stream,
+               struct ctf_packet_index *index);
+
+int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx,
+               uint64_t session_id);
+
+/*
+ * Create the output files of a local stream.
+ *
+ * This must be called with the channel's and the stream's lock held.
+ */
+int consumer_stream_create_output_files(struct lttng_consumer_stream *stream,
+               bool create_index);
+
+/*
+ * Rotate the output files of a local stream. This will change the
+ * active output files of both the binary and index in accordance
+ * with the stream's configuration (stream file count).
+ *
+ * This must be called with the channel's and the stream's lock held.
+ */
+int consumer_stream_rotate_output_files(struct lttng_consumer_stream *stream);
+
+/*
+ * Indicates whether or not a stream is logically deleted. A deleted stream
+ * should no longer be used; its existence is only garanteed by the RCU lock
+ * held by the caller.
+ *
+ * This function must be called with the RCU read side lock held.
+ */
+bool consumer_stream_is_deleted(struct lttng_consumer_stream *stream);
+
+/*
+ * Enable metadata bucketization. This must only be enabled if the tracer
+ * provides a reliable metadata `coherent` flag.
+ *
+ * This must be called on initialization before any subbuffer is consumed.
+ */
+int consumer_stream_enable_metadata_bucketization(
+               struct lttng_consumer_stream *stream);
+
+/*
+ * Set the version of a metadata stream (i.e. following a metadata
+ * regeneration).
+ *
+ * Changing the version of a metadata stream will cause any bucketized metadata
+ * to be discarded and will mark the metadata stream for future `reset`.
+ */
+void consumer_stream_metadata_set_version(
+               struct lttng_consumer_stream *stream, uint64_t new_version);
+
+/*
+ * Attempt to open a packet in a stream.
+ *
+ * This function must be called with the stream and channel locks held.
+ */
+enum consumer_stream_open_packet_status consumer_stream_open_packet(
+               struct lttng_consumer_stream *stream);
+
+/*
+ * Flush a stream's buffer.
+ *
+ * producer_active: if true, causes a flush to occur only if there is
+ * content present in the current sub-buffer. If false, forces a flush to take
+ * place (otherwise known as "flush_empty").
+ *
+ * This function must be called with the stream and channel locks held.
+ */
+int consumer_stream_flush_buffer(struct lttng_consumer_stream *stream,
+               bool producer_active);
+
+#endif /* LTTNG_CONSUMER_STREAM_H */
diff --git a/src/common/consumer/consumer-testpoint.h b/src/common/consumer/consumer-testpoint.h
deleted file mode 100644 (file)
index 7373522..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef CONSUMERD_TESTPOINT_H
-#define CONSUMERD_TESTPOINT_H
-
-/*
- * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
- * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <common/testpoint/testpoint.h>
-
-/* Testpoints, internal use only */
-TESTPOINT_DECL(consumerd_thread_channel);
-TESTPOINT_DECL(consumerd_thread_metadata);
-TESTPOINT_DECL(consumerd_thread_data);
-TESTPOINT_DECL(consumerd_thread_data_poll);
-TESTPOINT_DECL(consumerd_thread_sessiond);
-TESTPOINT_DECL(consumerd_thread_metadata_timer);
-
-#endif /* CONSUMERD_TESTPOINT_H */
diff --git a/src/common/consumer/consumer-testpoint.hpp b/src/common/consumer/consumer-testpoint.hpp
new file mode 100644 (file)
index 0000000..90b66a9
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef CONSUMERD_TESTPOINT_H
+#define CONSUMERD_TESTPOINT_H
+
+/*
+ * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
+ * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <common/testpoint/testpoint.hpp>
+
+/* Testpoints, internal use only */
+TESTPOINT_DECL(consumerd_thread_channel);
+TESTPOINT_DECL(consumerd_thread_metadata);
+TESTPOINT_DECL(consumerd_thread_data);
+TESTPOINT_DECL(consumerd_thread_data_poll);
+TESTPOINT_DECL(consumerd_thread_sessiond);
+TESTPOINT_DECL(consumerd_thread_metadata_timer);
+
+#endif /* CONSUMERD_TESTPOINT_H */
index 51fa1687e9359a2d0c9a09e77b4573e8dce6e0ce..f37bfa3506c0f08d6bc59f96ed6daf72736c0330 100644 (file)
 #include <inttypes.h>
 #include <signal.h>
 
-#include <bin/lttng-consumerd/health-consumerd.h>
-#include <common/common.h>
-#include <common/compat/endian.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/kernel-consumer/kernel-consumer.h>
-#include <common/consumer/consumer-stream.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/consumer/consumer-testpoint.h>
-#include <common/ust-consumer/ust-consumer.h>
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/kernel-consumer/kernel-consumer.hpp>
+#include <common/consumer/consumer-stream.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/consumer/consumer-testpoint.hpp>
+#include <common/ust-consumer/ust-consumer.hpp>
 
 typedef int (*sample_positions_cb)(struct lttng_consumer_stream *stream);
 typedef int (*get_consumed_cb)(struct lttng_consumer_stream *stream,
diff --git a/src/common/consumer/consumer-timer.h b/src/common/consumer/consumer-timer.h
deleted file mode 100644 (file)
index bf1649c..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef CONSUMER_TIMER_H
-#define CONSUMER_TIMER_H
-
-#include <pthread.h>
-
-#include "consumer.h"
-
-#define LTTNG_CONSUMER_SIG_SWITCH      SIGRTMIN + 10
-#define LTTNG_CONSUMER_SIG_TEARDOWN    SIGRTMIN + 11
-#define LTTNG_CONSUMER_SIG_LIVE                SIGRTMIN + 12
-#define LTTNG_CONSUMER_SIG_MONITOR     SIGRTMIN + 13
-#define LTTNG_CONSUMER_SIG_EXIT                SIGRTMIN + 14
-
-#define CLOCKID CLOCK_MONOTONIC
-
-/*
- * Handle timer teardown race wrt memory free of private data by consumer
- * signals are handled by a single thread, which permits a synchronization
- * point between handling of each signal. Internal lock ensures mutual
- * exclusion.
- */
-struct timer_signal_data {
-       pthread_t tid;  /* thread id managing signals */
-       int setup_done;
-       int qs_done;
-       pthread_mutex_t lock;
-};
-
-void consumer_timer_switch_start(struct lttng_consumer_channel *channel,
-               unsigned int switch_timer_interval_us);
-void consumer_timer_switch_stop(struct lttng_consumer_channel *channel);
-void consumer_timer_live_start(struct lttng_consumer_channel *channel,
-               unsigned int live_timer_interval_us);
-void consumer_timer_live_stop(struct lttng_consumer_channel *channel);
-int consumer_timer_monitor_start(struct lttng_consumer_channel *channel,
-               unsigned int monitor_timer_interval_us);
-int consumer_timer_monitor_stop(struct lttng_consumer_channel *channel);
-void *consumer_timer_thread(void *data);
-int consumer_signal_init(void);
-
-int consumer_flush_kernel_index(struct lttng_consumer_stream *stream);
-int consumer_flush_ust_index(struct lttng_consumer_stream *stream);
-
-int consumer_timer_thread_get_channel_monitor_pipe(void);
-int consumer_timer_thread_set_channel_monitor_pipe(int fd);
-
-#endif /* CONSUMER_TIMER_H */
diff --git a/src/common/consumer/consumer-timer.hpp b/src/common/consumer/consumer-timer.hpp
new file mode 100644 (file)
index 0000000..3445ed5
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef CONSUMER_TIMER_H
+#define CONSUMER_TIMER_H
+
+#include <pthread.h>
+
+#include "consumer.hpp"
+
+#define LTTNG_CONSUMER_SIG_SWITCH      SIGRTMIN + 10
+#define LTTNG_CONSUMER_SIG_TEARDOWN    SIGRTMIN + 11
+#define LTTNG_CONSUMER_SIG_LIVE                SIGRTMIN + 12
+#define LTTNG_CONSUMER_SIG_MONITOR     SIGRTMIN + 13
+#define LTTNG_CONSUMER_SIG_EXIT                SIGRTMIN + 14
+
+#define CLOCKID CLOCK_MONOTONIC
+
+/*
+ * Handle timer teardown race wrt memory free of private data by consumer
+ * signals are handled by a single thread, which permits a synchronization
+ * point between handling of each signal. Internal lock ensures mutual
+ * exclusion.
+ */
+struct timer_signal_data {
+       pthread_t tid;  /* thread id managing signals */
+       int setup_done;
+       int qs_done;
+       pthread_mutex_t lock;
+};
+
+void consumer_timer_switch_start(struct lttng_consumer_channel *channel,
+               unsigned int switch_timer_interval_us);
+void consumer_timer_switch_stop(struct lttng_consumer_channel *channel);
+void consumer_timer_live_start(struct lttng_consumer_channel *channel,
+               unsigned int live_timer_interval_us);
+void consumer_timer_live_stop(struct lttng_consumer_channel *channel);
+int consumer_timer_monitor_start(struct lttng_consumer_channel *channel,
+               unsigned int monitor_timer_interval_us);
+int consumer_timer_monitor_stop(struct lttng_consumer_channel *channel);
+void *consumer_timer_thread(void *data);
+int consumer_signal_init(void);
+
+int consumer_flush_kernel_index(struct lttng_consumer_stream *stream);
+int consumer_flush_ust_index(struct lttng_consumer_stream *stream);
+
+int consumer_timer_thread_get_channel_monitor_pipe(void);
+int consumer_timer_thread_set_channel_monitor_pipe(int fd);
+
+#endif /* CONSUMER_TIMER_H */
index f26ccd71a9ff57bc3eda8c2b97cc58ae5ec0a414..685d55f838120a4b94cf407d9e420e03cf294e32 100644 (file)
@@ -7,43 +7,42 @@
  *
  */
 
-#include "common/index/ctf-index.h"
-#include <stdint.h>
 #define _LGPL_SOURCE
+#include <inttypes.h>
 #include <poll.h>
 #include <pthread.h>
+#include <signal.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/mman.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <inttypes.h>
-#include <signal.h>
 
-#include <bin/lttng-consumerd/health-consumerd.h>
-#include <common/common.h>
-#include <common/utils.h>
-#include <common/time.h>
-#include <common/compat/poll.h>
-#include <common/compat/endian.h>
-#include <common/index/index.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/kernel-consumer/kernel-consumer.h>
-#include <common/relayd/relayd.h>
-#include <common/ust-consumer/ust-consumer.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/consumer-stream.h>
-#include <common/consumer/consumer-testpoint.h>
-#include <common/align.h>
-#include <common/consumer/consumer-metadata-cache.h>
-#include <common/trace-chunk.h>
-#include <common/trace-chunk-registry.h>
-#include <common/string-utils/format.h>
-#include <common/dynamic-array.h>
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <common/align.hpp>
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/poll.hpp>
+#include <common/consumer/consumer-metadata-cache.hpp>
+#include <common/consumer/consumer-stream.hpp>
+#include <common/consumer/consumer-testpoint.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/index/ctf-index.hpp>
+#include <common/index/index.hpp>
+#include <common/kernel-consumer/kernel-consumer.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/string-utils/format.hpp>
+#include <common/time.hpp>
+#include <common/trace-chunk-registry.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/ust-consumer/ust-consumer.hpp>
+#include <common/utils.hpp>
 
 lttng_consumer_global_data the_consumer_data;
 
diff --git a/src/common/consumer/consumer.h b/src/common/consumer/consumer.h
deleted file mode 100644 (file)
index 1c6eeb3..0000000
+++ /dev/null
@@ -1,1085 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LIB_CONSUMER_H
-#define LIB_CONSUMER_H
-
-#include <limits.h>
-#include <poll.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <urcu/list.h>
-
-#include <lttng/lttng.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/compat/fcntl.h>
-#include <common/uuid.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/pipe.h>
-#include <common/index/ctf-index.h>
-#include <common/trace-chunk-registry.h>
-#include <common/credentials.h>
-#include <common/buffer-view.h>
-#include <common/dynamic-array.h>
-
-struct lttng_consumer_local_data;
-
-/* Commands for consumer */
-enum lttng_consumer_command {
-       LTTNG_CONSUMER_ADD_CHANNEL,
-       LTTNG_CONSUMER_ADD_STREAM,
-       /* pause, delete, active depending on fd state */
-       LTTNG_CONSUMER_UPDATE_STREAM,
-       /* inform the consumer to quit when all fd has hang up */
-       LTTNG_CONSUMER_STOP,    /* deprecated */
-       LTTNG_CONSUMER_ADD_RELAYD_SOCKET,
-       /* Inform the consumer to kill a specific relayd connection */
-       LTTNG_CONSUMER_DESTROY_RELAYD,
-       /* Return to the sessiond if there is data pending for a session */
-       LTTNG_CONSUMER_DATA_PENDING,
-       /* Consumer creates a channel and returns it to sessiond. */
-       LTTNG_CONSUMER_ASK_CHANNEL_CREATION,
-       LTTNG_CONSUMER_GET_CHANNEL,
-       LTTNG_CONSUMER_DESTROY_CHANNEL,
-       LTTNG_CONSUMER_PUSH_METADATA,
-       LTTNG_CONSUMER_CLOSE_METADATA,
-       LTTNG_CONSUMER_SETUP_METADATA,
-       LTTNG_CONSUMER_FLUSH_CHANNEL,
-       LTTNG_CONSUMER_SNAPSHOT_CHANNEL,
-       LTTNG_CONSUMER_SNAPSHOT_METADATA,
-       LTTNG_CONSUMER_STREAMS_SENT,
-       LTTNG_CONSUMER_DISCARDED_EVENTS,
-       LTTNG_CONSUMER_LOST_PACKETS,
-       LTTNG_CONSUMER_CLEAR_QUIESCENT_CHANNEL,
-       LTTNG_CONSUMER_SET_CHANNEL_MONITOR_PIPE,
-       LTTNG_CONSUMER_ROTATE_CHANNEL,
-       LTTNG_CONSUMER_INIT,
-       LTTNG_CONSUMER_CREATE_TRACE_CHUNK,
-       LTTNG_CONSUMER_CLOSE_TRACE_CHUNK,
-       LTTNG_CONSUMER_TRACE_CHUNK_EXISTS,
-       LTTNG_CONSUMER_CLEAR_CHANNEL,
-       LTTNG_CONSUMER_OPEN_CHANNEL_PACKETS,
-};
-
-enum lttng_consumer_type {
-       LTTNG_CONSUMER_UNKNOWN = 0,
-       LTTNG_CONSUMER_KERNEL,
-       LTTNG_CONSUMER64_UST,
-       LTTNG_CONSUMER32_UST,
-};
-
-enum consumer_endpoint_status {
-       CONSUMER_ENDPOINT_ACTIVE,
-       CONSUMER_ENDPOINT_INACTIVE,
-};
-
-enum consumer_channel_output {
-       CONSUMER_CHANNEL_MMAP   = 0,
-       CONSUMER_CHANNEL_SPLICE = 1,
-};
-
-enum consumer_channel_type {
-       CONSUMER_CHANNEL_TYPE_METADATA  = 0,
-       CONSUMER_CHANNEL_TYPE_DATA      = 1,
-};
-
-enum sync_metadata_status {
-       SYNC_METADATA_STATUS_NEW_DATA,
-       SYNC_METADATA_STATUS_NO_DATA,
-       SYNC_METADATA_STATUS_ERROR,
-};
-
-extern struct lttng_consumer_global_data the_consumer_data;
-
-struct stream_list {
-       struct cds_list_head head;
-       unsigned int count;
-};
-
-/* Stub. */
-struct consumer_metadata_cache;
-
-struct lttng_consumer_channel {
-       /* Is the channel published in the channel hash tables? */
-       bool is_published;
-       /*
-        * Was the channel deleted (logically) and waiting to be reclaimed?
-        * If this flag is set, no modification that is not cleaned-up by the
-        * RCU reclamation callback should be made
-        */
-       bool is_deleted;
-       /* HT node used for consumer_data.channel_ht */
-       struct lttng_ht_node_u64 node;
-       /* HT node used for consumer_data.channels_by_session_id_ht */
-       struct lttng_ht_node_u64 channels_by_session_id_ht_node;
-       /* Indexed key. Incremented value in the consumer. */
-       uint64_t key;
-       /* Number of streams referencing this channel */
-       int refcount;
-       /* Tracing session id on the session daemon side. */
-       uint64_t session_id;
-       /* Current trace chunk of the session in which this channel exists. */
-       struct lttng_trace_chunk *trace_chunk;
-       /*
-        * Session id when requesting metadata to the session daemon for
-        * a session with per-PID buffers.
-        */
-       uint64_t session_id_per_pid;
-       /*
-        * In the case of local streams, this field contains the channel's
-        * output path; a path relative to the session's output path.
-        *   e.g. ust/uid/1000/64-bit
-        *
-        * In the case of remote streams, the contents of this field depends
-        * on the version of the relay daemon peer. For 2.11+ peers, the
-        * contents are the same as in the local case. However, for legacy
-        * peers, this contains a path of the form:
-        *   /hostname/session_path/ust/uid/1000/64-bit
-        */
-       char pathname[PATH_MAX];
-       /* Channel name. */
-       char name[LTTNG_SYMBOL_NAME_LEN];
-       /* Relayd id of the channel. -1ULL if it does not apply. */
-       uint64_t relayd_id;
-       /*
-        * Number of streams NOT initialized yet. This is used in order to not
-        * delete this channel if streams are getting initialized.
-        */
-       unsigned int nb_init_stream_left;
-       /* Output type (mmap or splice). */
-       enum consumer_channel_output output;
-       /* Channel type for stream */
-       enum consumer_channel_type type;
-
-       /* For UST */
-       uid_t ust_app_uid;      /* Application UID. */
-       struct lttng_ust_ctl_consumer_channel *uchan;
-       unsigned char uuid[LTTNG_UUID_STR_LEN];
-       /*
-        * Temporary stream list used to store the streams once created and waiting
-        * to be sent to the session daemon by receiving the
-        * LTTNG_CONSUMER_GET_CHANNEL.
-        */
-       struct stream_list streams;
-
-       /*
-        * Set if the channel is metadata. We keep a reference to the stream
-        * because we have to flush data once pushed by the session daemon. For a
-        * regular channel, this is always set to NULL.
-        */
-       struct lttng_consumer_stream *metadata_stream;
-
-       /* for UST */
-       int wait_fd;
-       /* Node within channel thread ht */
-       struct lttng_ht_node_u64 wait_fd_node;
-
-       /* Metadata cache is metadata channel */
-       struct consumer_metadata_cache *metadata_cache;
-
-       /* For UST metadata periodical flush */
-       int switch_timer_enabled;
-       timer_t switch_timer;
-       int switch_timer_error;
-
-       /* For the live mode */
-       int live_timer_enabled;
-       timer_t live_timer;
-       int live_timer_error;
-       /* Channel is part of a live session ? */
-       bool is_live;
-
-       /* For channel monitoring timer. */
-       int monitor_timer_enabled;
-       timer_t monitor_timer;
-
-       /* On-disk circular buffer */
-       uint64_t tracefile_size;
-       uint64_t tracefile_count;
-       /*
-        * Monitor or not the streams of this channel meaning this indicates if the
-        * streams should be sent to the data/metadata thread or added to the no
-        * monitor list of the channel.
-        */
-       unsigned int monitor;
-
-       /*
-        * Channel lock.
-        *
-        * This lock protects against concurrent update of channel.
-        *
-        * This is nested INSIDE the consumer data lock.
-        * This is nested OUTSIDE the channel timer lock.
-        * This is nested OUTSIDE the metadata cache lock.
-        * This is nested OUTSIDE stream lock.
-        * This is nested OUTSIDE consumer_relayd_sock_pair lock.
-        */
-       pthread_mutex_t lock;
-
-       /*
-        * Channel teardown lock.
-        *
-        * This lock protect against teardown of channel. It is _never_
-        * taken by the timer handler.
-        *
-        * This is nested INSIDE the consumer data lock.
-        * This is nested INSIDE the channel lock.
-        * This is nested OUTSIDE the metadata cache lock.
-        * This is nested OUTSIDE stream lock.
-        * This is nested OUTSIDE consumer_relayd_sock_pair lock.
-        */
-       pthread_mutex_t timer_lock;
-
-       /* Timer value in usec for live streaming. */
-       unsigned int live_timer_interval;
-
-       int *stream_fds;
-       int nr_stream_fds;
-       char root_shm_path[PATH_MAX];
-       char shm_path[PATH_MAX];
-       /* Only set for UST channels. */
-       LTTNG_OPTIONAL(struct lttng_credentials) buffer_credentials;
-       /* Total number of discarded events for that channel. */
-       uint64_t discarded_events;
-       /* Total number of missed packets due to overwriting (overwrite). */
-       uint64_t lost_packets;
-
-       bool streams_sent_to_relayd;
-};
-
-struct stream_subbuffer {
-       union {
-               /*
-                * CONSUMER_CHANNEL_SPLICE
-                * No ownership assumed.
-                */
-               int fd;
-               /* CONSUMER_CHANNEL_MMAP */
-               struct lttng_buffer_view buffer;
-       } buffer;
-       union {
-               /*
-                * Common members are fine to access through either
-                * union entries (as per C11, Common Initial Sequence).
-                */
-               struct {
-                       unsigned long subbuf_size;
-                       unsigned long padded_subbuf_size;
-                       uint64_t version;
-                       /*
-                        * Left unset when unsupported.
-                        *
-                        * Indicates that this is the last sub-buffer of
-                        * a series of sub-buffer that makes-up a coherent
-                        * (parseable) unit of metadata.
-                        */
-                       LTTNG_OPTIONAL(bool) coherent;
-               } metadata;
-               struct {
-                       unsigned long subbuf_size;
-                       unsigned long padded_subbuf_size;
-                       uint64_t packet_size;
-                       uint64_t content_size;
-                       uint64_t timestamp_begin;
-                       uint64_t timestamp_end;
-                       uint64_t events_discarded;
-                       /* Left unset when unsupported. */
-                       LTTNG_OPTIONAL(uint64_t) sequence_number;
-                       uint64_t stream_id;
-                       /* Left unset when unsupported. */
-                       LTTNG_OPTIONAL(uint64_t) stream_instance_id;
-               } data;
-       } info;
-};
-
-enum get_next_subbuffer_status {
-       GET_NEXT_SUBBUFFER_STATUS_OK,
-       GET_NEXT_SUBBUFFER_STATUS_NO_DATA,
-       GET_NEXT_SUBBUFFER_STATUS_ERROR,
-};
-
-/*
- * Perform any operation required to acknowledge
- * the wake-up of a consumer stream (e.g. consume a byte on a wake-up pipe).
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*on_wake_up_cb)(struct lttng_consumer_stream *);
-
-/*
- * Perform any operation required before a consumer stream is put
- * to sleep before awaiting a data availability notification.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*on_sleep_cb)(struct lttng_consumer_stream *,
-               struct lttng_consumer_local_data *);
-
-/*
- * Acquire the subbuffer at the current 'consumed' position.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef enum get_next_subbuffer_status (*get_next_subbuffer_cb)(
-               struct lttng_consumer_stream *, struct stream_subbuffer *);
-
-/*
- * Populate the stream_subbuffer's info member. The info to populate
- * depends on the type (metadata/data) of the stream.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*extract_subbuffer_info_cb)(
-               struct lttng_consumer_stream *, struct stream_subbuffer *);
-
-/*
- * Invoked after a subbuffer's info has been filled.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*pre_consume_subbuffer_cb)(struct lttng_consumer_stream *,
-               const struct stream_subbuffer *);
-
-/*
- * Consume subbuffer contents.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef ssize_t (*consume_subbuffer_cb)(struct lttng_consumer_local_data *,
-               struct lttng_consumer_stream *,
-               const struct stream_subbuffer *);
-
-/*
- * Release the current subbuffer and advance the 'consumed' position by
- * one subbuffer.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*put_next_subbuffer_cb)(struct lttng_consumer_stream *,
-               struct stream_subbuffer *);
-
-/*
- * Invoked after consuming a subbuffer.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*post_consume_cb)(struct lttng_consumer_stream *,
-               const struct stream_subbuffer *,
-               struct lttng_consumer_local_data *);
-
-/*
- * Send a live beacon if no data is available.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*send_live_beacon_cb)(struct lttng_consumer_stream *);
-
-/*
- * Lock the stream and channel locks and any other stream-type specific
- * lock that need to be acquired during the processing of an
- * availability notification.
- */
-typedef void (*lock_cb)(struct lttng_consumer_stream *);
-
-/*
- * Unlock the stream and channel locks and any other stream-type specific
- * lock before sleeping until the next availability notification.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef void (*unlock_cb)(struct lttng_consumer_stream *);
-
-/*
- * Assert that the stream and channel lock and any other stream type specific
- * lock that need to be acquired during the processing of a read_subbuffer
- * operation is acquired.
- */
-typedef void (*assert_locked_cb)(struct lttng_consumer_stream *);
-
-/*
- * Invoked when a subbuffer's metadata version does not match the last
- * known metadata version.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef void (*reset_metadata_cb)(struct lttng_consumer_stream *);
-
-/*
- * Internal representation of the streams, sessiond_key is used to identify
- * uniquely a stream.
- */
-struct lttng_consumer_stream {
-       /* HT node used by the data_ht and metadata_ht */
-       struct lttng_ht_node_u64 node;
-       /* stream indexed per channel key node */
-       struct lttng_ht_node_u64 node_channel_id;
-       /* HT node used in consumer_data.stream_list_ht */
-       struct lttng_ht_node_u64 node_session_id;
-       /*
-        * List used by channels to reference streams that are not yet globally
-        * visible.
-        */
-       struct cds_list_head send_node;
-       /* Pointer to associated channel. */
-       struct lttng_consumer_channel *chan;
-       /*
-        * Current trace chunk. Holds a reference to the trace chunk.
-        * `chunk` can be NULL when a stream is not associated to a chunk, e.g.
-        * when it was created in the context of a no-output session.
-        */
-       struct lttng_trace_chunk *trace_chunk;
-
-       /* Key by which the stream is indexed for 'node'. */
-       uint64_t key;
-       /*
-        * File descriptor of the data output file. This can be either a file or a
-        * socket fd for relayd streaming.
-        */
-       int out_fd; /* output file to write the data */
-       /* Write position in the output file descriptor */
-       off_t out_fd_offset;
-       /* Amount of bytes written to the output */
-       uint64_t output_written;
-       int shm_fd_is_copy;
-       int data_read;
-       int hangup_flush_done;
-
-       /*
-        * Whether the stream is in a "complete" state (e.g. it does not have a
-        * partially written sub-buffer.
-        *
-        * Initialized to "false" on stream creation (first packet is empty).
-        *
-        * The various transitions of the quiescent state are:
-        *     - On "start" tracing: set to false, since the stream is not
-        *       "complete".
-        *     - On "stop" tracing: if !quiescent -> flush FINAL (update
-        *       timestamp_end), and set to true; the stream has entered a
-        *       complete/quiescent state.
-        *     - On "destroy" or stream/application hang-up: if !quiescent ->
-        *       flush FINAL, and set to true.
-        *
-        * NOTE: Update and read are protected by the stream lock.
-        */
-       bool quiescent;
-
-       /*
-        * True if the sequence number is not available (lttng-modules < 2.8).
-        */
-       bool sequence_number_unavailable;
-
-       /*
-        * metadata_timer_lock protects flags waiting_on_metadata and
-        * missed_metadata_flush.
-        */
-       pthread_mutex_t metadata_timer_lock;
-       /*
-        * Flag set when awaiting metadata to be pushed. Used in the
-        * timer thread to skip waiting on the stream (and stream lock) to
-        * ensure we can proceed to flushing metadata in live mode.
-        */
-       bool waiting_on_metadata;
-       /* Raised when a timer misses a metadata flush. */
-       bool missed_metadata_flush;
-
-       enum lttng_event_output output;
-       /* Maximum subbuffer size (in bytes). */
-       unsigned long max_sb_size;
-
-       /*
-        * Still used by the kernel for MMAP output. For UST, the ustctl getter is
-        * used for the mmap base and offset.
-        */
-       void *mmap_base;
-       unsigned long mmap_len;
-
-       /* For UST */
-
-       int wait_fd;
-       /* Network sequence number. Indicating on which relayd socket it goes. */
-       uint64_t net_seq_idx;
-       /*
-        * Indicate if this stream was successfully sent to a relayd. This is set
-        * after the refcount of the relayd is incremented and is checked when the
-        * stream is closed before decrementing the refcount in order to avoid an
-        * unbalanced state.
-        */
-       unsigned int sent_to_relayd;
-
-       /* Identify if the stream is the metadata */
-       unsigned int metadata_flag;
-       /*
-        * Last known metadata version, reset the metadata file in case
-        * of change.
-        */
-       uint64_t metadata_version;
-       /* Used when the stream is set for network streaming */
-       uint64_t relayd_stream_id;
-       /*
-        * When sending a stream packet to a relayd, this number is used to track
-        * the packet sent by the consumer and seen by the relayd. When sending the
-        * data header to the relayd, this number is sent and if the transmission
-        * was successful, it is incremented.
-        *
-        * Even if the full data is not fully transmitted it won't matter since
-        * only two possible error can happen after that where either the relayd
-        * died or a read error is detected on the stream making this value useless
-        * after that.
-        *
-        * This value SHOULD be read/updated atomically or with the lock acquired.
-        */
-       uint64_t next_net_seq_num;
-       /*
-        * Lock to use the stream FDs since they are used between threads.
-        *
-        * This is nested INSIDE the consumer_data lock.
-        * This is nested INSIDE the channel lock.
-        * This is nested INSIDE the channel timer lock.
-        * This is nested OUTSIDE the metadata cache lock.
-        * This is nested OUTSIDE consumer_relayd_sock_pair lock.
-        */
-       pthread_mutex_t lock;
-       /* Tracing session id */
-       uint64_t session_id;
-       /*
-        * Indicates if the stream end point is still active or not (network
-        * streaming or local file system). The thread "owning" the stream is
-        * handling this status and can be notified of a state change through the
-        * consumer data appropriate pipe.
-        */
-       enum consumer_endpoint_status endpoint_status;
-       /* Stream name. Format is: <channel_name>_<cpu_number> */
-       char name[LTTNG_SYMBOL_NAME_LEN];
-       /* Internal state of libustctl. */
-       struct lttng_ust_ctl_consumer_stream *ustream;
-       /* On-disk circular buffer */
-       uint64_t tracefile_size_current;
-       uint64_t tracefile_count_current;
-       /*
-        * Monitor or not the streams of this channel meaning this indicates if the
-        * streams should be sent to the data/metadata thread or added to the no
-        * monitor list of the channel.
-        */
-       unsigned int monitor;
-       /*
-        * Indicate if the stream is globally visible meaning that it has been
-        * added to the multiple hash tables. If *not* set, NO lock should be
-        * acquired in the destroy path.
-        */
-       unsigned int globally_visible;
-       /*
-        * Pipe to wake up the metadata poll thread when the UST metadata
-        * cache is updated.
-        */
-       int ust_metadata_poll_pipe[2];
-       /*
-        * How much metadata was read from the metadata cache and sent
-        * to the channel.
-        */
-       uint64_t ust_metadata_pushed;
-       /*
-        * Copy of the last discarded event value to detect the overflow of
-        * the counter.
-        */
-       uint64_t last_discarded_events;
-       /* Copy of the sequence number of the last packet extracted. */
-       uint64_t last_sequence_number;
-       /*
-        * Index file object of the index file for this stream.
-        */
-       struct lttng_index_file *index_file;
-
-       /*
-        * Local pipe to extract data when using splice.
-        */
-       int splice_pipe[2];
-
-       /*
-        * Rendez-vous point between data and metadata stream in live mode.
-        */
-       pthread_cond_t metadata_rdv;
-       pthread_mutex_t metadata_rdv_lock;
-
-       /*
-        * rotate_position represents the packet sequence number of the last
-        * packet which belongs to the current trace chunk prior to the rotation.
-        * When that position is reached, this tracefile can be closed and a
-        * new one is created in channel_read_only_attributes.path.
-        */
-       uint64_t rotate_position;
-
-       /* Whether or not a packet was opened during the current trace chunk. */
-       bool opened_packet_in_current_trace_chunk;
-
-       /*
-        * Read-only copies of channel values. We cannot safely access the
-        * channel from a stream, so we need to have a local copy of these
-        * fields in the stream object. These fields should be removed from
-        * the stream objects when we introduce refcounting.
-        */
-       struct {
-               uint64_t tracefile_size;
-       } channel_read_only_attributes;
-
-       /*
-        * Flag to inform the data or metadata thread that a stream is
-        * ready to be rotated.
-        */
-       bool rotate_ready;
-
-       /* Indicate if the stream still has some data to be read. */
-       unsigned int has_data:1;
-       /*
-        * Inform the consumer or relay to reset the metadata
-        * file before writing in it (regeneration).
-        */
-       unsigned int reset_metadata_flag:1;
-       struct {
-               /*
-                * Invoked in the order of declaration.
-                * See callback type definitions.
-                */
-               lock_cb lock;
-               on_wake_up_cb on_wake_up;
-               get_next_subbuffer_cb get_next_subbuffer;
-               extract_subbuffer_info_cb extract_subbuffer_info;
-               pre_consume_subbuffer_cb pre_consume_subbuffer;
-               reset_metadata_cb reset_metadata;
-               consume_subbuffer_cb consume_subbuffer;
-               put_next_subbuffer_cb put_next_subbuffer;
-               struct lttng_dynamic_array post_consume_cbs;
-               send_live_beacon_cb send_live_beacon;
-               on_sleep_cb on_sleep;
-               unlock_cb unlock;
-               assert_locked_cb assert_locked;
-       } read_subbuffer_ops;
-       struct metadata_bucket *metadata_bucket;
-};
-
-/*
- * Internal representation of a relayd socket pair.
- */
-struct consumer_relayd_sock_pair {
-       /* Network sequence number. */
-       uint64_t net_seq_idx;
-       /* Number of stream associated with this relayd */
-       int refcount;
-
-       /*
-        * This flag indicates whether or not we should destroy this object. The
-        * destruction should ONLY occurs when this flag is set and the refcount is
-        * set to zero.
-        */
-       unsigned int destroy_flag;
-
-       /*
-        * Mutex protecting the control socket to avoid out of order packets
-        * between threads sending data to the relayd. Since metadata data is sent
-        * over that socket, at least two sendmsg() are needed (header + data)
-        * creating a race for packets to overlap between threads using it.
-        *
-        * This is nested INSIDE the consumer_data lock.
-        * This is nested INSIDE the stream lock.
-        */
-       pthread_mutex_t ctrl_sock_mutex;
-
-       /* Control socket. Command and metadata are passed over it */
-       struct lttcomm_relayd_sock control_sock;
-
-       /*
-        * We don't need a mutex at this point since we only splice or write single
-        * large chunk of data with a header appended at the begining. Moreover,
-        * this socket is for now only used in a single thread.
-        */
-       struct lttcomm_relayd_sock data_sock;
-       struct lttng_ht_node_u64 node;
-
-       /* Session id on both sides for the sockets. */
-       uint64_t relayd_session_id;
-       uint64_t sessiond_session_id;
-       struct lttng_consumer_local_data *ctx;
-};
-
-/*
- * UST consumer local data to the program. One or more instance per
- * process.
- */
-struct lttng_consumer_local_data {
-       /*
-        * Function to call when data is available on a buffer.
-        * Returns the number of bytes read, or negative error value.
-        */
-       ssize_t (*on_buffer_ready)(struct lttng_consumer_stream *stream,
-                       struct lttng_consumer_local_data *ctx,
-                       bool locked_by_caller);
-       /*
-        * function to call when we receive a new channel, it receives a
-        * newly allocated channel, depending on the return code of this
-        * function, the new channel will be handled by the application
-        * or the library.
-        *
-        * Returns:
-        *    > 0 (success, FD is kept by application)
-        *   == 0 (success, FD is left to library)
-        *    < 0 (error)
-        */
-       int (*on_recv_channel)(struct lttng_consumer_channel *channel);
-       /*
-        * function to call when we receive a new stream, it receives a
-        * newly allocated stream, depending on the return code of this
-        * function, the new stream will be handled by the application
-        * or the library.
-        *
-        * Returns:
-        *    > 0 (success, FD is kept by application)
-        *   == 0 (success, FD is left to library)
-        *    < 0 (error)
-        */
-       int (*on_recv_stream)(struct lttng_consumer_stream *stream);
-       /*
-        * function to call when a stream is getting updated by the session
-        * daemon, this function receives the sessiond key and the new
-        * state, depending on the return code of this function the
-        * update of state for the stream is handled by the application
-        * or the library.
-        *
-        * Returns:
-        *    > 0 (success, FD is kept by application)
-        *   == 0 (success, FD is left to library)
-        *    < 0 (error)
-        */
-       int (*on_update_stream)(uint64_t sessiond_key, uint32_t state);
-       enum lttng_consumer_type type;
-       /* socket to communicate errors with sessiond */
-       int consumer_error_socket;
-       /* socket to ask metadata to sessiond. */
-       int consumer_metadata_socket;
-       /*
-        * Protect consumer_metadata_socket.
-        *
-        * This is nested OUTSIDE the metadata cache lock.
-        */
-       pthread_mutex_t metadata_socket_lock;
-       /* socket to exchange commands with sessiond */
-       char *consumer_command_sock_path;
-       /* communication with splice */
-       int consumer_channel_pipe[2];
-       /* Data stream poll thread pipe. To transfer data stream to the thread */
-       struct lttng_pipe *consumer_data_pipe;
-
-       /*
-        * Data thread use that pipe to catch wakeup from read subbuffer that
-        * detects that there is still data to be read for the stream encountered.
-        * Before doing so, the stream is flagged to indicate that there is still
-        * data to be read.
-        *
-        * Both pipes (read/write) are owned and used inside the data thread.
-        */
-       struct lttng_pipe *consumer_wakeup_pipe;
-       /* Indicate if the wakeup thread has been notified. */
-       unsigned int has_wakeup:1;
-
-       /* to let the signal handler wake up the fd receiver thread */
-       int consumer_should_quit[2];
-       /* Metadata poll thread pipe. Transfer metadata stream to it */
-       struct lttng_pipe *consumer_metadata_pipe;
-       /*
-        * Pipe used by the channel monitoring timers to provide state samples
-        * to the session daemon (write-only).
-        */
-       int channel_monitor_pipe;
-       LTTNG_OPTIONAL(lttng_uuid) sessiond_uuid;
-};
-
-/*
- * Library-level data. One instance per process.
- */
-struct lttng_consumer_global_data {
-       /*
-        * At this time, this lock is used to ensure coherence between the count
-        * and number of element in the hash table. It's also a protection for
-        * concurrent read/write between threads.
-        *
-        * This is nested OUTSIDE the stream lock.
-        * This is nested OUTSIDE the consumer_relayd_sock_pair lock.
-        */
-       pthread_mutex_t lock {};
-
-       /*
-        * Number of streams in the data stream hash table declared outside.
-        * Protected by consumer_data.lock.
-        */
-       int stream_count = 0;
-
-       /* Channel hash table protected by consumer_data.lock. */
-       struct lttng_ht *channel_ht = nullptr;
-       /* Channel hash table indexed by session id. */
-       struct lttng_ht *channels_by_session_id_ht = nullptr;
-       /*
-        * Flag specifying if the local array of FDs needs update in the
-        * poll function. Protected by consumer_data.lock.
-        */
-       unsigned int need_update = 1;
-       enum lttng_consumer_type type = LTTNG_CONSUMER_UNKNOWN;
-
-       /*
-        * Relayd socket(s) hashtable indexed by network sequence number. Each
-        * stream has an index which associate the right relayd socket to use.
-        */
-       struct lttng_ht *relayd_ht = nullptr;
-
-       /*
-        * This hash table contains all streams (metadata and data) indexed by
-        * session id. In other words, the ht is indexed by session id and each
-        * bucket contains the list of associated streams.
-        *
-        * This HT uses the "node_session_id" of the consumer stream.
-        */
-       struct lttng_ht *stream_list_ht = nullptr;
-
-       /*
-        * This HT uses the "node_channel_id" of the consumer stream.
-        */
-       struct lttng_ht *stream_per_chan_id_ht = nullptr;
-
-       /*
-        * Trace chunk registry indexed by (session_id, chunk_id).
-        */
-       struct lttng_trace_chunk_registry *chunk_registry = nullptr;
-};
-
-/*
- * Set to nonzero when the consumer is exiting. Updated by signal
- * handler and thread exit, read by threads.
- */
-extern int consumer_quit;
-
-/*
- * Set to nonzero when the consumer is exiting. Updated by signal
- * handler and thread exit, read by threads.
- */
-extern int consumer_quit;
-
-/*
- * Flag used to temporarily pause data consumption from testpoints.
- *
- * This variable is dlsym-ed from a test, so needs to be exported.
- */
-LTTNG_EXPORT extern int data_consumption_paused;
-
-/* Return a human-readable consumer type string that is suitable for logging. */
-static inline
-const char *lttng_consumer_type_str(enum lttng_consumer_type type)
-{
-       switch (type) {
-       case LTTNG_CONSUMER_UNKNOWN:
-               return "unknown";
-       case LTTNG_CONSUMER_KERNEL:
-               return "kernel";
-       case LTTNG_CONSUMER32_UST:
-               return "32-bit user space";
-       case LTTNG_CONSUMER64_UST:
-               return "64-bit user space";
-       default:
-               abort();
-       }
-}
-
-/*
- * Init consumer data structures.
- */
-int lttng_consumer_init(void);
-
-/*
- * Set the error socket for communication with a session daemon.
- */
-void lttng_consumer_set_error_sock(struct lttng_consumer_local_data *ctx,
-               int sock);
-
-/*
- * Set the command socket path for communication with a session daemon.
- */
-void lttng_consumer_set_command_sock_path(
-               struct lttng_consumer_local_data *ctx, char *sock);
-
-/*
- * Send return code to session daemon.
- *
- * Returns the return code of sendmsg : the number of bytes transmitted or -1
- * on error.
- */
-int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx, int cmd);
-
-/*
- * Called from signal handler to ensure a clean exit.
- */
-void lttng_consumer_should_exit(struct lttng_consumer_local_data *ctx);
-
-/*
- * Cleanup the daemon's socket on exit.
- */
-void lttng_consumer_cleanup(void);
-
-/*
- * Poll on the should_quit pipe and the command socket return -1 on error and
- * should exit, 0 if data is available on the command socket
- */
-int lttng_consumer_poll_socket(struct pollfd *kconsumer_sockpoll);
-
-/*
- * Copy the fields from the channel that need to be accessed (read-only)
- * directly from the stream.
- */
-void consumer_stream_update_channel_attributes(
-               struct lttng_consumer_stream *stream,
-               struct lttng_consumer_channel *channel);
-
-struct lttng_consumer_stream *consumer_allocate_stream(
-               struct lttng_consumer_channel *channel,
-               uint64_t channel_key,
-               uint64_t stream_key,
-               const char *channel_name,
-               uint64_t relayd_id,
-               uint64_t session_id,
-               struct lttng_trace_chunk *trace_chunk,
-               int cpu,
-               int *alloc_ret,
-               enum consumer_channel_type type,
-               unsigned int monitor);
-struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key,
-               uint64_t session_id,
-               const uint64_t *chunk_id,
-               const char *pathname,
-               const char *name,
-               uint64_t relayd_id,
-               enum lttng_event_output output,
-               uint64_t tracefile_size,
-               uint64_t tracefile_count,
-               uint64_t session_id_per_pid,
-               unsigned int monitor,
-               unsigned int live_timer_interval,
-               bool is_in_live_session,
-               const char *root_shm_path,
-               const char *shm_path);
-void consumer_del_stream(struct lttng_consumer_stream *stream,
-               struct lttng_ht *ht);
-void consumer_del_metadata_stream(struct lttng_consumer_stream *stream,
-               struct lttng_ht *ht);
-int consumer_add_channel(struct lttng_consumer_channel *channel,
-               struct lttng_consumer_local_data *ctx);
-void consumer_del_channel(struct lttng_consumer_channel *channel);
-
-/* lttng-relayd consumer command */
-struct consumer_relayd_sock_pair *consumer_find_relayd(uint64_t key);
-int consumer_send_relayd_stream(struct lttng_consumer_stream *stream, char *path);
-int consumer_send_relayd_streams_sent(uint64_t net_seq_idx);
-void close_relayd_stream(struct lttng_consumer_stream *stream);
-struct lttng_consumer_channel *consumer_find_channel(uint64_t key);
-int consumer_handle_stream_before_relayd(struct lttng_consumer_stream *stream,
-               size_t data_size);
-void consumer_steal_stream_key(int key, struct lttng_ht *ht);
-
-struct lttng_consumer_local_data *lttng_consumer_create(
-               enum lttng_consumer_type type,
-               ssize_t (*buffer_ready)(struct lttng_consumer_stream *stream,
-                       struct lttng_consumer_local_data *ctx,
-                       bool locked_by_caller),
-               int (*recv_channel)(struct lttng_consumer_channel *channel),
-               int (*recv_stream)(struct lttng_consumer_stream *stream),
-               int (*update_stream)(uint64_t sessiond_key, uint32_t state));
-void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx);
-ssize_t lttng_consumer_on_read_subbuffer_mmap(
-               struct lttng_consumer_stream *stream,
-               const struct lttng_buffer_view *buffer,
-               unsigned long padding);
-ssize_t lttng_consumer_on_read_subbuffer_splice(
-               struct lttng_consumer_local_data *ctx,
-               struct lttng_consumer_stream *stream, unsigned long len,
-               unsigned long padding);
-int lttng_consumer_sample_snapshot_positions(struct lttng_consumer_stream *stream);
-int lttng_consumer_take_snapshot(struct lttng_consumer_stream *stream);
-int lttng_consumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
-               unsigned long *pos);
-int lttng_consumer_get_consumed_snapshot(struct lttng_consumer_stream *stream,
-               unsigned long *pos);
-int lttng_ustconsumer_get_wakeup_fd(struct lttng_consumer_stream *stream);
-int lttng_ustconsumer_close_wakeup_fd(struct lttng_consumer_stream *stream);
-void *consumer_thread_metadata_poll(void *data);
-void *consumer_thread_data_poll(void *data);
-void *consumer_thread_sessiond_poll(void *data);
-void *consumer_thread_channel_poll(void *data);
-int lttng_consumer_recv_cmd(struct lttng_consumer_local_data *ctx,
-               int sock, struct pollfd *consumer_sockpoll);
-
-ssize_t lttng_consumer_read_subbuffer(struct lttng_consumer_stream *stream,
-               struct lttng_consumer_local_data *ctx,
-               bool locked_by_caller);
-int lttng_consumer_on_recv_stream(struct lttng_consumer_stream *stream);
-void consumer_add_relayd_socket(uint64_t net_seq_idx,
-               int sock_type,
-               struct lttng_consumer_local_data *ctx,
-               int sock,
-               struct pollfd *consumer_sockpoll,
-               uint64_t sessiond_id,
-               uint64_t relayd_session_id,
-               uint32_t relayd_version_major,
-               uint32_t relayd_version_minor,
-               enum lttcomm_sock_proto relayd_socket_protocol);
-void consumer_flag_relayd_for_destroy(
-               struct consumer_relayd_sock_pair *relayd);
-int consumer_data_pending(uint64_t id);
-int consumer_send_status_msg(int sock, int ret_code);
-int consumer_send_status_channel(int sock,
-               struct lttng_consumer_channel *channel);
-void notify_thread_del_channel(struct lttng_consumer_local_data *ctx,
-               uint64_t key);
-void consumer_destroy_relayd(struct consumer_relayd_sock_pair *relayd);
-unsigned long consumer_get_consume_start_pos(unsigned long consumed_pos,
-               unsigned long produced_pos, uint64_t nb_packets_per_stream,
-               uint64_t max_sb_size);
-void consumer_add_data_stream(struct lttng_consumer_stream *stream);
-void consumer_del_stream_for_data(struct lttng_consumer_stream *stream);
-void consumer_add_metadata_stream(struct lttng_consumer_stream *stream);
-void consumer_del_stream_for_metadata(struct lttng_consumer_stream *stream);
-int consumer_create_index_file(struct lttng_consumer_stream *stream);
-int lttng_consumer_rotate_channel(struct lttng_consumer_channel *channel,
-               uint64_t key, uint64_t relayd_id);
-int lttng_consumer_stream_is_rotate_ready(struct lttng_consumer_stream *stream);
-int lttng_consumer_rotate_stream(struct lttng_consumer_stream *stream);
-int lttng_consumer_rotate_ready_streams(struct lttng_consumer_channel *channel,
-               uint64_t key);
-void lttng_consumer_reset_stream_rotate_state(struct lttng_consumer_stream *stream);
-enum lttcomm_return_code lttng_consumer_create_trace_chunk(
-               const uint64_t *relayd_id, uint64_t session_id,
-               uint64_t chunk_id,
-               time_t chunk_creation_timestamp,
-               const char *chunk_override_name,
-               const struct lttng_credentials *credentials,
-               struct lttng_directory_handle *chunk_directory_handle);
-enum lttcomm_return_code lttng_consumer_close_trace_chunk(
-               const uint64_t *relayd_id, uint64_t session_id,
-               uint64_t chunk_id, time_t chunk_close_timestamp,
-               const enum lttng_trace_chunk_command_type *close_command,
-               char *path);
-enum lttcomm_return_code lttng_consumer_trace_chunk_exists(
-               const uint64_t *relayd_id, uint64_t session_id,
-               uint64_t chunk_id);
-void lttng_consumer_cleanup_relayd(struct consumer_relayd_sock_pair *relayd);
-enum lttcomm_return_code lttng_consumer_init_command(
-               struct lttng_consumer_local_data *ctx,
-               const lttng_uuid sessiond_uuid);
-int lttng_consumer_clear_channel(struct lttng_consumer_channel *channel);
-enum lttcomm_return_code lttng_consumer_open_channel_packets(
-               struct lttng_consumer_channel *channel);
-int consumer_metadata_wakeup_pipe(const struct lttng_consumer_channel *channel);
-void lttng_consumer_sigbus_handle(void *addr);
-
-#endif /* LIB_CONSUMER_H */
diff --git a/src/common/consumer/consumer.hpp b/src/common/consumer/consumer.hpp
new file mode 100644 (file)
index 0000000..4bcfe5d
--- /dev/null
@@ -0,0 +1,1085 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LIB_CONSUMER_H
+#define LIB_CONSUMER_H
+
+#include <limits.h>
+#include <poll.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <urcu/list.h>
+
+#include <lttng/lttng.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/compat/fcntl.hpp>
+#include <common/uuid.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/pipe.hpp>
+#include <common/index/ctf-index.hpp>
+#include <common/trace-chunk-registry.hpp>
+#include <common/credentials.hpp>
+#include <common/buffer-view.hpp>
+#include <common/dynamic-array.hpp>
+
+struct lttng_consumer_local_data;
+
+/* Commands for consumer */
+enum lttng_consumer_command {
+       LTTNG_CONSUMER_ADD_CHANNEL,
+       LTTNG_CONSUMER_ADD_STREAM,
+       /* pause, delete, active depending on fd state */
+       LTTNG_CONSUMER_UPDATE_STREAM,
+       /* inform the consumer to quit when all fd has hang up */
+       LTTNG_CONSUMER_STOP,    /* deprecated */
+       LTTNG_CONSUMER_ADD_RELAYD_SOCKET,
+       /* Inform the consumer to kill a specific relayd connection */
+       LTTNG_CONSUMER_DESTROY_RELAYD,
+       /* Return to the sessiond if there is data pending for a session */
+       LTTNG_CONSUMER_DATA_PENDING,
+       /* Consumer creates a channel and returns it to sessiond. */
+       LTTNG_CONSUMER_ASK_CHANNEL_CREATION,
+       LTTNG_CONSUMER_GET_CHANNEL,
+       LTTNG_CONSUMER_DESTROY_CHANNEL,
+       LTTNG_CONSUMER_PUSH_METADATA,
+       LTTNG_CONSUMER_CLOSE_METADATA,
+       LTTNG_CONSUMER_SETUP_METADATA,
+       LTTNG_CONSUMER_FLUSH_CHANNEL,
+       LTTNG_CONSUMER_SNAPSHOT_CHANNEL,
+       LTTNG_CONSUMER_SNAPSHOT_METADATA,
+       LTTNG_CONSUMER_STREAMS_SENT,
+       LTTNG_CONSUMER_DISCARDED_EVENTS,
+       LTTNG_CONSUMER_LOST_PACKETS,
+       LTTNG_CONSUMER_CLEAR_QUIESCENT_CHANNEL,
+       LTTNG_CONSUMER_SET_CHANNEL_MONITOR_PIPE,
+       LTTNG_CONSUMER_ROTATE_CHANNEL,
+       LTTNG_CONSUMER_INIT,
+       LTTNG_CONSUMER_CREATE_TRACE_CHUNK,
+       LTTNG_CONSUMER_CLOSE_TRACE_CHUNK,
+       LTTNG_CONSUMER_TRACE_CHUNK_EXISTS,
+       LTTNG_CONSUMER_CLEAR_CHANNEL,
+       LTTNG_CONSUMER_OPEN_CHANNEL_PACKETS,
+};
+
+enum lttng_consumer_type {
+       LTTNG_CONSUMER_UNKNOWN = 0,
+       LTTNG_CONSUMER_KERNEL,
+       LTTNG_CONSUMER64_UST,
+       LTTNG_CONSUMER32_UST,
+};
+
+enum consumer_endpoint_status {
+       CONSUMER_ENDPOINT_ACTIVE,
+       CONSUMER_ENDPOINT_INACTIVE,
+};
+
+enum consumer_channel_output {
+       CONSUMER_CHANNEL_MMAP   = 0,
+       CONSUMER_CHANNEL_SPLICE = 1,
+};
+
+enum consumer_channel_type {
+       CONSUMER_CHANNEL_TYPE_METADATA  = 0,
+       CONSUMER_CHANNEL_TYPE_DATA      = 1,
+};
+
+enum sync_metadata_status {
+       SYNC_METADATA_STATUS_NEW_DATA,
+       SYNC_METADATA_STATUS_NO_DATA,
+       SYNC_METADATA_STATUS_ERROR,
+};
+
+extern struct lttng_consumer_global_data the_consumer_data;
+
+struct stream_list {
+       struct cds_list_head head;
+       unsigned int count;
+};
+
+/* Stub. */
+struct consumer_metadata_cache;
+
+struct lttng_consumer_channel {
+       /* Is the channel published in the channel hash tables? */
+       bool is_published;
+       /*
+        * Was the channel deleted (logically) and waiting to be reclaimed?
+        * If this flag is set, no modification that is not cleaned-up by the
+        * RCU reclamation callback should be made
+        */
+       bool is_deleted;
+       /* HT node used for consumer_data.channel_ht */
+       struct lttng_ht_node_u64 node;
+       /* HT node used for consumer_data.channels_by_session_id_ht */
+       struct lttng_ht_node_u64 channels_by_session_id_ht_node;
+       /* Indexed key. Incremented value in the consumer. */
+       uint64_t key;
+       /* Number of streams referencing this channel */
+       int refcount;
+       /* Tracing session id on the session daemon side. */
+       uint64_t session_id;
+       /* Current trace chunk of the session in which this channel exists. */
+       struct lttng_trace_chunk *trace_chunk;
+       /*
+        * Session id when requesting metadata to the session daemon for
+        * a session with per-PID buffers.
+        */
+       uint64_t session_id_per_pid;
+       /*
+        * In the case of local streams, this field contains the channel's
+        * output path; a path relative to the session's output path.
+        *   e.g. ust/uid/1000/64-bit
+        *
+        * In the case of remote streams, the contents of this field depends
+        * on the version of the relay daemon peer. For 2.11+ peers, the
+        * contents are the same as in the local case. However, for legacy
+        * peers, this contains a path of the form:
+        *   /hostname/session_path/ust/uid/1000/64-bit
+        */
+       char pathname[PATH_MAX];
+       /* Channel name. */
+       char name[LTTNG_SYMBOL_NAME_LEN];
+       /* Relayd id of the channel. -1ULL if it does not apply. */
+       uint64_t relayd_id;
+       /*
+        * Number of streams NOT initialized yet. This is used in order to not
+        * delete this channel if streams are getting initialized.
+        */
+       unsigned int nb_init_stream_left;
+       /* Output type (mmap or splice). */
+       enum consumer_channel_output output;
+       /* Channel type for stream */
+       enum consumer_channel_type type;
+
+       /* For UST */
+       uid_t ust_app_uid;      /* Application UID. */
+       struct lttng_ust_ctl_consumer_channel *uchan;
+       unsigned char uuid[LTTNG_UUID_STR_LEN];
+       /*
+        * Temporary stream list used to store the streams once created and waiting
+        * to be sent to the session daemon by receiving the
+        * LTTNG_CONSUMER_GET_CHANNEL.
+        */
+       struct stream_list streams;
+
+       /*
+        * Set if the channel is metadata. We keep a reference to the stream
+        * because we have to flush data once pushed by the session daemon. For a
+        * regular channel, this is always set to NULL.
+        */
+       struct lttng_consumer_stream *metadata_stream;
+
+       /* for UST */
+       int wait_fd;
+       /* Node within channel thread ht */
+       struct lttng_ht_node_u64 wait_fd_node;
+
+       /* Metadata cache is metadata channel */
+       struct consumer_metadata_cache *metadata_cache;
+
+       /* For UST metadata periodical flush */
+       int switch_timer_enabled;
+       timer_t switch_timer;
+       int switch_timer_error;
+
+       /* For the live mode */
+       int live_timer_enabled;
+       timer_t live_timer;
+       int live_timer_error;
+       /* Channel is part of a live session ? */
+       bool is_live;
+
+       /* For channel monitoring timer. */
+       int monitor_timer_enabled;
+       timer_t monitor_timer;
+
+       /* On-disk circular buffer */
+       uint64_t tracefile_size;
+       uint64_t tracefile_count;
+       /*
+        * Monitor or not the streams of this channel meaning this indicates if the
+        * streams should be sent to the data/metadata thread or added to the no
+        * monitor list of the channel.
+        */
+       unsigned int monitor;
+
+       /*
+        * Channel lock.
+        *
+        * This lock protects against concurrent update of channel.
+        *
+        * This is nested INSIDE the consumer data lock.
+        * This is nested OUTSIDE the channel timer lock.
+        * This is nested OUTSIDE the metadata cache lock.
+        * This is nested OUTSIDE stream lock.
+        * This is nested OUTSIDE consumer_relayd_sock_pair lock.
+        */
+       pthread_mutex_t lock;
+
+       /*
+        * Channel teardown lock.
+        *
+        * This lock protect against teardown of channel. It is _never_
+        * taken by the timer handler.
+        *
+        * This is nested INSIDE the consumer data lock.
+        * This is nested INSIDE the channel lock.
+        * This is nested OUTSIDE the metadata cache lock.
+        * This is nested OUTSIDE stream lock.
+        * This is nested OUTSIDE consumer_relayd_sock_pair lock.
+        */
+       pthread_mutex_t timer_lock;
+
+       /* Timer value in usec for live streaming. */
+       unsigned int live_timer_interval;
+
+       int *stream_fds;
+       int nr_stream_fds;
+       char root_shm_path[PATH_MAX];
+       char shm_path[PATH_MAX];
+       /* Only set for UST channels. */
+       LTTNG_OPTIONAL(struct lttng_credentials) buffer_credentials;
+       /* Total number of discarded events for that channel. */
+       uint64_t discarded_events;
+       /* Total number of missed packets due to overwriting (overwrite). */
+       uint64_t lost_packets;
+
+       bool streams_sent_to_relayd;
+};
+
+struct stream_subbuffer {
+       union {
+               /*
+                * CONSUMER_CHANNEL_SPLICE
+                * No ownership assumed.
+                */
+               int fd;
+               /* CONSUMER_CHANNEL_MMAP */
+               struct lttng_buffer_view buffer;
+       } buffer;
+       union {
+               /*
+                * Common members are fine to access through either
+                * union entries (as per C11, Common Initial Sequence).
+                */
+               struct {
+                       unsigned long subbuf_size;
+                       unsigned long padded_subbuf_size;
+                       uint64_t version;
+                       /*
+                        * Left unset when unsupported.
+                        *
+                        * Indicates that this is the last sub-buffer of
+                        * a series of sub-buffer that makes-up a coherent
+                        * (parseable) unit of metadata.
+                        */
+                       LTTNG_OPTIONAL(bool) coherent;
+               } metadata;
+               struct {
+                       unsigned long subbuf_size;
+                       unsigned long padded_subbuf_size;
+                       uint64_t packet_size;
+                       uint64_t content_size;
+                       uint64_t timestamp_begin;
+                       uint64_t timestamp_end;
+                       uint64_t events_discarded;
+                       /* Left unset when unsupported. */
+                       LTTNG_OPTIONAL(uint64_t) sequence_number;
+                       uint64_t stream_id;
+                       /* Left unset when unsupported. */
+                       LTTNG_OPTIONAL(uint64_t) stream_instance_id;
+               } data;
+       } info;
+};
+
+enum get_next_subbuffer_status {
+       GET_NEXT_SUBBUFFER_STATUS_OK,
+       GET_NEXT_SUBBUFFER_STATUS_NO_DATA,
+       GET_NEXT_SUBBUFFER_STATUS_ERROR,
+};
+
+/*
+ * Perform any operation required to acknowledge
+ * the wake-up of a consumer stream (e.g. consume a byte on a wake-up pipe).
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*on_wake_up_cb)(struct lttng_consumer_stream *);
+
+/*
+ * Perform any operation required before a consumer stream is put
+ * to sleep before awaiting a data availability notification.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*on_sleep_cb)(struct lttng_consumer_stream *,
+               struct lttng_consumer_local_data *);
+
+/*
+ * Acquire the subbuffer at the current 'consumed' position.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef enum get_next_subbuffer_status (*get_next_subbuffer_cb)(
+               struct lttng_consumer_stream *, struct stream_subbuffer *);
+
+/*
+ * Populate the stream_subbuffer's info member. The info to populate
+ * depends on the type (metadata/data) of the stream.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*extract_subbuffer_info_cb)(
+               struct lttng_consumer_stream *, struct stream_subbuffer *);
+
+/*
+ * Invoked after a subbuffer's info has been filled.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*pre_consume_subbuffer_cb)(struct lttng_consumer_stream *,
+               const struct stream_subbuffer *);
+
+/*
+ * Consume subbuffer contents.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef ssize_t (*consume_subbuffer_cb)(struct lttng_consumer_local_data *,
+               struct lttng_consumer_stream *,
+               const struct stream_subbuffer *);
+
+/*
+ * Release the current subbuffer and advance the 'consumed' position by
+ * one subbuffer.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*put_next_subbuffer_cb)(struct lttng_consumer_stream *,
+               struct stream_subbuffer *);
+
+/*
+ * Invoked after consuming a subbuffer.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*post_consume_cb)(struct lttng_consumer_stream *,
+               const struct stream_subbuffer *,
+               struct lttng_consumer_local_data *);
+
+/*
+ * Send a live beacon if no data is available.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*send_live_beacon_cb)(struct lttng_consumer_stream *);
+
+/*
+ * Lock the stream and channel locks and any other stream-type specific
+ * lock that need to be acquired during the processing of an
+ * availability notification.
+ */
+typedef void (*lock_cb)(struct lttng_consumer_stream *);
+
+/*
+ * Unlock the stream and channel locks and any other stream-type specific
+ * lock before sleeping until the next availability notification.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef void (*unlock_cb)(struct lttng_consumer_stream *);
+
+/*
+ * Assert that the stream and channel lock and any other stream type specific
+ * lock that need to be acquired during the processing of a read_subbuffer
+ * operation is acquired.
+ */
+typedef void (*assert_locked_cb)(struct lttng_consumer_stream *);
+
+/*
+ * Invoked when a subbuffer's metadata version does not match the last
+ * known metadata version.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef void (*reset_metadata_cb)(struct lttng_consumer_stream *);
+
+/*
+ * Internal representation of the streams, sessiond_key is used to identify
+ * uniquely a stream.
+ */
+struct lttng_consumer_stream {
+       /* HT node used by the data_ht and metadata_ht */
+       struct lttng_ht_node_u64 node;
+       /* stream indexed per channel key node */
+       struct lttng_ht_node_u64 node_channel_id;
+       /* HT node used in consumer_data.stream_list_ht */
+       struct lttng_ht_node_u64 node_session_id;
+       /*
+        * List used by channels to reference streams that are not yet globally
+        * visible.
+        */
+       struct cds_list_head send_node;
+       /* Pointer to associated channel. */
+       struct lttng_consumer_channel *chan;
+       /*
+        * Current trace chunk. Holds a reference to the trace chunk.
+        * `chunk` can be NULL when a stream is not associated to a chunk, e.g.
+        * when it was created in the context of a no-output session.
+        */
+       struct lttng_trace_chunk *trace_chunk;
+
+       /* Key by which the stream is indexed for 'node'. */
+       uint64_t key;
+       /*
+        * File descriptor of the data output file. This can be either a file or a
+        * socket fd for relayd streaming.
+        */
+       int out_fd; /* output file to write the data */
+       /* Write position in the output file descriptor */
+       off_t out_fd_offset;
+       /* Amount of bytes written to the output */
+       uint64_t output_written;
+       int shm_fd_is_copy;
+       int data_read;
+       int hangup_flush_done;
+
+       /*
+        * Whether the stream is in a "complete" state (e.g. it does not have a
+        * partially written sub-buffer.
+        *
+        * Initialized to "false" on stream creation (first packet is empty).
+        *
+        * The various transitions of the quiescent state are:
+        *     - On "start" tracing: set to false, since the stream is not
+        *       "complete".
+        *     - On "stop" tracing: if !quiescent -> flush FINAL (update
+        *       timestamp_end), and set to true; the stream has entered a
+        *       complete/quiescent state.
+        *     - On "destroy" or stream/application hang-up: if !quiescent ->
+        *       flush FINAL, and set to true.
+        *
+        * NOTE: Update and read are protected by the stream lock.
+        */
+       bool quiescent;
+
+       /*
+        * True if the sequence number is not available (lttng-modules < 2.8).
+        */
+       bool sequence_number_unavailable;
+
+       /*
+        * metadata_timer_lock protects flags waiting_on_metadata and
+        * missed_metadata_flush.
+        */
+       pthread_mutex_t metadata_timer_lock;
+       /*
+        * Flag set when awaiting metadata to be pushed. Used in the
+        * timer thread to skip waiting on the stream (and stream lock) to
+        * ensure we can proceed to flushing metadata in live mode.
+        */
+       bool waiting_on_metadata;
+       /* Raised when a timer misses a metadata flush. */
+       bool missed_metadata_flush;
+
+       enum lttng_event_output output;
+       /* Maximum subbuffer size (in bytes). */
+       unsigned long max_sb_size;
+
+       /*
+        * Still used by the kernel for MMAP output. For UST, the ustctl getter is
+        * used for the mmap base and offset.
+        */
+       void *mmap_base;
+       unsigned long mmap_len;
+
+       /* For UST */
+
+       int wait_fd;
+       /* Network sequence number. Indicating on which relayd socket it goes. */
+       uint64_t net_seq_idx;
+       /*
+        * Indicate if this stream was successfully sent to a relayd. This is set
+        * after the refcount of the relayd is incremented and is checked when the
+        * stream is closed before decrementing the refcount in order to avoid an
+        * unbalanced state.
+        */
+       unsigned int sent_to_relayd;
+
+       /* Identify if the stream is the metadata */
+       unsigned int metadata_flag;
+       /*
+        * Last known metadata version, reset the metadata file in case
+        * of change.
+        */
+       uint64_t metadata_version;
+       /* Used when the stream is set for network streaming */
+       uint64_t relayd_stream_id;
+       /*
+        * When sending a stream packet to a relayd, this number is used to track
+        * the packet sent by the consumer and seen by the relayd. When sending the
+        * data header to the relayd, this number is sent and if the transmission
+        * was successful, it is incremented.
+        *
+        * Even if the full data is not fully transmitted it won't matter since
+        * only two possible error can happen after that where either the relayd
+        * died or a read error is detected on the stream making this value useless
+        * after that.
+        *
+        * This value SHOULD be read/updated atomically or with the lock acquired.
+        */
+       uint64_t next_net_seq_num;
+       /*
+        * Lock to use the stream FDs since they are used between threads.
+        *
+        * This is nested INSIDE the consumer_data lock.
+        * This is nested INSIDE the channel lock.
+        * This is nested INSIDE the channel timer lock.
+        * This is nested OUTSIDE the metadata cache lock.
+        * This is nested OUTSIDE consumer_relayd_sock_pair lock.
+        */
+       pthread_mutex_t lock;
+       /* Tracing session id */
+       uint64_t session_id;
+       /*
+        * Indicates if the stream end point is still active or not (network
+        * streaming or local file system). The thread "owning" the stream is
+        * handling this status and can be notified of a state change through the
+        * consumer data appropriate pipe.
+        */
+       enum consumer_endpoint_status endpoint_status;
+       /* Stream name. Format is: <channel_name>_<cpu_number> */
+       char name[LTTNG_SYMBOL_NAME_LEN];
+       /* Internal state of libustctl. */
+       struct lttng_ust_ctl_consumer_stream *ustream;
+       /* On-disk circular buffer */
+       uint64_t tracefile_size_current;
+       uint64_t tracefile_count_current;
+       /*
+        * Monitor or not the streams of this channel meaning this indicates if the
+        * streams should be sent to the data/metadata thread or added to the no
+        * monitor list of the channel.
+        */
+       unsigned int monitor;
+       /*
+        * Indicate if the stream is globally visible meaning that it has been
+        * added to the multiple hash tables. If *not* set, NO lock should be
+        * acquired in the destroy path.
+        */
+       unsigned int globally_visible;
+       /*
+        * Pipe to wake up the metadata poll thread when the UST metadata
+        * cache is updated.
+        */
+       int ust_metadata_poll_pipe[2];
+       /*
+        * How much metadata was read from the metadata cache and sent
+        * to the channel.
+        */
+       uint64_t ust_metadata_pushed;
+       /*
+        * Copy of the last discarded event value to detect the overflow of
+        * the counter.
+        */
+       uint64_t last_discarded_events;
+       /* Copy of the sequence number of the last packet extracted. */
+       uint64_t last_sequence_number;
+       /*
+        * Index file object of the index file for this stream.
+        */
+       struct lttng_index_file *index_file;
+
+       /*
+        * Local pipe to extract data when using splice.
+        */
+       int splice_pipe[2];
+
+       /*
+        * Rendez-vous point between data and metadata stream in live mode.
+        */
+       pthread_cond_t metadata_rdv;
+       pthread_mutex_t metadata_rdv_lock;
+
+       /*
+        * rotate_position represents the packet sequence number of the last
+        * packet which belongs to the current trace chunk prior to the rotation.
+        * When that position is reached, this tracefile can be closed and a
+        * new one is created in channel_read_only_attributes.path.
+        */
+       uint64_t rotate_position;
+
+       /* Whether or not a packet was opened during the current trace chunk. */
+       bool opened_packet_in_current_trace_chunk;
+
+       /*
+        * Read-only copies of channel values. We cannot safely access the
+        * channel from a stream, so we need to have a local copy of these
+        * fields in the stream object. These fields should be removed from
+        * the stream objects when we introduce refcounting.
+        */
+       struct {
+               uint64_t tracefile_size;
+       } channel_read_only_attributes;
+
+       /*
+        * Flag to inform the data or metadata thread that a stream is
+        * ready to be rotated.
+        */
+       bool rotate_ready;
+
+       /* Indicate if the stream still has some data to be read. */
+       unsigned int has_data:1;
+       /*
+        * Inform the consumer or relay to reset the metadata
+        * file before writing in it (regeneration).
+        */
+       unsigned int reset_metadata_flag:1;
+       struct {
+               /*
+                * Invoked in the order of declaration.
+                * See callback type definitions.
+                */
+               lock_cb lock;
+               on_wake_up_cb on_wake_up;
+               get_next_subbuffer_cb get_next_subbuffer;
+               extract_subbuffer_info_cb extract_subbuffer_info;
+               pre_consume_subbuffer_cb pre_consume_subbuffer;
+               reset_metadata_cb reset_metadata;
+               consume_subbuffer_cb consume_subbuffer;
+               put_next_subbuffer_cb put_next_subbuffer;
+               struct lttng_dynamic_array post_consume_cbs;
+               send_live_beacon_cb send_live_beacon;
+               on_sleep_cb on_sleep;
+               unlock_cb unlock;
+               assert_locked_cb assert_locked;
+       } read_subbuffer_ops;
+       struct metadata_bucket *metadata_bucket;
+};
+
+/*
+ * Internal representation of a relayd socket pair.
+ */
+struct consumer_relayd_sock_pair {
+       /* Network sequence number. */
+       uint64_t net_seq_idx;
+       /* Number of stream associated with this relayd */
+       int refcount;
+
+       /*
+        * This flag indicates whether or not we should destroy this object. The
+        * destruction should ONLY occurs when this flag is set and the refcount is
+        * set to zero.
+        */
+       unsigned int destroy_flag;
+
+       /*
+        * Mutex protecting the control socket to avoid out of order packets
+        * between threads sending data to the relayd. Since metadata data is sent
+        * over that socket, at least two sendmsg() are needed (header + data)
+        * creating a race for packets to overlap between threads using it.
+        *
+        * This is nested INSIDE the consumer_data lock.
+        * This is nested INSIDE the stream lock.
+        */
+       pthread_mutex_t ctrl_sock_mutex;
+
+       /* Control socket. Command and metadata are passed over it */
+       struct lttcomm_relayd_sock control_sock;
+
+       /*
+        * We don't need a mutex at this point since we only splice or write single
+        * large chunk of data with a header appended at the begining. Moreover,
+        * this socket is for now only used in a single thread.
+        */
+       struct lttcomm_relayd_sock data_sock;
+       struct lttng_ht_node_u64 node;
+
+       /* Session id on both sides for the sockets. */
+       uint64_t relayd_session_id;
+       uint64_t sessiond_session_id;
+       struct lttng_consumer_local_data *ctx;
+};
+
+/*
+ * UST consumer local data to the program. One or more instance per
+ * process.
+ */
+struct lttng_consumer_local_data {
+       /*
+        * Function to call when data is available on a buffer.
+        * Returns the number of bytes read, or negative error value.
+        */
+       ssize_t (*on_buffer_ready)(struct lttng_consumer_stream *stream,
+                       struct lttng_consumer_local_data *ctx,
+                       bool locked_by_caller);
+       /*
+        * function to call when we receive a new channel, it receives a
+        * newly allocated channel, depending on the return code of this
+        * function, the new channel will be handled by the application
+        * or the library.
+        *
+        * Returns:
+        *    > 0 (success, FD is kept by application)
+        *   == 0 (success, FD is left to library)
+        *    < 0 (error)
+        */
+       int (*on_recv_channel)(struct lttng_consumer_channel *channel);
+       /*
+        * function to call when we receive a new stream, it receives a
+        * newly allocated stream, depending on the return code of this
+        * function, the new stream will be handled by the application
+        * or the library.
+        *
+        * Returns:
+        *    > 0 (success, FD is kept by application)
+        *   == 0 (success, FD is left to library)
+        *    < 0 (error)
+        */
+       int (*on_recv_stream)(struct lttng_consumer_stream *stream);
+       /*
+        * function to call when a stream is getting updated by the session
+        * daemon, this function receives the sessiond key and the new
+        * state, depending on the return code of this function the
+        * update of state for the stream is handled by the application
+        * or the library.
+        *
+        * Returns:
+        *    > 0 (success, FD is kept by application)
+        *   == 0 (success, FD is left to library)
+        *    < 0 (error)
+        */
+       int (*on_update_stream)(uint64_t sessiond_key, uint32_t state);
+       enum lttng_consumer_type type;
+       /* socket to communicate errors with sessiond */
+       int consumer_error_socket;
+       /* socket to ask metadata to sessiond. */
+       int consumer_metadata_socket;
+       /*
+        * Protect consumer_metadata_socket.
+        *
+        * This is nested OUTSIDE the metadata cache lock.
+        */
+       pthread_mutex_t metadata_socket_lock;
+       /* socket to exchange commands with sessiond */
+       char *consumer_command_sock_path;
+       /* communication with splice */
+       int consumer_channel_pipe[2];
+       /* Data stream poll thread pipe. To transfer data stream to the thread */
+       struct lttng_pipe *consumer_data_pipe;
+
+       /*
+        * Data thread use that pipe to catch wakeup from read subbuffer that
+        * detects that there is still data to be read for the stream encountered.
+        * Before doing so, the stream is flagged to indicate that there is still
+        * data to be read.
+        *
+        * Both pipes (read/write) are owned and used inside the data thread.
+        */
+       struct lttng_pipe *consumer_wakeup_pipe;
+       /* Indicate if the wakeup thread has been notified. */
+       unsigned int has_wakeup:1;
+
+       /* to let the signal handler wake up the fd receiver thread */
+       int consumer_should_quit[2];
+       /* Metadata poll thread pipe. Transfer metadata stream to it */
+       struct lttng_pipe *consumer_metadata_pipe;
+       /*
+        * Pipe used by the channel monitoring timers to provide state samples
+        * to the session daemon (write-only).
+        */
+       int channel_monitor_pipe;
+       LTTNG_OPTIONAL(lttng_uuid) sessiond_uuid;
+};
+
+/*
+ * Library-level data. One instance per process.
+ */
+struct lttng_consumer_global_data {
+       /*
+        * At this time, this lock is used to ensure coherence between the count
+        * and number of element in the hash table. It's also a protection for
+        * concurrent read/write between threads.
+        *
+        * This is nested OUTSIDE the stream lock.
+        * This is nested OUTSIDE the consumer_relayd_sock_pair lock.
+        */
+       pthread_mutex_t lock {};
+
+       /*
+        * Number of streams in the data stream hash table declared outside.
+        * Protected by consumer_data.lock.
+        */
+       int stream_count = 0;
+
+       /* Channel hash table protected by consumer_data.lock. */
+       struct lttng_ht *channel_ht = nullptr;
+       /* Channel hash table indexed by session id. */
+       struct lttng_ht *channels_by_session_id_ht = nullptr;
+       /*
+        * Flag specifying if the local array of FDs needs update in the
+        * poll function. Protected by consumer_data.lock.
+        */
+       unsigned int need_update = 1;
+       enum lttng_consumer_type type = LTTNG_CONSUMER_UNKNOWN;
+
+       /*
+        * Relayd socket(s) hashtable indexed by network sequence number. Each
+        * stream has an index which associate the right relayd socket to use.
+        */
+       struct lttng_ht *relayd_ht = nullptr;
+
+       /*
+        * This hash table contains all streams (metadata and data) indexed by
+        * session id. In other words, the ht is indexed by session id and each
+        * bucket contains the list of associated streams.
+        *
+        * This HT uses the "node_session_id" of the consumer stream.
+        */
+       struct lttng_ht *stream_list_ht = nullptr;
+
+       /*
+        * This HT uses the "node_channel_id" of the consumer stream.
+        */
+       struct lttng_ht *stream_per_chan_id_ht = nullptr;
+
+       /*
+        * Trace chunk registry indexed by (session_id, chunk_id).
+        */
+       struct lttng_trace_chunk_registry *chunk_registry = nullptr;
+};
+
+/*
+ * Set to nonzero when the consumer is exiting. Updated by signal
+ * handler and thread exit, read by threads.
+ */
+extern int consumer_quit;
+
+/*
+ * Set to nonzero when the consumer is exiting. Updated by signal
+ * handler and thread exit, read by threads.
+ */
+extern int consumer_quit;
+
+/*
+ * Flag used to temporarily pause data consumption from testpoints.
+ *
+ * This variable is dlsym-ed from a test, so needs to be exported.
+ */
+LTTNG_EXPORT extern int data_consumption_paused;
+
+/* Return a human-readable consumer type string that is suitable for logging. */
+static inline
+const char *lttng_consumer_type_str(enum lttng_consumer_type type)
+{
+       switch (type) {
+       case LTTNG_CONSUMER_UNKNOWN:
+               return "unknown";
+       case LTTNG_CONSUMER_KERNEL:
+               return "kernel";
+       case LTTNG_CONSUMER32_UST:
+               return "32-bit user space";
+       case LTTNG_CONSUMER64_UST:
+               return "64-bit user space";
+       default:
+               abort();
+       }
+}
+
+/*
+ * Init consumer data structures.
+ */
+int lttng_consumer_init(void);
+
+/*
+ * Set the error socket for communication with a session daemon.
+ */
+void lttng_consumer_set_error_sock(struct lttng_consumer_local_data *ctx,
+               int sock);
+
+/*
+ * Set the command socket path for communication with a session daemon.
+ */
+void lttng_consumer_set_command_sock_path(
+               struct lttng_consumer_local_data *ctx, char *sock);
+
+/*
+ * Send return code to session daemon.
+ *
+ * Returns the return code of sendmsg : the number of bytes transmitted or -1
+ * on error.
+ */
+int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx, int cmd);
+
+/*
+ * Called from signal handler to ensure a clean exit.
+ */
+void lttng_consumer_should_exit(struct lttng_consumer_local_data *ctx);
+
+/*
+ * Cleanup the daemon's socket on exit.
+ */
+void lttng_consumer_cleanup(void);
+
+/*
+ * Poll on the should_quit pipe and the command socket return -1 on error and
+ * should exit, 0 if data is available on the command socket
+ */
+int lttng_consumer_poll_socket(struct pollfd *kconsumer_sockpoll);
+
+/*
+ * Copy the fields from the channel that need to be accessed (read-only)
+ * directly from the stream.
+ */
+void consumer_stream_update_channel_attributes(
+               struct lttng_consumer_stream *stream,
+               struct lttng_consumer_channel *channel);
+
+struct lttng_consumer_stream *consumer_allocate_stream(
+               struct lttng_consumer_channel *channel,
+               uint64_t channel_key,
+               uint64_t stream_key,
+               const char *channel_name,
+               uint64_t relayd_id,
+               uint64_t session_id,
+               struct lttng_trace_chunk *trace_chunk,
+               int cpu,
+               int *alloc_ret,
+               enum consumer_channel_type type,
+               unsigned int monitor);
+struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key,
+               uint64_t session_id,
+               const uint64_t *chunk_id,
+               const char *pathname,
+               const char *name,
+               uint64_t relayd_id,
+               enum lttng_event_output output,
+               uint64_t tracefile_size,
+               uint64_t tracefile_count,
+               uint64_t session_id_per_pid,
+               unsigned int monitor,
+               unsigned int live_timer_interval,
+               bool is_in_live_session,
+               const char *root_shm_path,
+               const char *shm_path);
+void consumer_del_stream(struct lttng_consumer_stream *stream,
+               struct lttng_ht *ht);
+void consumer_del_metadata_stream(struct lttng_consumer_stream *stream,
+               struct lttng_ht *ht);
+int consumer_add_channel(struct lttng_consumer_channel *channel,
+               struct lttng_consumer_local_data *ctx);
+void consumer_del_channel(struct lttng_consumer_channel *channel);
+
+/* lttng-relayd consumer command */
+struct consumer_relayd_sock_pair *consumer_find_relayd(uint64_t key);
+int consumer_send_relayd_stream(struct lttng_consumer_stream *stream, char *path);
+int consumer_send_relayd_streams_sent(uint64_t net_seq_idx);
+void close_relayd_stream(struct lttng_consumer_stream *stream);
+struct lttng_consumer_channel *consumer_find_channel(uint64_t key);
+int consumer_handle_stream_before_relayd(struct lttng_consumer_stream *stream,
+               size_t data_size);
+void consumer_steal_stream_key(int key, struct lttng_ht *ht);
+
+struct lttng_consumer_local_data *lttng_consumer_create(
+               enum lttng_consumer_type type,
+               ssize_t (*buffer_ready)(struct lttng_consumer_stream *stream,
+                       struct lttng_consumer_local_data *ctx,
+                       bool locked_by_caller),
+               int (*recv_channel)(struct lttng_consumer_channel *channel),
+               int (*recv_stream)(struct lttng_consumer_stream *stream),
+               int (*update_stream)(uint64_t sessiond_key, uint32_t state));
+void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx);
+ssize_t lttng_consumer_on_read_subbuffer_mmap(
+               struct lttng_consumer_stream *stream,
+               const struct lttng_buffer_view *buffer,
+               unsigned long padding);
+ssize_t lttng_consumer_on_read_subbuffer_splice(
+               struct lttng_consumer_local_data *ctx,
+               struct lttng_consumer_stream *stream, unsigned long len,
+               unsigned long padding);
+int lttng_consumer_sample_snapshot_positions(struct lttng_consumer_stream *stream);
+int lttng_consumer_take_snapshot(struct lttng_consumer_stream *stream);
+int lttng_consumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
+               unsigned long *pos);
+int lttng_consumer_get_consumed_snapshot(struct lttng_consumer_stream *stream,
+               unsigned long *pos);
+int lttng_ustconsumer_get_wakeup_fd(struct lttng_consumer_stream *stream);
+int lttng_ustconsumer_close_wakeup_fd(struct lttng_consumer_stream *stream);
+void *consumer_thread_metadata_poll(void *data);
+void *consumer_thread_data_poll(void *data);
+void *consumer_thread_sessiond_poll(void *data);
+void *consumer_thread_channel_poll(void *data);
+int lttng_consumer_recv_cmd(struct lttng_consumer_local_data *ctx,
+               int sock, struct pollfd *consumer_sockpoll);
+
+ssize_t lttng_consumer_read_subbuffer(struct lttng_consumer_stream *stream,
+               struct lttng_consumer_local_data *ctx,
+               bool locked_by_caller);
+int lttng_consumer_on_recv_stream(struct lttng_consumer_stream *stream);
+void consumer_add_relayd_socket(uint64_t net_seq_idx,
+               int sock_type,
+               struct lttng_consumer_local_data *ctx,
+               int sock,
+               struct pollfd *consumer_sockpoll,
+               uint64_t sessiond_id,
+               uint64_t relayd_session_id,
+               uint32_t relayd_version_major,
+               uint32_t relayd_version_minor,
+               enum lttcomm_sock_proto relayd_socket_protocol);
+void consumer_flag_relayd_for_destroy(
+               struct consumer_relayd_sock_pair *relayd);
+int consumer_data_pending(uint64_t id);
+int consumer_send_status_msg(int sock, int ret_code);
+int consumer_send_status_channel(int sock,
+               struct lttng_consumer_channel *channel);
+void notify_thread_del_channel(struct lttng_consumer_local_data *ctx,
+               uint64_t key);
+void consumer_destroy_relayd(struct consumer_relayd_sock_pair *relayd);
+unsigned long consumer_get_consume_start_pos(unsigned long consumed_pos,
+               unsigned long produced_pos, uint64_t nb_packets_per_stream,
+               uint64_t max_sb_size);
+void consumer_add_data_stream(struct lttng_consumer_stream *stream);
+void consumer_del_stream_for_data(struct lttng_consumer_stream *stream);
+void consumer_add_metadata_stream(struct lttng_consumer_stream *stream);
+void consumer_del_stream_for_metadata(struct lttng_consumer_stream *stream);
+int consumer_create_index_file(struct lttng_consumer_stream *stream);
+int lttng_consumer_rotate_channel(struct lttng_consumer_channel *channel,
+               uint64_t key, uint64_t relayd_id);
+int lttng_consumer_stream_is_rotate_ready(struct lttng_consumer_stream *stream);
+int lttng_consumer_rotate_stream(struct lttng_consumer_stream *stream);
+int lttng_consumer_rotate_ready_streams(struct lttng_consumer_channel *channel,
+               uint64_t key);
+void lttng_consumer_reset_stream_rotate_state(struct lttng_consumer_stream *stream);
+enum lttcomm_return_code lttng_consumer_create_trace_chunk(
+               const uint64_t *relayd_id, uint64_t session_id,
+               uint64_t chunk_id,
+               time_t chunk_creation_timestamp,
+               const char *chunk_override_name,
+               const struct lttng_credentials *credentials,
+               struct lttng_directory_handle *chunk_directory_handle);
+enum lttcomm_return_code lttng_consumer_close_trace_chunk(
+               const uint64_t *relayd_id, uint64_t session_id,
+               uint64_t chunk_id, time_t chunk_close_timestamp,
+               const enum lttng_trace_chunk_command_type *close_command,
+               char *path);
+enum lttcomm_return_code lttng_consumer_trace_chunk_exists(
+               const uint64_t *relayd_id, uint64_t session_id,
+               uint64_t chunk_id);
+void lttng_consumer_cleanup_relayd(struct consumer_relayd_sock_pair *relayd);
+enum lttcomm_return_code lttng_consumer_init_command(
+               struct lttng_consumer_local_data *ctx,
+               const lttng_uuid sessiond_uuid);
+int lttng_consumer_clear_channel(struct lttng_consumer_channel *channel);
+enum lttcomm_return_code lttng_consumer_open_channel_packets(
+               struct lttng_consumer_channel *channel);
+int consumer_metadata_wakeup_pipe(const struct lttng_consumer_channel *channel);
+void lttng_consumer_sigbus_handle(void *addr);
+
+#endif /* LIB_CONSUMER_H */
index 160185def7b77fe5e05ff5434c486eae9c405092..ed78ec9472f800e3b55358bd9c5e235135bf52e9 100644 (file)
@@ -5,13 +5,13 @@
  *
  */
 
-#include "metadata-bucket.h"
+#include "metadata-bucket.hpp"
 
-#include <common/buffer-view.h>
-#include <common/consumer/consumer.h>
-#include <common/dynamic-buffer.h>
-#include <common/macros.h>
-#include <common/error.h>
+#include <common/buffer-view.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/macros.hpp>
+#include <common/error.hpp>
 
 struct metadata_bucket {
        struct lttng_dynamic_buffer content;
diff --git a/src/common/consumer/metadata-bucket.h b/src/common/consumer/metadata-bucket.h
deleted file mode 100644 (file)
index 993d3f4..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef METADATA_BUCKET_H
-#define METADATA_BUCKET_H
-
-#include <common/consumer/consumer.h>
-
-struct metadata_bucket;
-
-typedef ssize_t (*metadata_bucket_flush_cb)(
-               const struct stream_subbuffer *buffer, void *data);
-
-enum metadata_bucket_status {
-       METADATA_BUCKET_STATUS_OK,
-       METADATA_BUCKET_STATUS_ERROR,
-};
-
-struct metadata_bucket *metadata_bucket_create(
-               metadata_bucket_flush_cb flush, void *data);
-
-void metadata_bucket_destroy(struct metadata_bucket *bucket);
-
-enum metadata_bucket_status metadata_bucket_fill(struct metadata_bucket *bucket,
-               const struct stream_subbuffer *buffer);
-
-void metadata_bucket_reset(struct metadata_bucket *bucket);
-
-#endif /* METADATA_BUCKET_H */
diff --git a/src/common/consumer/metadata-bucket.hpp b/src/common/consumer/metadata-bucket.hpp
new file mode 100644 (file)
index 0000000..2c6961c
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef METADATA_BUCKET_H
+#define METADATA_BUCKET_H
+
+#include <common/consumer/consumer.hpp>
+
+struct metadata_bucket;
+
+typedef ssize_t (*metadata_bucket_flush_cb)(
+               const struct stream_subbuffer *buffer, void *data);
+
+enum metadata_bucket_status {
+       METADATA_BUCKET_STATUS_OK,
+       METADATA_BUCKET_STATUS_ERROR,
+};
+
+struct metadata_bucket *metadata_bucket_create(
+               metadata_bucket_flush_cb flush, void *data);
+
+void metadata_bucket_destroy(struct metadata_bucket *bucket);
+
+enum metadata_bucket_status metadata_bucket_fill(struct metadata_bucket *bucket,
+               const struct stream_subbuffer *buffer);
+
+void metadata_bucket_reset(struct metadata_bucket *bucket);
+
+#endif /* METADATA_BUCKET_H */
index ab61a8133386b026bf27972a168030c74d9c401f..98c29f86c2cbac21f344e3a1df33231e6e6eb7c5 100644 (file)
@@ -5,11 +5,11 @@
  *
  */
 
-#include "context.h"
+#include "context.hpp"
 #include <stddef.h>
 #include <string.h>
-#include <common/error.h>
-#include <common/macros.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
 
 int parse_application_context(const char *str, char **out_provider_name,
                char **out_ctx_name)
diff --git a/src/common/context.h b/src/common/context.h
deleted file mode 100644 (file)
index f4abd84..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_COMMON_CONTEXT_H
-#define LTTNG_COMMON_CONTEXT_H
-
-#include <common/macros.h>
-
-/*
- * Parse string as an application context of the form
- * "$app.provider_name:context_name" and return the provider name and context
- * name separately.
- *
- * provider_name and ctx_name are returned only if an application context name
- * was successfully parsed and must be freed by the caller.
- *
- * Returns 0 if the string is a valid application context, else a negative
- * value on error.
- */
-int parse_application_context(const char *str, char **provider_name,
-               char **ctx_name);
-
-#endif /* LTTNG_COMMON_CONTEXT_H */
diff --git a/src/common/context.hpp b/src/common/context.hpp
new file mode 100644 (file)
index 0000000..324ef53
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_COMMON_CONTEXT_H
+#define LTTNG_COMMON_CONTEXT_H
+
+#include <common/macros.hpp>
+
+/*
+ * Parse string as an application context of the form
+ * "$app.provider_name:context_name" and return the provider name and context
+ * name separately.
+ *
+ * provider_name and ctx_name are returned only if an application context name
+ * was successfully parsed and must be freed by the caller.
+ *
+ * Returns 0 if the string is a valid application context, else a negative
+ * value on error.
+ */
+int parse_application_context(const char *str, char **provider_name,
+               char **ctx_name);
+
+#endif /* LTTNG_COMMON_CONTEXT_H */
index fd8b4477bb9ad1b0861ab8a76a10bce35fed60ac..f936736db4919760dcc5c42094c35497d25ddb7b 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #include <stdbool.h>
-#include "credentials.h"
+#include "credentials.hpp"
 
 uid_t lttng_credentials_get_uid(const struct lttng_credentials *creds)
 {
diff --git a/src/common/credentials.h b/src/common/credentials.h
deleted file mode 100644 (file)
index 66f2dbe..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CREDENTIALS_H
-#define LTTNG_CREDENTIALS_H
-
-#include <sys/types.h>
-#include <stdbool.h>
-#include "macros.h"
-
-#include "optional.h"
-
-struct lttng_credentials {
-       LTTNG_OPTIONAL(uid_t) uid;
-       LTTNG_OPTIONAL(gid_t) gid;
-};
-
-uid_t lttng_credentials_get_uid(const struct lttng_credentials *creds);
-
-gid_t lttng_credentials_get_gid(const struct lttng_credentials *creds);
-
-bool lttng_credentials_is_equal_uid(const struct lttng_credentials *a,
-               const struct lttng_credentials *b);
-
-bool lttng_credentials_is_equal_gid(const struct lttng_credentials *a,
-               const struct lttng_credentials *b);
-
-bool lttng_credentials_is_equal(const struct lttng_credentials *a,
-               const struct lttng_credentials *b);
-
-#endif /* LTTNG_CREDENTIALS_H */
diff --git a/src/common/credentials.hpp b/src/common/credentials.hpp
new file mode 100644 (file)
index 0000000..340e64e
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CREDENTIALS_H
+#define LTTNG_CREDENTIALS_H
+
+#include <sys/types.h>
+#include <stdbool.h>
+#include "macros.hpp"
+
+#include "optional.hpp"
+
+struct lttng_credentials {
+       LTTNG_OPTIONAL(uid_t) uid;
+       LTTNG_OPTIONAL(gid_t) gid;
+};
+
+uid_t lttng_credentials_get_uid(const struct lttng_credentials *creds);
+
+gid_t lttng_credentials_get_gid(const struct lttng_credentials *creds);
+
+bool lttng_credentials_is_equal_uid(const struct lttng_credentials *a,
+               const struct lttng_credentials *b);
+
+bool lttng_credentials_is_equal_gid(const struct lttng_credentials *a,
+               const struct lttng_credentials *b);
+
+bool lttng_credentials_is_equal(const struct lttng_credentials *a,
+               const struct lttng_credentials *b);
+
+#endif /* LTTNG_CREDENTIALS_H */
index 16af5a3f78ccec5da76033a48a7d0a04bd0c38f2..0ed35556e81a52a87c8a94e8295e10a1fd1f3eca 100644 (file)
@@ -8,15 +8,15 @@
 
 #define _LGPL_SOURCE
 #include <unistd.h>
-#include <common/compat/paths.h>
+#include <common/compat/paths.hpp>
 #include <fcntl.h>
 #include <sys/wait.h>
 #include <stdlib.h>
 
 #include <urcu/system.h>
 
-#include <common/daemonize.h>
-#include <common/error.h>
+#include <common/daemonize.hpp>
+#include <common/error.hpp>
 
 int lttng_daemonize(pid_t *child_ppid, int *completion_flag,
                int close_fds)
diff --git a/src/common/daemonize.h b/src/common/daemonize.h
deleted file mode 100644 (file)
index 2c88f06..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef LTTNG_DAEMONIZE_H
-#define LTTNG_DAEMONIZE_H
-
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <unistd.h>
-#include <common/macros.h>
-
-/*
- * Daemonize this process by forking and making the parent wait for the child
- * to signal it indicating readiness. Once received, the parent successfully
- * quits.
- *
- * The child process undergoes the same action that daemon(3) does meaning
- * setsid, chdir, and dup /dev/null into 0, 1 and 2.
- *
- * Return 0 on success else -1 on error.
- */
-int lttng_daemonize(pid_t *child_ppid, int *completion_flag,
-               int close_fds);
-
-#endif /* LTTNG_DAEMONIZE_H */
diff --git a/src/common/daemonize.hpp b/src/common/daemonize.hpp
new file mode 100644 (file)
index 0000000..d1ec1cb
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef LTTNG_DAEMONIZE_H
+#define LTTNG_DAEMONIZE_H
+
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <unistd.h>
+#include <common/macros.hpp>
+
+/*
+ * Daemonize this process by forking and making the parent wait for the child
+ * to signal it indicating readiness. Once received, the parent successfully
+ * quits.
+ *
+ * The child process undergoes the same action that daemon(3) does meaning
+ * setsid, chdir, and dup /dev/null into 0, 1 and 2.
+ *
+ * Return 0 on success else -1 on error.
+ */
+int lttng_daemonize(pid_t *child_ppid, int *completion_flag,
+               int close_fds);
+
+#endif /* LTTNG_DAEMONIZE_H */
index 830720bd2698645e9d8f6e320a6d3d5aa54927f2..d79e42a6b63b5a35490f42798412b98c68417d59 100644 (file)
@@ -13,9 +13,9 @@
 #include <pthread.h>
 #include <algorithm>
 
-#include "defaults.h"
-#include "macros.h"
-#include "error.h"
+#include "defaults.hpp"
+#include "macros.hpp"
+#include "error.hpp"
 
 static int pthread_attr_init_done;
 static pthread_attr_t tattr;
diff --git a/src/common/defaults.h b/src/common/defaults.h
deleted file mode 100644 (file)
index b889466..0000000
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _DEFAULTS_H
-#define _DEFAULTS_H
-
-#include <pthread.h>
-#include <common/macros.h>
-
-/* Default unix group name for tracing. */
-#define DEFAULT_TRACING_GROUP                   "tracing"
-
-/*
- * This value is defined in the CTF specification (see
- * git://git.efficios.com/ctf.git in the file
- * common-trace-format-specification.txt.
- */
-#define DEFAULT_METADATA_NAME                   "metadata"
-
-/* Environment variable to set session daemon binary path. */
-#define DEFAULT_SESSIOND_PATH_ENV               "LTTNG_SESSIOND_PATH"
-
-/* Environment variable to set man pager binary path. */
-#define DEFAULT_MAN_BIN_PATH_ENV                "LTTNG_MAN_BIN_PATH"
-
-/* Default man pager binary path. */
-#define DEFAULT_MAN_BIN_PATH                    "/usr/bin/man"
-
-/* Default trace output directory name */
-#define DEFAULT_TRACE_DIR_NAME                  "lttng-traces"
-
-/* Default size of a hash table */
-#define DEFAULT_HT_SIZE                         4
-
-/* Default session daemon paths */
-#define DEFAULT_HOME_DIR                                               "/tmp"
-#define DEFAULT_UST_SOCK_DIR                    DEFAULT_HOME_DIR "/ust-app-socks"
-#define DEFAULT_GLOBAL_APPS_PIPE                DEFAULT_UST_SOCK_DIR "/global"
-#define DEFAULT_TRACE_OUTPUT                    DEFAULT_HOME_DIR "/lttng"
-
-/* Default directory where the trace are written in per domain */
-#define DEFAULT_KERNEL_TRACE_DIR                "kernel"
-#define DEFAULT_UST_TRACE_DIR                   "ust"
-
-/* Subpath for per PID or UID sessions. */
-#define DEFAULT_UST_TRACE_PID_PATH               "pid"
-#define DEFAULT_UST_TRACE_UID_PATH               "uid/%d/%u-bit"
-
-/*
- * Default session name for the lttng command line. This default value will
- * get the date and time appended (%Y%m%d-%H%M%S) to it.
- */
-#define DEFAULT_SESSION_NAME                    "auto"
-
-/* Default consumer paths */
-#define DEFAULT_CONSUMERD_FILE                  "lttng-consumerd"
-
-/* Default consumer paths */
-#define DEFAULT_CONSUMERD_RUNDIR                "%s"
-
-/* Kernel consumer path */
-#define DEFAULT_KCONSUMERD_PATH                 DEFAULT_CONSUMERD_RUNDIR "/kconsumerd"
-#define DEFAULT_KCONSUMERD_CMD_SOCK_PATH        DEFAULT_KCONSUMERD_PATH "/command"
-#define DEFAULT_KCONSUMERD_ERR_SOCK_PATH        DEFAULT_KCONSUMERD_PATH "/error"
-
-/* UST 64-bit consumer path */
-#define DEFAULT_USTCONSUMERD64_PATH             DEFAULT_CONSUMERD_RUNDIR "/ustconsumerd64"
-#define DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH    DEFAULT_USTCONSUMERD64_PATH "/command"
-#define DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH    DEFAULT_USTCONSUMERD64_PATH "/error"
-
-/* UST 32-bit consumer path */
-#define DEFAULT_USTCONSUMERD32_PATH             DEFAULT_CONSUMERD_RUNDIR "/ustconsumerd32"
-#define DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH    DEFAULT_USTCONSUMERD32_PATH "/command"
-#define DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH    DEFAULT_USTCONSUMERD32_PATH "/error"
-
-/* Relayd path */
-#define DEFAULT_RELAYD_RUNDIR                  "%s"
-#define DEFAULT_RELAYD_PATH                    DEFAULT_RELAYD_RUNDIR "/relayd"
-
-#define DEFAULT_RELAYD_MIN_FD_POOL_SIZE                100
-/*
- * The file descriptor pool size needs a reserve buffer to accommodates the
- * indirect use of short-lived file descriptors. For instance, glibc will
- * create a socket (and thus, use an fd) during calls to gethostname() or
- * when querying the user's group. Other calls also probably make use of
- * short-lived FDs.
- *
- * The theoritical maximal reserve corresponds to the number of threads as,
- * in the worst case, they could all be making such calls.
- *
- * This value must be less than DEFAULT_RELAYD_MIN_FD_POOL_SIZE.
- */
-#define DEFAULT_RELAYD_FD_POOL_SIZE_RESERVE    10
-
-/* Default lttng run directory */
-#define DEFAULT_LTTNG_HOME_ENV_VAR              "LTTNG_HOME"
-#define DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR    "HOME"
-#define DEFAULT_LTTNG_RUNDIR                    CONFIG_LTTNG_SYSTEM_RUNDIR
-#define DEFAULT_LTTNG_HOME_RUNDIR               "%s/.lttng"
-#define DEFAULT_LTTNG_SESSIOND_PIDFILE          "lttng-sessiond.pid"
-#define DEFAULT_LTTNG_SESSIOND_AGENTPORT_FILE   "agent.port"
-#define DEFAULT_LTTNG_SESSIOND_LOCKFILE         "lttng-sessiond.lck"
-
-/* Default probes list */
-#define DEFAULT_LTTNG_KMOD_PROBES              "LTTNG_KMOD_PROBES"
-
-/* Default extra probes list */
-#define DEFAULT_LTTNG_EXTRA_KMOD_PROBES                "LTTNG_EXTRA_KMOD_PROBES"
-
-/* Default unix socket path */
-#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK                DEFAULT_LTTNG_RUNDIR "/client-lttng-sessiond"
-#define DEFAULT_HOME_CLIENT_UNIX_SOCK                  DEFAULT_LTTNG_HOME_RUNDIR "/client-lttng-sessiond"
-#define DEFAULT_GLOBAL_HEALTH_UNIX_SOCK                DEFAULT_LTTNG_RUNDIR "/sessiond-health"
-#define DEFAULT_HOME_HEALTH_UNIX_SOCK                  DEFAULT_LTTNG_HOME_RUNDIR "/sessiond-health"
-#define DEFAULT_GLOBAL_NOTIFICATION_CHANNEL_UNIX_SOCK   DEFAULT_LTTNG_RUNDIR "/sessiond-notification"
-#define DEFAULT_HOME_NOTIFICATION_CHANNEL_UNIX_SOCK    DEFAULT_LTTNG_HOME_RUNDIR "/sessiond-notification"
-
-/* Default consumer health unix socket path */
-#define DEFAULT_GLOBAL_USTCONSUMER32_HEALTH_UNIX_SOCK  DEFAULT_LTTNG_RUNDIR "/ustconsumerd32/health"
-#define DEFAULT_HOME_USTCONSUMER32_HEALTH_UNIX_SOCK    DEFAULT_LTTNG_HOME_RUNDIR "/ustconsumerd32/health"
-#define DEFAULT_GLOBAL_USTCONSUMER64_HEALTH_UNIX_SOCK  DEFAULT_LTTNG_RUNDIR "/ustconsumerd64/health"
-#define DEFAULT_HOME_USTCONSUMER64_HEALTH_UNIX_SOCK    DEFAULT_LTTNG_HOME_RUNDIR "/ustconsumerd64/health"
-#define DEFAULT_GLOBAL_KCONSUMER_HEALTH_UNIX_SOCK      DEFAULT_LTTNG_RUNDIR "/kconsumerd/health"
-#define DEFAULT_HOME_KCONSUMER_HEALTH_UNIX_SOCK                DEFAULT_LTTNG_HOME_RUNDIR "/kconsumerd/health"
-
-/* Default relay health unix socket path */
-#define DEFAULT_GLOBAL_RELAY_HEALTH_UNIX_SOCK          DEFAULT_LTTNG_RUNDIR "/relayd/health-%d"
-#define DEFAULT_HOME_RELAY_HEALTH_UNIX_SOCK            DEFAULT_LTTNG_HOME_RUNDIR "/relayd/health-%d"
-
-/* Default daemon configuration file path */
-#define DEFAULT_SYSTEM_CONFIGPATH               CONFIG_LTTNG_SYSTEM_CONFIGDIR \
-       "/lttng"
-
-#define DEFAULT_DAEMON_CONFIG_FILE              "lttng.conf"
-#define DEFAULT_DAEMON_HOME_CONFIGPATH          DEFAULT_LTTNG_HOME_RUNDIR "/" \
-       DEFAULT_DAEMON_CONFIG_FILE
-#define DEFAULT_DAEMON_SYSTEM_CONFIGPATH        DEFAULT_SYSTEM_CONFIGPATH "/" \
-       DEFAULT_DAEMON_CONFIG_FILE
-
-/* Default session configuration file path */
-#define DEFAULT_SESSION_PATH                    "sessions"
-/* Auto load session in that directory. */
-#define DEFAULT_SESSION_CONFIG_AUTOLOAD         "auto"
-#define DEFAULT_SESSION_HOME_CONFIGPATH         DEFAULT_LTTNG_HOME_RUNDIR "/" \
-       DEFAULT_SESSION_PATH
-#define DEFAULT_SESSION_SYSTEM_CONFIGPATH       DEFAULT_SYSTEM_CONFIGPATH "/" \
-       DEFAULT_SESSION_PATH
-#define DEFAULT_SESSION_CONFIG_FILE_EXTENSION   ".lttng"
-#define DEFAULT_SESSION_CONFIG_XSD_FILENAME     "session.xsd"
-#define DEFAULT_SESSION_CONFIG_XSD_PATH         CONFIG_LTTNG_SYSTEM_DATADIR "/xml/lttng/"
-#define DEFAULT_SESSION_CONFIG_XSD_PATH_ENV     "LTTNG_SESSION_CONFIG_XSD_PATH"
-
-#define DEFAULT_GLOBAL_APPS_UNIX_SOCK \
-       DEFAULT_LTTNG_RUNDIR "/" LTTNG_UST_SOCK_FILENAME
-#define DEFAULT_HOME_APPS_UNIX_SOCK \
-       DEFAULT_LTTNG_HOME_RUNDIR "/" LTTNG_UST_SOCK_FILENAME
-#define DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH \
-       "/" LTTNG_UST_WAIT_FILENAME
-#define DEFAULT_HOME_APPS_WAIT_SHM_PATH \
-       DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH "-%d"
-
-/*
- * Value taken from the hard limit allowed by the kernel when using setrlimit
- * with RLIMIT_NOFILE on an Intel i7 CPU and Linux 3.0.3.
- */
-#define DEFAULT_POLL_SIZE 65535
-
-/*
- * Format is %s_%d respectively channel name and CPU number. Eigth bytes
- * are added here to add space for the CPU number. I guess 2^8 CPUs is more
- * than enough. We might end up with quantum computing in a cell phone when
- * reaching this limit.
- */
-#define DEFAULT_STREAM_NAME_LEN        LTTNG_SYMBOL_NAME_LEN + 8
-
-/* Default channel attributes */
-#define DEFAULT_CHANNEL_NAME            "channel0"
-/* Default JUL domain channel name. */
-#define DEFAULT_JUL_CHANNEL_NAME        "lttng_jul_channel"
-/* Default JUL tracepoint name. This is a wildcard for the JUL domain. */
-#define DEFAULT_JUL_EVENT_COMPONENT     "lttng_jul"
-#define DEFAULT_JUL_EVENT_NAME          DEFAULT_JUL_EVENT_COMPONENT ":*"
-
-/* Default log4j domain channel name. */
-#define DEFAULT_LOG4J_CHANNEL_NAME        "lttng_log4j_channel"
-/* Default log4j tracepoint name. This is a wildcard for the log4j domain. */
-#define DEFAULT_LOG4J_EVENT_COMPONENT     "lttng_log4j"
-#define DEFAULT_LOG4J_EVENT_NAME          DEFAULT_LOG4J_EVENT_COMPONENT ":*"
-
-/* Default Python domain channel name. */
-#define DEFAULT_PYTHON_CHANNEL_NAME       "lttng_python_channel"
-/* Default Python tracepoint name. This is a wildcard for the python domain. */
-#define DEFAULT_PYTHON_EVENT_COMPONENT    "lttng_python"
-#define DEFAULT_PYTHON_EVENT_NAME         DEFAULT_PYTHON_EVENT_COMPONENT ":*"
-
-#define DEFAULT_CHANNEL_OVERWRITE       -1
-#define DEFAULT_CHANNEL_TRACEFILE_SIZE  CONFIG_DEFAULT_CHANNEL_TRACEFILE_SIZE
-#define DEFAULT_CHANNEL_TRACEFILE_COUNT CONFIG_DEFAULT_CHANNEL_TRACEFILE_COUNT
-
-#define _DEFAULT_CHANNEL_SUBBUF_SIZE   CONFIG_DEFAULT_CHANNEL_SUBBUF_SIZE
-#define _DEFAULT_CHANNEL_OUTPUT                        LTTNG_EVENT_MMAP
-
-/* Metadata channel defaults. */
-#define DEFAULT_METADATA_SUBBUF_SIZE    CONFIG_DEFAULT_METADATA_SUBBUF_SIZE
-#define DEFAULT_METADATA_SUBBUF_NUM     CONFIG_DEFAULT_METADATA_SUBBUF_NUM
-#define DEFAULT_METADATA_CACHE_SIZE     CONFIG_DEFAULT_METADATA_CACHE_SIZE
-#define DEFAULT_METADATA_SWITCH_TIMER  0
-#define DEFAULT_METADATA_READ_TIMER    0
-#define DEFAULT_METADATA_OVERWRITE     0
-#define DEFAULT_METADATA_OUTPUT                LTTNG_EVENT_MMAP
-
-/* Kernel has different defaults */
-
-/* DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE must always be a power of 2 */
-#define DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE     CONFIG_DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE
-/*
- * DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM must always be a power of 2.
- * Update help manually if override.
- */
-#define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM      CONFIG_DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM
-/* See lttng-kernel.h enum lttng_kernel_output for channel output */
-#define DEFAULT_KERNEL_CHANNEL_OUTPUT                  LTTNG_EVENT_SPLICE
-#define DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER    CONFIG_DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER
-#define DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER   CONFIG_DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER
-#define DEFAULT_KERNEL_CHANNEL_READ_TIMER      CONFIG_DEFAULT_KERNEL_CHANNEL_READ_TIMER
-#define DEFAULT_KERNEL_CHANNEL_LIVE_TIMER      CONFIG_DEFAULT_KERNEL_CHANNEL_LIVE_TIMER
-#define DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT        CONFIG_DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT
-
-/* User space defaults */
-
-/* Must be a power of 2 */
-#define DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE    CONFIG_DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE
-#define DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE    CONFIG_DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE
-/* Must be a power of 2. Update help manuall if override. */
-#define DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM     CONFIG_DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM
-#define DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM     CONFIG_DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM
-/* See lttng-ust.h enum lttng_ust_output */
-#define DEFAULT_UST_PID_CHANNEL_OUTPUT                 _DEFAULT_CHANNEL_OUTPUT
-#define DEFAULT_UST_UID_CHANNEL_OUTPUT                 _DEFAULT_CHANNEL_OUTPUT
-/* Timers in usec. */
-#define DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER   CONFIG_DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER
-#define DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER   CONFIG_DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER
-#define DEFAULT_UST_PID_CHANNEL_LIVE_TIMER     CONFIG_DEFAULT_UST_PID_CHANNEL_LIVE_TIMER
-#define DEFAULT_UST_UID_CHANNEL_LIVE_TIMER     CONFIG_DEFAULT_UST_UID_CHANNEL_LIVE_TIMER
-#define DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER  CONFIG_DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER
-#define DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER  CONFIG_DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER
-
-#define DEFAULT_UST_PID_CHANNEL_READ_TIMER      CONFIG_DEFAULT_UST_PID_CHANNEL_READ_TIMER
-#define DEFAULT_UST_UID_CHANNEL_READ_TIMER      CONFIG_DEFAULT_UST_UID_CHANNEL_READ_TIMER
-
-#define DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT       CONFIG_DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT
-#define DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT       CONFIG_DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT
-
-/*
- * Default timeout value for the sem_timedwait() call. Blocking forever is not
- * wanted so a timeout is used to control the data flow and not freeze the
- * session daemon.
- */
-#define DEFAULT_SEM_WAIT_TIMEOUT            30    /* in seconds */
-
-/* Default bind addresses for network services. */
-#define DEFAULT_NETWORK_CONTROL_BIND_ADDRESS    CONFIG_DEFAULT_NETWORK_CONTROL_BIND_ADDRESS
-#define DEFAULT_NETWORK_DATA_BIND_ADDRESS              CONFIG_DEFAULT_NETWORK_DATA_BIND_ADDRESS
-#define DEFAULT_NETWORK_VIEWER_BIND_ADDRESS     CONFIG_DEFAULT_NETWORK_VIEWER_BIND_ADDRESS
-#define DEFAULT_AGENT_BIND_ADDRESS              CONFIG_DEFAULT_AGENT_BIND_ADDRESS
-
-/* Default network ports for trace streaming support. */
-#define DEFAULT_NETWORK_CONTROL_PORT        CONFIG_DEFAULT_NETWORK_CONTROL_PORT
-#define DEFAULT_NETWORK_DATA_PORT           CONFIG_DEFAULT_NETWORK_DATA_PORT
-#define DEFAULT_NETWORK_VIEWER_PORT         CONFIG_DEFAULT_NETWORK_VIEWER_PORT
-
-/* Agent registration TCP port range. */
-#define DEFAULT_AGENT_TCP_PORT_RANGE_BEGIN  CONFIG_DEFAULT_AGENT_TCP_PORT_RANGE_BEGIN
-#define DEFAULT_AGENT_TCP_PORT_RANGE_END    CONFIG_DEFAULT_AGENT_TCP_PORT_RANGE_END
-
-/* Number of buckets in the event notifier error count map. */
-#define DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE CONFIG_DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE
-
-/*
- * If a thread stalls for this amount of time, it will be considered bogus (bad
- * health).
- */
-#define DEFAULT_HEALTH_CHECK_DELTA_S        20
-#define DEFAULT_HEALTH_CHECK_DELTA_NS       0
-
-/*
- * Wait period before retrying the lttng_data_pending command in the lttng
- * stop command of liblttng-ctl.
- */
-#define DEFAULT_DATA_AVAILABILITY_WAIT_TIME_US 200000  /* usec */
-
-/*
- * Wait period before retrying the lttng_consumer_flushed_cache when
- * the consumer receives metadata.
- */
-#define DEFAULT_METADATA_AVAILABILITY_WAIT_TIME 200000  /* usec */
-
-/*
- * The usual value for the maximum TCP SYN retries time and TCP FIN timeout is
- * 180 and 60 seconds on most Linux system and the default value since kernel
- * 2.2 thus using the highest value. See tcp(7) for more details.
- */
-#define DEFAULT_INET_TCP_TIMEOUT                       180     /* sec */
-
-/* Maximum payload size for a control connection */
-
-#define DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE CONFIG_DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE
-
-/*
- * Default receiving and sending timeout for an application socket.
- */
-#define DEFAULT_APP_SOCKET_RW_TIMEOUT       CONFIG_DEFAULT_APP_SOCKET_RW_TIMEOUT
-#define DEFAULT_APP_SOCKET_TIMEOUT_ENV      "LTTNG_APP_SOCKET_TIMEOUT"
-
-#define DEFAULT_UST_STREAM_FD_NUM                      2 /* Number of fd per UST stream. */
-
-#define DEFAULT_SNAPSHOT_NAME                          "snapshot"
-#define DEFAULT_SNAPSHOT_MAX_SIZE                      0 /* Unlimited. */
-
-/* Suffix of an index file. */
-#define DEFAULT_INDEX_FILE_SUFFIX                      ".idx"
-#define DEFAULT_INDEX_DIR                                      "index"
-
-/* Default lttng command live timer value in usec. */
-#define DEFAULT_LTTNG_LIVE_TIMER                       CONFIG_DEFAULT_LTTNG_LIVE_TIMER
-
-/* Default runas worker name */
-#define DEFAULT_RUN_AS_WORKER_NAME                     "lttng-runas"
-
-/* Default LTTng MI XML namespace. */
-#define DEFAULT_LTTNG_MI_NAMESPACE             "https://lttng.org/xml/ns/lttng-mi"
-
-/* Default thread stack size; the default mandated by pthread_create(3) */
-#define DEFAULT_LTTNG_THREAD_STACK_SIZE                2097152
-
-/* Default maximal size of message notification channel message payloads. */
-#define DEFAULT_MAX_NOTIFICATION_CLIENT_MESSAGE_PAYLOAD_SIZE   65536
-
-/* Default maximal size of trace archive location. */
-#define DEFAULT_MAX_TRACE_ARCHIVE_LOCATION_PAYLOAD_SIZE                65536
-
-/* Default maximal size of message notification channel message payloads. */
-#define DEFAULT_CLIENT_MAX_QUEUED_NOTIFICATIONS_COUNT          100
-
-
-#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE"
-#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME"
-#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT"
-#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL"
-#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD"
-#define DEFAULT_LTTNG_RELAYD_DISALLOW_CLEAR_ENV "LTTNG_RELAYD_DISALLOW_CLEAR"
-
-#define DEFAULT_LTTNG_RELAYD_WORKING_DIRECTORY_ENV "LTTNG_RELAYD_WORKING_DIRECTORY"
-
-/*
- * Name of the intermediate directory used to rename the trace chunk of a
- * session's first rotation.
- */
-#define DEFAULT_CHUNK_TMP_OLD_DIRECTORY                        ".tmp_old_chunk"
-#define DEFAULT_CHUNK_TMP_NEW_DIRECTORY                        ".tmp_new_chunk"
-#define DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY                "archives"
-#define DEFAULT_UNLINKED_FILES_DIRECTORY               ".unlinked"
-
-/*
- * Default timer value in usec for the rotate pending polling check on the
- * relay when a rotation has completed on the consumer.
- */
-#define DEFAULT_ROTATE_PENDING_TIMER   CONFIG_DEFAULT_ROTATE_PENDING_TIMER
-
-/*
- * Returns the default subbuf size.
- *
- * This function depends on a value that is set at constructor time, so it is
- * unsafe to call it from another constructor.
- */
-size_t default_get_channel_subbuf_size(void);
-
-/*
- * Returns the default metadata subbuf size.
- *
- * This function depends on a value that is set at constructor time, so it is
- * unsafe to call it from another constructor.
- */
-size_t default_get_metadata_subbuf_size(void);
-
-/*
- * Returns the default subbuf size for the kernel domain.
- *
- * This function depends on a value that is set at constructor time, so it is
- * unsafe to call it from another constructor.
- */
-size_t default_get_kernel_channel_subbuf_size(void);
-
-/*
- * Returns the default subbuf size for the UST domain per PID.
- *
- * This function depends on a value that is set at constructor time, so it is
- * unsafe to call it from another constructor.
- */
-size_t default_get_ust_pid_channel_subbuf_size(void);
-
-/*
- * Returns the default subbuf size for the UST domain per UID.
- *
- * This function depends on a value that is set at constructor time, so it is
- * unsafe to call it from another constructor.
- */
-size_t default_get_ust_uid_channel_subbuf_size(void);
-
-/*
- * Get the default pthread_attr to use on thread creation.
- *
- * Some libc, such as musl, don't honor the limit set for the stack size and use
- * their own empirically chosen static value. This function checks if the
- * current stack size is smaller than the stack size limit and if so returns a
- * pthread_attr_t pointer where the thread stack size is set to the soft stack
- * size limit.
- */
-pthread_attr_t *default_pthread_attr(void);
-
-#endif /* _DEFAULTS_H */
diff --git a/src/common/defaults.hpp b/src/common/defaults.hpp
new file mode 100644 (file)
index 0000000..61e2891
--- /dev/null
@@ -0,0 +1,427 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _DEFAULTS_H
+#define _DEFAULTS_H
+
+#include <pthread.h>
+#include <common/macros.hpp>
+
+/* Default unix group name for tracing. */
+#define DEFAULT_TRACING_GROUP                   "tracing"
+
+/*
+ * This value is defined in the CTF specification (see
+ * git://git.efficios.com/ctf.git in the file
+ * common-trace-format-specification.txt.
+ */
+#define DEFAULT_METADATA_NAME                   "metadata"
+
+/* Environment variable to set session daemon binary path. */
+#define DEFAULT_SESSIOND_PATH_ENV               "LTTNG_SESSIOND_PATH"
+
+/* Environment variable to set man pager binary path. */
+#define DEFAULT_MAN_BIN_PATH_ENV                "LTTNG_MAN_BIN_PATH"
+
+/* Default man pager binary path. */
+#define DEFAULT_MAN_BIN_PATH                    "/usr/bin/man"
+
+/* Default trace output directory name */
+#define DEFAULT_TRACE_DIR_NAME                  "lttng-traces"
+
+/* Default size of a hash table */
+#define DEFAULT_HT_SIZE                         4
+
+/* Default session daemon paths */
+#define DEFAULT_HOME_DIR                                               "/tmp"
+#define DEFAULT_UST_SOCK_DIR                    DEFAULT_HOME_DIR "/ust-app-socks"
+#define DEFAULT_GLOBAL_APPS_PIPE                DEFAULT_UST_SOCK_DIR "/global"
+#define DEFAULT_TRACE_OUTPUT                    DEFAULT_HOME_DIR "/lttng"
+
+/* Default directory where the trace are written in per domain */
+#define DEFAULT_KERNEL_TRACE_DIR                "kernel"
+#define DEFAULT_UST_TRACE_DIR                   "ust"
+
+/* Subpath for per PID or UID sessions. */
+#define DEFAULT_UST_TRACE_PID_PATH               "pid"
+#define DEFAULT_UST_TRACE_UID_PATH               "uid/%d/%u-bit"
+
+/*
+ * Default session name for the lttng command line. This default value will
+ * get the date and time appended (%Y%m%d-%H%M%S) to it.
+ */
+#define DEFAULT_SESSION_NAME                    "auto"
+
+/* Default consumer paths */
+#define DEFAULT_CONSUMERD_FILE                  "lttng-consumerd"
+
+/* Default consumer paths */
+#define DEFAULT_CONSUMERD_RUNDIR                "%s"
+
+/* Kernel consumer path */
+#define DEFAULT_KCONSUMERD_PATH                 DEFAULT_CONSUMERD_RUNDIR "/kconsumerd"
+#define DEFAULT_KCONSUMERD_CMD_SOCK_PATH        DEFAULT_KCONSUMERD_PATH "/command"
+#define DEFAULT_KCONSUMERD_ERR_SOCK_PATH        DEFAULT_KCONSUMERD_PATH "/error"
+
+/* UST 64-bit consumer path */
+#define DEFAULT_USTCONSUMERD64_PATH             DEFAULT_CONSUMERD_RUNDIR "/ustconsumerd64"
+#define DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH    DEFAULT_USTCONSUMERD64_PATH "/command"
+#define DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH    DEFAULT_USTCONSUMERD64_PATH "/error"
+
+/* UST 32-bit consumer path */
+#define DEFAULT_USTCONSUMERD32_PATH             DEFAULT_CONSUMERD_RUNDIR "/ustconsumerd32"
+#define DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH    DEFAULT_USTCONSUMERD32_PATH "/command"
+#define DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH    DEFAULT_USTCONSUMERD32_PATH "/error"
+
+/* Relayd path */
+#define DEFAULT_RELAYD_RUNDIR                  "%s"
+#define DEFAULT_RELAYD_PATH                    DEFAULT_RELAYD_RUNDIR "/relayd"
+
+#define DEFAULT_RELAYD_MIN_FD_POOL_SIZE                100
+/*
+ * The file descriptor pool size needs a reserve buffer to accommodates the
+ * indirect use of short-lived file descriptors. For instance, glibc will
+ * create a socket (and thus, use an fd) during calls to gethostname() or
+ * when querying the user's group. Other calls also probably make use of
+ * short-lived FDs.
+ *
+ * The theoritical maximal reserve corresponds to the number of threads as,
+ * in the worst case, they could all be making such calls.
+ *
+ * This value must be less than DEFAULT_RELAYD_MIN_FD_POOL_SIZE.
+ */
+#define DEFAULT_RELAYD_FD_POOL_SIZE_RESERVE    10
+
+/* Default lttng run directory */
+#define DEFAULT_LTTNG_HOME_ENV_VAR              "LTTNG_HOME"
+#define DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR    "HOME"
+#define DEFAULT_LTTNG_RUNDIR                    CONFIG_LTTNG_SYSTEM_RUNDIR
+#define DEFAULT_LTTNG_HOME_RUNDIR               "%s/.lttng"
+#define DEFAULT_LTTNG_SESSIOND_PIDFILE          "lttng-sessiond.pid"
+#define DEFAULT_LTTNG_SESSIOND_AGENTPORT_FILE   "agent.port"
+#define DEFAULT_LTTNG_SESSIOND_LOCKFILE         "lttng-sessiond.lck"
+
+/* Default probes list */
+#define DEFAULT_LTTNG_KMOD_PROBES              "LTTNG_KMOD_PROBES"
+
+/* Default extra probes list */
+#define DEFAULT_LTTNG_EXTRA_KMOD_PROBES                "LTTNG_EXTRA_KMOD_PROBES"
+
+/* Default unix socket path */
+#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK                DEFAULT_LTTNG_RUNDIR "/client-lttng-sessiond"
+#define DEFAULT_HOME_CLIENT_UNIX_SOCK                  DEFAULT_LTTNG_HOME_RUNDIR "/client-lttng-sessiond"
+#define DEFAULT_GLOBAL_HEALTH_UNIX_SOCK                DEFAULT_LTTNG_RUNDIR "/sessiond-health"
+#define DEFAULT_HOME_HEALTH_UNIX_SOCK                  DEFAULT_LTTNG_HOME_RUNDIR "/sessiond-health"
+#define DEFAULT_GLOBAL_NOTIFICATION_CHANNEL_UNIX_SOCK   DEFAULT_LTTNG_RUNDIR "/sessiond-notification"
+#define DEFAULT_HOME_NOTIFICATION_CHANNEL_UNIX_SOCK    DEFAULT_LTTNG_HOME_RUNDIR "/sessiond-notification"
+
+/* Default consumer health unix socket path */
+#define DEFAULT_GLOBAL_USTCONSUMER32_HEALTH_UNIX_SOCK  DEFAULT_LTTNG_RUNDIR "/ustconsumerd32/health"
+#define DEFAULT_HOME_USTCONSUMER32_HEALTH_UNIX_SOCK    DEFAULT_LTTNG_HOME_RUNDIR "/ustconsumerd32/health"
+#define DEFAULT_GLOBAL_USTCONSUMER64_HEALTH_UNIX_SOCK  DEFAULT_LTTNG_RUNDIR "/ustconsumerd64/health"
+#define DEFAULT_HOME_USTCONSUMER64_HEALTH_UNIX_SOCK    DEFAULT_LTTNG_HOME_RUNDIR "/ustconsumerd64/health"
+#define DEFAULT_GLOBAL_KCONSUMER_HEALTH_UNIX_SOCK      DEFAULT_LTTNG_RUNDIR "/kconsumerd/health"
+#define DEFAULT_HOME_KCONSUMER_HEALTH_UNIX_SOCK                DEFAULT_LTTNG_HOME_RUNDIR "/kconsumerd/health"
+
+/* Default relay health unix socket path */
+#define DEFAULT_GLOBAL_RELAY_HEALTH_UNIX_SOCK          DEFAULT_LTTNG_RUNDIR "/relayd/health-%d"
+#define DEFAULT_HOME_RELAY_HEALTH_UNIX_SOCK            DEFAULT_LTTNG_HOME_RUNDIR "/relayd/health-%d"
+
+/* Default daemon configuration file path */
+#define DEFAULT_SYSTEM_CONFIGPATH               CONFIG_LTTNG_SYSTEM_CONFIGDIR \
+       "/lttng"
+
+#define DEFAULT_DAEMON_CONFIG_FILE              "lttng.conf"
+#define DEFAULT_DAEMON_HOME_CONFIGPATH          DEFAULT_LTTNG_HOME_RUNDIR "/" \
+       DEFAULT_DAEMON_CONFIG_FILE
+#define DEFAULT_DAEMON_SYSTEM_CONFIGPATH        DEFAULT_SYSTEM_CONFIGPATH "/" \
+       DEFAULT_DAEMON_CONFIG_FILE
+
+/* Default session configuration file path */
+#define DEFAULT_SESSION_PATH                    "sessions"
+/* Auto load session in that directory. */
+#define DEFAULT_SESSION_CONFIG_AUTOLOAD         "auto"
+#define DEFAULT_SESSION_HOME_CONFIGPATH         DEFAULT_LTTNG_HOME_RUNDIR "/" \
+       DEFAULT_SESSION_PATH
+#define DEFAULT_SESSION_SYSTEM_CONFIGPATH       DEFAULT_SYSTEM_CONFIGPATH "/" \
+       DEFAULT_SESSION_PATH
+#define DEFAULT_SESSION_CONFIG_FILE_EXTENSION   ".lttng"
+#define DEFAULT_SESSION_CONFIG_XSD_FILENAME     "session.xsd"
+#define DEFAULT_SESSION_CONFIG_XSD_PATH         CONFIG_LTTNG_SYSTEM_DATADIR "/xml/lttng/"
+#define DEFAULT_SESSION_CONFIG_XSD_PATH_ENV     "LTTNG_SESSION_CONFIG_XSD_PATH"
+
+#define DEFAULT_GLOBAL_APPS_UNIX_SOCK \
+       DEFAULT_LTTNG_RUNDIR "/" LTTNG_UST_SOCK_FILENAME
+#define DEFAULT_HOME_APPS_UNIX_SOCK \
+       DEFAULT_LTTNG_HOME_RUNDIR "/" LTTNG_UST_SOCK_FILENAME
+#define DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH \
+       "/" LTTNG_UST_WAIT_FILENAME
+#define DEFAULT_HOME_APPS_WAIT_SHM_PATH \
+       DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH "-%d"
+
+/*
+ * Value taken from the hard limit allowed by the kernel when using setrlimit
+ * with RLIMIT_NOFILE on an Intel i7 CPU and Linux 3.0.3.
+ */
+#define DEFAULT_POLL_SIZE 65535
+
+/*
+ * Format is %s_%d respectively channel name and CPU number. Eigth bytes
+ * are added here to add space for the CPU number. I guess 2^8 CPUs is more
+ * than enough. We might end up with quantum computing in a cell phone when
+ * reaching this limit.
+ */
+#define DEFAULT_STREAM_NAME_LEN        LTTNG_SYMBOL_NAME_LEN + 8
+
+/* Default channel attributes */
+#define DEFAULT_CHANNEL_NAME            "channel0"
+/* Default JUL domain channel name. */
+#define DEFAULT_JUL_CHANNEL_NAME        "lttng_jul_channel"
+/* Default JUL tracepoint name. This is a wildcard for the JUL domain. */
+#define DEFAULT_JUL_EVENT_COMPONENT     "lttng_jul"
+#define DEFAULT_JUL_EVENT_NAME          DEFAULT_JUL_EVENT_COMPONENT ":*"
+
+/* Default log4j domain channel name. */
+#define DEFAULT_LOG4J_CHANNEL_NAME        "lttng_log4j_channel"
+/* Default log4j tracepoint name. This is a wildcard for the log4j domain. */
+#define DEFAULT_LOG4J_EVENT_COMPONENT     "lttng_log4j"
+#define DEFAULT_LOG4J_EVENT_NAME          DEFAULT_LOG4J_EVENT_COMPONENT ":*"
+
+/* Default Python domain channel name. */
+#define DEFAULT_PYTHON_CHANNEL_NAME       "lttng_python_channel"
+/* Default Python tracepoint name. This is a wildcard for the python domain. */
+#define DEFAULT_PYTHON_EVENT_COMPONENT    "lttng_python"
+#define DEFAULT_PYTHON_EVENT_NAME         DEFAULT_PYTHON_EVENT_COMPONENT ":*"
+
+#define DEFAULT_CHANNEL_OVERWRITE       -1
+#define DEFAULT_CHANNEL_TRACEFILE_SIZE  CONFIG_DEFAULT_CHANNEL_TRACEFILE_SIZE
+#define DEFAULT_CHANNEL_TRACEFILE_COUNT CONFIG_DEFAULT_CHANNEL_TRACEFILE_COUNT
+
+#define _DEFAULT_CHANNEL_SUBBUF_SIZE   CONFIG_DEFAULT_CHANNEL_SUBBUF_SIZE
+#define _DEFAULT_CHANNEL_OUTPUT                        LTTNG_EVENT_MMAP
+
+/* Metadata channel defaults. */
+#define DEFAULT_METADATA_SUBBUF_SIZE    CONFIG_DEFAULT_METADATA_SUBBUF_SIZE
+#define DEFAULT_METADATA_SUBBUF_NUM     CONFIG_DEFAULT_METADATA_SUBBUF_NUM
+#define DEFAULT_METADATA_CACHE_SIZE     CONFIG_DEFAULT_METADATA_CACHE_SIZE
+#define DEFAULT_METADATA_SWITCH_TIMER  0
+#define DEFAULT_METADATA_READ_TIMER    0
+#define DEFAULT_METADATA_OVERWRITE     0
+#define DEFAULT_METADATA_OUTPUT                LTTNG_EVENT_MMAP
+
+/* Kernel has different defaults */
+
+/* DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE must always be a power of 2 */
+#define DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE     CONFIG_DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE
+/*
+ * DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM must always be a power of 2.
+ * Update help manually if override.
+ */
+#define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM      CONFIG_DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM
+/* See lttng-kernel.h enum lttng_kernel_output for channel output */
+#define DEFAULT_KERNEL_CHANNEL_OUTPUT                  LTTNG_EVENT_SPLICE
+#define DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER    CONFIG_DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER
+#define DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER   CONFIG_DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER
+#define DEFAULT_KERNEL_CHANNEL_READ_TIMER      CONFIG_DEFAULT_KERNEL_CHANNEL_READ_TIMER
+#define DEFAULT_KERNEL_CHANNEL_LIVE_TIMER      CONFIG_DEFAULT_KERNEL_CHANNEL_LIVE_TIMER
+#define DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT        CONFIG_DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT
+
+/* User space defaults */
+
+/* Must be a power of 2 */
+#define DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE    CONFIG_DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE
+#define DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE    CONFIG_DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE
+/* Must be a power of 2. Update help manuall if override. */
+#define DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM     CONFIG_DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM
+#define DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM     CONFIG_DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM
+/* See lttng-ust.h enum lttng_ust_output */
+#define DEFAULT_UST_PID_CHANNEL_OUTPUT                 _DEFAULT_CHANNEL_OUTPUT
+#define DEFAULT_UST_UID_CHANNEL_OUTPUT                 _DEFAULT_CHANNEL_OUTPUT
+/* Timers in usec. */
+#define DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER   CONFIG_DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER
+#define DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER   CONFIG_DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER
+#define DEFAULT_UST_PID_CHANNEL_LIVE_TIMER     CONFIG_DEFAULT_UST_PID_CHANNEL_LIVE_TIMER
+#define DEFAULT_UST_UID_CHANNEL_LIVE_TIMER     CONFIG_DEFAULT_UST_UID_CHANNEL_LIVE_TIMER
+#define DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER  CONFIG_DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER
+#define DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER  CONFIG_DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER
+
+#define DEFAULT_UST_PID_CHANNEL_READ_TIMER      CONFIG_DEFAULT_UST_PID_CHANNEL_READ_TIMER
+#define DEFAULT_UST_UID_CHANNEL_READ_TIMER      CONFIG_DEFAULT_UST_UID_CHANNEL_READ_TIMER
+
+#define DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT       CONFIG_DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT
+#define DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT       CONFIG_DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT
+
+/*
+ * Default timeout value for the sem_timedwait() call. Blocking forever is not
+ * wanted so a timeout is used to control the data flow and not freeze the
+ * session daemon.
+ */
+#define DEFAULT_SEM_WAIT_TIMEOUT            30    /* in seconds */
+
+/* Default bind addresses for network services. */
+#define DEFAULT_NETWORK_CONTROL_BIND_ADDRESS    CONFIG_DEFAULT_NETWORK_CONTROL_BIND_ADDRESS
+#define DEFAULT_NETWORK_DATA_BIND_ADDRESS              CONFIG_DEFAULT_NETWORK_DATA_BIND_ADDRESS
+#define DEFAULT_NETWORK_VIEWER_BIND_ADDRESS     CONFIG_DEFAULT_NETWORK_VIEWER_BIND_ADDRESS
+#define DEFAULT_AGENT_BIND_ADDRESS              CONFIG_DEFAULT_AGENT_BIND_ADDRESS
+
+/* Default network ports for trace streaming support. */
+#define DEFAULT_NETWORK_CONTROL_PORT        CONFIG_DEFAULT_NETWORK_CONTROL_PORT
+#define DEFAULT_NETWORK_DATA_PORT           CONFIG_DEFAULT_NETWORK_DATA_PORT
+#define DEFAULT_NETWORK_VIEWER_PORT         CONFIG_DEFAULT_NETWORK_VIEWER_PORT
+
+/* Agent registration TCP port range. */
+#define DEFAULT_AGENT_TCP_PORT_RANGE_BEGIN  CONFIG_DEFAULT_AGENT_TCP_PORT_RANGE_BEGIN
+#define DEFAULT_AGENT_TCP_PORT_RANGE_END    CONFIG_DEFAULT_AGENT_TCP_PORT_RANGE_END
+
+/* Number of buckets in the event notifier error count map. */
+#define DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE CONFIG_DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE
+
+/*
+ * If a thread stalls for this amount of time, it will be considered bogus (bad
+ * health).
+ */
+#define DEFAULT_HEALTH_CHECK_DELTA_S        20
+#define DEFAULT_HEALTH_CHECK_DELTA_NS       0
+
+/*
+ * Wait period before retrying the lttng_data_pending command in the lttng
+ * stop command of liblttng-ctl.
+ */
+#define DEFAULT_DATA_AVAILABILITY_WAIT_TIME_US 200000  /* usec */
+
+/*
+ * Wait period before retrying the lttng_consumer_flushed_cache when
+ * the consumer receives metadata.
+ */
+#define DEFAULT_METADATA_AVAILABILITY_WAIT_TIME 200000  /* usec */
+
+/*
+ * The usual value for the maximum TCP SYN retries time and TCP FIN timeout is
+ * 180 and 60 seconds on most Linux system and the default value since kernel
+ * 2.2 thus using the highest value. See tcp(7) for more details.
+ */
+#define DEFAULT_INET_TCP_TIMEOUT                       180     /* sec */
+
+/* Maximum payload size for a control connection */
+
+#define DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE CONFIG_DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE
+
+/*
+ * Default receiving and sending timeout for an application socket.
+ */
+#define DEFAULT_APP_SOCKET_RW_TIMEOUT       CONFIG_DEFAULT_APP_SOCKET_RW_TIMEOUT
+#define DEFAULT_APP_SOCKET_TIMEOUT_ENV      "LTTNG_APP_SOCKET_TIMEOUT"
+
+#define DEFAULT_UST_STREAM_FD_NUM                      2 /* Number of fd per UST stream. */
+
+#define DEFAULT_SNAPSHOT_NAME                          "snapshot"
+#define DEFAULT_SNAPSHOT_MAX_SIZE                      0 /* Unlimited. */
+
+/* Suffix of an index file. */
+#define DEFAULT_INDEX_FILE_SUFFIX                      ".idx"
+#define DEFAULT_INDEX_DIR                                      "index"
+
+/* Default lttng command live timer value in usec. */
+#define DEFAULT_LTTNG_LIVE_TIMER                       CONFIG_DEFAULT_LTTNG_LIVE_TIMER
+
+/* Default runas worker name */
+#define DEFAULT_RUN_AS_WORKER_NAME                     "lttng-runas"
+
+/* Default LTTng MI XML namespace. */
+#define DEFAULT_LTTNG_MI_NAMESPACE             "https://lttng.org/xml/ns/lttng-mi"
+
+/* Default thread stack size; the default mandated by pthread_create(3) */
+#define DEFAULT_LTTNG_THREAD_STACK_SIZE                2097152
+
+/* Default maximal size of message notification channel message payloads. */
+#define DEFAULT_MAX_NOTIFICATION_CLIENT_MESSAGE_PAYLOAD_SIZE   65536
+
+/* Default maximal size of trace archive location. */
+#define DEFAULT_MAX_TRACE_ARCHIVE_LOCATION_PAYLOAD_SIZE                65536
+
+/* Default maximal size of message notification channel message payloads. */
+#define DEFAULT_CLIENT_MAX_QUEUED_NOTIFICATIONS_COUNT          100
+
+
+#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE"
+#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME"
+#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT"
+#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL"
+#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD"
+#define DEFAULT_LTTNG_RELAYD_DISALLOW_CLEAR_ENV "LTTNG_RELAYD_DISALLOW_CLEAR"
+
+#define DEFAULT_LTTNG_RELAYD_WORKING_DIRECTORY_ENV "LTTNG_RELAYD_WORKING_DIRECTORY"
+
+/*
+ * Name of the intermediate directory used to rename the trace chunk of a
+ * session's first rotation.
+ */
+#define DEFAULT_CHUNK_TMP_OLD_DIRECTORY                        ".tmp_old_chunk"
+#define DEFAULT_CHUNK_TMP_NEW_DIRECTORY                        ".tmp_new_chunk"
+#define DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY                "archives"
+#define DEFAULT_UNLINKED_FILES_DIRECTORY               ".unlinked"
+
+/*
+ * Default timer value in usec for the rotate pending polling check on the
+ * relay when a rotation has completed on the consumer.
+ */
+#define DEFAULT_ROTATE_PENDING_TIMER   CONFIG_DEFAULT_ROTATE_PENDING_TIMER
+
+/*
+ * Returns the default subbuf size.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+size_t default_get_channel_subbuf_size(void);
+
+/*
+ * Returns the default metadata subbuf size.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+size_t default_get_metadata_subbuf_size(void);
+
+/*
+ * Returns the default subbuf size for the kernel domain.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+size_t default_get_kernel_channel_subbuf_size(void);
+
+/*
+ * Returns the default subbuf size for the UST domain per PID.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+size_t default_get_ust_pid_channel_subbuf_size(void);
+
+/*
+ * Returns the default subbuf size for the UST domain per UID.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+size_t default_get_ust_uid_channel_subbuf_size(void);
+
+/*
+ * Get the default pthread_attr to use on thread creation.
+ *
+ * Some libc, such as musl, don't honor the limit set for the stack size and use
+ * their own empirically chosen static value. This function checks if the
+ * current stack size is smaller than the stack size limit and if so returns a
+ * pthread_attr_t pointer where the thread stack size is set to the soft stack
+ * size limit.
+ */
+pthread_attr_t *default_pthread_attr(void);
+
+#endif /* _DEFAULTS_H */
index fb088faca187751c50e7750bba9075365334dc67..2c39c66e1ac6e4459a2860e09bb833f9034ecf25 100644 (file)
@@ -5,8 +5,8 @@
  *
  */
 
-#include "lttng/domain-internal.h"
-#include "common/macros.h"
+#include "lttng/domain-internal.hpp"
+#include "common/macros.hpp"
 
 const char *lttng_domain_type_str(enum lttng_domain_type domain_type)
 {
index d723ffacb385094097508250b5d28a40e4c3991c..ddc691bb13e76f4e5d0472584f5568b83633f523 100644 (file)
@@ -5,7 +5,7 @@
  *
  */
 
-#include <common/dynamic-array.h>
+#include <common/dynamic-array.hpp>
 
 void lttng_dynamic_array_init(struct lttng_dynamic_array *array,
                size_t element_size,
diff --git a/src/common/dynamic-array.h b/src/common/dynamic-array.h
deleted file mode 100644 (file)
index 8b08186..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_DYNAMIC_ARRAY_H
-#define LTTNG_DYNAMIC_ARRAY_H
-
-#include <common/dynamic-buffer.h>
-
-typedef void (*lttng_dynamic_array_element_destructor)(void *element);
-typedef void (*lttng_dynamic_pointer_array_destructor)(void *ptr);
-
-struct lttng_dynamic_array {
-       struct lttng_dynamic_buffer buffer;
-       size_t element_size;
-       size_t size;
-       lttng_dynamic_array_element_destructor destructor;
-};
-
-struct lttng_dynamic_pointer_array {
-       struct lttng_dynamic_array array;
-};
-
-/*
- * Initialize a resizable array of fixed-size elements. This performs no
- * allocation and can't fail.
- */
-void lttng_dynamic_array_init(struct lttng_dynamic_array *array,
-               size_t element_size,
-               lttng_dynamic_array_element_destructor destructor);
-
-/*
- * Returns the number of elements in the dynamic array.
- */
-static inline
-size_t lttng_dynamic_array_get_count(
-               const struct lttng_dynamic_array *array)
-{
-       return array->size;
-}
-
-/*
- * Returns a pointer to the element. Mutating operations on the array invalidate
- * the returned pointer.
- */
-static inline
-void *lttng_dynamic_array_get_element(const struct lttng_dynamic_array *array,
-               size_t element_index)
-{
-       LTTNG_ASSERT(element_index < array->size);
-       return array->buffer.data + (element_index * array->element_size);
-}
-
-/*
- * Set the array's element count to new_element_count. Any added element will
- * be zeroed.
- *
- * Be careful to expand the array's element count _before_ calling out external
- * APIs (e.g. read(3)) which may populate the buffer as setting the element
- * count after will zero-out the result of the operation.
- *
- * Shrinking an array does not zero the old content. If the buffer may contain
- * sensititve information, it must be cleared manually _before_ changing the
- * size.
- *
- * NOTE: It is striclty _invalid_ to access memory after _size_, regardless
- *       of prior calls to set_capacity().
- */
-int lttng_dynamic_array_set_count(struct lttng_dynamic_array *array,
-               size_t new_element_count);
-
-/*
- * Add an element to the end of a dynamic array. The array's element count is
- * increased by one and its underlying capacity is adjusted automatically.
- *
- * element is a pointer to the element to add (copy) to the array.
- */
-int lttng_dynamic_array_add_element(struct lttng_dynamic_array *array,
-               const void *element);
-
-/*
- * Remove an element from the dynamic array. The array's element count is
- * decreased by one and the following elements are shifted to take its place
- * (when applicable).
- */
-int lttng_dynamic_array_remove_element(struct lttng_dynamic_array *array,
-               size_t element_index);
-
-/* Release any memory used by the dynamic array. */
-void lttng_dynamic_array_reset(struct lttng_dynamic_array *array);
-
-/* Remove all elements from the dynamic array. */
-void lttng_dynamic_array_clear(struct lttng_dynamic_array *array);
-
-/*
- * Specialization of lttng_dynamic_array for pointers. This utility
- * is built under the assumption that pointer sizes are equal
- * for all data types on supported architectures. Revisit this in the event
- * of a port to an Harvard architecture.
- */
-
-/*
- * Initialize a resizable array of fixed-size elements. This performs no
- * allocation and can't fail.
- */
-void lttng_dynamic_pointer_array_init(
-               struct lttng_dynamic_pointer_array *array,
-               lttng_dynamic_pointer_array_destructor destructor);
-
-/*
- * Returns the number of pointers in the dynamic pointer array.
- */
-static inline
-size_t lttng_dynamic_pointer_array_get_count(
-               const struct lttng_dynamic_pointer_array *array)
-{
-       return lttng_dynamic_array_get_count(&array->array);
-}
-
-/*
- * Returns the pointer at index `index`.
- */
-static inline
-void *lttng_dynamic_pointer_array_get_pointer(
-               const struct lttng_dynamic_pointer_array *array, size_t index)
-{
-       void **element = (void **) lttng_dynamic_array_get_element(&array->array, index);
-
-       return *element;
-}
-
-/*
- * Returns the pointer at index `index`, sets the array slot to NULL. Does not
- * run the destructor.
- */
-
-static inline
-void *lttng_dynamic_pointer_array_steal_pointer(
-               struct lttng_dynamic_pointer_array *array, size_t index)
-{
-       void **p_element = (void **) lttng_dynamic_array_get_element(&array->array, index);
-       void *element = *p_element;
-
-       *p_element = NULL;
-
-       return element;
-}
-
-/*
- * Add a pointer to the end of a dynamic pointer array. The array's element
- * count is increased by one and its underlying capacity is adjusted
- * automatically.
- */
-static inline
-int lttng_dynamic_pointer_array_add_pointer(
-               struct lttng_dynamic_pointer_array *array, void *pointer)
-{
-       return lttng_dynamic_array_add_element(&array->array, &pointer);
-}
-
-/*
- * Remove a pointer from a dynamic pointer array. The array's element
- * count is decreased by one and the following pointers are shifted to
- * take the place of the removed pointer (if applicable).
- */
-int lttng_dynamic_pointer_array_remove_pointer(
-               struct lttng_dynamic_pointer_array *array, size_t index);
-
-/* Release any memory used by the dynamic array. */
-void lttng_dynamic_pointer_array_reset(
-               struct lttng_dynamic_pointer_array *array);
-
-/* Remove all elements from the dynamic pointer array. */
-void lttng_dynamic_pointer_array_clear(
-               struct lttng_dynamic_pointer_array *array);
-
-#endif /* LTTNG_DYNAMIC_ARRAY_H */
diff --git a/src/common/dynamic-array.hpp b/src/common/dynamic-array.hpp
new file mode 100644 (file)
index 0000000..23f3a39
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_DYNAMIC_ARRAY_H
+#define LTTNG_DYNAMIC_ARRAY_H
+
+#include <common/dynamic-buffer.hpp>
+
+typedef void (*lttng_dynamic_array_element_destructor)(void *element);
+typedef void (*lttng_dynamic_pointer_array_destructor)(void *ptr);
+
+struct lttng_dynamic_array {
+       struct lttng_dynamic_buffer buffer;
+       size_t element_size;
+       size_t size;
+       lttng_dynamic_array_element_destructor destructor;
+};
+
+struct lttng_dynamic_pointer_array {
+       struct lttng_dynamic_array array;
+};
+
+/*
+ * Initialize a resizable array of fixed-size elements. This performs no
+ * allocation and can't fail.
+ */
+void lttng_dynamic_array_init(struct lttng_dynamic_array *array,
+               size_t element_size,
+               lttng_dynamic_array_element_destructor destructor);
+
+/*
+ * Returns the number of elements in the dynamic array.
+ */
+static inline
+size_t lttng_dynamic_array_get_count(
+               const struct lttng_dynamic_array *array)
+{
+       return array->size;
+}
+
+/*
+ * Returns a pointer to the element. Mutating operations on the array invalidate
+ * the returned pointer.
+ */
+static inline
+void *lttng_dynamic_array_get_element(const struct lttng_dynamic_array *array,
+               size_t element_index)
+{
+       LTTNG_ASSERT(element_index < array->size);
+       return array->buffer.data + (element_index * array->element_size);
+}
+
+/*
+ * Set the array's element count to new_element_count. Any added element will
+ * be zeroed.
+ *
+ * Be careful to expand the array's element count _before_ calling out external
+ * APIs (e.g. read(3)) which may populate the buffer as setting the element
+ * count after will zero-out the result of the operation.
+ *
+ * Shrinking an array does not zero the old content. If the buffer may contain
+ * sensititve information, it must be cleared manually _before_ changing the
+ * size.
+ *
+ * NOTE: It is striclty _invalid_ to access memory after _size_, regardless
+ *       of prior calls to set_capacity().
+ */
+int lttng_dynamic_array_set_count(struct lttng_dynamic_array *array,
+               size_t new_element_count);
+
+/*
+ * Add an element to the end of a dynamic array. The array's element count is
+ * increased by one and its underlying capacity is adjusted automatically.
+ *
+ * element is a pointer to the element to add (copy) to the array.
+ */
+int lttng_dynamic_array_add_element(struct lttng_dynamic_array *array,
+               const void *element);
+
+/*
+ * Remove an element from the dynamic array. The array's element count is
+ * decreased by one and the following elements are shifted to take its place
+ * (when applicable).
+ */
+int lttng_dynamic_array_remove_element(struct lttng_dynamic_array *array,
+               size_t element_index);
+
+/* Release any memory used by the dynamic array. */
+void lttng_dynamic_array_reset(struct lttng_dynamic_array *array);
+
+/* Remove all elements from the dynamic array. */
+void lttng_dynamic_array_clear(struct lttng_dynamic_array *array);
+
+/*
+ * Specialization of lttng_dynamic_array for pointers. This utility
+ * is built under the assumption that pointer sizes are equal
+ * for all data types on supported architectures. Revisit this in the event
+ * of a port to an Harvard architecture.
+ */
+
+/*
+ * Initialize a resizable array of fixed-size elements. This performs no
+ * allocation and can't fail.
+ */
+void lttng_dynamic_pointer_array_init(
+               struct lttng_dynamic_pointer_array *array,
+               lttng_dynamic_pointer_array_destructor destructor);
+
+/*
+ * Returns the number of pointers in the dynamic pointer array.
+ */
+static inline
+size_t lttng_dynamic_pointer_array_get_count(
+               const struct lttng_dynamic_pointer_array *array)
+{
+       return lttng_dynamic_array_get_count(&array->array);
+}
+
+/*
+ * Returns the pointer at index `index`.
+ */
+static inline
+void *lttng_dynamic_pointer_array_get_pointer(
+               const struct lttng_dynamic_pointer_array *array, size_t index)
+{
+       void **element = (void **) lttng_dynamic_array_get_element(&array->array, index);
+
+       return *element;
+}
+
+/*
+ * Returns the pointer at index `index`, sets the array slot to NULL. Does not
+ * run the destructor.
+ */
+
+static inline
+void *lttng_dynamic_pointer_array_steal_pointer(
+               struct lttng_dynamic_pointer_array *array, size_t index)
+{
+       void **p_element = (void **) lttng_dynamic_array_get_element(&array->array, index);
+       void *element = *p_element;
+
+       *p_element = NULL;
+
+       return element;
+}
+
+/*
+ * Add a pointer to the end of a dynamic pointer array. The array's element
+ * count is increased by one and its underlying capacity is adjusted
+ * automatically.
+ */
+static inline
+int lttng_dynamic_pointer_array_add_pointer(
+               struct lttng_dynamic_pointer_array *array, void *pointer)
+{
+       return lttng_dynamic_array_add_element(&array->array, &pointer);
+}
+
+/*
+ * Remove a pointer from a dynamic pointer array. The array's element
+ * count is decreased by one and the following pointers are shifted to
+ * take the place of the removed pointer (if applicable).
+ */
+int lttng_dynamic_pointer_array_remove_pointer(
+               struct lttng_dynamic_pointer_array *array, size_t index);
+
+/* Release any memory used by the dynamic array. */
+void lttng_dynamic_pointer_array_reset(
+               struct lttng_dynamic_pointer_array *array);
+
+/* Remove all elements from the dynamic pointer array. */
+void lttng_dynamic_pointer_array_clear(
+               struct lttng_dynamic_pointer_array *array);
+
+#endif /* LTTNG_DYNAMIC_ARRAY_H */
index 945434ca9d6f2fd10fe2f357bdfe61d3a8ae2191..a12e1485d02132b77b60d153062c1b06879d21d1 100644 (file)
@@ -5,9 +5,9 @@
  *
  */
 
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <common/utils.h>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
+#include <common/utils.hpp>
 
 /*
  * Round to (upper) power of two, val is returned if it already is a power of
diff --git a/src/common/dynamic-buffer.h b/src/common/dynamic-buffer.h
deleted file mode 100644 (file)
index 0e0dedc..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_DYNAMIC_BUFFER_H
-#define LTTNG_DYNAMIC_BUFFER_H
-
-#include <stddef.h>
-#include <stdint.h>
-#include <common/macros.h>
-
-struct lttng_buffer_view;
-
-struct lttng_dynamic_buffer {
-       char *data;
-       /* size is the buffer's currently used capacity. */
-       size_t size;
-       /*
-        * capacity shall not be accessed by users directly, it is meant for
-        * internal use only.
-        */
-       size_t _capacity;
-};
-
-/*
- * Initialize a dynamic buffer. This performs no allocation and is meant
- * to be used instead of memset or explicit initialization of the buffer.
- */
-void lttng_dynamic_buffer_init(struct lttng_dynamic_buffer *buffer);
-
-/*
- * Append the content of a raw memory buffer to the end of a dynamic buffer
- * (after its current "size"). The dynamic buffer's size is increased by
- * "len", and its capacity is adjusted automatically.
- */
-int lttng_dynamic_buffer_append(struct lttng_dynamic_buffer *buffer,
-               const void *buf, size_t len);
-
-/*
- * Performs the same action as lttng_dynamic_buffer_append(), but using another
- * dynamic buffer as the source buffer. The source buffer's size is used in lieu
- * of "len".
- */
-int lttng_dynamic_buffer_append_buffer(struct lttng_dynamic_buffer *dst_buffer,
-               const struct lttng_dynamic_buffer *src_buffer);
-
-/*
- * Performs the same action as lttng_dynamic_buffer_append(), but using a
- * buffer view as the source buffer. The source buffer's size is used in lieu
- * of "len".
- */
-int lttng_dynamic_buffer_append_view(struct lttng_dynamic_buffer *buffer,
-               const struct lttng_buffer_view *view);
-
-/*
- * Set the buffer's size to new_size. The capacity of the buffer will
- * be expanded (if necessary) to accommodates new_size. Areas acquired by
- * a size increase will be zeroed.
- *
- * Be careful to expand the buffer's size _before_ calling out external
- * APIs (e.g. read(3)) which may populate the buffer as setting the size
- * after will zero-out the result of the operation.
- *
- * Shrinking a buffer does not zero the old content. If the buffer may contain
- * sensititve information, it must be cleared manually _before_ changing the
- * size.
- *
- * NOTE: It is striclty _invalid_ to access memory after _size_, regardless
- *       of prior calls to set_capacity().
- */
-int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer *buffer,
-               size_t new_size);
-
-/*
- * Set the buffer's capacity to accommodates the new_capacity, allocating memory
- * as necessary. The buffer's content is preserved. Setting a buffer's capacity
- * is meant as a _hint_ to the underlying buffer and is only optimization; no
- * guarantee is offered that subsequent calls to append or set_size will succeed.
- *
- * If the current size > new_capacity, the operation will fail.
- */
-int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer,
-               size_t new_capacity);
-
-/* Release any memory used by the dynamic buffer. */
-void lttng_dynamic_buffer_reset(struct lttng_dynamic_buffer *buffer);
-
-/* Get the space left in the buffer before a new resize is needed. */
-size_t lttng_dynamic_buffer_get_capacity_left(
-               struct lttng_dynamic_buffer *buffer);
-
-#endif /* LTTNG_DYNAMIC_BUFFER_H */
diff --git a/src/common/dynamic-buffer.hpp b/src/common/dynamic-buffer.hpp
new file mode 100644 (file)
index 0000000..65b1575
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_DYNAMIC_BUFFER_H
+#define LTTNG_DYNAMIC_BUFFER_H
+
+#include <stddef.h>
+#include <stdint.h>
+#include <common/macros.hpp>
+
+struct lttng_buffer_view;
+
+struct lttng_dynamic_buffer {
+       char *data;
+       /* size is the buffer's currently used capacity. */
+       size_t size;
+       /*
+        * capacity shall not be accessed by users directly, it is meant for
+        * internal use only.
+        */
+       size_t _capacity;
+};
+
+/*
+ * Initialize a dynamic buffer. This performs no allocation and is meant
+ * to be used instead of memset or explicit initialization of the buffer.
+ */
+void lttng_dynamic_buffer_init(struct lttng_dynamic_buffer *buffer);
+
+/*
+ * Append the content of a raw memory buffer to the end of a dynamic buffer
+ * (after its current "size"). The dynamic buffer's size is increased by
+ * "len", and its capacity is adjusted automatically.
+ */
+int lttng_dynamic_buffer_append(struct lttng_dynamic_buffer *buffer,
+               const void *buf, size_t len);
+
+/*
+ * Performs the same action as lttng_dynamic_buffer_append(), but using another
+ * dynamic buffer as the source buffer. The source buffer's size is used in lieu
+ * of "len".
+ */
+int lttng_dynamic_buffer_append_buffer(struct lttng_dynamic_buffer *dst_buffer,
+               const struct lttng_dynamic_buffer *src_buffer);
+
+/*
+ * Performs the same action as lttng_dynamic_buffer_append(), but using a
+ * buffer view as the source buffer. The source buffer's size is used in lieu
+ * of "len".
+ */
+int lttng_dynamic_buffer_append_view(struct lttng_dynamic_buffer *buffer,
+               const struct lttng_buffer_view *view);
+
+/*
+ * Set the buffer's size to new_size. The capacity of the buffer will
+ * be expanded (if necessary) to accommodates new_size. Areas acquired by
+ * a size increase will be zeroed.
+ *
+ * Be careful to expand the buffer's size _before_ calling out external
+ * APIs (e.g. read(3)) which may populate the buffer as setting the size
+ * after will zero-out the result of the operation.
+ *
+ * Shrinking a buffer does not zero the old content. If the buffer may contain
+ * sensititve information, it must be cleared manually _before_ changing the
+ * size.
+ *
+ * NOTE: It is striclty _invalid_ to access memory after _size_, regardless
+ *       of prior calls to set_capacity().
+ */
+int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer *buffer,
+               size_t new_size);
+
+/*
+ * Set the buffer's capacity to accommodates the new_capacity, allocating memory
+ * as necessary. The buffer's content is preserved. Setting a buffer's capacity
+ * is meant as a _hint_ to the underlying buffer and is only optimization; no
+ * guarantee is offered that subsequent calls to append or set_size will succeed.
+ *
+ * If the current size > new_capacity, the operation will fail.
+ */
+int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer,
+               size_t new_capacity);
+
+/* Release any memory used by the dynamic buffer. */
+void lttng_dynamic_buffer_reset(struct lttng_dynamic_buffer *buffer);
+
+/* Get the space left in the buffer before a new resize is needed. */
+size_t lttng_dynamic_buffer_get_capacity_left(
+               struct lttng_dynamic_buffer *buffer);
+
+#endif /* LTTNG_DYNAMIC_BUFFER_H */
index 3a0bbadcbcbcb5af550c815f1543660c4a2083ff..52d3d22d315fabfdcbd711544e869520a4b48b22 100644 (file)
@@ -5,7 +5,7 @@
  *
  */
 
-#include <lttng/endpoint-internal.h>
+#include <lttng/endpoint-internal.hpp>
 
 static
 struct lttng_endpoint lttng_session_daemon_notification_endpoint_instance = {
index 8072b26bdcdcaef9f97c85f5c2b05339f3998736..b299966515dd4175e75f19aa5bce56eb74593940 100644 (file)
@@ -7,17 +7,17 @@
  *
  */
 
-#include <common/dynamic-array.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/list-internal.h>
-#include <lttng/action/path-internal.h>
-#include <lttng/error-query-internal.h>
+#include <common/dynamic-array.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/list-internal.hpp>
+#include <lttng/action/path-internal.hpp>
+#include <lttng/error-query-internal.hpp>
 #include <lttng/error-query.h>
-#include <lttng/trigger/trigger-internal.h>
+#include <lttng/trigger/trigger-internal.hpp>
 #include <stddef.h>
 
 struct lttng_error_query {
index 0ec467bcd7d282323a59ea4c2b275eeaa040f7d2..150d2e53fbfe75ef02517a766356eea7db809f7d 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#include <common/common.h>
-#include <common/thread.h>
-#include <common/compat/errno.h>
-#include <common/compat/getenv.h>
+#include <common/common.hpp>
+#include <common/thread.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/getenv.hpp>
 #include <lttng/lttng-error.h>
 
-#include "error.h"
+#include "error.hpp"
 
 /*
  * lttng_opt_abort_on_error: unset: -1, disabled: 0, enabled: 1.
diff --git a/src/common/error.h b/src/common/error.h
deleted file mode 100644 (file)
index b3e19c4..0000000
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _ERROR_H
-#define _ERROR_H
-
-#include <common/compat/errno.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdbool.h>
-#include <urcu/tls-compat.h>
-#include <common/compat/time.h>
-#include <common/string-utils/format.h>
-#include <common/macros.h>
-
-#ifndef _GNU_SOURCE
-#error "lttng-tools error.h needs _GNU_SOURCE"
-#endif
-
-#include <lttng/lttng-error.h>
-#include <common/compat/tid.h>
-
-/* Avoid conflict with Solaris <sys/regset.h> */
-#if defined(ERR) && defined(__sun__)
-#undef ERR
-#endif
-
-/* Stringify the expansion of a define */
-#define XSTR(d) STR(d)
-#define STR(s) #s
-
-/*
- * Contains the string of the log entry time. This is used as a thread local
- * storage so we don't race between thread and also avoid memory allocation
- * every time a log is fired.
- */
-struct log_time {
-       /* Format: 00:00:00.000000000 plus NULL byte. */
-       char str[19];
-};
-extern LTTNG_EXPORT  DECLARE_URCU_TLS(struct log_time, error_log_time);
-extern DECLARE_URCU_TLS(const char *, logger_thread_name);
-
-extern int lttng_opt_quiet;
-extern int lttng_opt_verbose;
-extern int lttng_opt_mi;
-
-/* Error type. */
-enum lttng_error_level {
-       PRINT_ERR =     0,
-       PRINT_BUG =     1,
-       PRINT_WARN =    2,
-       PRINT_MSG =     3,
-       PRINT_DBG =     4,
-       PRINT_DBG2 =    5,
-       PRINT_DBG3 =    6,
-};
-
-static inline bool __lttng_print_check_opt(enum lttng_error_level type)
-{
-       /* lttng_opt_mi and lttng_opt_quiet. */
-       switch (type) {
-       case PRINT_DBG3:
-       case PRINT_DBG2:
-       case PRINT_DBG:
-       case PRINT_MSG:
-               if (lttng_opt_mi) {
-                       return false;
-               }
-               /* Fall-through. */
-       case PRINT_WARN:
-       case PRINT_BUG:
-       case PRINT_ERR:
-               if (lttng_opt_quiet) {
-                       return false;
-               }
-       }
-
-       /* lttng_opt_verbose */
-       switch (type) {
-       case PRINT_DBG3:
-               if (lttng_opt_verbose < 3) {
-                       return false;
-               }
-               break;
-       case PRINT_DBG2:
-               if (lttng_opt_verbose < 2) {
-                       return false;
-               }
-               break;
-       case PRINT_DBG:
-               if (lttng_opt_verbose < 1) {
-                       return false;
-               }
-               break;
-       case PRINT_MSG:
-       case PRINT_WARN:
-       case PRINT_BUG:
-       case PRINT_ERR:
-               break;
-       }
-
-       return true;
-}
-
-C_LINKAGE void lttng_abort_on_error(void);
-
-static inline void __lttng_print_check_abort(enum lttng_error_level type)
-{
-       switch (type) {
-       case PRINT_DBG3:
-       case PRINT_DBG2:
-       case PRINT_DBG:
-       case PRINT_MSG:
-       case PRINT_WARN:
-               break;
-       case PRINT_BUG:
-       case PRINT_ERR:
-               lttng_abort_on_error();
-       }
-}
-
-/*
- * Macro for printing message depending on command line option and verbosity.
- *
- * Machine interface:
- * We use lttng_opt_mi to suppress all normal msg to stdout. We don't
- * want any nested msg to show up when printing mi to stdout(if it's the case).
- * All warnings and errors should be printed to stderr as normal.
- */
-#define __lttng_print(type, fmt, args...)                                              \
-       do {                                                                            \
-               if (__lttng_print_check_opt(type)) {                                    \
-                       fprintf((type) == PRINT_MSG ? stdout : stderr, fmt, ## args);   \
-               }                                                                       \
-               __lttng_print_check_abort(type);                                        \
-       } while (0)
-
-/* Three level of debug. Use -v, -vv or -vvv for the levels */
-#define _ERRMSG(msg, type, fmt, args...)                                \
-       do {                                                            \
-               if (caa_unlikely(__lttng_print_check_opt(type))) {      \
-                       char generic_name[MAX_INT_DEC_LEN(long) +       \
-                                         MAX_INT_DEC_LEN(long)];       \
-                                                                        \
-                       snprintf(generic_name, sizeof(generic_name),    \
-                                       "%ld/%ld", (long) getpid(),     \
-                                       (long) lttng_gettid());         \
-                                                                        \
-                       __lttng_print(type,                             \
-                                       msg " - %s [%s]: " fmt          \
-                                           " (in %s() at " __FILE__    \
-                                           ":" XSTR(__LINE__) ")\n",   \
-                                       log_add_time(),                 \
-                                       URCU_TLS(logger_thread_name) ?: \
-                                                       generic_name,   \
-                                       ##args, __func__);              \
-               }                                                       \
-       } while (0)
-
-#define _ERRMSG_NO_LOC(msg, type, fmt, args...)                          \
-       do {                                                             \
-               if (caa_unlikely(__lttng_print_check_opt(type))) {       \
-                       char generic_name[MAX_INT_DEC_LEN(long) +        \
-                                         MAX_INT_DEC_LEN(long)];        \
-                                                                         \
-                       snprintf(generic_name, sizeof(generic_name),     \
-                                       "%ld/%ld", (long) getpid(),      \
-                                       (long) lttng_gettid());          \
-                                                                         \
-                       __lttng_print(type, msg " - %s [%s]: " fmt "\n", \
-                                       log_add_time(),                  \
-                                       URCU_TLS(logger_thread_name) ?:  \
-                                                       generic_name,    \
-                                       ##args);                         \
-               }                                                        \
-       } while (0)
-
-#define MSG(fmt, args...) \
-       __lttng_print(PRINT_MSG, fmt "\n", ## args)
-#define _MSG(fmt, args...) \
-       __lttng_print(PRINT_MSG, fmt, ## args)
-#define ERR(fmt, args...) \
-       __lttng_print(PRINT_ERR, "Error: " fmt "\n", ## args)
-#define WARN(fmt, args...) \
-       __lttng_print(PRINT_WARN, "Warning: " fmt "\n", ## args)
-
-#define BUG(fmt, args...) _ERRMSG("BUG", PRINT_BUG, fmt, ## args)
-
-#define DBG(fmt, args...) _ERRMSG("DBG1", PRINT_DBG, fmt, ## args)
-#define DBG_NO_LOC(fmt, args...) _ERRMSG_NO_LOC("DBG1", PRINT_DBG, fmt, ## args)
-#define DBG2(fmt, args...) _ERRMSG("DBG2", PRINT_DBG2, fmt, ## args)
-#define DBG3(fmt, args...) _ERRMSG("DBG3", PRINT_DBG3, fmt, ## args)
-#define LOG(type, fmt, args...)                        \
-       do {                                    \
-               switch (type) {                 \
-               case PRINT_ERR:                 \
-                       ERR(fmt, ## args);      \
-                       break;                  \
-               case PRINT_WARN:                \
-                       WARN(fmt, ## args);     \
-                       break;                  \
-               case PRINT_BUG:                 \
-                       BUG(fmt, ## args);      \
-                       break;                  \
-               case PRINT_MSG:                 \
-                       MSG(fmt, ## args);      \
-                       break;                  \
-               case PRINT_DBG:                 \
-                       DBG(fmt, ## args);      \
-                       break;                  \
-               case PRINT_DBG2:                \
-                       DBG2(fmt, ## args);     \
-                       break;                  \
-               case PRINT_DBG3:                \
-                       DBG3(fmt, ## args);     \
-                       break;                  \
-               default:                        \
-                       abort();                \
-               }                               \
-       } while(0);
-
-#define _PERROR(fmt, args...) _ERRMSG("PERROR", PRINT_ERR, fmt, ## args)
-
-#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
-
-/*
- * Version using XSI strerror_r.
- */
-#define PERROR(call, args...)                                        \
-       do {                                                         \
-               char _perror_buf[200];                               \
-               strerror_r(errno, _perror_buf, sizeof(_perror_buf)); \
-               _PERROR(call ": %s", ##args, _perror_buf);           \
-       } while (0);
-#else
-/*
- * Version using GNU strerror_r, for linux with appropriate defines.
- */
-#define PERROR(call, args...)                                             \
-       do {                                                              \
-               char *_perror_buf;                                        \
-               char _perror_tmp[200];                                    \
-               _perror_buf = strerror_r(                                 \
-                               errno, _perror_tmp, sizeof(_perror_tmp)); \
-               _PERROR(call ": %s", ##args, _perror_buf);                \
-       } while (0);
-#endif
-
-const char *error_get_str(int32_t code);
-
-/*
- * Function that format the time and return the reference of log_time.str to
- * the caller. On error, an empty string is returned thus no time will be
- * printed in the log.
- */
-const char *log_add_time(void);
-
-/* Name must be a statically-allocated string. */
-void logger_set_thread_name(const char *name, bool set_pthread_name);
-
-#endif /* _ERROR_H */
diff --git a/src/common/error.hpp b/src/common/error.hpp
new file mode 100644 (file)
index 0000000..fdae1e7
--- /dev/null
@@ -0,0 +1,267 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _ERROR_H
+#define _ERROR_H
+
+#include <common/compat/errno.hpp>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdbool.h>
+#include <urcu/tls-compat.h>
+#include <common/compat/time.hpp>
+#include <common/string-utils/format.hpp>
+#include <common/macros.hpp>
+
+#ifndef _GNU_SOURCE
+#error "lttng-tools error.h needs _GNU_SOURCE"
+#endif
+
+#include <lttng/lttng-error.h>
+#include <common/compat/tid.hpp>
+
+/* Avoid conflict with Solaris <sys/regset.h> */
+#if defined(ERR) && defined(__sun__)
+#undef ERR
+#endif
+
+/* Stringify the expansion of a define */
+#define XSTR(d) STR(d)
+#define STR(s) #s
+
+/*
+ * Contains the string of the log entry time. This is used as a thread local
+ * storage so we don't race between thread and also avoid memory allocation
+ * every time a log is fired.
+ */
+struct log_time {
+       /* Format: 00:00:00.000000000 plus NULL byte. */
+       char str[19];
+};
+extern LTTNG_EXPORT  DECLARE_URCU_TLS(struct log_time, error_log_time);
+extern DECLARE_URCU_TLS(const char *, logger_thread_name);
+
+extern int lttng_opt_quiet;
+extern int lttng_opt_verbose;
+extern int lttng_opt_mi;
+
+/* Error type. */
+enum lttng_error_level {
+       PRINT_ERR =     0,
+       PRINT_BUG =     1,
+       PRINT_WARN =    2,
+       PRINT_MSG =     3,
+       PRINT_DBG =     4,
+       PRINT_DBG2 =    5,
+       PRINT_DBG3 =    6,
+};
+
+static inline bool __lttng_print_check_opt(enum lttng_error_level type)
+{
+       /* lttng_opt_mi and lttng_opt_quiet. */
+       switch (type) {
+       case PRINT_DBG3:
+       case PRINT_DBG2:
+       case PRINT_DBG:
+       case PRINT_MSG:
+               if (lttng_opt_mi) {
+                       return false;
+               }
+               /* Fall-through. */
+       case PRINT_WARN:
+       case PRINT_BUG:
+       case PRINT_ERR:
+               if (lttng_opt_quiet) {
+                       return false;
+               }
+       }
+
+       /* lttng_opt_verbose */
+       switch (type) {
+       case PRINT_DBG3:
+               if (lttng_opt_verbose < 3) {
+                       return false;
+               }
+               break;
+       case PRINT_DBG2:
+               if (lttng_opt_verbose < 2) {
+                       return false;
+               }
+               break;
+       case PRINT_DBG:
+               if (lttng_opt_verbose < 1) {
+                       return false;
+               }
+               break;
+       case PRINT_MSG:
+       case PRINT_WARN:
+       case PRINT_BUG:
+       case PRINT_ERR:
+               break;
+       }
+
+       return true;
+}
+
+C_LINKAGE void lttng_abort_on_error(void);
+
+static inline void __lttng_print_check_abort(enum lttng_error_level type)
+{
+       switch (type) {
+       case PRINT_DBG3:
+       case PRINT_DBG2:
+       case PRINT_DBG:
+       case PRINT_MSG:
+       case PRINT_WARN:
+               break;
+       case PRINT_BUG:
+       case PRINT_ERR:
+               lttng_abort_on_error();
+       }
+}
+
+/*
+ * Macro for printing message depending on command line option and verbosity.
+ *
+ * Machine interface:
+ * We use lttng_opt_mi to suppress all normal msg to stdout. We don't
+ * want any nested msg to show up when printing mi to stdout(if it's the case).
+ * All warnings and errors should be printed to stderr as normal.
+ */
+#define __lttng_print(type, fmt, args...)                                              \
+       do {                                                                            \
+               if (__lttng_print_check_opt(type)) {                                    \
+                       fprintf((type) == PRINT_MSG ? stdout : stderr, fmt, ## args);   \
+               }                                                                       \
+               __lttng_print_check_abort(type);                                        \
+       } while (0)
+
+/* Three level of debug. Use -v, -vv or -vvv for the levels */
+#define _ERRMSG(msg, type, fmt, args...)                                \
+       do {                                                            \
+               if (caa_unlikely(__lttng_print_check_opt(type))) {      \
+                       char generic_name[MAX_INT_DEC_LEN(long) +       \
+                                         MAX_INT_DEC_LEN(long)];       \
+                                                                        \
+                       snprintf(generic_name, sizeof(generic_name),    \
+                                       "%ld/%ld", (long) getpid(),     \
+                                       (long) lttng_gettid());         \
+                                                                        \
+                       __lttng_print(type,                             \
+                                       msg " - %s [%s]: " fmt          \
+                                           " (in %s() at " __FILE__    \
+                                           ":" XSTR(__LINE__) ")\n",   \
+                                       log_add_time(),                 \
+                                       URCU_TLS(logger_thread_name) ?: \
+                                                       generic_name,   \
+                                       ##args, __func__);              \
+               }                                                       \
+       } while (0)
+
+#define _ERRMSG_NO_LOC(msg, type, fmt, args...)                          \
+       do {                                                             \
+               if (caa_unlikely(__lttng_print_check_opt(type))) {       \
+                       char generic_name[MAX_INT_DEC_LEN(long) +        \
+                                         MAX_INT_DEC_LEN(long)];        \
+                                                                         \
+                       snprintf(generic_name, sizeof(generic_name),     \
+                                       "%ld/%ld", (long) getpid(),      \
+                                       (long) lttng_gettid());          \
+                                                                         \
+                       __lttng_print(type, msg " - %s [%s]: " fmt "\n", \
+                                       log_add_time(),                  \
+                                       URCU_TLS(logger_thread_name) ?:  \
+                                                       generic_name,    \
+                                       ##args);                         \
+               }                                                        \
+       } while (0)
+
+#define MSG(fmt, args...) \
+       __lttng_print(PRINT_MSG, fmt "\n", ## args)
+#define _MSG(fmt, args...) \
+       __lttng_print(PRINT_MSG, fmt, ## args)
+#define ERR(fmt, args...) \
+       __lttng_print(PRINT_ERR, "Error: " fmt "\n", ## args)
+#define WARN(fmt, args...) \
+       __lttng_print(PRINT_WARN, "Warning: " fmt "\n", ## args)
+
+#define BUG(fmt, args...) _ERRMSG("BUG", PRINT_BUG, fmt, ## args)
+
+#define DBG(fmt, args...) _ERRMSG("DBG1", PRINT_DBG, fmt, ## args)
+#define DBG_NO_LOC(fmt, args...) _ERRMSG_NO_LOC("DBG1", PRINT_DBG, fmt, ## args)
+#define DBG2(fmt, args...) _ERRMSG("DBG2", PRINT_DBG2, fmt, ## args)
+#define DBG3(fmt, args...) _ERRMSG("DBG3", PRINT_DBG3, fmt, ## args)
+#define LOG(type, fmt, args...)                        \
+       do {                                    \
+               switch (type) {                 \
+               case PRINT_ERR:                 \
+                       ERR(fmt, ## args);      \
+                       break;                  \
+               case PRINT_WARN:                \
+                       WARN(fmt, ## args);     \
+                       break;                  \
+               case PRINT_BUG:                 \
+                       BUG(fmt, ## args);      \
+                       break;                  \
+               case PRINT_MSG:                 \
+                       MSG(fmt, ## args);      \
+                       break;                  \
+               case PRINT_DBG:                 \
+                       DBG(fmt, ## args);      \
+                       break;                  \
+               case PRINT_DBG2:                \
+                       DBG2(fmt, ## args);     \
+                       break;                  \
+               case PRINT_DBG3:                \
+                       DBG3(fmt, ## args);     \
+                       break;                  \
+               default:                        \
+                       abort();                \
+               }                               \
+       } while(0);
+
+#define _PERROR(fmt, args...) _ERRMSG("PERROR", PRINT_ERR, fmt, ## args)
+
+#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
+
+/*
+ * Version using XSI strerror_r.
+ */
+#define PERROR(call, args...)                                        \
+       do {                                                         \
+               char _perror_buf[200];                               \
+               strerror_r(errno, _perror_buf, sizeof(_perror_buf)); \
+               _PERROR(call ": %s", ##args, _perror_buf);           \
+       } while (0);
+#else
+/*
+ * Version using GNU strerror_r, for linux with appropriate defines.
+ */
+#define PERROR(call, args...)                                             \
+       do {                                                              \
+               char *_perror_buf;                                        \
+               char _perror_tmp[200];                                    \
+               _perror_buf = strerror_r(                                 \
+                               errno, _perror_tmp, sizeof(_perror_tmp)); \
+               _PERROR(call ": %s", ##args, _perror_buf);                \
+       } while (0);
+#endif
+
+const char *error_get_str(int32_t code);
+
+/*
+ * Function that format the time and return the reference of log_time.str to
+ * the caller. On error, an empty string is returned thus no time will be
+ * printed in the log.
+ */
+const char *log_add_time(void);
+
+/* Name must be a statically-allocated string. */
+void logger_set_thread_name(const char *name, bool set_pthread_name);
+
+#endif /* _ERROR_H */
index 6b3e634947253812329f099770d2345f999622b1..a0fbc9dd905e1c247eedd3f16ae7837341158099 100644 (file)
@@ -5,14 +5,14 @@
  *
  */
 
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/evaluation-internal.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <lttng/condition/session-consumed-size-internal.h>
-#include <lttng/condition/session-rotation-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
-#include <common/macros.h>
-#include <common/error.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/evaluation-internal.hpp>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/session-consumed-size-internal.hpp>
+#include <lttng/condition/session-rotation-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
+#include <common/macros.hpp>
+#include <common/error.hpp>
 #include <stdbool.h>
 
 void lttng_evaluation_init(struct lttng_evaluation *evaluation,
index e80fb1d5df4d269627847bb0ccb74f7d246fb666..9306dbeee76571c0cb210b99f0360cf9b0f1464a 100644 (file)
 #define _LGPL_SOURCE
 #include <stddef.h>
 
-#include <common/bytecode/bytecode.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/event-expr-internal.h>
+#include <common/bytecode/bytecode.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/event-expr-internal.hpp>
 #include <lttng/event-expr.h>
 #include <stdio.h>
 
index 7572713137ae810b21eef141e7b57a370ea3907b..816017a2da77fe1e316fdf0f347c1bcfa0512df4 100644 (file)
@@ -13,9 +13,9 @@
 #include <stddef.h>
 #include <stdbool.h>
 
-#include <common/error.h>
-#include <common/macros.h>
-#include <lttng/event-field-value-internal.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <lttng/event-field-value-internal.hpp>
 
 static
 struct lttng_event_field_value *create_empty_field_val(
index 7e3f7248ee3a562448ebf0574443eee5048b834a..8c1b81dbd3ee77e1594a3663da4007ccb72f9ca3 100644 (file)
@@ -6,22 +6,22 @@
  *
  */
 
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/jul-logging-internal.h>
-#include <lttng/event-rule/kernel-kprobe-internal.h>
-#include <lttng/event-rule/kernel-syscall-internal.h>
-#include <lttng/event-rule/kernel-tracepoint-internal.h>
-#include <lttng/event-rule/kernel-uprobe-internal.h>
-#include <lttng/event-rule/log4j-logging-internal.h>
-#include <lttng/event-rule/python-logging-internal.h>
-#include <lttng/event-rule/user-tracepoint-internal.h>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/jul-logging-internal.hpp>
+#include <lttng/event-rule/kernel-kprobe-internal.hpp>
+#include <lttng/event-rule/kernel-syscall-internal.hpp>
+#include <lttng/event-rule/kernel-tracepoint-internal.hpp>
+#include <lttng/event-rule/kernel-uprobe-internal.hpp>
+#include <lttng/event-rule/log4j-logging-internal.hpp>
+#include <lttng/event-rule/python-logging-internal.hpp>
+#include <lttng/event-rule/user-tracepoint-internal.hpp>
 #include <stdbool.h>
 
 enum lttng_event_rule_type lttng_event_rule_get_type(
index 319a904a2f27d1a4d2f351882cf9b4905983cb3f..51cbdc0041857ed2894995124a02f0dc85bfb6da 100644 (file)
@@ -5,19 +5,19 @@
  *
  */
 
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <common/string-utils/string-utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/jul-logging-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/jul-logging-internal.hpp>
 #include <lttng/event.h>
 #include <lttng/log-level-rule.h>
 
index da87fd2b95eac68d3a4e0a5072e595115f97d5cf..628a051c30ce312ebd46f5389022aa80bccd5119 100644 (file)
@@ -5,21 +5,21 @@
  *
  */
 
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
 #include <ctype.h>
 #include <lttng/constant.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
 #include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/kernel-kprobe-internal.h>
-#include <lttng/kernel-probe-internal.h>
+#include <lttng/event-rule/kernel-kprobe-internal.hpp>
+#include <lttng/kernel-probe-internal.hpp>
 #include <lttng/kernel-probe.h>
 #include <stdio.h>
 
index 64ebe47fd1c7d874de4c556ee3724ad2af229734..815f99d9df0434a3dfac3f9ec96160c342116c32 100644 (file)
@@ -5,18 +5,18 @@
  *
  */
 
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <common/string-utils/string-utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-syscall-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-syscall-internal.hpp>
 
 #define IS_SYSCALL_EVENT_RULE(rule) \
        (lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL)
index 1b7fbe2a2350ca8d6e427ec4eb8137375bc083c7..e546de1f3d7539eb6bd65f7f2ceb1bb679477326 100644 (file)
@@ -5,19 +5,19 @@
  *
  */
 
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <common/string-utils/string-utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-tracepoint-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-tracepoint-internal.hpp>
 #include <lttng/event.h>
 
 #define IS_KERNEL_TRACEPOINT_EVENT_RULE(rule) \
index fe84f7cdad2680654fd695d0ad2441dfbe284696..1a42421d39c2f405632083c244752b5435e53d90 100644 (file)
@@ -5,18 +5,18 @@
  *
  */
 
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-uprobe-internal.h>
-#include <lttng/userspace-probe-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-uprobe-internal.hpp>
+#include <lttng/userspace-probe-internal.hpp>
 
 #define IS_UPROBE_EVENT_RULE(rule) \
        (lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE)
index 0bef6efab9ed37cff8ff82fa6b4b2c380d99c25f..937331a36a315a533be2c161b7e571c2ed7023a8 100644 (file)
@@ -5,19 +5,19 @@
  *
  */
 
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <common/string-utils/string-utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/log4j-logging-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/log4j-logging-internal.hpp>
 #include <lttng/event.h>
 #include <lttng/log-level-rule.h>
 
index 4389c8aafae0e23a8177e2c8be0e990b79298920..20b649648c13bb94bee1bab8b7cbdd3b4ee4e133 100644 (file)
@@ -5,19 +5,19 @@
  *
  */
 
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <common/string-utils/string-utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/python-logging-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/python-logging-internal.hpp>
 #include <lttng/event.h>
 #include <lttng/log-level-rule.h>
 
index d6d166685421e08affd1222c884679c2dd164b53..8932ca786c72c657ac11692c1de6d6228f3daa77 100644 (file)
@@ -5,19 +5,19 @@
  *
  */
 
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <common/string-utils/string-utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/user-tracepoint-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/user-tracepoint-internal.hpp>
 #include <lttng/event.h>
 #include <lttng/log-level-rule.h>
 
index 9cef3e9b9189829be10ca8eea0c300ac8be4fb4f..358d058411cf5ce862ff44815b59f52ff5aa4a0d 100644 (file)
@@ -5,22 +5,20 @@
  *
  */
 
-#include "common/compat/string.h"
-#include "common/macros.h"
-#include "lttng/lttng-error.h"
-#include <assert.h>
-#include <common/buffer-view.h>
-#include <common/dynamic-array.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/align.h>
+#include <common/align.hpp>
+#include <common/buffer-view.hpp>
+#include <common/compat/string.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
 #include <lttng/constant.h>
-#include <lttng/event-internal.h>
+#include <lttng/event-internal.hpp>
 #include <lttng/event.h>
-#include <lttng/userspace-probe-internal.h>
-#include <stdint.h>
-#include <string.h>
+#include <lttng/lttng-error.h>
+#include <lttng/userspace-probe-internal.hpp>
 
 struct event_list_element {
        struct lttng_event *event;
index d8b5b785d11679d25d045a08e4df0e93592c7072..7473f071789982ca1c169812ef6d109430269269 100644 (file)
@@ -8,8 +8,8 @@
 #include <unistd.h>
 #include <urcu/ref.h>
 
-#include "fd-handle.h"
-#include <common/error.h>
+#include "fd-handle.hpp"
+#include <common/error.hpp>
 
 struct fd_handle {
        struct urcu_ref ref;
diff --git a/src/common/fd-handle.h b/src/common/fd-handle.h
deleted file mode 100644 (file)
index dab9e2b..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef FD_HANDLE_H
-#define FD_HANDLE_H
-
-#include <common/macros.h>
-
-/*
- * Wrapper around a file descriptor providing reference counting semantics.
- *
- * An fd_handle will close() the underlying file descriptor when its reference
- * count reaches zero.
- */
-struct fd_handle;
-
-/* Create a file descriptor handle. */
-struct fd_handle *fd_handle_create(int fd);
-
-/* Acquire reference to a file descriptor handle. */
-void fd_handle_get(struct fd_handle *handle);
-
-/* Release reference to a file descriptor handle. */
-void fd_handle_put(struct fd_handle *handle);
-
-/*
- * Return the underlying file descriptor of a file descriptor handle.
- *
- * This function can't fail.
- */
-int fd_handle_get_fd(struct fd_handle *handle);
-
-/*
- * Obtain a copy of a file descriptor handle.
- *
- * On success, the caller becomes the sole owner of the returned file descriptor
- * handle. The underlying file descriptor is duplicated using dup(). Refer to
- * the system documentation for the semantics of dup() for this particular file
- * descriptor type.
- */
-struct fd_handle *fd_handle_copy(const struct fd_handle *handle);
-
-#endif /* FS_HANDLE_H */
diff --git a/src/common/fd-handle.hpp b/src/common/fd-handle.hpp
new file mode 100644 (file)
index 0000000..877e88a
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef FD_HANDLE_H
+#define FD_HANDLE_H
+
+#include <common/macros.hpp>
+
+/*
+ * Wrapper around a file descriptor providing reference counting semantics.
+ *
+ * An fd_handle will close() the underlying file descriptor when its reference
+ * count reaches zero.
+ */
+struct fd_handle;
+
+/* Create a file descriptor handle. */
+struct fd_handle *fd_handle_create(int fd);
+
+/* Acquire reference to a file descriptor handle. */
+void fd_handle_get(struct fd_handle *handle);
+
+/* Release reference to a file descriptor handle. */
+void fd_handle_put(struct fd_handle *handle);
+
+/*
+ * Return the underlying file descriptor of a file descriptor handle.
+ *
+ * This function can't fail.
+ */
+int fd_handle_get_fd(struct fd_handle *handle);
+
+/*
+ * Obtain a copy of a file descriptor handle.
+ *
+ * On success, the caller becomes the sole owner of the returned file descriptor
+ * handle. The underlying file descriptor is duplicated using dup(). Refer to
+ * the system documentation for the semantics of dup() for this particular file
+ * descriptor type.
+ */
+struct fd_handle *fd_handle_copy(const struct fd_handle *handle);
+
+#endif /* FS_HANDLE_H */
index 18071dbd488b77f5a4331598438b5dfc705c7c28..9c6f031b0b6dc6e4995dde7d72f50fc158c06824 100644 (file)
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/fs-handle-internal.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/optional.h>
-
-#include "fd-tracker.h"
-#include "inode.h"
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/fs-handle-internal.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+
+#include "fd-tracker.hpp"
+#include "inode.hpp"
 
 /* Tracker lock must be taken by the user. */
 #define TRACKED_COUNT(tracker)                                 \
diff --git a/src/common/fd-tracker/fd-tracker.h b/src/common/fd-tracker/fd-tracker.h
deleted file mode 100644 (file)
index 5c98107..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef FD_TRACKER_H
-#define FD_TRACKER_H
-
-#include <common/compat/directory-handle.h>
-#include <common/macros.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-struct fs_handle;
-struct fd_tracker;
-
-/*
- * Callback which returns a file descriptor to track through the fd
- * tracker. This callback must not make use of the fd_tracker as a deadlock
- * may occur.
- *
- * The int pointer argument is an output parameter that should be used to return
- * the advertised number of file descriptors.
- *
- * Must return zero on success. Negative values should map to a UNIX error code.
- */
-typedef int (*fd_open_cb)(void *, int *out_fds);
-
-/*
- * Callback to allow the user to close a now-untracked file descriptor. This
- * callback must not make use of the fd_tracker as a deadlock may occur.
- *
- * The callback can freely modify the in_fds argument as it is copied by the
- * fd_tracker before being used. The fd tracker assumes in_fds to be closed by
- * the time the callback returns.
- *
- * Must return zero on success. Negative values should map to a UNIX error code.
- */
-typedef int (*fd_close_cb)(void *, int *in_fds);
-
-/*
- * Set the maximal number of fds that the process should be allowed to open at
- * any given time. This function must be called before any other of this
- * interface.
- *
- * The unlinked_file_path is an absolute path (which does not need to exist)
- * under which unlinked files will be stored for as long as a reference to them
- * is held.
- */
-struct fd_tracker *fd_tracker_create(const char *unlinked_file_path,
-               unsigned int capacity);
-
-/* Returns an error if file descriptors are leaked. */
-int fd_tracker_destroy(struct fd_tracker *tracker);
-
-/*
- * Open a handle to a suspendable filesystem file descriptor.
- *
- * See OPEN(3) for an explanation of flags and mode. NULL is returned in case of
- * error and errno is left untouched. Note that passing NULL as mode will result
- * in open()'s default behaviour being used (using the process' umask).
- *
- * A fs_handle wraps a file descriptor created by OPEN(3). It is suspendable
- * meaning that the underlying file may be closed at any time unless the
- * handle is marked as being in-use (see fs_handle_get_fd() and
- * fs_handle_put_fd()).
- *
- * If the tracker opted to close the underlying file descriptor, it will
- * be restored to its last known state when it is obtained through
- * the fs_handle's fs_handle_get_fd() method.
- *
- * Note that a suspendable file descriptor can be closed by the fd tracker at
- * anytime when it is not in use. This means that the user should not rely on it
- * being safe to unlink the file. Moreover, concurent modifications to the file
- * (e.g. truncation) may react differently than if the file descriptor was kept
- * open.
- */
-struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
-               struct lttng_directory_handle *directory,
-               const char *path,
-               int flags,
-               mode_t *mode);
-
-/*
- * Open a tracked unsuspendable file descriptor.
- *
- * This function allows the fd tracker to keep track of unsuspendable
- * file descriptors. A callback, open, is passed to allow the tracker
- * to atomically reserve an entry for a given count of new file descriptors,
- * suspending file descriptors as needed, and invoke the provided callback
- * without ever exceeding the tracker's capacity.
- *
- * fd_count indicates the count of file descriptors that will be opened and
- * returned by the open callback. The storage location at out_fds is assumed
- * to be large enough to hold 'fd_count * sizeof(int)'.
- *
- * Names may be provided to allow easier debugging of file descriptor
- * exhaustions.
- *
- * The callback's return value is returned to the user. Additionally, two
- * negative tracker-specific codes may be returned:
- *   - ENOMEM: allocation of a new entry failed,
- *   - EMFILE: too many unsuspendable fds are opened and the tracker can't
- *             accommodates the request for a new unsuspendable entry.
- */
-int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker,
-               int *out_fds,
-               const char **names,
-               unsigned int fd_count,
-               fd_open_cb open,
-               void *data);
-
-/*
- * Close a tracked unsuspendable file descriptor.
- *
- * This function allows the fd tracker to keep track of unsuspendable
- * file descriptors. A callback, close, is passed to allow the tracker
- * to atomically release a file descriptor entry.
- *
- * Returns 0 if the close callback returned success. Returns the value returned
- * by the close callback if it is negative. Additionally, a tracker-specific
- * code may be returned:
- *   - EINVAL: a file descriptor was unknown to the tracker
- *
- * Closed fds are set to -1 in the fds array which, in the event of an error,
- * allows the user to know which file descriptors are no longer being tracked.
- */
-int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker,
-               int *fds,
-               unsigned int fd_count,
-               fd_close_cb close,
-               void *data);
-
-/*
- * Log the contents of the fd_tracker.
- */
-void fd_tracker_log(struct fd_tracker *tracker);
-
-#endif /* FD_TRACKER_H */
diff --git a/src/common/fd-tracker/fd-tracker.hpp b/src/common/fd-tracker/fd-tracker.hpp
new file mode 100644 (file)
index 0000000..a38c880
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef FD_TRACKER_H
+#define FD_TRACKER_H
+
+#include <common/compat/directory-handle.hpp>
+#include <common/macros.hpp>
+#include <stdint.h>
+#include <sys/types.h>
+
+struct fs_handle;
+struct fd_tracker;
+
+/*
+ * Callback which returns a file descriptor to track through the fd
+ * tracker. This callback must not make use of the fd_tracker as a deadlock
+ * may occur.
+ *
+ * The int pointer argument is an output parameter that should be used to return
+ * the advertised number of file descriptors.
+ *
+ * Must return zero on success. Negative values should map to a UNIX error code.
+ */
+typedef int (*fd_open_cb)(void *, int *out_fds);
+
+/*
+ * Callback to allow the user to close a now-untracked file descriptor. This
+ * callback must not make use of the fd_tracker as a deadlock may occur.
+ *
+ * The callback can freely modify the in_fds argument as it is copied by the
+ * fd_tracker before being used. The fd tracker assumes in_fds to be closed by
+ * the time the callback returns.
+ *
+ * Must return zero on success. Negative values should map to a UNIX error code.
+ */
+typedef int (*fd_close_cb)(void *, int *in_fds);
+
+/*
+ * Set the maximal number of fds that the process should be allowed to open at
+ * any given time. This function must be called before any other of this
+ * interface.
+ *
+ * The unlinked_file_path is an absolute path (which does not need to exist)
+ * under which unlinked files will be stored for as long as a reference to them
+ * is held.
+ */
+struct fd_tracker *fd_tracker_create(const char *unlinked_file_path,
+               unsigned int capacity);
+
+/* Returns an error if file descriptors are leaked. */
+int fd_tracker_destroy(struct fd_tracker *tracker);
+
+/*
+ * Open a handle to a suspendable filesystem file descriptor.
+ *
+ * See OPEN(3) for an explanation of flags and mode. NULL is returned in case of
+ * error and errno is left untouched. Note that passing NULL as mode will result
+ * in open()'s default behaviour being used (using the process' umask).
+ *
+ * A fs_handle wraps a file descriptor created by OPEN(3). It is suspendable
+ * meaning that the underlying file may be closed at any time unless the
+ * handle is marked as being in-use (see fs_handle_get_fd() and
+ * fs_handle_put_fd()).
+ *
+ * If the tracker opted to close the underlying file descriptor, it will
+ * be restored to its last known state when it is obtained through
+ * the fs_handle's fs_handle_get_fd() method.
+ *
+ * Note that a suspendable file descriptor can be closed by the fd tracker at
+ * anytime when it is not in use. This means that the user should not rely on it
+ * being safe to unlink the file. Moreover, concurent modifications to the file
+ * (e.g. truncation) may react differently than if the file descriptor was kept
+ * open.
+ */
+struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
+               struct lttng_directory_handle *directory,
+               const char *path,
+               int flags,
+               mode_t *mode);
+
+/*
+ * Open a tracked unsuspendable file descriptor.
+ *
+ * This function allows the fd tracker to keep track of unsuspendable
+ * file descriptors. A callback, open, is passed to allow the tracker
+ * to atomically reserve an entry for a given count of new file descriptors,
+ * suspending file descriptors as needed, and invoke the provided callback
+ * without ever exceeding the tracker's capacity.
+ *
+ * fd_count indicates the count of file descriptors that will be opened and
+ * returned by the open callback. The storage location at out_fds is assumed
+ * to be large enough to hold 'fd_count * sizeof(int)'.
+ *
+ * Names may be provided to allow easier debugging of file descriptor
+ * exhaustions.
+ *
+ * The callback's return value is returned to the user. Additionally, two
+ * negative tracker-specific codes may be returned:
+ *   - ENOMEM: allocation of a new entry failed,
+ *   - EMFILE: too many unsuspendable fds are opened and the tracker can't
+ *             accommodates the request for a new unsuspendable entry.
+ */
+int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker,
+               int *out_fds,
+               const char **names,
+               unsigned int fd_count,
+               fd_open_cb open,
+               void *data);
+
+/*
+ * Close a tracked unsuspendable file descriptor.
+ *
+ * This function allows the fd tracker to keep track of unsuspendable
+ * file descriptors. A callback, close, is passed to allow the tracker
+ * to atomically release a file descriptor entry.
+ *
+ * Returns 0 if the close callback returned success. Returns the value returned
+ * by the close callback if it is negative. Additionally, a tracker-specific
+ * code may be returned:
+ *   - EINVAL: a file descriptor was unknown to the tracker
+ *
+ * Closed fds are set to -1 in the fds array which, in the event of an error,
+ * allows the user to know which file descriptors are no longer being tracked.
+ */
+int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker,
+               int *fds,
+               unsigned int fd_count,
+               fd_close_cb close,
+               void *data);
+
+/*
+ * Log the contents of the fd_tracker.
+ */
+void fd_tracker_log(struct fd_tracker *tracker);
+
+#endif /* FD_TRACKER_H */
index 74f7062484a9b7fa58a4e84e44a7b003ef411d1c..b5cdcf1b27b583dd3e67f004db62ba214057281d 100644 (file)
@@ -5,13 +5,13 @@
  *
  */
 
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <common/string-utils/format.h>
-#include <common/utils.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <common/string-utils/format.hpp>
+#include <common/utils.hpp>
 #include <inttypes.h>
 #include <lttng/constant.h>
 #include <sys/stat.h>
@@ -21,7 +21,7 @@
 #include <urcu/rculfhash.h>
 #include <urcu/ref.h>
 
-#include "inode.h"
+#include "inode.hpp"
 
 struct inode_id {
        dev_t device;
diff --git a/src/common/fd-tracker/inode.h b/src/common/fd-tracker/inode.h
deleted file mode 100644 (file)
index 7e95c07..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef FD_TRACKER_INODE_H
-#define FD_TRACKER_INODE_H
-
-#include <common/compat/directory-handle.h>
-#include <stdbool.h>
-
-struct lttng_inode;
-struct lttng_inode_registry;
-struct lttng_unlinked_file_directory;
-struct lttng_directory_handle;
-
-/*
- * The unlinked file pool is protected by the fd-tracker's lock.
- *
- * NOTE: the unlinked file pool can use a single file desriptor when unlinked
- * files are present in the pool. This file descriptor is not accounted-for
- * by the fd-tracker. Users of the fd-tracker should account for this extra
- * file descriptor.
- */
-struct lttng_unlinked_file_pool *lttng_unlinked_file_pool_create(
-               const char *path);
-
-void lttng_unlinked_file_pool_destroy(
-               struct lttng_unlinked_file_pool *pool);
-
-/* The inode registry is protected by the fd-tracker's lock. */
-struct lttng_inode_registry *lttng_inode_registry_create(void);
-
-struct lttng_inode *lttng_inode_registry_get_inode(
-               struct lttng_inode_registry *registry,
-               struct lttng_directory_handle *handle,
-               const char *path,
-               int fd,
-               struct lttng_unlinked_file_pool *pool);
-
-void lttng_inode_registry_destroy(struct lttng_inode_registry *registry);
-
-void lttng_inode_borrow_location(struct lttng_inode *inode,
-               const struct lttng_directory_handle **out_directory_handle,
-               const char **out_path);
-
-/* Returns a new reference to the inode's location directory handle. */
-struct lttng_directory_handle *lttng_inode_get_location_directory_handle(
-               struct lttng_inode *inode);
-
-int lttng_inode_rename(struct lttng_inode *inode,
-               struct lttng_directory_handle *old_directory_handle,
-               const char *old_path,
-               struct lttng_directory_handle *new_directory_handle,
-               const char *new_path,
-               bool overwrite);
-
-int lttng_inode_unlink(struct lttng_inode *inode);
-
-void lttng_inode_put(struct lttng_inode *inode);
-
-#endif /* FD_TRACKER_INODE_H */
diff --git a/src/common/fd-tracker/inode.hpp b/src/common/fd-tracker/inode.hpp
new file mode 100644 (file)
index 0000000..d4cb282
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef FD_TRACKER_INODE_H
+#define FD_TRACKER_INODE_H
+
+#include <common/compat/directory-handle.hpp>
+#include <stdbool.h>
+
+struct lttng_inode;
+struct lttng_inode_registry;
+struct lttng_unlinked_file_directory;
+struct lttng_directory_handle;
+
+/*
+ * The unlinked file pool is protected by the fd-tracker's lock.
+ *
+ * NOTE: the unlinked file pool can use a single file desriptor when unlinked
+ * files are present in the pool. This file descriptor is not accounted-for
+ * by the fd-tracker. Users of the fd-tracker should account for this extra
+ * file descriptor.
+ */
+struct lttng_unlinked_file_pool *lttng_unlinked_file_pool_create(
+               const char *path);
+
+void lttng_unlinked_file_pool_destroy(
+               struct lttng_unlinked_file_pool *pool);
+
+/* The inode registry is protected by the fd-tracker's lock. */
+struct lttng_inode_registry *lttng_inode_registry_create(void);
+
+struct lttng_inode *lttng_inode_registry_get_inode(
+               struct lttng_inode_registry *registry,
+               struct lttng_directory_handle *handle,
+               const char *path,
+               int fd,
+               struct lttng_unlinked_file_pool *pool);
+
+void lttng_inode_registry_destroy(struct lttng_inode_registry *registry);
+
+void lttng_inode_borrow_location(struct lttng_inode *inode,
+               const struct lttng_directory_handle **out_directory_handle,
+               const char **out_path);
+
+/* Returns a new reference to the inode's location directory handle. */
+struct lttng_directory_handle *lttng_inode_get_location_directory_handle(
+               struct lttng_inode *inode);
+
+int lttng_inode_rename(struct lttng_inode *inode,
+               struct lttng_directory_handle *old_directory_handle,
+               const char *old_path,
+               struct lttng_directory_handle *new_directory_handle,
+               const char *new_path,
+               bool overwrite);
+
+int lttng_inode_unlink(struct lttng_inode *inode);
+
+void lttng_inode_put(struct lttng_inode *inode);
+
+#endif /* FD_TRACKER_INODE_H */
index 6ea088c03c49daac4a3ce57d63d03b9fda9484f5..8c04b07b2da1d2049f11ecc8f0dffda586a516f7 100644 (file)
@@ -5,9 +5,9 @@
  *
  */
 
-#include <common/compat/poll.h>
+#include <common/compat/poll.hpp>
 
-#include "utils.h"
+#include "utils.hpp"
 
 #ifdef HAVE_EPOLL
 
index 7690fe463de02473b5fbae9d76ae620be2d106cc..79da7ced6b14dde19faf553569940b68df7db6b8 100644 (file)
@@ -5,9 +5,9 @@
  *
  */
 
-#include <common/error.h>
-#include <common/fd-tracker/utils.h>
-#include <common/utils.h>
+#include <common/error.hpp>
+#include <common/fd-tracker/utils.hpp>
+#include <common/utils.hpp>
 #include <lttng/constant.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/common/fd-tracker/utils.h b/src/common/fd-tracker/utils.h
deleted file mode 100644 (file)
index 9c3d489..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef FD_TRACKER_UTILS_H
-#define FD_TRACKER_UTILS_H
-
-#include <common/compat/directory-handle.h>
-#include <common/fd-tracker/fd-tracker.h>
-#include <common/macros.h>
-
-struct lttng_poll_event;
-
-/*
- * Utility implementing a close_fd callback which receives one file descriptor
- * and closes it, returning close()'s return value.
- */
-int fd_tracker_util_close_fd(void *, int *fd);
-
-/*
- * Create a pipe and track its underlying fds.
- */
-int fd_tracker_util_pipe_open_cloexec(
-               struct fd_tracker *tracker, const char *name, int *pipe);
-int fd_tracker_util_pipe_close(struct fd_tracker *tracker, int *pipe);
-
-/*
- * Create a poll event and track its underlying fd, if applicable.
- */
-int fd_tracker_util_poll_create(struct fd_tracker *tracker,
-               const char *name,
-               struct lttng_poll_event *events,
-               int size,
-               int flags);
-int fd_tracker_util_poll_clean(
-               struct fd_tracker *tracker, struct lttng_poll_event *events);
-
-struct lttng_directory_handle *fd_tracker_create_directory_handle(
-               struct fd_tracker *tracker, const char *path);
-
-struct lttng_directory_handle *fd_tracker_create_directory_handle_from_handle(
-               struct fd_tracker *tracker,
-               struct lttng_directory_handle *handle,
-               const char *path);
-
-#endif /* FD_TRACKER_UTILS_H */
diff --git a/src/common/fd-tracker/utils.hpp b/src/common/fd-tracker/utils.hpp
new file mode 100644 (file)
index 0000000..064e09c
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef FD_TRACKER_UTILS_H
+#define FD_TRACKER_UTILS_H
+
+#include <common/compat/directory-handle.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
+#include <common/macros.hpp>
+
+struct lttng_poll_event;
+
+/*
+ * Utility implementing a close_fd callback which receives one file descriptor
+ * and closes it, returning close()'s return value.
+ */
+int fd_tracker_util_close_fd(void *, int *fd);
+
+/*
+ * Create a pipe and track its underlying fds.
+ */
+int fd_tracker_util_pipe_open_cloexec(
+               struct fd_tracker *tracker, const char *name, int *pipe);
+int fd_tracker_util_pipe_close(struct fd_tracker *tracker, int *pipe);
+
+/*
+ * Create a poll event and track its underlying fd, if applicable.
+ */
+int fd_tracker_util_poll_create(struct fd_tracker *tracker,
+               const char *name,
+               struct lttng_poll_event *events,
+               int size,
+               int flags);
+int fd_tracker_util_poll_clean(
+               struct fd_tracker *tracker, struct lttng_poll_event *events);
+
+struct lttng_directory_handle *fd_tracker_create_directory_handle(
+               struct fd_tracker *tracker, const char *path);
+
+struct lttng_directory_handle *fd_tracker_create_directory_handle_from_handle(
+               struct fd_tracker *tracker,
+               struct lttng_directory_handle *handle,
+               const char *path);
+
+#endif /* FD_TRACKER_UTILS_H */
index 75eb2c6ca38b30f243673cd9cbac0a214e79e559..5b8082fd48da905e3f95280201dfa682668e444e 100644 (file)
@@ -15,9 +15,9 @@
 #include <stdlib.h>
 #include <inttypes.h>
 
-#include <common/compat/errno.h>
-#include <common/bytecode/bytecode.h>
-#include <common/filter/filter-ast.h>
+#include <common/compat/errno.hpp>
+#include <common/bytecode/bytecode.hpp>
+#include <common/filter/filter-ast.hpp>
 #include <common/filter/filter-parser.hpp>
 
 /* For error.h */
index f74b6374bcea3dcbb4b1405361917a334e23591b..2bff02031f2b97d5220bf034af286f2e3e386682 100644 (file)
@@ -5,7 +5,7 @@
  *
  */
 
-#include "filter.h"
+#include "filter.hpp"
 #include <stddef.h>
 
 struct bytecode_symbol_iterator {
diff --git a/src/common/filter.h b/src/common/filter.h
deleted file mode 100644 (file)
index 305434b..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_COMMON_FILTER_H
-#define LTTNG_COMMON_FILTER_H
-
-#include <common/sessiond-comm/sessiond-comm.h>
-
-struct bytecode_symbol_iterator;
-
-/*
- * Create an iterator on a bytecode's symbols. The iterator points to the
- * first element after creation.
- */
-struct bytecode_symbol_iterator *bytecode_symbol_iterator_create(
-               struct lttng_bytecode *bytecode);
-
-/*
- * Advance iterator of one element.
- *
- * Returns 0 if a next element exists or a negative value at the end.
- */
-int bytecode_symbol_iterator_next(struct bytecode_symbol_iterator *it);
-
-int bytecode_symbol_iterator_get_type(struct bytecode_symbol_iterator *it);
-
-const char *bytecode_symbol_iterator_get_name(
-               struct bytecode_symbol_iterator *it);
-
-void bytecode_symbol_iterator_destroy(struct bytecode_symbol_iterator *it);
-
-#endif /* LTTNG_COMMON_FILTER_H */
diff --git a/src/common/filter.hpp b/src/common/filter.hpp
new file mode 100644 (file)
index 0000000..085d6d0
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_COMMON_FILTER_H
+#define LTTNG_COMMON_FILTER_H
+
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+struct bytecode_symbol_iterator;
+
+/*
+ * Create an iterator on a bytecode's symbols. The iterator points to the
+ * first element after creation.
+ */
+struct bytecode_symbol_iterator *bytecode_symbol_iterator_create(
+               struct lttng_bytecode *bytecode);
+
+/*
+ * Advance iterator of one element.
+ *
+ * Returns 0 if a next element exists or a negative value at the end.
+ */
+int bytecode_symbol_iterator_next(struct bytecode_symbol_iterator *it);
+
+int bytecode_symbol_iterator_get_type(struct bytecode_symbol_iterator *it);
+
+const char *bytecode_symbol_iterator_get_name(
+               struct bytecode_symbol_iterator *it);
+
+void bytecode_symbol_iterator_destroy(struct bytecode_symbol_iterator *it);
+
+#endif /* LTTNG_COMMON_FILTER_H */
diff --git a/src/common/filter/filter-ast.h b/src/common/filter/filter-ast.h
deleted file mode 100644 (file)
index 2b460b4..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-#ifndef _FILTER_AST_H
-#define _FILTER_AST_H
-
-/*
- * filter-ast.h
- *
- * LTTng filter AST
- *
- * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-/*
- * Note: filter-ast.h should be included before filter-parser.h.
- */
-
-#include <urcu/list.h>
-#include <stdio.h>
-#include <stdint.h>
-
-#define printf_debug(fmt, args...)                                     \
-       do {                                                            \
-               if (filter_parser_debug)                                \
-                       fprintf(stdout, "[debug] " fmt, ## args);       \
-       } while (0)
-
-// the parameter name (of the reentrant 'yyparse' function)
-// data is a pointer to a 'SParserParam' structure
-//#define YYPARSE_PARAM        parser_ctx
-
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
-typedef void* yyscan_t;
-#endif
-
-extern int filter_parser_debug;
-
-struct filter_node;
-struct filter_parser;
-
-enum node_type {
-       NODE_UNKNOWN = 0,
-       NODE_ROOT,
-
-       NODE_EXPRESSION,
-       NODE_OP,
-       NODE_UNARY_OP,
-
-       NR_NODE_TYPES,
-};
-
-enum op_type {
-       AST_OP_UNKNOWN = 0,
-       AST_OP_MUL,
-       AST_OP_DIV,
-       AST_OP_MOD,
-       AST_OP_PLUS,
-       AST_OP_MINUS,
-       AST_OP_BIT_RSHIFT,
-       AST_OP_BIT_LSHIFT,
-       AST_OP_AND,
-       AST_OP_OR,
-       AST_OP_BIT_AND,
-       AST_OP_BIT_OR,
-       AST_OP_BIT_XOR,
-
-       AST_OP_EQ,
-       AST_OP_NE,
-       AST_OP_GT,
-       AST_OP_LT,
-       AST_OP_GE,
-       AST_OP_LE,
-};
-
-enum unary_op_type {
-       AST_UNARY_UNKNOWN = 0,
-       AST_UNARY_PLUS,
-       AST_UNARY_MINUS,
-       AST_UNARY_NOT,
-       AST_UNARY_BIT_NOT,
-};
-
-enum ast_link_type {
-       AST_LINK_UNKNOWN = 0,
-       AST_LINK_DOT,
-       AST_LINK_RARROW,
-       AST_LINK_BRACKET,
-};
-
-enum ast_expt_type {
-       AST_EXP_UNKNOWN = 0,
-       AST_EXP_STRING,
-       AST_EXP_CONSTANT,
-       AST_EXP_FLOAT_CONSTANT,
-       AST_EXP_IDENTIFIER,
-       AST_EXP_GLOBAL_IDENTIFIER,
-       AST_EXP_NESTED,
-};
-
-struct filter_node {
-       /*
-        * Parent node is only set on demand by specific visitor.
-        */
-       struct filter_node *parent;
-       struct cds_list_head gc;
-
-       enum node_type type;
-       union {
-               struct {
-                       /* Avoid -Wextern-c-compat warning with clang++. */
-                       char unused;
-               } unknown;
-               struct {
-                       struct filter_node *child;
-               } root;
-               struct {
-                       enum ast_expt_type type;
-                       enum ast_link_type post_op;     /* reverse */
-                       enum ast_link_type pre_op;      /* forward */
-                       union {
-                               const char *string;
-                               uint64_t constant;
-                               double float_constant;
-                               const char *identifier;
-                               /*
-                                * child can be nested.
-                                */
-                               struct filter_node *child;
-                       } u;
-                       /* prev: backward dot/arrow chain (postfix expression) */
-                       struct filter_node *prev;
-                       /* next: forward dot/arrow chain, generated by a visitor. */
-                       struct filter_node *next;
-                       /* next_bracket: linked bracket chain (prefix expression) */
-                       struct filter_node *next_bracket;
-               } expression;
-               struct {
-                       enum op_type type;
-                       struct filter_node *lchild;
-                       struct filter_node *rchild;
-               } op;
-               struct {
-                       enum unary_op_type type;
-                       struct filter_node *child;
-               } unary_op;
-       } u;
-};
-
-struct filter_ast {
-       struct filter_node root;
-       struct cds_list_head allocated_nodes;
-};
-
-const char *node_type(struct filter_node *node);
-
-struct ir_op;
-
-struct filter_parser_ctx {
-       yyscan_t scanner;
-       struct filter_ast *ast;
-       struct cds_list_head allocated_strings;
-       struct ir_op *ir_root;
-       struct lttng_bytecode_alloc *bytecode;
-       struct lttng_bytecode_alloc *bytecode_reloc;
-};
-
-struct filter_parser_ctx *filter_parser_ctx_alloc(FILE *input);
-void filter_parser_ctx_free(struct filter_parser_ctx *parser_ctx);
-int filter_parser_ctx_append_ast(struct filter_parser_ctx *parser_ctx);
-int filter_parser_ctx_create_from_filter_expression(
-               const char *filter_expression, struct filter_parser_ctx **ctxp);
-
-static inline
-struct filter_ast *filter_parser_get_ast(struct filter_parser_ctx *parser_ctx)
-{
-       return parser_ctx->ast;
-}
-
-int filter_visitor_print_xml(struct filter_parser_ctx *ctx, FILE *stream,
-                       int indent);
-int filter_visitor_ir_generate(struct filter_parser_ctx *ctx);
-void filter_ir_free(struct filter_parser_ctx *ctx);
-int filter_visitor_bytecode_generate(struct filter_parser_ctx *ctx);
-void filter_bytecode_free(struct filter_parser_ctx *ctx);
-int filter_visitor_ir_check_binary_op_nesting(struct filter_parser_ctx *ctx);
-int filter_visitor_ir_check_binary_comparator(struct filter_parser_ctx *ctx);
-int filter_visitor_ir_validate_string(struct filter_parser_ctx *ctx);
-int filter_visitor_ir_normalize_glob_patterns(struct filter_parser_ctx *ctx);
-int filter_visitor_ir_validate_globbing(struct filter_parser_ctx *ctx);
-
-#endif /* _FILTER_AST_H */
diff --git a/src/common/filter/filter-ast.hpp b/src/common/filter/filter-ast.hpp
new file mode 100644 (file)
index 0000000..2b460b4
--- /dev/null
@@ -0,0 +1,193 @@
+#ifndef _FILTER_AST_H
+#define _FILTER_AST_H
+
+/*
+ * filter-ast.h
+ *
+ * LTTng filter AST
+ *
+ * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+/*
+ * Note: filter-ast.h should be included before filter-parser.h.
+ */
+
+#include <urcu/list.h>
+#include <stdio.h>
+#include <stdint.h>
+
+#define printf_debug(fmt, args...)                                     \
+       do {                                                            \
+               if (filter_parser_debug)                                \
+                       fprintf(stdout, "[debug] " fmt, ## args);       \
+       } while (0)
+
+// the parameter name (of the reentrant 'yyparse' function)
+// data is a pointer to a 'SParserParam' structure
+//#define YYPARSE_PARAM        parser_ctx
+
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+
+extern int filter_parser_debug;
+
+struct filter_node;
+struct filter_parser;
+
+enum node_type {
+       NODE_UNKNOWN = 0,
+       NODE_ROOT,
+
+       NODE_EXPRESSION,
+       NODE_OP,
+       NODE_UNARY_OP,
+
+       NR_NODE_TYPES,
+};
+
+enum op_type {
+       AST_OP_UNKNOWN = 0,
+       AST_OP_MUL,
+       AST_OP_DIV,
+       AST_OP_MOD,
+       AST_OP_PLUS,
+       AST_OP_MINUS,
+       AST_OP_BIT_RSHIFT,
+       AST_OP_BIT_LSHIFT,
+       AST_OP_AND,
+       AST_OP_OR,
+       AST_OP_BIT_AND,
+       AST_OP_BIT_OR,
+       AST_OP_BIT_XOR,
+
+       AST_OP_EQ,
+       AST_OP_NE,
+       AST_OP_GT,
+       AST_OP_LT,
+       AST_OP_GE,
+       AST_OP_LE,
+};
+
+enum unary_op_type {
+       AST_UNARY_UNKNOWN = 0,
+       AST_UNARY_PLUS,
+       AST_UNARY_MINUS,
+       AST_UNARY_NOT,
+       AST_UNARY_BIT_NOT,
+};
+
+enum ast_link_type {
+       AST_LINK_UNKNOWN = 0,
+       AST_LINK_DOT,
+       AST_LINK_RARROW,
+       AST_LINK_BRACKET,
+};
+
+enum ast_expt_type {
+       AST_EXP_UNKNOWN = 0,
+       AST_EXP_STRING,
+       AST_EXP_CONSTANT,
+       AST_EXP_FLOAT_CONSTANT,
+       AST_EXP_IDENTIFIER,
+       AST_EXP_GLOBAL_IDENTIFIER,
+       AST_EXP_NESTED,
+};
+
+struct filter_node {
+       /*
+        * Parent node is only set on demand by specific visitor.
+        */
+       struct filter_node *parent;
+       struct cds_list_head gc;
+
+       enum node_type type;
+       union {
+               struct {
+                       /* Avoid -Wextern-c-compat warning with clang++. */
+                       char unused;
+               } unknown;
+               struct {
+                       struct filter_node *child;
+               } root;
+               struct {
+                       enum ast_expt_type type;
+                       enum ast_link_type post_op;     /* reverse */
+                       enum ast_link_type pre_op;      /* forward */
+                       union {
+                               const char *string;
+                               uint64_t constant;
+                               double float_constant;
+                               const char *identifier;
+                               /*
+                                * child can be nested.
+                                */
+                               struct filter_node *child;
+                       } u;
+                       /* prev: backward dot/arrow chain (postfix expression) */
+                       struct filter_node *prev;
+                       /* next: forward dot/arrow chain, generated by a visitor. */
+                       struct filter_node *next;
+                       /* next_bracket: linked bracket chain (prefix expression) */
+                       struct filter_node *next_bracket;
+               } expression;
+               struct {
+                       enum op_type type;
+                       struct filter_node *lchild;
+                       struct filter_node *rchild;
+               } op;
+               struct {
+                       enum unary_op_type type;
+                       struct filter_node *child;
+               } unary_op;
+       } u;
+};
+
+struct filter_ast {
+       struct filter_node root;
+       struct cds_list_head allocated_nodes;
+};
+
+const char *node_type(struct filter_node *node);
+
+struct ir_op;
+
+struct filter_parser_ctx {
+       yyscan_t scanner;
+       struct filter_ast *ast;
+       struct cds_list_head allocated_strings;
+       struct ir_op *ir_root;
+       struct lttng_bytecode_alloc *bytecode;
+       struct lttng_bytecode_alloc *bytecode_reloc;
+};
+
+struct filter_parser_ctx *filter_parser_ctx_alloc(FILE *input);
+void filter_parser_ctx_free(struct filter_parser_ctx *parser_ctx);
+int filter_parser_ctx_append_ast(struct filter_parser_ctx *parser_ctx);
+int filter_parser_ctx_create_from_filter_expression(
+               const char *filter_expression, struct filter_parser_ctx **ctxp);
+
+static inline
+struct filter_ast *filter_parser_get_ast(struct filter_parser_ctx *parser_ctx)
+{
+       return parser_ctx->ast;
+}
+
+int filter_visitor_print_xml(struct filter_parser_ctx *ctx, FILE *stream,
+                       int indent);
+int filter_visitor_ir_generate(struct filter_parser_ctx *ctx);
+void filter_ir_free(struct filter_parser_ctx *ctx);
+int filter_visitor_bytecode_generate(struct filter_parser_ctx *ctx);
+void filter_bytecode_free(struct filter_parser_ctx *ctx);
+int filter_visitor_ir_check_binary_op_nesting(struct filter_parser_ctx *ctx);
+int filter_visitor_ir_check_binary_comparator(struct filter_parser_ctx *ctx);
+int filter_visitor_ir_validate_string(struct filter_parser_ctx *ctx);
+int filter_visitor_ir_normalize_glob_patterns(struct filter_parser_ctx *ctx);
+int filter_visitor_ir_validate_globbing(struct filter_parser_ctx *ctx);
+
+#endif /* _FILTER_AST_H */
diff --git a/src/common/filter/filter-ir.h b/src/common/filter/filter-ir.h
deleted file mode 100644 (file)
index 5775e80..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-#ifndef _FILTER_IR_H
-#define _FILTER_IR_H
-
-/*
- * filter-ir.h
- *
- * LTTng filter ir
- *
- * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include "filter-ast.h"
-
-enum ir_op_signedness {
-       IR_SIGN_UNKNOWN = 0,
-       IR_SIGNED,
-       IR_UNSIGNED,
-       IR_SIGN_DYN,            /* signedness determined dynamically */
-};
-
-enum ir_data_type {
-       IR_DATA_UNKNOWN = 0,
-       IR_DATA_STRING,
-       IR_DATA_NUMERIC,        /* numeric and boolean */
-       IR_DATA_FLOAT,
-       IR_DATA_FIELD_REF,
-       IR_DATA_GET_CONTEXT_REF,
-       IR_DATA_EXPRESSION,
-};
-
-static inline
-const char *ir_data_type_str(enum ir_data_type type)
-{
-       switch (type) {
-       case IR_DATA_UNKNOWN:
-               return "IR_DATA_UNKNOWN";
-       case IR_DATA_STRING:
-               return "IR_DATA_STRING";
-       case IR_DATA_NUMERIC:
-               return "IR_DATA_NUMERIC";
-       case IR_DATA_FLOAT:
-               return "IR_DATA_FLOAT";
-       case IR_DATA_FIELD_REF:
-               return "IR_DATA_FIELD_REF";
-       case IR_DATA_GET_CONTEXT_REF:
-               return "IR_DATA_GET_CONTEXT_REF";
-       case IR_DATA_EXPRESSION:
-               return "IR_DATA_EXPRESSION";
-       default:
-               abort();
-       }
-}
-
-enum ir_op_type {
-       IR_OP_UNKNOWN = 0,
-       IR_OP_ROOT,
-       IR_OP_LOAD,
-       IR_OP_UNARY,
-       IR_OP_BINARY,
-       IR_OP_LOGICAL,
-};
-
-static inline
-const char *ir_op_type_str(enum ir_op_type type)
-{
-       switch (type) {
-       case IR_OP_UNKNOWN:
-               return "IR_OP_UNKNOWN";
-       case IR_OP_ROOT:
-               return "IR_OP_ROOT";
-       case IR_OP_LOAD:
-               return "IR_OP_LOAD";
-       case IR_OP_UNARY:
-               return "IR_OP_UNARY";
-       case IR_OP_BINARY:
-               return "IR_OP_BINARY";
-       case IR_OP_LOGICAL:
-               return "IR_OP_LOGICAL";
-       default:
-               abort();
-       }
-}
-
-/* left or right child */
-enum ir_side {
-       IR_SIDE_UNKNOWN = 0,
-       IR_LEFT,
-       IR_RIGHT,
-};
-
-enum ir_load_string_type {
-       /* Plain, no globbing at all: `hello world`. */
-       IR_LOAD_STRING_TYPE_PLAIN = 0,
-
-       /* Star at the end only: `hello *`. */
-       IR_LOAD_STRING_TYPE_GLOB_STAR_END,
-
-       /* At least one star, anywhere, but not at the end only: `he*wor*`. */
-       IR_LOAD_STRING_TYPE_GLOB_STAR,
-};
-
-struct ir_op_root {
-       struct ir_op *child;
-};
-
-enum ir_load_expression_type {
-       IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT,
-       IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT,
-       IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT,
-       IR_LOAD_EXPRESSION_GET_SYMBOL,
-       IR_LOAD_EXPRESSION_GET_INDEX,
-       IR_LOAD_EXPRESSION_LOAD_FIELD,
-};
-
-static inline
-const char *ir_load_expression_type_str(enum ir_load_expression_type type)
-{
-       switch (type) {
-       case IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT:
-               return "IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT";
-       case IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT:
-               return "IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT";
-       case IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT:
-               return "IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT";
-       case IR_LOAD_EXPRESSION_GET_SYMBOL:
-               return "IR_LOAD_EXPRESSION_GET_SYMBOL";
-       case IR_LOAD_EXPRESSION_GET_INDEX:
-               return "IR_LOAD_EXPRESSION_GET_INDEX";
-       case IR_LOAD_EXPRESSION_LOAD_FIELD:
-               return "IR_LOAD_EXPRESSION_LOAD_FIELD";
-       default:
-               abort();
-       }
-}
-
-struct ir_load_expression_op {
-       struct ir_load_expression_op *next;
-       enum ir_load_expression_type type;
-       union {
-               char *symbol;
-               uint64_t index;
-       } u;
-};
-
-struct ir_load_expression {
-       struct ir_load_expression_op *child;
-};
-
-struct ir_op_load {
-       union {
-               struct {
-                       enum ir_load_string_type type;
-                       char *value;
-               } string;
-               int64_t num;
-               double flt;
-               char *ref;
-               struct ir_load_expression *expression;
-       } u;
-};
-
-struct ir_op_unary {
-       enum unary_op_type type;
-       struct ir_op *child;
-};
-
-struct ir_op_binary {
-       enum op_type type;
-       struct ir_op *left;
-       struct ir_op *right;
-};
-
-struct ir_op_logical {
-       enum op_type type;
-       struct ir_op *left;
-       struct ir_op *right;
-};
-
-struct ir_op {
-       /* common to all ops */
-       enum ir_op_type op;
-       enum ir_data_type data_type;
-       enum ir_op_signedness signedness;
-       enum ir_side side;
-
-       union {
-               struct ir_op_root root;
-               struct ir_op_load load;
-               struct ir_op_unary unary;
-               struct ir_op_binary binary;
-               struct ir_op_logical logical;
-       } u;
-};
-
-#endif /* _FILTER_IR_H */
diff --git a/src/common/filter/filter-ir.hpp b/src/common/filter/filter-ir.hpp
new file mode 100644 (file)
index 0000000..068d3aa
--- /dev/null
@@ -0,0 +1,198 @@
+#ifndef _FILTER_IR_H
+#define _FILTER_IR_H
+
+/*
+ * filter-ir.h
+ *
+ * LTTng filter ir
+ *
+ * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include "filter-ast.hpp"
+
+enum ir_op_signedness {
+       IR_SIGN_UNKNOWN = 0,
+       IR_SIGNED,
+       IR_UNSIGNED,
+       IR_SIGN_DYN,            /* signedness determined dynamically */
+};
+
+enum ir_data_type {
+       IR_DATA_UNKNOWN = 0,
+       IR_DATA_STRING,
+       IR_DATA_NUMERIC,        /* numeric and boolean */
+       IR_DATA_FLOAT,
+       IR_DATA_FIELD_REF,
+       IR_DATA_GET_CONTEXT_REF,
+       IR_DATA_EXPRESSION,
+};
+
+static inline
+const char *ir_data_type_str(enum ir_data_type type)
+{
+       switch (type) {
+       case IR_DATA_UNKNOWN:
+               return "IR_DATA_UNKNOWN";
+       case IR_DATA_STRING:
+               return "IR_DATA_STRING";
+       case IR_DATA_NUMERIC:
+               return "IR_DATA_NUMERIC";
+       case IR_DATA_FLOAT:
+               return "IR_DATA_FLOAT";
+       case IR_DATA_FIELD_REF:
+               return "IR_DATA_FIELD_REF";
+       case IR_DATA_GET_CONTEXT_REF:
+               return "IR_DATA_GET_CONTEXT_REF";
+       case IR_DATA_EXPRESSION:
+               return "IR_DATA_EXPRESSION";
+       default:
+               abort();
+       }
+}
+
+enum ir_op_type {
+       IR_OP_UNKNOWN = 0,
+       IR_OP_ROOT,
+       IR_OP_LOAD,
+       IR_OP_UNARY,
+       IR_OP_BINARY,
+       IR_OP_LOGICAL,
+};
+
+static inline
+const char *ir_op_type_str(enum ir_op_type type)
+{
+       switch (type) {
+       case IR_OP_UNKNOWN:
+               return "IR_OP_UNKNOWN";
+       case IR_OP_ROOT:
+               return "IR_OP_ROOT";
+       case IR_OP_LOAD:
+               return "IR_OP_LOAD";
+       case IR_OP_UNARY:
+               return "IR_OP_UNARY";
+       case IR_OP_BINARY:
+               return "IR_OP_BINARY";
+       case IR_OP_LOGICAL:
+               return "IR_OP_LOGICAL";
+       default:
+               abort();
+       }
+}
+
+/* left or right child */
+enum ir_side {
+       IR_SIDE_UNKNOWN = 0,
+       IR_LEFT,
+       IR_RIGHT,
+};
+
+enum ir_load_string_type {
+       /* Plain, no globbing at all: `hello world`. */
+       IR_LOAD_STRING_TYPE_PLAIN = 0,
+
+       /* Star at the end only: `hello *`. */
+       IR_LOAD_STRING_TYPE_GLOB_STAR_END,
+
+       /* At least one star, anywhere, but not at the end only: `he*wor*`. */
+       IR_LOAD_STRING_TYPE_GLOB_STAR,
+};
+
+struct ir_op_root {
+       struct ir_op *child;
+};
+
+enum ir_load_expression_type {
+       IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT,
+       IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT,
+       IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT,
+       IR_LOAD_EXPRESSION_GET_SYMBOL,
+       IR_LOAD_EXPRESSION_GET_INDEX,
+       IR_LOAD_EXPRESSION_LOAD_FIELD,
+};
+
+static inline
+const char *ir_load_expression_type_str(enum ir_load_expression_type type)
+{
+       switch (type) {
+       case IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT:
+               return "IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT";
+       case IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT:
+               return "IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT";
+       case IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT:
+               return "IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT";
+       case IR_LOAD_EXPRESSION_GET_SYMBOL:
+               return "IR_LOAD_EXPRESSION_GET_SYMBOL";
+       case IR_LOAD_EXPRESSION_GET_INDEX:
+               return "IR_LOAD_EXPRESSION_GET_INDEX";
+       case IR_LOAD_EXPRESSION_LOAD_FIELD:
+               return "IR_LOAD_EXPRESSION_LOAD_FIELD";
+       default:
+               abort();
+       }
+}
+
+struct ir_load_expression_op {
+       struct ir_load_expression_op *next;
+       enum ir_load_expression_type type;
+       union {
+               char *symbol;
+               uint64_t index;
+       } u;
+};
+
+struct ir_load_expression {
+       struct ir_load_expression_op *child;
+};
+
+struct ir_op_load {
+       union {
+               struct {
+                       enum ir_load_string_type type;
+                       char *value;
+               } string;
+               int64_t num;
+               double flt;
+               char *ref;
+               struct ir_load_expression *expression;
+       } u;
+};
+
+struct ir_op_unary {
+       enum unary_op_type type;
+       struct ir_op *child;
+};
+
+struct ir_op_binary {
+       enum op_type type;
+       struct ir_op *left;
+       struct ir_op *right;
+};
+
+struct ir_op_logical {
+       enum op_type type;
+       struct ir_op *left;
+       struct ir_op *right;
+};
+
+struct ir_op {
+       /* common to all ops */
+       enum ir_op_type op;
+       enum ir_data_type data_type;
+       enum ir_op_signedness signedness;
+       enum ir_side side;
+
+       union {
+               struct ir_op_root root;
+               struct ir_op_load load;
+               struct ir_op_unary unary;
+               struct ir_op_binary binary;
+               struct ir_op_logical logical;
+       } u;
+};
+
+#endif /* _FILTER_IR_H */
index acd4c0be82eb33ae550b21b376538b636cecb26c..12164af0174306ad716b5231767e6a82df1217b7 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #include <stdio.h>
-#include "filter-ast.h"
+#include "filter-ast.hpp"
 #include "filter-parser.hpp"
 #include <lttng/lttng-export.h>
 %}
index d654ecc84ab7ac539925d4973d50027172d1ece8..89f6b43d911f7de5a17db2dd25dadfb2aaf74262 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include <inttypes.h>
-#include "common/bytecode/bytecode.h"
-#include "filter-ast.h"
+#include "common/bytecode/bytecode.hpp"
+#include "filter-ast.hpp"
 #include "filter-parser.hpp"
-#include "memstream.h"
+#include "memstream.hpp"
 
-#include <common/compat/errno.h>
-#include <common/macros.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
 
 #define WIDTH_u64_SCANF_IS_A_BROKEN_API        "20"
 #define WIDTH_o64_SCANF_IS_A_BROKEN_API        "22"
@@ -428,7 +428,7 @@ error:
 
 %code provides
 {
-#include "common/macros.h"
+#include "common/macros.hpp"
 
 void setstring(struct filter_parser_ctx *parser_ctx, YYSTYPE *lvalp, const char *src);
 }
diff --git a/src/common/filter/filter-symbols.h b/src/common/filter/filter-symbols.h
deleted file mode 100644 (file)
index 27aaada..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef _FILTER_SYMBOLS_H
-#define _FILTER_SYMBOLS_H
-
-/*
- * filter-symbols.h
- *
- * LTTng filter flex/bison symbol prefixes
- *
- * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#define yy_create_buffer lttng_filter_yy_create_buffer
-#define yy_delete_buffer lttng_filter_yy_delete_buffer
-#define yy_flush_buffer lttng_filter_yy_flush_buffer
-#define yy_scan_buffer lttng_filter_yy_scan_buffer
-#define yy_scan_bytes lttng_filter_yy_scan_bytes
-#define yy_scan_string lttng_filter_yy_scan_string
-#define yy_switch_to_buffer lttng_filter_yy_switch_to_buffer
-#define yyalloc lttng_filter_yyalloc
-#define yyfree lttng_filter_yyfree
-#define yyget_column lttng_filter_yyget_column
-#define yyget_debug lttng_filter_yyget_debug
-#define yyget_extra lttng_filter_yyget_extra
-#define yyget_in lttng_filter_yyget_in
-#define yyget_leng lttng_filter_yyget_leng
-#define yyget_lineno lttng_filter_yyget_lineno
-#define yyget_lval lttng_filter_yyget_lval
-#define yyget_out lttng_filter_yyget_out
-#define yyget_text lttng_filter_yyget_text
-#define yylex_init lttng_filter_yylex_init
-#define yypop_buffer_state lttng_filter_yypop_buffer_state
-#define yypush_buffer_state lttng_filter_yypush_buffer_state
-#define yyrealloc lttng_filter_yyrealloc
-#define yyset_column lttng_filter_yyset_column
-#define yyset_debug lttng_filter_yyset_debug
-#define yyset_extra lttng_filter_yyset_extra
-#define yyset_in lttng_filter_yyset_in
-#define yyset_lineno lttng_filter_yyset_lineno
-#define yyset_lval lttng_filter_yyset_lval
-#define yyset_out lttng_filter_yyset_out
-
-#endif /* _FILTER_SYMBOLS_H */
diff --git a/src/common/filter/filter-symbols.hpp b/src/common/filter/filter-symbols.hpp
new file mode 100644 (file)
index 0000000..27aaada
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef _FILTER_SYMBOLS_H
+#define _FILTER_SYMBOLS_H
+
+/*
+ * filter-symbols.h
+ *
+ * LTTng filter flex/bison symbol prefixes
+ *
+ * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#define yy_create_buffer lttng_filter_yy_create_buffer
+#define yy_delete_buffer lttng_filter_yy_delete_buffer
+#define yy_flush_buffer lttng_filter_yy_flush_buffer
+#define yy_scan_buffer lttng_filter_yy_scan_buffer
+#define yy_scan_bytes lttng_filter_yy_scan_bytes
+#define yy_scan_string lttng_filter_yy_scan_string
+#define yy_switch_to_buffer lttng_filter_yy_switch_to_buffer
+#define yyalloc lttng_filter_yyalloc
+#define yyfree lttng_filter_yyfree
+#define yyget_column lttng_filter_yyget_column
+#define yyget_debug lttng_filter_yyget_debug
+#define yyget_extra lttng_filter_yyget_extra
+#define yyget_in lttng_filter_yyget_in
+#define yyget_leng lttng_filter_yyget_leng
+#define yyget_lineno lttng_filter_yyget_lineno
+#define yyget_lval lttng_filter_yyget_lval
+#define yyget_out lttng_filter_yyget_out
+#define yyget_text lttng_filter_yyget_text
+#define yylex_init lttng_filter_yylex_init
+#define yypop_buffer_state lttng_filter_yypop_buffer_state
+#define yypush_buffer_state lttng_filter_yypush_buffer_state
+#define yyrealloc lttng_filter_yyrealloc
+#define yyset_column lttng_filter_yyset_column
+#define yyset_debug lttng_filter_yyset_debug
+#define yyset_extra lttng_filter_yyset_extra
+#define yyset_in lttng_filter_yyset_in
+#define yyset_lineno lttng_filter_yyset_lineno
+#define yyset_lval lttng_filter_yyset_lval
+#define yyset_out lttng_filter_yyset_out
+
+#endif /* _FILTER_SYMBOLS_H */
index c7e1be782666f7f0fdf292d57564ea2cdda91688..d7f775775530d39923c6f919988691a3425a4e3f 100644 (file)
 
 #include <stdlib.h>
 #include <string.h>
-#include <common/align.h>
-#include <common/compat/errno.h>
-#include <common/compat/string.h>
-
-#include "common/align.h"
-#include "common/bytecode/bytecode.h"
-#include "common/compat/string.h"
-#include "common/macros.h"
-#include "common/string-utils/string-utils.h"
-#include "filter-ast.h"
-#include "filter-ir.h"
+#include <common/align.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/string.hpp>
+
+#include "common/align.hpp"
+#include "common/bytecode/bytecode.hpp"
+#include "common/compat/string.hpp"
+#include "common/macros.hpp"
+#include "common/string-utils/string-utils.hpp"
+#include "filter-ast.hpp"
+#include "filter-ir.hpp"
 
 #ifndef max_t
 #define max_t(type, a, b)      ((type) ((a) > (b) ? (a) : (b)))
index 3705ce4f283453ed190e4f9d75bdca02bdc2d6ca..a7236bd104f7e7314301507dc7442bb3a82b6f6a 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include <inttypes.h>
-#include "filter-ast.h"
+#include "filter-ast.hpp"
 #include "filter-parser.hpp"
-#include "filter-ir.h"
+#include "filter-ir.hpp"
 
-#include <common/compat/errno.h>
-#include <common/macros.h>
-#include <common/string-utils/string-utils.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
+#include <common/string-utils/string-utils.hpp>
 
 static
 struct ir_op *generate_ir_recursive(struct filter_parser_ctx *ctx,
index 480100f25c535a83c2433e81bae202017d1ae7ea..2699abde8b5379d52f81673d1d0b12ba1affc0e3 100644 (file)
 #include <stdlib.h>
 #include <inttypes.h>
 
-#include <common/compat/errno.h>
+#include <common/compat/errno.hpp>
 
-#include "filter-ast.h"
+#include "filter-ast.hpp"
 #include "filter-parser.hpp"
-#include "filter-ir.h"
+#include "filter-ir.hpp"
 
 static
 int check_bin_comparator(struct ir_op *node)
index 290ea0367aa80d4742862abac7ec01cb5939d4cf..9c3dd76737f64f57e3d1a5a5aea34768d4190c54 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include <inttypes.h>
-#include "filter-ast.h"
+#include "filter-ast.hpp"
 #include "filter-parser.hpp"
-#include "filter-ir.h"
+#include "filter-ir.hpp"
 
-#include <common/compat/errno.h>
-#include <common/macros.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
 
 static
 int check_bin_op_nesting_recursive(struct ir_op *node, int nesting)
index a091b812305cb10a470a54cc6e2641f99a7424e0..446c720db635e9ea0e0eb1d33c9c625f408980d8 100644 (file)
 #include <stdlib.h>
 #include <inttypes.h>
 
-#include <common/compat/errno.h>
-#include <common/macros.h>
-#include <common/string-utils/string-utils.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
+#include <common/string-utils/string-utils.hpp>
 
-#include "filter-ast.h"
+#include "filter-ast.hpp"
 #include "filter-parser.hpp"
-#include "filter-ir.h"
+#include "filter-ir.hpp"
 
 static
 int normalize_glob_patterns(struct ir_op *node)
index 8f9c785c49b231925822581fe3019e4ca8212467..718098a433403bea810158b9e8b5b2fe27ca030a 100644 (file)
 #include <stdlib.h>
 #include <inttypes.h>
 
-#include <common/compat/errno.h>
-#include <common/macros.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
 
-#include "filter-ast.h"
+#include "filter-ast.hpp"
 #include "filter-parser.hpp"
-#include "filter-ir.h"
+#include "filter-ir.hpp"
 
 static
 int validate_globbing(struct ir_op *node)
index 0c18f98bc7b25959eeb98b71d12d4bf040484933..9e060ce2b64e4fe77817c0af71fe76e150be308a 100644 (file)
 #include <stdlib.h>
 #include <inttypes.h>
 
-#include <common/macros.h>
-#include <common/compat/errno.h>
+#include <common/macros.hpp>
+#include <common/compat/errno.hpp>
 
-#include "filter-ast.h"
+#include "filter-ast.hpp"
 #include "filter-parser.hpp"
-#include "filter-ir.h"
+#include "filter-ir.hpp"
 
 enum parse_char_result {
        PARSE_CHAR_UNKNOWN = -2,
index eb12452a60d0918f08d9264a7aac39b0b6944dac..5b531a28979ad7a09eb788fdf55b47d62493cbd8 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include <inttypes.h>
-#include "filter-ast.h"
+#include "filter-ast.hpp"
 #include "filter-parser.hpp"
 
-#include <common/compat/errno.h>
-#include <common/macros.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
 
 #define fprintf_dbg(fd, fmt, args...)  fprintf(fd, "%s: " fmt, __func__, ## args)
 
diff --git a/src/common/filter/memstream.h b/src/common/filter/memstream.h
deleted file mode 100644 (file)
index 41c7681..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2012 (C) Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _LTTNG_CTL_MEMSTREAM_H
-#define _LTTNG_CTL_MEMSTREAM_H
-
-#ifdef LTTNG_HAVE_FMEMOPEN
-#include <stdio.h>
-
-static inline
-FILE *lttng_fmemopen(void *buf, size_t size, const char *mode)
-{
-       return fmemopen(buf, size, mode);
-}
-
-#else /* LTTNG_HAVE_FMEMOPEN */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <common/error.h>
-
-/*
- * Fallback for systems which don't have fmemopen. Copy buffer to a
- * temporary file, and use that file as FILE * input.
- */
-static inline
-FILE *lttng_fmemopen(void *buf, size_t size, const char *mode)
-{
-       char tmpname[PATH_MAX];
-       size_t len;
-       FILE *fp;
-       int ret;
-
-       /*
-        * Support reading only.
-        */
-       if (strcmp(mode, "rb") != 0) {
-               return NULL;
-       }
-       strncpy(tmpname, "/tmp/lttng-tmp-XXXXXX", PATH_MAX);
-       ret = mkstemp(tmpname);
-       if (ret < 0) {
-               return NULL;
-       }
-       /*
-        * We need to write to the file.
-        */
-       fp = fdopen(ret, "w+");
-       if (!fp) {
-               goto error_unlink;
-       }
-       /* Copy the entire buffer to the file */
-       len = fwrite(buf, sizeof(char), size, fp);
-       if (len != size) {
-               goto error_close;
-       }
-       ret = fseek(fp, 0L, SEEK_SET);
-       if (ret < 0) {
-               PERROR("fseek");
-               goto error_close;
-       }
-       /* We keep the handle open, but can unlink the file on the VFS. */
-       ret = unlink(tmpname);
-       if (ret < 0) {
-               PERROR("unlink");
-       }
-       return fp;
-
-error_close:
-       ret = fclose(fp);
-       if (ret < 0) {
-               PERROR("close");
-       }
-error_unlink:
-       ret = unlink(tmpname);
-       if (ret < 0) {
-               PERROR("unlink");
-       }
-       return NULL;
-}
-
-#endif /* LTTNG_HAVE_FMEMOPEN */
-
-#endif /* _LTTNG_CTL_MEMSTREAM_H */
diff --git a/src/common/filter/memstream.hpp b/src/common/filter/memstream.hpp
new file mode 100644 (file)
index 0000000..26b124a
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2012 (C) Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _LTTNG_CTL_MEMSTREAM_H
+#define _LTTNG_CTL_MEMSTREAM_H
+
+#ifdef LTTNG_HAVE_FMEMOPEN
+#include <stdio.h>
+
+static inline
+FILE *lttng_fmemopen(void *buf, size_t size, const char *mode)
+{
+       return fmemopen(buf, size, mode);
+}
+
+#else /* LTTNG_HAVE_FMEMOPEN */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <common/error.hpp>
+
+/*
+ * Fallback for systems which don't have fmemopen. Copy buffer to a
+ * temporary file, and use that file as FILE * input.
+ */
+static inline
+FILE *lttng_fmemopen(void *buf, size_t size, const char *mode)
+{
+       char tmpname[PATH_MAX];
+       size_t len;
+       FILE *fp;
+       int ret;
+
+       /*
+        * Support reading only.
+        */
+       if (strcmp(mode, "rb") != 0) {
+               return NULL;
+       }
+       strncpy(tmpname, "/tmp/lttng-tmp-XXXXXX", PATH_MAX);
+       ret = mkstemp(tmpname);
+       if (ret < 0) {
+               return NULL;
+       }
+       /*
+        * We need to write to the file.
+        */
+       fp = fdopen(ret, "w+");
+       if (!fp) {
+               goto error_unlink;
+       }
+       /* Copy the entire buffer to the file */
+       len = fwrite(buf, sizeof(char), size, fp);
+       if (len != size) {
+               goto error_close;
+       }
+       ret = fseek(fp, 0L, SEEK_SET);
+       if (ret < 0) {
+               PERROR("fseek");
+               goto error_close;
+       }
+       /* We keep the handle open, but can unlink the file on the VFS. */
+       ret = unlink(tmpname);
+       if (ret < 0) {
+               PERROR("unlink");
+       }
+       return fp;
+
+error_close:
+       ret = fclose(fp);
+       if (ret < 0) {
+               PERROR("close");
+       }
+error_unlink:
+       ret = unlink(tmpname);
+       if (ret < 0) {
+               PERROR("unlink");
+       }
+       return NULL;
+}
+
+#endif /* LTTNG_HAVE_FMEMOPEN */
+
+#endif /* _LTTNG_CTL_MEMSTREAM_H */
diff --git a/src/common/fs-handle-internal.h b/src/common/fs-handle-internal.h
deleted file mode 100644 (file)
index 0882467..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef FS_HANDLE_INTERNAL_H
-#define FS_HANDLE_INTERNAL_H
-
-struct fs_handle;
-
-/*
- * Multiple internal APIs return fs_handles. For the moment, this internal
- * interface allows the use of different fs_handle implementations in different
- * daemons. For instance, the trace chunk interface returns fs_handles that
- * behave diffently depending on whether or not the trace chunk was configured
- * to use an fd-tracker.
- */
-
-typedef int (*fs_handle_get_fd_cb)(struct fs_handle *);
-typedef void (*fs_handle_put_fd_cb)(struct fs_handle *);
-typedef int (*fs_handle_unlink_cb)(struct fs_handle *);
-typedef int (*fs_handle_close_cb)(struct fs_handle *);
-
-struct fs_handle {
-       fs_handle_get_fd_cb get_fd;
-       fs_handle_put_fd_cb put_fd;
-       fs_handle_unlink_cb unlink;
-       fs_handle_close_cb close;
-};
-
-#endif /* FS_HANDLE_INTERNAL_H */
diff --git a/src/common/fs-handle-internal.hpp b/src/common/fs-handle-internal.hpp
new file mode 100644 (file)
index 0000000..0882467
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef FS_HANDLE_INTERNAL_H
+#define FS_HANDLE_INTERNAL_H
+
+struct fs_handle;
+
+/*
+ * Multiple internal APIs return fs_handles. For the moment, this internal
+ * interface allows the use of different fs_handle implementations in different
+ * daemons. For instance, the trace chunk interface returns fs_handles that
+ * behave diffently depending on whether or not the trace chunk was configured
+ * to use an fd-tracker.
+ */
+
+typedef int (*fs_handle_get_fd_cb)(struct fs_handle *);
+typedef void (*fs_handle_put_fd_cb)(struct fs_handle *);
+typedef int (*fs_handle_unlink_cb)(struct fs_handle *);
+typedef int (*fs_handle_close_cb)(struct fs_handle *);
+
+struct fs_handle {
+       fs_handle_get_fd_cb get_fd;
+       fs_handle_put_fd_cb put_fd;
+       fs_handle_unlink_cb unlink;
+       fs_handle_close_cb close;
+};
+
+#endif /* FS_HANDLE_INTERNAL_H */
index bed0010e76d9f850b5f88e40035f5ae0099ca59f..ffdb883bd61c86921c8dc4e1cf14350093283236 100644 (file)
@@ -5,9 +5,9 @@
  *
  */
 
-#include <common/fs-handle-internal.h>
-#include <common/fs-handle.h>
-#include <common/readwrite.h>
+#include <common/fs-handle-internal.hpp>
+#include <common/fs-handle.hpp>
+#include <common/readwrite.hpp>
 
 int fs_handle_get_fd(struct fs_handle *handle)
 {
diff --git a/src/common/fs-handle.h b/src/common/fs-handle.h
deleted file mode 100644 (file)
index be6419c..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef FS_HANDLE_H
-#define FS_HANDLE_H
-
-#include <common/macros.h>
-#include <stdio.h>
-
-struct fs_handle;
-
-/*
- * Marks the handle as the most recently used and marks the 'fd' as
- * "in-use". This prevents the tracker from recycling the underlying
- * file descriptor while it is actively being used by a thread.
- *
- * Don't forget that the tracker may be initiating an fd 'suspension'
- * from another thread as the need to free an fd slot may arise from any
- * thread within the daemon.
- *
- * Note that a restorable fd should never be held for longer than
- * strictly necessary (e.g. the duration of a syscall()).
- *
- * Returns the fd on success, otherwise a negative value may be returned
- * if the restoration of the fd failed.
- */
-int fs_handle_get_fd(struct fs_handle *handle);
-
-/*
- * Used by the caller to signal that it is no longer using the underlying fd and
- * that it may be safely suspended.
- */
-void fs_handle_put_fd(struct fs_handle *handle);
-
-/*
- * Unlink the file associated to an fs_handle. Note that the unlink
- * operation will not be performed immediately. It will only be performed
- * once all references to the underlying file (through other fs_handle objects)
- * have been released.
- *
- * However, note that the file will be renamed so as to provide the observable
- * effect of an unlink(), that is removing a name from the filesystem.
- *
- * Returns 0 on success, otherwise a negative value will be returned
- * if the operation failed.
- */
-int fs_handle_unlink(struct fs_handle *handle);
-
-/*
- * Frees the handle and discards the underlying fd.
- */
-int fs_handle_close(struct fs_handle *handle);
-
-ssize_t fs_handle_read(struct fs_handle *handle, void *buf, size_t count);
-
-ssize_t fs_handle_write(struct fs_handle *handle, const void *buf, size_t count);
-
-int fs_handle_truncate(struct fs_handle *handle, off_t offset);
-
-off_t fs_handle_seek(struct fs_handle *handle, off_t offset, int whence);
-
-#endif /* FS_HANDLE_H */
diff --git a/src/common/fs-handle.hpp b/src/common/fs-handle.hpp
new file mode 100644 (file)
index 0000000..8b3a882
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef FS_HANDLE_H
+#define FS_HANDLE_H
+
+#include <common/macros.hpp>
+#include <stdio.h>
+
+struct fs_handle;
+
+/*
+ * Marks the handle as the most recently used and marks the 'fd' as
+ * "in-use". This prevents the tracker from recycling the underlying
+ * file descriptor while it is actively being used by a thread.
+ *
+ * Don't forget that the tracker may be initiating an fd 'suspension'
+ * from another thread as the need to free an fd slot may arise from any
+ * thread within the daemon.
+ *
+ * Note that a restorable fd should never be held for longer than
+ * strictly necessary (e.g. the duration of a syscall()).
+ *
+ * Returns the fd on success, otherwise a negative value may be returned
+ * if the restoration of the fd failed.
+ */
+int fs_handle_get_fd(struct fs_handle *handle);
+
+/*
+ * Used by the caller to signal that it is no longer using the underlying fd and
+ * that it may be safely suspended.
+ */
+void fs_handle_put_fd(struct fs_handle *handle);
+
+/*
+ * Unlink the file associated to an fs_handle. Note that the unlink
+ * operation will not be performed immediately. It will only be performed
+ * once all references to the underlying file (through other fs_handle objects)
+ * have been released.
+ *
+ * However, note that the file will be renamed so as to provide the observable
+ * effect of an unlink(), that is removing a name from the filesystem.
+ *
+ * Returns 0 on success, otherwise a negative value will be returned
+ * if the operation failed.
+ */
+int fs_handle_unlink(struct fs_handle *handle);
+
+/*
+ * Frees the handle and discards the underlying fd.
+ */
+int fs_handle_close(struct fs_handle *handle);
+
+ssize_t fs_handle_read(struct fs_handle *handle, void *buf, size_t count);
+
+ssize_t fs_handle_write(struct fs_handle *handle, const void *buf, size_t count);
+
+int fs_handle_truncate(struct fs_handle *handle, off_t offset);
+
+off_t fs_handle_seek(struct fs_handle *handle, off_t offset, int whence);
+
+#endif /* FS_HANDLE_H */
index 3eadf096bc8086760e36b24f3a342341d048c9fa..21ab09ab7e455cc961305f6711ed2b6f53e36132 100644 (file)
@@ -12,9 +12,9 @@
 #include <urcu.h>
 #include <urcu/futex.h>
 
-#include <common/common.h>
+#include <common/common.hpp>
 
-#include "futex.h"
+#include "futex.hpp"
 
 /*
  * This futex wait/wake scheme only works for N wakers / 1 waiters. Hence the
diff --git a/src/common/futex.h b/src/common/futex.h
deleted file mode 100644 (file)
index e0faa97..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_FUTEX_H
-#define _LTT_FUTEX_H
-
-void futex_wait_update(int32_t *futex, int active);
-void futex_nto1_prepare(int32_t *futex);
-void futex_nto1_wait(int32_t *futex);
-void futex_nto1_wake(int32_t *futex);
-
-#endif /* _LTT_FUTEX_H */
diff --git a/src/common/futex.hpp b/src/common/futex.hpp
new file mode 100644 (file)
index 0000000..e0faa97
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_FUTEX_H
+#define _LTT_FUTEX_H
+
+void futex_wait_update(int32_t *futex, int active);
+void futex_nto1_prepare(int32_t *futex);
+void futex_nto1_wait(int32_t *futex);
+void futex_nto1_wake(int32_t *futex);
+
+#endif /* _LTT_FUTEX_H */
diff --git a/src/common/hashtable/hashtable-symbols.h b/src/common/hashtable/hashtable-symbols.h
deleted file mode 100644 (file)
index 5f22c0e..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef _HASHTABLE_SYMBOLS_H
-#define _HASHTABLE_SYMBOLS_H
-
-/*
- * hashtable-symbols.h
- *
- * LTTng hash table symbol prefixing
- *
- * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#define _cds_lfht_new lttng__cds_lfht_new
-#define cds_lfht_add lttng_cds_lfht_add
-#define cds_lfht_add_replace lttng_cds_lfht_add_replace
-#define cds_lfht_add_unique lttng_cds_lfht_add_unique
-#define cds_lfht_count_nodes lttng_cds_lfht_count_nodes
-#define cds_lfht_del lttng_cds_lfht_del
-#define cds_lfht_destroy lttng_cds_lfht_destroy
-#define cds_lfht_first lttng_cds_lfht_first
-#define cds_lfht_fls_ulong lttng_cds_lfht_fls_ulong
-#define cds_lfht_get_count_order_u32 lttng_cds_lfht_get_count_order_u32
-#define cds_lfht_get_count_order_ulong lttng_cds_lfht_get_count_order_ulong
-#define cds_lfht_is_node_deleted lttng_cds_lfht_is_node_deleted
-#define cds_lfht_lookup lttng_cds_lfht_lookup
-#define cds_lfht_next lttng_cds_lfht_next
-#define cds_lfht_next_duplicate lttng_cds_lfht_next_duplicate
-#define cds_lfht_replace lttng_cds_lfht_replace
-#define cds_lfht_resize lttng_cds_lfht_resize
-
-#endif /* _HASHTABLE_SYMBOLS_H */
diff --git a/src/common/hashtable/hashtable-symbols.hpp b/src/common/hashtable/hashtable-symbols.hpp
new file mode 100644 (file)
index 0000000..5f22c0e
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef _HASHTABLE_SYMBOLS_H
+#define _HASHTABLE_SYMBOLS_H
+
+/*
+ * hashtable-symbols.h
+ *
+ * LTTng hash table symbol prefixing
+ *
+ * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#define _cds_lfht_new lttng__cds_lfht_new
+#define cds_lfht_add lttng_cds_lfht_add
+#define cds_lfht_add_replace lttng_cds_lfht_add_replace
+#define cds_lfht_add_unique lttng_cds_lfht_add_unique
+#define cds_lfht_count_nodes lttng_cds_lfht_count_nodes
+#define cds_lfht_del lttng_cds_lfht_del
+#define cds_lfht_destroy lttng_cds_lfht_destroy
+#define cds_lfht_first lttng_cds_lfht_first
+#define cds_lfht_fls_ulong lttng_cds_lfht_fls_ulong
+#define cds_lfht_get_count_order_u32 lttng_cds_lfht_get_count_order_u32
+#define cds_lfht_get_count_order_ulong lttng_cds_lfht_get_count_order_ulong
+#define cds_lfht_is_node_deleted lttng_cds_lfht_is_node_deleted
+#define cds_lfht_lookup lttng_cds_lfht_lookup
+#define cds_lfht_next lttng_cds_lfht_next
+#define cds_lfht_next_duplicate lttng_cds_lfht_next_duplicate
+#define cds_lfht_replace lttng_cds_lfht_replace
+#define cds_lfht_resize lttng_cds_lfht_resize
+
+#endif /* _HASHTABLE_SYMBOLS_H */
index c641dad3c8db2949e156dfd8f4ecd0a691508595..6b87ff71f016ae9fb1fa309ace336a58d369b1f8 100644 (file)
 #include <urcu.h>
 #include <urcu/compiler.h>
 
-#include <common/common.h>
-#include <common/defaults.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
 
-#include "hashtable.h"
-#include "utils.h"
+#include "hashtable.hpp"
+#include "utils.hpp"
 
 /* seed_lock protects both seed_init and lttng_ht_seed. */
 static pthread_mutex_t seed_lock = PTHREAD_MUTEX_INITIALIZER;
diff --git a/src/common/hashtable/hashtable.h b/src/common/hashtable/hashtable.h
deleted file mode 100644 (file)
index e129ac5..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_HT_H
-#define _LTT_HT_H
-
-#include <urcu.h>
-#include <stdint.h>
-
-#include <common/macros.h>
-#include <lttng/lttng-export.h>
-#include <urcu/rculfhash.h>
-
-LTTNG_EXPORT extern unsigned long lttng_ht_seed;
-
-typedef unsigned long (*hash_fct_type)(const void *_key, unsigned long seed);
-typedef cds_lfht_match_fct hash_match_fct;
-
-enum lttng_ht_type {
-       LTTNG_HT_TYPE_STRING,
-       LTTNG_HT_TYPE_ULONG,
-       LTTNG_HT_TYPE_U64,
-       LTTNG_HT_TYPE_TWO_U64,
-};
-
-struct lttng_ht {
-       struct cds_lfht *ht;
-       cds_lfht_match_fct match_fct;
-       hash_fct_type hash_fct;
-};
-
-struct lttng_ht_iter {
-       struct cds_lfht_iter iter;
-};
-
-struct lttng_ht_node_str {
-       char *key;
-       struct cds_lfht_node node;
-       struct rcu_head head;
-};
-
-struct lttng_ht_node_ulong {
-       unsigned long key;
-       struct cds_lfht_node node;
-       struct rcu_head head;
-};
-
-struct lttng_ht_node_u64 {
-       uint64_t key;
-       struct cds_lfht_node node;
-       struct rcu_head head;
-};
-
-struct lttng_ht_two_u64 {
-       uint64_t key1;
-       uint64_t key2;
-};
-
-struct lttng_ht_node_two_u64 {
-       struct lttng_ht_two_u64 key;
-       struct cds_lfht_node node;
-       struct rcu_head head;
-};
-
-/* Hashtable new and destroy */
-struct lttng_ht *lttng_ht_new(unsigned long size, enum lttng_ht_type type);
-void lttng_ht_destroy(struct lttng_ht *ht);
-
-/* Specialized node init and free functions */
-void lttng_ht_node_init_str(struct lttng_ht_node_str *node, char *key);
-void lttng_ht_node_init_ulong(struct lttng_ht_node_ulong *node,
-               unsigned long key);
-void lttng_ht_node_init_u64(struct lttng_ht_node_u64 *node,
-               uint64_t key);
-void lttng_ht_node_init_two_u64(struct lttng_ht_node_two_u64 *node,
-               uint64_t key1, uint64_t key2);
-void lttng_ht_node_free_str(struct lttng_ht_node_str *node);
-void lttng_ht_node_free_ulong(struct lttng_ht_node_ulong *node);
-void lttng_ht_node_free_u64(struct lttng_ht_node_u64 *node);
-void lttng_ht_node_free_two_u64(struct lttng_ht_node_two_u64 *node);
-
-void lttng_ht_lookup(struct lttng_ht *ht, const void *key,
-               struct lttng_ht_iter *iter);
-
-/* Specialized add unique functions */
-void lttng_ht_add_unique_str(struct lttng_ht *ht,
-               struct lttng_ht_node_str *node);
-void lttng_ht_add_unique_ulong(struct lttng_ht *ht,
-               struct lttng_ht_node_ulong *node);
-void lttng_ht_add_unique_u64(struct lttng_ht *ht,
-               struct lttng_ht_node_u64 *node);
-void lttng_ht_add_unique_two_u64(struct lttng_ht *ht,
-               struct lttng_ht_node_two_u64 *node);
-struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(
-               struct lttng_ht *ht, struct lttng_ht_node_ulong *node);
-struct lttng_ht_node_u64 *lttng_ht_add_replace_u64(
-               struct lttng_ht *ht, struct lttng_ht_node_u64 *node);
-void lttng_ht_add_str(struct lttng_ht *ht,
-               struct lttng_ht_node_str *node);
-void lttng_ht_add_ulong(struct lttng_ht *ht,
-               struct lttng_ht_node_ulong *node);
-void lttng_ht_add_u64(struct lttng_ht *ht,
-               struct lttng_ht_node_u64 *node);
-
-int lttng_ht_del(struct lttng_ht *ht, struct lttng_ht_iter *iter);
-
-void lttng_ht_get_first(struct lttng_ht *ht,
-               struct lttng_ht_iter *iter);
-void lttng_ht_get_next(struct lttng_ht *ht, struct lttng_ht_iter *iter);
-
-unsigned long lttng_ht_get_count(struct lttng_ht *ht);
-
-struct lttng_ht_node_str *lttng_ht_iter_get_node_str(
-               struct lttng_ht_iter *iter);
-struct lttng_ht_node_ulong *lttng_ht_iter_get_node_ulong(
-               struct lttng_ht_iter *iter);
-struct lttng_ht_node_u64 *lttng_ht_iter_get_node_u64(
-               struct lttng_ht_iter *iter);
-struct lttng_ht_node_two_u64 *lttng_ht_iter_get_node_two_u64(
-               struct lttng_ht_iter *iter);
-
-#endif /* _LTT_HT_H */
diff --git a/src/common/hashtable/hashtable.hpp b/src/common/hashtable/hashtable.hpp
new file mode 100644 (file)
index 0000000..bd5cb94
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_HT_H
+#define _LTT_HT_H
+
+#include <urcu.h>
+#include <stdint.h>
+
+#include <common/macros.hpp>
+#include <lttng/lttng-export.h>
+#include <urcu/rculfhash.h>
+
+LTTNG_EXPORT extern unsigned long lttng_ht_seed;
+
+typedef unsigned long (*hash_fct_type)(const void *_key, unsigned long seed);
+typedef cds_lfht_match_fct hash_match_fct;
+
+enum lttng_ht_type {
+       LTTNG_HT_TYPE_STRING,
+       LTTNG_HT_TYPE_ULONG,
+       LTTNG_HT_TYPE_U64,
+       LTTNG_HT_TYPE_TWO_U64,
+};
+
+struct lttng_ht {
+       struct cds_lfht *ht;
+       cds_lfht_match_fct match_fct;
+       hash_fct_type hash_fct;
+};
+
+struct lttng_ht_iter {
+       struct cds_lfht_iter iter;
+};
+
+struct lttng_ht_node_str {
+       char *key;
+       struct cds_lfht_node node;
+       struct rcu_head head;
+};
+
+struct lttng_ht_node_ulong {
+       unsigned long key;
+       struct cds_lfht_node node;
+       struct rcu_head head;
+};
+
+struct lttng_ht_node_u64 {
+       uint64_t key;
+       struct cds_lfht_node node;
+       struct rcu_head head;
+};
+
+struct lttng_ht_two_u64 {
+       uint64_t key1;
+       uint64_t key2;
+};
+
+struct lttng_ht_node_two_u64 {
+       struct lttng_ht_two_u64 key;
+       struct cds_lfht_node node;
+       struct rcu_head head;
+};
+
+/* Hashtable new and destroy */
+struct lttng_ht *lttng_ht_new(unsigned long size, enum lttng_ht_type type);
+void lttng_ht_destroy(struct lttng_ht *ht);
+
+/* Specialized node init and free functions */
+void lttng_ht_node_init_str(struct lttng_ht_node_str *node, char *key);
+void lttng_ht_node_init_ulong(struct lttng_ht_node_ulong *node,
+               unsigned long key);
+void lttng_ht_node_init_u64(struct lttng_ht_node_u64 *node,
+               uint64_t key);
+void lttng_ht_node_init_two_u64(struct lttng_ht_node_two_u64 *node,
+               uint64_t key1, uint64_t key2);
+void lttng_ht_node_free_str(struct lttng_ht_node_str *node);
+void lttng_ht_node_free_ulong(struct lttng_ht_node_ulong *node);
+void lttng_ht_node_free_u64(struct lttng_ht_node_u64 *node);
+void lttng_ht_node_free_two_u64(struct lttng_ht_node_two_u64 *node);
+
+void lttng_ht_lookup(struct lttng_ht *ht, const void *key,
+               struct lttng_ht_iter *iter);
+
+/* Specialized add unique functions */
+void lttng_ht_add_unique_str(struct lttng_ht *ht,
+               struct lttng_ht_node_str *node);
+void lttng_ht_add_unique_ulong(struct lttng_ht *ht,
+               struct lttng_ht_node_ulong *node);
+void lttng_ht_add_unique_u64(struct lttng_ht *ht,
+               struct lttng_ht_node_u64 *node);
+void lttng_ht_add_unique_two_u64(struct lttng_ht *ht,
+               struct lttng_ht_node_two_u64 *node);
+struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(
+               struct lttng_ht *ht, struct lttng_ht_node_ulong *node);
+struct lttng_ht_node_u64 *lttng_ht_add_replace_u64(
+               struct lttng_ht *ht, struct lttng_ht_node_u64 *node);
+void lttng_ht_add_str(struct lttng_ht *ht,
+               struct lttng_ht_node_str *node);
+void lttng_ht_add_ulong(struct lttng_ht *ht,
+               struct lttng_ht_node_ulong *node);
+void lttng_ht_add_u64(struct lttng_ht *ht,
+               struct lttng_ht_node_u64 *node);
+
+int lttng_ht_del(struct lttng_ht *ht, struct lttng_ht_iter *iter);
+
+void lttng_ht_get_first(struct lttng_ht *ht,
+               struct lttng_ht_iter *iter);
+void lttng_ht_get_next(struct lttng_ht *ht, struct lttng_ht_iter *iter);
+
+unsigned long lttng_ht_get_count(struct lttng_ht *ht);
+
+struct lttng_ht_node_str *lttng_ht_iter_get_node_str(
+               struct lttng_ht_iter *iter);
+struct lttng_ht_node_ulong *lttng_ht_iter_get_node_ulong(
+               struct lttng_ht_iter *iter);
+struct lttng_ht_node_u64 *lttng_ht_iter_get_node_u64(
+               struct lttng_ht_iter *iter);
+struct lttng_ht_node_two_u64 *lttng_ht_iter_get_node_two_u64(
+               struct lttng_ht_iter *iter);
+
+#endif /* _LTT_HT_H */
index 24da1bc95cac4f7a006d40dd24e60a12fcce7d65..b541c71cfa9e687b5af739ba54f11f98d9a89c01 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #define _LGPL_SOURCE
-#include "hashtable.h"
-#include "utils.h"
+#include "hashtable.hpp"
+#include "utils.hpp"
 
 unsigned long lttng_ht_seed;
index 33a5edb9d87b6c561c057d400148498e282c7329..516deeb64bbb6dcf8b3550abd0f236616bcec6c2 100644 (file)
 #include <time.h>       /* defines time_t for timings in the test */
 #include <urcu/compiler.h>
 
-#include "utils.h"
-#include <common/compat/endian.h>    /* attempt to define endianness */
-#include <common/common.h>
-#include <common/hashtable/hashtable.h>
+#include "utils.hpp"
+#include <common/compat/endian.hpp>    /* attempt to define endianness */
+#include <common/common.hpp>
+#include <common/hashtable/hashtable.hpp>
 
 /*
  * My best guess at if you are big-endian or little-endian.  This may
diff --git a/src/common/hashtable/utils.h b/src/common/hashtable/utils.h
deleted file mode 100644 (file)
index a8c8de2..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _LTT_HT_UTILS_H
-#define _LTT_HT_UTILS_H
-
-#include <stdint.h>
-
-unsigned long hash_key_ulong(const void *_key, unsigned long seed);
-unsigned long hash_key_u64(const void *_key, unsigned long seed);
-unsigned long hash_key_str(const void *key, unsigned long seed);
-unsigned long hash_key_two_u64(const void *key, unsigned long seed);
-int hash_match_key_ulong(const void *key1, const void *key2);
-int hash_match_key_u64(const void *key1, const void *key2);
-int hash_match_key_str(const void *key1, const void *key2);
-int hash_match_key_two_u64(const void *key1, const void *key2);
-
-#endif /* _LTT_HT_UTILS_H */
diff --git a/src/common/hashtable/utils.hpp b/src/common/hashtable/utils.hpp
new file mode 100644 (file)
index 0000000..a8c8de2
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _LTT_HT_UTILS_H
+#define _LTT_HT_UTILS_H
+
+#include <stdint.h>
+
+unsigned long hash_key_ulong(const void *_key, unsigned long seed);
+unsigned long hash_key_u64(const void *_key, unsigned long seed);
+unsigned long hash_key_str(const void *key, unsigned long seed);
+unsigned long hash_key_two_u64(const void *key, unsigned long seed);
+int hash_match_key_ulong(const void *key1, const void *key2);
+int hash_match_key_u64(const void *key1, const void *key2);
+int hash_match_key_str(const void *key1, const void *key2);
+int hash_match_key_two_u64(const void *key1, const void *key2);
+
+#endif /* _LTT_HT_UTILS_H */
index 8a07e642607cb6cb401a57c845043ca63870f97e..9d33ffd2fc7b8e487885bc69d0fbce0c6875f09d 100644 (file)
 #include <stdlib.h>
 #include <time.h>
 
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/sessiond-comm/inet.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/sessiond-comm/inet.hpp>
 
-#include <lttng/health-internal.h>
+#include <lttng/health-internal.hpp>
 
 /*
  * An application-specific error state for unregistered thread keeps
index c48d708d0ea2759e8806aa5558d949ae2ec12e8d..7fe18eb1862cd41674b38c359d425de62f1365ad 100644 (file)
 #include <urcu.h>
 #include <urcu/list.h>
 
-#include "macros.h"
-#include "error.h"
+#include "macros.hpp"
+#include "error.hpp"
 
-#include "index-allocator.h"
+#include "index-allocator.hpp"
 
 struct lttng_index_allocator {
        struct cds_list_head unused_list;
diff --git a/src/common/index-allocator.h b/src/common/index-allocator.h
deleted file mode 100644 (file)
index ee7c2ec..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _COMMON_INDEX_ALLOCATOR_H
-#define _COMMON_INDEX_ALLOCATOR_H
-
-#include <inttypes.h>
-#include <lttng/lttng-export.h>
-
-struct lttng_index_allocator;
-
-enum lttng_index_allocator_status {
-       LTTNG_INDEX_ALLOCATOR_STATUS_OK,
-       LTTNG_INDEX_ALLOCATOR_STATUS_EMPTY,
-       LTTNG_INDEX_ALLOCATOR_STATUS_ERROR,
-};
-
-/*
- * Create an index allocator of `index_count` slots.
- */
-extern "C" LTTNG_EXPORT
-struct lttng_index_allocator *lttng_index_allocator_create(
-               uint64_t index_count);
-
-/*
- * Get the number of indexes currently in use.
- */
-extern "C" LTTNG_EXPORT
-uint64_t lttng_index_allocator_get_index_count(
-       struct lttng_index_allocator *allocator);
-
-/*
- * Allocate (i.e. reserve) a slot.
- */
-extern "C" LTTNG_EXPORT
-enum lttng_index_allocator_status lttng_index_allocator_alloc(
-               struct lttng_index_allocator *allocator,
-               uint64_t *index);
-
-/*
- * Release a slot by index. The slot will be re-used by the index allocator
- * in future 'alloc' calls.
- */
-extern "C" LTTNG_EXPORT
-enum lttng_index_allocator_status lttng_index_allocator_release(
-               struct lttng_index_allocator *allocator, uint64_t index);
-
-/*
- * Destroy an index allocator.
- */
-extern "C" LTTNG_EXPORT
-void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator);
-
-#endif /* _COMMON_INDEX_ALLOCATOR_H */
diff --git a/src/common/index-allocator.hpp b/src/common/index-allocator.hpp
new file mode 100644 (file)
index 0000000..ee7c2ec
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _COMMON_INDEX_ALLOCATOR_H
+#define _COMMON_INDEX_ALLOCATOR_H
+
+#include <inttypes.h>
+#include <lttng/lttng-export.h>
+
+struct lttng_index_allocator;
+
+enum lttng_index_allocator_status {
+       LTTNG_INDEX_ALLOCATOR_STATUS_OK,
+       LTTNG_INDEX_ALLOCATOR_STATUS_EMPTY,
+       LTTNG_INDEX_ALLOCATOR_STATUS_ERROR,
+};
+
+/*
+ * Create an index allocator of `index_count` slots.
+ */
+extern "C" LTTNG_EXPORT
+struct lttng_index_allocator *lttng_index_allocator_create(
+               uint64_t index_count);
+
+/*
+ * Get the number of indexes currently in use.
+ */
+extern "C" LTTNG_EXPORT
+uint64_t lttng_index_allocator_get_index_count(
+       struct lttng_index_allocator *allocator);
+
+/*
+ * Allocate (i.e. reserve) a slot.
+ */
+extern "C" LTTNG_EXPORT
+enum lttng_index_allocator_status lttng_index_allocator_alloc(
+               struct lttng_index_allocator *allocator,
+               uint64_t *index);
+
+/*
+ * Release a slot by index. The slot will be re-used by the index allocator
+ * in future 'alloc' calls.
+ */
+extern "C" LTTNG_EXPORT
+enum lttng_index_allocator_status lttng_index_allocator_release(
+               struct lttng_index_allocator *allocator, uint64_t index);
+
+/*
+ * Destroy an index allocator.
+ */
+extern "C" LTTNG_EXPORT
+void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator);
+
+#endif /* _COMMON_INDEX_ALLOCATOR_H */
diff --git a/src/common/index/ctf-index.h b/src/common/index/ctf-index.h
deleted file mode 100644 (file)
index 7fc7fd8..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef LTTNG_INDEX_H
-#define LTTNG_INDEX_H
-
-#include <common/compat/endian.h>
-#include <common/macros.h>
-
-#include <stdint.h>
-#include <limits.h>
-#include <stddef.h>
-
-#define CTF_INDEX_MAGIC 0xC1F1DCC1
-#define CTF_INDEX_MAJOR 1
-#define CTF_INDEX_MINOR 1
-
-/*
- * Header at the beginning of each index file.
- * All integer fields are stored in big endian.
- */
-struct ctf_packet_index_file_hdr {
-       uint32_t magic;
-       uint32_t index_major;
-       uint32_t index_minor;
-       /* struct packet_index_len, in bytes */
-       uint32_t packet_index_len;
-} __attribute__((__packed__));
-
-/*
- * Packet index generated for each trace packet stored in a trace file.
- * All integer fields are stored in big endian.
- */
-struct ctf_packet_index {
-       uint64_t offset;                /* offset of the packet in the file, in bytes */
-       uint64_t packet_size;           /* packet size, in bits */
-       uint64_t content_size;          /* content size, in bits */
-       uint64_t timestamp_begin;
-       uint64_t timestamp_end;
-       uint64_t events_discarded;
-       uint64_t stream_id;             /* ID of the channel */
-       /* CTF_INDEX 1.0 limit */
-       uint64_t stream_instance_id;    /* ID of the channel instance */
-       uint64_t packet_seq_num;        /* packet sequence number */
-} __attribute__((__packed__));
-
-static inline size_t ctf_packet_index_len(uint32_t major, uint32_t minor)
-{
-       if (major == 1) {
-               switch (minor) {
-               case 0:
-                       return offsetof(struct ctf_packet_index, stream_id)
-                               + member_sizeof(struct ctf_packet_index,
-                                               stream_id);
-               case 1:
-                       return offsetof(struct ctf_packet_index, packet_seq_num)
-                               + member_sizeof(struct ctf_packet_index,
-                                               packet_seq_num);
-               default:
-                       abort();
-               }
-       }
-       abort();
-}
-
-static inline uint32_t lttng_to_index_major(uint32_t lttng_major,
-               uint32_t lttng_minor __attribute__((unused)))
-{
-       if (lttng_major == 2) {
-               return 1;
-       }
-       abort();
-}
-
-static inline uint32_t lttng_to_index_minor(uint32_t lttng_major,
-               uint32_t lttng_minor)
-{
-       if (lttng_major == 2) {
-               if (lttng_minor < 8) {
-                       return 0;
-               } else {
-                       return 1;
-               }
-       }
-       abort();
-}
-
-static inline void ctf_packet_index_file_hdr_init(
-               struct ctf_packet_index_file_hdr *hdr,
-               uint32_t idx_major, uint32_t idx_minor)
-{
-       memset(hdr, 0, sizeof(*hdr));
-       hdr->magic = htobe32(CTF_INDEX_MAGIC);
-       hdr->index_major = htobe32(idx_major);
-       hdr->index_minor = htobe32(idx_minor);
-       hdr->packet_index_len = htobe32(
-                       ctf_packet_index_len(idx_major, idx_minor));
-}
-
-#endif /* LTTNG_INDEX_H */
diff --git a/src/common/index/ctf-index.hpp b/src/common/index/ctf-index.hpp
new file mode 100644 (file)
index 0000000..2b9bc54
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef LTTNG_INDEX_H
+#define LTTNG_INDEX_H
+
+#include <common/compat/endian.hpp>
+#include <common/macros.hpp>
+
+#include <stdint.h>
+#include <limits.h>
+#include <stddef.h>
+
+#define CTF_INDEX_MAGIC 0xC1F1DCC1
+#define CTF_INDEX_MAJOR 1
+#define CTF_INDEX_MINOR 1
+
+/*
+ * Header at the beginning of each index file.
+ * All integer fields are stored in big endian.
+ */
+struct ctf_packet_index_file_hdr {
+       uint32_t magic;
+       uint32_t index_major;
+       uint32_t index_minor;
+       /* struct packet_index_len, in bytes */
+       uint32_t packet_index_len;
+} __attribute__((__packed__));
+
+/*
+ * Packet index generated for each trace packet stored in a trace file.
+ * All integer fields are stored in big endian.
+ */
+struct ctf_packet_index {
+       uint64_t offset;                /* offset of the packet in the file, in bytes */
+       uint64_t packet_size;           /* packet size, in bits */
+       uint64_t content_size;          /* content size, in bits */
+       uint64_t timestamp_begin;
+       uint64_t timestamp_end;
+       uint64_t events_discarded;
+       uint64_t stream_id;             /* ID of the channel */
+       /* CTF_INDEX 1.0 limit */
+       uint64_t stream_instance_id;    /* ID of the channel instance */
+       uint64_t packet_seq_num;        /* packet sequence number */
+} __attribute__((__packed__));
+
+static inline size_t ctf_packet_index_len(uint32_t major, uint32_t minor)
+{
+       if (major == 1) {
+               switch (minor) {
+               case 0:
+                       return offsetof(struct ctf_packet_index, stream_id)
+                               + member_sizeof(struct ctf_packet_index,
+                                               stream_id);
+               case 1:
+                       return offsetof(struct ctf_packet_index, packet_seq_num)
+                               + member_sizeof(struct ctf_packet_index,
+                                               packet_seq_num);
+               default:
+                       abort();
+               }
+       }
+       abort();
+}
+
+static inline uint32_t lttng_to_index_major(uint32_t lttng_major,
+               uint32_t lttng_minor __attribute__((unused)))
+{
+       if (lttng_major == 2) {
+               return 1;
+       }
+       abort();
+}
+
+static inline uint32_t lttng_to_index_minor(uint32_t lttng_major,
+               uint32_t lttng_minor)
+{
+       if (lttng_major == 2) {
+               if (lttng_minor < 8) {
+                       return 0;
+               } else {
+                       return 1;
+               }
+       }
+       abort();
+}
+
+static inline void ctf_packet_index_file_hdr_init(
+               struct ctf_packet_index_file_hdr *hdr,
+               uint32_t idx_major, uint32_t idx_minor)
+{
+       memset(hdr, 0, sizeof(*hdr));
+       hdr->magic = htobe32(CTF_INDEX_MAGIC);
+       hdr->index_major = htobe32(idx_major);
+       hdr->index_minor = htobe32(idx_minor);
+       hdr->packet_index_len = htobe32(
+                       ctf_packet_index_len(idx_major, idx_minor));
+}
+
+#endif /* LTTNG_INDEX_H */
index 48d30e428253518412c276c89012d0cc71c1e2f0..9d6895baea9817af1a7e4c34dafffbce53e131ea 100644 (file)
 #include <fcntl.h>
 
 #include <lttng/constant.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/compat/endian.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/compat/endian.hpp>
+#include <common/utils.hpp>
 
-#include "index.h"
+#include "index.hpp"
 
 #define WRITE_FILE_FLAGS       (O_WRONLY | O_CREAT | O_TRUNC)
 #define READ_ONLY_FILE_FLAGS   O_RDONLY
diff --git a/src/common/index/index.h b/src/common/index/index.h
deleted file mode 100644 (file)
index 25ecc19..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _INDEX_H
-#define _INDEX_H
-
-#include <inttypes.h>
-#include <urcu/ref.h>
-
-#include "ctf-index.h"
-#include <common/fs-handle.h>
-#include <common/trace-chunk.h>
-
-struct lttng_index_file {
-       struct fs_handle *file;
-       uint32_t major;
-       uint32_t minor;
-       uint32_t element_len;
-       struct lttng_trace_chunk *trace_chunk;
-       struct urcu_ref ref;
-};
-
-/*
- * create and open have refcount of 1. Use put to decrement the
- * refcount. Destroys when reaching 0. Use "get" to increment refcount.
- */
-enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk(
-               struct lttng_trace_chunk *chunk,
-               const char *channel_path, const char *stream_name,
-               uint64_t stream_file_size, uint64_t stream_count,
-               uint32_t index_major, uint32_t index_minor,
-               bool unlink_existing_file, struct lttng_index_file **file);
-
-enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk_read_only(
-               struct lttng_trace_chunk *chunk,
-               const char *channel_path, const char *stream_name,
-               uint64_t stream_file_size, uint64_t stream_file_index,
-               uint32_t index_major, uint32_t index_minor,
-               bool expect_no_file, struct lttng_index_file **file);
-
-int lttng_index_file_write(const struct lttng_index_file *index_file,
-               const struct ctf_packet_index *element);
-int lttng_index_file_read(const struct lttng_index_file *index_file,
-               struct ctf_packet_index *element);
-
-void lttng_index_file_get(struct lttng_index_file *index_file);
-void lttng_index_file_put(struct lttng_index_file *index_file);
-
-#endif /* _INDEX_H */
diff --git a/src/common/index/index.hpp b/src/common/index/index.hpp
new file mode 100644 (file)
index 0000000..00d8203
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _INDEX_H
+#define _INDEX_H
+
+#include <inttypes.h>
+#include <urcu/ref.h>
+
+#include "ctf-index.hpp"
+#include <common/fs-handle.hpp>
+#include <common/trace-chunk.hpp>
+
+struct lttng_index_file {
+       struct fs_handle *file;
+       uint32_t major;
+       uint32_t minor;
+       uint32_t element_len;
+       struct lttng_trace_chunk *trace_chunk;
+       struct urcu_ref ref;
+};
+
+/*
+ * create and open have refcount of 1. Use put to decrement the
+ * refcount. Destroys when reaching 0. Use "get" to increment refcount.
+ */
+enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk(
+               struct lttng_trace_chunk *chunk,
+               const char *channel_path, const char *stream_name,
+               uint64_t stream_file_size, uint64_t stream_count,
+               uint32_t index_major, uint32_t index_minor,
+               bool unlink_existing_file, struct lttng_index_file **file);
+
+enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk_read_only(
+               struct lttng_trace_chunk *chunk,
+               const char *channel_path, const char *stream_name,
+               uint64_t stream_file_size, uint64_t stream_file_index,
+               uint32_t index_major, uint32_t index_minor,
+               bool expect_no_file, struct lttng_index_file **file);
+
+int lttng_index_file_write(const struct lttng_index_file *index_file,
+               const struct ctf_packet_index *element);
+int lttng_index_file_read(const struct lttng_index_file *index_file,
+               struct ctf_packet_index *element);
+
+void lttng_index_file_get(struct lttng_index_file *index_file);
+void lttng_index_file_put(struct lttng_index_file *index_file);
+
+#endif /* _INDEX_H */
index 797de0164d35303716c880a4d306cee10a5b5b8b..98308c9f348ee2946b86da36654c6897194779db 100644 (file)
@@ -5,13 +5,13 @@
  *
  */
 
-#include "ini-config.h"
+#include "ini-config.hpp"
 
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/ini-config/ini.h>
-#include <common/macros.h>
-#include <common/utils.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/ini-config/ini.hpp>
+#include <common/macros.hpp>
+#include <common/utils.hpp>
 #include <ctype.h>
 
 LTTNG_EXPORT const char *config_str_yes = "yes";
diff --git a/src/common/ini-config/ini-config.h b/src/common/ini-config/ini-config.h
deleted file mode 100644 (file)
index 3e41605..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef INI_CONFIG_H
-#define INI_CONFIG_H
-
-struct config_entry {
-       /* section is NULL if the entry is not in a section */
-       const char *section;
-       const char *name;
-       const char *value;
-};
-
-/*
- * A config_entry_handler_cb receives config_entry structures belonging to the
- * sections the handler has been registered to.
- *
- * The config_entry and its members are only valid for the duration of the call
- * and must not be freed.
- *
- * config_entry_handler_cb may return negative value to indicate an error in
- * the configuration file.
- */
-typedef int (*config_entry_handler_cb)(const struct config_entry *, void *);
-
-/*
- * Read a section's entries in an INI configuration file.
- *
- * path may be NULL, in which case the following paths will be tried:
- *     1) $HOME/.lttng/lttng.conf
- *     2) /etc/lttng/lttng.conf
- *
- * handler will only be called with entries belonging to the provided section.
- * If section is NULL, all entries will be relayed to handler. If section is
- * "", only the global entries are relayed.
- *
- * Returns 0 on success. Negative values are error codes. If the return value
- * is positive, it represents the line number on which a parsing error occurred.
- */
-int config_get_section_entries(const char *path, const char *section,
-               config_entry_handler_cb handler, void *user_data);
-
-/*
- * Parse a configuration value.
- *
- * This function expects either an unsigned integer or a boolean text option.
- * The following strings are recognized: true, yes, on, false, no and off.
- *
- * Returns either the value of the parsed integer, or 0/1 if a boolean text
- * string was recognized. Negative values indicate an error.
- */
-int config_parse_value(const char *value);
-
-#endif /* INI_CONFIG_H */
diff --git a/src/common/ini-config/ini-config.hpp b/src/common/ini-config/ini-config.hpp
new file mode 100644 (file)
index 0000000..3e41605
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef INI_CONFIG_H
+#define INI_CONFIG_H
+
+struct config_entry {
+       /* section is NULL if the entry is not in a section */
+       const char *section;
+       const char *name;
+       const char *value;
+};
+
+/*
+ * A config_entry_handler_cb receives config_entry structures belonging to the
+ * sections the handler has been registered to.
+ *
+ * The config_entry and its members are only valid for the duration of the call
+ * and must not be freed.
+ *
+ * config_entry_handler_cb may return negative value to indicate an error in
+ * the configuration file.
+ */
+typedef int (*config_entry_handler_cb)(const struct config_entry *, void *);
+
+/*
+ * Read a section's entries in an INI configuration file.
+ *
+ * path may be NULL, in which case the following paths will be tried:
+ *     1) $HOME/.lttng/lttng.conf
+ *     2) /etc/lttng/lttng.conf
+ *
+ * handler will only be called with entries belonging to the provided section.
+ * If section is NULL, all entries will be relayed to handler. If section is
+ * "", only the global entries are relayed.
+ *
+ * Returns 0 on success. Negative values are error codes. If the return value
+ * is positive, it represents the line number on which a parsing error occurred.
+ */
+int config_get_section_entries(const char *path, const char *section,
+               config_entry_handler_cb handler, void *user_data);
+
+/*
+ * Parse a configuration value.
+ *
+ * This function expects either an unsigned integer or a boolean text option.
+ * The following strings are recognized: true, yes, on, false, no and off.
+ *
+ * Returns either the value of the parsed integer, or 0/1 if a boolean text
+ * string was recognized. Negative values indicate an error.
+ */
+int config_parse_value(const char *value);
+
+#endif /* INI_CONFIG_H */
index 1d967a49d0b0da6de531da8d37a7ba1c0d2b05cb..d8ec8cf3e375545b36416867704e45fa2b16f2cc 100644 (file)
@@ -36,9 +36,9 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
-#include <common/common.h>
+#include <common/common.hpp>
 
-#include "ini.h"
+#include "ini.hpp"
 
 #if !INI_USE_STACK
 #include <stdlib.h>
diff --git a/src/common/ini-config/ini.h b/src/common/ini-config/ini.h
deleted file mode 100644 (file)
index 34b3654..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * inih -- simple .INI file parser
- *
- * The "inih" library is distributed under the New BSD license:
- *
- * Copyright (C) 2009 Brush Technology - All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *     * Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *     * Neither the name of Brush Technology nor the names of its contributors
- *     may be used to endorse or promote products derived from this software
- *     without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY BRUSH TECHNOLOGY ''AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL BRUSH TECHNOLOGY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://code.google.com/p/inih/
- */
-
-#ifndef __INI_H__
-#define __INI_H__
-
-/* Make this header file easier to include in C++ code */
-#include <stdio.h>
-
-typedef int (*ini_entry_handler)(void *, const char *, const char *,
-               const char *);
-
-/*
- * Parse given INI-style file. May have [section]s, name=value pairs
- * (whitespace stripped), and comments starting with ';' (semicolon). Section
- * is "" if name=value pair parsed before any section heading. name:value
- * pairs are also supported as a concession to Python's ConfigParser.
- *
- * For each name=value pair parsed, call handler function with given user
- * pointer as well as section, name, and value (data only valid for duration
- * of handler call). Handler should return zero on success, < 0 on error.
- *
- * Returns 0 on success, line number of first error on parse error (doesn't
- * stop on first error), -1 on file open error, or -2 on memory allocation
- * error (only when INI_USE_STACK is zero).
- */
-int ini_parse(const char *filename, ini_entry_handler handler, void *user);
-
-/*
- * Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
- * close the file when it's finished -- the caller must do that.
- */
-int ini_parse_file(FILE *file, ini_entry_handler handler, void *user);
-
-/*
- * Nonzero to allow multi-line value parsing, in the style of Python's
- * ConfigParser. If allowed, ini_parse() will call the handler with the same
- * name for each subsequent line parsed.
- */
-#ifndef INI_ALLOW_MULTILINE
-#define INI_ALLOW_MULTILINE 1
-#endif
-
-/*
- * Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
- * the file. See http://code.google.com/p/inih/issues/detail?id=21
- */
-#ifndef INI_ALLOW_BOM
-#define INI_ALLOW_BOM 1
-#endif
-
-/* Nonzero to use stack, zero to use heap (malloc/free). */
-#ifndef INI_USE_STACK
-#define INI_USE_STACK 1
-#endif
-
-/* Maximum line length for any line in INI file. */
-#ifndef INI_MAX_LINE
-#define INI_MAX_LINE 200
-#endif
-
-#endif /* __INI_H__ */
diff --git a/src/common/ini-config/ini.hpp b/src/common/ini-config/ini.hpp
new file mode 100644 (file)
index 0000000..34b3654
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * inih -- simple .INI file parser
+ *
+ * The "inih" library is distributed under the New BSD license:
+ *
+ * Copyright (C) 2009 Brush Technology - All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *     * Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Brush Technology nor the names of its contributors
+ *     may be used to endorse or promote products derived from this software
+ *     without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BRUSH TECHNOLOGY ''AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL BRUSH TECHNOLOGY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://code.google.com/p/inih/
+ */
+
+#ifndef __INI_H__
+#define __INI_H__
+
+/* Make this header file easier to include in C++ code */
+#include <stdio.h>
+
+typedef int (*ini_entry_handler)(void *, const char *, const char *,
+               const char *);
+
+/*
+ * Parse given INI-style file. May have [section]s, name=value pairs
+ * (whitespace stripped), and comments starting with ';' (semicolon). Section
+ * is "" if name=value pair parsed before any section heading. name:value
+ * pairs are also supported as a concession to Python's ConfigParser.
+ *
+ * For each name=value pair parsed, call handler function with given user
+ * pointer as well as section, name, and value (data only valid for duration
+ * of handler call). Handler should return zero on success, < 0 on error.
+ *
+ * Returns 0 on success, line number of first error on parse error (doesn't
+ * stop on first error), -1 on file open error, or -2 on memory allocation
+ * error (only when INI_USE_STACK is zero).
+ */
+int ini_parse(const char *filename, ini_entry_handler handler, void *user);
+
+/*
+ * Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
+ * close the file when it's finished -- the caller must do that.
+ */
+int ini_parse_file(FILE *file, ini_entry_handler handler, void *user);
+
+/*
+ * Nonzero to allow multi-line value parsing, in the style of Python's
+ * ConfigParser. If allowed, ini_parse() will call the handler with the same
+ * name for each subsequent line parsed.
+ */
+#ifndef INI_ALLOW_MULTILINE
+#define INI_ALLOW_MULTILINE 1
+#endif
+
+/*
+ * Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
+ * the file. See http://code.google.com/p/inih/issues/detail?id=21
+ */
+#ifndef INI_ALLOW_BOM
+#define INI_ALLOW_BOM 1
+#endif
+
+/* Nonzero to use stack, zero to use heap (malloc/free). */
+#ifndef INI_USE_STACK
+#define INI_USE_STACK 1
+#endif
+
+/* Maximum line length for any line in INI file. */
+#ifndef INI_MAX_LINE
+#define INI_MAX_LINE 200
+#endif
+
+#endif /* __INI_H__ */
index fa3e8a55377213dc5e5e91d6b0c660b6c890caab..95036a44cc6bdda6dec41d009182807fbbd76650 100644 (file)
 #include <sys/stat.h>
 #include <stdint.h>
 
-#include <bin/lttng-consumerd/health-consumerd.h>
-#include <common/common.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/compat/fcntl.h>
-#include <common/compat/endian.h>
-#include <common/pipe.h>
-#include <common/relayd/relayd.h>
-#include <common/utils.h>
-#include <common/consumer/consumer-stream.h>
-#include <common/index/index.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/optional.h>
-#include <common/buffer-view.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/metadata-bucket.h>
-
-#include "kernel-consumer.h"
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <common/common.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/compat/fcntl.hpp>
+#include <common/compat/endian.hpp>
+#include <common/pipe.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/utils.hpp>
+#include <common/consumer/consumer-stream.hpp>
+#include <common/index/index.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/optional.hpp>
+#include <common/buffer-view.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/consumer/metadata-bucket.hpp>
+
+#include "kernel-consumer.hpp"
 
 extern struct lttng_consumer_global_data the_consumer_data;
 extern int consumer_poll_timeout;
diff --git a/src/common/kernel-consumer/kernel-consumer.h b/src/common/kernel-consumer/kernel-consumer.h
deleted file mode 100644 (file)
index bd885f8..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_KCONSUMER_H
-#define _LTTNG_KCONSUMER_H
-
-#include <stdbool.h>
-#include <common/consumer/consumer.h>
-
-int lttng_kconsumer_take_snapshot(struct lttng_consumer_stream *stream);
-int lttng_kconsumer_sample_snapshot_positions(
-               struct lttng_consumer_stream *stream);
-int lttng_kconsumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
-               unsigned long *pos);
-int lttng_kconsumer_get_consumed_snapshot(struct lttng_consumer_stream *stream,
-               unsigned long *pos);
-int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
-               int sock, struct pollfd *consumer_sockpoll);
-int lttng_kconsumer_on_recv_stream(struct lttng_consumer_stream *stream);
-int lttng_kconsumer_data_pending(struct lttng_consumer_stream *stream);
-enum sync_metadata_status lttng_kconsumer_sync_metadata(
-               struct lttng_consumer_stream *metadata);
-
-#endif /* _LTTNG_KCONSUMER_H */
diff --git a/src/common/kernel-consumer/kernel-consumer.hpp b/src/common/kernel-consumer/kernel-consumer.hpp
new file mode 100644 (file)
index 0000000..7070cfa
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_KCONSUMER_H
+#define _LTTNG_KCONSUMER_H
+
+#include <stdbool.h>
+#include <common/consumer/consumer.hpp>
+
+int lttng_kconsumer_take_snapshot(struct lttng_consumer_stream *stream);
+int lttng_kconsumer_sample_snapshot_positions(
+               struct lttng_consumer_stream *stream);
+int lttng_kconsumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
+               unsigned long *pos);
+int lttng_kconsumer_get_consumed_snapshot(struct lttng_consumer_stream *stream,
+               unsigned long *pos);
+int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
+               int sock, struct pollfd *consumer_sockpoll);
+int lttng_kconsumer_on_recv_stream(struct lttng_consumer_stream *stream);
+int lttng_kconsumer_data_pending(struct lttng_consumer_stream *stream);
+enum sync_metadata_status lttng_kconsumer_sync_metadata(
+               struct lttng_consumer_stream *metadata);
+
+#endif /* _LTTNG_KCONSUMER_H */
index 8a43239ef5f76037c9c9bfe4fd93b5ca8c95f8e2..059ab4b0dc5a41060818c624abb1e5d16528520e 100644 (file)
 #define __USE_LINUX_IOCTL_DEFS
 #include <sys/ioctl.h>
 #include <string.h>
-#include <common/align.h>
-#include <common/macros.h>
-#include <common/compat/errno.h>
+#include <common/align.hpp>
+#include <common/macros.hpp>
+#include <common/compat/errno.hpp>
 #include <stdarg.h>
-#include <common/time.h>
+#include <common/time.hpp>
 
-#include "kernel-ctl.h"
-#include "kernel-ioctl.h"
+#include "kernel-ctl.hpp"
+#include "kernel-ioctl.hpp"
 
 #define LTTNG_IOCTL_CHECK(fildes, request, ...)                         \
        ({                                                              \
diff --git a/src/common/kernel-ctl/kernel-ctl.h b/src/common/kernel-ctl/kernel-ctl.h
deleted file mode 100644 (file)
index f512e69..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_KERNEL_CTL_H
-#define _LTTNG_KERNEL_CTL_H
-
-#include <stdbool.h>
-
-#include <lttng/lttng.h>
-#include <common/lttng-kernel.h>
-#include <common/lttng-kernel-old.h>
-#include <common/sessiond-comm/sessiond-comm.h>        /* for struct lttng_filter_bytecode */
-
-int kernctl_create_session(int fd);
-int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops);
-int kernctl_create_channel(int fd, struct lttng_channel_attr *chops);
-int kernctl_create_stream(int fd);
-int kernctl_create_event(int fd, struct lttng_kernel_abi_event *ev);
-int kernctl_add_context(int fd, struct lttng_kernel_abi_context *ctx);
-
-int kernctl_enable(int fd);
-int kernctl_disable(int fd);
-int kernctl_start_session(int fd);
-int kernctl_stop_session(int fd);
-
-int kernctl_create_event_notifier_group(int fd);
-
-/* Apply on event notifier_group file descriptor. */
-int kernctl_create_event_notifier_group_notification_fd(int fd);
-int kernctl_create_event_notifier_group_error_counter(int fd,
-               const struct lttng_kernel_abi_counter_conf *error_counter_conf);
-int kernctl_create_event_notifier(int fd,
-               const struct lttng_kernel_abi_event_notifier *event_notifier);
-
-int kernctl_counter_get_aggregate_value(int counter_fd,
-               struct lttng_kernel_abi_counter_aggregate *value);
-int kernctl_counter_clear(int counter_fd,
-               struct lttng_kernel_abi_counter_clear *clear);
-
-/* Apply on event file descriptor. */
-int kernctl_filter(int fd, const struct lttng_bytecode *filter);
-int kernctl_add_callsite(int fd, struct lttng_kernel_abi_event_callsite *callsite);
-int kernctl_capture(int fd, const struct lttng_bytecode *capture);
-
-int kernctl_tracepoint_list(int fd);
-int kernctl_syscall_list(int fd);
-int kernctl_tracer_version(int fd, struct lttng_kernel_abi_tracer_version *v);
-int kernctl_tracer_abi_version(int fd, struct lttng_kernel_abi_tracer_abi_version *v);
-int kernctl_wait_quiescent(int fd);
-
-/*
- * kernctl_syscall_mask - Get syscall mask associated to a channel file
- * descriptor.
- *
- * The parameter @syscall_mask should initially be either NULL or point
- * to memory allocated with malloc(3) or realloc(3). When the function
- * returns, it will point to a memory area of the size required for the
- * bitmask (using realloc(3) to resize the memory).
- *
- * It returns 0 if OK, -1 on error. In all cases (error and OK),
- * @syscall_mask should be freed by the caller with free(3).
- */
-int kernctl_syscall_mask(int fd, char **syscall_mask,
-               uint32_t *nr_bits);
-
-/* Process ID tracking can be applied to session file descriptor. */
-int kernctl_track_pid(int fd, int pid);
-int kernctl_untrack_pid(int fd, int pid);
-int kernctl_list_tracker_pids(int fd);
-
-int kernctl_track_id(int fd, enum lttng_process_attr process_attr, int id);
-int kernctl_untrack_id(int fd, enum lttng_process_attr process_attr, int id);
-int kernctl_list_tracker_ids(int fd, enum lttng_process_attr process_attr);
-
-int kernctl_session_regenerate_metadata(int fd);
-int kernctl_session_regenerate_statedump(int fd);
-int kernctl_session_set_name(int fd, const char *name);
-int kernctl_session_set_creation_time(int fd, time_t time);
-
-/* Buffer operations */
-
-/* For mmap mode, readable without "get" operation */
-int kernctl_get_mmap_len(int fd, unsigned long *len);
-int kernctl_get_max_subbuf_size(int fd, unsigned long *len);
-
-/*
- * For mmap mode, operate on the current packet (between get/put or
- * get_next/put_next).
- */
-int kernctl_get_mmap_read_offset(int fd, unsigned long *len);
-int kernctl_get_subbuf_size(int fd, unsigned long *len);
-int kernctl_get_padded_subbuf_size(int fd, unsigned long *len);
-
-int kernctl_get_next_subbuf(int fd);
-int kernctl_put_next_subbuf(int fd);
-
-/* snapshot */
-int kernctl_snapshot(int fd);
-int kernctl_snapshot_sample_positions(int fd);
-int kernctl_snapshot_get_consumed(int fd, unsigned long *pos);
-int kernctl_snapshot_get_produced(int fd, unsigned long *pos);
-int kernctl_get_subbuf(int fd, unsigned long *pos);
-int kernctl_put_subbuf(int fd);
-
-int kernctl_buffer_flush(int fd);
-int kernctl_buffer_flush_empty(int fd);
-int kernctl_buffer_clear(int fd);
-int kernctl_get_metadata_version(int fd, uint64_t *version);
-int kernctl_metadata_cache_dump(int fd);
-int kernctl_get_next_subbuf_metadata_check(int fd, bool *consistent);
-
-/* index */
-int kernctl_get_timestamp_begin(int fd, uint64_t *timestamp_begin);
-int kernctl_get_timestamp_end(int fd, uint64_t *timestamp_end);
-int kernctl_get_events_discarded(int fd, uint64_t *events_discarded);
-int kernctl_get_content_size(int fd, uint64_t *content_size);
-int kernctl_get_packet_size(int fd, uint64_t *packet_size);
-int kernctl_get_stream_id(int fd, uint64_t *stream_id);
-int kernctl_get_current_timestamp(int fd, uint64_t *ts);
-int kernctl_get_sequence_number(int fd, uint64_t *seq);
-int kernctl_get_instance_id(int fd, uint64_t *seq);
-
-#endif /* _LTTNG_KERNEL_CTL_H */
diff --git a/src/common/kernel-ctl/kernel-ctl.hpp b/src/common/kernel-ctl/kernel-ctl.hpp
new file mode 100644 (file)
index 0000000..4f47488
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_KERNEL_CTL_H
+#define _LTTNG_KERNEL_CTL_H
+
+#include <stdbool.h>
+
+#include <lttng/lttng.h>
+#include <common/lttng-kernel.hpp>
+#include <common/lttng-kernel-old.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>      /* for struct lttng_filter_bytecode */
+
+int kernctl_create_session(int fd);
+int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops);
+int kernctl_create_channel(int fd, struct lttng_channel_attr *chops);
+int kernctl_create_stream(int fd);
+int kernctl_create_event(int fd, struct lttng_kernel_abi_event *ev);
+int kernctl_add_context(int fd, struct lttng_kernel_abi_context *ctx);
+
+int kernctl_enable(int fd);
+int kernctl_disable(int fd);
+int kernctl_start_session(int fd);
+int kernctl_stop_session(int fd);
+
+int kernctl_create_event_notifier_group(int fd);
+
+/* Apply on event notifier_group file descriptor. */
+int kernctl_create_event_notifier_group_notification_fd(int fd);
+int kernctl_create_event_notifier_group_error_counter(int fd,
+               const struct lttng_kernel_abi_counter_conf *error_counter_conf);
+int kernctl_create_event_notifier(int fd,
+               const struct lttng_kernel_abi_event_notifier *event_notifier);
+
+int kernctl_counter_get_aggregate_value(int counter_fd,
+               struct lttng_kernel_abi_counter_aggregate *value);
+int kernctl_counter_clear(int counter_fd,
+               struct lttng_kernel_abi_counter_clear *clear);
+
+/* Apply on event file descriptor. */
+int kernctl_filter(int fd, const struct lttng_bytecode *filter);
+int kernctl_add_callsite(int fd, struct lttng_kernel_abi_event_callsite *callsite);
+int kernctl_capture(int fd, const struct lttng_bytecode *capture);
+
+int kernctl_tracepoint_list(int fd);
+int kernctl_syscall_list(int fd);
+int kernctl_tracer_version(int fd, struct lttng_kernel_abi_tracer_version *v);
+int kernctl_tracer_abi_version(int fd, struct lttng_kernel_abi_tracer_abi_version *v);
+int kernctl_wait_quiescent(int fd);
+
+/*
+ * kernctl_syscall_mask - Get syscall mask associated to a channel file
+ * descriptor.
+ *
+ * The parameter @syscall_mask should initially be either NULL or point
+ * to memory allocated with malloc(3) or realloc(3). When the function
+ * returns, it will point to a memory area of the size required for the
+ * bitmask (using realloc(3) to resize the memory).
+ *
+ * It returns 0 if OK, -1 on error. In all cases (error and OK),
+ * @syscall_mask should be freed by the caller with free(3).
+ */
+int kernctl_syscall_mask(int fd, char **syscall_mask,
+               uint32_t *nr_bits);
+
+/* Process ID tracking can be applied to session file descriptor. */
+int kernctl_track_pid(int fd, int pid);
+int kernctl_untrack_pid(int fd, int pid);
+int kernctl_list_tracker_pids(int fd);
+
+int kernctl_track_id(int fd, enum lttng_process_attr process_attr, int id);
+int kernctl_untrack_id(int fd, enum lttng_process_attr process_attr, int id);
+int kernctl_list_tracker_ids(int fd, enum lttng_process_attr process_attr);
+
+int kernctl_session_regenerate_metadata(int fd);
+int kernctl_session_regenerate_statedump(int fd);
+int kernctl_session_set_name(int fd, const char *name);
+int kernctl_session_set_creation_time(int fd, time_t time);
+
+/* Buffer operations */
+
+/* For mmap mode, readable without "get" operation */
+int kernctl_get_mmap_len(int fd, unsigned long *len);
+int kernctl_get_max_subbuf_size(int fd, unsigned long *len);
+
+/*
+ * For mmap mode, operate on the current packet (between get/put or
+ * get_next/put_next).
+ */
+int kernctl_get_mmap_read_offset(int fd, unsigned long *len);
+int kernctl_get_subbuf_size(int fd, unsigned long *len);
+int kernctl_get_padded_subbuf_size(int fd, unsigned long *len);
+
+int kernctl_get_next_subbuf(int fd);
+int kernctl_put_next_subbuf(int fd);
+
+/* snapshot */
+int kernctl_snapshot(int fd);
+int kernctl_snapshot_sample_positions(int fd);
+int kernctl_snapshot_get_consumed(int fd, unsigned long *pos);
+int kernctl_snapshot_get_produced(int fd, unsigned long *pos);
+int kernctl_get_subbuf(int fd, unsigned long *pos);
+int kernctl_put_subbuf(int fd);
+
+int kernctl_buffer_flush(int fd);
+int kernctl_buffer_flush_empty(int fd);
+int kernctl_buffer_clear(int fd);
+int kernctl_get_metadata_version(int fd, uint64_t *version);
+int kernctl_metadata_cache_dump(int fd);
+int kernctl_get_next_subbuf_metadata_check(int fd, bool *consistent);
+
+/* index */
+int kernctl_get_timestamp_begin(int fd, uint64_t *timestamp_begin);
+int kernctl_get_timestamp_end(int fd, uint64_t *timestamp_end);
+int kernctl_get_events_discarded(int fd, uint64_t *events_discarded);
+int kernctl_get_content_size(int fd, uint64_t *content_size);
+int kernctl_get_packet_size(int fd, uint64_t *packet_size);
+int kernctl_get_stream_id(int fd, uint64_t *stream_id);
+int kernctl_get_current_timestamp(int fd, uint64_t *ts);
+int kernctl_get_sequence_number(int fd, uint64_t *seq);
+int kernctl_get_instance_id(int fd, uint64_t *seq);
+
+#endif /* _LTTNG_KERNEL_CTL_H */
diff --git a/src/common/kernel-ctl/kernel-ioctl.h b/src/common/kernel-ctl/kernel-ioctl.h
deleted file mode 100644 (file)
index 68bcc47..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_KERNEL_IOCTL_H
-#define _LTT_KERNEL_IOCTL_H
-
-#define LTTNG_KERNEL_ABI_MAJOR_VERSION         2
-#define LTTNG_KERNEL_ABI_MINOR_VERSION         6
-
-/* Get a snapshot of the current ring buffer producer and consumer positions */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT                _IO(0xF6, 0x00)
-/* Get the consumer position (iteration start) */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_CONSUMED   _IOR(0xF6, 0x01, unsigned long)
-/* Get the producer position (iteration end) */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_PRODUCED   _IOR(0xF6, 0x02, unsigned long)
-/* Get exclusive read access to the specified sub-buffer position */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF              _IOW(0xF6, 0x03, unsigned long)
-/* Release exclusive sub-buffer access */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_PUT_SUBBUF              _IO(0xF6, 0x04)
-
-/* Get exclusive read access to the next sub-buffer that can be read. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF         _IO(0xF6, 0x05)
-/* Release exclusive sub-buffer access, move consumer forward. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_PUT_NEXT_SUBBUF         _IO(0xF6, 0x06)
-/* returns the size of the current sub-buffer, without padding (for mmap). */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF_SIZE         _IOR(0xF6, 0x07, unsigned long)
-/* returns the size of the current sub-buffer, with padding (for splice). */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_PADDED_SUBBUF_SIZE  _IOR(0xF6, 0x08, unsigned long)
-/* returns the maximum size for sub-buffers. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MAX_SUBBUF_SIZE     _IOR(0xF6, 0x09, unsigned long)
-/* returns the length to mmap. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_LEN            _IOR(0xF6, 0x0A, unsigned long)
-/* returns the offset of the subbuffer belonging to the mmap reader. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_READ_OFFSET    _IOR(0xF6, 0x0B, unsigned long)
-/* Flush the current sub-buffer, if non-empty. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH                   _IO(0xF6, 0x0C)
-/* Get the current version of the metadata cache (after a get_next). */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_METADATA_VERSION    _IOR(0xF6, 0x0D, uint64_t)
-/*
- * Get a snapshot of the current ring buffer producer and consumer positions,
- * regardless of whether or not the two positions are contained within the same
- * sub-buffer.
- */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS _IO(0xF6, 0x0E)
-/* Flush the current sub-buffer, even if empty. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY                       _IO(0xF6, 0x0F)
-/*
- * Reset the position of what has been consumed from the metadata cache to 0
- * so it can be read again.
- */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_METADATA_CACHE_DUMP               _IO(0xF6, 0x10)
-/* Clear ring buffer content */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_CLEAR                               _IO(0xF6, 0x11)
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK _IOR(0xF6, 0x12, uint32_t)
-
-/* returns the timestamp begin of the current sub-buffer */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_TIMESTAMP_BEGIN     _IOR(0xF6, 0x20, uint64_t)
-/* returns the timestamp end of the current sub-buffer */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_TIMESTAMP_END       _IOR(0xF6, 0x21, uint64_t)
-/* returns the number of events discarded */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_EVENTS_DISCARDED    _IOR(0xF6, 0x22, uint64_t)
-/* returns the packet payload size */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_CONTENT_SIZE        _IOR(0xF6, 0x23, uint64_t)
-/* returns the actual packet size */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_PACKET_SIZE         _IOR(0xF6, 0x24, uint64_t)
-/* returns the stream id */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_STREAM_ID           _IOR(0xF6, 0x25, uint64_t)
-/* returns the current timestamp */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_CURRENT_TIMESTAMP   _IOR(0xF6, 0x26, uint64_t)
-/* returns the packet sequence number */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SEQ_NUM             _IOR(0xF6, 0x27, uint64_t)
-/* returns the stream instance id */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_INSTANCE_ID             _IOR(0xF6, 0x28, uint64_t)
-
-/* Old ABI (without support for 32/64 bits compat) */
-/* LTTng file descriptor ioctl */
-#define LTTNG_KERNEL_ABI_OLD_SESSION                _IO(0xF6, 0x40)
-#define LTTNG_KERNEL_ABI_OLD_TRACER_VERSION         \
-               _IOR(0xF6, 0x41, struct lttng_kernel_abi_old_tracer_version)
-#define LTTNG_KERNEL_ABI_OLD_TRACEPOINT_LIST        _IO(0xF6, 0x42)
-#define LTTNG_KERNEL_ABI_OLD_WAIT_QUIESCENT         _IO(0xF6, 0x43)
-
-/* Session FD ioctl */
-#define LTTNG_KERNEL_ABI_OLD_METADATA               \
-               _IOW(0xF6, 0x50, struct lttng_kernel_abi_old_channel)
-#define LTTNG_KERNEL_ABI_OLD_CHANNEL                \
-               _IOW(0xF6, 0x51, struct lttng_kernel_abi_old_channel)
-#define LTTNG_KERNEL_ABI_OLD_SESSION_START          _IO(0xF6, 0x52)
-#define LTTNG_KERNEL_ABI_OLD_SESSION_STOP           _IO(0xF6, 0x53)
-
-/* Channel FD ioctl */
-#define LTTNG_KERNEL_ABI_OLD_STREAM                 _IO(0xF6, 0x60)
-#define LTTNG_KERNEL_ABI_OLD_EVENT                  \
-               _IOW(0xF6, 0x61, struct lttng_kernel_abi_old_event)
-
-/* Event and Channel FD ioctl */
-#define LTTNG_KERNEL_ABI_OLD_CONTEXT                \
-               _IOW(0xF6, 0x70, struct lttng_kernel_abi_old_context)
-
-/* Event, Channel and Session ioctl */
-#define LTTNG_KERNEL_ABI_OLD_ENABLE                 _IO(0xF6, 0x80)
-#define LTTNG_KERNEL_ABI_OLD_DISABLE                _IO(0xF6, 0x81)
-
-
-/* Current ABI (with suport for 32/64 bits compat) */
-/* LTTng file descriptor ioctl */
-#define LTTNG_KERNEL_ABI_SESSION               _IO(0xF6, 0x45)
-#define LTTNG_KERNEL_ABI_TRACER_VERSION                \
-       _IOR(0xF6, 0x46, struct lttng_kernel_abi_tracer_version)
-#define LTTNG_KERNEL_ABI_TRACEPOINT_LIST       _IO(0xF6, 0x47)
-#define LTTNG_KERNEL_ABI_WAIT_QUIESCENT                _IO(0xF6, 0x48)
-#define LTTNG_KERNEL_ABI_SYSCALL_LIST          _IO(0xF6, 0x4A)
-#define LTTNG_KERNEL_ABI_TRACER_ABI_VERSION            \
-       _IOR(0xF6, 0x4B, struct lttng_kernel_abi_tracer_abi_version)
-#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_CREATE \
-       _IO(0xF6, 0x4C)
-
-/* Session FD ioctl */
-#define LTTNG_KERNEL_ABI_METADATA                      \
-       _IOW(0xF6, 0x54, struct lttng_kernel_abi_channel)
-#define LTTNG_KERNEL_ABI_CHANNEL                       \
-       _IOW(0xF6, 0x55, struct lttng_kernel_abi_channel)
-#define LTTNG_KERNEL_ABI_SESSION_START         _IO(0xF6, 0x56)
-#define LTTNG_KERNEL_ABI_SESSION_STOP          _IO(0xF6, 0x57)
-#define LTTNG_KERNEL_ABI_SESSION_TRACK_PID             \
-       _IOW(0xF6, 0x58, int32_t)
-#define LTTNG_KERNEL_ABI_SESSION_UNTRACK_PID   \
-       _IOW(0xF6, 0x59, int32_t)
-/*
- * ioctl 0x58 and 0x59 are duplicated here. It works, since _IOR vs _IO
- * are generating two different ioctl numbers, but this was not done on
- * purpose. We should generally try to avoid those duplications.
- */
-#define LTTNG_KERNEL_ABI_SESSION_LIST_TRACKER_PIDS  _IO(0xF6, 0x58)
-#define LTTNG_KERNEL_ABI_SESSION_METADATA_REGEN            _IO(0xF6, 0x59)
-/* 0x5A and 0x5B are reserved for a future ABI-breaking cleanup. */
-#define LTTNG_KERNEL_ABI_SESSION_STATEDUMP         _IO(0xF6, 0x5C)
-#define LTTNG_KERNEL_ABI_SESSION_SET_NAME              \
-       _IOW(0xF6, 0x5D, struct lttng_kernel_abi_session_name)
-#define LTTNG_KERNEL_ABI_SESSION_SET_CREATION_TIME             \
-       _IOW(0xF6, 0x5E, struct lttng_kernel_abi_session_creation_time)
-
-/* Channel FD ioctl */
-#define LTTNG_KERNEL_ABI_STREAM                        _IO(0xF6, 0x62)
-#define LTTNG_KERNEL_ABI_EVENT                 \
-       _IOW(0xF6, 0x63, struct lttng_kernel_abi_event)
-#define LTTNG_KERNEL_ABI_SYSCALL_MASK          \
-       _IOWR(0xF6, 0x64, struct lttng_kernel_abi_syscall_mask)
-
-/* Event and Channel FD ioctl */
-#define LTTNG_KERNEL_ABI_CONTEXT                       \
-       _IOW(0xF6, 0x71, struct lttng_kernel_abi_context)
-
-/* Event, event notifier, Channel and Session ioctl */
-#define LTTNG_KERNEL_ABI_ENABLE                        _IO(0xF6, 0x82)
-#define LTTNG_KERNEL_ABI_DISABLE               _IO(0xF6, 0x83)
-
-/* Event notifier group ioctl */
-#define LTTNG_KERNEL_ABI_COUNTER                       \
-       _IOW(0xF6, 0x84, struct lttng_kernel_abi_counter_conf)
-
-/* Event and event notifier FD ioctl */
-#define LTTNG_KERNEL_ABI_FILTER                        _IO(0xF6, 0x90)
-#define LTTNG_KERNEL_ABI_ADD_CALLSITE          _IO(0xF6, 0x91)
-
-/* Session FD ioctl (continued) */
-#define LTTNG_KERNEL_ABI_SESSION_LIST_TRACKER_IDS      \
-       _IOW(0xF6, 0xA0, struct lttng_kernel_abi_tracker_args)
-#define LTTNG_KERNEL_ABI_SESSION_TRACK_ID              \
-       _IOW(0xF6, 0xA1, struct lttng_kernel_abi_tracker_args)
-#define LTTNG_KERNEL_ABI_SESSION_UNTRACK_ID            \
-       _IOW(0xF6, 0xA2, struct lttng_kernel_abi_tracker_args)
-
-/* Event notifier group file descriptor ioctl */
-#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_CREATE                 \
-       _IOW(0xF6, 0xB0, struct lttng_kernel_abi_event_notifier)
-#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD  \
-       _IO(0xF6, 0xB1)
-
-/* Event notifier file descriptor ioctl */
-#define LTTNG_KERNEL_ABI_CAPTURE               _IO(0xF6, 0xB8)
-
-/* Counter file descriptor ioctl */
-#define LTTNG_KERNEL_ABI_COUNTER_READ          \
-       IOWR(0xF6, 0xC0, struct lttng_kernel_abi_counter_read)
-#define LTTNG_KERNEL_ABI_COUNTER_AGGREGATE             \
-       _IOWR(0xF6, 0xC1, struct lttng_kernel_abi_counter_aggregate)
-#define LTTNG_KERNEL_ABI_COUNTER_CLEAR         \
-       _IOW(0xF6, 0xC2, struct lttng_kernel_abi_counter_clear)
-
-/*
-  * Those ioctl numbers use the wrong direction, but are kept for ABI backward
-  * compatibility.
-  */
- #define LTTNG_KERNEL_ABI_OLD_SESSION_SET_NAME        \
-     _IOR(0xF6, 0x5D, struct lttng_kernel_abi_session_name)
- #define LTTNG_KERNEL_ABI_OLD_SESSION_SET_CREATION_TIME    \
-     _IOR(0xF6, 0x5E, struct lttng_kernel_abi_session_creation_time)
- #define LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_PID        \
-     _IOW(0xF6, 0x58, int32_t)
- #define LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_PID    \
-     _IOW(0xF6, 0x59, int32_t)
- #define LTTNG_KERNEL_ABI_OLD_SESSION_LIST_TRACKER_IDS    \
-     _IOR(0xF6, 0xA0, struct lttng_kernel_abi_tracker_args)
- #define LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_ID        \
-     _IOR(0xF6, 0xA1, struct lttng_kernel_abi_tracker_args)
- #define LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_ID        \
-     _IOR(0xF6, 0xA2, struct lttng_kernel_abi_tracker_args)
-
-#endif /* _LTT_KERNEL_IOCTL_H */
diff --git a/src/common/kernel-ctl/kernel-ioctl.hpp b/src/common/kernel-ctl/kernel-ioctl.hpp
new file mode 100644 (file)
index 0000000..68bcc47
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_KERNEL_IOCTL_H
+#define _LTT_KERNEL_IOCTL_H
+
+#define LTTNG_KERNEL_ABI_MAJOR_VERSION         2
+#define LTTNG_KERNEL_ABI_MINOR_VERSION         6
+
+/* Get a snapshot of the current ring buffer producer and consumer positions */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT                _IO(0xF6, 0x00)
+/* Get the consumer position (iteration start) */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_CONSUMED   _IOR(0xF6, 0x01, unsigned long)
+/* Get the producer position (iteration end) */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_PRODUCED   _IOR(0xF6, 0x02, unsigned long)
+/* Get exclusive read access to the specified sub-buffer position */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF              _IOW(0xF6, 0x03, unsigned long)
+/* Release exclusive sub-buffer access */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_PUT_SUBBUF              _IO(0xF6, 0x04)
+
+/* Get exclusive read access to the next sub-buffer that can be read. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF         _IO(0xF6, 0x05)
+/* Release exclusive sub-buffer access, move consumer forward. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_PUT_NEXT_SUBBUF         _IO(0xF6, 0x06)
+/* returns the size of the current sub-buffer, without padding (for mmap). */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF_SIZE         _IOR(0xF6, 0x07, unsigned long)
+/* returns the size of the current sub-buffer, with padding (for splice). */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_PADDED_SUBBUF_SIZE  _IOR(0xF6, 0x08, unsigned long)
+/* returns the maximum size for sub-buffers. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MAX_SUBBUF_SIZE     _IOR(0xF6, 0x09, unsigned long)
+/* returns the length to mmap. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_LEN            _IOR(0xF6, 0x0A, unsigned long)
+/* returns the offset of the subbuffer belonging to the mmap reader. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_READ_OFFSET    _IOR(0xF6, 0x0B, unsigned long)
+/* Flush the current sub-buffer, if non-empty. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH                   _IO(0xF6, 0x0C)
+/* Get the current version of the metadata cache (after a get_next). */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_METADATA_VERSION    _IOR(0xF6, 0x0D, uint64_t)
+/*
+ * Get a snapshot of the current ring buffer producer and consumer positions,
+ * regardless of whether or not the two positions are contained within the same
+ * sub-buffer.
+ */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS _IO(0xF6, 0x0E)
+/* Flush the current sub-buffer, even if empty. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY                       _IO(0xF6, 0x0F)
+/*
+ * Reset the position of what has been consumed from the metadata cache to 0
+ * so it can be read again.
+ */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_METADATA_CACHE_DUMP               _IO(0xF6, 0x10)
+/* Clear ring buffer content */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_CLEAR                               _IO(0xF6, 0x11)
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK _IOR(0xF6, 0x12, uint32_t)
+
+/* returns the timestamp begin of the current sub-buffer */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_TIMESTAMP_BEGIN     _IOR(0xF6, 0x20, uint64_t)
+/* returns the timestamp end of the current sub-buffer */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_TIMESTAMP_END       _IOR(0xF6, 0x21, uint64_t)
+/* returns the number of events discarded */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_EVENTS_DISCARDED    _IOR(0xF6, 0x22, uint64_t)
+/* returns the packet payload size */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_CONTENT_SIZE        _IOR(0xF6, 0x23, uint64_t)
+/* returns the actual packet size */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_PACKET_SIZE         _IOR(0xF6, 0x24, uint64_t)
+/* returns the stream id */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_STREAM_ID           _IOR(0xF6, 0x25, uint64_t)
+/* returns the current timestamp */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_CURRENT_TIMESTAMP   _IOR(0xF6, 0x26, uint64_t)
+/* returns the packet sequence number */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SEQ_NUM             _IOR(0xF6, 0x27, uint64_t)
+/* returns the stream instance id */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_INSTANCE_ID             _IOR(0xF6, 0x28, uint64_t)
+
+/* Old ABI (without support for 32/64 bits compat) */
+/* LTTng file descriptor ioctl */
+#define LTTNG_KERNEL_ABI_OLD_SESSION                _IO(0xF6, 0x40)
+#define LTTNG_KERNEL_ABI_OLD_TRACER_VERSION         \
+               _IOR(0xF6, 0x41, struct lttng_kernel_abi_old_tracer_version)
+#define LTTNG_KERNEL_ABI_OLD_TRACEPOINT_LIST        _IO(0xF6, 0x42)
+#define LTTNG_KERNEL_ABI_OLD_WAIT_QUIESCENT         _IO(0xF6, 0x43)
+
+/* Session FD ioctl */
+#define LTTNG_KERNEL_ABI_OLD_METADATA               \
+               _IOW(0xF6, 0x50, struct lttng_kernel_abi_old_channel)
+#define LTTNG_KERNEL_ABI_OLD_CHANNEL                \
+               _IOW(0xF6, 0x51, struct lttng_kernel_abi_old_channel)
+#define LTTNG_KERNEL_ABI_OLD_SESSION_START          _IO(0xF6, 0x52)
+#define LTTNG_KERNEL_ABI_OLD_SESSION_STOP           _IO(0xF6, 0x53)
+
+/* Channel FD ioctl */
+#define LTTNG_KERNEL_ABI_OLD_STREAM                 _IO(0xF6, 0x60)
+#define LTTNG_KERNEL_ABI_OLD_EVENT                  \
+               _IOW(0xF6, 0x61, struct lttng_kernel_abi_old_event)
+
+/* Event and Channel FD ioctl */
+#define LTTNG_KERNEL_ABI_OLD_CONTEXT                \
+               _IOW(0xF6, 0x70, struct lttng_kernel_abi_old_context)
+
+/* Event, Channel and Session ioctl */
+#define LTTNG_KERNEL_ABI_OLD_ENABLE                 _IO(0xF6, 0x80)
+#define LTTNG_KERNEL_ABI_OLD_DISABLE                _IO(0xF6, 0x81)
+
+
+/* Current ABI (with suport for 32/64 bits compat) */
+/* LTTng file descriptor ioctl */
+#define LTTNG_KERNEL_ABI_SESSION               _IO(0xF6, 0x45)
+#define LTTNG_KERNEL_ABI_TRACER_VERSION                \
+       _IOR(0xF6, 0x46, struct lttng_kernel_abi_tracer_version)
+#define LTTNG_KERNEL_ABI_TRACEPOINT_LIST       _IO(0xF6, 0x47)
+#define LTTNG_KERNEL_ABI_WAIT_QUIESCENT                _IO(0xF6, 0x48)
+#define LTTNG_KERNEL_ABI_SYSCALL_LIST          _IO(0xF6, 0x4A)
+#define LTTNG_KERNEL_ABI_TRACER_ABI_VERSION            \
+       _IOR(0xF6, 0x4B, struct lttng_kernel_abi_tracer_abi_version)
+#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_CREATE \
+       _IO(0xF6, 0x4C)
+
+/* Session FD ioctl */
+#define LTTNG_KERNEL_ABI_METADATA                      \
+       _IOW(0xF6, 0x54, struct lttng_kernel_abi_channel)
+#define LTTNG_KERNEL_ABI_CHANNEL                       \
+       _IOW(0xF6, 0x55, struct lttng_kernel_abi_channel)
+#define LTTNG_KERNEL_ABI_SESSION_START         _IO(0xF6, 0x56)
+#define LTTNG_KERNEL_ABI_SESSION_STOP          _IO(0xF6, 0x57)
+#define LTTNG_KERNEL_ABI_SESSION_TRACK_PID             \
+       _IOW(0xF6, 0x58, int32_t)
+#define LTTNG_KERNEL_ABI_SESSION_UNTRACK_PID   \
+       _IOW(0xF6, 0x59, int32_t)
+/*
+ * ioctl 0x58 and 0x59 are duplicated here. It works, since _IOR vs _IO
+ * are generating two different ioctl numbers, but this was not done on
+ * purpose. We should generally try to avoid those duplications.
+ */
+#define LTTNG_KERNEL_ABI_SESSION_LIST_TRACKER_PIDS  _IO(0xF6, 0x58)
+#define LTTNG_KERNEL_ABI_SESSION_METADATA_REGEN            _IO(0xF6, 0x59)
+/* 0x5A and 0x5B are reserved for a future ABI-breaking cleanup. */
+#define LTTNG_KERNEL_ABI_SESSION_STATEDUMP         _IO(0xF6, 0x5C)
+#define LTTNG_KERNEL_ABI_SESSION_SET_NAME              \
+       _IOW(0xF6, 0x5D, struct lttng_kernel_abi_session_name)
+#define LTTNG_KERNEL_ABI_SESSION_SET_CREATION_TIME             \
+       _IOW(0xF6, 0x5E, struct lttng_kernel_abi_session_creation_time)
+
+/* Channel FD ioctl */
+#define LTTNG_KERNEL_ABI_STREAM                        _IO(0xF6, 0x62)
+#define LTTNG_KERNEL_ABI_EVENT                 \
+       _IOW(0xF6, 0x63, struct lttng_kernel_abi_event)
+#define LTTNG_KERNEL_ABI_SYSCALL_MASK          \
+       _IOWR(0xF6, 0x64, struct lttng_kernel_abi_syscall_mask)
+
+/* Event and Channel FD ioctl */
+#define LTTNG_KERNEL_ABI_CONTEXT                       \
+       _IOW(0xF6, 0x71, struct lttng_kernel_abi_context)
+
+/* Event, event notifier, Channel and Session ioctl */
+#define LTTNG_KERNEL_ABI_ENABLE                        _IO(0xF6, 0x82)
+#define LTTNG_KERNEL_ABI_DISABLE               _IO(0xF6, 0x83)
+
+/* Event notifier group ioctl */
+#define LTTNG_KERNEL_ABI_COUNTER                       \
+       _IOW(0xF6, 0x84, struct lttng_kernel_abi_counter_conf)
+
+/* Event and event notifier FD ioctl */
+#define LTTNG_KERNEL_ABI_FILTER                        _IO(0xF6, 0x90)
+#define LTTNG_KERNEL_ABI_ADD_CALLSITE          _IO(0xF6, 0x91)
+
+/* Session FD ioctl (continued) */
+#define LTTNG_KERNEL_ABI_SESSION_LIST_TRACKER_IDS      \
+       _IOW(0xF6, 0xA0, struct lttng_kernel_abi_tracker_args)
+#define LTTNG_KERNEL_ABI_SESSION_TRACK_ID              \
+       _IOW(0xF6, 0xA1, struct lttng_kernel_abi_tracker_args)
+#define LTTNG_KERNEL_ABI_SESSION_UNTRACK_ID            \
+       _IOW(0xF6, 0xA2, struct lttng_kernel_abi_tracker_args)
+
+/* Event notifier group file descriptor ioctl */
+#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_CREATE                 \
+       _IOW(0xF6, 0xB0, struct lttng_kernel_abi_event_notifier)
+#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD  \
+       _IO(0xF6, 0xB1)
+
+/* Event notifier file descriptor ioctl */
+#define LTTNG_KERNEL_ABI_CAPTURE               _IO(0xF6, 0xB8)
+
+/* Counter file descriptor ioctl */
+#define LTTNG_KERNEL_ABI_COUNTER_READ          \
+       IOWR(0xF6, 0xC0, struct lttng_kernel_abi_counter_read)
+#define LTTNG_KERNEL_ABI_COUNTER_AGGREGATE             \
+       _IOWR(0xF6, 0xC1, struct lttng_kernel_abi_counter_aggregate)
+#define LTTNG_KERNEL_ABI_COUNTER_CLEAR         \
+       _IOW(0xF6, 0xC2, struct lttng_kernel_abi_counter_clear)
+
+/*
+  * Those ioctl numbers use the wrong direction, but are kept for ABI backward
+  * compatibility.
+  */
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_SET_NAME        \
+     _IOR(0xF6, 0x5D, struct lttng_kernel_abi_session_name)
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_SET_CREATION_TIME    \
+     _IOR(0xF6, 0x5E, struct lttng_kernel_abi_session_creation_time)
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_PID        \
+     _IOW(0xF6, 0x58, int32_t)
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_PID    \
+     _IOW(0xF6, 0x59, int32_t)
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_LIST_TRACKER_IDS    \
+     _IOR(0xF6, 0xA0, struct lttng_kernel_abi_tracker_args)
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_ID        \
+     _IOR(0xF6, 0xA1, struct lttng_kernel_abi_tracker_args)
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_ID        \
+     _IOR(0xF6, 0xA2, struct lttng_kernel_abi_tracker_args)
+
+#endif /* _LTT_KERNEL_IOCTL_H */
index a05b451c38dc406a68b4c5631841aaf649db96c8..979ca73111dc161b82cc4e6b8872ea5f9f34853c 100644 (file)
@@ -6,16 +6,16 @@
  */
 
 #include "lttng/lttng-error.h"
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
 #include <fcntl.h>
 #include <lttng/constant.h>
-#include <lttng/kernel-probe-internal.h>
+#include <lttng/kernel-probe-internal.hpp>
 #include <lttng/kernel-probe.h>
 #include <sys/stat.h>
 #include <sys/types.h>
index 80c4b4d554dff7fb1f354497040c2c20f40d1259..7e6ea79b0aac8baa6082ff5f06869e7771bac670 100644 (file)
@@ -5,10 +5,10 @@
  *
  */
 
-#include <lttng/location-internal.h>
-#include <common/macros.h>
+#include <lttng/location-internal.hpp>
+#include <common/macros.hpp>
 #include <stdlib.h>
-#include <common/error.h>
+#include <common/error.hpp>
 
 static
 struct lttng_trace_archive_location *lttng_trace_archive_location_create(
index e891222e0136842b6a1e86c8b922e20568067902..766e8b25becb60296b7afb750108c48098dfbda1 100644 (file)
@@ -5,13 +5,13 @@
  *
  */
 
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/log-level-rule-internal.h>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/log-level-rule-internal.hpp>
 #include <lttng/log-level-rule.h>
 #include <stdbool.h>
 #include <stdlib.h>
index 23d5cb7f0b9630ab233830e2e99d181ac016ca51..47d66936f9b9356c772da348f71ef849850e5dd9 100644 (file)
@@ -8,11 +8,11 @@
  */
 
 #include <algorithm>
-#include <common/compat/endian.h>
-#include <common/error.h>
-#include <common/lttng-elf.h>
-#include <common/macros.h>
-#include <common/readwrite.h>
+#include <common/compat/endian.hpp>
+#include <common/error.hpp>
+#include <common/lttng-elf.hpp>
+#include <common/macros.hpp>
+#include <common/readwrite.hpp>
 #include <fcntl.h>
 #include <stdbool.h>
 #include <stdint.h>
diff --git a/src/common/lttng-elf.h b/src/common/lttng-elf.h
deleted file mode 100644 (file)
index 41dd496..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _LTTNG_ELF_H
-#define _LTTNG_ELF_H
-/*
- * Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
- * Copyright (C) 2017 Erica Bugden <erica.bugden@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-or-later
- *
- */
-
-#include <lttng/lttng-export.h>
-
-extern "C" LTTNG_EXPORT
-int lttng_elf_get_symbol_offset(int fd, char *symbol, uint64_t *offset);
-
-extern "C" LTTNG_EXPORT
-int lttng_elf_get_sdt_probe_offsets(int fd, const char *provider_name,
-               const char *probe_name, uint64_t **offsets, uint32_t *nb_probe);
-
-#endif /* _LTTNG_ELF_H */
diff --git a/src/common/lttng-elf.hpp b/src/common/lttng-elf.hpp
new file mode 100644 (file)
index 0000000..41dd496
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef _LTTNG_ELF_H
+#define _LTTNG_ELF_H
+/*
+ * Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
+ * Copyright (C) 2017 Erica Bugden <erica.bugden@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ */
+
+#include <lttng/lttng-export.h>
+
+extern "C" LTTNG_EXPORT
+int lttng_elf_get_symbol_offset(int fd, char *symbol, uint64_t *offset);
+
+extern "C" LTTNG_EXPORT
+int lttng_elf_get_sdt_probe_offsets(int fd, const char *provider_name,
+               const char *probe_name, uint64_t **offsets, uint32_t *nb_probe);
+
+#endif /* _LTTNG_ELF_H */
diff --git a/src/common/lttng-kernel-old.h b/src/common/lttng-kernel-old.h
deleted file mode 100644 (file)
index c36c633..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_KERNEL_OLD_H
-#define _LTTNG_KERNEL_OLD_H
-
-#include <stdint.h>
-#include <common/lttng-kernel.h>
-
-/*
- * LTTng DebugFS ABI structures.
- *
- * This is the kernel ABI copied from lttng-modules tree.
- */
-
-/* Perf counter attributes */
-struct lttng_kernel_abi_old_perf_counter_ctx {
-       uint32_t type;
-       uint64_t config;
-       char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-};
-
-/* Event/Channel context */
-#define LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING1  16
-#define LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING2  LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
-struct lttng_kernel_abi_old_context {
-       enum lttng_kernel_abi_context_type ctx;
-       char padding[LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING1];
-
-       union {
-               struct lttng_kernel_abi_old_perf_counter_ctx perf_counter;
-               char padding[LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING2];
-       } u;
-};
-
-struct lttng_kernel_abi_old_kretprobe {
-       uint64_t addr;
-
-       uint64_t offset;
-       char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-};
-
-/*
- * Either addr is used, or symbol_name and offset.
- */
-struct lttng_kernel_abi_old_kprobe {
-       uint64_t addr;
-
-       uint64_t offset;
-       char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-};
-
-/* Function tracer */
-struct lttng_kernel_abi_old_function {
-       char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-};
-
-#define LTTNG_KERNEL_ABI_OLD_EVENT_PADDING1    16
-#define LTTNG_KERNEL_ABI_OLD_EVENT_PADDING2    LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
-struct lttng_kernel_abi_old_event {
-       char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-       enum lttng_kernel_abi_instrumentation instrumentation;
-       char padding[LTTNG_KERNEL_ABI_OLD_EVENT_PADDING1];
-
-       /* Per instrumentation type configuration */
-       union {
-               struct lttng_kernel_abi_old_kretprobe kretprobe;
-               struct lttng_kernel_abi_old_kprobe kprobe;
-               struct lttng_kernel_abi_old_function ftrace;
-               char padding[LTTNG_KERNEL_ABI_OLD_EVENT_PADDING2];
-       } u;
-};
-
-struct lttng_kernel_abi_old_tracer_version {
-       uint32_t major;
-       uint32_t minor;
-       uint32_t patchlevel;
-};
-
-/*
- * kernel channel
- */
-#define LTTNG_KERNEL_ABI_OLD_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32
-struct lttng_kernel_abi_old_channel {
-       int overwrite;                      /* 1: overwrite, 0: discard */
-       uint64_t subbuf_size;               /* bytes */
-       uint64_t num_subbuf;                /* power of 2 */
-       unsigned int switch_timer_interval; /* usec */
-       unsigned int read_timer_interval;   /* usec */
-       enum lttng_event_output output;     /* splice, mmap */
-
-       char padding[LTTNG_KERNEL_ABI_OLD_CHANNEL_PADDING1];
-};
-
-#endif /* _LTTNG_KERNEL_OLD_H */
diff --git a/src/common/lttng-kernel-old.hpp b/src/common/lttng-kernel-old.hpp
new file mode 100644 (file)
index 0000000..2ffb754
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_KERNEL_OLD_H
+#define _LTTNG_KERNEL_OLD_H
+
+#include <stdint.h>
+#include <common/lttng-kernel.hpp>
+
+/*
+ * LTTng DebugFS ABI structures.
+ *
+ * This is the kernel ABI copied from lttng-modules tree.
+ */
+
+/* Perf counter attributes */
+struct lttng_kernel_abi_old_perf_counter_ctx {
+       uint32_t type;
+       uint64_t config;
+       char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+};
+
+/* Event/Channel context */
+#define LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING1  16
+#define LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING2  LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
+struct lttng_kernel_abi_old_context {
+       enum lttng_kernel_abi_context_type ctx;
+       char padding[LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING1];
+
+       union {
+               struct lttng_kernel_abi_old_perf_counter_ctx perf_counter;
+               char padding[LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING2];
+       } u;
+};
+
+struct lttng_kernel_abi_old_kretprobe {
+       uint64_t addr;
+
+       uint64_t offset;
+       char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+};
+
+/*
+ * Either addr is used, or symbol_name and offset.
+ */
+struct lttng_kernel_abi_old_kprobe {
+       uint64_t addr;
+
+       uint64_t offset;
+       char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+};
+
+/* Function tracer */
+struct lttng_kernel_abi_old_function {
+       char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+};
+
+#define LTTNG_KERNEL_ABI_OLD_EVENT_PADDING1    16
+#define LTTNG_KERNEL_ABI_OLD_EVENT_PADDING2    LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
+struct lttng_kernel_abi_old_event {
+       char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+       enum lttng_kernel_abi_instrumentation instrumentation;
+       char padding[LTTNG_KERNEL_ABI_OLD_EVENT_PADDING1];
+
+       /* Per instrumentation type configuration */
+       union {
+               struct lttng_kernel_abi_old_kretprobe kretprobe;
+               struct lttng_kernel_abi_old_kprobe kprobe;
+               struct lttng_kernel_abi_old_function ftrace;
+               char padding[LTTNG_KERNEL_ABI_OLD_EVENT_PADDING2];
+       } u;
+};
+
+struct lttng_kernel_abi_old_tracer_version {
+       uint32_t major;
+       uint32_t minor;
+       uint32_t patchlevel;
+};
+
+/*
+ * kernel channel
+ */
+#define LTTNG_KERNEL_ABI_OLD_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32
+struct lttng_kernel_abi_old_channel {
+       int overwrite;                      /* 1: overwrite, 0: discard */
+       uint64_t subbuf_size;               /* bytes */
+       uint64_t num_subbuf;                /* power of 2 */
+       unsigned int switch_timer_interval; /* usec */
+       unsigned int read_timer_interval;   /* usec */
+       enum lttng_event_output output;     /* splice, mmap */
+
+       char padding[LTTNG_KERNEL_ABI_OLD_CHANNEL_PADDING1];
+};
+
+#endif /* _LTTNG_KERNEL_OLD_H */
diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h
deleted file mode 100644 (file)
index dd9db6f..0000000
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_KERNEL_H
-#define _LTTNG_KERNEL_H
-
-#include <stdint.h>
-#include <common/macros.h>
-#include <lttng/constant.h>
-#include <lttng/event.h>
-
-#define LTTNG_KERNEL_ABI_SYM_NAME_LEN  256
-#define LTTNG_KERNEL_ABI_MAX_UPROBE_NUM  32
-#define LTTNG_KERNEL_ABI_SESSION_NAME_LEN      256
-#define LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN     26
-
-/*
- * LTTng DebugFS ABI structures.
- *
- * This is the kernel ABI copied from lttng-modules tree.
- */
-
-enum lttng_kernel_abi_instrumentation {
-       LTTNG_KERNEL_ABI_ALL           = -1,   /* Used within lttng-tools */
-       LTTNG_KERNEL_ABI_TRACEPOINT    = 0,
-       LTTNG_KERNEL_ABI_KPROBE        = 1,
-       LTTNG_KERNEL_ABI_FUNCTION      = 2,
-       LTTNG_KERNEL_ABI_KRETPROBE     = 3,
-       LTTNG_KERNEL_ABI_NOOP          = 4,    /* not hooked */
-       LTTNG_KERNEL_ABI_SYSCALL       = 5,
-       LTTNG_KERNEL_ABI_UPROBE        = 6,
-};
-
-enum lttng_kernel_abi_context_type {
-       LTTNG_KERNEL_ABI_CONTEXT_PID            = 0,
-       LTTNG_KERNEL_ABI_CONTEXT_PERF_CPU_COUNTER = 1,
-       LTTNG_KERNEL_ABI_CONTEXT_PROCNAME       = 2,
-       LTTNG_KERNEL_ABI_CONTEXT_PRIO           = 3,
-       LTTNG_KERNEL_ABI_CONTEXT_NICE           = 4,
-       LTTNG_KERNEL_ABI_CONTEXT_VPID           = 5,
-       LTTNG_KERNEL_ABI_CONTEXT_TID            = 6,
-       LTTNG_KERNEL_ABI_CONTEXT_VTID           = 7,
-       LTTNG_KERNEL_ABI_CONTEXT_PPID           = 8,
-       LTTNG_KERNEL_ABI_CONTEXT_VPPID          = 9,
-       LTTNG_KERNEL_ABI_CONTEXT_HOSTNAME       = 10,
-       LTTNG_KERNEL_ABI_CONTEXT_CPU_ID         = 11,
-       LTTNG_KERNEL_ABI_CONTEXT_INTERRUPTIBLE  = 12,
-       LTTNG_KERNEL_ABI_CONTEXT_PREEMPTIBLE    = 13,
-       LTTNG_KERNEL_ABI_CONTEXT_NEED_RESCHEDULE = 14,
-       LTTNG_KERNEL_ABI_CONTEXT_MIGRATABLE     = 15,
-       LTTNG_KERNEL_ABI_CONTEXT_CALLSTACK_KERNEL = 16,
-       LTTNG_KERNEL_ABI_CONTEXT_CALLSTACK_USER   = 17,
-       LTTNG_KERNEL_ABI_CONTEXT_CGROUP_NS      = 18,
-       LTTNG_KERNEL_ABI_CONTEXT_IPC_NS         = 19,
-       LTTNG_KERNEL_ABI_CONTEXT_MNT_NS         = 20,
-       LTTNG_KERNEL_ABI_CONTEXT_NET_NS         = 21,
-       LTTNG_KERNEL_ABI_CONTEXT_PID_NS         = 22,
-       LTTNG_KERNEL_ABI_CONTEXT_USER_NS        = 23,
-       LTTNG_KERNEL_ABI_CONTEXT_UTS_NS         = 24,
-       LTTNG_KERNEL_ABI_CONTEXT_UID            = 25,
-       LTTNG_KERNEL_ABI_CONTEXT_EUID           = 26,
-       LTTNG_KERNEL_ABI_CONTEXT_SUID           = 27,
-       LTTNG_KERNEL_ABI_CONTEXT_GID            = 28,
-       LTTNG_KERNEL_ABI_CONTEXT_EGID           = 29,
-       LTTNG_KERNEL_ABI_CONTEXT_SGID           = 30,
-       LTTNG_KERNEL_ABI_CONTEXT_VUID           = 31,
-       LTTNG_KERNEL_ABI_CONTEXT_VEUID          = 32,
-       LTTNG_KERNEL_ABI_CONTEXT_VSUID          = 33,
-       LTTNG_KERNEL_ABI_CONTEXT_VGID           = 34,
-       LTTNG_KERNEL_ABI_CONTEXT_VEGID          = 35,
-       LTTNG_KERNEL_ABI_CONTEXT_VSGID          = 36,
-       LTTNG_KERNEL_ABI_CONTEXT_TIME_NS        = 37,
-};
-
-/* Perf counter attributes */
-struct lttng_kernel_abi_perf_counter_ctx {
-       uint32_t type;
-       uint64_t config;
-       char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-} LTTNG_PACKED;
-
-/* Event/Channel context */
-#define LTTNG_KERNEL_ABI_CONTEXT_PADDING1  16
-#define LTTNG_KERNEL_ABI_CONTEXT_PADDING2  LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
-struct lttng_kernel_abi_context {
-       enum lttng_kernel_abi_context_type ctx;
-       char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING1];
-
-       union {
-               struct lttng_kernel_abi_perf_counter_ctx perf_counter;
-               char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING2];
-       } u;
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_kretprobe {
-       uint64_t addr;
-
-       uint64_t offset;
-       char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-} LTTNG_PACKED;
-
-/*
- * Either addr is used, or symbol_name and offset.
- */
-struct lttng_kernel_abi_kprobe {
-       uint64_t addr;
-
-       uint64_t offset;
-       char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_uprobe {
-       int fd;
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_event_callsite_uprobe {
-       uint64_t offset;
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_event_callsite {
-       union {
-               struct lttng_kernel_abi_event_callsite_uprobe uprobe;
-       } u;
-} LTTNG_PACKED;
-
-enum lttng_kernel_abi_syscall_entryexit {
-       LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT      = 0,
-       LTTNG_KERNEL_ABI_SYSCALL_ENTRY  = 1,
-       LTTNG_KERNEL_ABI_SYSCALL_EXIT   = 2,
-};
-
-enum lttng_kernel_abi_syscall_abi {
-       LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL        = 0,
-       LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE = 1,
-       LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT = 2,
-};
-
-enum lttng_kernel_abi_syscall_match {
-       LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME = 0,
-       LTTNG_KERNEL_ABI_SYSCALL_MATCH_NR       = 1,
-};
-
-struct lttng_kernel_abi_syscall {
-       uint8_t entryexit;      /* enum lttng_kernel_abi_syscall_entryexit */
-       uint8_t abi;            /* enum lttng_kernel_abi_syscall_abi */
-       uint8_t match;          /* enum lttng_kernel_abi_syscall_match */
-       uint8_t padding;
-       uint32_t nr;            /* For LTTNG_SYSCALL_MATCH_NR */
-} LTTNG_PACKED;
-
-/* Function tracer */
-struct lttng_kernel_abi_function {
-       char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_EVENT_PADDING1    8
-#define LTTNG_KERNEL_ABI_EVENT_PADDING2    LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
-struct lttng_kernel_abi_event {
-       char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-       enum lttng_kernel_abi_instrumentation instrumentation;
-       uint64_t token;
-       char padding[LTTNG_KERNEL_ABI_EVENT_PADDING1];
-
-       /* Per instrumentation type configuration */
-       union {
-               struct lttng_kernel_abi_kretprobe kretprobe;
-               struct lttng_kernel_abi_kprobe kprobe;
-               struct lttng_kernel_abi_function ftrace;
-               struct lttng_kernel_abi_uprobe uprobe;
-               struct lttng_kernel_abi_syscall syscall;
-               char padding[LTTNG_KERNEL_ABI_EVENT_PADDING2];
-       } u;
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING        32
-struct lttng_kernel_abi_event_notifier {
-       struct lttng_kernel_abi_event event;
-       uint64_t error_counter_idx;
-
-       char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX      4
-
-enum lttng_kernel_abi_counter_arithmetic {
-       LTTNG_KERNEL_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
-};
-
-enum lttng_kernel_abi_counter_bitness {
-       LTTNG_KERNEL_ABI_COUNTER_BITNESS_32 = 0,
-       LTTNG_KERNEL_ABI_COUNTER_BITNESS_64 = 1,
-};
-
-struct lttng_kernel_abi_counter_dimension {
-       uint64_t size;
-       uint64_t underflow_index;
-       uint64_t overflow_index;
-       uint8_t has_underflow;
-       uint8_t has_overflow;
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1      67
-struct lttng_kernel_abi_counter_conf {
-       uint32_t arithmetic;    /* enum lttng_kernel_abi_counter_arithmetic */
-       uint32_t bitness;       /* enum lttng_kernel_abi_counter_bitness */
-       uint32_t number_dimensions;
-       int64_t global_sum_step;
-       struct lttng_kernel_abi_counter_dimension dimensions[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
-       uint8_t coalesce_hits;
-       char padding[LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1];
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_counter_index {
-       uint32_t number_dimensions;
-       uint64_t dimension_indexes[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_counter_value {
-       int64_t value;
-       uint8_t underflow;
-       uint8_t overflow;
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_COUNTER_READ_PADDING 32
-struct lttng_kernel_abi_counter_read {
-       struct lttng_kernel_abi_counter_index index;
-       int32_t cpu;    /* -1 for global counter, >= 0 for specific cpu. */
-       struct lttng_kernel_abi_counter_value value;    /* output */
-       char padding[LTTNG_KERNEL_ABI_COUNTER_READ_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING 32
-struct lttng_kernel_abi_counter_aggregate {
-       struct lttng_kernel_abi_counter_index index;
-       struct lttng_kernel_abi_counter_value value;    /* output */
-       char padding[LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING 32
-struct lttng_kernel_abi_counter_clear {
-       struct lttng_kernel_abi_counter_index index;
-       char padding[LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
-struct lttng_kernel_abi_event_notifier_notification {
-       uint64_t token;
-       uint16_t capture_buf_size;
-       char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_CAPTURE_BYTECODE_MAX_LEN              65536
-struct lttng_kernel_abi_capture_bytecode {
-       uint32_t len;
-       uint32_t reloc_offset;
-       uint64_t seqnum;
-       char data[0];
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_tracer_version {
-       uint32_t major;
-       uint32_t minor;
-       uint32_t patchlevel;
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_tracer_abi_version {
-       uint32_t major;
-       uint32_t minor;
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_syscall_mask {
-       uint32_t len;   /* in bits */
-       char mask[];
-} LTTNG_PACKED;
-
-/*
- * kernel channel
- */
-#define LTTNG_KERNEL_ABI_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32
-struct lttng_kernel_abi_channel {
-       uint64_t subbuf_size;               /* bytes */
-       uint64_t num_subbuf;                /* power of 2 */
-       unsigned int switch_timer_interval; /* usec */
-       unsigned int read_timer_interval;   /* usec */
-       enum lttng_event_output output;     /* splice, mmap */
-
-       int overwrite;                      /* 1: overwrite, 0: discard */
-       char padding[LTTNG_KERNEL_ABI_CHANNEL_PADDING1];
-} LTTNG_PACKED;
-
-#define KERNEL_FILTER_BYTECODE_MAX_LEN         65536
-struct lttng_kernel_abi_filter_bytecode {
-       uint32_t len;
-       uint32_t reloc_offset;
-       uint64_t seqnum;
-       char data[0];
-} LTTNG_PACKED;
-
-/*
- * kernel session name
- */
-struct lttng_kernel_abi_session_name {
-       char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN];
-} LTTNG_PACKED;
-
-/*
- * kernel session creation datetime
- */
-struct lttng_kernel_abi_session_creation_time {
-       char iso8601[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN];
-} LTTNG_PACKED;
-
-enum lttng_kernel_abi_tracker_type {
-       LTTNG_KERNEL_ABI_TRACKER_UNKNOWN                = -1,
-
-       LTTNG_KERNEL_ABI_TRACKER_PID            = 0,
-       LTTNG_KERNEL_ABI_TRACKER_VPID           = 1,
-       LTTNG_KERNEL_ABI_TRACKER_UID            = 2,
-       LTTNG_KERNEL_ABI_TRACKER_VUID           = 3,
-       LTTNG_KERNEL_ABI_TRACKER_GID            = 4,
-       LTTNG_KERNEL_ABI_TRACKER_VGID           = 5,
-};
-
-struct lttng_kernel_abi_tracker_args {
-       enum lttng_kernel_abi_tracker_type type;
-       int32_t id;
-};
-
-#endif /* _LTTNG_KERNEL_H */
diff --git a/src/common/lttng-kernel.hpp b/src/common/lttng-kernel.hpp
new file mode 100644 (file)
index 0000000..6b1f798
--- /dev/null
@@ -0,0 +1,334 @@
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_KERNEL_H
+#define _LTTNG_KERNEL_H
+
+#include <stdint.h>
+#include <common/macros.hpp>
+#include <lttng/constant.h>
+#include <lttng/event.h>
+
+#define LTTNG_KERNEL_ABI_SYM_NAME_LEN  256
+#define LTTNG_KERNEL_ABI_MAX_UPROBE_NUM  32
+#define LTTNG_KERNEL_ABI_SESSION_NAME_LEN      256
+#define LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN     26
+
+/*
+ * LTTng DebugFS ABI structures.
+ *
+ * This is the kernel ABI copied from lttng-modules tree.
+ */
+
+enum lttng_kernel_abi_instrumentation {
+       LTTNG_KERNEL_ABI_ALL           = -1,   /* Used within lttng-tools */
+       LTTNG_KERNEL_ABI_TRACEPOINT    = 0,
+       LTTNG_KERNEL_ABI_KPROBE        = 1,
+       LTTNG_KERNEL_ABI_FUNCTION      = 2,
+       LTTNG_KERNEL_ABI_KRETPROBE     = 3,
+       LTTNG_KERNEL_ABI_NOOP          = 4,    /* not hooked */
+       LTTNG_KERNEL_ABI_SYSCALL       = 5,
+       LTTNG_KERNEL_ABI_UPROBE        = 6,
+};
+
+enum lttng_kernel_abi_context_type {
+       LTTNG_KERNEL_ABI_CONTEXT_PID            = 0,
+       LTTNG_KERNEL_ABI_CONTEXT_PERF_CPU_COUNTER = 1,
+       LTTNG_KERNEL_ABI_CONTEXT_PROCNAME       = 2,
+       LTTNG_KERNEL_ABI_CONTEXT_PRIO           = 3,
+       LTTNG_KERNEL_ABI_CONTEXT_NICE           = 4,
+       LTTNG_KERNEL_ABI_CONTEXT_VPID           = 5,
+       LTTNG_KERNEL_ABI_CONTEXT_TID            = 6,
+       LTTNG_KERNEL_ABI_CONTEXT_VTID           = 7,
+       LTTNG_KERNEL_ABI_CONTEXT_PPID           = 8,
+       LTTNG_KERNEL_ABI_CONTEXT_VPPID          = 9,
+       LTTNG_KERNEL_ABI_CONTEXT_HOSTNAME       = 10,
+       LTTNG_KERNEL_ABI_CONTEXT_CPU_ID         = 11,
+       LTTNG_KERNEL_ABI_CONTEXT_INTERRUPTIBLE  = 12,
+       LTTNG_KERNEL_ABI_CONTEXT_PREEMPTIBLE    = 13,
+       LTTNG_KERNEL_ABI_CONTEXT_NEED_RESCHEDULE = 14,
+       LTTNG_KERNEL_ABI_CONTEXT_MIGRATABLE     = 15,
+       LTTNG_KERNEL_ABI_CONTEXT_CALLSTACK_KERNEL = 16,
+       LTTNG_KERNEL_ABI_CONTEXT_CALLSTACK_USER   = 17,
+       LTTNG_KERNEL_ABI_CONTEXT_CGROUP_NS      = 18,
+       LTTNG_KERNEL_ABI_CONTEXT_IPC_NS         = 19,
+       LTTNG_KERNEL_ABI_CONTEXT_MNT_NS         = 20,
+       LTTNG_KERNEL_ABI_CONTEXT_NET_NS         = 21,
+       LTTNG_KERNEL_ABI_CONTEXT_PID_NS         = 22,
+       LTTNG_KERNEL_ABI_CONTEXT_USER_NS        = 23,
+       LTTNG_KERNEL_ABI_CONTEXT_UTS_NS         = 24,
+       LTTNG_KERNEL_ABI_CONTEXT_UID            = 25,
+       LTTNG_KERNEL_ABI_CONTEXT_EUID           = 26,
+       LTTNG_KERNEL_ABI_CONTEXT_SUID           = 27,
+       LTTNG_KERNEL_ABI_CONTEXT_GID            = 28,
+       LTTNG_KERNEL_ABI_CONTEXT_EGID           = 29,
+       LTTNG_KERNEL_ABI_CONTEXT_SGID           = 30,
+       LTTNG_KERNEL_ABI_CONTEXT_VUID           = 31,
+       LTTNG_KERNEL_ABI_CONTEXT_VEUID          = 32,
+       LTTNG_KERNEL_ABI_CONTEXT_VSUID          = 33,
+       LTTNG_KERNEL_ABI_CONTEXT_VGID           = 34,
+       LTTNG_KERNEL_ABI_CONTEXT_VEGID          = 35,
+       LTTNG_KERNEL_ABI_CONTEXT_VSGID          = 36,
+       LTTNG_KERNEL_ABI_CONTEXT_TIME_NS        = 37,
+};
+
+/* Perf counter attributes */
+struct lttng_kernel_abi_perf_counter_ctx {
+       uint32_t type;
+       uint64_t config;
+       char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+} LTTNG_PACKED;
+
+/* Event/Channel context */
+#define LTTNG_KERNEL_ABI_CONTEXT_PADDING1  16
+#define LTTNG_KERNEL_ABI_CONTEXT_PADDING2  LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
+struct lttng_kernel_abi_context {
+       enum lttng_kernel_abi_context_type ctx;
+       char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING1];
+
+       union {
+               struct lttng_kernel_abi_perf_counter_ctx perf_counter;
+               char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING2];
+       } u;
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_kretprobe {
+       uint64_t addr;
+
+       uint64_t offset;
+       char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+} LTTNG_PACKED;
+
+/*
+ * Either addr is used, or symbol_name and offset.
+ */
+struct lttng_kernel_abi_kprobe {
+       uint64_t addr;
+
+       uint64_t offset;
+       char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_uprobe {
+       int fd;
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_event_callsite_uprobe {
+       uint64_t offset;
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_event_callsite {
+       union {
+               struct lttng_kernel_abi_event_callsite_uprobe uprobe;
+       } u;
+} LTTNG_PACKED;
+
+enum lttng_kernel_abi_syscall_entryexit {
+       LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT      = 0,
+       LTTNG_KERNEL_ABI_SYSCALL_ENTRY  = 1,
+       LTTNG_KERNEL_ABI_SYSCALL_EXIT   = 2,
+};
+
+enum lttng_kernel_abi_syscall_abi {
+       LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL        = 0,
+       LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE = 1,
+       LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT = 2,
+};
+
+enum lttng_kernel_abi_syscall_match {
+       LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME = 0,
+       LTTNG_KERNEL_ABI_SYSCALL_MATCH_NR       = 1,
+};
+
+struct lttng_kernel_abi_syscall {
+       uint8_t entryexit;      /* enum lttng_kernel_abi_syscall_entryexit */
+       uint8_t abi;            /* enum lttng_kernel_abi_syscall_abi */
+       uint8_t match;          /* enum lttng_kernel_abi_syscall_match */
+       uint8_t padding;
+       uint32_t nr;            /* For LTTNG_SYSCALL_MATCH_NR */
+} LTTNG_PACKED;
+
+/* Function tracer */
+struct lttng_kernel_abi_function {
+       char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_EVENT_PADDING1    8
+#define LTTNG_KERNEL_ABI_EVENT_PADDING2    LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
+struct lttng_kernel_abi_event {
+       char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+       enum lttng_kernel_abi_instrumentation instrumentation;
+       uint64_t token;
+       char padding[LTTNG_KERNEL_ABI_EVENT_PADDING1];
+
+       /* Per instrumentation type configuration */
+       union {
+               struct lttng_kernel_abi_kretprobe kretprobe;
+               struct lttng_kernel_abi_kprobe kprobe;
+               struct lttng_kernel_abi_function ftrace;
+               struct lttng_kernel_abi_uprobe uprobe;
+               struct lttng_kernel_abi_syscall syscall;
+               char padding[LTTNG_KERNEL_ABI_EVENT_PADDING2];
+       } u;
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING        32
+struct lttng_kernel_abi_event_notifier {
+       struct lttng_kernel_abi_event event;
+       uint64_t error_counter_idx;
+
+       char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX      4
+
+enum lttng_kernel_abi_counter_arithmetic {
+       LTTNG_KERNEL_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
+};
+
+enum lttng_kernel_abi_counter_bitness {
+       LTTNG_KERNEL_ABI_COUNTER_BITNESS_32 = 0,
+       LTTNG_KERNEL_ABI_COUNTER_BITNESS_64 = 1,
+};
+
+struct lttng_kernel_abi_counter_dimension {
+       uint64_t size;
+       uint64_t underflow_index;
+       uint64_t overflow_index;
+       uint8_t has_underflow;
+       uint8_t has_overflow;
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1      67
+struct lttng_kernel_abi_counter_conf {
+       uint32_t arithmetic;    /* enum lttng_kernel_abi_counter_arithmetic */
+       uint32_t bitness;       /* enum lttng_kernel_abi_counter_bitness */
+       uint32_t number_dimensions;
+       int64_t global_sum_step;
+       struct lttng_kernel_abi_counter_dimension dimensions[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
+       uint8_t coalesce_hits;
+       char padding[LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1];
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_counter_index {
+       uint32_t number_dimensions;
+       uint64_t dimension_indexes[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_counter_value {
+       int64_t value;
+       uint8_t underflow;
+       uint8_t overflow;
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_COUNTER_READ_PADDING 32
+struct lttng_kernel_abi_counter_read {
+       struct lttng_kernel_abi_counter_index index;
+       int32_t cpu;    /* -1 for global counter, >= 0 for specific cpu. */
+       struct lttng_kernel_abi_counter_value value;    /* output */
+       char padding[LTTNG_KERNEL_ABI_COUNTER_READ_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING 32
+struct lttng_kernel_abi_counter_aggregate {
+       struct lttng_kernel_abi_counter_index index;
+       struct lttng_kernel_abi_counter_value value;    /* output */
+       char padding[LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING 32
+struct lttng_kernel_abi_counter_clear {
+       struct lttng_kernel_abi_counter_index index;
+       char padding[LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
+struct lttng_kernel_abi_event_notifier_notification {
+       uint64_t token;
+       uint16_t capture_buf_size;
+       char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_CAPTURE_BYTECODE_MAX_LEN              65536
+struct lttng_kernel_abi_capture_bytecode {
+       uint32_t len;
+       uint32_t reloc_offset;
+       uint64_t seqnum;
+       char data[0];
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_tracer_version {
+       uint32_t major;
+       uint32_t minor;
+       uint32_t patchlevel;
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_tracer_abi_version {
+       uint32_t major;
+       uint32_t minor;
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_syscall_mask {
+       uint32_t len;   /* in bits */
+       char mask[];
+} LTTNG_PACKED;
+
+/*
+ * kernel channel
+ */
+#define LTTNG_KERNEL_ABI_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32
+struct lttng_kernel_abi_channel {
+       uint64_t subbuf_size;               /* bytes */
+       uint64_t num_subbuf;                /* power of 2 */
+       unsigned int switch_timer_interval; /* usec */
+       unsigned int read_timer_interval;   /* usec */
+       enum lttng_event_output output;     /* splice, mmap */
+
+       int overwrite;                      /* 1: overwrite, 0: discard */
+       char padding[LTTNG_KERNEL_ABI_CHANNEL_PADDING1];
+} LTTNG_PACKED;
+
+#define KERNEL_FILTER_BYTECODE_MAX_LEN         65536
+struct lttng_kernel_abi_filter_bytecode {
+       uint32_t len;
+       uint32_t reloc_offset;
+       uint64_t seqnum;
+       char data[0];
+} LTTNG_PACKED;
+
+/*
+ * kernel session name
+ */
+struct lttng_kernel_abi_session_name {
+       char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN];
+} LTTNG_PACKED;
+
+/*
+ * kernel session creation datetime
+ */
+struct lttng_kernel_abi_session_creation_time {
+       char iso8601[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN];
+} LTTNG_PACKED;
+
+enum lttng_kernel_abi_tracker_type {
+       LTTNG_KERNEL_ABI_TRACKER_UNKNOWN                = -1,
+
+       LTTNG_KERNEL_ABI_TRACKER_PID            = 0,
+       LTTNG_KERNEL_ABI_TRACKER_VPID           = 1,
+       LTTNG_KERNEL_ABI_TRACKER_UID            = 2,
+       LTTNG_KERNEL_ABI_TRACKER_VUID           = 3,
+       LTTNG_KERNEL_ABI_TRACKER_GID            = 4,
+       LTTNG_KERNEL_ABI_TRACKER_VGID           = 5,
+};
+
+struct lttng_kernel_abi_tracker_args {
+       enum lttng_kernel_abi_tracker_type type;
+       int32_t id;
+};
+
+#endif /* _LTTNG_KERNEL_H */
diff --git a/src/common/macros.h b/src/common/macros.h
deleted file mode 100644 (file)
index 8c35f0c..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _MACROS_H
-#define _MACROS_H
-
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-#include <common/compat/string.h>
-
-/*
- * Takes a pointer x and transform it so we can use it to access members
- * without a function call. Here an example:
- *
- *    #define GET_SIZE(x) LTTNG_REF(x)->size
- *
- *    struct { int size; } s;
- *
- *    printf("size : %d\n", GET_SIZE(&s));
- *
- * For this example we can't use something like this for compatibility purpose
- * since this will fail:
- *
- *    #define GET_SIZE(x) x->size;
- *
- * This is mostly use for the compatibility layer of lttng-tools. See
- * poll/epoll for a good example. Since x can be on the stack or allocated
- * memory using malloc(), we must use generic accessors for compat in order to
- * *not* use a function to access members and not the variable name.
- */
-#define LTTNG_REF(x) ((typeof(*x) *)(x))
-
-/*
- * Memory allocation zeroed
- */
-static inline
-void *zmalloc(size_t len)
-{
-       return calloc(1, len);
-}
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(array)   (sizeof(array) / (sizeof((array)[0])))
-#endif
-
-#ifndef container_of
-#define container_of(ptr, type, member)                                        \
-       ({                                                              \
-               const typeof(((type *)NULL)->member) * __ptr = (ptr);   \
-               (type *)((char *)__ptr - offsetof(type, member));       \
-       })
-#endif
-
-#ifndef LTTNG_PACKED
-#define LTTNG_PACKED __attribute__((__packed__))
-#endif
-
-#ifndef LTTNG_NO_SANITIZE_ADDRESS
-#if defined(__clang__) || defined (__GNUC__)
-#define LTTNG_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
-#else
-#define LTTNG_NO_SANITIZE_ADDRESS
-#endif
-#endif
-
-#define member_sizeof(type, field)     sizeof(((type *) 0)->field)
-
-#define ASSERT_LOCKED(lock) LTTNG_ASSERT(pthread_mutex_trylock(&lock))
-#define ASSERT_RCU_READ_LOCKED(lock) LTTNG_ASSERT(rcu_read_ongoing())
-
-/* Attribute suitable to tag functions as having printf()-like arguments. */
-#define ATTR_FORMAT_PRINTF(_string_index, _first_to_check) \
-       __attribute__((format(printf, _string_index, _first_to_check)))
-
-/* Attribute suitable to tag functions as having strftime()-like arguments. */
-#define ATTR_FORMAT_STRFTIME(_string_index) \
-       __attribute__((format(strftime, _string_index, 0)))
-
-/* Macros used to ignore specific compiler diagnostics. */
-
-#define DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
-#define DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
-
-#if defined(__clang__)
-  /* Clang */
-# define DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT
-# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
-       _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
-# define DIAGNOSTIC_IGNORE_LOGICAL_OP
-#else
-  /* GCC */
-# define DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT \
-       _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=format\"")
-# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
-       _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
-# define DIAGNOSTIC_IGNORE_LOGICAL_OP \
-       _Pragma("GCC diagnostic ignored \"-Wlogical-op\"")
-#endif
-
-/* Used to make specific C++ functions to C code. */
-#ifdef __cplusplus
-#define C_LINKAGE extern "C"
-#else
-#define C_LINKAGE
-#endif
-
-/*
- * lttng_strncpy returns 0 on success, or nonzero on failure.
- * It checks that the @src string fits into @dst_len before performing
- * the copy. On failure, no copy has been performed.
- *
- * Assumes that 'src' is null-terminated.
- *
- * dst_len includes the string's trailing NULL.
- */
-static inline
-int lttng_strncpy(char *dst, const char *src, size_t dst_len)
-{
-       if (strlen(src) >= dst_len) {
-               /* Fail since copying would result in truncation. */
-               return -1;
-       }
-       strcpy(dst, src);
-       return 0;
-}
-
-#ifdef NDEBUG
-/*
-* Force usage of the assertion condition to prevent unused variable warnings
-* when `assert()` are disabled by the `NDEBUG` definition.
-*/
-# define LTTNG_ASSERT(_cond) ((void) sizeof((void) (_cond), 0))
-#else
-# include <assert.h>
-# define LTTNG_ASSERT(_cond) assert(_cond)
-#endif
-
-#endif /* _MACROS_H */
diff --git a/src/common/macros.hpp b/src/common/macros.hpp
new file mode 100644 (file)
index 0000000..d2b7820
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _MACROS_H
+#define _MACROS_H
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+#include <common/compat/string.hpp>
+
+/*
+ * Takes a pointer x and transform it so we can use it to access members
+ * without a function call. Here an example:
+ *
+ *    #define GET_SIZE(x) LTTNG_REF(x)->size
+ *
+ *    struct { int size; } s;
+ *
+ *    printf("size : %d\n", GET_SIZE(&s));
+ *
+ * For this example we can't use something like this for compatibility purpose
+ * since this will fail:
+ *
+ *    #define GET_SIZE(x) x->size;
+ *
+ * This is mostly use for the compatibility layer of lttng-tools. See
+ * poll/epoll for a good example. Since x can be on the stack or allocated
+ * memory using malloc(), we must use generic accessors for compat in order to
+ * *not* use a function to access members and not the variable name.
+ */
+#define LTTNG_REF(x) ((typeof(*x) *)(x))
+
+/*
+ * Memory allocation zeroed
+ */
+static inline
+void *zmalloc(size_t len)
+{
+       return calloc(1, len);
+}
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(array)   (sizeof(array) / (sizeof((array)[0])))
+#endif
+
+#ifndef container_of
+#define container_of(ptr, type, member)                                        \
+       ({                                                              \
+               const typeof(((type *)NULL)->member) * __ptr = (ptr);   \
+               (type *)((char *)__ptr - offsetof(type, member));       \
+       })
+#endif
+
+#ifndef LTTNG_PACKED
+#define LTTNG_PACKED __attribute__((__packed__))
+#endif
+
+#ifndef LTTNG_NO_SANITIZE_ADDRESS
+#if defined(__clang__) || defined (__GNUC__)
+#define LTTNG_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
+#else
+#define LTTNG_NO_SANITIZE_ADDRESS
+#endif
+#endif
+
+#define member_sizeof(type, field)     sizeof(((type *) 0)->field)
+
+#define ASSERT_LOCKED(lock) LTTNG_ASSERT(pthread_mutex_trylock(&lock))
+#define ASSERT_RCU_READ_LOCKED(lock) LTTNG_ASSERT(rcu_read_ongoing())
+
+/* Attribute suitable to tag functions as having printf()-like arguments. */
+#define ATTR_FORMAT_PRINTF(_string_index, _first_to_check) \
+       __attribute__((format(printf, _string_index, _first_to_check)))
+
+/* Attribute suitable to tag functions as having strftime()-like arguments. */
+#define ATTR_FORMAT_STRFTIME(_string_index) \
+       __attribute__((format(strftime, _string_index, 0)))
+
+/* Macros used to ignore specific compiler diagnostics. */
+
+#define DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
+#define DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
+
+#if defined(__clang__)
+  /* Clang */
+# define DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT
+# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
+       _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
+# define DIAGNOSTIC_IGNORE_LOGICAL_OP
+#else
+  /* GCC */
+# define DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT \
+       _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=format\"")
+# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
+       _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
+# define DIAGNOSTIC_IGNORE_LOGICAL_OP \
+       _Pragma("GCC diagnostic ignored \"-Wlogical-op\"")
+#endif
+
+/* Used to make specific C++ functions to C code. */
+#ifdef __cplusplus
+#define C_LINKAGE extern "C"
+#else
+#define C_LINKAGE
+#endif
+
+/*
+ * lttng_strncpy returns 0 on success, or nonzero on failure.
+ * It checks that the @src string fits into @dst_len before performing
+ * the copy. On failure, no copy has been performed.
+ *
+ * Assumes that 'src' is null-terminated.
+ *
+ * dst_len includes the string's trailing NULL.
+ */
+static inline
+int lttng_strncpy(char *dst, const char *src, size_t dst_len)
+{
+       if (strlen(src) >= dst_len) {
+               /* Fail since copying would result in truncation. */
+               return -1;
+       }
+       strcpy(dst, src);
+       return 0;
+}
+
+#ifdef NDEBUG
+/*
+* Force usage of the assertion condition to prevent unused variable warnings
+* when `assert()` are disabled by the `NDEBUG` definition.
+*/
+# define LTTNG_ASSERT(_cond) ((void) sizeof((void) (_cond), 0))
+#else
+# include <assert.h>
+# define LTTNG_ASSERT(_cond) assert(_cond)
+#endif
+
+#endif /* _MACROS_H */
index 94963b222dbeb3384e0d36f7d62121cebcd5893d..2a1dfa57d942c4b5cec5c259900ee85671f71171 100644 (file)
@@ -8,12 +8,12 @@
 
 #include "lttng/tracker.h"
 #define _LGPL_SOURCE
-#include "mi-lttng.h"
-#include <common/config/session-config.h>
-#include <common/defaults.h>
-#include <common/tracker.h>
+#include "mi-lttng.hpp"
+#include <common/config/session-config.hpp>
+#include <common/defaults.hpp>
+#include <common/tracker.hpp>
 #include <lttng/channel.h>
-#include <lttng/snapshot-internal.h>
+#include <lttng/snapshot-internal.hpp>
 
 
 #define MI_SCHEMA_MAJOR_VERSION 4
diff --git a/src/common/mi-lttng.h b/src/common/mi-lttng.h
deleted file mode 100644 (file)
index 78e0419..0000000
+++ /dev/null
@@ -1,1116 +0,0 @@
-/*
- * Copyright (C) 2014 EfficiOS Inc.
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _MI_LTTNG_H
-#define _MI_LTTNG_H
-
-#include <stdint.h>
-
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/config/session-config.h>
-#include <lttng/lttng.h>
-
-/* Don't want to reference snapshot-internal.h here */
-struct lttng_snapshot_output;
-
-/* Instance of a machine interface writer. */
-struct mi_writer {
-       struct config_writer *writer;
-       enum lttng_mi_output_type type;
-};
-
-/*
- * Version information for the machine interface.
- */
-struct mi_lttng_version_data {
-       char version[LTTNG_NAME_MAX]; /* Version number of package */
-       uint32_t version_major; /* LTTng-Tools major version number */
-       uint32_t version_minor; /* LTTng-Tools minor version number */
-       uint32_t version_patchlevel; /* LTTng-Tools patchlevel version number */
-       char version_commit[LTTNG_NAME_MAX]; /* Commit hash of the current version */
-       char version_name[LTTNG_NAME_MAX];
-       char package_url[LTTNG_NAME_MAX]; /* Define to the home page for this package. */
-};
-
-/* Error query callbacks. */
-typedef enum lttng_error_code (*mi_lttng_error_query_trigger_cb)(
-               const struct lttng_trigger *trigger,
-               struct lttng_error_query_results **results);
-typedef enum lttng_error_code (*mi_lttng_error_query_condition_cb)(
-               const struct lttng_trigger *trigger,
-               struct lttng_error_query_results **results);
-typedef enum lttng_error_code (*mi_lttng_error_query_action_cb)(
-               const struct lttng_trigger *trigger,
-               const struct lttng_action_path *action_path,
-               struct lttng_error_query_results **results);
-
-struct mi_lttng_error_query_callbacks {
-       mi_lttng_error_query_trigger_cb trigger_cb;
-       mi_lttng_error_query_condition_cb condition_cb;
-       mi_lttng_error_query_action_cb action_cb;
-};
-
-/* Strings related to command */
-LTTNG_EXPORT extern const char * const mi_lttng_element_command;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_action;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_add_context;
-extern const char * const mi_lttng_element_command_add_trigger;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_create;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_destroy;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_disable_channel;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_disable_event;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_enable_channels;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_enable_event;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_list;
-extern const char * const mi_lttng_element_command_list_trigger;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_load;
-extern const char * const mi_lttng_element_command_metadata;
-extern const char * const mi_lttng_element_command_metadata_action;
-extern const char * const mi_lttng_element_command_regenerate;
-extern const char * const mi_lttng_element_command_regenerate_action;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_name;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_output;
-extern const char * const mi_lttng_element_command_remove_trigger;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_save;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_set_session;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_add;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_del;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_list;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_record;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_start;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_stop;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_success;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_track;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_untrack;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_version;
-extern const char * const mi_lttng_element_command_rotate;
-extern const char * const mi_lttng_element_command_enable_rotation;
-extern const char * const mi_lttng_element_command_disable_rotation;
-extern const char * const mi_lttng_element_command_clear;
-
-/* Strings related to version command */
-LTTNG_EXPORT extern const char * const mi_lttng_element_version;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_commit;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_description;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_license;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_major;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_minor;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_patch_level;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_str;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_web;
-
-/* String related to a lttng_event_field */
-LTTNG_EXPORT extern const char * const mi_lttng_element_event_field;
-LTTNG_EXPORT extern const char * const mi_lttng_element_event_fields;
-
-/* String related to lttng_event_perf_counter_ctx */
-LTTNG_EXPORT extern const char * const mi_lttng_element_perf_counter_context;
-
-/* Strings related to pid */
-LTTNG_EXPORT extern const char * const mi_lttng_element_pid_id;
-
-/* Strings related to save command */
-LTTNG_EXPORT extern const char * const mi_lttng_element_save;
-
-/* Strings related to load command */
-LTTNG_EXPORT extern const char * const mi_lttng_element_load;
-extern const char * const mi_lttng_element_load_overrides;
-extern const char * const mi_lttng_element_load_override_url;
-
-/* General element of mi_lttng */
-LTTNG_EXPORT extern const char * const mi_lttng_element_empty;
-LTTNG_EXPORT extern const char * const mi_lttng_element_id;
-LTTNG_EXPORT extern const char * const mi_lttng_element_nowrite;
-LTTNG_EXPORT extern const char * const mi_lttng_element_success;
-LTTNG_EXPORT extern const char * const mi_lttng_element_type_enum;
-LTTNG_EXPORT extern const char * const mi_lttng_element_type_float;
-LTTNG_EXPORT extern const char * const mi_lttng_element_type_integer;
-LTTNG_EXPORT extern const char * const mi_lttng_element_type_other;
-LTTNG_EXPORT extern const char * const mi_lttng_element_type_string;
-
-/* String related to loglevel */
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_alert;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_crit;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_function;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_line;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_module;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_process;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_program;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_system;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_unit;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_emerg;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_err;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_info;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_notice;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_unknown;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_warning;
-
-/* String related to loglevel JUL */
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_all;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_config;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_fine;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_finer;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_finest;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_info;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_off;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_severe;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_warning;
-
-/* String related to loglevel Log4j */
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_off;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_fatal;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_error;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_warn;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_info;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_debug;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_trace;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_all;
-
-/* String related to loglevel Python */
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_critical;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_error;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_warning;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_info;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_debug;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_notset;
-
-/* String related to loglevel type */
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_all;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_range;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_single;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_unknown;
-
-/* String related to a lttng_snapshot */
-LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_ctrl_url;
-LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_data_url;
-LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_max_size;
-LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_n_ptr;
-LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_session_name;
-LTTNG_EXPORT extern const char * const mi_lttng_element_snapshots;
-
-/* String related to track/untrack command */
-LTTNG_EXPORT extern const char * const mi_lttng_element_track_untrack_all_wildcard;
-
-extern const char * const mi_lttng_element_session_name;
-
-/* String related to rotate command */
-extern const char * const mi_lttng_element_rotation;
-extern const char * const mi_lttng_element_rotate_status;
-extern const char * const mi_lttng_element_rotation_schedule;
-extern const char * const mi_lttng_element_rotation_schedules;
-extern const char * const mi_lttng_element_rotation_schedule_periodic;
-extern const char * const mi_lttng_element_rotation_schedule_periodic_time_us;
-extern const char * const mi_lttng_element_rotation_schedule_size_threshold;
-extern const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes;
-extern const char * const mi_lttng_element_rotation_schedule_result;
-extern const char * const mi_lttng_element_rotation_schedule_results;
-extern const char * const mi_lttng_element_rotation_state;
-extern const char * const mi_lttng_element_rotation_location;
-extern const char * const mi_lttng_element_rotation_location_local;
-extern const char * const mi_lttng_element_rotation_location_local_absolute_path;
-extern const char * const mi_lttng_element_rotation_location_relay;
-extern const char * const mi_lttng_element_rotation_location_relay_host;
-extern const char * const mi_lttng_element_rotation_location_relay_control_port;
-extern const char * const mi_lttng_element_rotation_location_relay_data_port;
-extern const char * const mi_lttng_element_rotation_location_relay_protocol;
-extern const char * const mi_lttng_element_rotation_location_relay_relative_path;
-
-/* String related to enum lttng_rotation_state */
-extern const char * const mi_lttng_rotation_state_str_ongoing;
-extern const char * const mi_lttng_rotation_state_str_completed;
-extern const char * const mi_lttng_rotation_state_str_expired;
-extern const char * const mi_lttng_rotation_state_str_error;
-
-/* String related to enum lttng_trace_archive_location_relay_protocol_type */
-extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp;
-
-/* String related to rate_policy elements */
-extern const char *const mi_lttng_element_rate_policy;
-extern const char *const mi_lttng_element_rate_policy_every_n;
-extern const char *const mi_lttng_element_rate_policy_once_after_n;
-
-extern const char
-               *const mi_lttng_element_rate_policy_every_n_interval;
-extern const char
-               *const mi_lttng_element_rate_policy_once_after_n_threshold;
-
-/* String related to action elements */
-extern const char *const mi_lttng_element_action;
-extern const char *const mi_lttng_element_action_list;
-extern const char *const mi_lttng_element_action_notify;
-extern const char *const mi_lttng_element_action_start_session;
-extern const char *const mi_lttng_element_action_stop_session;
-extern const char *const mi_lttng_element_action_rotate_session;
-extern const char *const mi_lttng_element_action_snapshot_session;
-extern const char
-               *const mi_lttng_element_action_snapshot_session_output;
-
-/* String related to condition */
-extern const char *const mi_lttng_element_condition;
-extern const char
-               *const mi_lttng_element_condition_buffer_usage_high;
-extern const char
-               *const mi_lttng_element_condition_buffer_usage_low;
-extern const char
-               *const mi_lttng_element_condition_event_rule_matches;
-extern const char
-               *const mi_lttng_element_condition_session_consumed_size;
-extern const char
-               *const mi_lttng_element_condition_session_rotation;
-extern const char
-               *const mi_lttng_element_condition_session_rotation_completed;
-extern const char
-               *const mi_lttng_element_condition_session_rotation_ongoing;
-extern const char *const mi_lttng_element_condition_channel_name;
-extern const char *const mi_lttng_element_condition_threshold_ratio;
-extern const char *const mi_lttng_element_condition_threshold_bytes;
-
-/* String related to capture descriptor */
-extern const char *const mi_lttng_element_capture_descriptor;
-extern const char *const mi_lttng_element_capture_descriptors;
-
-/* String related to event expression */
-extern const char *const mi_lttng_element_event_expr;
-extern const char *const mi_lttng_element_event_expr_payload_field;
-extern const char
-               *const mi_lttng_element_event_expr_channel_context_field;
-extern const char
-               *const mi_lttng_element_event_expr_app_specific_context_field;
-extern const char
-               *const mi_lttng_element_event_expr_array_field_element;
-
-extern const char *const mi_lttng_element_event_expr_provider_name;
-extern const char *const mi_lttng_element_event_expr_type_name;
-extern const char *const mi_lttng_element_event_expr_index;
-
-/* String related to event rule */
-extern const char *const mi_lttng_element_event_rule;
-
-/* String related to lttng_event_rule */
-extern const char *const mi_lttng_element_event_rule_event_name;
-extern const char *const mi_lttng_element_event_rule_name_pattern;
-extern const char
-               *const mi_lttng_element_event_rule_filter_expression;
-extern const char *const mi_lttng_element_event_rule_jul_logging;
-extern const char *const mi_lttng_element_event_rule_kernel_kprobe;
-extern const char *const mi_lttng_element_event_rule_kernel_syscall;
-extern const char
-               *const mi_lttng_element_event_rule_kernel_tracepoint;
-extern const char *const mi_lttng_element_event_rule_kernel_uprobe;
-extern const char *const mi_lttng_element_event_rule_log4j_logging;
-extern const char *const mi_lttng_element_event_rule_python_logging;
-extern const char
-               *const mi_lttng_element_event_rule_user_tracepoint;
-
-/* String related to lttng_event_rule_kernel_syscall. */
-extern const char
-               *const mi_lttng_element_event_rule_kernel_syscall_emission_site;
-
-/* String related to enum lttng_event_rule_kernel_syscall_emission_site. */
-extern const char *const
-               mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit;
-extern const char
-               *const mi_lttng_event_rule_kernel_syscall_emission_site_entry;
-extern const char
-               *const mi_lttng_event_rule_kernel_syscall_emission_site_exit;
-
-extern const char *const
-               mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions;
-extern const char *const
-               mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion;
-
-/* String related to log level rule. */
-extern const char *const mi_lttng_element_log_level_rule;
-extern const char *const mi_lttng_element_log_level_rule_exactly;
-extern const char
-               *const mi_lttng_element_log_level_rule_at_least_as_severe_as;
-extern const char *const
-               mi_lttng_element_log_level_rule_at_least_as_severe_as_thre;
-extern const char *const mi_lttng_element_log_level_rule_level;
-
-/* String related to kernel probe location. */
-extern const char *const mi_lttng_element_kernel_probe_location;
-extern const char
-               *const mi_lttng_element_kernel_probe_location_symbol_offset;
-extern const char *const
-               mi_lttng_element_kernel_probe_location_symbol_offset_name;
-extern const char *const
-               mi_lttng_element_kernel_probe_location_symbol_offset_offset;
-extern const char
-               *const mi_lttng_element_kernel_probe_location_address;
-extern const char
-               *const mi_lttng_element_kernel_probe_location_address_address;
-
-/* String related to userspace probe location. */
-extern const char *const mi_lttng_element_userspace_probe_location;
-extern const char
-               *const mi_lttng_element_userspace_probe_location_binary_path;
-extern const char
-               *const mi_lttng_element_userspace_probe_location_function;
-extern const char
-               *const mi_lttng_element_userspace_probe_location_function_name;
-extern const char
-               *const mi_lttng_element_userspace_probe_location_lookup_method;
-extern const char *const
-               mi_lttng_element_userspace_probe_location_lookup_method_function_default;
-extern const char *const
-               mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
-extern const char *const
-               mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
-extern const char
-               *const mi_lttng_element_userspace_probe_location_tracepoint;
-extern const char *const
-               mi_lttng_element_userspace_probe_location_tracepoint_probe_name;
-extern const char *const
-               mi_lttng_element_userspace_probe_location_tracepoint_provider_name;
-
-/* String related to enum
- * lttng_userspace_probe_location_function_instrumentation_type */
-extern const char *const
-               mi_lttng_element_userspace_probe_location_function_instrumentation_type;
-extern const char *const
-               mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
-
-/* String related to trigger */
-extern const char *const mi_lttng_element_triggers;
-extern const char *const mi_lttng_element_trigger;
-extern const char *const mi_lttng_element_trigger_owner_uid;
-
-/* String related to error_query. */
-extern const char *const mi_lttng_element_error_query_result;
-extern const char
-               *const mi_lttng_element_error_query_result_counter;
-extern const char
-               *const mi_lttng_element_error_query_result_counter_value;
-extern const char
-               *const mi_lttng_element_error_query_result_description;
-extern const char *const mi_lttng_element_error_query_result_name;
-extern const char *const mi_lttng_element_error_query_result_type;
-extern const char *const mi_lttng_element_error_query_results;
-
-/* String related to add-context command */
-extern const char * const mi_lttng_element_context_symbol;
-
-/* Utility string function  */
-const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain);
-const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value);
-const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value);
-const char *mi_lttng_domaintype_string(enum lttng_domain_type value);
-const char *mi_lttng_buffertype_string(enum lttng_buffer_type value);
-const char *mi_lttng_rotation_state_string(enum lttng_rotation_state value);
-const char *mi_lttng_trace_archive_location_relay_protocol_type_string(
-               enum lttng_trace_archive_location_relay_protocol_type value);
-
-/*
- * Create an instance of a machine interface writer.
- *
- * fd_output File to which the XML content must be written. The file will be
- * closed once the mi_writer has been destroyed.
- *
- * Returns an instance of a machine interface writer on success, NULL on
- * error.
- */
-struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type);
-
-/*
- * Destroy an instance of a machine interface writer.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the XML document could be closed cleanly. Negative values
- * indicate an error.
- */
-int mi_lttng_writer_destroy(struct mi_writer *writer);
-
-/*
- * Open a command tag and add it's name node.
- *
- * writer An instance of a machine interface writer.
- * command The command name.
- *
- * Returns zero if the XML document could be closed cleanly.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command);
-
-/*
- * Close a command tag.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the XML document could be closed cleanly.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_command_close(struct mi_writer *writer);
-
-/*
- * Open an element tag.
- *
- * writer An instance of a machine interface writer.
- * element_name Element tag name.
- *
- * Returns zero if the XML document could be closed cleanly.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_open_element(struct mi_writer *writer,
-               const char *element_name);
-
-/*
- * Close the current element tag.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the XML document could be closed cleanly.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_close_element(struct mi_writer *writer);
-
-/*
- * Close multiple element.
- *
- * writer An instance of a machine interface writer.
- * nb_element Number of elements.
- *
- * Returns zero if the XML document could be closed cleanly.
- * Negative values indicate an error.
- */
-int mi_lttng_close_multi_element(struct mi_writer *writer,
-               unsigned int nb_element);
-
-/*
- * Write an element of type unsigned int.
- *
- * writer An instance of a machine interface writer.
- * element_name Element name.
- * value Unsigned int value of the element
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
-               const char *element_name, uint64_t value);
-
-/*
- * Write an element of type signed int.
- *
- * writer An instance of a machine interface writer.
- * element_name Element name.
- * value Signed int value of the element.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
-               const char *element_name, int64_t value);
-
-/*
- * Write an element of type boolean.
- *
- * writer An instance of a machine interface writer.
- * element_name Element name.
- * value Boolean value of the element.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
-               const char *element_name, int value);
-
-/*
- * Write an element of type string.
- *
- * writer An instance of a machine interface writer.
- * element_name Element name.
- * value String value of the element.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_write_element_string(struct mi_writer *writer,
-               const char *element_name, const char *value);
-
-/*
- * Write an element of type double.
- *
- * writer An instance of a machine interface writer.
- * element_name Element name.
- * value Double value of the element.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_write_element_double(struct mi_writer *writer,
-               const char *element_name,
-               double value);
-
-/*
- * Machine interface of struct version.
- *
- * writer An instance of a machine interface writer.
- * version Version struct.
- * lttng_description String value of the version description.
- * lttng_license String value of the version license.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version_data *version,
-               const char *lttng_description, const char *lttng_license);
-
-/*
- * Machine interface: open a sessions element.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_sessions_open(struct mi_writer *writer);
-
-/*
- * Machine interface of struct session.
- *
- * writer An instance of a machine interface writer.
- * session An instance of a session.
- * is_open Defines whether or not the session element shall be closed.
- *         This should be used carefully and the client
- *         must close the session element.
- *         Use case: nested additional information on a session
- *                  ex: domain,channel event.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_session(struct mi_writer *writer,
-               struct lttng_session *session, int is_open);
-
-/*
- * Machine interface: open a domains element.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_domains_open(struct mi_writer *writer);
-
-/*
- * Machine interface of struct domain.
- *
- * writer An instance of a machine interface writer.
- * domain An instance of a domain.
- *
- * is_open Defines whether or not the session element shall be closed.
- *         This should be used carefully and the client
- *         must close the domain element.
- *         Use case: nested addition information on a domain
- *                  ex: channel event.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_domain(struct mi_writer *writer,
-               struct lttng_domain *domain, int is_open);
-
-/*
- * Machine interface: open a channels element.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_channels_open(struct mi_writer *writer);
-
-/*
- * Machine interface of struct channel.
- *
- * writer An instance of a machine interface writer.
- * channel An instance of a channel.
- *
- * is_open Defines whether or not the session element shall be closed.
- *         This should be used carefully and the client
- *         must close the channel element.
- *         Use case: nested addition information on a channel.
- *                  ex: channel event.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_channel(struct mi_writer *writer,
-               struct lttng_channel *channel, int is_open);
-
-/*
- * Machine interface of struct channel_attr.
- *
- * writer An instance of a machine interface writer.
- * attr An instance of a channel_attr struct.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_channel_attr(struct mi_writer *writer,
-               struct lttng_channel_attr *attr);
-
-/*
-* Machine interface for event common attributes.
-*
-* writer An instance of a mi writer.
-* event single trace event.
-*
-* The common attribute are:
-* - mi event element
-* - event name
-* - event type
-* - enabled tag
-* - event filter
-*
-* Returns zero if the element's value could be written.
-* Negative values indicate an error.
-*/
-int mi_lttng_event_common_attributes(struct mi_writer *writer,
-               struct lttng_event *event);
-
-/*
- * Machine interface for kernel tracepoint event with a loglevel.
- *
- * writer An instance of a mi writer.
- * event single trace event.
- * domain Event's domain
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
-               struct lttng_event *event, enum lttng_domain_type domain);
-
-/*
- * Machine interface for kernel tracepoint event with no loglevel.
- *
- * writer An instance of a mi writer.
- * event single trace event.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer,
-               struct lttng_event *event);
-
-/*
- * Machine interface for kernel function and probe event.
- *
- * writer An instance of a mi writer.
- * event single trace event.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_event_function_probe(struct mi_writer *writer,
-               struct lttng_event *event);
-
-/*
- * Machine interface for kernel function entry event.
- *
- * writer An instance of a mi writer.
- * event single trace event.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_event_function_entry(struct mi_writer *writer,
-               struct lttng_event *event);
-
-/*
- * Machine interface: open an events element.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_events_open(struct mi_writer *writer);
-
-/*
- * Machine interface for printing an event.
- * The trace event type currently supported are:
- *  TRACEPOINT,
- *  PROBE,
- *  FUNCTION,
- *  FUNCTION_ENTRY,
- *  SYSCALL
- *
- * writer An instance of a mi writer.
- * event single trace event.
- * is_open Defines whether or not the session element shall be closed.
- *         This should be used carefully and the client
- *         must close the event element.
- *         Use case: nested additional information
- * domain Event's domain
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_event(struct mi_writer *writer, struct lttng_event *event,
-               int is_open, enum lttng_domain_type domain);
-
-/*
- * Machine interface for struct lttng_event_field.
- *
- * writer An instance of a mi writer.
- * field An event_field instance.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_event_field(struct mi_writer *writer,
-               struct lttng_event_field *field);
-
-/*
- * Machine interface: open a event_fields element.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element have be written.
- * Negative values indicate an error.
- */
-int mi_lttng_event_fields_open(struct mi_writer *writer);
-
-/*
- * Machine interface: open a trackers element.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_trackers_open(struct mi_writer *writer);
-
-/*
- * Machine interface: open a process attribute tracker element.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- *
- * Note: A targets element is also opened for each tracker definition
- */
-int mi_lttng_process_attribute_tracker_open(
-               struct mi_writer *writer, enum lttng_process_attr process_attr);
-
-/*
- * Machine interface: open a PIDs element.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_pids_open(struct mi_writer *writer);
-
-/*
- * Machine interface: open a processes element.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_processes_open(struct mi_writer *writer);
-
-/*
- * Machine interface of a Process.
- *
- * writer An instance of a machine interface writer.
- * pid A PID.
- *
- * is_open Defines whether or not the session element shall be closed.
- *         This should be used carefully and the client
- *         must close the pid element.
- *         Use case: nested addition information on a domain
- *                  ex: channel event.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_process(struct mi_writer *writer, pid_t pid , const char *name,
-               int is_open);
-
-/*
- * TODO: move pid of lttng list -u to process semantic on mi api bump
- * Machine interface of a Process.
- *
- * writer An instance of a machine interface writer.
- * pid A PID.
- *
- * is_open Defines whether or not the session element shall be closed.
- *         This should be used carefully and the client
- *         must close the pid element.
- *         Use case: nested addition information on a domain
- *                  ex: channel event.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *name,
-               int is_open);
-
-/*
- * Machine interface: open a process attribute values element.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_process_attr_values_open(struct mi_writer *writer);
-
-/*
- * Machine interface for track/untrack of all process attribute values.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_all_process_attribute_value(struct mi_writer *writer,
-               enum lttng_process_attr process_attr,
-               bool is_open);
-
-/*
- * Machine interface for track/untrack of an integral process attribute value.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_integral_process_attribute_value(struct mi_writer *writer,
-               enum lttng_process_attr process_attr,
-               int64_t value,
-               bool is_open);
-
-/*
- * Machine interface for track/untrack of a string process attribute value.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_string_process_attribute_value(struct mi_writer *writer,
-               enum lttng_process_attr process_attr,
-               const char *value,
-               bool is_open);
-
-/*
- * Machine interface of a context.
- *
- * writer An instance of a machine interface writer
- *
- * context An instance of a lttng_event_context
- *
- * is_open Define if we close the context element
- *         This should be used carefully and the client
- *         need to close the context element.
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_context(struct mi_writer *writer,
-               struct lttng_event_context *context, int is_open);
-
-/*
- * Machine interface of a perf_counter_context.
- *
- * writer An instance of a machine interface writer
- *
- * contest An instance of a lttng_event_perf_counter_ctx
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_perf_counter_context(struct mi_writer *writer,
-               struct lttng_event_perf_counter_ctx  *perf_context);
-
-/*
- * Machine interface of the snapshot list_output.
- * It specifies the session for which we are listing snapshots,
- * and it opens a snapshots element to list a sequence
- * of snapshots.
- *
- * writer An instance of a machine interface writer.
- *
- * session_name: Snapshot output for session "session_name".
- *
- * Note: The client has to close the session and the snapshots elements after
- * having listed every lttng_snapshot_output.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_snapshot_output_session_name(struct mi_writer *writer,
-               const char *session_name);
-
-/*
- * Machine interface of the snapshot output.
- * The machine interface serializes the following attributes:
- * - id: ID of the snapshot output.
- * - name: Name of the output.
- * - data_url : Destination of the output.
- * - ctrl_url: Destination of the output.
- * - max_size: total size of all stream combined.
- *
- * writer An instance of a machine interface writer.
- *
- * output: A list of snapshot_output.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_snapshot_list_output(struct mi_writer *writer,
-               const struct lttng_snapshot_output *output);
-
-/*
- * Machine interface of the output of the command snapshot del output
- * when deleting a snapshot either by id or by name.
- * If the snapshot was found and successfully deleted using its id,
- * it return the id of the snapshot and the current session name on which it
- * was attached.
- *
- * Otherwise, it do the same process with the name of the snapshot, if the
- * snapshot output id is undefined.
- *
- * writer An instance of a machine interface writer.
- *
- * id: ID of the snapshot output.
- *
- * name: Name of the snapshot.
- *
- * current_session_name: Session to which the snapshot belongs.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_snapshot_del_output(struct mi_writer *writer, int id,
-               const char *name, const char *current_session_name);
-
-/*
- * Machine interface of the output of the command snapshot add output
- * when adding a snapshot from a user URL.
- *
- * If the snapshot was successfully added, the machine interface lists
- * these information:
- * - id: ID of the newly add snapshot output.
- * - current_session_name: Name of the session to which the output was added.
- * - ctrl_url: Destination of the output.
- * - max_size: total size of all stream combined.
- *
- * writer An instance of a machine interface writer.
- *
- * current_session_name: Session to which the snapshot belongs.
- *
- * n_ptr:
- *
- * output: iterator over a lttng_snapshot_output_list which contain
- * the snapshot output informations.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_snapshot_add_output(struct mi_writer *writer,
-               const char *current_session_name, const char *n_ptr,
-               struct lttng_snapshot_output *output);
-
-/*
- * Machine interface of the output of the command snapshot
- * record  from a URL (if given).
- *
- * If the snapshot is successfully recorded from a url, the machine interface
- * output the following information:
- * - url: Destination of the output stored in the snapshot.
- *
- * Otherwise, the machine interface output the data and ctrl url received
- * from the command-line.
- *
- * writer An instance of a machine interface writer.
- *
- * ctrl_url, data_url: Destination of the output receive from the command-line.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_snapshot_record(struct mi_writer *writer, const char *url,
-               const char *cmdline_ctrl_url, const char *cmdline_data_url);
-
-/*
- * Machine interface representation of a session rotation schedule.
- *
- * The machine interface serializes the provided schedule as one of the choices
- * from 'rotation_schedule_type'.
- *
- * writer: An instance of a machine interface writer.
- *
- * schedule: An lttng rotation schedule descriptor object.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_rotation_schedule(struct mi_writer *writer,
-               const struct lttng_rotation_schedule *schedule);
-
-/*
- * Machine interface of a session rotation schedule result.
- * This is an element that is part of the output of the enable-rotation and
- * disable-rotation commands.
- *
- * The machine interface provides the following information:
- * - schedule: the session rotation schedule descriptor.
- * - success: whether the sub-command succeeded.
- *
- * writer: An instance of a machine interface writer.
- *
- * schedule: An lttng rotation schedule descriptor object.
- *
- * success: Whether the sub-command suceeded.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_rotation_schedule_result(struct mi_writer *writer,
-               const struct lttng_rotation_schedule *schedule,
-               bool success);
-
-/*
- * Machine interface of a session rotation result.
- * This is an element that is part of the output of the rotate command.
- *
- * The machine interface provides the following information:
- * - session_name: the session to be rotated.
- * - state: the session rotation state.
- * - location: the location of the completed chunk archive.
- *
- * writer: An instance of a machine interface writer.
- *
- * session_name: The session to which the rotate command applies.
- *
- * location: A location descriptor object.
- *
- * success: Whether the sub-command suceeded.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_rotate(struct mi_writer *writer,
-               const char *session_name,
-               enum lttng_rotation_state rotation_state,
-               const struct lttng_trace_archive_location *location);
-
-#endif /* _MI_LTTNG_H */
diff --git a/src/common/mi-lttng.hpp b/src/common/mi-lttng.hpp
new file mode 100644 (file)
index 0000000..182a189
--- /dev/null
@@ -0,0 +1,1116 @@
+/*
+ * Copyright (C) 2014 EfficiOS Inc.
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _MI_LTTNG_H
+#define _MI_LTTNG_H
+
+#include <stdint.h>
+
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/config/session-config.hpp>
+#include <lttng/lttng.h>
+
+/* Don't want to reference snapshot-internal.h here */
+struct lttng_snapshot_output;
+
+/* Instance of a machine interface writer. */
+struct mi_writer {
+       struct config_writer *writer;
+       enum lttng_mi_output_type type;
+};
+
+/*
+ * Version information for the machine interface.
+ */
+struct mi_lttng_version_data {
+       char version[LTTNG_NAME_MAX]; /* Version number of package */
+       uint32_t version_major; /* LTTng-Tools major version number */
+       uint32_t version_minor; /* LTTng-Tools minor version number */
+       uint32_t version_patchlevel; /* LTTng-Tools patchlevel version number */
+       char version_commit[LTTNG_NAME_MAX]; /* Commit hash of the current version */
+       char version_name[LTTNG_NAME_MAX];
+       char package_url[LTTNG_NAME_MAX]; /* Define to the home page for this package. */
+};
+
+/* Error query callbacks. */
+typedef enum lttng_error_code (*mi_lttng_error_query_trigger_cb)(
+               const struct lttng_trigger *trigger,
+               struct lttng_error_query_results **results);
+typedef enum lttng_error_code (*mi_lttng_error_query_condition_cb)(
+               const struct lttng_trigger *trigger,
+               struct lttng_error_query_results **results);
+typedef enum lttng_error_code (*mi_lttng_error_query_action_cb)(
+               const struct lttng_trigger *trigger,
+               const struct lttng_action_path *action_path,
+               struct lttng_error_query_results **results);
+
+struct mi_lttng_error_query_callbacks {
+       mi_lttng_error_query_trigger_cb trigger_cb;
+       mi_lttng_error_query_condition_cb condition_cb;
+       mi_lttng_error_query_action_cb action_cb;
+};
+
+/* Strings related to command */
+LTTNG_EXPORT extern const char * const mi_lttng_element_command;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_action;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_add_context;
+extern const char * const mi_lttng_element_command_add_trigger;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_create;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_destroy;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_disable_channel;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_disable_event;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_enable_channels;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_enable_event;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_list;
+extern const char * const mi_lttng_element_command_list_trigger;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_load;
+extern const char * const mi_lttng_element_command_metadata;
+extern const char * const mi_lttng_element_command_metadata_action;
+extern const char * const mi_lttng_element_command_regenerate;
+extern const char * const mi_lttng_element_command_regenerate_action;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_name;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_output;
+extern const char * const mi_lttng_element_command_remove_trigger;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_save;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_set_session;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_add;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_del;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_list;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_record;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_start;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_stop;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_success;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_track;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_untrack;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_version;
+extern const char * const mi_lttng_element_command_rotate;
+extern const char * const mi_lttng_element_command_enable_rotation;
+extern const char * const mi_lttng_element_command_disable_rotation;
+extern const char * const mi_lttng_element_command_clear;
+
+/* Strings related to version command */
+LTTNG_EXPORT extern const char * const mi_lttng_element_version;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_commit;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_description;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_license;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_major;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_minor;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_patch_level;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_str;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_web;
+
+/* String related to a lttng_event_field */
+LTTNG_EXPORT extern const char * const mi_lttng_element_event_field;
+LTTNG_EXPORT extern const char * const mi_lttng_element_event_fields;
+
+/* String related to lttng_event_perf_counter_ctx */
+LTTNG_EXPORT extern const char * const mi_lttng_element_perf_counter_context;
+
+/* Strings related to pid */
+LTTNG_EXPORT extern const char * const mi_lttng_element_pid_id;
+
+/* Strings related to save command */
+LTTNG_EXPORT extern const char * const mi_lttng_element_save;
+
+/* Strings related to load command */
+LTTNG_EXPORT extern const char * const mi_lttng_element_load;
+extern const char * const mi_lttng_element_load_overrides;
+extern const char * const mi_lttng_element_load_override_url;
+
+/* General element of mi_lttng */
+LTTNG_EXPORT extern const char * const mi_lttng_element_empty;
+LTTNG_EXPORT extern const char * const mi_lttng_element_id;
+LTTNG_EXPORT extern const char * const mi_lttng_element_nowrite;
+LTTNG_EXPORT extern const char * const mi_lttng_element_success;
+LTTNG_EXPORT extern const char * const mi_lttng_element_type_enum;
+LTTNG_EXPORT extern const char * const mi_lttng_element_type_float;
+LTTNG_EXPORT extern const char * const mi_lttng_element_type_integer;
+LTTNG_EXPORT extern const char * const mi_lttng_element_type_other;
+LTTNG_EXPORT extern const char * const mi_lttng_element_type_string;
+
+/* String related to loglevel */
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_alert;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_crit;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_function;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_line;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_module;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_process;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_program;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_system;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_unit;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_emerg;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_err;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_info;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_notice;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_unknown;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_warning;
+
+/* String related to loglevel JUL */
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_all;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_config;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_fine;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_finer;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_finest;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_info;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_off;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_severe;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_warning;
+
+/* String related to loglevel Log4j */
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_off;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_fatal;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_error;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_warn;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_info;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_debug;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_trace;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_all;
+
+/* String related to loglevel Python */
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_critical;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_error;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_warning;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_info;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_debug;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_notset;
+
+/* String related to loglevel type */
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_all;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_range;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_single;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_unknown;
+
+/* String related to a lttng_snapshot */
+LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_ctrl_url;
+LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_data_url;
+LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_max_size;
+LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_n_ptr;
+LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_session_name;
+LTTNG_EXPORT extern const char * const mi_lttng_element_snapshots;
+
+/* String related to track/untrack command */
+LTTNG_EXPORT extern const char * const mi_lttng_element_track_untrack_all_wildcard;
+
+extern const char * const mi_lttng_element_session_name;
+
+/* String related to rotate command */
+extern const char * const mi_lttng_element_rotation;
+extern const char * const mi_lttng_element_rotate_status;
+extern const char * const mi_lttng_element_rotation_schedule;
+extern const char * const mi_lttng_element_rotation_schedules;
+extern const char * const mi_lttng_element_rotation_schedule_periodic;
+extern const char * const mi_lttng_element_rotation_schedule_periodic_time_us;
+extern const char * const mi_lttng_element_rotation_schedule_size_threshold;
+extern const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes;
+extern const char * const mi_lttng_element_rotation_schedule_result;
+extern const char * const mi_lttng_element_rotation_schedule_results;
+extern const char * const mi_lttng_element_rotation_state;
+extern const char * const mi_lttng_element_rotation_location;
+extern const char * const mi_lttng_element_rotation_location_local;
+extern const char * const mi_lttng_element_rotation_location_local_absolute_path;
+extern const char * const mi_lttng_element_rotation_location_relay;
+extern const char * const mi_lttng_element_rotation_location_relay_host;
+extern const char * const mi_lttng_element_rotation_location_relay_control_port;
+extern const char * const mi_lttng_element_rotation_location_relay_data_port;
+extern const char * const mi_lttng_element_rotation_location_relay_protocol;
+extern const char * const mi_lttng_element_rotation_location_relay_relative_path;
+
+/* String related to enum lttng_rotation_state */
+extern const char * const mi_lttng_rotation_state_str_ongoing;
+extern const char * const mi_lttng_rotation_state_str_completed;
+extern const char * const mi_lttng_rotation_state_str_expired;
+extern const char * const mi_lttng_rotation_state_str_error;
+
+/* String related to enum lttng_trace_archive_location_relay_protocol_type */
+extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp;
+
+/* String related to rate_policy elements */
+extern const char *const mi_lttng_element_rate_policy;
+extern const char *const mi_lttng_element_rate_policy_every_n;
+extern const char *const mi_lttng_element_rate_policy_once_after_n;
+
+extern const char
+               *const mi_lttng_element_rate_policy_every_n_interval;
+extern const char
+               *const mi_lttng_element_rate_policy_once_after_n_threshold;
+
+/* String related to action elements */
+extern const char *const mi_lttng_element_action;
+extern const char *const mi_lttng_element_action_list;
+extern const char *const mi_lttng_element_action_notify;
+extern const char *const mi_lttng_element_action_start_session;
+extern const char *const mi_lttng_element_action_stop_session;
+extern const char *const mi_lttng_element_action_rotate_session;
+extern const char *const mi_lttng_element_action_snapshot_session;
+extern const char
+               *const mi_lttng_element_action_snapshot_session_output;
+
+/* String related to condition */
+extern const char *const mi_lttng_element_condition;
+extern const char
+               *const mi_lttng_element_condition_buffer_usage_high;
+extern const char
+               *const mi_lttng_element_condition_buffer_usage_low;
+extern const char
+               *const mi_lttng_element_condition_event_rule_matches;
+extern const char
+               *const mi_lttng_element_condition_session_consumed_size;
+extern const char
+               *const mi_lttng_element_condition_session_rotation;
+extern const char
+               *const mi_lttng_element_condition_session_rotation_completed;
+extern const char
+               *const mi_lttng_element_condition_session_rotation_ongoing;
+extern const char *const mi_lttng_element_condition_channel_name;
+extern const char *const mi_lttng_element_condition_threshold_ratio;
+extern const char *const mi_lttng_element_condition_threshold_bytes;
+
+/* String related to capture descriptor */
+extern const char *const mi_lttng_element_capture_descriptor;
+extern const char *const mi_lttng_element_capture_descriptors;
+
+/* String related to event expression */
+extern const char *const mi_lttng_element_event_expr;
+extern const char *const mi_lttng_element_event_expr_payload_field;
+extern const char
+               *const mi_lttng_element_event_expr_channel_context_field;
+extern const char
+               *const mi_lttng_element_event_expr_app_specific_context_field;
+extern const char
+               *const mi_lttng_element_event_expr_array_field_element;
+
+extern const char *const mi_lttng_element_event_expr_provider_name;
+extern const char *const mi_lttng_element_event_expr_type_name;
+extern const char *const mi_lttng_element_event_expr_index;
+
+/* String related to event rule */
+extern const char *const mi_lttng_element_event_rule;
+
+/* String related to lttng_event_rule */
+extern const char *const mi_lttng_element_event_rule_event_name;
+extern const char *const mi_lttng_element_event_rule_name_pattern;
+extern const char
+               *const mi_lttng_element_event_rule_filter_expression;
+extern const char *const mi_lttng_element_event_rule_jul_logging;
+extern const char *const mi_lttng_element_event_rule_kernel_kprobe;
+extern const char *const mi_lttng_element_event_rule_kernel_syscall;
+extern const char
+               *const mi_lttng_element_event_rule_kernel_tracepoint;
+extern const char *const mi_lttng_element_event_rule_kernel_uprobe;
+extern const char *const mi_lttng_element_event_rule_log4j_logging;
+extern const char *const mi_lttng_element_event_rule_python_logging;
+extern const char
+               *const mi_lttng_element_event_rule_user_tracepoint;
+
+/* String related to lttng_event_rule_kernel_syscall. */
+extern const char
+               *const mi_lttng_element_event_rule_kernel_syscall_emission_site;
+
+/* String related to enum lttng_event_rule_kernel_syscall_emission_site. */
+extern const char *const
+               mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit;
+extern const char
+               *const mi_lttng_event_rule_kernel_syscall_emission_site_entry;
+extern const char
+               *const mi_lttng_event_rule_kernel_syscall_emission_site_exit;
+
+extern const char *const
+               mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions;
+extern const char *const
+               mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion;
+
+/* String related to log level rule. */
+extern const char *const mi_lttng_element_log_level_rule;
+extern const char *const mi_lttng_element_log_level_rule_exactly;
+extern const char
+               *const mi_lttng_element_log_level_rule_at_least_as_severe_as;
+extern const char *const
+               mi_lttng_element_log_level_rule_at_least_as_severe_as_thre;
+extern const char *const mi_lttng_element_log_level_rule_level;
+
+/* String related to kernel probe location. */
+extern const char *const mi_lttng_element_kernel_probe_location;
+extern const char
+               *const mi_lttng_element_kernel_probe_location_symbol_offset;
+extern const char *const
+               mi_lttng_element_kernel_probe_location_symbol_offset_name;
+extern const char *const
+               mi_lttng_element_kernel_probe_location_symbol_offset_offset;
+extern const char
+               *const mi_lttng_element_kernel_probe_location_address;
+extern const char
+               *const mi_lttng_element_kernel_probe_location_address_address;
+
+/* String related to userspace probe location. */
+extern const char *const mi_lttng_element_userspace_probe_location;
+extern const char
+               *const mi_lttng_element_userspace_probe_location_binary_path;
+extern const char
+               *const mi_lttng_element_userspace_probe_location_function;
+extern const char
+               *const mi_lttng_element_userspace_probe_location_function_name;
+extern const char
+               *const mi_lttng_element_userspace_probe_location_lookup_method;
+extern const char *const
+               mi_lttng_element_userspace_probe_location_lookup_method_function_default;
+extern const char *const
+               mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
+extern const char *const
+               mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
+extern const char
+               *const mi_lttng_element_userspace_probe_location_tracepoint;
+extern const char *const
+               mi_lttng_element_userspace_probe_location_tracepoint_probe_name;
+extern const char *const
+               mi_lttng_element_userspace_probe_location_tracepoint_provider_name;
+
+/* String related to enum
+ * lttng_userspace_probe_location_function_instrumentation_type */
+extern const char *const
+               mi_lttng_element_userspace_probe_location_function_instrumentation_type;
+extern const char *const
+               mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
+
+/* String related to trigger */
+extern const char *const mi_lttng_element_triggers;
+extern const char *const mi_lttng_element_trigger;
+extern const char *const mi_lttng_element_trigger_owner_uid;
+
+/* String related to error_query. */
+extern const char *const mi_lttng_element_error_query_result;
+extern const char
+               *const mi_lttng_element_error_query_result_counter;
+extern const char
+               *const mi_lttng_element_error_query_result_counter_value;
+extern const char
+               *const mi_lttng_element_error_query_result_description;
+extern const char *const mi_lttng_element_error_query_result_name;
+extern const char *const mi_lttng_element_error_query_result_type;
+extern const char *const mi_lttng_element_error_query_results;
+
+/* String related to add-context command */
+extern const char * const mi_lttng_element_context_symbol;
+
+/* Utility string function  */
+const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain);
+const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value);
+const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value);
+const char *mi_lttng_domaintype_string(enum lttng_domain_type value);
+const char *mi_lttng_buffertype_string(enum lttng_buffer_type value);
+const char *mi_lttng_rotation_state_string(enum lttng_rotation_state value);
+const char *mi_lttng_trace_archive_location_relay_protocol_type_string(
+               enum lttng_trace_archive_location_relay_protocol_type value);
+
+/*
+ * Create an instance of a machine interface writer.
+ *
+ * fd_output File to which the XML content must be written. The file will be
+ * closed once the mi_writer has been destroyed.
+ *
+ * Returns an instance of a machine interface writer on success, NULL on
+ * error.
+ */
+struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type);
+
+/*
+ * Destroy an instance of a machine interface writer.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly. Negative values
+ * indicate an error.
+ */
+int mi_lttng_writer_destroy(struct mi_writer *writer);
+
+/*
+ * Open a command tag and add it's name node.
+ *
+ * writer An instance of a machine interface writer.
+ * command The command name.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command);
+
+/*
+ * Close a command tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_command_close(struct mi_writer *writer);
+
+/*
+ * Open an element tag.
+ *
+ * writer An instance of a machine interface writer.
+ * element_name Element tag name.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_open_element(struct mi_writer *writer,
+               const char *element_name);
+
+/*
+ * Close the current element tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_close_element(struct mi_writer *writer);
+
+/*
+ * Close multiple element.
+ *
+ * writer An instance of a machine interface writer.
+ * nb_element Number of elements.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_close_multi_element(struct mi_writer *writer,
+               unsigned int nb_element);
+
+/*
+ * Write an element of type unsigned int.
+ *
+ * writer An instance of a machine interface writer.
+ * element_name Element name.
+ * value Unsigned int value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
+               const char *element_name, uint64_t value);
+
+/*
+ * Write an element of type signed int.
+ *
+ * writer An instance of a machine interface writer.
+ * element_name Element name.
+ * value Signed int value of the element.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
+               const char *element_name, int64_t value);
+
+/*
+ * Write an element of type boolean.
+ *
+ * writer An instance of a machine interface writer.
+ * element_name Element name.
+ * value Boolean value of the element.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
+               const char *element_name, int value);
+
+/*
+ * Write an element of type string.
+ *
+ * writer An instance of a machine interface writer.
+ * element_name Element name.
+ * value String value of the element.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_string(struct mi_writer *writer,
+               const char *element_name, const char *value);
+
+/*
+ * Write an element of type double.
+ *
+ * writer An instance of a machine interface writer.
+ * element_name Element name.
+ * value Double value of the element.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_double(struct mi_writer *writer,
+               const char *element_name,
+               double value);
+
+/*
+ * Machine interface of struct version.
+ *
+ * writer An instance of a machine interface writer.
+ * version Version struct.
+ * lttng_description String value of the version description.
+ * lttng_license String value of the version license.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version_data *version,
+               const char *lttng_description, const char *lttng_license);
+
+/*
+ * Machine interface: open a sessions element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_sessions_open(struct mi_writer *writer);
+
+/*
+ * Machine interface of struct session.
+ *
+ * writer An instance of a machine interface writer.
+ * session An instance of a session.
+ * is_open Defines whether or not the session element shall be closed.
+ *         This should be used carefully and the client
+ *         must close the session element.
+ *         Use case: nested additional information on a session
+ *                  ex: domain,channel event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_session(struct mi_writer *writer,
+               struct lttng_session *session, int is_open);
+
+/*
+ * Machine interface: open a domains element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_domains_open(struct mi_writer *writer);
+
+/*
+ * Machine interface of struct domain.
+ *
+ * writer An instance of a machine interface writer.
+ * domain An instance of a domain.
+ *
+ * is_open Defines whether or not the session element shall be closed.
+ *         This should be used carefully and the client
+ *         must close the domain element.
+ *         Use case: nested addition information on a domain
+ *                  ex: channel event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_domain(struct mi_writer *writer,
+               struct lttng_domain *domain, int is_open);
+
+/*
+ * Machine interface: open a channels element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_channels_open(struct mi_writer *writer);
+
+/*
+ * Machine interface of struct channel.
+ *
+ * writer An instance of a machine interface writer.
+ * channel An instance of a channel.
+ *
+ * is_open Defines whether or not the session element shall be closed.
+ *         This should be used carefully and the client
+ *         must close the channel element.
+ *         Use case: nested addition information on a channel.
+ *                  ex: channel event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_channel(struct mi_writer *writer,
+               struct lttng_channel *channel, int is_open);
+
+/*
+ * Machine interface of struct channel_attr.
+ *
+ * writer An instance of a machine interface writer.
+ * attr An instance of a channel_attr struct.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_channel_attr(struct mi_writer *writer,
+               struct lttng_channel_attr *attr);
+
+/*
+* Machine interface for event common attributes.
+*
+* writer An instance of a mi writer.
+* event single trace event.
+*
+* The common attribute are:
+* - mi event element
+* - event name
+* - event type
+* - enabled tag
+* - event filter
+*
+* Returns zero if the element's value could be written.
+* Negative values indicate an error.
+*/
+int mi_lttng_event_common_attributes(struct mi_writer *writer,
+               struct lttng_event *event);
+
+/*
+ * Machine interface for kernel tracepoint event with a loglevel.
+ *
+ * writer An instance of a mi writer.
+ * event single trace event.
+ * domain Event's domain
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
+               struct lttng_event *event, enum lttng_domain_type domain);
+
+/*
+ * Machine interface for kernel tracepoint event with no loglevel.
+ *
+ * writer An instance of a mi writer.
+ * event single trace event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer,
+               struct lttng_event *event);
+
+/*
+ * Machine interface for kernel function and probe event.
+ *
+ * writer An instance of a mi writer.
+ * event single trace event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_function_probe(struct mi_writer *writer,
+               struct lttng_event *event);
+
+/*
+ * Machine interface for kernel function entry event.
+ *
+ * writer An instance of a mi writer.
+ * event single trace event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_function_entry(struct mi_writer *writer,
+               struct lttng_event *event);
+
+/*
+ * Machine interface: open an events element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_events_open(struct mi_writer *writer);
+
+/*
+ * Machine interface for printing an event.
+ * The trace event type currently supported are:
+ *  TRACEPOINT,
+ *  PROBE,
+ *  FUNCTION,
+ *  FUNCTION_ENTRY,
+ *  SYSCALL
+ *
+ * writer An instance of a mi writer.
+ * event single trace event.
+ * is_open Defines whether or not the session element shall be closed.
+ *         This should be used carefully and the client
+ *         must close the event element.
+ *         Use case: nested additional information
+ * domain Event's domain
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event(struct mi_writer *writer, struct lttng_event *event,
+               int is_open, enum lttng_domain_type domain);
+
+/*
+ * Machine interface for struct lttng_event_field.
+ *
+ * writer An instance of a mi writer.
+ * field An event_field instance.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_field(struct mi_writer *writer,
+               struct lttng_event_field *field);
+
+/*
+ * Machine interface: open a event_fields element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element have be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_fields_open(struct mi_writer *writer);
+
+/*
+ * Machine interface: open a trackers element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_trackers_open(struct mi_writer *writer);
+
+/*
+ * Machine interface: open a process attribute tracker element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ *
+ * Note: A targets element is also opened for each tracker definition
+ */
+int mi_lttng_process_attribute_tracker_open(
+               struct mi_writer *writer, enum lttng_process_attr process_attr);
+
+/*
+ * Machine interface: open a PIDs element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_pids_open(struct mi_writer *writer);
+
+/*
+ * Machine interface: open a processes element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_processes_open(struct mi_writer *writer);
+
+/*
+ * Machine interface of a Process.
+ *
+ * writer An instance of a machine interface writer.
+ * pid A PID.
+ *
+ * is_open Defines whether or not the session element shall be closed.
+ *         This should be used carefully and the client
+ *         must close the pid element.
+ *         Use case: nested addition information on a domain
+ *                  ex: channel event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_process(struct mi_writer *writer, pid_t pid , const char *name,
+               int is_open);
+
+/*
+ * TODO: move pid of lttng list -u to process semantic on mi api bump
+ * Machine interface of a Process.
+ *
+ * writer An instance of a machine interface writer.
+ * pid A PID.
+ *
+ * is_open Defines whether or not the session element shall be closed.
+ *         This should be used carefully and the client
+ *         must close the pid element.
+ *         Use case: nested addition information on a domain
+ *                  ex: channel event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *name,
+               int is_open);
+
+/*
+ * Machine interface: open a process attribute values element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_process_attr_values_open(struct mi_writer *writer);
+
+/*
+ * Machine interface for track/untrack of all process attribute values.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_all_process_attribute_value(struct mi_writer *writer,
+               enum lttng_process_attr process_attr,
+               bool is_open);
+
+/*
+ * Machine interface for track/untrack of an integral process attribute value.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_integral_process_attribute_value(struct mi_writer *writer,
+               enum lttng_process_attr process_attr,
+               int64_t value,
+               bool is_open);
+
+/*
+ * Machine interface for track/untrack of a string process attribute value.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_string_process_attribute_value(struct mi_writer *writer,
+               enum lttng_process_attr process_attr,
+               const char *value,
+               bool is_open);
+
+/*
+ * Machine interface of a context.
+ *
+ * writer An instance of a machine interface writer
+ *
+ * context An instance of a lttng_event_context
+ *
+ * is_open Define if we close the context element
+ *         This should be used carefully and the client
+ *         need to close the context element.
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_context(struct mi_writer *writer,
+               struct lttng_event_context *context, int is_open);
+
+/*
+ * Machine interface of a perf_counter_context.
+ *
+ * writer An instance of a machine interface writer
+ *
+ * contest An instance of a lttng_event_perf_counter_ctx
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_perf_counter_context(struct mi_writer *writer,
+               struct lttng_event_perf_counter_ctx  *perf_context);
+
+/*
+ * Machine interface of the snapshot list_output.
+ * It specifies the session for which we are listing snapshots,
+ * and it opens a snapshots element to list a sequence
+ * of snapshots.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * session_name: Snapshot output for session "session_name".
+ *
+ * Note: The client has to close the session and the snapshots elements after
+ * having listed every lttng_snapshot_output.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_snapshot_output_session_name(struct mi_writer *writer,
+               const char *session_name);
+
+/*
+ * Machine interface of the snapshot output.
+ * The machine interface serializes the following attributes:
+ * - id: ID of the snapshot output.
+ * - name: Name of the output.
+ * - data_url : Destination of the output.
+ * - ctrl_url: Destination of the output.
+ * - max_size: total size of all stream combined.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * output: A list of snapshot_output.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_snapshot_list_output(struct mi_writer *writer,
+               const struct lttng_snapshot_output *output);
+
+/*
+ * Machine interface of the output of the command snapshot del output
+ * when deleting a snapshot either by id or by name.
+ * If the snapshot was found and successfully deleted using its id,
+ * it return the id of the snapshot and the current session name on which it
+ * was attached.
+ *
+ * Otherwise, it do the same process with the name of the snapshot, if the
+ * snapshot output id is undefined.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * id: ID of the snapshot output.
+ *
+ * name: Name of the snapshot.
+ *
+ * current_session_name: Session to which the snapshot belongs.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_snapshot_del_output(struct mi_writer *writer, int id,
+               const char *name, const char *current_session_name);
+
+/*
+ * Machine interface of the output of the command snapshot add output
+ * when adding a snapshot from a user URL.
+ *
+ * If the snapshot was successfully added, the machine interface lists
+ * these information:
+ * - id: ID of the newly add snapshot output.
+ * - current_session_name: Name of the session to which the output was added.
+ * - ctrl_url: Destination of the output.
+ * - max_size: total size of all stream combined.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * current_session_name: Session to which the snapshot belongs.
+ *
+ * n_ptr:
+ *
+ * output: iterator over a lttng_snapshot_output_list which contain
+ * the snapshot output informations.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_snapshot_add_output(struct mi_writer *writer,
+               const char *current_session_name, const char *n_ptr,
+               struct lttng_snapshot_output *output);
+
+/*
+ * Machine interface of the output of the command snapshot
+ * record  from a URL (if given).
+ *
+ * If the snapshot is successfully recorded from a url, the machine interface
+ * output the following information:
+ * - url: Destination of the output stored in the snapshot.
+ *
+ * Otherwise, the machine interface output the data and ctrl url received
+ * from the command-line.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * ctrl_url, data_url: Destination of the output receive from the command-line.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_snapshot_record(struct mi_writer *writer, const char *url,
+               const char *cmdline_ctrl_url, const char *cmdline_data_url);
+
+/*
+ * Machine interface representation of a session rotation schedule.
+ *
+ * The machine interface serializes the provided schedule as one of the choices
+ * from 'rotation_schedule_type'.
+ *
+ * writer: An instance of a machine interface writer.
+ *
+ * schedule: An lttng rotation schedule descriptor object.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_rotation_schedule(struct mi_writer *writer,
+               const struct lttng_rotation_schedule *schedule);
+
+/*
+ * Machine interface of a session rotation schedule result.
+ * This is an element that is part of the output of the enable-rotation and
+ * disable-rotation commands.
+ *
+ * The machine interface provides the following information:
+ * - schedule: the session rotation schedule descriptor.
+ * - success: whether the sub-command succeeded.
+ *
+ * writer: An instance of a machine interface writer.
+ *
+ * schedule: An lttng rotation schedule descriptor object.
+ *
+ * success: Whether the sub-command suceeded.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_rotation_schedule_result(struct mi_writer *writer,
+               const struct lttng_rotation_schedule *schedule,
+               bool success);
+
+/*
+ * Machine interface of a session rotation result.
+ * This is an element that is part of the output of the rotate command.
+ *
+ * The machine interface provides the following information:
+ * - session_name: the session to be rotated.
+ * - state: the session rotation state.
+ * - location: the location of the completed chunk archive.
+ *
+ * writer: An instance of a machine interface writer.
+ *
+ * session_name: The session to which the rotate command applies.
+ *
+ * location: A location descriptor object.
+ *
+ * success: Whether the sub-command suceeded.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_rotate(struct mi_writer *writer,
+               const char *session_name,
+               enum lttng_rotation_state rotation_state,
+               const struct lttng_trace_archive_location *location);
+
+#endif /* _MI_LTTNG_H */
index 989c20ade5e1f126ffcf2609e7f0eea21e2f4028..248dd42e7529cf3f9ae16fdb69f0d4e2f9c013dc 100644 (file)
@@ -5,14 +5,14 @@
  *
  */
 
-#include <lttng/notification/notification-internal.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/evaluation-internal.h>
+#include <lttng/notification/notification-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/evaluation-internal.hpp>
 #include <lttng/condition/condition.h>
 #include <lttng/condition/evaluation.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <common/payload.hpp>
+#include <common/payload-view.hpp>
 
 struct lttng_notification *lttng_notification_create(
                struct lttng_trigger *trigger,
diff --git a/src/common/optional.h b/src/common/optional.h
deleted file mode 100644 (file)
index f34c599..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_OPTIONAL_H
-#define LTTNG_OPTIONAL_H
-
-#include <stdint.h>
-
-/*
- * Define wrapper structure representing an optional value.
- *
- * This macro defines an "is_set" boolean field that must be checked
- * when accessing the optional field. This "is_set" field provides
- * the semantics that would be expected of a typical "raw pointer" field
- * which would be checked for NULL.
- *
- * Prefer using this macro where "special" values would be used, e.g.
- * -1ULL for uint64_t types.
- *
- * Declaration example:
- * struct my_struct {
- *     int a;
- *     LTTNG_OPTIONAL(int) b;
- * };
- *
- * Usage example:
- * struct my_struct foo = LTTNG_OPTIONAL_INIT;
- *
- * LTTNG_OPTIONAL_SET(&foo.b, 42);
- * if (foo.b.is_set) {
- *     printf("%d", foo.b.value);
- * }
- *
- * LTTNG_OPTIONAL_UNSET(&foo.b);
- */
-#define LTTNG_OPTIONAL(type) \
-       struct {             \
-               uint8_t is_set; \
-               type value;  \
-       }
-
-/*
- * Alias used for communication structures. If the layout of an LTTNG_OPTIONAL
- * is changed, the original layout should still be used for communication
- * purposes.
- *
- * LTTNG_OPTIONAL_COMM should be combined with the LTTNG_PACKED macro when
- * used for IPC / network communication.
- */
-#define LTTNG_OPTIONAL_COMM LTTNG_OPTIONAL
-
-/*
- * This macro is available as a 'convenience' to allow sites that assume
- * an optional value is set to LTTNG_ASSERT() that it is set when accessing it.
- *
- * Since this returns the 'optional' by value, it is not suitable for all
- * wrapped optional types. It is meant to be used with PODs.
- */
-#define LTTNG_OPTIONAL_GET(optional)                   \
-       ({                                              \
-               LTTNG_ASSERT((optional).is_set);                \
-               (optional).value;                       \
-       })
-
-/*
- * This macro is available as a 'convenience' to allow sites that assume
- * an optional value is set to LTTNG_ASSERT() that it is set when fecthing the
- * underlying value's address.
- */
-#define LTTNG_OPTIONAL_GET_PTR(optional)                       \
-       ({                                              \
-               LTTNG_ASSERT((optional).is_set);                \
-               &(optional).value;                      \
-       })
-
-/*
- * Initialize an optional field as unset.
- *
- * The wrapped field is set to the value it would gave if it had static storage
- * duration.
- */
-#define LTTNG_OPTIONAL_INIT_UNSET {}
-
-/*
- * Initialize an optional field as 'set' with a given value.
- */
-#define LTTNG_OPTIONAL_INIT_VALUE(val) { .is_set = 1, .value = val }
-
-/* Set the value of an optional field. */
-#define LTTNG_OPTIONAL_SET(field_ptr, val)     \
-       do {                                    \
-               (field_ptr)->is_set = 1;        \
-               (field_ptr)->value = (val);     \
-       } while (0)
-
-/* Put an optional field in the "unset" (NULL-ed) state. */
-#define LTTNG_OPTIONAL_UNSET(field_ptr)                \
-       do {                                    \
-               (field_ptr)->is_set = 0;        \
-       } while (0)
-
-#endif /* LTTNG_OPTIONAL_H */
diff --git a/src/common/optional.hpp b/src/common/optional.hpp
new file mode 100644 (file)
index 0000000..f34c599
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_OPTIONAL_H
+#define LTTNG_OPTIONAL_H
+
+#include <stdint.h>
+
+/*
+ * Define wrapper structure representing an optional value.
+ *
+ * This macro defines an "is_set" boolean field that must be checked
+ * when accessing the optional field. This "is_set" field provides
+ * the semantics that would be expected of a typical "raw pointer" field
+ * which would be checked for NULL.
+ *
+ * Prefer using this macro where "special" values would be used, e.g.
+ * -1ULL for uint64_t types.
+ *
+ * Declaration example:
+ * struct my_struct {
+ *     int a;
+ *     LTTNG_OPTIONAL(int) b;
+ * };
+ *
+ * Usage example:
+ * struct my_struct foo = LTTNG_OPTIONAL_INIT;
+ *
+ * LTTNG_OPTIONAL_SET(&foo.b, 42);
+ * if (foo.b.is_set) {
+ *     printf("%d", foo.b.value);
+ * }
+ *
+ * LTTNG_OPTIONAL_UNSET(&foo.b);
+ */
+#define LTTNG_OPTIONAL(type) \
+       struct {             \
+               uint8_t is_set; \
+               type value;  \
+       }
+
+/*
+ * Alias used for communication structures. If the layout of an LTTNG_OPTIONAL
+ * is changed, the original layout should still be used for communication
+ * purposes.
+ *
+ * LTTNG_OPTIONAL_COMM should be combined with the LTTNG_PACKED macro when
+ * used for IPC / network communication.
+ */
+#define LTTNG_OPTIONAL_COMM LTTNG_OPTIONAL
+
+/*
+ * This macro is available as a 'convenience' to allow sites that assume
+ * an optional value is set to LTTNG_ASSERT() that it is set when accessing it.
+ *
+ * Since this returns the 'optional' by value, it is not suitable for all
+ * wrapped optional types. It is meant to be used with PODs.
+ */
+#define LTTNG_OPTIONAL_GET(optional)                   \
+       ({                                              \
+               LTTNG_ASSERT((optional).is_set);                \
+               (optional).value;                       \
+       })
+
+/*
+ * This macro is available as a 'convenience' to allow sites that assume
+ * an optional value is set to LTTNG_ASSERT() that it is set when fecthing the
+ * underlying value's address.
+ */
+#define LTTNG_OPTIONAL_GET_PTR(optional)                       \
+       ({                                              \
+               LTTNG_ASSERT((optional).is_set);                \
+               &(optional).value;                      \
+       })
+
+/*
+ * Initialize an optional field as unset.
+ *
+ * The wrapped field is set to the value it would gave if it had static storage
+ * duration.
+ */
+#define LTTNG_OPTIONAL_INIT_UNSET {}
+
+/*
+ * Initialize an optional field as 'set' with a given value.
+ */
+#define LTTNG_OPTIONAL_INIT_VALUE(val) { .is_set = 1, .value = val }
+
+/* Set the value of an optional field. */
+#define LTTNG_OPTIONAL_SET(field_ptr, val)     \
+       do {                                    \
+               (field_ptr)->is_set = 1;        \
+               (field_ptr)->value = (val);     \
+       } while (0)
+
+/* Put an optional field in the "unset" (NULL-ed) state. */
+#define LTTNG_OPTIONAL_UNSET(field_ptr)                \
+       do {                                    \
+               (field_ptr)->is_set = 0;        \
+       } while (0)
+
+#endif /* LTTNG_OPTIONAL_H */
index ff2f86d652a1d2124febd59da9c5e2d3ea69bad9..1699cc5a6de28d0075002ee0266220399fd8c79d 100644 (file)
@@ -8,9 +8,9 @@
  */
 
 #define _LGPL_SOURCE
-#include <common/macros.h>
-#include <common/common.h>
-#include <common/path.h>
+#include <common/macros.hpp>
+#include <common/common.hpp>
+#include <common/path.hpp>
 
 /*
  * Return a partial realpath(3) of the path even if the full path does not
diff --git a/src/common/path.h b/src/common/path.h
deleted file mode 100644 (file)
index 3f81eeb..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- */
-
-#ifndef _COMMON_PATH_H
-#define _COMMON_PATH_H
-
-char *utils_expand_path(const char *path);
-char *utils_expand_path_keep_symlink(const char *path);
-
-#endif /* _COMMON_PATH_H */
diff --git a/src/common/path.hpp b/src/common/path.hpp
new file mode 100644 (file)
index 0000000..3f81eeb
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ */
+
+#ifndef _COMMON_PATH_H
+#define _COMMON_PATH_H
+
+char *utils_expand_path(const char *path);
+char *utils_expand_path_keep_symlink(const char *path);
+
+#endif /* _COMMON_PATH_H */
index f446acacfa2c22f744a4be7b49db94b5d548c330..d5e67961b54b49b680993b9593986c3166638cea 100644 (file)
@@ -5,10 +5,10 @@
  *
  */
 
-#include <common/dynamic-array.h>
-#include <common/buffer-view.h>
-#include "payload-view.h"
-#include "payload.h"
+#include <common/dynamic-array.hpp>
+#include <common/buffer-view.hpp>
+#include "payload-view.hpp"
+#include "payload.hpp"
 #include <stddef.h>
 
 bool lttng_payload_view_is_valid(const struct lttng_payload_view *view)
diff --git a/src/common/payload-view.h b/src/common/payload-view.h
deleted file mode 100644 (file)
index deaa965..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_PAYLOAD_VIEW_H
-#define LTTNG_PAYLOAD_VIEW_H
-
-#include <common/buffer-view.h>
-#include <common/dynamic-array.h>
-
-struct lttng_payload;
-struct fd_handle;
-
-/*
- * An lttng_payload_view references a payload and allows code to share
- * a `const` version of a subset of a payload.
- *
- * A payload view is invalidated whenever its source (a payload, or another
- * payload view) is modified.
- *
- * While a payload view does not allow users to modify the underlying bytes
- * of the payload, it can be used to 'pop' file descriptor handles using an
- * iterator belonging to the top-level payload view.
- *
- * Hence, a payload view created from a        payload or a dynamic buffer contains
- * an implicit file descriptor handle iterator. Any payload view created from
- * another payload view will share the same underlying file descriptor handle
- * iterator.
- *
- * The rationale for this is that a payload is never consumed directly, it must
- * be consumed through a payload view.
- *
- * Typically, a payload view will be used to rebuild a previously serialized
- * object hierarchy. Sharing an underlying iterator allows aggregate objects
- * to provide a restricted view of the payload to their members, which will
- * report the number of bytes consumed and `pop` the file descriptor handle they
- * should own. In return, those objects can create an even narrower view for
- * their children, allowing them to also consume file descriptor handles.
- *
- * Note that a payload view never assumes any ownership of the underlying
- * payload.
- */
-struct lttng_payload_view {
-       struct lttng_buffer_view buffer;
-       /* private */
-
-       const struct lttng_dynamic_pointer_array _fd_handles;
-
-       struct {
-               size_t *p_fd_handles_position;
-               size_t fd_handles_position;
-       } _iterator;
-};
-
-/**
- * Checks if a payload view's buffer is safe to access.
- *
- * After calling the payload view creation functions, callers should verify
- * if the resquested length (if any is explicitly provided) could be mapped
- * to a new view.
- *
- * @view       Payload to validate
- */
-bool lttng_payload_view_is_valid(const struct lttng_payload_view *view);
-
-/**
- * Return a payload view referencing a subset of a payload.
- *
- * @payload    Source payload to reference
- * @offset     Offset to apply to the payload's buffer
- * @len                Length of the contents to reference. Passing -1 will
- *             cause the view to reference the whole payload from the
- *             offset provided.
- */
-struct lttng_payload_view lttng_payload_view_from_payload(
-               const struct lttng_payload *payload, size_t offset,
-               ptrdiff_t len);
-
-/**
- * Return a payload view referencing a subset of a payload referenced by
- * another payload view.
- *
- * @view       Source payload view to reference
- * @offset     Offset to apply to the payload view's buffer view
- * @len                Length of the contents to reference. Passing -1 will
- *             cause the payload view to reference the whole payload view's
- *             buffer view from the offset provided.
- */
-struct lttng_payload_view lttng_payload_view_from_view(
-               struct lttng_payload_view *view, size_t offset,
-               ptrdiff_t len);
-
-/**
- * Return a payload view referencing a subset of a dynamic buffer.
- *
- * Meant as an adapter for code paths that need to create a payload view
- * from an existing dynamic buffer.
- *
- * @src                Source dynamic buffer to reference
- * @offset     Offset to apply to the dynamic buffer
- * @len                Length of the buffer contents to reference. Passing -1 will
- *             cause the payload view to reference the whole payload from the
- *             offset provided.
- */
-struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
-               const struct lttng_dynamic_buffer *buffer, size_t offset,
-               ptrdiff_t len);
-/**
- *
- * Return a payload view referencing a subset of a dynamic buffer.
- *
- * Meant as an adapter for code paths that need to create a payload view
- * from an existing buffer view.
- *
- * @src                Source buffer view to reference
- * @offset     Offset to apply to the buffer view
- * @len                Length of the buffer contents to reference. Passing -1 will
- *             cause the payload view to reference the whole payload from the
- *             offset provided.
- */
-struct lttng_payload_view lttng_payload_view_from_buffer_view(
-               const struct lttng_buffer_view *view, size_t offset,
-               ptrdiff_t len);
-
-/**
- * Return a payload view referencing a subset of the memory referenced by a raw
- * pointer.
- *
- * @src                Source buffer to reference
- * @offset     Offset to apply to the source memory buffer
- * @len                Length of the memory contents to reference.
- *
- * Note that a payload view never assumes the ownership of the memory it
- * references.
- */
-struct lttng_payload_view lttng_payload_view_init_from_buffer(
-               const char *src, size_t offset, ptrdiff_t len);
-
-/**
- * Get the number of file descriptor handles left in a payload view.
- *
- * @payload    Payload instance
- *
- * Returns the number of file descriptor handles left on success, -1 on error.
- */
-int lttng_payload_view_get_fd_handle_count(
-               const struct lttng_payload_view *payload_view);
-
-/**
- * Pop an fd handle from a payload view.
- *
- * A reference to the returned fd_handle is acquired on behalf of the caller.
- *
- * @payload    Payload instance
- *
- * Returns an fd_handle on success, -1 on error.
- */
-struct fd_handle *lttng_payload_view_pop_fd_handle(
-               struct lttng_payload_view *payload_view);
-
-#endif /* LTTNG_PAYLOAD_VIEW_H */
diff --git a/src/common/payload-view.hpp b/src/common/payload-view.hpp
new file mode 100644 (file)
index 0000000..06bb3d1
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_PAYLOAD_VIEW_H
+#define LTTNG_PAYLOAD_VIEW_H
+
+#include <common/buffer-view.hpp>
+#include <common/dynamic-array.hpp>
+
+struct lttng_payload;
+struct fd_handle;
+
+/*
+ * An lttng_payload_view references a payload and allows code to share
+ * a `const` version of a subset of a payload.
+ *
+ * A payload view is invalidated whenever its source (a payload, or another
+ * payload view) is modified.
+ *
+ * While a payload view does not allow users to modify the underlying bytes
+ * of the payload, it can be used to 'pop' file descriptor handles using an
+ * iterator belonging to the top-level payload view.
+ *
+ * Hence, a payload view created from a        payload or a dynamic buffer contains
+ * an implicit file descriptor handle iterator. Any payload view created from
+ * another payload view will share the same underlying file descriptor handle
+ * iterator.
+ *
+ * The rationale for this is that a payload is never consumed directly, it must
+ * be consumed through a payload view.
+ *
+ * Typically, a payload view will be used to rebuild a previously serialized
+ * object hierarchy. Sharing an underlying iterator allows aggregate objects
+ * to provide a restricted view of the payload to their members, which will
+ * report the number of bytes consumed and `pop` the file descriptor handle they
+ * should own. In return, those objects can create an even narrower view for
+ * their children, allowing them to also consume file descriptor handles.
+ *
+ * Note that a payload view never assumes any ownership of the underlying
+ * payload.
+ */
+struct lttng_payload_view {
+       struct lttng_buffer_view buffer;
+       /* private */
+
+       const struct lttng_dynamic_pointer_array _fd_handles;
+
+       struct {
+               size_t *p_fd_handles_position;
+               size_t fd_handles_position;
+       } _iterator;
+};
+
+/**
+ * Checks if a payload view's buffer is safe to access.
+ *
+ * After calling the payload view creation functions, callers should verify
+ * if the resquested length (if any is explicitly provided) could be mapped
+ * to a new view.
+ *
+ * @view       Payload to validate
+ */
+bool lttng_payload_view_is_valid(const struct lttng_payload_view *view);
+
+/**
+ * Return a payload view referencing a subset of a payload.
+ *
+ * @payload    Source payload to reference
+ * @offset     Offset to apply to the payload's buffer
+ * @len                Length of the contents to reference. Passing -1 will
+ *             cause the view to reference the whole payload from the
+ *             offset provided.
+ */
+struct lttng_payload_view lttng_payload_view_from_payload(
+               const struct lttng_payload *payload, size_t offset,
+               ptrdiff_t len);
+
+/**
+ * Return a payload view referencing a subset of a payload referenced by
+ * another payload view.
+ *
+ * @view       Source payload view to reference
+ * @offset     Offset to apply to the payload view's buffer view
+ * @len                Length of the contents to reference. Passing -1 will
+ *             cause the payload view to reference the whole payload view's
+ *             buffer view from the offset provided.
+ */
+struct lttng_payload_view lttng_payload_view_from_view(
+               struct lttng_payload_view *view, size_t offset,
+               ptrdiff_t len);
+
+/**
+ * Return a payload view referencing a subset of a dynamic buffer.
+ *
+ * Meant as an adapter for code paths that need to create a payload view
+ * from an existing dynamic buffer.
+ *
+ * @src                Source dynamic buffer to reference
+ * @offset     Offset to apply to the dynamic buffer
+ * @len                Length of the buffer contents to reference. Passing -1 will
+ *             cause the payload view to reference the whole payload from the
+ *             offset provided.
+ */
+struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
+               const struct lttng_dynamic_buffer *buffer, size_t offset,
+               ptrdiff_t len);
+/**
+ *
+ * Return a payload view referencing a subset of a dynamic buffer.
+ *
+ * Meant as an adapter for code paths that need to create a payload view
+ * from an existing buffer view.
+ *
+ * @src                Source buffer view to reference
+ * @offset     Offset to apply to the buffer view
+ * @len                Length of the buffer contents to reference. Passing -1 will
+ *             cause the payload view to reference the whole payload from the
+ *             offset provided.
+ */
+struct lttng_payload_view lttng_payload_view_from_buffer_view(
+               const struct lttng_buffer_view *view, size_t offset,
+               ptrdiff_t len);
+
+/**
+ * Return a payload view referencing a subset of the memory referenced by a raw
+ * pointer.
+ *
+ * @src                Source buffer to reference
+ * @offset     Offset to apply to the source memory buffer
+ * @len                Length of the memory contents to reference.
+ *
+ * Note that a payload view never assumes the ownership of the memory it
+ * references.
+ */
+struct lttng_payload_view lttng_payload_view_init_from_buffer(
+               const char *src, size_t offset, ptrdiff_t len);
+
+/**
+ * Get the number of file descriptor handles left in a payload view.
+ *
+ * @payload    Payload instance
+ *
+ * Returns the number of file descriptor handles left on success, -1 on error.
+ */
+int lttng_payload_view_get_fd_handle_count(
+               const struct lttng_payload_view *payload_view);
+
+/**
+ * Pop an fd handle from a payload view.
+ *
+ * A reference to the returned fd_handle is acquired on behalf of the caller.
+ *
+ * @payload    Payload instance
+ *
+ * Returns an fd_handle on success, -1 on error.
+ */
+struct fd_handle *lttng_payload_view_pop_fd_handle(
+               struct lttng_payload_view *payload_view);
+
+#endif /* LTTNG_PAYLOAD_VIEW_H */
index 0097e65bcf1191cb75cacb10dbb4f07531797a90..fa07dae31c840c2fa7661088e9d35ed691e3bad0 100644 (file)
@@ -5,10 +5,10 @@
  *
  */
 
-#include "payload.h"
-#include <common/dynamic-array.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
+#include "payload.hpp"
+#include <common/dynamic-array.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
 
 static
 void release_fd_handle_ref(void *ptr)
diff --git a/src/common/payload.h b/src/common/payload.h
deleted file mode 100644 (file)
index d6c0cc1..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_PAYLOAD_H
-#define LTTNG_PAYLOAD_H
-
-#include <common/dynamic-buffer.h>
-#include <common/dynamic-array.h>
-#include <common/fd-handle.h>
-
-/*
- * An lttng_payload encompasses the 'data' (bytes) and any passed file
- * descriptors as part of a message between liblttng-ctl and the session
- * daemon.
- */
-struct lttng_payload {
-       struct lttng_dynamic_buffer buffer;
-       /* private */
-       struct lttng_dynamic_pointer_array _fd_handles;
-};
-
-/*
- * Initialize a payload. This performs no allocation and is meant
- * to be used instead of zero-ing the payload structure.
- */
-void lttng_payload_init(struct lttng_payload *payload);
-
-/* Copy a payload. */
-int lttng_payload_copy(const struct lttng_payload *src_payload,
-               struct lttng_payload *dst_payload);
-
-/* Release any memory and references held by the payload. */
-void lttng_payload_reset(struct lttng_payload *payload);
-
-/*
- * Empty the contents of a payload, releasing all references held.
- * This should be used to put a payload in a re-usable state.
- *
- * lttng_payload_reset must still be called on an lttng_payload to
- * free all allocated memory.
- */
-void lttng_payload_clear(struct lttng_payload *payload);
-
-/**
- * Add an fd to the payload.
- * The payload acquires a reference to the fd_handle.
- *
- * @payload    Payload instance
- * @fd_handle  File descriptor handle to add to the payload
- *
- * Returns 0 on success, -1 on allocation error.
- */
-int lttng_payload_push_fd_handle(struct lttng_payload *payload,
-               struct fd_handle *fd_handle);
-
-#endif /* LTTNG_PAYLOAD_H */
diff --git a/src/common/payload.hpp b/src/common/payload.hpp
new file mode 100644 (file)
index 0000000..9747f59
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_PAYLOAD_H
+#define LTTNG_PAYLOAD_H
+
+#include <common/dynamic-buffer.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/fd-handle.hpp>
+
+/*
+ * An lttng_payload encompasses the 'data' (bytes) and any passed file
+ * descriptors as part of a message between liblttng-ctl and the session
+ * daemon.
+ */
+struct lttng_payload {
+       struct lttng_dynamic_buffer buffer;
+       /* private */
+       struct lttng_dynamic_pointer_array _fd_handles;
+};
+
+/*
+ * Initialize a payload. This performs no allocation and is meant
+ * to be used instead of zero-ing the payload structure.
+ */
+void lttng_payload_init(struct lttng_payload *payload);
+
+/* Copy a payload. */
+int lttng_payload_copy(const struct lttng_payload *src_payload,
+               struct lttng_payload *dst_payload);
+
+/* Release any memory and references held by the payload. */
+void lttng_payload_reset(struct lttng_payload *payload);
+
+/*
+ * Empty the contents of a payload, releasing all references held.
+ * This should be used to put a payload in a re-usable state.
+ *
+ * lttng_payload_reset must still be called on an lttng_payload to
+ * free all allocated memory.
+ */
+void lttng_payload_clear(struct lttng_payload *payload);
+
+/**
+ * Add an fd to the payload.
+ * The payload acquires a reference to the fd_handle.
+ *
+ * @payload    Payload instance
+ * @fd_handle  File descriptor handle to add to the payload
+ *
+ * Returns 0 on success, -1 on allocation error.
+ */
+int lttng_payload_push_fd_handle(struct lttng_payload *payload,
+               struct fd_handle *fd_handle);
+
+#endif /* LTTNG_PAYLOAD_H */
index 2de91f5a06eaac1f87aec7e724d9a98c5ef25eb3..c2dce78816f0fad0e41a935d49371b20f5bbcd0d 100644 (file)
@@ -11,9 +11,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include <common/common.h>
+#include <common/common.hpp>
 
-#include "pipe.h"
+#include "pipe.hpp"
 
 /*
  * Lock read side of a pipe.
diff --git a/src/common/pipe.h b/src/common/pipe.h
deleted file mode 100644 (file)
index d9f43d6..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_PIPE_H
-#define LTTNG_PIPE_H
-
-#include <pthread.h>
-#include <common/macros.h>
-#include <sys/types.h>
-
-enum lttng_pipe_state {
-       LTTNG_PIPE_STATE_OPENED = 1,
-       LTTNG_PIPE_STATE_CLOSED = 2,
-};
-
-struct lttng_pipe {
-       /* Read: 0, Write: 1. */
-       int fd[2];
-       /*
-        * Flags of the pipe once opened. pipe(2) specifies either O_NONBLOCK or
-        * O_CLOEXEC can be used. Flags are set using fcntl(2) call.
-        */
-       int flags;
-
-       /*
-        * These states are protected by the operation mutex below.
-        */
-       enum lttng_pipe_state r_state;
-       enum lttng_pipe_state w_state;
-
-       /* Held for each read(2) operation. */
-       pthread_mutex_t read_mutex;
-       /* Held for each write(2) operation. */
-       pthread_mutex_t write_mutex;
-};
-
-/*
- * Return 1 if read side is open else 0.
- */
-static inline int lttng_pipe_is_read_open(const struct lttng_pipe *pipe)
-{
-       return pipe->r_state == LTTNG_PIPE_STATE_OPENED ? 1 : 0;
-}
-
-/*
- * Return 1 if write side is open else 0.
- */
-static inline int lttng_pipe_is_write_open(const struct lttng_pipe *pipe)
-{
-       return pipe->w_state == LTTNG_PIPE_STATE_OPENED ? 1 : 0;
-}
-
-static inline int lttng_pipe_get_readfd(const struct lttng_pipe *pipe)
-{
-       return pipe->fd[0];
-}
-
-static inline int lttng_pipe_get_writefd(const struct lttng_pipe *pipe)
-{
-       return pipe->fd[1];
-}
-
-struct lttng_pipe *lttng_pipe_open(int flags);
-struct lttng_pipe *lttng_pipe_named_open(const char *path, mode_t mode,
-               int flags);
-int lttng_pipe_write_close(struct lttng_pipe *pipe);
-int lttng_pipe_read_close(struct lttng_pipe *pipe);
-/* Close both side of pipe. */
-int lttng_pipe_close(struct lttng_pipe *pipe);
-void lttng_pipe_destroy(struct lttng_pipe *pipe);
-
-ssize_t lttng_pipe_read(struct lttng_pipe *pipe, void *buf, size_t count);
-ssize_t lttng_pipe_write(struct lttng_pipe *pipe, const void *buf,
-               size_t count);
-/* Returns and releases the read end of the pipe. */
-int lttng_pipe_release_readfd(struct lttng_pipe *pipe);
-/* Returns and releases the write end of the pipe. */
-int lttng_pipe_release_writefd(struct lttng_pipe *pipe);
-
-#endif /* LTTNG_PIPE_H */
diff --git a/src/common/pipe.hpp b/src/common/pipe.hpp
new file mode 100644 (file)
index 0000000..d46e65d
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_PIPE_H
+#define LTTNG_PIPE_H
+
+#include <pthread.h>
+#include <common/macros.hpp>
+#include <sys/types.h>
+
+enum lttng_pipe_state {
+       LTTNG_PIPE_STATE_OPENED = 1,
+       LTTNG_PIPE_STATE_CLOSED = 2,
+};
+
+struct lttng_pipe {
+       /* Read: 0, Write: 1. */
+       int fd[2];
+       /*
+        * Flags of the pipe once opened. pipe(2) specifies either O_NONBLOCK or
+        * O_CLOEXEC can be used. Flags are set using fcntl(2) call.
+        */
+       int flags;
+
+       /*
+        * These states are protected by the operation mutex below.
+        */
+       enum lttng_pipe_state r_state;
+       enum lttng_pipe_state w_state;
+
+       /* Held for each read(2) operation. */
+       pthread_mutex_t read_mutex;
+       /* Held for each write(2) operation. */
+       pthread_mutex_t write_mutex;
+};
+
+/*
+ * Return 1 if read side is open else 0.
+ */
+static inline int lttng_pipe_is_read_open(const struct lttng_pipe *pipe)
+{
+       return pipe->r_state == LTTNG_PIPE_STATE_OPENED ? 1 : 0;
+}
+
+/*
+ * Return 1 if write side is open else 0.
+ */
+static inline int lttng_pipe_is_write_open(const struct lttng_pipe *pipe)
+{
+       return pipe->w_state == LTTNG_PIPE_STATE_OPENED ? 1 : 0;
+}
+
+static inline int lttng_pipe_get_readfd(const struct lttng_pipe *pipe)
+{
+       return pipe->fd[0];
+}
+
+static inline int lttng_pipe_get_writefd(const struct lttng_pipe *pipe)
+{
+       return pipe->fd[1];
+}
+
+struct lttng_pipe *lttng_pipe_open(int flags);
+struct lttng_pipe *lttng_pipe_named_open(const char *path, mode_t mode,
+               int flags);
+int lttng_pipe_write_close(struct lttng_pipe *pipe);
+int lttng_pipe_read_close(struct lttng_pipe *pipe);
+/* Close both side of pipe. */
+int lttng_pipe_close(struct lttng_pipe *pipe);
+void lttng_pipe_destroy(struct lttng_pipe *pipe);
+
+ssize_t lttng_pipe_read(struct lttng_pipe *pipe, void *buf, size_t count);
+ssize_t lttng_pipe_write(struct lttng_pipe *pipe, const void *buf,
+               size_t count);
+/* Returns and releases the read end of the pipe. */
+int lttng_pipe_release_readfd(struct lttng_pipe *pipe);
+/* Returns and releases the write end of the pipe. */
+int lttng_pipe_release_writefd(struct lttng_pipe *pipe);
+
+#endif /* LTTNG_PIPE_H */
index 857781c6ae7ed3ab345d392fb0fddeaa0423a696..8e901c9fec81f0027d120064ed90572765710ea6 100644 (file)
@@ -9,9 +9,9 @@
 #include <limits.h>
 #include <unistd.h>
 
-#include <common/compat/errno.h>
+#include <common/compat/errno.hpp>
 
-#include "readwrite.h"
+#include "readwrite.hpp"
 
 /*
  * lttng_read and lttng_write take care of EINTR and partial read/write.
diff --git a/src/common/readwrite.h b/src/common/readwrite.h
deleted file mode 100644 (file)
index ac3668a..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef LTTNG_COMMON_READWRITE_H
-#define LTTNG_COMMON_READWRITE_H
-
-/*
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <unistd.h>
-#include <common/macros.h>
-
-/*
- * lttng_read and lttng_write take care of EINTR and partial read/write.
- * Upon success, they return the "count" received as parameter.
- * They can return a negative value if an error occurs.
- * If a value lower than the requested "count" is returned, it means an
- * error occurred.
- * The error can be checked by querying errno.
- */
-ssize_t lttng_read(int fd, void *buf, size_t count);
-ssize_t lttng_write(int fd, const void *buf, size_t count);
-
-#endif /* LTTNG_COMMON_READWRITE_H */
diff --git a/src/common/readwrite.hpp b/src/common/readwrite.hpp
new file mode 100644 (file)
index 0000000..1818fdb
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef LTTNG_COMMON_READWRITE_H
+#define LTTNG_COMMON_READWRITE_H
+
+/*
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <unistd.h>
+#include <common/macros.hpp>
+
+/*
+ * lttng_read and lttng_write take care of EINTR and partial read/write.
+ * Upon success, they return the "count" received as parameter.
+ * They can return a negative value if an error occurs.
+ * If a value lower than the requested "count" is returned, it means an
+ * error occurred.
+ * The error can be checked by querying errno.
+ */
+ssize_t lttng_read(int fd, void *buf, size_t count);
+ssize_t lttng_write(int fd, const void *buf, size_t count);
+
+#endif /* LTTNG_COMMON_READWRITE_H */
index 6c2641ac03bec575f2c7ad469bac9ddd19bb7fe0..28cab7bc5c8d0500f8615e071d1eac758ca1896c 100644 (file)
 #include <sys/stat.h>
 #include <inttypes.h>
 
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/compat/endian.h>
-#include <common/compat/string.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/index/ctf-index.h>
-#include <common/trace-chunk.h>
-#include <common/string-utils/format.h>
-
-#include "relayd.h"
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/string.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/index/ctf-index.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/string-utils/format.hpp>
+
+#include "relayd.hpp"
 
 static
 bool relayd_supports_chunks(const struct lttcomm_relayd_sock *sock)
diff --git a/src/common/relayd/relayd.h b/src/common/relayd/relayd.h
deleted file mode 100644 (file)
index 1fbe226..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _RELAYD_H
-#define _RELAYD_H
-
-#include <unistd.h>
-#include <stdbool.h>
-
-#include <common/sessiond-comm/relayd.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/trace-chunk.h>
-#include <common/dynamic-array.h>
-
-struct relayd_stream_rotation_position {
-       uint64_t stream_id;
-       /*
-        * Packet sequence number of the first packet belonging to the new
-        * "destination" trace chunk to which the stream is rotating.
-        *
-        * Ignored for metadata streams.
-        */
-       uint64_t rotate_at_seq_num;
-};
-
-int relayd_connect(struct lttcomm_relayd_sock *sock);
-int relayd_close(struct lttcomm_relayd_sock *sock);
-int relayd_create_session(struct lttcomm_relayd_sock *rsock,
-               uint64_t *relayd_session_id,
-               const char *session_name, const char *hostname,
-               const char *base_path, int session_live_timer,
-               unsigned int snapshot, uint64_t sessiond_session_id,
-               const lttng_uuid sessiond_uuid,
-               const uint64_t *current_chunk_id,
-               time_t creation_time, bool session_name_contains_creation_time,
-               char *output_path);
-int relayd_add_stream(struct lttcomm_relayd_sock *sock, const char *channel_name,
-               const char *domain_name, const char *pathname, uint64_t *stream_id,
-               uint64_t tracefile_size, uint64_t tracefile_count,
-               struct lttng_trace_chunk *trace_chunk);
-int relayd_streams_sent(struct lttcomm_relayd_sock *rsock);
-int relayd_send_close_stream(struct lttcomm_relayd_sock *sock, uint64_t stream_id,
-               uint64_t last_net_seq_num);
-int relayd_version_check(struct lttcomm_relayd_sock *sock);
-int relayd_start_data(struct lttcomm_relayd_sock *sock);
-int relayd_send_metadata(struct lttcomm_relayd_sock *sock, size_t len);
-int relayd_send_data_hdr(struct lttcomm_relayd_sock *sock,
-               struct lttcomm_relayd_data_hdr *hdr, size_t size);
-int relayd_data_pending(struct lttcomm_relayd_sock *sock, uint64_t stream_id,
-               uint64_t last_net_seq_num);
-int relayd_quiescent_control(struct lttcomm_relayd_sock *sock,
-               uint64_t metadata_stream_id);
-int relayd_begin_data_pending(struct lttcomm_relayd_sock *sock, uint64_t id);
-int relayd_end_data_pending(struct lttcomm_relayd_sock *sock, uint64_t id,
-               unsigned int *is_data_inflight);
-int relayd_send_index(struct lttcomm_relayd_sock *rsock,
-               struct ctf_packet_index *index, uint64_t relay_stream_id,
-               uint64_t net_seq_num);
-int relayd_reset_metadata(struct lttcomm_relayd_sock *rsock,
-               uint64_t stream_id, uint64_t version);
-/* `positions` is an array of `stream_count` relayd_stream_rotation_position. */
-int relayd_rotate_streams(struct lttcomm_relayd_sock *sock,
-               unsigned int stream_count, const uint64_t *new_chunk_id,
-               const struct relayd_stream_rotation_position *positions);
-int relayd_create_trace_chunk(struct lttcomm_relayd_sock *sock,
-               struct lttng_trace_chunk *chunk);
-int relayd_close_trace_chunk(struct lttcomm_relayd_sock *sock,
-               struct lttng_trace_chunk *chunk,
-               char *path);
-int relayd_trace_chunk_exists(struct lttcomm_relayd_sock *sock,
-               uint64_t chunk_id, bool *chunk_exists);
-int relayd_get_configuration(struct lttcomm_relayd_sock *sock,
-               uint64_t query_flags,
-               uint64_t *result_flags);
-
-#endif /* _RELAYD_H */
diff --git a/src/common/relayd/relayd.hpp b/src/common/relayd/relayd.hpp
new file mode 100644 (file)
index 0000000..d4a903a
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _RELAYD_H
+#define _RELAYD_H
+
+#include <unistd.h>
+#include <stdbool.h>
+
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/dynamic-array.hpp>
+
+struct relayd_stream_rotation_position {
+       uint64_t stream_id;
+       /*
+        * Packet sequence number of the first packet belonging to the new
+        * "destination" trace chunk to which the stream is rotating.
+        *
+        * Ignored for metadata streams.
+        */
+       uint64_t rotate_at_seq_num;
+};
+
+int relayd_connect(struct lttcomm_relayd_sock *sock);
+int relayd_close(struct lttcomm_relayd_sock *sock);
+int relayd_create_session(struct lttcomm_relayd_sock *rsock,
+               uint64_t *relayd_session_id,
+               const char *session_name, const char *hostname,
+               const char *base_path, int session_live_timer,
+               unsigned int snapshot, uint64_t sessiond_session_id,
+               const lttng_uuid sessiond_uuid,
+               const uint64_t *current_chunk_id,
+               time_t creation_time, bool session_name_contains_creation_time,
+               char *output_path);
+int relayd_add_stream(struct lttcomm_relayd_sock *sock, const char *channel_name,
+               const char *domain_name, const char *pathname, uint64_t *stream_id,
+               uint64_t tracefile_size, uint64_t tracefile_count,
+               struct lttng_trace_chunk *trace_chunk);
+int relayd_streams_sent(struct lttcomm_relayd_sock *rsock);
+int relayd_send_close_stream(struct lttcomm_relayd_sock *sock, uint64_t stream_id,
+               uint64_t last_net_seq_num);
+int relayd_version_check(struct lttcomm_relayd_sock *sock);
+int relayd_start_data(struct lttcomm_relayd_sock *sock);
+int relayd_send_metadata(struct lttcomm_relayd_sock *sock, size_t len);
+int relayd_send_data_hdr(struct lttcomm_relayd_sock *sock,
+               struct lttcomm_relayd_data_hdr *hdr, size_t size);
+int relayd_data_pending(struct lttcomm_relayd_sock *sock, uint64_t stream_id,
+               uint64_t last_net_seq_num);
+int relayd_quiescent_control(struct lttcomm_relayd_sock *sock,
+               uint64_t metadata_stream_id);
+int relayd_begin_data_pending(struct lttcomm_relayd_sock *sock, uint64_t id);
+int relayd_end_data_pending(struct lttcomm_relayd_sock *sock, uint64_t id,
+               unsigned int *is_data_inflight);
+int relayd_send_index(struct lttcomm_relayd_sock *rsock,
+               struct ctf_packet_index *index, uint64_t relay_stream_id,
+               uint64_t net_seq_num);
+int relayd_reset_metadata(struct lttcomm_relayd_sock *rsock,
+               uint64_t stream_id, uint64_t version);
+/* `positions` is an array of `stream_count` relayd_stream_rotation_position. */
+int relayd_rotate_streams(struct lttcomm_relayd_sock *sock,
+               unsigned int stream_count, const uint64_t *new_chunk_id,
+               const struct relayd_stream_rotation_position *positions);
+int relayd_create_trace_chunk(struct lttcomm_relayd_sock *sock,
+               struct lttng_trace_chunk *chunk);
+int relayd_close_trace_chunk(struct lttcomm_relayd_sock *sock,
+               struct lttng_trace_chunk *chunk,
+               char *path);
+int relayd_trace_chunk_exists(struct lttcomm_relayd_sock *sock,
+               uint64_t chunk_id, bool *chunk_exists);
+int relayd_get_configuration(struct lttcomm_relayd_sock *sock,
+               uint64_t query_flags,
+               uint64_t *result_flags);
+
+#endif /* _RELAYD_H */
index eae650ba5038b9a09ab028709adaad6f7b41dc89..d5b53f2dc29ab31f6ecb99b49b70a64ec1e462bc 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 
-#include <common/bytecode/bytecode.h>
-#include <common/lttng-kernel.h>
-#include <common/common.h>
-#include <common/utils.h>
-#include <common/compat/errno.h>
-#include <common/compat/getenv.h>
-#include <common/compat/string.h>
-#include <common/unix.h>
-#include <common/defaults.h>
-#include <common/lttng-elf.h>
-#include <common/thread.h>
+#include <common/bytecode/bytecode.hpp>
+#include <common/lttng-kernel.hpp>
+#include <common/common.hpp>
+#include <common/utils.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/compat/string.hpp>
+#include <common/unix.hpp>
+#include <common/defaults.hpp>
+#include <common/lttng-elf.hpp>
+#include <common/thread.hpp>
 
 #include <lttng/constant.h>
 
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/filter/filter-ast.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/filter/filter-ast.hpp>
 
-#include "runas.h"
+#include "runas.hpp"
 
 #define GETPW_BUFFER_FALLBACK_SIZE 4096
 
diff --git a/src/common/runas.h b/src/common/runas.h
deleted file mode 100644 (file)
index 99c541f..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef _RUNAS_H
-#define _RUNAS_H
-
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <stdint.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <common/macros.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-
-/*
- * The run-as process is launched by forking without an exec*() call. This means
- * that any resource allocated before the run-as worker is launched should be
- * cleaned-up after the fork(). This callback allows the user to perform this
- * clean-up.
- *
- * Note that the callback will _not_ be invoked if the LTTNG_DEBUG_NOCLONE
- * environment variable is set as the clean-up is not needed (and may not be
- * expected).
- *
- * A negative return value will cause the run-as process to exit with a non-zero
- * value.
- */
-typedef int (*post_fork_cleanup_cb)(void *user_data);
-
-int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid);
-int run_as_mkdirat_recursive(int dirfd, const char *path, mode_t mode,
-               uid_t uid, gid_t gid);
-int run_as_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid);
-int run_as_mkdirat(int dirfd, const char *path, mode_t mode,
-               uid_t uid, gid_t gid);
-int run_as_open(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid);
-int run_as_openat(int dirfd, const char *filename, int flags, mode_t mode,
-               uid_t uid, gid_t gid);
-int run_as_unlink(const char *path, uid_t uid, gid_t gid);
-int run_as_unlinkat(int dirfd, const char *filename, uid_t uid, gid_t gid);
-int run_as_rmdir(const char *path, uid_t uid, gid_t gid);
-int run_as_rmdir_recursive(const char *path, uid_t uid, gid_t gid, int flags);
-int run_as_rmdirat(int dirfd, const char *path, uid_t uid, gid_t gid);
-int run_as_rmdirat_recursive(int dirfd, const char *path, uid_t uid, gid_t gid, int flags);
-int run_as_rename(const char *old_name, const char *new_name, uid_t uid, gid_t gid);
-int run_as_renameat(int old_dirfd, const char *old_name,
-               int new_dirfd, const char *new_name, uid_t uid, gid_t gid);
-int run_as_extract_elf_symbol_offset(int fd, const char* function,
-               uid_t uid, gid_t gid, uint64_t *offset);
-int run_as_extract_sdt_probe_offsets(int fd, const char *provider_name,
-               const char* probe_name, uid_t uid, gid_t gid,
-               uint64_t **offsets, uint32_t *num_offset);
-int run_as_generate_filter_bytecode(const char *filter_expression,
-               const struct lttng_credentials *creds,
-               struct lttng_bytecode **bytecode);
-int run_as_create_worker(const char *procname,
-               post_fork_cleanup_cb clean_up_func, void *clean_up_user_data);
-void run_as_destroy_worker(void);
-
-#endif /* _RUNAS_H */
diff --git a/src/common/runas.hpp b/src/common/runas.hpp
new file mode 100644 (file)
index 0000000..1732286
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef _RUNAS_H
+#define _RUNAS_H
+
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <common/macros.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+/*
+ * The run-as process is launched by forking without an exec*() call. This means
+ * that any resource allocated before the run-as worker is launched should be
+ * cleaned-up after the fork(). This callback allows the user to perform this
+ * clean-up.
+ *
+ * Note that the callback will _not_ be invoked if the LTTNG_DEBUG_NOCLONE
+ * environment variable is set as the clean-up is not needed (and may not be
+ * expected).
+ *
+ * A negative return value will cause the run-as process to exit with a non-zero
+ * value.
+ */
+typedef int (*post_fork_cleanup_cb)(void *user_data);
+
+int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid);
+int run_as_mkdirat_recursive(int dirfd, const char *path, mode_t mode,
+               uid_t uid, gid_t gid);
+int run_as_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid);
+int run_as_mkdirat(int dirfd, const char *path, mode_t mode,
+               uid_t uid, gid_t gid);
+int run_as_open(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid);
+int run_as_openat(int dirfd, const char *filename, int flags, mode_t mode,
+               uid_t uid, gid_t gid);
+int run_as_unlink(const char *path, uid_t uid, gid_t gid);
+int run_as_unlinkat(int dirfd, const char *filename, uid_t uid, gid_t gid);
+int run_as_rmdir(const char *path, uid_t uid, gid_t gid);
+int run_as_rmdir_recursive(const char *path, uid_t uid, gid_t gid, int flags);
+int run_as_rmdirat(int dirfd, const char *path, uid_t uid, gid_t gid);
+int run_as_rmdirat_recursive(int dirfd, const char *path, uid_t uid, gid_t gid, int flags);
+int run_as_rename(const char *old_name, const char *new_name, uid_t uid, gid_t gid);
+int run_as_renameat(int old_dirfd, const char *old_name,
+               int new_dirfd, const char *new_name, uid_t uid, gid_t gid);
+int run_as_extract_elf_symbol_offset(int fd, const char* function,
+               uid_t uid, gid_t gid, uint64_t *offset);
+int run_as_extract_sdt_probe_offsets(int fd, const char *provider_name,
+               const char* probe_name, uid_t uid, gid_t gid,
+               uint64_t **offsets, uint32_t *num_offset);
+int run_as_generate_filter_bytecode(const char *filter_expression,
+               const struct lttng_credentials *creds,
+               struct lttng_bytecode **bytecode);
+int run_as_create_worker(const char *procname,
+               post_fork_cleanup_cb clean_up_func, void *clean_up_user_data);
+void run_as_destroy_worker(void);
+
+#endif /* _RUNAS_H */
index e8a602121351b6034aa8846bf877be6945f76655..9867de83e73a0f8db63d3d4cb4b060f6b830f21a 100644 (file)
@@ -4,11 +4,11 @@
  * SPDX-License-Identifier: LGPL-2.1-only
  */
 
-#include <lttng/session-descriptor-internal.h>
-#include <common/macros.h>
-#include <common/uri.h>
-#include <common/defaults.h>
-#include <common/error.h>
+#include <lttng/session-descriptor-internal.hpp>
+#include <common/macros.hpp>
+#include <common/uri.hpp>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
 #include <time.h>
 #include <stdio.h>
 
diff --git a/src/common/sessiond-comm/agent.h b/src/common/sessiond-comm/agent.h
deleted file mode 100644 (file)
index 92ac068..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef AGENT_COMM
-#define AGENT_COMM
-
-#include <stdint.h>
-
-#include <common/macros.h>
-#include <lttng/lttng.h>
-
-/*
- * Command value passed in the header.
- */
-enum lttcomm_agent_command {
-       AGENT_CMD_LIST                  = 1,
-       AGENT_CMD_ENABLE                = 2,
-       AGENT_CMD_DISABLE               = 3,
-       AGENT_CMD_REG_DONE              = 4,    /* End registration process. */
-       AGENT_CMD_APP_CTX_ENABLE        = 5,
-       AGENT_CMD_APP_CTX_DISABLE       = 6,
-};
-
-/*
- * Return codes from the agent.
- */
-enum lttcomm_agent_ret_code {
-       /* Success, assumed to be the first entry */
-       AGENT_RET_CODE_SUCCESS          = 1,
-       /* Invalid command */
-       AGENT_RET_CODE_INVALID          = 2,
-       /* Unknown logger name */
-       AGENT_RET_CODE_UNKNOWN_NAME     = 3,
-       AGENT_RET_CODE_NR,
-};
-
-/*
- * Agent application communication header.
- */
-struct lttcomm_agent_hdr {
-       uint64_t data_size;             /* data size following this header */
-       uint32_t cmd;                   /* Enum of agent command. */
-       uint32_t cmd_version;   /* command version */
-} LTTNG_PACKED;
-
-/*
- * Enable event command payload. Will be immediately followed by the
- * variable-length string representing the filter expression.
- */
-struct lttcomm_agent_enable_event {
-       uint32_t loglevel_value;
-       uint32_t loglevel_type;
-       char name[LTTNG_SYMBOL_NAME_LEN];
-       uint32_t filter_expression_length;
-} LTTNG_PACKED;
-
-/*
- * Disable event command payload.
- */
-struct lttcomm_agent_disable_event {
-       char name[LTTNG_SYMBOL_NAME_LEN];
-} LTTNG_PACKED;
-
-/*
- * Generic reply coming from the agent.
- */
-struct lttcomm_agent_generic_reply {
-       uint32_t ret_code;
-} LTTNG_PACKED;
-
-/*
- * List command reply header.
- */
-struct lttcomm_agent_list_reply_hdr {
-       uint32_t ret_code;
-       uint32_t data_size;
-} LTTNG_PACKED;
-
-/*
- * List command reply payload coming from the agent.
- */
-struct lttcomm_agent_list_reply {
-       uint32_t nb_event;
-       /* List of event name each of them ending by a NULL byte. */
-       char payload[];
-} LTTNG_PACKED;
-
-#endif /* AGENT_COMM */
diff --git a/src/common/sessiond-comm/agent.hpp b/src/common/sessiond-comm/agent.hpp
new file mode 100644 (file)
index 0000000..9fcb1f3
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef AGENT_COMM
+#define AGENT_COMM
+
+#include <stdint.h>
+
+#include <common/macros.hpp>
+#include <lttng/lttng.h>
+
+/*
+ * Command value passed in the header.
+ */
+enum lttcomm_agent_command {
+       AGENT_CMD_LIST                  = 1,
+       AGENT_CMD_ENABLE                = 2,
+       AGENT_CMD_DISABLE               = 3,
+       AGENT_CMD_REG_DONE              = 4,    /* End registration process. */
+       AGENT_CMD_APP_CTX_ENABLE        = 5,
+       AGENT_CMD_APP_CTX_DISABLE       = 6,
+};
+
+/*
+ * Return codes from the agent.
+ */
+enum lttcomm_agent_ret_code {
+       /* Success, assumed to be the first entry */
+       AGENT_RET_CODE_SUCCESS          = 1,
+       /* Invalid command */
+       AGENT_RET_CODE_INVALID          = 2,
+       /* Unknown logger name */
+       AGENT_RET_CODE_UNKNOWN_NAME     = 3,
+       AGENT_RET_CODE_NR,
+};
+
+/*
+ * Agent application communication header.
+ */
+struct lttcomm_agent_hdr {
+       uint64_t data_size;             /* data size following this header */
+       uint32_t cmd;                   /* Enum of agent command. */
+       uint32_t cmd_version;   /* command version */
+} LTTNG_PACKED;
+
+/*
+ * Enable event command payload. Will be immediately followed by the
+ * variable-length string representing the filter expression.
+ */
+struct lttcomm_agent_enable_event {
+       uint32_t loglevel_value;
+       uint32_t loglevel_type;
+       char name[LTTNG_SYMBOL_NAME_LEN];
+       uint32_t filter_expression_length;
+} LTTNG_PACKED;
+
+/*
+ * Disable event command payload.
+ */
+struct lttcomm_agent_disable_event {
+       char name[LTTNG_SYMBOL_NAME_LEN];
+} LTTNG_PACKED;
+
+/*
+ * Generic reply coming from the agent.
+ */
+struct lttcomm_agent_generic_reply {
+       uint32_t ret_code;
+} LTTNG_PACKED;
+
+/*
+ * List command reply header.
+ */
+struct lttcomm_agent_list_reply_hdr {
+       uint32_t ret_code;
+       uint32_t data_size;
+} LTTNG_PACKED;
+
+/*
+ * List command reply payload coming from the agent.
+ */
+struct lttcomm_agent_list_reply {
+       uint32_t nb_event;
+       /* List of event name each of them ending by a NULL byte. */
+       char payload[];
+} LTTNG_PACKED;
+
+#endif /* AGENT_COMM */
index 20eb613a82aa2182662f65062cc6f8119871bb1d..30aa8c6134a42903f2df14cd6e0e69c103d2173a 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
 #include <poll.h>
 
-#include <common/common.h>
-#include <common/time.h>
-#include <common/compat/errno.h>
+#include <common/common.hpp>
+#include <common/time.hpp>
+#include <common/compat/errno.hpp>
 
-#include "inet.h"
+#include "inet.hpp"
 
 #define RECONNECT_DELAY        200     /* ms */
 
diff --git a/src/common/sessiond-comm/inet.h b/src/common/sessiond-comm/inet.h
deleted file mode 100644 (file)
index fd7cffe..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTCOMM_INET_H
-#define _LTTCOMM_INET_H
-
-#include <limits.h>
-
-#include "sessiond-comm.h"
-
-/* See man tcp(7) for more detail about this value. */
-#define LTTCOMM_INET_PROC_SYN_RETRIES_PATH "/proc/sys/net/ipv4/tcp_syn_retries"
-#define LTTCOMM_INET_PROC_FIN_TIMEOUT_PATH "/proc/sys/net/ipv4/tcp_fin_timeout"
-
-/*
- * The timeout value of a connect() is computed with an algorithm inside the
- * kernel using the defined TCP SYN retries so the end value in time is
- * approximative. According to tcp(7) man page, a value of 5 is roughly 180
- * seconds of timeout. With that information, we've computed a factor of 36
- * (180/5) by considering that it grows linearly. This is of course uncertain
- * but this is the best approximation we can do at runtime.
- */
-#define LTTCOMM_INET_SYN_TIMEOUT_FACTOR                36
-
-/*
- * Maximum timeout value in seconds of a TCP connection for both send/recv and
- * connect operations.
- */
-LTTNG_EXPORT extern unsigned long lttcomm_inet_tcp_timeout;
-
-/* Stub */
-struct lttcomm_sock;
-
-/* Net family callback */
-extern int lttcomm_create_inet_sock(struct lttcomm_sock *sock, int type,
-               int proto);
-
-extern struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock);
-extern int lttcomm_bind_inet_sock(struct lttcomm_sock *sock);
-extern int lttcomm_close_inet_sock(struct lttcomm_sock *sock);
-extern int lttcomm_connect_inet_sock(struct lttcomm_sock *sock);
-extern int lttcomm_listen_inet_sock(struct lttcomm_sock *sock, int backlog);
-
-extern ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf,
-               size_t len, int flags);
-extern ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock,
-               const void *buf, size_t len, int flags);
-
-/* Initialize inet communication layer. */
-extern void lttcomm_inet_init(void);
-
-#endif /* _LTTCOMM_INET_H */
diff --git a/src/common/sessiond-comm/inet.hpp b/src/common/sessiond-comm/inet.hpp
new file mode 100644 (file)
index 0000000..dca1cc1
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTCOMM_INET_H
+#define _LTTCOMM_INET_H
+
+#include <limits.h>
+
+#include "sessiond-comm.hpp"
+
+/* See man tcp(7) for more detail about this value. */
+#define LTTCOMM_INET_PROC_SYN_RETRIES_PATH "/proc/sys/net/ipv4/tcp_syn_retries"
+#define LTTCOMM_INET_PROC_FIN_TIMEOUT_PATH "/proc/sys/net/ipv4/tcp_fin_timeout"
+
+/*
+ * The timeout value of a connect() is computed with an algorithm inside the
+ * kernel using the defined TCP SYN retries so the end value in time is
+ * approximative. According to tcp(7) man page, a value of 5 is roughly 180
+ * seconds of timeout. With that information, we've computed a factor of 36
+ * (180/5) by considering that it grows linearly. This is of course uncertain
+ * but this is the best approximation we can do at runtime.
+ */
+#define LTTCOMM_INET_SYN_TIMEOUT_FACTOR                36
+
+/*
+ * Maximum timeout value in seconds of a TCP connection for both send/recv and
+ * connect operations.
+ */
+LTTNG_EXPORT extern unsigned long lttcomm_inet_tcp_timeout;
+
+/* Stub */
+struct lttcomm_sock;
+
+/* Net family callback */
+extern int lttcomm_create_inet_sock(struct lttcomm_sock *sock, int type,
+               int proto);
+
+extern struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock);
+extern int lttcomm_bind_inet_sock(struct lttcomm_sock *sock);
+extern int lttcomm_close_inet_sock(struct lttcomm_sock *sock);
+extern int lttcomm_connect_inet_sock(struct lttcomm_sock *sock);
+extern int lttcomm_listen_inet_sock(struct lttcomm_sock *sock, int backlog);
+
+extern ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf,
+               size_t len, int flags);
+extern ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock,
+               const void *buf, size_t len, int flags);
+
+/* Initialize inet communication layer. */
+extern void lttcomm_inet_init(void);
+
+#endif /* _LTTCOMM_INET_H */
index adabebfaeb3ec176ccabcc12a12474a8be969203..caa4d7eb3906b691d1762b6e0fd41268b0ff53ed 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
 #include <poll.h>
 
-#include <common/common.h>
-#include <common/time.h>
-#include <common/compat/errno.h>
+#include <common/common.hpp>
+#include <common/time.hpp>
+#include <common/compat/errno.hpp>
 
-#include "inet6.h"
+#include "inet6.hpp"
 
 #define RECONNECT_DELAY        200     /* ms */
 
diff --git a/src/common/sessiond-comm/inet6.h b/src/common/sessiond-comm/inet6.h
deleted file mode 100644 (file)
index b292848..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTCOMM_INET6_H
-#define _LTTCOMM_INET6_H
-
-#include <limits.h>
-
-#include "sessiond-comm.h"
-
-/* Stub */
-struct lttcomm_sock;
-
-/* Net family callback */
-extern int lttcomm_create_inet6_sock(struct lttcomm_sock *sock, int type,
-               int proto);
-
-extern struct lttcomm_sock *lttcomm_accept_inet6_sock(
-               struct lttcomm_sock *sock);
-extern int lttcomm_bind_inet6_sock(struct lttcomm_sock *sock);
-extern int lttcomm_close_inet6_sock(struct lttcomm_sock *sock);
-extern int lttcomm_connect_inet6_sock(struct lttcomm_sock *sock);
-extern int lttcomm_listen_inet6_sock(struct lttcomm_sock *sock, int backlog);
-
-extern ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
-               size_t len, int flags);
-extern ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock,
-               const void *buf, size_t len, int flags);
-
-#endif /* _LTTCOMM_INET6_H */
diff --git a/src/common/sessiond-comm/inet6.hpp b/src/common/sessiond-comm/inet6.hpp
new file mode 100644 (file)
index 0000000..d6122fd
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTCOMM_INET6_H
+#define _LTTCOMM_INET6_H
+
+#include <limits.h>
+
+#include "sessiond-comm.hpp"
+
+/* Stub */
+struct lttcomm_sock;
+
+/* Net family callback */
+extern int lttcomm_create_inet6_sock(struct lttcomm_sock *sock, int type,
+               int proto);
+
+extern struct lttcomm_sock *lttcomm_accept_inet6_sock(
+               struct lttcomm_sock *sock);
+extern int lttcomm_bind_inet6_sock(struct lttcomm_sock *sock);
+extern int lttcomm_close_inet6_sock(struct lttcomm_sock *sock);
+extern int lttcomm_connect_inet6_sock(struct lttcomm_sock *sock);
+extern int lttcomm_listen_inet6_sock(struct lttcomm_sock *sock, int backlog);
+
+extern ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
+               size_t len, int flags);
+extern ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock,
+               const void *buf, size_t len, int flags);
+
+#endif /* _LTTCOMM_INET6_H */
diff --git a/src/common/sessiond-comm/relayd.h b/src/common/sessiond-comm/relayd.h
deleted file mode 100644 (file)
index 36a9107..0000000
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2012 Julien Desfossez <julien.desfossez@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _RELAYD_COMM
-#define _RELAYD_COMM
-
-#include <limits.h>
-#include <stdint.h>
-
-#include <lttng/lttng.h>
-#include <common/defaults.h>
-#include <common/index/ctf-index.h>
-#include <common/macros.h>
-#include <common/uuid.h>
-#include <common/optional.h>
-
-#define RELAYD_VERSION_COMM_MAJOR             VERSION_MAJOR
-#define RELAYD_VERSION_COMM_MINOR             VERSION_MINOR
-
-#define RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4    64
-#define RELAYD_COMM_LTTNG_NAME_MAX_2_4 255
-#define RELAYD_COMM_LTTNG_PATH_MAX     4096
-#define RELAYD_COMM_DEFAULT_STREAM_NAME_LEN    264 /* 256 + 8 */
-
-/*
- * lttng-relayd communication header.
- */
-struct lttcomm_relayd_hdr {
-       /* Circuit ID not used for now so always ignored */
-       uint64_t circuit_id;
-       uint64_t data_size;             /* data size following this header */
-       uint32_t cmd;                   /* enum lttcomm_relayd_command */
-       uint32_t cmd_version;   /* command version */
-} LTTNG_PACKED;
-
-/*
- * lttng-relayd data header.
- */
-struct lttcomm_relayd_data_hdr {
-       /* Circuit ID not used for now so always ignored */
-       uint64_t circuit_id;
-       uint64_t stream_id;     /* Stream ID known by the relayd */
-       uint64_t net_seq_num;   /* Network sequence number, per stream. */
-       uint32_t data_size;     /* data size following this header */
-       uint32_t padding_size;  /* Size of 0 padding the data */
-} LTTNG_PACKED;
-
-/*
- * Reply from a create session command.
- */
-struct lttcomm_relayd_status_session {
-       uint64_t session_id;
-       uint32_t ret_code;
-} LTTNG_PACKED;
-
-/*
- * Used to add a stream on the relay daemon.
- */
-struct lttcomm_relayd_add_stream {
-       char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN];
-       char pathname[RELAYD_COMM_LTTNG_PATH_MAX];
-} LTTNG_PACKED;
-
-/*
- * Used to add a stream on the relay daemon.
- * Protocol version 2.2
- */
-struct lttcomm_relayd_add_stream_2_2 {
-       char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN];
-       char pathname[RELAYD_COMM_LTTNG_PATH_MAX];
-       uint64_t tracefile_size;
-       uint64_t tracefile_count;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_add_stream_2_11 {
-       uint32_t channel_name_len;
-       uint32_t pathname_len;
-       uint64_t tracefile_size;
-       uint64_t tracefile_count;
-       uint64_t trace_chunk_id;
-       char names[];
-} LTTNG_PACKED;
-
-/*
- * Answer from an add stream command.
- */
-struct lttcomm_relayd_status_stream {
-       uint64_t handle;
-       uint32_t ret_code;
-} LTTNG_PACKED;
-
-/*
- * Used to return command code for command not needing special data.
- */
-struct lttcomm_relayd_generic_reply {
-       uint32_t ret_code;
-} LTTNG_PACKED;
-
-/*
- * Version command.
- */
-struct lttcomm_relayd_version {
-       uint32_t major;
-       uint32_t minor;
-} LTTNG_PACKED;
-
-/*
- * Metadata payload used when metadata command is sent.
- */
-struct lttcomm_relayd_metadata_payload {
-       uint64_t stream_id;
-       uint32_t padding_size;
-       char payload[];
-} LTTNG_PACKED;
-
-/*
- * Used to indicate that a specific stream id can now be closed.
- */
-struct lttcomm_relayd_close_stream {
-       uint64_t stream_id;
-       uint64_t last_net_seq_num;      /* sequence number of last packet */
-} LTTNG_PACKED;
-
-/*
- * Used to test if for a given stream id the data is pending on the relayd side
- * for reading.
- */
-struct lttcomm_relayd_data_pending {
-       uint64_t stream_id;
-       uint64_t last_net_seq_num; /* Sequence number of the last packet */
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_begin_data_pending {
-       uint64_t session_id;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_end_data_pending {
-       uint64_t session_id;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_quiescent_control {
-       uint64_t stream_id;
-} LTTNG_PACKED;
-
-/*
- * Index data.
- */
-struct lttcomm_relayd_index {
-       uint64_t relay_stream_id;
-       uint64_t net_seq_num;
-       uint64_t packet_size;
-       uint64_t content_size;
-       uint64_t timestamp_begin;
-       uint64_t timestamp_end;
-       uint64_t events_discarded;
-       uint64_t stream_id;
-       /* 2.8+ */
-       uint64_t stream_instance_id;
-       uint64_t packet_seq_num;
-} LTTNG_PACKED;
-
-static inline size_t lttcomm_relayd_index_len(uint32_t major, uint32_t minor)
-{
-       if (major == 1) {
-               switch (minor) {
-               case 0:
-                       return offsetof(struct lttcomm_relayd_index, stream_id)
-                               + member_sizeof(struct lttcomm_relayd_index,
-                                               stream_id);
-               case 1:
-                       return offsetof(struct lttcomm_relayd_index, packet_seq_num)
-                               + member_sizeof(struct lttcomm_relayd_index,
-                                               packet_seq_num);
-               default:
-                       abort();
-               }
-       }
-       abort();
-}
-
-/*
- * Create session in 2.4 adds additionnal parameters for live reading.
- */
-struct lttcomm_relayd_create_session_2_4 {
-       char session_name[RELAYD_COMM_LTTNG_NAME_MAX_2_4];
-       char hostname[RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4];
-       uint32_t live_timer;
-       uint32_t snapshot;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_create_session_2_11 {
-       uint32_t session_name_len;
-       uint32_t hostname_len;
-       /* Optional, set to 0 to indicate it is not user-specified. */
-       uint32_t base_path_len;
-       uint32_t live_timer;
-       uint8_t snapshot;
-       uint8_t session_name_contains_creation_time;
-       /* Sessiond instance UUID */
-       lttng_uuid sessiond_uuid;
-       /* Sessiond session id */
-       uint64_t session_id;
-       /* Session creation time, in seconds since UNIX Epoch. */
-       uint64_t creation_time;
-       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED current_chunk_id;
-       /* Contains the session_name, hostname, base_path. */
-       char names[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_create_session_reply_2_11 {
-       struct lttcomm_relayd_status_session generic;
-       /* Includes the '\0' terminator. */
-       uint32_t output_path_length;
-       char output_path[];
-} LTTNG_PACKED;
-
-/*
- * Used to ask the relay to reset the metadata trace file (regeneration).
- * Send the new version of the metadata (starts at 0).
- */
-struct lttcomm_relayd_reset_metadata {
-       uint64_t stream_id;
-       uint64_t version;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_stream_rotation_position {
-       uint64_t stream_id;
-       /*
-        * Sequence number of the first packet belonging to the new
-        * "destination" trace chunk to which the stream is rotating.
-        *
-        * Ignored for metadata streams.
-        */
-       uint64_t rotate_at_seq_num;
-} LTTNG_PACKED;
-
-/*
- * For certain releases, the LTTNG_PACKED annotation was missing on the
- * `new_chunk_id` field which causes padding to be added between the
- * "optional" structure's `is_set` and `value` fields.
- *
- * Three alignment cases are handled:
- *   - `value` is aligned to the next byte boundary after `is_set`
- *     no padding is produced, see
- *     `struct lttcomm_relayd_rotate_streams_packed`,
- *   - `value` is aligned to the next 4-byte boundary after `is_set`
- *     (e.g. x86), 3 bytes of padding are produced, see
- *     `struct lttcomm_relayd_rotate_streams_3_bytes_padding`,
- *   - `value` is aligned to the next 8-byte boundary after `is_set`
- *     (e.g. x86-64), 7 bytes of padding are produced, see
- *     `struct lttcomm_relayd_rotate_streams_7_bytes_padding`.
- *
- * Note that since this structure's advertised size is used to determine
- * the size of the padding it includes, it can't be extended with new
- * optional fields. A new command would be needed.
- */
-struct lttcomm_relayd_rotate_streams {
-       uint32_t stream_count;
-       /*
-        * Streams can be rotated outside of a chunk but not be parented to
-        * a new chunk.
-        *
-        * Improperly packed, but left as-is for backwards compatibility
-        * with unpatched relay daemons.
-        */
-       LTTNG_OPTIONAL_COMM(uint64_t) new_chunk_id;
-       /* `stream_count` positions follow. */
-       struct lttcomm_relayd_stream_rotation_position rotation_positions[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_rotate_streams_packed {
-       uint32_t stream_count;
-       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED new_chunk_id;
-       struct lttcomm_relayd_stream_rotation_position rotation_positions[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_rotate_streams_3_bytes_padding {
-       uint32_t stream_count;
-       struct {
-               union {
-                       uint8_t is_set;
-                       uint32_t padding;
-               };
-               uint64_t value;
-       } LTTNG_PACKED new_chunk_id;
-       struct lttcomm_relayd_stream_rotation_position rotation_positions[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_rotate_streams_7_bytes_padding {
-       uint32_t stream_count;
-       struct {
-               union {
-                       uint8_t is_set;
-                       uint64_t padding;
-               };
-               uint64_t value;
-       } LTTNG_PACKED new_chunk_id;
-       struct lttcomm_relayd_stream_rotation_position rotation_positions[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_create_trace_chunk {
-       uint64_t chunk_id;
-       /* Seconds since EPOCH. */
-       uint64_t creation_timestamp;
-       /* Includes trailing NULL. */
-       uint32_t override_name_length;
-       char override_name[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_close_trace_chunk {
-       uint64_t chunk_id;
-       /* Seconds since EPOCH. */
-       uint64_t close_timestamp;
-       /* enum lttng_trace_chunk_command_type */
-       LTTNG_OPTIONAL_COMM(uint32_t) LTTNG_PACKED close_command;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_close_trace_chunk_reply {
-       struct lttcomm_relayd_generic_reply generic;
-       /* Includes trailing NULL. */
-       uint32_t path_length;
-       char path[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_trace_chunk_exists {
-       uint64_t chunk_id;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_trace_chunk_exists_reply {
-       struct lttcomm_relayd_generic_reply generic;
-       uint8_t trace_chunk_exists;
-} LTTNG_PACKED;
-
-enum lttcomm_relayd_configuration_flag {
-       /* The relay daemon (2.12) is configured to allow clear operations. */
-       LTTCOMM_RELAYD_CONFIGURATION_FLAG_CLEAR_ALLOWED = (1 << 0),
-};
-
-struct lttcomm_relayd_get_configuration {
-       uint64_t query_flags;
-} LTTNG_PACKED;
-
-/*
- * Used to return a relay daemon's configuration in reply to the
- * RELAYD_GET_CONFIGURATION command.
- */
-struct lttcomm_relayd_get_configuration_reply {
-       struct lttcomm_relayd_generic_reply generic;
-       /* Set of lttcomm_relayd_configuration_flag. */
-       uint64_t relayd_configuration_flags;
-       /* Optional variable-length payload. */
-       char payload[];
-} LTTNG_PACKED;
-
-#endif /* _RELAYD_COMM */
diff --git a/src/common/sessiond-comm/relayd.hpp b/src/common/sessiond-comm/relayd.hpp
new file mode 100644 (file)
index 0000000..febbe4e
--- /dev/null
@@ -0,0 +1,360 @@
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2012 Julien Desfossez <julien.desfossez@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _RELAYD_COMM
+#define _RELAYD_COMM
+
+#include <limits.h>
+#include <stdint.h>
+
+#include <lttng/lttng.h>
+#include <common/defaults.hpp>
+#include <common/index/ctf-index.hpp>
+#include <common/macros.hpp>
+#include <common/uuid.hpp>
+#include <common/optional.hpp>
+
+#define RELAYD_VERSION_COMM_MAJOR             VERSION_MAJOR
+#define RELAYD_VERSION_COMM_MINOR             VERSION_MINOR
+
+#define RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4    64
+#define RELAYD_COMM_LTTNG_NAME_MAX_2_4 255
+#define RELAYD_COMM_LTTNG_PATH_MAX     4096
+#define RELAYD_COMM_DEFAULT_STREAM_NAME_LEN    264 /* 256 + 8 */
+
+/*
+ * lttng-relayd communication header.
+ */
+struct lttcomm_relayd_hdr {
+       /* Circuit ID not used for now so always ignored */
+       uint64_t circuit_id;
+       uint64_t data_size;             /* data size following this header */
+       uint32_t cmd;                   /* enum lttcomm_relayd_command */
+       uint32_t cmd_version;   /* command version */
+} LTTNG_PACKED;
+
+/*
+ * lttng-relayd data header.
+ */
+struct lttcomm_relayd_data_hdr {
+       /* Circuit ID not used for now so always ignored */
+       uint64_t circuit_id;
+       uint64_t stream_id;     /* Stream ID known by the relayd */
+       uint64_t net_seq_num;   /* Network sequence number, per stream. */
+       uint32_t data_size;     /* data size following this header */
+       uint32_t padding_size;  /* Size of 0 padding the data */
+} LTTNG_PACKED;
+
+/*
+ * Reply from a create session command.
+ */
+struct lttcomm_relayd_status_session {
+       uint64_t session_id;
+       uint32_t ret_code;
+} LTTNG_PACKED;
+
+/*
+ * Used to add a stream on the relay daemon.
+ */
+struct lttcomm_relayd_add_stream {
+       char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN];
+       char pathname[RELAYD_COMM_LTTNG_PATH_MAX];
+} LTTNG_PACKED;
+
+/*
+ * Used to add a stream on the relay daemon.
+ * Protocol version 2.2
+ */
+struct lttcomm_relayd_add_stream_2_2 {
+       char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN];
+       char pathname[RELAYD_COMM_LTTNG_PATH_MAX];
+       uint64_t tracefile_size;
+       uint64_t tracefile_count;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_add_stream_2_11 {
+       uint32_t channel_name_len;
+       uint32_t pathname_len;
+       uint64_t tracefile_size;
+       uint64_t tracefile_count;
+       uint64_t trace_chunk_id;
+       char names[];
+} LTTNG_PACKED;
+
+/*
+ * Answer from an add stream command.
+ */
+struct lttcomm_relayd_status_stream {
+       uint64_t handle;
+       uint32_t ret_code;
+} LTTNG_PACKED;
+
+/*
+ * Used to return command code for command not needing special data.
+ */
+struct lttcomm_relayd_generic_reply {
+       uint32_t ret_code;
+} LTTNG_PACKED;
+
+/*
+ * Version command.
+ */
+struct lttcomm_relayd_version {
+       uint32_t major;
+       uint32_t minor;
+} LTTNG_PACKED;
+
+/*
+ * Metadata payload used when metadata command is sent.
+ */
+struct lttcomm_relayd_metadata_payload {
+       uint64_t stream_id;
+       uint32_t padding_size;
+       char payload[];
+} LTTNG_PACKED;
+
+/*
+ * Used to indicate that a specific stream id can now be closed.
+ */
+struct lttcomm_relayd_close_stream {
+       uint64_t stream_id;
+       uint64_t last_net_seq_num;      /* sequence number of last packet */
+} LTTNG_PACKED;
+
+/*
+ * Used to test if for a given stream id the data is pending on the relayd side
+ * for reading.
+ */
+struct lttcomm_relayd_data_pending {
+       uint64_t stream_id;
+       uint64_t last_net_seq_num; /* Sequence number of the last packet */
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_begin_data_pending {
+       uint64_t session_id;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_end_data_pending {
+       uint64_t session_id;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_quiescent_control {
+       uint64_t stream_id;
+} LTTNG_PACKED;
+
+/*
+ * Index data.
+ */
+struct lttcomm_relayd_index {
+       uint64_t relay_stream_id;
+       uint64_t net_seq_num;
+       uint64_t packet_size;
+       uint64_t content_size;
+       uint64_t timestamp_begin;
+       uint64_t timestamp_end;
+       uint64_t events_discarded;
+       uint64_t stream_id;
+       /* 2.8+ */
+       uint64_t stream_instance_id;
+       uint64_t packet_seq_num;
+} LTTNG_PACKED;
+
+static inline size_t lttcomm_relayd_index_len(uint32_t major, uint32_t minor)
+{
+       if (major == 1) {
+               switch (minor) {
+               case 0:
+                       return offsetof(struct lttcomm_relayd_index, stream_id)
+                               + member_sizeof(struct lttcomm_relayd_index,
+                                               stream_id);
+               case 1:
+                       return offsetof(struct lttcomm_relayd_index, packet_seq_num)
+                               + member_sizeof(struct lttcomm_relayd_index,
+                                               packet_seq_num);
+               default:
+                       abort();
+               }
+       }
+       abort();
+}
+
+/*
+ * Create session in 2.4 adds additionnal parameters for live reading.
+ */
+struct lttcomm_relayd_create_session_2_4 {
+       char session_name[RELAYD_COMM_LTTNG_NAME_MAX_2_4];
+       char hostname[RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4];
+       uint32_t live_timer;
+       uint32_t snapshot;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_create_session_2_11 {
+       uint32_t session_name_len;
+       uint32_t hostname_len;
+       /* Optional, set to 0 to indicate it is not user-specified. */
+       uint32_t base_path_len;
+       uint32_t live_timer;
+       uint8_t snapshot;
+       uint8_t session_name_contains_creation_time;
+       /* Sessiond instance UUID */
+       lttng_uuid sessiond_uuid;
+       /* Sessiond session id */
+       uint64_t session_id;
+       /* Session creation time, in seconds since UNIX Epoch. */
+       uint64_t creation_time;
+       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED current_chunk_id;
+       /* Contains the session_name, hostname, base_path. */
+       char names[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_create_session_reply_2_11 {
+       struct lttcomm_relayd_status_session generic;
+       /* Includes the '\0' terminator. */
+       uint32_t output_path_length;
+       char output_path[];
+} LTTNG_PACKED;
+
+/*
+ * Used to ask the relay to reset the metadata trace file (regeneration).
+ * Send the new version of the metadata (starts at 0).
+ */
+struct lttcomm_relayd_reset_metadata {
+       uint64_t stream_id;
+       uint64_t version;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_stream_rotation_position {
+       uint64_t stream_id;
+       /*
+        * Sequence number of the first packet belonging to the new
+        * "destination" trace chunk to which the stream is rotating.
+        *
+        * Ignored for metadata streams.
+        */
+       uint64_t rotate_at_seq_num;
+} LTTNG_PACKED;
+
+/*
+ * For certain releases, the LTTNG_PACKED annotation was missing on the
+ * `new_chunk_id` field which causes padding to be added between the
+ * "optional" structure's `is_set` and `value` fields.
+ *
+ * Three alignment cases are handled:
+ *   - `value` is aligned to the next byte boundary after `is_set`
+ *     no padding is produced, see
+ *     `struct lttcomm_relayd_rotate_streams_packed`,
+ *   - `value` is aligned to the next 4-byte boundary after `is_set`
+ *     (e.g. x86), 3 bytes of padding are produced, see
+ *     `struct lttcomm_relayd_rotate_streams_3_bytes_padding`,
+ *   - `value` is aligned to the next 8-byte boundary after `is_set`
+ *     (e.g. x86-64), 7 bytes of padding are produced, see
+ *     `struct lttcomm_relayd_rotate_streams_7_bytes_padding`.
+ *
+ * Note that since this structure's advertised size is used to determine
+ * the size of the padding it includes, it can't be extended with new
+ * optional fields. A new command would be needed.
+ */
+struct lttcomm_relayd_rotate_streams {
+       uint32_t stream_count;
+       /*
+        * Streams can be rotated outside of a chunk but not be parented to
+        * a new chunk.
+        *
+        * Improperly packed, but left as-is for backwards compatibility
+        * with unpatched relay daemons.
+        */
+       LTTNG_OPTIONAL_COMM(uint64_t) new_chunk_id;
+       /* `stream_count` positions follow. */
+       struct lttcomm_relayd_stream_rotation_position rotation_positions[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_rotate_streams_packed {
+       uint32_t stream_count;
+       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED new_chunk_id;
+       struct lttcomm_relayd_stream_rotation_position rotation_positions[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_rotate_streams_3_bytes_padding {
+       uint32_t stream_count;
+       struct {
+               union {
+                       uint8_t is_set;
+                       uint32_t padding;
+               };
+               uint64_t value;
+       } LTTNG_PACKED new_chunk_id;
+       struct lttcomm_relayd_stream_rotation_position rotation_positions[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_rotate_streams_7_bytes_padding {
+       uint32_t stream_count;
+       struct {
+               union {
+                       uint8_t is_set;
+                       uint64_t padding;
+               };
+               uint64_t value;
+       } LTTNG_PACKED new_chunk_id;
+       struct lttcomm_relayd_stream_rotation_position rotation_positions[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_create_trace_chunk {
+       uint64_t chunk_id;
+       /* Seconds since EPOCH. */
+       uint64_t creation_timestamp;
+       /* Includes trailing NULL. */
+       uint32_t override_name_length;
+       char override_name[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_close_trace_chunk {
+       uint64_t chunk_id;
+       /* Seconds since EPOCH. */
+       uint64_t close_timestamp;
+       /* enum lttng_trace_chunk_command_type */
+       LTTNG_OPTIONAL_COMM(uint32_t) LTTNG_PACKED close_command;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_close_trace_chunk_reply {
+       struct lttcomm_relayd_generic_reply generic;
+       /* Includes trailing NULL. */
+       uint32_t path_length;
+       char path[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_trace_chunk_exists {
+       uint64_t chunk_id;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_trace_chunk_exists_reply {
+       struct lttcomm_relayd_generic_reply generic;
+       uint8_t trace_chunk_exists;
+} LTTNG_PACKED;
+
+enum lttcomm_relayd_configuration_flag {
+       /* The relay daemon (2.12) is configured to allow clear operations. */
+       LTTCOMM_RELAYD_CONFIGURATION_FLAG_CLEAR_ALLOWED = (1 << 0),
+};
+
+struct lttcomm_relayd_get_configuration {
+       uint64_t query_flags;
+} LTTNG_PACKED;
+
+/*
+ * Used to return a relay daemon's configuration in reply to the
+ * RELAYD_GET_CONFIGURATION command.
+ */
+struct lttcomm_relayd_get_configuration_reply {
+       struct lttcomm_relayd_generic_reply generic;
+       /* Set of lttcomm_relayd_configuration_flag. */
+       uint64_t relayd_configuration_flags;
+       /* Optional variable-length payload. */
+       char payload[];
+} LTTNG_PACKED;
+
+#endif /* _RELAYD_COMM */
index 9be0cbcac8d07be1ee25f2a5dd7882243fdedc1e..7b20007a8ea2ef0068a57cdd6c348043ad0a907c 100644 (file)
 #include <unistd.h>
 #include <inttypes.h>
 
-#include <common/common.h>
-#include <common/compat/errno.h>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
 
-#include "sessiond-comm.h"
+#include "sessiond-comm.hpp"
 
 /* For Unix socket */
-#include <common/unix.h>
+#include <common/unix.hpp>
 /* For Inet socket */
-#include "inet.h"
+#include "inet.hpp"
 /* For Inet6 socket */
-#include "inet6.h"
+#include "inet6.hpp"
 
 #define NETWORK_TIMEOUT_ENV    "LTTNG_NETWORK_SOCKET_TIMEOUT"
 
diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h
deleted file mode 100644 (file)
index e327e01..0000000
+++ /dev/null
@@ -1,958 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-/*
- * This header is meant for liblttng and libust internal use ONLY. These
- * declarations should NOT be considered stable API.
- */
-
-#ifndef _LTTNG_SESSIOND_COMM_H
-#define _LTTNG_SESSIOND_COMM_H
-
-#include <limits.h>
-#include <lttng/lttng.h>
-#include <lttng/snapshot-internal.h>
-#include <lttng/save-internal.h>
-#include <lttng/channel-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/rotate-internal.h>
-#include <common/compat/socket.h>
-#include <common/uri.h>
-#include <common/defaults.h>
-#include <common/uuid.h>
-#include <common/macros.h>
-#include <common/optional.h>
-
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <stdint.h>
-#include <sys/un.h>
-
-#include "inet.h"
-#include "inet6.h"
-#include <common/unix.h>
-
-/* Queue size of listen(2) */
-#define LTTNG_SESSIOND_COMM_MAX_LISTEN 64
-
-/* Maximum number of FDs that can be sent over a Unix socket */
-#if defined(__linux__)
-/* Based on the kernel's SCM_MAX_FD which is 253 since 2.6.38 (255 before) */
-#define LTTCOMM_MAX_SEND_FDS           253
-#else
-#define LTTCOMM_MAX_SEND_FDS           16
-#endif
-
-enum lttcomm_sessiond_command {
-       /* Tracer command */
-       LTTNG_ADD_CONTEXT                               = 0,
-       /* LTTNG_CALIBRATE used to be here */
-       LTTNG_DISABLE_CHANNEL                           = 2,
-       LTTNG_DISABLE_EVENT                             = 3,
-       LTTNG_LIST_SYSCALLS                             = 4,
-       LTTNG_ENABLE_CHANNEL                            = 5,
-       LTTNG_ENABLE_EVENT                              = 6,
-       /* 7 */
-       /* Session daemon command */
-       /* 8 */
-       LTTNG_DESTROY_SESSION                           = 9,
-       LTTNG_LIST_CHANNELS                             = 10,
-       LTTNG_LIST_DOMAINS                              = 11,
-       LTTNG_LIST_EVENTS                               = 12,
-       LTTNG_LIST_SESSIONS                             = 13,
-       LTTNG_LIST_TRACEPOINTS                          = 14,
-       LTTNG_REGISTER_CONSUMER                         = 15,
-       LTTNG_START_TRACE                               = 16,
-       LTTNG_STOP_TRACE                                = 17,
-       LTTNG_LIST_TRACEPOINT_FIELDS                    = 18,
-
-       /* Consumer */
-       LTTNG_DISABLE_CONSUMER                          = 19,
-       LTTNG_ENABLE_CONSUMER                           = 20,
-       LTTNG_SET_CONSUMER_URI                          = 21,
-       /* 22 */
-       /* 23 */
-       LTTNG_DATA_PENDING                              = 24,
-       LTTNG_SNAPSHOT_ADD_OUTPUT                       = 25,
-       LTTNG_SNAPSHOT_DEL_OUTPUT                       = 26,
-       LTTNG_SNAPSHOT_LIST_OUTPUT                      = 27,
-       LTTNG_SNAPSHOT_RECORD                           = 28,
-       /* 29 */
-       /* 30 */
-       LTTNG_SAVE_SESSION                              = 31,
-       LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE    = 32,
-       LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE = 33,
-       LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY           = 34,
-       LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY           = 35,
-       LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET     = 36,
-       LTTNG_SET_SESSION_SHM_PATH                      = 40,
-       LTTNG_REGENERATE_METADATA                       = 41,
-       LTTNG_REGENERATE_STATEDUMP                      = 42,
-       LTTNG_REGISTER_TRIGGER                          = 43,
-       LTTNG_UNREGISTER_TRIGGER                        = 44,
-       LTTNG_ROTATE_SESSION                            = 45,
-       LTTNG_ROTATION_GET_INFO                         = 46,
-       LTTNG_ROTATION_SET_SCHEDULE                     = 47,
-       LTTNG_SESSION_LIST_ROTATION_SCHEDULES           = 48,
-       LTTNG_CREATE_SESSION_EXT                        = 49,
-       LTTNG_CLEAR_SESSION                             = 50,
-       LTTNG_LIST_TRIGGERS                             = 51,
-       LTTNG_EXECUTE_ERROR_QUERY                       = 52,
-};
-
-static inline
-const char *lttcomm_sessiond_command_str(enum lttcomm_sessiond_command cmd)
-{
-       switch (cmd) {
-       case LTTNG_ADD_CONTEXT:
-               return "LTTNG_ADD_CONTEXT";
-       case LTTNG_DISABLE_CHANNEL:
-               return "LTTNG_DISABLE_CHANNEL";
-       case LTTNG_DISABLE_EVENT:
-               return "LTTNG_DISABLE_EVENT";
-       case LTTNG_LIST_SYSCALLS:
-               return "LTTNG_LIST_SYSCALLS";
-       case LTTNG_ENABLE_CHANNEL:
-               return "LTTNG_ENABLE_CHANNEL";
-       case LTTNG_ENABLE_EVENT:
-               return "LTTNG_ENABLE_EVENT";
-       case LTTNG_DESTROY_SESSION:
-               return "LTTNG_DESTROY_SESSION";
-       case LTTNG_LIST_CHANNELS:
-               return "LTTNG_LIST_CHANNELS";
-       case LTTNG_LIST_DOMAINS:
-               return "LTTNG_LIST_DOMAINS";
-       case LTTNG_LIST_EVENTS:
-               return "LTTNG_LIST_EVENTS";
-       case LTTNG_LIST_SESSIONS:
-               return "LTTNG_LIST_SESSIONS";
-       case LTTNG_LIST_TRACEPOINTS:
-               return "LTTNG_LIST_TRACEPOINTS";
-       case LTTNG_REGISTER_CONSUMER:
-               return "LTTNG_REGISTER_CONSUMER";
-       case LTTNG_START_TRACE:
-               return "LTTNG_START_TRACE";
-       case LTTNG_STOP_TRACE:
-               return "LTTNG_STOP_TRACE";
-       case LTTNG_LIST_TRACEPOINT_FIELDS:
-               return "LTTNG_LIST_TRACEPOINT_FIELDS";
-       case LTTNG_DISABLE_CONSUMER:
-               return "LTTNG_DISABLE_CONSUMER";
-       case LTTNG_ENABLE_CONSUMER:
-               return "LTTNG_ENABLE_CONSUMER";
-       case LTTNG_SET_CONSUMER_URI:
-               return "LTTNG_SET_CONSUMER_URI";
-       case LTTNG_DATA_PENDING:
-               return "LTTNG_DATA_PENDING";
-       case LTTNG_SNAPSHOT_ADD_OUTPUT:
-               return "LTTNG_SNAPSHOT_ADD_OUTPUT";
-       case LTTNG_SNAPSHOT_DEL_OUTPUT:
-               return "LTTNG_SNAPSHOT_DEL_OUTPUT";
-       case LTTNG_SNAPSHOT_LIST_OUTPUT:
-               return "LTTNG_SNAPSHOT_LIST_OUTPUT";
-       case LTTNG_SNAPSHOT_RECORD:
-               return "LTTNG_SNAPSHOT_RECORD";
-       case LTTNG_SAVE_SESSION:
-               return "LTTNG_SAVE_SESSION";
-       case LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE:
-               return "LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE";
-       case LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE:
-               return "LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE";
-       case LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY:
-               return "LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY";
-       case LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY:
-               return "LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY";
-       case LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET:
-               return "LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET";
-       case LTTNG_SET_SESSION_SHM_PATH:
-               return "LTTNG_SET_SESSION_SHM_PATH";
-       case LTTNG_REGENERATE_METADATA:
-               return "LTTNG_REGENERATE_METADATA";
-       case LTTNG_REGENERATE_STATEDUMP:
-               return "LTTNG_REGENERATE_STATEDUMP";
-       case LTTNG_REGISTER_TRIGGER:
-               return "LTTNG_REGISTER_TRIGGER";
-       case LTTNG_UNREGISTER_TRIGGER:
-               return "LTTNG_UNREGISTER_TRIGGER";
-       case LTTNG_ROTATE_SESSION:
-               return "LTTNG_ROTATE_SESSION";
-       case LTTNG_ROTATION_GET_INFO:
-               return "LTTNG_ROTATION_GET_INFO";
-       case LTTNG_ROTATION_SET_SCHEDULE:
-               return "LTTNG_ROTATION_SET_SCHEDULE";
-       case LTTNG_SESSION_LIST_ROTATION_SCHEDULES:
-               return "LTTNG_SESSION_LIST_ROTATION_SCHEDULES";
-       case LTTNG_CREATE_SESSION_EXT:
-               return "LTTNG_CREATE_SESSION_EXT";
-       case LTTNG_CLEAR_SESSION:
-               return "LTTNG_CLEAR_SESSION";
-       case LTTNG_LIST_TRIGGERS:
-               return "LTTNG_LIST_TRIGGERS";
-       case LTTNG_EXECUTE_ERROR_QUERY:
-               return "LTTNG_EXECUTE_ERROR_QUERY";
-       default:
-               abort();
-       }
-}
-
-enum lttcomm_relayd_command {
-       RELAYD_ADD_STREAM                   = 1,
-       RELAYD_CREATE_SESSION               = 2,
-       RELAYD_START_DATA                   = 3,
-       RELAYD_UPDATE_SYNC_INFO             = 4,
-       RELAYD_VERSION                      = 5,
-       RELAYD_SEND_METADATA                = 6,
-       RELAYD_CLOSE_STREAM                 = 7,
-       RELAYD_DATA_PENDING                 = 8,
-       RELAYD_QUIESCENT_CONTROL            = 9,
-       RELAYD_BEGIN_DATA_PENDING           = 10,
-       RELAYD_END_DATA_PENDING             = 11,
-       RELAYD_ADD_INDEX                    = 12,
-       RELAYD_SEND_INDEX                   = 13,
-       RELAYD_CLOSE_INDEX                  = 14,
-       /* Live-reading commands (2.4+). */
-       RELAYD_LIST_SESSIONS                = 15,
-       /* All streams of the channel have been sent to the relayd (2.4+). */
-       RELAYD_STREAMS_SENT                 = 16,
-       /* Ask the relay to reset the metadata trace file (2.8+) */
-       RELAYD_RESET_METADATA               = 17,
-       /* Ask the relay to rotate a set of stream files (2.11+) */
-       RELAYD_ROTATE_STREAMS                = 18,
-       /* Ask the relay to create a trace chunk (2.11+) */
-       RELAYD_CREATE_TRACE_CHUNK           = 19,
-       /* Ask the relay to close a trace chunk (2.11+) */
-       RELAYD_CLOSE_TRACE_CHUNK            = 20,
-       /* Ask the relay whether a trace chunk exists (2.11+) */
-       RELAYD_TRACE_CHUNK_EXISTS           = 21,
-       /* Get the current configuration of a relayd peer (2.12+) */
-       RELAYD_GET_CONFIGURATION            = 22,
-
-       /* Feature branch specific commands start at 10000. */
-};
-
-static inline
-const char *lttcomm_relayd_command_str(lttcomm_relayd_command cmd)
-{
-       switch (cmd) {
-       case RELAYD_ADD_STREAM:
-               return "RELAYD_ADD_STREAM";
-       case RELAYD_CREATE_SESSION:
-               return "RELAYD_CREATE_SESSION";
-       case RELAYD_START_DATA:
-               return "RELAYD_START_DATA";
-       case RELAYD_UPDATE_SYNC_INFO:
-               return "RELAYD_UPDATE_SYNC_INFO";
-       case RELAYD_VERSION:
-               return "RELAYD_VERSION";
-       case RELAYD_SEND_METADATA:
-               return "RELAYD_SEND_METADATA";
-       case RELAYD_CLOSE_STREAM:
-               return "RELAYD_CLOSE_STREAM";
-       case RELAYD_DATA_PENDING:
-               return "RELAYD_DATA_PENDING";
-       case RELAYD_QUIESCENT_CONTROL:
-               return "RELAYD_QUIESCENT_CONTROL";
-       case RELAYD_BEGIN_DATA_PENDING:
-               return "RELAYD_BEGIN_DATA_PENDING";
-       case RELAYD_END_DATA_PENDING:
-               return "RELAYD_END_DATA_PENDING";
-       case RELAYD_ADD_INDEX:
-               return "RELAYD_ADD_INDEX";
-       case RELAYD_SEND_INDEX:
-               return "RELAYD_SEND_INDEX";
-       case RELAYD_CLOSE_INDEX:
-               return "RELAYD_CLOSE_INDEX";
-       case RELAYD_LIST_SESSIONS:
-               return "RELAYD_LIST_SESSIONS";
-       case RELAYD_STREAMS_SENT:
-               return "RELAYD_STREAMS_SENT";
-       case RELAYD_RESET_METADATA:
-               return "RELAYD_RESET_METADATA";
-       case RELAYD_ROTATE_STREAMS:
-               return "RELAYD_ROTATE_STREAMS";
-       case RELAYD_CREATE_TRACE_CHUNK:
-               return "RELAYD_CREATE_TRACE_CHUNK";
-       case RELAYD_CLOSE_TRACE_CHUNK:
-               return "RELAYD_CLOSE_TRACE_CHUNK";
-       case RELAYD_TRACE_CHUNK_EXISTS:
-               return "RELAYD_TRACE_CHUNK_EXISTS";
-       case RELAYD_GET_CONFIGURATION:
-               return "RELAYD_GET_CONFIGURATION";
-       default:
-               abort();
-       }
-}
-
-/*
- * lttcomm error code.
- */
-enum lttcomm_return_code {
-       LTTCOMM_CONSUMERD_SUCCESS            = 0,   /* Everything went fine. */
-       /*
-        * Some code paths use -1 to express an error, others
-        * negate this consumer return code. Starting codes at
-        * 100 ensures there is no mix-up between this error value
-        * and legitimate status codes.
-        */
-       LTTCOMM_CONSUMERD_COMMAND_SOCK_READY = 100, /* Command socket ready */
-       LTTCOMM_CONSUMERD_SUCCESS_RECV_FD,          /* Success on receiving fds */
-       LTTCOMM_CONSUMERD_ERROR_RECV_FD,            /* Error on receiving fds */
-       LTTCOMM_CONSUMERD_ERROR_RECV_CMD,           /* Error on receiving command */
-       LTTCOMM_CONSUMERD_POLL_ERROR,               /* Error in polling thread */
-       LTTCOMM_CONSUMERD_POLL_NVAL,                /* Poll on closed fd */
-       LTTCOMM_CONSUMERD_POLL_HUP,                 /* All fds have hungup */
-       LTTCOMM_CONSUMERD_EXIT_SUCCESS,             /* Consumerd exiting normally */
-       LTTCOMM_CONSUMERD_EXIT_FAILURE,             /* Consumerd exiting on error */
-       LTTCOMM_CONSUMERD_OUTFD_ERROR,              /* Error opening the tracefile */
-       LTTCOMM_CONSUMERD_SPLICE_EBADF,             /* EBADF from splice(2) */
-       LTTCOMM_CONSUMERD_SPLICE_EINVAL,            /* EINVAL from splice(2) */
-       LTTCOMM_CONSUMERD_SPLICE_ENOMEM,            /* ENOMEM from splice(2) */
-       LTTCOMM_CONSUMERD_SPLICE_ESPIPE,            /* ESPIPE from splice(2) */
-       LTTCOMM_CONSUMERD_ENOMEM,                   /* Consumer is out of memory */
-       LTTCOMM_CONSUMERD_ERROR_METADATA,           /* Error with metadata. */
-       LTTCOMM_CONSUMERD_FATAL,                    /* Fatal error. */
-       LTTCOMM_CONSUMERD_RELAYD_FAIL,              /* Error on remote relayd */
-       LTTCOMM_CONSUMERD_CHANNEL_FAIL,             /* Channel creation failed. */
-       LTTCOMM_CONSUMERD_CHAN_NOT_FOUND,           /* Channel not found. */
-       LTTCOMM_CONSUMERD_ALREADY_SET,              /* Resource already set. */
-       LTTCOMM_CONSUMERD_ROTATION_FAIL,            /* Rotation has failed. */
-       LTTCOMM_CONSUMERD_SNAPSHOT_FAILED,          /* snapshot has failed. */
-       LTTCOMM_CONSUMERD_CREATE_TRACE_CHUNK_FAILED,/* Trace chunk creation failed. */
-       LTTCOMM_CONSUMERD_CLOSE_TRACE_CHUNK_FAILED, /* Trace chunk close failed. */
-       LTTCOMM_CONSUMERD_INVALID_PARAMETERS,       /* Invalid parameters. */
-       LTTCOMM_CONSUMERD_TRACE_CHUNK_EXISTS_LOCAL, /* Trace chunk exists on consumer daemon. */
-       LTTCOMM_CONSUMERD_TRACE_CHUNK_EXISTS_REMOTE,/* Trace chunk exists on relay daemon. */
-       LTTCOMM_CONSUMERD_UNKNOWN_TRACE_CHUNK,      /* Unknown trace chunk. */
-       LTTCOMM_CONSUMERD_RELAYD_CLEAR_DISALLOWED,  /* Relayd does not accept clear command. */
-       LTTCOMM_CONSUMERD_UNKNOWN_ERROR,            /* Unknown error. */
-
-       /* MUST be last element */
-       LTTCOMM_NR,                                             /* Last element */
-};
-
-/* lttng socket protocol. */
-enum lttcomm_sock_proto {
-       LTTCOMM_SOCK_UDP,
-       LTTCOMM_SOCK_TCP,
-};
-
-/*
- * Index in the net_families array below. Please keep in sync!
- */
-enum lttcomm_sock_domain {
-       LTTCOMM_INET      = 0,
-       LTTCOMM_INET6     = 1,
-};
-
-enum lttcomm_metadata_command {
-       LTTCOMM_METADATA_REQUEST = 1,
-};
-
-/*
- * Commands sent from the consumerd to the sessiond to request if new metadata
- * is available. This message is used to find the per UID _or_ per PID registry
- * for the channel key. For per UID lookup, the triplet
- * bits_per_long/uid/session_id is used. On lookup failure, we search for the
- * per PID registry indexed by session id ignoring the other values.
- */
-struct lttcomm_metadata_request_msg {
-       uint64_t session_id; /* Tracing session id */
-       uint64_t session_id_per_pid; /* Tracing session id for per-pid */
-       uint32_t bits_per_long; /* Consumer ABI */
-       uint32_t uid;
-       uint64_t key; /* Metadata channel key. */
-} LTTNG_PACKED;
-
-struct lttcomm_sockaddr {
-       enum lttcomm_sock_domain type;
-       union {
-               struct sockaddr_in sin;
-               struct sockaddr_in6 sin6;
-       } addr;
-};
-
-struct lttcomm_sock {
-       int32_t fd;
-       enum lttcomm_sock_proto proto;
-       struct lttcomm_sockaddr sockaddr;
-       const struct lttcomm_proto_ops *ops;
-};
-
-/*
- * Relayd sock. Adds the protocol version to use for the communications with
- * the relayd.
- */
-struct lttcomm_relayd_sock {
-       struct lttcomm_sock sock;
-       uint32_t major;
-       uint32_t minor;
-};
-
-struct lttcomm_net_family {
-       int family;
-       int (*create) (struct lttcomm_sock *sock, int type, int proto);
-};
-
-struct lttcomm_proto_ops {
-       int (*bind) (struct lttcomm_sock *sock);
-       int (*close) (struct lttcomm_sock *sock);
-       int (*connect) (struct lttcomm_sock *sock);
-       struct lttcomm_sock *(*accept) (struct lttcomm_sock *sock);
-       int (*listen) (struct lttcomm_sock *sock, int backlog);
-       ssize_t (*recvmsg) (struct lttcomm_sock *sock, void *buf, size_t len,
-                       int flags);
-       ssize_t (*sendmsg) (struct lttcomm_sock *sock, const void *buf,
-                       size_t len, int flags);
-};
-
-struct process_attr_integral_value_comm {
-       union {
-               int64_t _signed;
-               uint64_t _unsigned;
-       } u;
-} LTTNG_PACKED;
-
-/*
- * Data structure received from lttng client to session daemon.
- */
-struct lttcomm_session_msg {
-       uint32_t cmd_type;      /* enum lttcomm_sessiond_command */
-       struct lttng_session session;
-       struct lttng_domain domain;
-       union {
-               /* Event data */
-               struct {
-                       char channel_name[LTTNG_SYMBOL_NAME_LEN];
-                       uint32_t length;
-               } LTTNG_PACKED enable;
-               struct {
-                       char channel_name[LTTNG_SYMBOL_NAME_LEN];
-                       uint32_t length;
-               } LTTNG_PACKED disable;
-               /* Create channel */
-               struct {
-                       uint32_t length;
-               } LTTNG_PACKED channel;
-               /* Context */
-               struct {
-                       char channel_name[LTTNG_SYMBOL_NAME_LEN];
-                       uint32_t length;
-               } LTTNG_PACKED context;
-               /* Use by register_consumer */
-               struct {
-                       char path[PATH_MAX];
-               } LTTNG_PACKED reg;
-               /* List */
-               struct {
-                       char channel_name[LTTNG_SYMBOL_NAME_LEN];
-               } LTTNG_PACKED list;
-               struct lttng_calibrate calibrate;
-               /* Used by the set_consumer_url and used by create_session also call */
-               struct {
-                       /* Number of lttng_uri following */
-                       uint32_t size;
-               } LTTNG_PACKED uri;
-               struct {
-                       struct lttng_snapshot_output output;
-               } LTTNG_PACKED snapshot_output;
-               struct {
-                       uint32_t wait;
-                       struct lttng_snapshot_output output;
-               } LTTNG_PACKED snapshot_record;
-               struct {
-                       uint32_t nb_uri;
-                       unsigned int timer_interval;    /* usec */
-               } LTTNG_PACKED session_live;
-               struct {
-                       struct lttng_save_session_attr attr;
-               } LTTNG_PACKED save_session;
-               struct {
-                       char shm_path[PATH_MAX];
-               } LTTNG_PACKED set_shm_path;
-               struct {
-                       /* enum lttng_process_attr */
-                       int32_t process_attr;
-                       /* enum lttng_process_attr_value_type */
-                       int32_t value_type;
-
-                       struct process_attr_integral_value_comm integral_value;
-                       /*
-                        * For user/group names, a variable length,
-                        * zero-terminated, string of length 'name_len'
-                        * (including the terminator) follows.
-                        *
-                        * integral_value should not be used in those cases.
-                        */
-                       uint32_t name_len;
-               } LTTNG_PACKED process_attr_tracker_add_remove_include_value;
-               struct {
-                       /* enum lttng_process_attr */
-                       int32_t process_attr;
-               } LTTNG_PACKED process_attr_tracker_get_inclusion_set;
-               struct {
-                       /* enum lttng_process_attr */
-                       int32_t process_attr;
-               } LTTNG_PACKED process_attr_tracker_get_tracking_policy;
-               struct {
-                       /* enum lttng_process_attr */
-                       int32_t process_attr;
-                       /* enum lttng_tracking_policy */
-                       int32_t tracking_policy;
-               } LTTNG_PACKED process_attr_tracker_set_tracking_policy;
-               struct {
-                       uint32_t length;
-                       uint8_t is_trigger_anonymous;
-               } LTTNG_PACKED trigger;
-               struct {
-                       uint32_t length;
-               } LTTNG_PACKED error_query;
-               struct {
-                       uint64_t rotation_id;
-               } LTTNG_PACKED get_rotation_info;
-               struct {
-                       /* enum lttng_rotation_schedule_type */
-                       uint8_t type;
-                       /*
-                        * If set == 1, set schedule to value, if set == 0,
-                        * clear this schedule type.
-                        */
-                       uint8_t set;
-                       uint64_t value;
-               } LTTNG_PACKED rotation_set_schedule;
-               struct {
-                       /*
-                        * Includes the null-terminator.
-                        * Must be an absolute path.
-                        *
-                        * Size bounded by LTTNG_PATH_MAX.
-                        */
-                       uint16_t home_dir_size;
-                       uint64_t session_descriptor_size;
-                       /* An lttng_session_descriptor follows. */
-               } LTTNG_PACKED create_session;
-       } u;
-       /* Count of fds sent. */
-       uint32_t fd_count;
-} LTTNG_PACKED;
-
-#define LTTNG_FILTER_MAX_LEN   65536
-#define LTTNG_SESSION_DESCRIPTOR_MAX_LEN       65536
-
-/*
- * Filter bytecode data. The reloc table is located at the end of the
- * bytecode. It is made of tuples: (uint16_t, var. len. string). It
- * starts at reloc_table_offset.
- */
-#define LTTNG_FILTER_PADDING   32
-struct lttng_bytecode {
-       uint32_t len;   /* len of data */
-       uint32_t reloc_table_offset;
-       uint64_t seqnum;
-       char padding[LTTNG_FILTER_PADDING];
-       char data[0];
-} LTTNG_PACKED;
-
-/*
- * Event exclusion data. At the end of the structure, there will actually
- * by zero or more names, where the actual number of names is given by
- * the 'count' item of the structure.
- */
-#define LTTNG_EVENT_EXCLUSION_PADDING  32
-struct lttng_event_exclusion {
-       uint32_t count;
-       char padding[LTTNG_EVENT_EXCLUSION_PADDING];
-       char names[][LTTNG_SYMBOL_NAME_LEN];
-} LTTNG_PACKED;
-
-#define LTTNG_EVENT_EXCLUSION_NAME_AT(_exclusion, _i) \
-       ((_exclusion)->names[_i])
-
-/*
- * Listing command header.
- */
-struct lttcomm_list_command_header {
-       /* Number of elements */
-       uint32_t count;
-} LTTNG_PACKED;
-
-/*
- * Event extended info header. This is the structure preceding each
- * extended info data.
- */
-struct lttcomm_event_extended_header {
-       /*
-        * Size of filter string immediately following this header.
-        * This size includes the terminal null character.
-        */
-       uint32_t filter_len;
-
-       /*
-        * Number of exclusion names, immediately following the filter
-        * string. Each exclusion name has a fixed length of
-        * LTTNG_SYMBOL_NAME_LEN bytes, including the terminal null
-        * character.
-        */
-       uint32_t nb_exclusions;
-
-       /*
-        * Size of the event's userspace probe location (if applicable).
-        */
-       uint32_t userspace_probe_location_len;
-} LTTNG_PACKED;
-
-/*
- * Command header of the reply to an LTTNG_DESTROY_SESSION command.
- */
-struct lttcomm_session_destroy_command_header {
-       /* enum lttng_session */
-       int32_t rotation_state;
-};
-
-/*
- * tracker command header.
- */
-struct lttcomm_tracker_command_header {
-       uint32_t nb_tracker_id;
-} LTTNG_PACKED;
-
-/*
- * Data structure for the response from sessiond to the lttng client.
- */
-struct lttcomm_lttng_msg {
-       uint32_t cmd_type;      /* enum lttcomm_sessiond_command */
-       uint32_t ret_code;      /* enum lttcomm_return_code */
-       uint32_t pid;           /* pid_t */
-       uint32_t cmd_header_size;
-       uint32_t data_size;
-       uint32_t fd_count;
-} LTTNG_PACKED;
-
-struct lttcomm_lttng_output_id {
-       uint32_t id;
-} LTTNG_PACKED;
-
-/*
- * lttcomm_consumer_msg is the message sent from sessiond to consumerd
- * to either add a channel, add a stream, update a stream, or stop
- * operation.
- */
-struct lttcomm_consumer_msg {
-       uint32_t cmd_type;      /* enum lttng_consumer_command */
-       union {
-               struct {
-                       uint64_t channel_key;
-                       uint64_t session_id;
-                       /* ID of the session's current trace chunk. */
-                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED chunk_id;
-                       char pathname[PATH_MAX];
-                       uint64_t relayd_id;
-                       /* nb_init_streams is the number of streams open initially. */
-                       uint32_t nb_init_streams;
-                       char name[LTTNG_SYMBOL_NAME_LEN];
-                       /* Use splice or mmap to consume this fd */
-                       enum lttng_event_output output;
-                       int type; /* Per cpu or metadata. */
-                       uint64_t tracefile_size; /* bytes */
-                       uint32_t tracefile_count; /* number of tracefiles */
-                       /* If the channel's streams have to be monitored or not. */
-                       uint32_t monitor;
-                       /* timer to check the streams usage in live mode (usec). */
-                       unsigned int live_timer_interval;
-                       /* is part of a live session */
-                       uint8_t is_live;
-                       /* timer to sample a channel's positions (usec). */
-                       unsigned int monitor_timer_interval;
-               } LTTNG_PACKED channel; /* Only used by Kernel. */
-               struct {
-                       uint64_t stream_key;
-                       uint64_t channel_key;
-                       int32_t cpu;    /* On which CPU this stream is assigned. */
-                       /* Tells the consumer if the stream should be or not monitored. */
-                       uint32_t no_monitor;
-               } LTTNG_PACKED stream;  /* Only used by Kernel. */
-               struct {
-                       uint64_t net_index;
-                       enum lttng_stream_type type;
-                       uint32_t major;
-                       uint32_t minor;
-                       uint8_t relayd_socket_protocol;
-                       /* Tracing session id associated to the relayd. */
-                       uint64_t session_id;
-                       /* Relayd session id, only used with control socket. */
-                       uint64_t relayd_session_id;
-               } LTTNG_PACKED relayd_sock;
-               struct {
-                       uint64_t net_seq_idx;
-               } LTTNG_PACKED destroy_relayd;
-               struct {
-                       uint64_t session_id;
-               } LTTNG_PACKED data_pending;
-               struct {
-                       uint64_t subbuf_size;                   /* bytes */
-                       uint64_t num_subbuf;                    /* power of 2 */
-                       int32_t overwrite;                      /* 1: overwrite, 0: discard */
-                       uint32_t switch_timer_interval;         /* usec */
-                       uint32_t read_timer_interval;           /* usec */
-                       unsigned int live_timer_interval;       /* usec */
-                       uint8_t is_live;                        /* is part of a live session */
-                       uint32_t monitor_timer_interval;        /* usec */
-                       int32_t output;                         /* splice, mmap */
-                       int32_t type;                           /* metadata or per_cpu */
-                       uint64_t session_id;                    /* Tracing session id */
-                       char pathname[PATH_MAX];                /* Channel file path. */
-                       char name[LTTNG_SYMBOL_NAME_LEN];       /* Channel name. */
-                       /* Credentials used to open the UST buffer shared mappings. */
-                       struct {
-                               uint32_t uid;
-                               uint32_t gid;
-                       } LTTNG_PACKED buffer_credentials;
-                       uint64_t relayd_id;                     /* Relayd id if apply. */
-                       uint64_t key;                           /* Unique channel key. */
-                       /* ID of the session's current trace chunk. */
-                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED chunk_id;
-                       unsigned char uuid[LTTNG_UUID_LEN];     /* uuid for ust tracer. */
-                       uint32_t chan_id;                       /* Channel ID on the tracer side. */
-                       uint64_t tracefile_size;        /* bytes */
-                       uint32_t tracefile_count;       /* number of tracefiles */
-                       uint64_t session_id_per_pid;    /* Per-pid session ID. */
-                       /* Tells the consumer if the stream should be or not monitored. */
-                       uint32_t monitor;
-                       /*
-                        * For UST per UID buffers, this is the application UID of the
-                        * channel.  This can be different from the user UID requesting the
-                        * channel creation and used for the rights on the stream file
-                        * because the application can be in the tracing for instance.
-                        */
-                       uint32_t ust_app_uid;
-                       int64_t blocking_timeout;
-                       char root_shm_path[PATH_MAX];
-                       char shm_path[PATH_MAX];
-               } LTTNG_PACKED ask_channel;
-               struct {
-                       uint64_t key;
-               } LTTNG_PACKED get_channel;
-               struct {
-                       uint64_t key;
-               } LTTNG_PACKED destroy_channel;
-               struct {
-                       uint64_t key;   /* Metadata channel key. */
-                       uint64_t target_offset; /* Offset in the consumer */
-                       uint64_t len;   /* Length of metadata to be received. */
-                       uint64_t version; /* Version of the metadata. */
-               } LTTNG_PACKED push_metadata;
-               struct {
-                       uint64_t key;   /* Metadata channel key. */
-               } LTTNG_PACKED close_metadata;
-               struct {
-                       uint64_t key;   /* Metadata channel key. */
-               } LTTNG_PACKED setup_metadata;
-               struct {
-                       uint64_t key;   /* Channel key. */
-               } LTTNG_PACKED flush_channel;
-               struct {
-                       uint64_t key;   /* Channel key. */
-               } LTTNG_PACKED clear_quiescent_channel;
-               struct {
-                       char pathname[PATH_MAX];
-                       /* Indicate if the snapshot goes on the relayd or locally. */
-                       uint32_t use_relayd;
-                       uint32_t metadata;              /* This a metadata snapshot. */
-                       uint64_t relayd_id;             /* Relayd id if apply. */
-                       uint64_t key;
-                       uint64_t nb_packets_per_stream;
-               } LTTNG_PACKED snapshot_channel;
-               struct {
-                       uint64_t channel_key;
-                       uint64_t net_seq_idx;
-               } LTTNG_PACKED sent_streams;
-               struct {
-                       uint64_t session_id;
-                       uint64_t channel_key;
-               } LTTNG_PACKED discarded_events;
-               struct {
-                       uint64_t session_id;
-                       uint64_t channel_key;
-               } LTTNG_PACKED lost_packets;
-               struct {
-                       uint64_t session_id;
-               } LTTNG_PACKED regenerate_metadata;
-               struct {
-                       uint32_t metadata; /* This is a metadata channel. */
-                       uint64_t relayd_id; /* Relayd id if apply. */
-                       uint64_t key;
-               } LTTNG_PACKED rotate_channel;
-               struct {
-                       uint64_t session_id;
-                       uint64_t chunk_id;
-               } LTTNG_PACKED check_rotation_pending_local;
-               struct {
-                       uint64_t relayd_id;
-                       uint64_t session_id;
-                       uint64_t chunk_id;
-               } LTTNG_PACKED check_rotation_pending_relay;
-               struct {
-                       /*
-                        * Relayd id, if applicable (remote).
-                        *
-                        * A directory file descriptor referring to the chunk's
-                        * output folder is transmitted if the chunk is local
-                        * (relayd_id unset).
-                        *
-                        * `override_name` is left NULL (all-zeroes) if the
-                        * chunk's name is not overridden.
-                        */
-                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
-                       char override_name[LTTNG_NAME_MAX];
-                       uint64_t session_id;
-                       uint64_t chunk_id;
-                       uint64_t creation_timestamp;
-                       LTTNG_OPTIONAL_COMM(struct {
-                               uint32_t uid;
-                               uint32_t gid;
-                       } LTTNG_PACKED ) LTTNG_PACKED credentials;
-               } LTTNG_PACKED create_trace_chunk;
-               struct {
-                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
-                       uint64_t session_id;
-                       uint64_t chunk_id;
-                       uint64_t close_timestamp;
-                       /* enum lttng_trace_chunk_command_type */
-                       LTTNG_OPTIONAL_COMM(uint32_t) LTTNG_PACKED close_command;
-               } LTTNG_PACKED close_trace_chunk;
-               struct {
-                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
-                       uint64_t session_id;
-                       uint64_t chunk_id;
-               } LTTNG_PACKED trace_chunk_exists;
-               struct {
-                       lttng_uuid sessiond_uuid;
-               } LTTNG_PACKED init;
-               struct {
-                       uint64_t key;
-               } LTTNG_PACKED clear_channel;
-               struct {
-                       uint64_t key;
-               } LTTNG_PACKED open_channel_packets;
-       } u;
-} LTTNG_PACKED;
-
-/*
- * Channel monitoring message returned to the session daemon on every
- * monitor timer expiration.
- */
-struct lttcomm_consumer_channel_monitor_msg {
-       /* Key of the sampled channel. */
-       uint64_t key;
-       /*
-        * Lowest and highest usage (bytes) at the moment the sample was taken.
-        */
-       uint64_t lowest, highest;
-       /*
-        * Sum of all the consumed positions for a channel.
-        */
-       uint64_t total_consumed;
-} LTTNG_PACKED;
-
-/*
- * Status message returned to the sessiond after a received command.
- */
-struct lttcomm_consumer_status_msg {
-       enum lttcomm_return_code ret_code;
-} LTTNG_PACKED;
-
-struct lttcomm_consumer_status_channel {
-       enum lttcomm_return_code ret_code;
-       uint64_t key;
-       unsigned int stream_count;
-} LTTNG_PACKED;
-
-struct lttcomm_consumer_close_trace_chunk_reply {
-       enum lttcomm_return_code ret_code;
-       uint32_t path_length;
-       char path[];
-};
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-#include <lttng/ust-abi.h>
-
-/*
- * Data structure for the commands sent from sessiond to UST.
- */
-struct lttcomm_ust_msg {
-       uint32_t handle;
-       uint32_t cmd;
-       union {
-               struct lttng_ust_abi_channel channel;
-               struct lttng_ust_abi_stream stream;
-               struct lttng_ust_abi_event event;
-               struct lttng_ust_abi_context context;
-               struct lttng_ust_abi_tracer_version version;
-       } u;
-} LTTNG_PACKED;
-
-/*
- * Data structure for the response from UST to the session daemon.
- * cmd_type is sent back in the reply for validation.
- */
-struct lttcomm_ust_reply {
-       uint32_t handle;
-       uint32_t cmd;
-       uint32_t ret_code;      /* enum lttcomm_return_code */
-       uint32_t ret_val;       /* return value */
-       union {
-               struct {
-                       uint64_t memory_map_size;
-               } LTTNG_PACKED channel;
-               struct {
-                       uint64_t memory_map_size;
-               } LTTNG_PACKED stream;
-               struct lttng_ust_abi_tracer_version version;
-       } u;
-} LTTNG_PACKED;
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
-
-int lttcomm_init_inet_sockaddr(struct lttcomm_sockaddr *sockaddr,
-               const char *ip, unsigned int port);
-int lttcomm_init_inet6_sockaddr(struct lttcomm_sockaddr *sockaddr,
-               const char *ip, unsigned int port);
-
-struct lttcomm_sock *lttcomm_alloc_sock(enum lttcomm_sock_proto proto);
-int lttcomm_populate_sock_from_open_socket(struct lttcomm_sock *sock,
-               int fd,
-               enum lttcomm_sock_proto protocol);
-int lttcomm_create_sock(struct lttcomm_sock *sock);
-struct lttcomm_sock *lttcomm_alloc_sock_from_uri(struct lttng_uri *uri);
-void lttcomm_destroy_sock(struct lttcomm_sock *sock);
-struct lttcomm_sock *lttcomm_alloc_copy_sock(struct lttcomm_sock *src);
-void lttcomm_copy_sock(struct lttcomm_sock *dst,
-               struct lttcomm_sock *src);
-
-/* Relayd socket object. */
-struct lttcomm_relayd_sock *lttcomm_alloc_relayd_sock(
-               struct lttng_uri *uri, uint32_t major, uint32_t minor);
-
-int lttcomm_setsockopt_rcv_timeout(int sock, unsigned int msec);
-int lttcomm_setsockopt_snd_timeout(int sock, unsigned int msec);
-
-int lttcomm_sock_get_port(const struct lttcomm_sock *sock,
-               uint16_t *port);
-/*
- * Set a port to an lttcomm_sock. This will have no effect is the socket is
- * already bound.
- */
-int lttcomm_sock_set_port(struct lttcomm_sock *sock, uint16_t port);
-
-void lttcomm_init(void);
-/* Get network timeout, in milliseconds */
-unsigned long lttcomm_get_network_timeout(void);
-
-#endif /* _LTTNG_SESSIOND_COMM_H */
diff --git a/src/common/sessiond-comm/sessiond-comm.hpp b/src/common/sessiond-comm/sessiond-comm.hpp
new file mode 100644 (file)
index 0000000..ae31118
--- /dev/null
@@ -0,0 +1,958 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+/*
+ * This header is meant for liblttng and libust internal use ONLY. These
+ * declarations should NOT be considered stable API.
+ */
+
+#ifndef _LTTNG_SESSIOND_COMM_H
+#define _LTTNG_SESSIOND_COMM_H
+
+#include <limits.h>
+#include <lttng/lttng.h>
+#include <lttng/snapshot-internal.hpp>
+#include <lttng/save-internal.hpp>
+#include <lttng/channel-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <lttng/rotate-internal.hpp>
+#include <common/compat/socket.hpp>
+#include <common/uri.hpp>
+#include <common/defaults.hpp>
+#include <common/uuid.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <stdint.h>
+#include <sys/un.h>
+
+#include "inet.hpp"
+#include "inet6.hpp"
+#include <common/unix.hpp>
+
+/* Queue size of listen(2) */
+#define LTTNG_SESSIOND_COMM_MAX_LISTEN 64
+
+/* Maximum number of FDs that can be sent over a Unix socket */
+#if defined(__linux__)
+/* Based on the kernel's SCM_MAX_FD which is 253 since 2.6.38 (255 before) */
+#define LTTCOMM_MAX_SEND_FDS           253
+#else
+#define LTTCOMM_MAX_SEND_FDS           16
+#endif
+
+enum lttcomm_sessiond_command {
+       /* Tracer command */
+       LTTNG_ADD_CONTEXT                               = 0,
+       /* LTTNG_CALIBRATE used to be here */
+       LTTNG_DISABLE_CHANNEL                           = 2,
+       LTTNG_DISABLE_EVENT                             = 3,
+       LTTNG_LIST_SYSCALLS                             = 4,
+       LTTNG_ENABLE_CHANNEL                            = 5,
+       LTTNG_ENABLE_EVENT                              = 6,
+       /* 7 */
+       /* Session daemon command */
+       /* 8 */
+       LTTNG_DESTROY_SESSION                           = 9,
+       LTTNG_LIST_CHANNELS                             = 10,
+       LTTNG_LIST_DOMAINS                              = 11,
+       LTTNG_LIST_EVENTS                               = 12,
+       LTTNG_LIST_SESSIONS                             = 13,
+       LTTNG_LIST_TRACEPOINTS                          = 14,
+       LTTNG_REGISTER_CONSUMER                         = 15,
+       LTTNG_START_TRACE                               = 16,
+       LTTNG_STOP_TRACE                                = 17,
+       LTTNG_LIST_TRACEPOINT_FIELDS                    = 18,
+
+       /* Consumer */
+       LTTNG_DISABLE_CONSUMER                          = 19,
+       LTTNG_ENABLE_CONSUMER                           = 20,
+       LTTNG_SET_CONSUMER_URI                          = 21,
+       /* 22 */
+       /* 23 */
+       LTTNG_DATA_PENDING                              = 24,
+       LTTNG_SNAPSHOT_ADD_OUTPUT                       = 25,
+       LTTNG_SNAPSHOT_DEL_OUTPUT                       = 26,
+       LTTNG_SNAPSHOT_LIST_OUTPUT                      = 27,
+       LTTNG_SNAPSHOT_RECORD                           = 28,
+       /* 29 */
+       /* 30 */
+       LTTNG_SAVE_SESSION                              = 31,
+       LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE    = 32,
+       LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE = 33,
+       LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY           = 34,
+       LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY           = 35,
+       LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET     = 36,
+       LTTNG_SET_SESSION_SHM_PATH                      = 40,
+       LTTNG_REGENERATE_METADATA                       = 41,
+       LTTNG_REGENERATE_STATEDUMP                      = 42,
+       LTTNG_REGISTER_TRIGGER                          = 43,
+       LTTNG_UNREGISTER_TRIGGER                        = 44,
+       LTTNG_ROTATE_SESSION                            = 45,
+       LTTNG_ROTATION_GET_INFO                         = 46,
+       LTTNG_ROTATION_SET_SCHEDULE                     = 47,
+       LTTNG_SESSION_LIST_ROTATION_SCHEDULES           = 48,
+       LTTNG_CREATE_SESSION_EXT                        = 49,
+       LTTNG_CLEAR_SESSION                             = 50,
+       LTTNG_LIST_TRIGGERS                             = 51,
+       LTTNG_EXECUTE_ERROR_QUERY                       = 52,
+};
+
+static inline
+const char *lttcomm_sessiond_command_str(enum lttcomm_sessiond_command cmd)
+{
+       switch (cmd) {
+       case LTTNG_ADD_CONTEXT:
+               return "LTTNG_ADD_CONTEXT";
+       case LTTNG_DISABLE_CHANNEL:
+               return "LTTNG_DISABLE_CHANNEL";
+       case LTTNG_DISABLE_EVENT:
+               return "LTTNG_DISABLE_EVENT";
+       case LTTNG_LIST_SYSCALLS:
+               return "LTTNG_LIST_SYSCALLS";
+       case LTTNG_ENABLE_CHANNEL:
+               return "LTTNG_ENABLE_CHANNEL";
+       case LTTNG_ENABLE_EVENT:
+               return "LTTNG_ENABLE_EVENT";
+       case LTTNG_DESTROY_SESSION:
+               return "LTTNG_DESTROY_SESSION";
+       case LTTNG_LIST_CHANNELS:
+               return "LTTNG_LIST_CHANNELS";
+       case LTTNG_LIST_DOMAINS:
+               return "LTTNG_LIST_DOMAINS";
+       case LTTNG_LIST_EVENTS:
+               return "LTTNG_LIST_EVENTS";
+       case LTTNG_LIST_SESSIONS:
+               return "LTTNG_LIST_SESSIONS";
+       case LTTNG_LIST_TRACEPOINTS:
+               return "LTTNG_LIST_TRACEPOINTS";
+       case LTTNG_REGISTER_CONSUMER:
+               return "LTTNG_REGISTER_CONSUMER";
+       case LTTNG_START_TRACE:
+               return "LTTNG_START_TRACE";
+       case LTTNG_STOP_TRACE:
+               return "LTTNG_STOP_TRACE";
+       case LTTNG_LIST_TRACEPOINT_FIELDS:
+               return "LTTNG_LIST_TRACEPOINT_FIELDS";
+       case LTTNG_DISABLE_CONSUMER:
+               return "LTTNG_DISABLE_CONSUMER";
+       case LTTNG_ENABLE_CONSUMER:
+               return "LTTNG_ENABLE_CONSUMER";
+       case LTTNG_SET_CONSUMER_URI:
+               return "LTTNG_SET_CONSUMER_URI";
+       case LTTNG_DATA_PENDING:
+               return "LTTNG_DATA_PENDING";
+       case LTTNG_SNAPSHOT_ADD_OUTPUT:
+               return "LTTNG_SNAPSHOT_ADD_OUTPUT";
+       case LTTNG_SNAPSHOT_DEL_OUTPUT:
+               return "LTTNG_SNAPSHOT_DEL_OUTPUT";
+       case LTTNG_SNAPSHOT_LIST_OUTPUT:
+               return "LTTNG_SNAPSHOT_LIST_OUTPUT";
+       case LTTNG_SNAPSHOT_RECORD:
+               return "LTTNG_SNAPSHOT_RECORD";
+       case LTTNG_SAVE_SESSION:
+               return "LTTNG_SAVE_SESSION";
+       case LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE:
+               return "LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE";
+       case LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE:
+               return "LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE";
+       case LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY:
+               return "LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY";
+       case LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY:
+               return "LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY";
+       case LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET:
+               return "LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET";
+       case LTTNG_SET_SESSION_SHM_PATH:
+               return "LTTNG_SET_SESSION_SHM_PATH";
+       case LTTNG_REGENERATE_METADATA:
+               return "LTTNG_REGENERATE_METADATA";
+       case LTTNG_REGENERATE_STATEDUMP:
+               return "LTTNG_REGENERATE_STATEDUMP";
+       case LTTNG_REGISTER_TRIGGER:
+               return "LTTNG_REGISTER_TRIGGER";
+       case LTTNG_UNREGISTER_TRIGGER:
+               return "LTTNG_UNREGISTER_TRIGGER";
+       case LTTNG_ROTATE_SESSION:
+               return "LTTNG_ROTATE_SESSION";
+       case LTTNG_ROTATION_GET_INFO:
+               return "LTTNG_ROTATION_GET_INFO";
+       case LTTNG_ROTATION_SET_SCHEDULE:
+               return "LTTNG_ROTATION_SET_SCHEDULE";
+       case LTTNG_SESSION_LIST_ROTATION_SCHEDULES:
+               return "LTTNG_SESSION_LIST_ROTATION_SCHEDULES";
+       case LTTNG_CREATE_SESSION_EXT:
+               return "LTTNG_CREATE_SESSION_EXT";
+       case LTTNG_CLEAR_SESSION:
+               return "LTTNG_CLEAR_SESSION";
+       case LTTNG_LIST_TRIGGERS:
+               return "LTTNG_LIST_TRIGGERS";
+       case LTTNG_EXECUTE_ERROR_QUERY:
+               return "LTTNG_EXECUTE_ERROR_QUERY";
+       default:
+               abort();
+       }
+}
+
+enum lttcomm_relayd_command {
+       RELAYD_ADD_STREAM                   = 1,
+       RELAYD_CREATE_SESSION               = 2,
+       RELAYD_START_DATA                   = 3,
+       RELAYD_UPDATE_SYNC_INFO             = 4,
+       RELAYD_VERSION                      = 5,
+       RELAYD_SEND_METADATA                = 6,
+       RELAYD_CLOSE_STREAM                 = 7,
+       RELAYD_DATA_PENDING                 = 8,
+       RELAYD_QUIESCENT_CONTROL            = 9,
+       RELAYD_BEGIN_DATA_PENDING           = 10,
+       RELAYD_END_DATA_PENDING             = 11,
+       RELAYD_ADD_INDEX                    = 12,
+       RELAYD_SEND_INDEX                   = 13,
+       RELAYD_CLOSE_INDEX                  = 14,
+       /* Live-reading commands (2.4+). */
+       RELAYD_LIST_SESSIONS                = 15,
+       /* All streams of the channel have been sent to the relayd (2.4+). */
+       RELAYD_STREAMS_SENT                 = 16,
+       /* Ask the relay to reset the metadata trace file (2.8+) */
+       RELAYD_RESET_METADATA               = 17,
+       /* Ask the relay to rotate a set of stream files (2.11+) */
+       RELAYD_ROTATE_STREAMS                = 18,
+       /* Ask the relay to create a trace chunk (2.11+) */
+       RELAYD_CREATE_TRACE_CHUNK           = 19,
+       /* Ask the relay to close a trace chunk (2.11+) */
+       RELAYD_CLOSE_TRACE_CHUNK            = 20,
+       /* Ask the relay whether a trace chunk exists (2.11+) */
+       RELAYD_TRACE_CHUNK_EXISTS           = 21,
+       /* Get the current configuration of a relayd peer (2.12+) */
+       RELAYD_GET_CONFIGURATION            = 22,
+
+       /* Feature branch specific commands start at 10000. */
+};
+
+static inline
+const char *lttcomm_relayd_command_str(lttcomm_relayd_command cmd)
+{
+       switch (cmd) {
+       case RELAYD_ADD_STREAM:
+               return "RELAYD_ADD_STREAM";
+       case RELAYD_CREATE_SESSION:
+               return "RELAYD_CREATE_SESSION";
+       case RELAYD_START_DATA:
+               return "RELAYD_START_DATA";
+       case RELAYD_UPDATE_SYNC_INFO:
+               return "RELAYD_UPDATE_SYNC_INFO";
+       case RELAYD_VERSION:
+               return "RELAYD_VERSION";
+       case RELAYD_SEND_METADATA:
+               return "RELAYD_SEND_METADATA";
+       case RELAYD_CLOSE_STREAM:
+               return "RELAYD_CLOSE_STREAM";
+       case RELAYD_DATA_PENDING:
+               return "RELAYD_DATA_PENDING";
+       case RELAYD_QUIESCENT_CONTROL:
+               return "RELAYD_QUIESCENT_CONTROL";
+       case RELAYD_BEGIN_DATA_PENDING:
+               return "RELAYD_BEGIN_DATA_PENDING";
+       case RELAYD_END_DATA_PENDING:
+               return "RELAYD_END_DATA_PENDING";
+       case RELAYD_ADD_INDEX:
+               return "RELAYD_ADD_INDEX";
+       case RELAYD_SEND_INDEX:
+               return "RELAYD_SEND_INDEX";
+       case RELAYD_CLOSE_INDEX:
+               return "RELAYD_CLOSE_INDEX";
+       case RELAYD_LIST_SESSIONS:
+               return "RELAYD_LIST_SESSIONS";
+       case RELAYD_STREAMS_SENT:
+               return "RELAYD_STREAMS_SENT";
+       case RELAYD_RESET_METADATA:
+               return "RELAYD_RESET_METADATA";
+       case RELAYD_ROTATE_STREAMS:
+               return "RELAYD_ROTATE_STREAMS";
+       case RELAYD_CREATE_TRACE_CHUNK:
+               return "RELAYD_CREATE_TRACE_CHUNK";
+       case RELAYD_CLOSE_TRACE_CHUNK:
+               return "RELAYD_CLOSE_TRACE_CHUNK";
+       case RELAYD_TRACE_CHUNK_EXISTS:
+               return "RELAYD_TRACE_CHUNK_EXISTS";
+       case RELAYD_GET_CONFIGURATION:
+               return "RELAYD_GET_CONFIGURATION";
+       default:
+               abort();
+       }
+}
+
+/*
+ * lttcomm error code.
+ */
+enum lttcomm_return_code {
+       LTTCOMM_CONSUMERD_SUCCESS            = 0,   /* Everything went fine. */
+       /*
+        * Some code paths use -1 to express an error, others
+        * negate this consumer return code. Starting codes at
+        * 100 ensures there is no mix-up between this error value
+        * and legitimate status codes.
+        */
+       LTTCOMM_CONSUMERD_COMMAND_SOCK_READY = 100, /* Command socket ready */
+       LTTCOMM_CONSUMERD_SUCCESS_RECV_FD,          /* Success on receiving fds */
+       LTTCOMM_CONSUMERD_ERROR_RECV_FD,            /* Error on receiving fds */
+       LTTCOMM_CONSUMERD_ERROR_RECV_CMD,           /* Error on receiving command */
+       LTTCOMM_CONSUMERD_POLL_ERROR,               /* Error in polling thread */
+       LTTCOMM_CONSUMERD_POLL_NVAL,                /* Poll on closed fd */
+       LTTCOMM_CONSUMERD_POLL_HUP,                 /* All fds have hungup */
+       LTTCOMM_CONSUMERD_EXIT_SUCCESS,             /* Consumerd exiting normally */
+       LTTCOMM_CONSUMERD_EXIT_FAILURE,             /* Consumerd exiting on error */
+       LTTCOMM_CONSUMERD_OUTFD_ERROR,              /* Error opening the tracefile */
+       LTTCOMM_CONSUMERD_SPLICE_EBADF,             /* EBADF from splice(2) */
+       LTTCOMM_CONSUMERD_SPLICE_EINVAL,            /* EINVAL from splice(2) */
+       LTTCOMM_CONSUMERD_SPLICE_ENOMEM,            /* ENOMEM from splice(2) */
+       LTTCOMM_CONSUMERD_SPLICE_ESPIPE,            /* ESPIPE from splice(2) */
+       LTTCOMM_CONSUMERD_ENOMEM,                   /* Consumer is out of memory */
+       LTTCOMM_CONSUMERD_ERROR_METADATA,           /* Error with metadata. */
+       LTTCOMM_CONSUMERD_FATAL,                    /* Fatal error. */
+       LTTCOMM_CONSUMERD_RELAYD_FAIL,              /* Error on remote relayd */
+       LTTCOMM_CONSUMERD_CHANNEL_FAIL,             /* Channel creation failed. */
+       LTTCOMM_CONSUMERD_CHAN_NOT_FOUND,           /* Channel not found. */
+       LTTCOMM_CONSUMERD_ALREADY_SET,              /* Resource already set. */
+       LTTCOMM_CONSUMERD_ROTATION_FAIL,            /* Rotation has failed. */
+       LTTCOMM_CONSUMERD_SNAPSHOT_FAILED,          /* snapshot has failed. */
+       LTTCOMM_CONSUMERD_CREATE_TRACE_CHUNK_FAILED,/* Trace chunk creation failed. */
+       LTTCOMM_CONSUMERD_CLOSE_TRACE_CHUNK_FAILED, /* Trace chunk close failed. */
+       LTTCOMM_CONSUMERD_INVALID_PARAMETERS,       /* Invalid parameters. */
+       LTTCOMM_CONSUMERD_TRACE_CHUNK_EXISTS_LOCAL, /* Trace chunk exists on consumer daemon. */
+       LTTCOMM_CONSUMERD_TRACE_CHUNK_EXISTS_REMOTE,/* Trace chunk exists on relay daemon. */
+       LTTCOMM_CONSUMERD_UNKNOWN_TRACE_CHUNK,      /* Unknown trace chunk. */
+       LTTCOMM_CONSUMERD_RELAYD_CLEAR_DISALLOWED,  /* Relayd does not accept clear command. */
+       LTTCOMM_CONSUMERD_UNKNOWN_ERROR,            /* Unknown error. */
+
+       /* MUST be last element */
+       LTTCOMM_NR,                                             /* Last element */
+};
+
+/* lttng socket protocol. */
+enum lttcomm_sock_proto {
+       LTTCOMM_SOCK_UDP,
+       LTTCOMM_SOCK_TCP,
+};
+
+/*
+ * Index in the net_families array below. Please keep in sync!
+ */
+enum lttcomm_sock_domain {
+       LTTCOMM_INET      = 0,
+       LTTCOMM_INET6     = 1,
+};
+
+enum lttcomm_metadata_command {
+       LTTCOMM_METADATA_REQUEST = 1,
+};
+
+/*
+ * Commands sent from the consumerd to the sessiond to request if new metadata
+ * is available. This message is used to find the per UID _or_ per PID registry
+ * for the channel key. For per UID lookup, the triplet
+ * bits_per_long/uid/session_id is used. On lookup failure, we search for the
+ * per PID registry indexed by session id ignoring the other values.
+ */
+struct lttcomm_metadata_request_msg {
+       uint64_t session_id; /* Tracing session id */
+       uint64_t session_id_per_pid; /* Tracing session id for per-pid */
+       uint32_t bits_per_long; /* Consumer ABI */
+       uint32_t uid;
+       uint64_t key; /* Metadata channel key. */
+} LTTNG_PACKED;
+
+struct lttcomm_sockaddr {
+       enum lttcomm_sock_domain type;
+       union {
+               struct sockaddr_in sin;
+               struct sockaddr_in6 sin6;
+       } addr;
+};
+
+struct lttcomm_sock {
+       int32_t fd;
+       enum lttcomm_sock_proto proto;
+       struct lttcomm_sockaddr sockaddr;
+       const struct lttcomm_proto_ops *ops;
+};
+
+/*
+ * Relayd sock. Adds the protocol version to use for the communications with
+ * the relayd.
+ */
+struct lttcomm_relayd_sock {
+       struct lttcomm_sock sock;
+       uint32_t major;
+       uint32_t minor;
+};
+
+struct lttcomm_net_family {
+       int family;
+       int (*create) (struct lttcomm_sock *sock, int type, int proto);
+};
+
+struct lttcomm_proto_ops {
+       int (*bind) (struct lttcomm_sock *sock);
+       int (*close) (struct lttcomm_sock *sock);
+       int (*connect) (struct lttcomm_sock *sock);
+       struct lttcomm_sock *(*accept) (struct lttcomm_sock *sock);
+       int (*listen) (struct lttcomm_sock *sock, int backlog);
+       ssize_t (*recvmsg) (struct lttcomm_sock *sock, void *buf, size_t len,
+                       int flags);
+       ssize_t (*sendmsg) (struct lttcomm_sock *sock, const void *buf,
+                       size_t len, int flags);
+};
+
+struct process_attr_integral_value_comm {
+       union {
+               int64_t _signed;
+               uint64_t _unsigned;
+       } u;
+} LTTNG_PACKED;
+
+/*
+ * Data structure received from lttng client to session daemon.
+ */
+struct lttcomm_session_msg {
+       uint32_t cmd_type;      /* enum lttcomm_sessiond_command */
+       struct lttng_session session;
+       struct lttng_domain domain;
+       union {
+               /* Event data */
+               struct {
+                       char channel_name[LTTNG_SYMBOL_NAME_LEN];
+                       uint32_t length;
+               } LTTNG_PACKED enable;
+               struct {
+                       char channel_name[LTTNG_SYMBOL_NAME_LEN];
+                       uint32_t length;
+               } LTTNG_PACKED disable;
+               /* Create channel */
+               struct {
+                       uint32_t length;
+               } LTTNG_PACKED channel;
+               /* Context */
+               struct {
+                       char channel_name[LTTNG_SYMBOL_NAME_LEN];
+                       uint32_t length;
+               } LTTNG_PACKED context;
+               /* Use by register_consumer */
+               struct {
+                       char path[PATH_MAX];
+               } LTTNG_PACKED reg;
+               /* List */
+               struct {
+                       char channel_name[LTTNG_SYMBOL_NAME_LEN];
+               } LTTNG_PACKED list;
+               struct lttng_calibrate calibrate;
+               /* Used by the set_consumer_url and used by create_session also call */
+               struct {
+                       /* Number of lttng_uri following */
+                       uint32_t size;
+               } LTTNG_PACKED uri;
+               struct {
+                       struct lttng_snapshot_output output;
+               } LTTNG_PACKED snapshot_output;
+               struct {
+                       uint32_t wait;
+                       struct lttng_snapshot_output output;
+               } LTTNG_PACKED snapshot_record;
+               struct {
+                       uint32_t nb_uri;
+                       unsigned int timer_interval;    /* usec */
+               } LTTNG_PACKED session_live;
+               struct {
+                       struct lttng_save_session_attr attr;
+               } LTTNG_PACKED save_session;
+               struct {
+                       char shm_path[PATH_MAX];
+               } LTTNG_PACKED set_shm_path;
+               struct {
+                       /* enum lttng_process_attr */
+                       int32_t process_attr;
+                       /* enum lttng_process_attr_value_type */
+                       int32_t value_type;
+
+                       struct process_attr_integral_value_comm integral_value;
+                       /*
+                        * For user/group names, a variable length,
+                        * zero-terminated, string of length 'name_len'
+                        * (including the terminator) follows.
+                        *
+                        * integral_value should not be used in those cases.
+                        */
+                       uint32_t name_len;
+               } LTTNG_PACKED process_attr_tracker_add_remove_include_value;
+               struct {
+                       /* enum lttng_process_attr */
+                       int32_t process_attr;
+               } LTTNG_PACKED process_attr_tracker_get_inclusion_set;
+               struct {
+                       /* enum lttng_process_attr */
+                       int32_t process_attr;
+               } LTTNG_PACKED process_attr_tracker_get_tracking_policy;
+               struct {
+                       /* enum lttng_process_attr */
+                       int32_t process_attr;
+                       /* enum lttng_tracking_policy */
+                       int32_t tracking_policy;
+               } LTTNG_PACKED process_attr_tracker_set_tracking_policy;
+               struct {
+                       uint32_t length;
+                       uint8_t is_trigger_anonymous;
+               } LTTNG_PACKED trigger;
+               struct {
+                       uint32_t length;
+               } LTTNG_PACKED error_query;
+               struct {
+                       uint64_t rotation_id;
+               } LTTNG_PACKED get_rotation_info;
+               struct {
+                       /* enum lttng_rotation_schedule_type */
+                       uint8_t type;
+                       /*
+                        * If set == 1, set schedule to value, if set == 0,
+                        * clear this schedule type.
+                        */
+                       uint8_t set;
+                       uint64_t value;
+               } LTTNG_PACKED rotation_set_schedule;
+               struct {
+                       /*
+                        * Includes the null-terminator.
+                        * Must be an absolute path.
+                        *
+                        * Size bounded by LTTNG_PATH_MAX.
+                        */
+                       uint16_t home_dir_size;
+                       uint64_t session_descriptor_size;
+                       /* An lttng_session_descriptor follows. */
+               } LTTNG_PACKED create_session;
+       } u;
+       /* Count of fds sent. */
+       uint32_t fd_count;
+} LTTNG_PACKED;
+
+#define LTTNG_FILTER_MAX_LEN   65536
+#define LTTNG_SESSION_DESCRIPTOR_MAX_LEN       65536
+
+/*
+ * Filter bytecode data. The reloc table is located at the end of the
+ * bytecode. It is made of tuples: (uint16_t, var. len. string). It
+ * starts at reloc_table_offset.
+ */
+#define LTTNG_FILTER_PADDING   32
+struct lttng_bytecode {
+       uint32_t len;   /* len of data */
+       uint32_t reloc_table_offset;
+       uint64_t seqnum;
+       char padding[LTTNG_FILTER_PADDING];
+       char data[0];
+} LTTNG_PACKED;
+
+/*
+ * Event exclusion data. At the end of the structure, there will actually
+ * by zero or more names, where the actual number of names is given by
+ * the 'count' item of the structure.
+ */
+#define LTTNG_EVENT_EXCLUSION_PADDING  32
+struct lttng_event_exclusion {
+       uint32_t count;
+       char padding[LTTNG_EVENT_EXCLUSION_PADDING];
+       char names[][LTTNG_SYMBOL_NAME_LEN];
+} LTTNG_PACKED;
+
+#define LTTNG_EVENT_EXCLUSION_NAME_AT(_exclusion, _i) \
+       ((_exclusion)->names[_i])
+
+/*
+ * Listing command header.
+ */
+struct lttcomm_list_command_header {
+       /* Number of elements */
+       uint32_t count;
+} LTTNG_PACKED;
+
+/*
+ * Event extended info header. This is the structure preceding each
+ * extended info data.
+ */
+struct lttcomm_event_extended_header {
+       /*
+        * Size of filter string immediately following this header.
+        * This size includes the terminal null character.
+        */
+       uint32_t filter_len;
+
+       /*
+        * Number of exclusion names, immediately following the filter
+        * string. Each exclusion name has a fixed length of
+        * LTTNG_SYMBOL_NAME_LEN bytes, including the terminal null
+        * character.
+        */
+       uint32_t nb_exclusions;
+
+       /*
+        * Size of the event's userspace probe location (if applicable).
+        */
+       uint32_t userspace_probe_location_len;
+} LTTNG_PACKED;
+
+/*
+ * Command header of the reply to an LTTNG_DESTROY_SESSION command.
+ */
+struct lttcomm_session_destroy_command_header {
+       /* enum lttng_session */
+       int32_t rotation_state;
+};
+
+/*
+ * tracker command header.
+ */
+struct lttcomm_tracker_command_header {
+       uint32_t nb_tracker_id;
+} LTTNG_PACKED;
+
+/*
+ * Data structure for the response from sessiond to the lttng client.
+ */
+struct lttcomm_lttng_msg {
+       uint32_t cmd_type;      /* enum lttcomm_sessiond_command */
+       uint32_t ret_code;      /* enum lttcomm_return_code */
+       uint32_t pid;           /* pid_t */
+       uint32_t cmd_header_size;
+       uint32_t data_size;
+       uint32_t fd_count;
+} LTTNG_PACKED;
+
+struct lttcomm_lttng_output_id {
+       uint32_t id;
+} LTTNG_PACKED;
+
+/*
+ * lttcomm_consumer_msg is the message sent from sessiond to consumerd
+ * to either add a channel, add a stream, update a stream, or stop
+ * operation.
+ */
+struct lttcomm_consumer_msg {
+       uint32_t cmd_type;      /* enum lttng_consumer_command */
+       union {
+               struct {
+                       uint64_t channel_key;
+                       uint64_t session_id;
+                       /* ID of the session's current trace chunk. */
+                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED chunk_id;
+                       char pathname[PATH_MAX];
+                       uint64_t relayd_id;
+                       /* nb_init_streams is the number of streams open initially. */
+                       uint32_t nb_init_streams;
+                       char name[LTTNG_SYMBOL_NAME_LEN];
+                       /* Use splice or mmap to consume this fd */
+                       enum lttng_event_output output;
+                       int type; /* Per cpu or metadata. */
+                       uint64_t tracefile_size; /* bytes */
+                       uint32_t tracefile_count; /* number of tracefiles */
+                       /* If the channel's streams have to be monitored or not. */
+                       uint32_t monitor;
+                       /* timer to check the streams usage in live mode (usec). */
+                       unsigned int live_timer_interval;
+                       /* is part of a live session */
+                       uint8_t is_live;
+                       /* timer to sample a channel's positions (usec). */
+                       unsigned int monitor_timer_interval;
+               } LTTNG_PACKED channel; /* Only used by Kernel. */
+               struct {
+                       uint64_t stream_key;
+                       uint64_t channel_key;
+                       int32_t cpu;    /* On which CPU this stream is assigned. */
+                       /* Tells the consumer if the stream should be or not monitored. */
+                       uint32_t no_monitor;
+               } LTTNG_PACKED stream;  /* Only used by Kernel. */
+               struct {
+                       uint64_t net_index;
+                       enum lttng_stream_type type;
+                       uint32_t major;
+                       uint32_t minor;
+                       uint8_t relayd_socket_protocol;
+                       /* Tracing session id associated to the relayd. */
+                       uint64_t session_id;
+                       /* Relayd session id, only used with control socket. */
+                       uint64_t relayd_session_id;
+               } LTTNG_PACKED relayd_sock;
+               struct {
+                       uint64_t net_seq_idx;
+               } LTTNG_PACKED destroy_relayd;
+               struct {
+                       uint64_t session_id;
+               } LTTNG_PACKED data_pending;
+               struct {
+                       uint64_t subbuf_size;                   /* bytes */
+                       uint64_t num_subbuf;                    /* power of 2 */
+                       int32_t overwrite;                      /* 1: overwrite, 0: discard */
+                       uint32_t switch_timer_interval;         /* usec */
+                       uint32_t read_timer_interval;           /* usec */
+                       unsigned int live_timer_interval;       /* usec */
+                       uint8_t is_live;                        /* is part of a live session */
+                       uint32_t monitor_timer_interval;        /* usec */
+                       int32_t output;                         /* splice, mmap */
+                       int32_t type;                           /* metadata or per_cpu */
+                       uint64_t session_id;                    /* Tracing session id */
+                       char pathname[PATH_MAX];                /* Channel file path. */
+                       char name[LTTNG_SYMBOL_NAME_LEN];       /* Channel name. */
+                       /* Credentials used to open the UST buffer shared mappings. */
+                       struct {
+                               uint32_t uid;
+                               uint32_t gid;
+                       } LTTNG_PACKED buffer_credentials;
+                       uint64_t relayd_id;                     /* Relayd id if apply. */
+                       uint64_t key;                           /* Unique channel key. */
+                       /* ID of the session's current trace chunk. */
+                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED chunk_id;
+                       unsigned char uuid[LTTNG_UUID_LEN];     /* uuid for ust tracer. */
+                       uint32_t chan_id;                       /* Channel ID on the tracer side. */
+                       uint64_t tracefile_size;        /* bytes */
+                       uint32_t tracefile_count;       /* number of tracefiles */
+                       uint64_t session_id_per_pid;    /* Per-pid session ID. */
+                       /* Tells the consumer if the stream should be or not monitored. */
+                       uint32_t monitor;
+                       /*
+                        * For UST per UID buffers, this is the application UID of the
+                        * channel.  This can be different from the user UID requesting the
+                        * channel creation and used for the rights on the stream file
+                        * because the application can be in the tracing for instance.
+                        */
+                       uint32_t ust_app_uid;
+                       int64_t blocking_timeout;
+                       char root_shm_path[PATH_MAX];
+                       char shm_path[PATH_MAX];
+               } LTTNG_PACKED ask_channel;
+               struct {
+                       uint64_t key;
+               } LTTNG_PACKED get_channel;
+               struct {
+                       uint64_t key;
+               } LTTNG_PACKED destroy_channel;
+               struct {
+                       uint64_t key;   /* Metadata channel key. */
+                       uint64_t target_offset; /* Offset in the consumer */
+                       uint64_t len;   /* Length of metadata to be received. */
+                       uint64_t version; /* Version of the metadata. */
+               } LTTNG_PACKED push_metadata;
+               struct {
+                       uint64_t key;   /* Metadata channel key. */
+               } LTTNG_PACKED close_metadata;
+               struct {
+                       uint64_t key;   /* Metadata channel key. */
+               } LTTNG_PACKED setup_metadata;
+               struct {
+                       uint64_t key;   /* Channel key. */
+               } LTTNG_PACKED flush_channel;
+               struct {
+                       uint64_t key;   /* Channel key. */
+               } LTTNG_PACKED clear_quiescent_channel;
+               struct {
+                       char pathname[PATH_MAX];
+                       /* Indicate if the snapshot goes on the relayd or locally. */
+                       uint32_t use_relayd;
+                       uint32_t metadata;              /* This a metadata snapshot. */
+                       uint64_t relayd_id;             /* Relayd id if apply. */
+                       uint64_t key;
+                       uint64_t nb_packets_per_stream;
+               } LTTNG_PACKED snapshot_channel;
+               struct {
+                       uint64_t channel_key;
+                       uint64_t net_seq_idx;
+               } LTTNG_PACKED sent_streams;
+               struct {
+                       uint64_t session_id;
+                       uint64_t channel_key;
+               } LTTNG_PACKED discarded_events;
+               struct {
+                       uint64_t session_id;
+                       uint64_t channel_key;
+               } LTTNG_PACKED lost_packets;
+               struct {
+                       uint64_t session_id;
+               } LTTNG_PACKED regenerate_metadata;
+               struct {
+                       uint32_t metadata; /* This is a metadata channel. */
+                       uint64_t relayd_id; /* Relayd id if apply. */
+                       uint64_t key;
+               } LTTNG_PACKED rotate_channel;
+               struct {
+                       uint64_t session_id;
+                       uint64_t chunk_id;
+               } LTTNG_PACKED check_rotation_pending_local;
+               struct {
+                       uint64_t relayd_id;
+                       uint64_t session_id;
+                       uint64_t chunk_id;
+               } LTTNG_PACKED check_rotation_pending_relay;
+               struct {
+                       /*
+                        * Relayd id, if applicable (remote).
+                        *
+                        * A directory file descriptor referring to the chunk's
+                        * output folder is transmitted if the chunk is local
+                        * (relayd_id unset).
+                        *
+                        * `override_name` is left NULL (all-zeroes) if the
+                        * chunk's name is not overridden.
+                        */
+                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
+                       char override_name[LTTNG_NAME_MAX];
+                       uint64_t session_id;
+                       uint64_t chunk_id;
+                       uint64_t creation_timestamp;
+                       LTTNG_OPTIONAL_COMM(struct {
+                               uint32_t uid;
+                               uint32_t gid;
+                       } LTTNG_PACKED ) LTTNG_PACKED credentials;
+               } LTTNG_PACKED create_trace_chunk;
+               struct {
+                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
+                       uint64_t session_id;
+                       uint64_t chunk_id;
+                       uint64_t close_timestamp;
+                       /* enum lttng_trace_chunk_command_type */
+                       LTTNG_OPTIONAL_COMM(uint32_t) LTTNG_PACKED close_command;
+               } LTTNG_PACKED close_trace_chunk;
+               struct {
+                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
+                       uint64_t session_id;
+                       uint64_t chunk_id;
+               } LTTNG_PACKED trace_chunk_exists;
+               struct {
+                       lttng_uuid sessiond_uuid;
+               } LTTNG_PACKED init;
+               struct {
+                       uint64_t key;
+               } LTTNG_PACKED clear_channel;
+               struct {
+                       uint64_t key;
+               } LTTNG_PACKED open_channel_packets;
+       } u;
+} LTTNG_PACKED;
+
+/*
+ * Channel monitoring message returned to the session daemon on every
+ * monitor timer expiration.
+ */
+struct lttcomm_consumer_channel_monitor_msg {
+       /* Key of the sampled channel. */
+       uint64_t key;
+       /*
+        * Lowest and highest usage (bytes) at the moment the sample was taken.
+        */
+       uint64_t lowest, highest;
+       /*
+        * Sum of all the consumed positions for a channel.
+        */
+       uint64_t total_consumed;
+} LTTNG_PACKED;
+
+/*
+ * Status message returned to the sessiond after a received command.
+ */
+struct lttcomm_consumer_status_msg {
+       enum lttcomm_return_code ret_code;
+} LTTNG_PACKED;
+
+struct lttcomm_consumer_status_channel {
+       enum lttcomm_return_code ret_code;
+       uint64_t key;
+       unsigned int stream_count;
+} LTTNG_PACKED;
+
+struct lttcomm_consumer_close_trace_chunk_reply {
+       enum lttcomm_return_code ret_code;
+       uint32_t path_length;
+       char path[];
+};
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+#include <lttng/ust-abi.h>
+
+/*
+ * Data structure for the commands sent from sessiond to UST.
+ */
+struct lttcomm_ust_msg {
+       uint32_t handle;
+       uint32_t cmd;
+       union {
+               struct lttng_ust_abi_channel channel;
+               struct lttng_ust_abi_stream stream;
+               struct lttng_ust_abi_event event;
+               struct lttng_ust_abi_context context;
+               struct lttng_ust_abi_tracer_version version;
+       } u;
+} LTTNG_PACKED;
+
+/*
+ * Data structure for the response from UST to the session daemon.
+ * cmd_type is sent back in the reply for validation.
+ */
+struct lttcomm_ust_reply {
+       uint32_t handle;
+       uint32_t cmd;
+       uint32_t ret_code;      /* enum lttcomm_return_code */
+       uint32_t ret_val;       /* return value */
+       union {
+               struct {
+                       uint64_t memory_map_size;
+               } LTTNG_PACKED channel;
+               struct {
+                       uint64_t memory_map_size;
+               } LTTNG_PACKED stream;
+               struct lttng_ust_abi_tracer_version version;
+       } u;
+} LTTNG_PACKED;
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
+
+int lttcomm_init_inet_sockaddr(struct lttcomm_sockaddr *sockaddr,
+               const char *ip, unsigned int port);
+int lttcomm_init_inet6_sockaddr(struct lttcomm_sockaddr *sockaddr,
+               const char *ip, unsigned int port);
+
+struct lttcomm_sock *lttcomm_alloc_sock(enum lttcomm_sock_proto proto);
+int lttcomm_populate_sock_from_open_socket(struct lttcomm_sock *sock,
+               int fd,
+               enum lttcomm_sock_proto protocol);
+int lttcomm_create_sock(struct lttcomm_sock *sock);
+struct lttcomm_sock *lttcomm_alloc_sock_from_uri(struct lttng_uri *uri);
+void lttcomm_destroy_sock(struct lttcomm_sock *sock);
+struct lttcomm_sock *lttcomm_alloc_copy_sock(struct lttcomm_sock *src);
+void lttcomm_copy_sock(struct lttcomm_sock *dst,
+               struct lttcomm_sock *src);
+
+/* Relayd socket object. */
+struct lttcomm_relayd_sock *lttcomm_alloc_relayd_sock(
+               struct lttng_uri *uri, uint32_t major, uint32_t minor);
+
+int lttcomm_setsockopt_rcv_timeout(int sock, unsigned int msec);
+int lttcomm_setsockopt_snd_timeout(int sock, unsigned int msec);
+
+int lttcomm_sock_get_port(const struct lttcomm_sock *sock,
+               uint16_t *port);
+/*
+ * Set a port to an lttcomm_sock. This will have no effect is the socket is
+ * already bound.
+ */
+int lttcomm_sock_set_port(struct lttcomm_sock *sock, uint16_t port);
+
+void lttcomm_init(void);
+/* Get network timeout, in milliseconds */
+unsigned long lttcomm_get_network_timeout(void);
+
+#endif /* _LTTNG_SESSIOND_COMM_H */
index f1793d7a7d280701b0235e497dc03a101b04d7cc..e3fa9b6404c3ad6f85d99293f664aeac9aebefb9 100644 (file)
@@ -16,9 +16,9 @@
 #include <unistd.h>
 #include <urcu.h>
 
-#include <common/error.h>
+#include <common/error.hpp>
 
-#include "shm.h"
+#include "shm.hpp"
 
 /*
  * Using fork to set umask in the child process (not multi-thread safe). We
diff --git a/src/common/shm.h b/src/common/shm.h
deleted file mode 100644 (file)
index 76c8148..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_SHM_H
-#define _LTT_SHM_H
-
-char *shm_ust_get_mmap(char *shm_path, int global);
-
-int shm_create_anonymous(const char *owner_name);
-
-#endif /* _LTT_SHM_H */
diff --git a/src/common/shm.hpp b/src/common/shm.hpp
new file mode 100644 (file)
index 0000000..76c8148
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_SHM_H
+#define _LTT_SHM_H
+
+char *shm_ust_get_mmap(char *shm_path, int global);
+
+int shm_create_anonymous(const char *owner_name);
+
+#endif /* _LTT_SHM_H */
index 5145dd120707dadee4b8e6c26c8e8d79dc7bf8d7..618196dd86f02b30f46f207cb95653bf8c3a86a7 100644 (file)
@@ -5,12 +5,12 @@
  *
  */
 
-#include <common/error.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/snapshot.h>
-#include <lttng/snapshot-internal.h>
+#include <common/error.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/snapshot.hpp>
+#include <lttng/snapshot-internal.hpp>
 #include <lttng/snapshot.h>
 
 #include <stdlib.h>
diff --git a/src/common/snapshot.h b/src/common/snapshot.h
deleted file mode 100644 (file)
index 56f3508..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2020 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef COMMON_SNAPSHOT_H
-#define COMMON_SNAPSHOT_H
-
-#include <common/macros.h>
-
-#include <stdbool.h>
-#include <sys/types.h>
-
-struct lttng_payload_view;
-struct lttng_payload;
-struct lttng_snapshot_output;
-struct mi_writer;
-
-bool lttng_snapshot_output_validate(const struct lttng_snapshot_output *output);
-
-bool lttng_snapshot_output_is_equal(
-               const struct lttng_snapshot_output *a,
-               const struct lttng_snapshot_output *b);
-
-int lttng_snapshot_output_serialize(
-               const struct lttng_snapshot_output *output,
-               struct lttng_payload *payload);
-
-ssize_t lttng_snapshot_output_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_snapshot_output **output_p);
-
-enum lttng_error_code lttng_snapshot_output_mi_serialize(
-               const struct lttng_snapshot_output *output,
-               struct mi_writer *writer);
-
-#endif /* COMMON_SNAPSHOT_H */
diff --git a/src/common/snapshot.hpp b/src/common/snapshot.hpp
new file mode 100644 (file)
index 0000000..d744215
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef COMMON_SNAPSHOT_H
+#define COMMON_SNAPSHOT_H
+
+#include <common/macros.hpp>
+
+#include <stdbool.h>
+#include <sys/types.h>
+
+struct lttng_payload_view;
+struct lttng_payload;
+struct lttng_snapshot_output;
+struct mi_writer;
+
+bool lttng_snapshot_output_validate(const struct lttng_snapshot_output *output);
+
+bool lttng_snapshot_output_is_equal(
+               const struct lttng_snapshot_output *a,
+               const struct lttng_snapshot_output *b);
+
+int lttng_snapshot_output_serialize(
+               const struct lttng_snapshot_output *output,
+               struct lttng_payload *payload);
+
+ssize_t lttng_snapshot_output_create_from_payload(
+               struct lttng_payload_view *view,
+               struct lttng_snapshot_output **output_p);
+
+enum lttng_error_code lttng_snapshot_output_mi_serialize(
+               const struct lttng_snapshot_output *output,
+               struct mi_writer *writer);
+
+#endif /* COMMON_SNAPSHOT_H */
index e7d2ca02dcfc24586f41ca68bf0527dafcfef4c2..fe11587130be8961da27c4e0484dab8d328bfd9e 100644 (file)
 
 #include <lttng/constant.h>
 
-#include <common/compat/errno.h>
-#include "error.h"
-#include "macros.h"
-#include "spawn-viewer.h"
+#include <common/compat/errno.hpp>
+#include "error.hpp"
+#include "macros.hpp"
+#include "spawn-viewer.hpp"
 
 
 static const char *babeltrace_bin = CONFIG_BABELTRACE_BIN;
diff --git a/src/common/spawn-viewer.h b/src/common/spawn-viewer.h
deleted file mode 100644 (file)
index 4c2fe02..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef LTTNG_SPAWN_VIEWER_H
-#define LTTNG_SPAWN_VIEWER_H
-
-/*
- * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <lttng/lttng-export.h>
-#include <stdbool.h>
-
-/*
- * Read the trace by `exec()ing` the provided viewer program if any. If
- * `opt_viewer` is NULL, try to read the trace with the default trace reader.
- * On success, this function doesn't return.
- * Returns -1 if the `opt_viewer` string or the default trace viewer can't be
- * `exec()`.
- *
- * This symbol was mistakenly made public before the 2.12 release. It can't
- * be removed (but it can be stubbed-out if necessary).
- */
-extern "C" LTTNG_EXPORT
-int spawn_viewer(const char *trace_path, char *opt_viewer, bool opt_live_mode);
-
-#endif /* ifndef LTTNG_SPAWN_VIEWER_H */
diff --git a/src/common/spawn-viewer.hpp b/src/common/spawn-viewer.hpp
new file mode 100644 (file)
index 0000000..4c2fe02
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef LTTNG_SPAWN_VIEWER_H
+#define LTTNG_SPAWN_VIEWER_H
+
+/*
+ * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <lttng/lttng-export.h>
+#include <stdbool.h>
+
+/*
+ * Read the trace by `exec()ing` the provided viewer program if any. If
+ * `opt_viewer` is NULL, try to read the trace with the default trace reader.
+ * On success, this function doesn't return.
+ * Returns -1 if the `opt_viewer` string or the default trace viewer can't be
+ * `exec()`.
+ *
+ * This symbol was mistakenly made public before the 2.12 release. It can't
+ * be removed (but it can be stubbed-out if necessary).
+ */
+extern "C" LTTNG_EXPORT
+int spawn_viewer(const char *trace_path, char *opt_viewer, bool opt_live_mode);
+
+#endif /* ifndef LTTNG_SPAWN_VIEWER_H */
diff --git a/src/common/string-utils/format.h b/src/common/string-utils/format.h
deleted file mode 100644 (file)
index 2446523..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _STRING_UTILS_FORMAT_H
-#define _STRING_UTILS_FORMAT_H
-
-/*
- * Maximal length of `val` when formatted in decimal.
- *
- * Note that this is an upper bound that can exceed the length
- * required to hold the largest textual value of `val`. Note that this length
- * assumes that no grouping/locale-aware formatting is performed (i.e. using
- * the `'` specifier in POSIX formatting functions).
- */
-#define MAX_INT_DEC_LEN(val)       ((3 * sizeof(val)) + 2)
-
-#endif /* _STRING_UTILS_FORMAT_H */
diff --git a/src/common/string-utils/format.hpp b/src/common/string-utils/format.hpp
new file mode 100644 (file)
index 0000000..2446523
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _STRING_UTILS_FORMAT_H
+#define _STRING_UTILS_FORMAT_H
+
+/*
+ * Maximal length of `val` when formatted in decimal.
+ *
+ * Note that this is an upper bound that can exceed the length
+ * required to hold the largest textual value of `val`. Note that this length
+ * assumes that no grouping/locale-aware formatting is performed (i.e. using
+ * the `'` specifier in POSIX formatting functions).
+ */
+#define MAX_INT_DEC_LEN(val)       ((3 * sizeof(val)) + 2)
+
+#endif /* _STRING_UTILS_FORMAT_H */
index c2a508dd134c239dba27a7f0b94f8a179408ae0b..5cfcef2566fec7f3bf5173eb176ddab8cf1735d5 100644 (file)
@@ -15,8 +15,8 @@
 #include <errno.h>
 #include <stdarg.h>
 
-#include "string-utils.h"
-#include "../macros.h"
+#include "string-utils.hpp"
+#include "../macros.hpp"
 
 enum star_glob_pattern_type_flags {
        STAR_GLOB_PATTERN_TYPE_FLAG_NONE = 0,
diff --git a/src/common/string-utils/string-utils.h b/src/common/string-utils/string-utils.h
deleted file mode 100644 (file)
index 3cafa0f..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _STRING_UTILS_H
-#define _STRING_UTILS_H
-
-#include <stdbool.h>
-#include <common/macros.h>
-#include <common/dynamic-array.h>
-
-void strutils_normalize_star_glob_pattern(char *pattern);
-
-bool strutils_is_star_glob_pattern(const char *pattern);
-
-bool strutils_is_star_at_the_end_only_glob_pattern(const char *pattern);
-
-char *strutils_unescape_string(const char *input, char only_char);
-
-int strutils_split(const char *input, char delim, bool escape_delim,
-               struct lttng_dynamic_pointer_array *out_strings);
-
-void strutils_free_null_terminated_array_of_strings(char **array);
-
-size_t strutils_array_of_strings_len(char * const *array);
-
-/*
- * Append `append` to the malloc-end string `str`.
- *
- * On success, `str` is free'd (if not NULL) and assigned a new malloc-ed
- * string.  On failure, `str` is not modified.
- *
- * Return 0 on success, -ENOMEM on failure.
- */
-C_LINKAGE int strutils_append_str(char **str, const char *append);
-
-/*
- * Like `strutils_append_str`, but the appended string is formatted using
- * `fmt` and the following arguments.
- */
-C_LINKAGE ATTR_FORMAT_PRINTF(2, 3)
-int strutils_appendf(char **s, const char *fmt, ...);
-
-#endif /* _STRING_UTILS_H */
diff --git a/src/common/string-utils/string-utils.hpp b/src/common/string-utils/string-utils.hpp
new file mode 100644 (file)
index 0000000..4be165f
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _STRING_UTILS_H
+#define _STRING_UTILS_H
+
+#include <stdbool.h>
+#include <common/macros.hpp>
+#include <common/dynamic-array.hpp>
+
+void strutils_normalize_star_glob_pattern(char *pattern);
+
+bool strutils_is_star_glob_pattern(const char *pattern);
+
+bool strutils_is_star_at_the_end_only_glob_pattern(const char *pattern);
+
+char *strutils_unescape_string(const char *input, char only_char);
+
+int strutils_split(const char *input, char delim, bool escape_delim,
+               struct lttng_dynamic_pointer_array *out_strings);
+
+void strutils_free_null_terminated_array_of_strings(char **array);
+
+size_t strutils_array_of_strings_len(char * const *array);
+
+/*
+ * Append `append` to the malloc-end string `str`.
+ *
+ * On success, `str` is free'd (if not NULL) and assigned a new malloc-ed
+ * string.  On failure, `str` is not modified.
+ *
+ * Return 0 on success, -ENOMEM on failure.
+ */
+C_LINKAGE int strutils_append_str(char **str, const char *append);
+
+/*
+ * Like `strutils_append_str`, but the appended string is formatted using
+ * `fmt` and the following arguments.
+ */
+C_LINKAGE ATTR_FORMAT_PRINTF(2, 3)
+int strutils_appendf(char **s, const char *fmt, ...);
+
+#endif /* _STRING_UTILS_H */
index c70245894e347dc27f9a9b20128d655db4f663f4..4dfeadd81eb9aad643d31b5200f0d59e38e5e921 100644 (file)
@@ -12,7 +12,7 @@
 #include <stdlib.h> /* for getenv  */
 #include <string.h> /* for strncmp */
 
-#include "testpoint.h"
+#include "testpoint.hpp"
 
 /* Environment variable used to enable the testpoints facilities. */
 static const char *lttng_testpoint_env_var = "LTTNG_TESTPOINT_ENABLE";
diff --git a/src/common/testpoint/testpoint.h b/src/common/testpoint/testpoint.h
deleted file mode 100644 (file)
index 33cb9aa..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifdef NTESTPOINT
-
-#define testpoint(name)
-#define TESTPOINT_DECL(name)
-
-#else /* NTESTPOINT */
-
-#include <urcu.h> /* for caa_likely/unlikely */
-
-extern int lttng_testpoint_activated;
-
-void *lttng_testpoint_lookup(const char *name);
-
-/*
- * Testpoint is only active if the global lttng_testpoint_activated flag is
- * set.
- * Return a non-zero error code to indicate failure.
- */
-#define testpoint(name)                                \
-       ((caa_unlikely(lttng_testpoint_activated))      \
-       ? __testpoint_##name##_wrapper() : 0)
-
-/*
- * One wrapper per testpoint is generated. This is to keep track of the symbol
- * lookup status and the corresponding function pointer, if any.
- */
-#define _TESTPOINT_DECL(_name)                                         \
-       static inline int __testpoint_##_name##_wrapper(void)           \
-       {                                                               \
-               int ret = 0;                                            \
-               static int (*tp)(void);                                 \
-               static int found;                                       \
-               const char *tp_name = "__testpoint_" #_name;            \
-                                                                       \
-               if (tp) {                                               \
-                       ret = tp();                                     \
-               } else {                                                \
-                       if (!found) {                                   \
-                               tp = (int (*)(void)) lttng_testpoint_lookup(tp_name);   \
-                               if (tp) {                               \
-                                       found = 1;                      \
-                                       ret = tp();                     \
-                               } else {                                \
-                                       found = -1;                     \
-                               }                                       \
-                       }                                               \
-               }                                                       \
-               return ret;                                             \
-       }
-
-/* Testpoint declaration */
-#define TESTPOINT_DECL(name)   \
-       _TESTPOINT_DECL(name)
-
-#endif /* NTESTPOINT */
diff --git a/src/common/testpoint/testpoint.hpp b/src/common/testpoint/testpoint.hpp
new file mode 100644 (file)
index 0000000..33cb9aa
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifdef NTESTPOINT
+
+#define testpoint(name)
+#define TESTPOINT_DECL(name)
+
+#else /* NTESTPOINT */
+
+#include <urcu.h> /* for caa_likely/unlikely */
+
+extern int lttng_testpoint_activated;
+
+void *lttng_testpoint_lookup(const char *name);
+
+/*
+ * Testpoint is only active if the global lttng_testpoint_activated flag is
+ * set.
+ * Return a non-zero error code to indicate failure.
+ */
+#define testpoint(name)                                \
+       ((caa_unlikely(lttng_testpoint_activated))      \
+       ? __testpoint_##name##_wrapper() : 0)
+
+/*
+ * One wrapper per testpoint is generated. This is to keep track of the symbol
+ * lookup status and the corresponding function pointer, if any.
+ */
+#define _TESTPOINT_DECL(_name)                                         \
+       static inline int __testpoint_##_name##_wrapper(void)           \
+       {                                                               \
+               int ret = 0;                                            \
+               static int (*tp)(void);                                 \
+               static int found;                                       \
+               const char *tp_name = "__testpoint_" #_name;            \
+                                                                       \
+               if (tp) {                                               \
+                       ret = tp();                                     \
+               } else {                                                \
+                       if (!found) {                                   \
+                               tp = (int (*)(void)) lttng_testpoint_lookup(tp_name);   \
+                               if (tp) {                               \
+                                       found = 1;                      \
+                                       ret = tp();                     \
+                               } else {                                \
+                                       found = -1;                     \
+                               }                                       \
+                       }                                               \
+               }                                                       \
+               return ret;                                             \
+       }
+
+/* Testpoint declaration */
+#define TESTPOINT_DECL(name)   \
+       _TESTPOINT_DECL(name)
+
+#endif /* NTESTPOINT */
index 34a620679d258a1e72035416f67ed85310473ba4..fecc0064dbca83358dd65dfb559a1d8cca2e16bf 100644 (file)
@@ -7,8 +7,8 @@
 
 #include <string.h>
 
-#include <common/compat/pthread.h>
-#include "thread.h"
+#include <common/compat/pthread.hpp>
+#include "thread.hpp"
 
 
 int lttng_thread_setname(const char *name)
diff --git a/src/common/thread.h b/src/common/thread.h
deleted file mode 100644 (file)
index 3caa9dd..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_THREAD_H
-#define LTTNG_THREAD_H
-
-#include <common/macros.h>
-
-/*
- * Set the current thread name on platforms that support it. The name can
- * be of arbitrary length and will be truncated to the platform limit,
- * usually 16.
- */
-int lttng_thread_setname(const char *name);
-
-#endif /* LTTNG_THREAD_H */
diff --git a/src/common/thread.hpp b/src/common/thread.hpp
new file mode 100644 (file)
index 0000000..3d4e7bd
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_THREAD_H
+#define LTTNG_THREAD_H
+
+#include <common/macros.hpp>
+
+/*
+ * Set the current thread name on platforms that support it. The name can
+ * be of arbitrary length and will be truncated to the platform limit,
+ * usually 16.
+ */
+int lttng_thread_setname(const char *name);
+
+#endif /* LTTNG_THREAD_H */
index 57078331c4f31add87924b0b0d80814a053618d5..7149912468d2c9d7a6acd41d41e13fe9eed92e90 100644 (file)
@@ -5,11 +5,11 @@
  *
  */
 
-#include <common/time.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/error.h>
-#include <common/compat/errno.h>
+#include <common/time.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/error.hpp>
+#include <common/compat/errno.hpp>
 #include <stddef.h>
 #include <stdint.h>
 #include <limits.h>
diff --git a/src/common/time.h b/src/common/time.h
deleted file mode 100644 (file)
index 87adf17..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-or-later
- *
- */
-
-#ifndef LTTNG_TIME_H
-#define LTTNG_TIME_H
-
-#include <time.h>
-#include <stdbool.h>
-#include <common/macros.h>
-#include <common/compat/time.h>
-
-#define MSEC_PER_SEC    1000ULL
-#define NSEC_PER_SEC    1000000000ULL
-#define NSEC_PER_MSEC   1000000ULL
-#define NSEC_PER_USEC   1000ULL
-#define USEC_PER_SEC    1000000ULL
-#define USEC_PER_MSEC   1000ULL
-
-#define SEC_PER_MINUTE  60ULL
-#define MINUTE_PER_HOUR 60ULL
-
-#define USEC_PER_MINUTE (USEC_PER_SEC * SEC_PER_MINUTE)
-#define USEC_PER_HOURS  (USEC_PER_MINUTE * MINUTE_PER_HOUR)
-
-#define ISO8601_STR_LEN sizeof("YYYYmmddTHHMMSS+HHMM")
-#define DATETIME_STR_LEN sizeof("YYYYmmdd-HHMMSS")
-
-bool locale_supports_utf8(void);
-
-#define NSEC_UNIT       "ns"
-#define USEC_UNIT       (locale_supports_utf8() ? "µs" : "us")
-#define MSEC_UNIT       "ms"
-#define SEC_UNIT        "s"
-#define MIN_UNIT        "m"
-#define HR_UNIT         "h"
-
-/*
- * timespec_to_ms: Convert timespec to milliseconds.
- *
- * Returns 0 on success, else -1 on error. errno is set to EOVERFLOW if
- * input would overflow the output in milliseconds.
- */
-int timespec_to_ms(struct timespec ts, unsigned long *ms);
-
-/*
- * timespec_abs_diff: Absolute difference between timespec.
- */
-struct timespec timespec_abs_diff(struct timespec ts_a, struct timespec ts_b);
-
-/*
- * Format a Unix timestamp to an ISO 8601 compatible timestamp of
- * the form "YYYYmmddTHHMMSS+HHMM" in local time. `len` must >= to
- * ISO8601_STR_LEN.
- *
- * Returns 0 on success, else -1 on error.
- */
-int time_to_iso8601_str(time_t time, char *str, size_t len);
-
-int time_to_datetime_str(time_t time, char *str, size_t len);
-
-#endif /* LTTNG_TIME_H */
diff --git a/src/common/time.hpp b/src/common/time.hpp
new file mode 100644 (file)
index 0000000..724b202
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ */
+
+#ifndef LTTNG_TIME_H
+#define LTTNG_TIME_H
+
+#include <time.h>
+#include <stdbool.h>
+#include <common/macros.hpp>
+#include <common/compat/time.hpp>
+
+#define MSEC_PER_SEC    1000ULL
+#define NSEC_PER_SEC    1000000000ULL
+#define NSEC_PER_MSEC   1000000ULL
+#define NSEC_PER_USEC   1000ULL
+#define USEC_PER_SEC    1000000ULL
+#define USEC_PER_MSEC   1000ULL
+
+#define SEC_PER_MINUTE  60ULL
+#define MINUTE_PER_HOUR 60ULL
+
+#define USEC_PER_MINUTE (USEC_PER_SEC * SEC_PER_MINUTE)
+#define USEC_PER_HOURS  (USEC_PER_MINUTE * MINUTE_PER_HOUR)
+
+#define ISO8601_STR_LEN sizeof("YYYYmmddTHHMMSS+HHMM")
+#define DATETIME_STR_LEN sizeof("YYYYmmdd-HHMMSS")
+
+bool locale_supports_utf8(void);
+
+#define NSEC_UNIT       "ns"
+#define USEC_UNIT       (locale_supports_utf8() ? "µs" : "us")
+#define MSEC_UNIT       "ms"
+#define SEC_UNIT        "s"
+#define MIN_UNIT        "m"
+#define HR_UNIT         "h"
+
+/*
+ * timespec_to_ms: Convert timespec to milliseconds.
+ *
+ * Returns 0 on success, else -1 on error. errno is set to EOVERFLOW if
+ * input would overflow the output in milliseconds.
+ */
+int timespec_to_ms(struct timespec ts, unsigned long *ms);
+
+/*
+ * timespec_abs_diff: Absolute difference between timespec.
+ */
+struct timespec timespec_abs_diff(struct timespec ts_a, struct timespec ts_b);
+
+/*
+ * Format a Unix timestamp to an ISO 8601 compatible timestamp of
+ * the form "YYYYmmddTHHMMSS+HHMM" in local time. `len` must >= to
+ * ISO8601_STR_LEN.
+ *
+ * Returns 0 on success, else -1 on error.
+ */
+int time_to_iso8601_str(time_t time, char *str, size_t len);
+
+int time_to_datetime_str(time_t time, char *str, size_t len);
+
+#endif /* LTTNG_TIME_H */
diff --git a/src/common/trace-chunk-registry.h b/src/common/trace-chunk-registry.h
deleted file mode 100644 (file)
index 5442d79..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_TRACE_CHUNK_REGISTRY_H
-#define LTTNG_TRACE_CHUNK_REGISTRY_H
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <common/macros.h>
-#include <common/trace-chunk.h>
-
-struct lttng_trace_chunk_registry;
-
-/*
- * Create an lttng_trace_chunk registry.
- *
- * A trace chunk registry maintains an association between a
- * (session_id, chunk_id) tuple and a trace chunk object. The chunk_id can
- * be "unset" in the case of an anonymous trace chunk.
- *
- * Note that a trace chunk registry holds no ownership of its trace
- * chunks. Trace chunks are unpublished when their last reference is released.
- * See the documentation of lttng_trace_chunk.
- *
- * Returns a trace chunk registry on success, NULL on error.
- *
- * Note that a trace chunk registry may only be accessed by an RCU thread.
- */
-struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create(void);
-
-/*
- * Destroy an lttng trace chunk registry. The registry must be emptied
- * (i.e. all references to the trace chunks it contains must be released) before
- * it is destroyed.
- */
-void lttng_trace_chunk_registry_destroy(
-               struct lttng_trace_chunk_registry *registry);
-
-/*
- * Publish a trace chunk for a given session id.
- * A reference is acquired on behalf of the caller.
- *
- * The trace chunk that is returned is the published version of the trace
- * chunk. The chunk provided should be discarded on success and it's
- * published version used in its place.
- *
- * See the documentation of lttng_trace_chunk for more information on
- * the usage of the various parameters.
- *
- * Returns an lttng_trace_chunk on success, NULL on error.
- */
-struct lttng_trace_chunk *lttng_trace_chunk_registry_publish_chunk(
-               struct lttng_trace_chunk_registry *registry,
-               uint64_t session_id, struct lttng_trace_chunk *chunk);
-/*
- * Adds the `previously_published` parameter which allows the caller
- * to know if a trace chunk equivalent to `chunk` was previously published.
- * 
- * The registry holds a reference to the published trace chunks it contains.
- * Trace chunks automatically unpublish themselves from their registry on
- * destruction.
- *
- * This information is necessary to drop the reference of newly published
- * chunks when a user doesn't wish to explicitly maintain all references
- * to a given trace chunk.
- * 
- * For instance, the relay daemon doesn't need the registry to hold a
- * reference since it controls the lifetime of its trace chunks.
- * Conversely, the consumer daemons rely on the session daemon to inform
- * them of the end of life of a trace chunk and the trace chunks don't
- * belong to a specific top-level object: they are always retrieved from
- * the registry by `id`.
- */
-struct lttng_trace_chunk *lttng_trace_chunk_registry_publish_chunk(
-               struct lttng_trace_chunk_registry *registry,
-               uint64_t session_id, struct lttng_trace_chunk *chunk,
-               bool *previously_published);
-
-/*
- * Look-up a trace chunk by session_id and chunk_id.
- * A reference is acquired on behalf of the caller.
- *
- * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
- */
-struct lttng_trace_chunk *
-lttng_trace_chunk_registry_find_chunk(
-               const struct lttng_trace_chunk_registry *registry,
-               uint64_t session_id, uint64_t chunk_id);
-
-/*
- * Query the existence of a trace chunk by session_id and chunk_id.
- *
- * Returns 0 on success, a negative value on error.
- */
-int lttng_trace_chunk_registry_chunk_exists(
-               const struct lttng_trace_chunk_registry *registry,
-               uint64_t session_id, uint64_t chunk_id, bool *chunk_exists);
-
-/*
- * Look-up an anonymous trace chunk by session_id.
- * A reference is acquired on behalf of the caller.
- *
- * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
- */
-struct lttng_trace_chunk *
-lttng_trace_chunk_registry_find_anonymous_chunk(
-               const struct lttng_trace_chunk_registry *registry,
-               uint64_t session_id);
-
-unsigned int lttng_trace_chunk_registry_put_each_chunk(
-               const struct lttng_trace_chunk_registry *registry);
-
-#endif /* LTTNG_TRACE_CHUNK_REGISTRY_H */
diff --git a/src/common/trace-chunk-registry.hpp b/src/common/trace-chunk-registry.hpp
new file mode 100644 (file)
index 0000000..e634e71
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_TRACE_CHUNK_REGISTRY_H
+#define LTTNG_TRACE_CHUNK_REGISTRY_H
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <common/macros.hpp>
+#include <common/trace-chunk.hpp>
+
+struct lttng_trace_chunk_registry;
+
+/*
+ * Create an lttng_trace_chunk registry.
+ *
+ * A trace chunk registry maintains an association between a
+ * (session_id, chunk_id) tuple and a trace chunk object. The chunk_id can
+ * be "unset" in the case of an anonymous trace chunk.
+ *
+ * Note that a trace chunk registry holds no ownership of its trace
+ * chunks. Trace chunks are unpublished when their last reference is released.
+ * See the documentation of lttng_trace_chunk.
+ *
+ * Returns a trace chunk registry on success, NULL on error.
+ *
+ * Note that a trace chunk registry may only be accessed by an RCU thread.
+ */
+struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create(void);
+
+/*
+ * Destroy an lttng trace chunk registry. The registry must be emptied
+ * (i.e. all references to the trace chunks it contains must be released) before
+ * it is destroyed.
+ */
+void lttng_trace_chunk_registry_destroy(
+               struct lttng_trace_chunk_registry *registry);
+
+/*
+ * Publish a trace chunk for a given session id.
+ * A reference is acquired on behalf of the caller.
+ *
+ * The trace chunk that is returned is the published version of the trace
+ * chunk. The chunk provided should be discarded on success and it's
+ * published version used in its place.
+ *
+ * See the documentation of lttng_trace_chunk for more information on
+ * the usage of the various parameters.
+ *
+ * Returns an lttng_trace_chunk on success, NULL on error.
+ */
+struct lttng_trace_chunk *lttng_trace_chunk_registry_publish_chunk(
+               struct lttng_trace_chunk_registry *registry,
+               uint64_t session_id, struct lttng_trace_chunk *chunk);
+/*
+ * Adds the `previously_published` parameter which allows the caller
+ * to know if a trace chunk equivalent to `chunk` was previously published.
+ * 
+ * The registry holds a reference to the published trace chunks it contains.
+ * Trace chunks automatically unpublish themselves from their registry on
+ * destruction.
+ *
+ * This information is necessary to drop the reference of newly published
+ * chunks when a user doesn't wish to explicitly maintain all references
+ * to a given trace chunk.
+ * 
+ * For instance, the relay daemon doesn't need the registry to hold a
+ * reference since it controls the lifetime of its trace chunks.
+ * Conversely, the consumer daemons rely on the session daemon to inform
+ * them of the end of life of a trace chunk and the trace chunks don't
+ * belong to a specific top-level object: they are always retrieved from
+ * the registry by `id`.
+ */
+struct lttng_trace_chunk *lttng_trace_chunk_registry_publish_chunk(
+               struct lttng_trace_chunk_registry *registry,
+               uint64_t session_id, struct lttng_trace_chunk *chunk,
+               bool *previously_published);
+
+/*
+ * Look-up a trace chunk by session_id and chunk_id.
+ * A reference is acquired on behalf of the caller.
+ *
+ * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
+ */
+struct lttng_trace_chunk *
+lttng_trace_chunk_registry_find_chunk(
+               const struct lttng_trace_chunk_registry *registry,
+               uint64_t session_id, uint64_t chunk_id);
+
+/*
+ * Query the existence of a trace chunk by session_id and chunk_id.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+int lttng_trace_chunk_registry_chunk_exists(
+               const struct lttng_trace_chunk_registry *registry,
+               uint64_t session_id, uint64_t chunk_id, bool *chunk_exists);
+
+/*
+ * Look-up an anonymous trace chunk by session_id.
+ * A reference is acquired on behalf of the caller.
+ *
+ * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
+ */
+struct lttng_trace_chunk *
+lttng_trace_chunk_registry_find_anonymous_chunk(
+               const struct lttng_trace_chunk_registry *registry,
+               uint64_t session_id);
+
+unsigned int lttng_trace_chunk_registry_put_each_chunk(
+               const struct lttng_trace_chunk_registry *registry);
+
+#endif /* LTTNG_TRACE_CHUNK_REGISTRY_H */
index 92cbd3c342d6daac671033b49c0262517fd2d28b..2bf1a39623d4ac6700ac48f99bdea254786a1dc1 100644 (file)
@@ -5,23 +5,23 @@
  *
  */
 
-#include <common/compat/directory-handle.h>
-#include <common/credentials.h>
-#include <common/defaults.h>
-#include <common/dynamic-array.h>
-#include <common/error.h>
-#include <common/fd-tracker/fd-tracker.h>
-#include <common/fd-tracker/utils.h>
-#include <common/fs-handle.h>
-#include <common/fs-handle-internal.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/optional.h>
-#include <common/string-utils/format.h>
-#include <common/time.h>
-#include <common/trace-chunk-registry.h>
-#include <common/trace-chunk.h>
-#include <common/utils.h>
+#include <common/compat/directory-handle.hpp>
+#include <common/credentials.hpp>
+#include <common/defaults.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/error.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
+#include <common/fd-tracker/utils.hpp>
+#include <common/fs-handle.hpp>
+#include <common/fs-handle-internal.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/optional.hpp>
+#include <common/string-utils/format.hpp>
+#include <common/time.hpp>
+#include <common/trace-chunk-registry.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/utils.hpp>
 #include <lttng/constant.h>
 
 #include <inttypes.h>
diff --git a/src/common/trace-chunk.h b/src/common/trace-chunk.h
deleted file mode 100644 (file)
index 4e4440b..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_TRACE_CHUNK_H
-#define LTTNG_TRACE_CHUNK_H
-
-#include <common/compat/directory-handle.h>
-#include <common/credentials.h>
-#include <common/fd-tracker/fd-tracker.h>
-#include <common/macros.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-
-/*
- * A trace chunk is a group of directories and files forming a (or a set of)
- * complete and independant trace(s). For instance, a trace archive chunk,
- * a snapshot, or a regular LTTng trace are all instances of a trace archive.
- *
- * A trace chunk is always contained within a session output directory.
- *
- * This facility is used by the session daemon, consumer daemon(s), and relay
- * daemon to:
- *   - Control file (data stream, metadata, and index) creation relative to
- *     a given output directory,
- *   - Track the use of an output directory by other objects in order to
- *     know if/when an output directory can be safely consumed, renamed,
- *     deleted, etc.
- *
- *
- * OWNER VS USER
- * ---
- *
- * A trace chunk can either be a owner or a user of its
- * "chunk output directory".
- *
- * A "user" trace chunk is provided with a handle to the chunk output directory
- * which can then be used to create subdirectories and files.
- *
- * An "owner" chunk, on top of being able to perform the operations of a "user"
- * chunk can perform operations on its chunk output directory, such as renaming
- * or deleting it.
- *
- * A trace chunk becomes an "owner" or "user" chunk based on which of
- * 'lttng_trace_chunk_set_as_owner()' or 'lttng_trace_chunk_set_as_user()' is
- * used. These methods are _exclusive_ and must only be used once on a
- * trace chunk.
- */
-
-struct lttng_trace_chunk;
-struct fd_tracker;
-
-enum lttng_trace_chunk_status {
-       LTTNG_TRACE_CHUNK_STATUS_OK,
-       LTTNG_TRACE_CHUNK_STATUS_NONE,
-       LTTNG_TRACE_CHUNK_STATUS_INVALID_ARGUMENT,
-       LTTNG_TRACE_CHUNK_STATUS_INVALID_OPERATION,
-       LTTNG_TRACE_CHUNK_STATUS_ERROR,
-       LTTNG_TRACE_CHUNK_STATUS_NO_FILE,
-};
-
-enum lttng_trace_chunk_command_type {
-       LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED = 0,
-       LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION = 1,
-       LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE = 2,
-       LTTNG_TRACE_CHUNK_COMMAND_TYPE_MAX,
-};
-
-struct lttng_trace_chunk *lttng_trace_chunk_create_anonymous(void);
-
-struct lttng_trace_chunk *lttng_trace_chunk_create(
-               uint64_t chunk_id,
-               time_t chunk_creation_time,
-               const char *path);
-
-void lttng_trace_chunk_set_fd_tracker(struct lttng_trace_chunk *chunk,
-               struct fd_tracker *fd_tracker);
-
-/*
- * Copy a trace chunk. The copy that is returned is always a _user_
- * mode chunk even if the source chunk was an _owner_ as there can never be
- * two _owners_ of the same trace output.
- */
-struct lttng_trace_chunk *lttng_trace_chunk_copy(
-               struct lttng_trace_chunk *source_chunk);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_get_id(
-               struct lttng_trace_chunk *chunk, uint64_t *id);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_get_creation_timestamp(
-               struct lttng_trace_chunk *chunk, time_t *creation_ts);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_get_close_timestamp(
-               struct lttng_trace_chunk *chunk, time_t *close_ts);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_close_timestamp(
-               struct lttng_trace_chunk *chunk, time_t close_ts);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_get_name(
-               struct lttng_trace_chunk *chunk, const char **name,
-               bool *name_overridden);
-
-bool lttng_trace_chunk_get_name_overridden(struct lttng_trace_chunk *chunk);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_override_name(
-               struct lttng_trace_chunk *chunk, const char *name);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_rename_path(
-               struct lttng_trace_chunk *chunk, const char *path);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_get_credentials(
-               struct lttng_trace_chunk *chunk,
-               struct lttng_credentials *credentials);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_credentials(
-               struct lttng_trace_chunk *chunk,
-               const struct lttng_credentials *credentials);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_credentials_current_user(
-               struct lttng_trace_chunk *chunk);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_as_owner(
-               struct lttng_trace_chunk *chunk,
-               struct lttng_directory_handle *session_output_directory);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_as_user(
-               struct lttng_trace_chunk *chunk,
-               struct lttng_directory_handle *chunk_directory);
-
-enum lttng_trace_chunk_status
-lttng_trace_chunk_get_session_output_directory_handle(
-               struct lttng_trace_chunk *chunk,
-               struct lttng_directory_handle **handle);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_borrow_chunk_directory_handle(
-               struct lttng_trace_chunk *chunk,
-               const struct lttng_directory_handle **handle);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_create_subdirectory(
-               struct lttng_trace_chunk *chunk,
-               const char *subdirectory_path);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_open_file(
-               struct lttng_trace_chunk *chunk,
-               const char *filename,
-               int flags,
-               mode_t mode,
-               int *out_fd,
-               bool expect_no_file);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_open_fs_handle(
-               struct lttng_trace_chunk *chunk,
-               const char *filename,
-               int flags,
-               mode_t mode,
-               struct fs_handle **out_handle,
-               bool expect_no_file);
-
-int lttng_trace_chunk_unlink_file(struct lttng_trace_chunk *chunk,
-               const char *filename);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_get_close_command(
-               struct lttng_trace_chunk *chunk,
-               enum lttng_trace_chunk_command_type *command_type);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_close_command(
-               struct lttng_trace_chunk *chunk,
-               enum lttng_trace_chunk_command_type command_type);
-
-const char *lttng_trace_chunk_command_type_get_name(
-               enum lttng_trace_chunk_command_type command);
-
-bool lttng_trace_chunk_ids_equal(const struct lttng_trace_chunk *chunk_a,
-               const struct lttng_trace_chunk *chunk_b);
-
-/* Returns true on success. */
-bool lttng_trace_chunk_get(struct lttng_trace_chunk *chunk);
-
-void lttng_trace_chunk_put(struct lttng_trace_chunk *chunk);
-
-#endif /* LTTNG_TRACE_CHUNK_H */
diff --git a/src/common/trace-chunk.hpp b/src/common/trace-chunk.hpp
new file mode 100644 (file)
index 0000000..cf038b9
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_TRACE_CHUNK_H
+#define LTTNG_TRACE_CHUNK_H
+
+#include <common/compat/directory-handle.hpp>
+#include <common/credentials.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
+#include <common/macros.hpp>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+/*
+ * A trace chunk is a group of directories and files forming a (or a set of)
+ * complete and independant trace(s). For instance, a trace archive chunk,
+ * a snapshot, or a regular LTTng trace are all instances of a trace archive.
+ *
+ * A trace chunk is always contained within a session output directory.
+ *
+ * This facility is used by the session daemon, consumer daemon(s), and relay
+ * daemon to:
+ *   - Control file (data stream, metadata, and index) creation relative to
+ *     a given output directory,
+ *   - Track the use of an output directory by other objects in order to
+ *     know if/when an output directory can be safely consumed, renamed,
+ *     deleted, etc.
+ *
+ *
+ * OWNER VS USER
+ * ---
+ *
+ * A trace chunk can either be a owner or a user of its
+ * "chunk output directory".
+ *
+ * A "user" trace chunk is provided with a handle to the chunk output directory
+ * which can then be used to create subdirectories and files.
+ *
+ * An "owner" chunk, on top of being able to perform the operations of a "user"
+ * chunk can perform operations on its chunk output directory, such as renaming
+ * or deleting it.
+ *
+ * A trace chunk becomes an "owner" or "user" chunk based on which of
+ * 'lttng_trace_chunk_set_as_owner()' or 'lttng_trace_chunk_set_as_user()' is
+ * used. These methods are _exclusive_ and must only be used once on a
+ * trace chunk.
+ */
+
+struct lttng_trace_chunk;
+struct fd_tracker;
+
+enum lttng_trace_chunk_status {
+       LTTNG_TRACE_CHUNK_STATUS_OK,
+       LTTNG_TRACE_CHUNK_STATUS_NONE,
+       LTTNG_TRACE_CHUNK_STATUS_INVALID_ARGUMENT,
+       LTTNG_TRACE_CHUNK_STATUS_INVALID_OPERATION,
+       LTTNG_TRACE_CHUNK_STATUS_ERROR,
+       LTTNG_TRACE_CHUNK_STATUS_NO_FILE,
+};
+
+enum lttng_trace_chunk_command_type {
+       LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED = 0,
+       LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION = 1,
+       LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE = 2,
+       LTTNG_TRACE_CHUNK_COMMAND_TYPE_MAX,
+};
+
+struct lttng_trace_chunk *lttng_trace_chunk_create_anonymous(void);
+
+struct lttng_trace_chunk *lttng_trace_chunk_create(
+               uint64_t chunk_id,
+               time_t chunk_creation_time,
+               const char *path);
+
+void lttng_trace_chunk_set_fd_tracker(struct lttng_trace_chunk *chunk,
+               struct fd_tracker *fd_tracker);
+
+/*
+ * Copy a trace chunk. The copy that is returned is always a _user_
+ * mode chunk even if the source chunk was an _owner_ as there can never be
+ * two _owners_ of the same trace output.
+ */
+struct lttng_trace_chunk *lttng_trace_chunk_copy(
+               struct lttng_trace_chunk *source_chunk);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_get_id(
+               struct lttng_trace_chunk *chunk, uint64_t *id);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_get_creation_timestamp(
+               struct lttng_trace_chunk *chunk, time_t *creation_ts);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_get_close_timestamp(
+               struct lttng_trace_chunk *chunk, time_t *close_ts);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_set_close_timestamp(
+               struct lttng_trace_chunk *chunk, time_t close_ts);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_get_name(
+               struct lttng_trace_chunk *chunk, const char **name,
+               bool *name_overridden);
+
+bool lttng_trace_chunk_get_name_overridden(struct lttng_trace_chunk *chunk);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_override_name(
+               struct lttng_trace_chunk *chunk, const char *name);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_rename_path(
+               struct lttng_trace_chunk *chunk, const char *path);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_get_credentials(
+               struct lttng_trace_chunk *chunk,
+               struct lttng_credentials *credentials);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_set_credentials(
+               struct lttng_trace_chunk *chunk,
+               const struct lttng_credentials *credentials);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_set_credentials_current_user(
+               struct lttng_trace_chunk *chunk);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_set_as_owner(
+               struct lttng_trace_chunk *chunk,
+               struct lttng_directory_handle *session_output_directory);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_set_as_user(
+               struct lttng_trace_chunk *chunk,
+               struct lttng_directory_handle *chunk_directory);
+
+enum lttng_trace_chunk_status
+lttng_trace_chunk_get_session_output_directory_handle(
+               struct lttng_trace_chunk *chunk,
+               struct lttng_directory_handle **handle);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_borrow_chunk_directory_handle(
+               struct lttng_trace_chunk *chunk,
+               const struct lttng_directory_handle **handle);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_create_subdirectory(
+               struct lttng_trace_chunk *chunk,
+               const char *subdirectory_path);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_open_file(
+               struct lttng_trace_chunk *chunk,
+               const char *filename,
+               int flags,
+               mode_t mode,
+               int *out_fd,
+               bool expect_no_file);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_open_fs_handle(
+               struct lttng_trace_chunk *chunk,
+               const char *filename,
+               int flags,
+               mode_t mode,
+               struct fs_handle **out_handle,
+               bool expect_no_file);
+
+int lttng_trace_chunk_unlink_file(struct lttng_trace_chunk *chunk,
+               const char *filename);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_get_close_command(
+               struct lttng_trace_chunk *chunk,
+               enum lttng_trace_chunk_command_type *command_type);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_set_close_command(
+               struct lttng_trace_chunk *chunk,
+               enum lttng_trace_chunk_command_type command_type);
+
+const char *lttng_trace_chunk_command_type_get_name(
+               enum lttng_trace_chunk_command_type command);
+
+bool lttng_trace_chunk_ids_equal(const struct lttng_trace_chunk *chunk_a,
+               const struct lttng_trace_chunk *chunk_b);
+
+/* Returns true on success. */
+bool lttng_trace_chunk_get(struct lttng_trace_chunk *chunk);
+
+void lttng_trace_chunk_put(struct lttng_trace_chunk *chunk);
+
+#endif /* LTTNG_TRACE_CHUNK_H */
index 0cd0e9027973f18e27e3ca238046b1cdd02bf5af..6bb84d0cad8175c8a879de39b056e03546099db0 100644 (file)
 #include <lttng/lttng-error.h>
 #include <lttng/tracker.h>
 
-#include <common/dynamic-array.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/tracker.h>
+#include <common/dynamic-array.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/tracker.hpp>
 
 #include <stdbool.h>
 
diff --git a/src/common/tracker.h b/src/common/tracker.h
deleted file mode 100644 (file)
index 8b37940..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_COMMON_TRACKER_H
-#define LTTNG_COMMON_TRACKER_H
-
-#include <lttng/lttng-error.h>
-#include <lttng/tracker.h>
-
-#include <common/buffer-view.h>
-#include <common/dynamic-array.h>
-#include <common/macros.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-
-struct process_attr_value {
-       enum lttng_process_attr_value_type type;
-       union value {
-               pid_t pid;
-               uid_t uid;
-               char *user_name;
-               gid_t gid;
-               char *group_name;
-       } value;
-};
-
-struct lttng_process_attr_values {
-       /* Array of struct process_attr_tracker_value. */
-       struct lttng_dynamic_pointer_array array;
-};
-
-const char *lttng_process_attr_to_string(enum lttng_process_attr process_attr);
-
-struct lttng_process_attr_values *lttng_process_attr_values_create(void);
-
-/* Prefixed with '_' since the name conflicts with a public API. */
-unsigned int _lttng_process_attr_values_get_count(
-               const struct lttng_process_attr_values *values);
-
-const struct process_attr_value *lttng_process_attr_tracker_values_get_at_index(
-               const struct lttng_process_attr_values *values,
-               unsigned int index);
-
-int lttng_process_attr_values_serialize(
-               const struct lttng_process_attr_values *values,
-               struct lttng_dynamic_buffer *buffer);
-
-ssize_t lttng_process_attr_values_create_from_buffer(
-               enum lttng_domain_type domain,
-               enum lttng_process_attr process_attr,
-               const struct lttng_buffer_view *buffer_view,
-               struct lttng_process_attr_values **_values);
-
-void lttng_process_attr_values_destroy(
-               struct lttng_process_attr_values *values);
-
-struct process_attr_value *process_attr_value_copy(
-               const struct process_attr_value *value);
-
-unsigned long process_attr_value_hash(const struct process_attr_value *a);
-
-bool process_attr_tracker_value_equal(const struct process_attr_value *a,
-               const struct process_attr_value *b);
-
-void process_attr_value_destroy(struct process_attr_value *value);
-
-enum lttng_error_code process_attr_value_from_comm(
-               enum lttng_domain_type domain,
-               enum lttng_process_attr process_attr,
-               enum lttng_process_attr_value_type value_type,
-               const struct process_attr_integral_value_comm *integral_value,
-               const struct lttng_buffer_view *value_view,
-               struct process_attr_value **value);
-
-#endif /* LTTNG_COMMON_TRACKER_H */
diff --git a/src/common/tracker.hpp b/src/common/tracker.hpp
new file mode 100644 (file)
index 0000000..7f4702a
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_COMMON_TRACKER_H
+#define LTTNG_COMMON_TRACKER_H
+
+#include <lttng/lttng-error.h>
+#include <lttng/tracker.h>
+
+#include <common/buffer-view.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/macros.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+struct process_attr_value {
+       enum lttng_process_attr_value_type type;
+       union value {
+               pid_t pid;
+               uid_t uid;
+               char *user_name;
+               gid_t gid;
+               char *group_name;
+       } value;
+};
+
+struct lttng_process_attr_values {
+       /* Array of struct process_attr_tracker_value. */
+       struct lttng_dynamic_pointer_array array;
+};
+
+const char *lttng_process_attr_to_string(enum lttng_process_attr process_attr);
+
+struct lttng_process_attr_values *lttng_process_attr_values_create(void);
+
+/* Prefixed with '_' since the name conflicts with a public API. */
+unsigned int _lttng_process_attr_values_get_count(
+               const struct lttng_process_attr_values *values);
+
+const struct process_attr_value *lttng_process_attr_tracker_values_get_at_index(
+               const struct lttng_process_attr_values *values,
+               unsigned int index);
+
+int lttng_process_attr_values_serialize(
+               const struct lttng_process_attr_values *values,
+               struct lttng_dynamic_buffer *buffer);
+
+ssize_t lttng_process_attr_values_create_from_buffer(
+               enum lttng_domain_type domain,
+               enum lttng_process_attr process_attr,
+               const struct lttng_buffer_view *buffer_view,
+               struct lttng_process_attr_values **_values);
+
+void lttng_process_attr_values_destroy(
+               struct lttng_process_attr_values *values);
+
+struct process_attr_value *process_attr_value_copy(
+               const struct process_attr_value *value);
+
+unsigned long process_attr_value_hash(const struct process_attr_value *a);
+
+bool process_attr_tracker_value_equal(const struct process_attr_value *a,
+               const struct process_attr_value *b);
+
+void process_attr_value_destroy(struct process_attr_value *value);
+
+enum lttng_error_code process_attr_value_from_comm(
+               enum lttng_domain_type domain,
+               enum lttng_process_attr process_attr,
+               enum lttng_process_attr_value_type value_type,
+               const struct process_attr_integral_value_comm *integral_value,
+               const struct lttng_buffer_view *value_view,
+               struct process_attr_value **value);
+
+#endif /* LTTNG_COMMON_TRACKER_H */
index 2796903fc722388245655519ce3eee5a70bb8cbd..be2c49b7cd3d79a03dc61eb1ed12e90c23321825 100644 (file)
@@ -5,24 +5,24 @@
  *
  */
 
-#include <common/credentials.h>
-#include <common/dynamic-array.h>
-#include <common/error.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
+#include <common/credentials.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/error.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
 #include <inttypes.h>
-#include <lttng/action/action-internal.h>
+#include <lttng/action/action-internal.hpp>
 #include <lttng/condition/buffer-usage.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
 #include <lttng/condition/event-rule-matches.h>
 #include <lttng/domain.h>
-#include <lttng/error-query-internal.h>
-#include <lttng/event-expr-internal.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/trigger/trigger-internal.h>
+#include <lttng/error-query-internal.hpp>
+#include <lttng/event-expr-internal.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
 #include <pthread.h>
 
 bool lttng_trigger_validate(const struct lttng_trigger *trigger)
index 4861b8ea139ae64b10bb4c0328bafc56d08587cc..0a1b1a5a54354beb1b759a7a95d6b6953d340ed2 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/common.h>
-#include <common/compat/errno.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/fd-handle.h>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/fd-handle.hpp>
 
-#include "unix.h"
+#include "unix.hpp"
 
 /*
  * Connect to unix socket using the path name.
diff --git a/src/common/unix.h b/src/common/unix.h
deleted file mode 100644 (file)
index e7f9e79..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _LTTCOMM_UNIX_H
-#define _LTTCOMM_UNIX_H
-
-#include <limits.h>
-#include <sys/un.h>
-
-#include <common/compat/socket.h>
-#include <common/macros.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
-
-int lttcomm_create_unix_sock(const char *pathname);
-int lttcomm_create_anon_unix_socketpair(int *fds);
-int lttcomm_connect_unix_sock(const char *pathname);
-int lttcomm_accept_unix_sock(int sock);
-int lttcomm_listen_unix_sock(int sock);
-int lttcomm_close_unix_sock(int sock);
-
-/* Send a message accompanied by fd(s) over a unix socket. */
-ssize_t lttcomm_send_fds_unix_sock(int sock, const int *fds, size_t nb_fd);
-ssize_t lttcomm_send_payload_view_fds_unix_sock(int sock,
-               struct lttng_payload_view *view);
-ssize_t lttcomm_send_fds_unix_sock_non_block(
-               int sock, const int *fds, size_t nb_fd);
-ssize_t lttcomm_send_payload_view_fds_unix_sock_non_block(int sock,
-               struct lttng_payload_view *view);
-
-/* Recv a message accompanied by fd(s) from a unix socket */
-ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd);
-ssize_t lttcomm_recv_payload_fds_unix_sock(int sock, size_t nb_fd,
-               struct lttng_payload *payload);
-ssize_t lttcomm_recv_fds_unix_sock_non_block(int sock, int *fds, size_t nb_fd);
-ssize_t lttcomm_recv_payload_fds_unix_sock_non_block(int sock, size_t nb_fd,
-               struct lttng_payload *payload);
-
-ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
-ssize_t lttcomm_recv_unix_sock_non_block(int sock, void *buf, size_t len);
-ssize_t lttcomm_send_unix_sock(int sock, const void *buf, size_t len);
-ssize_t lttcomm_send_unix_sock_non_block(int sock, const void *buf, size_t len);
-
-ssize_t lttcomm_send_creds_unix_sock(int sock, const void *buf, size_t len);
-ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
-               lttng_sock_cred *creds);
-
-int lttcomm_setsockopt_creds_unix_sock(int sock);
-
-#endif /* _LTTCOMM_UNIX_H */
diff --git a/src/common/unix.hpp b/src/common/unix.hpp
new file mode 100644 (file)
index 0000000..22ddf2e
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _LTTCOMM_UNIX_H
+#define _LTTCOMM_UNIX_H
+
+#include <limits.h>
+#include <sys/un.h>
+
+#include <common/compat/socket.hpp>
+#include <common/macros.hpp>
+#include <common/payload.hpp>
+#include <common/payload-view.hpp>
+
+int lttcomm_create_unix_sock(const char *pathname);
+int lttcomm_create_anon_unix_socketpair(int *fds);
+int lttcomm_connect_unix_sock(const char *pathname);
+int lttcomm_accept_unix_sock(int sock);
+int lttcomm_listen_unix_sock(int sock);
+int lttcomm_close_unix_sock(int sock);
+
+/* Send a message accompanied by fd(s) over a unix socket. */
+ssize_t lttcomm_send_fds_unix_sock(int sock, const int *fds, size_t nb_fd);
+ssize_t lttcomm_send_payload_view_fds_unix_sock(int sock,
+               struct lttng_payload_view *view);
+ssize_t lttcomm_send_fds_unix_sock_non_block(
+               int sock, const int *fds, size_t nb_fd);
+ssize_t lttcomm_send_payload_view_fds_unix_sock_non_block(int sock,
+               struct lttng_payload_view *view);
+
+/* Recv a message accompanied by fd(s) from a unix socket */
+ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd);
+ssize_t lttcomm_recv_payload_fds_unix_sock(int sock, size_t nb_fd,
+               struct lttng_payload *payload);
+ssize_t lttcomm_recv_fds_unix_sock_non_block(int sock, int *fds, size_t nb_fd);
+ssize_t lttcomm_recv_payload_fds_unix_sock_non_block(int sock, size_t nb_fd,
+               struct lttng_payload *payload);
+
+ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
+ssize_t lttcomm_recv_unix_sock_non_block(int sock, void *buf, size_t len);
+ssize_t lttcomm_send_unix_sock(int sock, const void *buf, size_t len);
+ssize_t lttcomm_send_unix_sock_non_block(int sock, const void *buf, size_t len);
+
+ssize_t lttcomm_send_creds_unix_sock(int sock, const void *buf, size_t len);
+ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
+               lttng_sock_cred *creds);
+
+int lttcomm_setsockopt_creds_unix_sock(int sock);
+
+#endif /* _LTTCOMM_UNIX_H */
index 393eba81594aefd3087b1577b6660d4cdb0b2511..b15fe25db9aca76a27127f753ca05df65ac463ad 100644 (file)
@@ -7,16 +7,16 @@
 
 #define _LGPL_SOURCE
 #include <arpa/inet.h>
-#include <common/compat/netdb.h>
+#include <common/compat/netdb.hpp>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/socket.h>
 
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
 
-#include "uri.h"
+#include "uri.hpp"
 
 #define LOOPBACK_ADDR_IPV4 "127.0.0.1"
 #define LOOPBACK_ADDR_IPV6 "::1"
diff --git a/src/common/uri.h b/src/common/uri.h
deleted file mode 100644 (file)
index 7f6ab00..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef URI_H
-#define URI_H
-
-#include <netinet/in.h>
-#include <lttng/lttng.h>
-#include <common/macros.h>
-
-/* Destination type of lttng URI */
-enum lttng_dst_type {
-       LTTNG_DST_IPV4                        = 1,
-       LTTNG_DST_IPV6                        = 2,
-       LTTNG_DST_PATH                        = 3,
-};
-
-/* Type of lttng URI where it is a final destination or a hop */
-enum lttng_uri_type {
-       LTTNG_URI_DST,  /* The URI is a final destination */
-       /*
-        * Hops are not supported yet but planned for a future release.
-        *
-        LTTNG_URI_HOP,
-        */
-};
-
-/* Communication stream type of a lttng URI */
-enum lttng_stream_type {
-       LTTNG_STREAM_CONTROL,
-       LTTNG_STREAM_DATA,
-};
-
-/*
- * Protocol type of a lttng URI. The value 0 indicate that the proto_type field
- * should be ignored.
- */
-enum lttng_proto_type {
-       LTTNG_PROTO_TYPE_NONE                 = 0,
-       LTTNG_TCP                             = 1,
-       /*
-        * UDP protocol is not supported for now.
-        *
-        LTTNG_UDP                             = 2,
-        */
-};
-
-/*
- * Structure representing an URI supported by lttng.
- */
-struct lttng_uri {
-       enum lttng_dst_type dtype;
-       enum lttng_uri_type utype;
-       enum lttng_stream_type stype;
-       enum lttng_proto_type proto;
-       uint16_t port;
-       char subdir[LTTNG_PATH_MAX];
-       union {
-               char ipv4[INET_ADDRSTRLEN];
-               char ipv6[INET6_ADDRSTRLEN];
-               char path[LTTNG_PATH_MAX];
-       } dst;
-} LTTNG_PACKED;
-
-int uri_compare(struct lttng_uri *uri1, struct lttng_uri *uri2);
-void uri_free(struct lttng_uri *uri);
-ssize_t uri_parse(const char *str_uri, struct lttng_uri **uris);
-ssize_t uri_parse_str_urls(const char *ctrl_url, const char *data_url,
-               struct lttng_uri **uris);
-int uri_to_str_url(struct lttng_uri *uri, char *dst, size_t size);
-
-#endif /* _LTT_URI_H */
diff --git a/src/common/uri.hpp b/src/common/uri.hpp
new file mode 100644 (file)
index 0000000..fe5c02a
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef URI_H
+#define URI_H
+
+#include <netinet/in.h>
+#include <lttng/lttng.h>
+#include <common/macros.hpp>
+
+/* Destination type of lttng URI */
+enum lttng_dst_type {
+       LTTNG_DST_IPV4                        = 1,
+       LTTNG_DST_IPV6                        = 2,
+       LTTNG_DST_PATH                        = 3,
+};
+
+/* Type of lttng URI where it is a final destination or a hop */
+enum lttng_uri_type {
+       LTTNG_URI_DST,  /* The URI is a final destination */
+       /*
+        * Hops are not supported yet but planned for a future release.
+        *
+        LTTNG_URI_HOP,
+        */
+};
+
+/* Communication stream type of a lttng URI */
+enum lttng_stream_type {
+       LTTNG_STREAM_CONTROL,
+       LTTNG_STREAM_DATA,
+};
+
+/*
+ * Protocol type of a lttng URI. The value 0 indicate that the proto_type field
+ * should be ignored.
+ */
+enum lttng_proto_type {
+       LTTNG_PROTO_TYPE_NONE                 = 0,
+       LTTNG_TCP                             = 1,
+       /*
+        * UDP protocol is not supported for now.
+        *
+        LTTNG_UDP                             = 2,
+        */
+};
+
+/*
+ * Structure representing an URI supported by lttng.
+ */
+struct lttng_uri {
+       enum lttng_dst_type dtype;
+       enum lttng_uri_type utype;
+       enum lttng_stream_type stype;
+       enum lttng_proto_type proto;
+       uint16_t port;
+       char subdir[LTTNG_PATH_MAX];
+       union {
+               char ipv4[INET_ADDRSTRLEN];
+               char ipv6[INET6_ADDRSTRLEN];
+               char path[LTTNG_PATH_MAX];
+       } dst;
+} LTTNG_PACKED;
+
+int uri_compare(struct lttng_uri *uri1, struct lttng_uri *uri2);
+void uri_free(struct lttng_uri *uri);
+ssize_t uri_parse(const char *str_uri, struct lttng_uri **uris);
+ssize_t uri_parse_str_urls(const char *ctrl_url, const char *data_url,
+               struct lttng_uri **uris);
+int uri_to_str_url(struct lttng_uri *uri, char *dst, size_t size);
+
+#endif /* _LTT_URI_H */
index 4ade5d84fcb93df2ec7971574770b0dfe811c02c..7eb4a6d91117e4632eea619090582a08000705c4 100644 (file)
@@ -6,18 +6,18 @@
  */
 
 #include "lttng/lttng-error.h"
-#include <common/compat/string.h>
-#include <common/align.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
+#include <common/compat/string.hpp>
+#include <common/align.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
 #include <fcntl.h>
 #include <lttng/constant.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/userspace-probe-internal.hpp>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
index aeafae642b554e1aafc825705b8be25bf1437ebf..5e9a442eb5058a98584c432d3bcebb351c25f683 100644 (file)
 #include <stdbool.h>
 #include <stdint.h>
 
-#include <bin/lttng-consumerd/health-consumerd.h>
-#include <common/common.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/relayd/relayd.h>
-#include <common/compat/fcntl.h>
-#include <common/compat/endian.h>
-#include <common/consumer/consumer-metadata-cache.h>
-#include <common/consumer/consumer-stream.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/utils.h>
-#include <common/index/index.h>
-#include <common/consumer/consumer.h>
-#include <common/shm.h>
-#include <common/optional.h>
-
-#include "ust-consumer.h"
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <common/common.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/compat/fcntl.hpp>
+#include <common/compat/endian.hpp>
+#include <common/consumer/consumer-metadata-cache.hpp>
+#include <common/consumer/consumer-stream.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/utils.hpp>
+#include <common/index/index.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/shm.hpp>
+#include <common/optional.hpp>
+
+#include "ust-consumer.hpp"
 
 #define INT_MAX_STR_LEN 12     /* includes \0 */
 
diff --git a/src/common/ust-consumer/ust-consumer.h b/src/common/ust-consumer/ust-consumer.h
deleted file mode 100644 (file)
index e6590c3..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_USTCONSUMER_H
-#define _LTTNG_USTCONSUMER_H
-
-#include <common/compat/errno.h>
-#include <common/consumer/consumer.h>
-#include <stdbool.h>
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-int lttng_ustconsumer_take_snapshot(struct lttng_consumer_stream *stream);
-int lttng_ustconsumer_sample_snapshot_positions(
-               struct lttng_consumer_stream *stream);
-
-int lttng_ustconsumer_get_produced_snapshot(
-               struct lttng_consumer_stream *stream, unsigned long *pos);
-int lttng_ustconsumer_get_consumed_snapshot(
-               struct lttng_consumer_stream *stream, unsigned long *pos);
-
-int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
-               int sock, struct pollfd *consumer_sockpoll);
-
-extern int lttng_ustconsumer_allocate_channel(struct lttng_consumer_channel *chan);
-extern void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan);
-extern void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan);
-extern int lttng_ustconsumer_add_stream(struct lttng_consumer_stream *stream);
-extern void lttng_ustconsumer_del_stream(struct lttng_consumer_stream *stream);
-
-int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
-               struct lttng_consumer_local_data *ctx);
-int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream);
-
-void lttng_ustconsumer_on_stream_hangup(struct lttng_consumer_stream *stream);
-
-int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream,
-               int producer_active);
-int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream *stream,
-               uint64_t *stream_id);
-int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream);
-void lttng_ustconsumer_close_all_metadata(struct lttng_ht *ht);
-void lttng_ustconsumer_close_metadata(struct lttng_consumer_channel *metadata);
-void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream);
-int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset,
-               uint64_t len, uint64_t version,
-               struct lttng_consumer_channel *channel, int timer, int wait);
-int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx,
-               struct lttng_consumer_channel *channel, int timer, int wait);
-enum sync_metadata_status lttng_ustconsumer_sync_metadata(
-               struct lttng_consumer_local_data *ctx,
-               struct lttng_consumer_stream *metadata);
-int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream,
-               int producer);
-int lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream *stream);
-int lttng_ustconsumer_get_current_timestamp(
-               struct lttng_consumer_stream *stream, uint64_t *ts);
-int lttng_ustconsumer_get_sequence_number(
-               struct lttng_consumer_stream *stream, uint64_t *seq);
-void lttng_ustconsumer_sigbus_handle(void *addr);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline
-ssize_t lttng_ustconsumer_on_read_subbuffer_mmap(
-               struct lttng_consumer_local_data *ctx __attribute__((unused)),
-               struct lttng_consumer_stream *stream __attribute__((unused)),
-               unsigned long len __attribute__((unused)),
-               unsigned long padding __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-ssize_t lttng_ustconsumer_on_read_subbuffer_splice(
-               struct lttng_consumer_local_data *ctx __attribute__((unused)),
-               struct lttng_consumer_stream *uststream __attribute__((unused)),
-               unsigned long len __attribute__((unused)),
-               unsigned long padding __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_take_snapshot(
-               struct lttng_consumer_stream *stream __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_sample_snapshot_positions(
-               struct lttng_consumer_stream *stream __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_get_produced_snapshot(
-               struct lttng_consumer_stream *stream __attribute__((unused)),
-               unsigned long *pos __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_get_consumed_snapshot(
-               struct lttng_consumer_stream *stream __attribute__((unused)),
-               unsigned long *pos __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_recv_cmd(
-               struct lttng_consumer_local_data *ctx __attribute__((unused)),
-               int sock __attribute__((unused)),
-               struct pollfd *consumer_sockpoll __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_allocate_channel(
-               struct lttng_consumer_channel *chan __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-void lttng_ustconsumer_del_channel(
-               struct lttng_consumer_channel *chan __attribute__((unused)))
-{
-}
-
-static inline
-void lttng_ustconsumer_free_channel(
-               struct lttng_consumer_channel *chan __attribute__((unused)))
-{
-}
-
-static inline
-int lttng_ustconsumer_add_stream(
-               struct lttng_consumer_stream *stream __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-void lttng_ustconsumer_del_stream(
-               struct lttng_consumer_stream *stream __attribute__((unused)))
-{
-}
-
-static inline
-int lttng_ustconsumer_read_subbuffer(
-               struct lttng_consumer_stream *stream __attribute__((unused)),
-               struct lttng_consumer_local_data *ctx __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_on_recv_stream(
-               struct lttng_consumer_stream *stream __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-void lttng_ustconsumer_on_stream_hangup(
-               struct lttng_consumer_stream *stream __attribute__((unused)))
-{
-}
-
-static inline
-int lttng_ustconsumer_data_pending(
-               struct lttng_consumer_stream *stream __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream __attribute__((unused)),
-               int producer_active __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-void lttng_ustconsumer_close_all_metadata(
-               struct lttng_ht *ht __attribute__((unused)))
-{
-}
-
-static inline
-void lttng_ustconsumer_close_metadata(
-               struct lttng_consumer_channel *metadata __attribute__((unused)))
-{
-}
-static inline
-void lttng_ustconsumer_close_stream_wakeup(
-               struct lttng_consumer_stream *stream __attribute__((unused)))
-{
-}
-
-static inline
-int lttng_ustconsumer_recv_metadata(int sock __attribute__((unused)),
-               uint64_t key __attribute__((unused)),
-               uint64_t offset __attribute__((unused)),
-               uint64_t len __attribute__((unused)),
-               uint64_t version __attribute__((unused)),
-               struct lttng_consumer_channel *channel __attribute__((unused)),
-               int timer __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_request_metadata(
-               struct lttng_consumer_local_data *ctx __attribute__((unused)),
-               struct lttng_consumer_channel *channel __attribute__((unused)),
-               int timer __attribute__((unused)),
-               int wait __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-enum sync_metadata_status lttng_ustconsumer_sync_metadata(
-               struct lttng_consumer_local_data *ctx __attribute__((unused)),
-               struct lttng_consumer_stream *metadata __attribute__((unused)))
-{
-       return SYNC_METADATA_STATUS_ERROR;
-}
-
-static inline
-int lttng_ustconsumer_flush_buffer(
-               struct lttng_consumer_stream *stream __attribute__((unused)),
-               int producer __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_clear_buffer(
-               struct lttng_consumer_stream *stream __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_get_current_timestamp(
-               struct lttng_consumer_stream *stream __attribute__((unused)),
-               uint64_t *ts __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_get_sequence_number(
-               struct lttng_consumer_stream *stream __attribute__((unused)),
-               uint64_t *seq __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_get_stream_id(
-               struct lttng_consumer_stream *stream __attribute__((unused)),
-               uint64_t *stream_id __attribute__((unused)))
-{
-       return -ENOSYS;
-}
-
-static inline
-void lttng_ustconsumer_sigbus_handle(
-               void *addr __attribute__((unused)))
-{
-}
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* _LTTNG_USTCONSUMER_H */
diff --git a/src/common/ust-consumer/ust-consumer.hpp b/src/common/ust-consumer/ust-consumer.hpp
new file mode 100644 (file)
index 0000000..6fc0ded
--- /dev/null
@@ -0,0 +1,288 @@
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_USTCONSUMER_H
+#define _LTTNG_USTCONSUMER_H
+
+#include <common/compat/errno.hpp>
+#include <common/consumer/consumer.hpp>
+#include <stdbool.h>
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+int lttng_ustconsumer_take_snapshot(struct lttng_consumer_stream *stream);
+int lttng_ustconsumer_sample_snapshot_positions(
+               struct lttng_consumer_stream *stream);
+
+int lttng_ustconsumer_get_produced_snapshot(
+               struct lttng_consumer_stream *stream, unsigned long *pos);
+int lttng_ustconsumer_get_consumed_snapshot(
+               struct lttng_consumer_stream *stream, unsigned long *pos);
+
+int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
+               int sock, struct pollfd *consumer_sockpoll);
+
+extern int lttng_ustconsumer_allocate_channel(struct lttng_consumer_channel *chan);
+extern void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan);
+extern void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan);
+extern int lttng_ustconsumer_add_stream(struct lttng_consumer_stream *stream);
+extern void lttng_ustconsumer_del_stream(struct lttng_consumer_stream *stream);
+
+int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
+               struct lttng_consumer_local_data *ctx);
+int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream);
+
+void lttng_ustconsumer_on_stream_hangup(struct lttng_consumer_stream *stream);
+
+int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream,
+               int producer_active);
+int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream *stream,
+               uint64_t *stream_id);
+int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream);
+void lttng_ustconsumer_close_all_metadata(struct lttng_ht *ht);
+void lttng_ustconsumer_close_metadata(struct lttng_consumer_channel *metadata);
+void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream);
+int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset,
+               uint64_t len, uint64_t version,
+               struct lttng_consumer_channel *channel, int timer, int wait);
+int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx,
+               struct lttng_consumer_channel *channel, int timer, int wait);
+enum sync_metadata_status lttng_ustconsumer_sync_metadata(
+               struct lttng_consumer_local_data *ctx,
+               struct lttng_consumer_stream *metadata);
+int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream,
+               int producer);
+int lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream *stream);
+int lttng_ustconsumer_get_current_timestamp(
+               struct lttng_consumer_stream *stream, uint64_t *ts);
+int lttng_ustconsumer_get_sequence_number(
+               struct lttng_consumer_stream *stream, uint64_t *seq);
+void lttng_ustconsumer_sigbus_handle(void *addr);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+ssize_t lttng_ustconsumer_on_read_subbuffer_mmap(
+               struct lttng_consumer_local_data *ctx __attribute__((unused)),
+               struct lttng_consumer_stream *stream __attribute__((unused)),
+               unsigned long len __attribute__((unused)),
+               unsigned long padding __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+ssize_t lttng_ustconsumer_on_read_subbuffer_splice(
+               struct lttng_consumer_local_data *ctx __attribute__((unused)),
+               struct lttng_consumer_stream *uststream __attribute__((unused)),
+               unsigned long len __attribute__((unused)),
+               unsigned long padding __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_take_snapshot(
+               struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_sample_snapshot_positions(
+               struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_get_produced_snapshot(
+               struct lttng_consumer_stream *stream __attribute__((unused)),
+               unsigned long *pos __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_get_consumed_snapshot(
+               struct lttng_consumer_stream *stream __attribute__((unused)),
+               unsigned long *pos __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_recv_cmd(
+               struct lttng_consumer_local_data *ctx __attribute__((unused)),
+               int sock __attribute__((unused)),
+               struct pollfd *consumer_sockpoll __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_allocate_channel(
+               struct lttng_consumer_channel *chan __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+void lttng_ustconsumer_del_channel(
+               struct lttng_consumer_channel *chan __attribute__((unused)))
+{
+}
+
+static inline
+void lttng_ustconsumer_free_channel(
+               struct lttng_consumer_channel *chan __attribute__((unused)))
+{
+}
+
+static inline
+int lttng_ustconsumer_add_stream(
+               struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+void lttng_ustconsumer_del_stream(
+               struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+}
+
+static inline
+int lttng_ustconsumer_read_subbuffer(
+               struct lttng_consumer_stream *stream __attribute__((unused)),
+               struct lttng_consumer_local_data *ctx __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_on_recv_stream(
+               struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+void lttng_ustconsumer_on_stream_hangup(
+               struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+}
+
+static inline
+int lttng_ustconsumer_data_pending(
+               struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream __attribute__((unused)),
+               int producer_active __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+void lttng_ustconsumer_close_all_metadata(
+               struct lttng_ht *ht __attribute__((unused)))
+{
+}
+
+static inline
+void lttng_ustconsumer_close_metadata(
+               struct lttng_consumer_channel *metadata __attribute__((unused)))
+{
+}
+static inline
+void lttng_ustconsumer_close_stream_wakeup(
+               struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+}
+
+static inline
+int lttng_ustconsumer_recv_metadata(int sock __attribute__((unused)),
+               uint64_t key __attribute__((unused)),
+               uint64_t offset __attribute__((unused)),
+               uint64_t len __attribute__((unused)),
+               uint64_t version __attribute__((unused)),
+               struct lttng_consumer_channel *channel __attribute__((unused)),
+               int timer __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_request_metadata(
+               struct lttng_consumer_local_data *ctx __attribute__((unused)),
+               struct lttng_consumer_channel *channel __attribute__((unused)),
+               int timer __attribute__((unused)),
+               int wait __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+enum sync_metadata_status lttng_ustconsumer_sync_metadata(
+               struct lttng_consumer_local_data *ctx __attribute__((unused)),
+               struct lttng_consumer_stream *metadata __attribute__((unused)))
+{
+       return SYNC_METADATA_STATUS_ERROR;
+}
+
+static inline
+int lttng_ustconsumer_flush_buffer(
+               struct lttng_consumer_stream *stream __attribute__((unused)),
+               int producer __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_clear_buffer(
+               struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_get_current_timestamp(
+               struct lttng_consumer_stream *stream __attribute__((unused)),
+               uint64_t *ts __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_get_sequence_number(
+               struct lttng_consumer_stream *stream __attribute__((unused)),
+               uint64_t *seq __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_get_stream_id(
+               struct lttng_consumer_stream *stream __attribute__((unused)),
+               uint64_t *stream_id __attribute__((unused)))
+{
+       return -ENOSYS;
+}
+
+static inline
+void lttng_ustconsumer_sigbus_handle(
+               void *addr __attribute__((unused)))
+{
+}
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* _LTTNG_USTCONSUMER_H */
index 5e116a9ab09513baa6809ed06671954c37156372..eb6b001434300594b3f0af974f565b0d2301959c 100644 (file)
@@ -6,36 +6,33 @@
  *
  */
 
-#include "common/macros.h"
-#include <stdint.h>
 #define _LGPL_SOURCE
 #include <ctype.h>
 #include <fcntl.h>
+#include <grp.h>
+#include <inttypes.h>
 #include <limits.h>
+#include <pwd.h>
 #include <stdlib.h>
+#include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <inttypes.h>
-#include <grp.h>
-#include <pwd.h>
-#include <sys/file.h>
-#include <unistd.h>
 
-#include <common/common.h>
-#include <common/readwrite.h>
-#include <common/runas.h>
-#include <common/compat/getenv.h>
-#include <common/compat/string.h>
-#include <common/compat/dirent.h>
-#include <common/compat/directory-handle.h>
-#include <common/dynamic-buffer.h>
-#include <common/string-utils/format.h>
+#include <common/common.hpp>
+#include <common/compat/directory-handle.hpp>
+#include <common/compat/dirent.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/compat/string.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/readwrite.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/format.hpp>
 #include <lttng/constant.h>
 
-#include "utils.h"
-#include "defaults.h"
-#include "time.h"
+#include "defaults.hpp"
+#include "time.hpp"
+#include "utils.hpp"
 
 #define PROC_MEMINFO_PATH               "/proc/meminfo"
 #define PROC_MEMINFO_MEMAVAILABLE_LINE  "MemAvailable:"
diff --git a/src/common/utils.h b/src/common/utils.h
deleted file mode 100644 (file)
index 8b6003b..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMMON_UTILS_H
-#define _COMMON_UTILS_H
-
-#include <getopt.h>
-#include <lttng/lttng-error.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <common/compat/directory-handle.h>
-
-#define KIBI_LOG2 10
-#define MEBI_LOG2 20
-#define GIBI_LOG2 30
-
-int utils_create_pipe(int *dst);
-int utils_create_pipe_cloexec(int *dst);
-int utils_create_pipe_cloexec_nonblock(int *dst);
-void utils_close_pipe(int *src);
-char *utils_strdupdelim(const char *begin, const char *end);
-int utils_set_fd_cloexec(int fd);
-int utils_create_pid_file(pid_t pid, const char *filepath);
-int utils_mkdir(const char *path, mode_t mode, int uid, int gid);
-int utils_mkdir_recursive(const char *path, mode_t mode, int uid, int gid);
-int utils_stream_file_path(const char *path_name, const char *file_name,
-               uint64_t size, uint64_t count, const char *suffix,
-               char *out_stream_path, size_t stream_path_len);
-int utils_parse_size_suffix(char const * const str, uint64_t * const size);
-int utils_parse_time_suffix(char const * const str, uint64_t * const time_us);
-int utils_get_count_order_u32(uint32_t x);
-int utils_get_count_order_u64(uint64_t x);
-const char *utils_get_home_dir(void);
-char *utils_get_user_home_dir(uid_t uid);
-
-size_t utils_get_current_time_str(const char *format, char *dst, size_t len)
-       ATTR_FORMAT_STRFTIME(1);
-
-int utils_get_group_id(const char *name, bool warn, gid_t *gid);
-char *utils_generate_optstring(const struct option *long_options,
-               size_t opt_count);
-int utils_create_lock_file(const char *filepath);
-int utils_recursive_rmdir(const char *path);
-int utils_truncate_stream_file(int fd, off_t length);
-int utils_show_help(int section, const char *page_name, const char *help_msg);
-int utils_get_memory_available(uint64_t *value);
-int utils_get_memory_total(uint64_t *value);
-int utils_change_working_directory(const char *path);
-enum lttng_error_code utils_user_id_from_name(
-               const char *user_name, uid_t *user_id);
-enum lttng_error_code utils_group_id_from_name(
-               const char *group_name, gid_t *group_id);
-
-/*
- * Parse `str` as an unsigned long long value.
- *
- * Return 0 on success.  Return -1 on failure which can be because:
- *
- * - `str` is zero length
- * - `str` contains invalid
- */
-int utils_parse_unsigned_long_long(const char *str,
-               unsigned long long *value);
-
-#endif /* _COMMON_UTILS_H */
diff --git a/src/common/utils.hpp b/src/common/utils.hpp
new file mode 100644 (file)
index 0000000..0c60a23
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMMON_UTILS_H
+#define _COMMON_UTILS_H
+
+#include <getopt.h>
+#include <lttng/lttng-error.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <common/compat/directory-handle.hpp>
+
+#define KIBI_LOG2 10
+#define MEBI_LOG2 20
+#define GIBI_LOG2 30
+
+int utils_create_pipe(int *dst);
+int utils_create_pipe_cloexec(int *dst);
+int utils_create_pipe_cloexec_nonblock(int *dst);
+void utils_close_pipe(int *src);
+char *utils_strdupdelim(const char *begin, const char *end);
+int utils_set_fd_cloexec(int fd);
+int utils_create_pid_file(pid_t pid, const char *filepath);
+int utils_mkdir(const char *path, mode_t mode, int uid, int gid);
+int utils_mkdir_recursive(const char *path, mode_t mode, int uid, int gid);
+int utils_stream_file_path(const char *path_name, const char *file_name,
+               uint64_t size, uint64_t count, const char *suffix,
+               char *out_stream_path, size_t stream_path_len);
+int utils_parse_size_suffix(char const * const str, uint64_t * const size);
+int utils_parse_time_suffix(char const * const str, uint64_t * const time_us);
+int utils_get_count_order_u32(uint32_t x);
+int utils_get_count_order_u64(uint64_t x);
+const char *utils_get_home_dir(void);
+char *utils_get_user_home_dir(uid_t uid);
+
+size_t utils_get_current_time_str(const char *format, char *dst, size_t len)
+       ATTR_FORMAT_STRFTIME(1);
+
+int utils_get_group_id(const char *name, bool warn, gid_t *gid);
+char *utils_generate_optstring(const struct option *long_options,
+               size_t opt_count);
+int utils_create_lock_file(const char *filepath);
+int utils_recursive_rmdir(const char *path);
+int utils_truncate_stream_file(int fd, off_t length);
+int utils_show_help(int section, const char *page_name, const char *help_msg);
+int utils_get_memory_available(uint64_t *value);
+int utils_get_memory_total(uint64_t *value);
+int utils_change_working_directory(const char *path);
+enum lttng_error_code utils_user_id_from_name(
+               const char *user_name, uid_t *user_id);
+enum lttng_error_code utils_group_id_from_name(
+               const char *group_name, gid_t *group_id);
+
+/*
+ * Parse `str` as an unsigned long long value.
+ *
+ * Return 0 on success.  Return -1 on failure which can be because:
+ *
+ * - `str` is zero length
+ * - `str` contains invalid
+ */
+int utils_parse_unsigned_long_long(const char *str,
+               unsigned long long *value);
+
+#endif /* _COMMON_UTILS_H */
index 77b9a767bececffe3210255c9d8c11f1dc9a086d..558110fc0e9e7e46b6d75f44978dfad0944c7454 100644 (file)
@@ -6,7 +6,7 @@
  *
  */
 
-#include <common/compat/string.h>
+#include <common/compat/string.hpp>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -14,7 +14,7 @@
 #include <string.h>
 #include <time.h>
 
-#include "uuid.h"
+#include "uuid.hpp"
 
 static const lttng_uuid nil_uuid = { 0 };
 static bool lttng_uuid_is_init;
diff --git a/src/common/uuid.h b/src/common/uuid.h
deleted file mode 100644 (file)
index 0d3e79a..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef LTTNG_UUID_H
-#define LTTNG_UUID_H
-
-#include <common/macros.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <inttypes.h>
-
-/*
- * Includes final \0.
- */
-#define LTTNG_UUID_STR_LEN     37
-#define LTTNG_UUID_LEN         16
-#define LTTNG_UUID_VER         4
-
-#define LTTNG_UUID_FMT \
-       "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 \
-       "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 \
-       "-%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 \
-       "%02" SCNx8
-
-#define LTTNG_UUID_FMT_VALUES(uuid) \
-       (uuid)[0], (uuid)[1], (uuid)[2], (uuid)[3], (uuid)[4], (uuid)[5], \
-       (uuid)[6], (uuid)[7], (uuid)[8], (uuid)[9], (uuid)[10], (uuid)[11], \
-       (uuid)[12], (uuid)[13], (uuid)[14], (uuid)[15]
-
-#define LTTNG_UUID_SCAN_VALUES(uuid) \
-       &(uuid)[0], &(uuid)[1], &(uuid)[2], &(uuid)[3], &(uuid)[4], &(uuid)[5], \
-       &(uuid)[6], &(uuid)[7], &(uuid)[8], &(uuid)[9], &(uuid)[10], &(uuid)[11], \
-       &(uuid)[12], &(uuid)[13], &(uuid)[14], &(uuid)[15]
-
-typedef uint8_t lttng_uuid[LTTNG_UUID_LEN];
-
-int lttng_uuid_from_str(const char *str_in, lttng_uuid uuid_out);
-
-/*
- * Convert a UUID to a human-readable, NULL-terminated, string of the form
- * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
- *
- * Assumes uuid_str is at least LTTNG_UUID_STR_LEN byte long.
- */
-void lttng_uuid_to_str(const lttng_uuid uuid, char *uuid_str);
-
-bool lttng_uuid_is_equal(const lttng_uuid a, const lttng_uuid b);
-
-bool lttng_uuid_is_nil(const lttng_uuid uuid);
-
-void lttng_uuid_copy(lttng_uuid dst, const lttng_uuid src);
-
-/*
- * Generate a random UUID according to RFC4122, section 4.4.
- */
-int lttng_uuid_generate(lttng_uuid uuid_out);
-
-#endif /* LTTNG_UUID_H */
diff --git a/src/common/uuid.hpp b/src/common/uuid.hpp
new file mode 100644 (file)
index 0000000..431490e
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef LTTNG_UUID_H
+#define LTTNG_UUID_H
+
+#include <common/macros.hpp>
+#include <stdbool.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+/*
+ * Includes final \0.
+ */
+#define LTTNG_UUID_STR_LEN     37
+#define LTTNG_UUID_LEN         16
+#define LTTNG_UUID_VER         4
+
+#define LTTNG_UUID_FMT \
+       "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 \
+       "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 \
+       "-%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 \
+       "%02" SCNx8
+
+#define LTTNG_UUID_FMT_VALUES(uuid) \
+       (uuid)[0], (uuid)[1], (uuid)[2], (uuid)[3], (uuid)[4], (uuid)[5], \
+       (uuid)[6], (uuid)[7], (uuid)[8], (uuid)[9], (uuid)[10], (uuid)[11], \
+       (uuid)[12], (uuid)[13], (uuid)[14], (uuid)[15]
+
+#define LTTNG_UUID_SCAN_VALUES(uuid) \
+       &(uuid)[0], &(uuid)[1], &(uuid)[2], &(uuid)[3], &(uuid)[4], &(uuid)[5], \
+       &(uuid)[6], &(uuid)[7], &(uuid)[8], &(uuid)[9], &(uuid)[10], &(uuid)[11], \
+       &(uuid)[12], &(uuid)[13], &(uuid)[14], &(uuid)[15]
+
+typedef uint8_t lttng_uuid[LTTNG_UUID_LEN];
+
+int lttng_uuid_from_str(const char *str_in, lttng_uuid uuid_out);
+
+/*
+ * Convert a UUID to a human-readable, NULL-terminated, string of the form
+ * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
+ *
+ * Assumes uuid_str is at least LTTNG_UUID_STR_LEN byte long.
+ */
+void lttng_uuid_to_str(const lttng_uuid uuid, char *uuid_str);
+
+bool lttng_uuid_is_equal(const lttng_uuid a, const lttng_uuid b);
+
+bool lttng_uuid_is_nil(const lttng_uuid uuid);
+
+void lttng_uuid_copy(lttng_uuid dst, const lttng_uuid src);
+
+/*
+ * Generate a random UUID according to RFC4122, section 4.4.
+ */
+int lttng_uuid_generate(lttng_uuid uuid_out);
+
+#endif /* LTTNG_UUID_H */
index aca88eb4db75ade4fa28b971d4616be68bd92742..3ddb68feb7c76dd91f09bec9d7664c02224627a2 100644 (file)
@@ -6,10 +6,10 @@
  *
  */
 
-#include "waiter.h"
+#include "waiter.hpp"
 #include <urcu/uatomic.h>
 #include <urcu/futex.h>
-#include "error.h"
+#include "error.hpp"
 #include <poll.h>
 
 /*
diff --git a/src/common/waiter.h b/src/common/waiter.h
deleted file mode 100644 (file)
index ed870ae..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- * This code is originally adapted from userspace-rcu's urcu-wait.h
- */
-
-#ifndef LTTNG_WAITER_H
-#define LTTNG_WAITER_H
-
-#define _LGPL_SOURCE
-
-#include <stdint.h>
-#include <urcu/wfstack.h>
-#include <stdbool.h>
-#include "macros.h"
-
-struct lttng_waiter {
-       struct cds_wfs_node wait_queue_node;
-       int32_t state;
-};
-
-void lttng_waiter_init(struct lttng_waiter *waiter);
-
-void lttng_waiter_wait(struct lttng_waiter *waiter);
-
-/*
- * lttng_waiter_wake_up must only be called by a single waker.
- * It is invalid for multiple "wake" operations to be invoked
- * on a single waiter without re-initializing it before.
- */
-void lttng_waiter_wake_up(struct lttng_waiter *waiter);
-
-#endif /* LTTNG_WAITER_H */
diff --git a/src/common/waiter.hpp b/src/common/waiter.hpp
new file mode 100644 (file)
index 0000000..75c9ac4
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * This code is originally adapted from userspace-rcu's urcu-wait.h
+ */
+
+#ifndef LTTNG_WAITER_H
+#define LTTNG_WAITER_H
+
+#define _LGPL_SOURCE
+
+#include <stdint.h>
+#include <urcu/wfstack.h>
+#include <stdbool.h>
+#include "macros.hpp"
+
+struct lttng_waiter {
+       struct cds_wfs_node wait_queue_node;
+       int32_t state;
+};
+
+void lttng_waiter_init(struct lttng_waiter *waiter);
+
+void lttng_waiter_wait(struct lttng_waiter *waiter);
+
+/*
+ * lttng_waiter_wake_up must only be called by a single waker.
+ * It is invalid for multiple "wake" operations to be invoked
+ * on a single waiter without re-initializing it before.
+ */
+void lttng_waiter_wake_up(struct lttng_waiter *waiter);
+
+#endif /* LTTNG_WAITER_H */
index 8d559c9ca47e3c7237d32b34c21139c819e9462d..2cf4c36d4dd2be49452853ed5052a66c066dadaf 100644 (file)
@@ -11,7 +11,7 @@ liblttng_ctl_la_SOURCES = \
                load.cpp \
                lttng-ctl.cpp \
                lttng-ctl-health.cpp \
-               lttng-ctl-helper.h \
+               lttng-ctl-helper.hpp \
                rotate.cpp \
                save.cpp \
                snapshot.cpp \
index f464e7000573ac0381b366b51a50b660845f61c5..080dbb4439659a33c10dc052e81f21b56251b4c9 100644 (file)
@@ -5,20 +5,20 @@
  *
  */
 
-#include <lttng/notification/notification-internal.h>
-#include <lttng/notification/channel-internal.h>
-#include <lttng/condition/condition-internal.h>
+#include <lttng/notification/notification-internal.hpp>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
 #include <lttng/endpoint.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/dynamic-buffer.h>
-#include <common/utils.h>
-#include <common/defaults.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
-#include <common/unix.h>
-#include "lttng-ctl-helper.h"
-#include <common/compat/poll.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/utils.hpp>
+#include <common/defaults.hpp>
+#include <common/payload.hpp>
+#include <common/payload-view.hpp>
+#include <common/unix.hpp>
+#include "lttng-ctl-helper.hpp"
+#include <common/compat/poll.hpp>
 
 static
 int handshake(struct lttng_notification_channel *channel);
index fb2b1cae951e2cf3c06f1bdd0d8990554f61ea24..114758b0c8f3a38296600e9bba47d28929ccc0f2 100644 (file)
 #include <lttng/lttng-error.h>
 #include <lttng/clear.h>
 #include <lttng/clear-handle.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/macros.h>
-#include <common/compat/poll.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <common/optional.h>
-
-#include "lttng-ctl-helper.h"
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/macros.hpp>
+#include <common/compat/poll.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
+#include <common/optional.hpp>
+
+#include "lttng-ctl-helper.hpp"
 
 enum communication_state {
        COMMUNICATION_STATE_RECEIVE_LTTNG_MSG,
index 0bfa303d804392107b612893cf50117a88c13bb6..d937b2c73c3693a26dadb38962363b34323625d0 100644 (file)
@@ -8,16 +8,16 @@
 #include <lttng/destruction-handle.h>
 #include <lttng/rotation.h>
 
-#include <common/optional.h>
-#include <common/compat/poll.h>
-#include <common/compat/time.h>
-#include <common/macros.h>
-#include <common/compat/poll.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/location-internal.h>
-#include "lttng-ctl-helper.h"
+#include <common/optional.hpp>
+#include <common/compat/poll.hpp>
+#include <common/compat/time.hpp>
+#include <common/macros.hpp>
+#include <common/compat/poll.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/location-internal.hpp>
+#include "lttng-ctl-helper.hpp"
 
 #include <algorithm>
 #include <stdbool.h>
index 3a6bf22b2ec90987014acd5f085230d04fdf638e..e89aae4829464d4fed25d70354c41b64df40365d 100644 (file)
 #define _LGPL_SOURCE
 #include <stddef.h>
 
-#include <common/error.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/event-internal.h>
+#include <common/error.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/event-internal.hpp>
 #include <lttng/event.h>
 #include <lttng/lttng-error.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/userspace-probe-internal.hpp>
 
 struct lttng_event *lttng_event_create(void)
 {
index 0032df5697fd0ae2b591096800450ce7f31987c9..4a07f4212a463439ec80a1986b1fc9ea720c0ff6 100644 (file)
 
 #include <lttng/lttng-error.h>
 #include <lttng/load.h>
-#include <lttng/load-internal.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/config/session-config.h>
-#include <common/uri.h>
-#include <common/macros.h>
-#include <common/compat/string.h>
-
-#include "lttng-ctl-helper.h"
+#include <lttng/load-internal.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/config/session-config.hpp>
+#include <common/uri.hpp>
+#include <common/macros.hpp>
+#include <common/compat/string.hpp>
+
+#include "lttng-ctl-helper.hpp"
 
 struct lttng_load_session_attr *lttng_load_session_attr_create(void)
 {
index d061d9beae9876432639c382a7ba9efa510847c8..4821548e515c032a636b9d765f9e42429403cd33 100644 (file)
 #include <stdint.h>
 #include <limits.h>
 #include <string.h>
-#include <lttng/health-internal.h>
+#include <lttng/health-internal.hpp>
 
-#include <bin/lttng-sessiond/health-sessiond.h>
-#include <bin/lttng-consumerd/health-consumerd.h>
-#include <bin/lttng-relayd/health-relayd.h>
-#include <common/defaults.h>
-#include <common/utils.h>
-#include <common/compat/errno.h>
+#include <bin/lttng-sessiond/health-sessiond.hpp>
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <bin/lttng-relayd/health-relayd.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
+#include <common/compat/errno.hpp>
 
-#include "lttng-ctl-helper.h"
+#include "lttng-ctl-helper.hpp"
 
 enum health_component {
        HEALTH_COMPONENT_SESSIOND,
diff --git a/src/lib/lttng-ctl/lttng-ctl-helper.h b/src/lib/lttng-ctl/lttng-ctl-helper.h
deleted file mode 100644 (file)
index b10acd5..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CTL_HELPER_H
-#define LTTNG_CTL_HELPER_H
-
-#include <stdio.h>
-
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/lttng.h>
-
-/* Copy helper functions. */
-void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst,
-               struct lttng_domain *src);
-
-/*
- * Sends the lttcomm message to the session daemon and fills buf if the
- * returned data is not NULL.
- *
- * Return the size of the received data on success or else a negative lttng
- * error code. If buf is NULL, 0 is returned on success.
- */
-int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm,
-               const int *fds, size_t nb_fd,
-               const void *vardata, size_t vardata_len,
-               void **user_payload_buf, void **user_cmd_header_buf,
-               size_t *user_cmd_header_len);
-
-/*
- * Sends the lttcomm message to the session daemon and fills the reply payload.
- *
- * Return the size of the received data on success or else a negative lttng
- * error code.
- */
-int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message,
-               struct lttng_payload *reply);
-
-/*
- * Calls lttng_ctl_ask_sessiond_fds_varlen() with no expected command header.
- */
-static inline int lttng_ctl_ask_sessiond_varlen_no_cmd_header(
-               struct lttcomm_session_msg *lsm,
-               const void *vardata,
-               size_t vardata_len,
-               void **user_payload_buf)
-{
-       return lttng_ctl_ask_sessiond_fds_varlen(lsm, NULL, 0, vardata,
-               vardata_len, user_payload_buf, NULL, NULL);
-}
-
-/*
- * Calls lttng_ctl_ask_sessiond_fds_varlen() with fds and no expected command header.
- */
-static inline
-int lttng_ctl_ask_sessiond_fds_no_cmd_header(struct lttcomm_session_msg *lsm,
-               const int *fds, size_t nb_fd, void **buf __attribute__((unused)))
-{
-       return lttng_ctl_ask_sessiond_fds_varlen(lsm, fds, nb_fd, NULL,
-               0, NULL, NULL, NULL);
-}
-/*
- * Use this if no variable length data needs to be sent.
- */
-static inline
-int lttng_ctl_ask_sessiond(struct lttcomm_session_msg *lsm, void **buf)
-{
-       return lttng_ctl_ask_sessiond_varlen_no_cmd_header(lsm, NULL, 0, buf);
-}
-
-int lttng_check_tracing_group(void);
-
-int connect_sessiond(void);
-
-#endif /* LTTNG_CTL_HELPER_H */
diff --git a/src/lib/lttng-ctl/lttng-ctl-helper.hpp b/src/lib/lttng-ctl/lttng-ctl-helper.hpp
new file mode 100644 (file)
index 0000000..4b025a4
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CTL_HELPER_H
+#define LTTNG_CTL_HELPER_H
+
+#include <stdio.h>
+
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/lttng.h>
+
+/* Copy helper functions. */
+void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst,
+               struct lttng_domain *src);
+
+/*
+ * Sends the lttcomm message to the session daemon and fills buf if the
+ * returned data is not NULL.
+ *
+ * Return the size of the received data on success or else a negative lttng
+ * error code. If buf is NULL, 0 is returned on success.
+ */
+int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm,
+               const int *fds, size_t nb_fd,
+               const void *vardata, size_t vardata_len,
+               void **user_payload_buf, void **user_cmd_header_buf,
+               size_t *user_cmd_header_len);
+
+/*
+ * Sends the lttcomm message to the session daemon and fills the reply payload.
+ *
+ * Return the size of the received data on success or else a negative lttng
+ * error code.
+ */
+int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message,
+               struct lttng_payload *reply);
+
+/*
+ * Calls lttng_ctl_ask_sessiond_fds_varlen() with no expected command header.
+ */
+static inline int lttng_ctl_ask_sessiond_varlen_no_cmd_header(
+               struct lttcomm_session_msg *lsm,
+               const void *vardata,
+               size_t vardata_len,
+               void **user_payload_buf)
+{
+       return lttng_ctl_ask_sessiond_fds_varlen(lsm, NULL, 0, vardata,
+               vardata_len, user_payload_buf, NULL, NULL);
+}
+
+/*
+ * Calls lttng_ctl_ask_sessiond_fds_varlen() with fds and no expected command header.
+ */
+static inline
+int lttng_ctl_ask_sessiond_fds_no_cmd_header(struct lttcomm_session_msg *lsm,
+               const int *fds, size_t nb_fd, void **buf __attribute__((unused)))
+{
+       return lttng_ctl_ask_sessiond_fds_varlen(lsm, fds, nb_fd, NULL,
+               0, NULL, NULL, NULL);
+}
+/*
+ * Use this if no variable length data needs to be sent.
+ */
+static inline
+int lttng_ctl_ask_sessiond(struct lttcomm_session_msg *lsm, void **buf)
+{
+       return lttng_ctl_ask_sessiond_varlen_no_cmd_header(lsm, NULL, 0, buf);
+}
+
+int lttng_check_tracing_group(void);
+
+int connect_sessiond(void);
+
+#endif /* LTTNG_CTL_HELPER_H */
index 68f8c1f7e01916c51c7299e6e660832aba029391..c5d47ebdc53d66b2182a6656b2ecb955fdf91942 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
-#include <common/bytecode/bytecode.h>
-#include <common/align.h>
-#include <common/common.h>
-#include <common/compat/errno.h>
-#include <common/compat/string.h>
-#include <common/defaults.h>
-#include <common/dynamic-array.h>
-#include <common/dynamic-buffer.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/tracker.h>
-#include <common/unix.h>
-#include <common/uri.h>
-#include <common/utils.h>
-#include <lttng/channel-internal.h>
+#include <common/bytecode/bytecode.hpp>
+#include <common/align.hpp>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/string.hpp>
+#include <common/defaults.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/tracker.hpp>
+#include <common/unix.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+#include <lttng/channel-internal.hpp>
 #include <lttng/destruction-handle.h>
 #include <lttng/endpoint.h>
-#include <lttng/error-query-internal.h>
-#include <lttng/event-internal.h>
-#include <lttng/health-internal.h>
+#include <lttng/error-query-internal.hpp>
+#include <lttng/event-internal.hpp>
+#include <lttng/health-internal.hpp>
 #include <lttng/lttng-error.h>
 #include <lttng/lttng.h>
-#include <lttng/session-descriptor-internal.h>
-#include <lttng/session-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/session-descriptor-internal.hpp>
+#include <lttng/session-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <lttng/userspace-probe-internal.hpp>
 
-#include "lttng-ctl-helper.h"
-#include <common/filter/filter-ast.h>
+#include "lttng-ctl-helper.hpp"
+#include <common/filter/filter-ast.hpp>
 #include <common/filter/filter-parser.hpp>
-#include <common/filter/memstream.h>
+#include <common/filter/memstream.hpp>
 
 #define COPY_DOMAIN_PACKED(dst, src)                           \
 do {                                                           \
index ed198922ee6535daf2fccc86a5bf617cb8da3e4d..b6a66392af2cd2e492d7f7eec0af567ed8d71f0d 100644 (file)
 
 #include <lttng/lttng-error.h>
 #include <lttng/rotation.h>
-#include <lttng/location-internal.h>
-#include <lttng/rotate-internal.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/macros.h>
+#include <lttng/location-internal.hpp>
+#include <lttng/rotate-internal.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/macros.hpp>
 
-#include "lttng-ctl-helper.h"
+#include "lttng-ctl-helper.hpp"
 
 static
 enum lttng_rotation_status ask_rotation_info(
index 45894277a04c15f47b480ac2a9c13fa69e0fee0a..7843df300699afded1d46ed8da083f60d8fc4c49 100644 (file)
 
 #include <lttng/lttng-error.h>
 #include <lttng/save.h>
-#include <lttng/save-internal.h>
-#include <common/sessiond-comm/sessiond-comm.h>
+#include <lttng/save-internal.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
 
-#include "lttng-ctl-helper.h"
+#include "lttng-ctl-helper.hpp"
 
 struct lttng_save_session_attr *lttng_save_session_attr_create(void)
 {
index b50403512d2f9378ee56269212146ca1b7407fce..b9bac9aa84b0c2d3cc90c4efcf6593922dbbc1af 100644 (file)
@@ -8,12 +8,12 @@
 #define _LGPL_SOURCE
 #include <string.h>
 
-#include <common/sessiond-comm/sessiond-comm.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
 #include <lttng/lttng-error.h>
 #include <lttng/snapshot.h>
-#include <lttng/snapshot-internal.h>
+#include <lttng/snapshot-internal.hpp>
 
-#include "lttng-ctl-helper.h"
+#include "lttng-ctl-helper.hpp"
 
 /*
  * Add an output object to a session identified by name.
index b7fc1f78a0f794976022bb29ab1c37b1fef3689e..53deced1d36172bb678e40234149dcae23b6b8b4 100644 (file)
@@ -5,14 +5,14 @@
  *
  */
 
-#include <type_traits>
+#include <lttng/domain.h>
+#include <lttng/lttng-error.h>
 
-#include "lttng-ctl-helper.h"
-#include "lttng/domain.h"
-#include "lttng/lttng-error.h"
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/tracker.h>
+#include "lttng-ctl-helper.hpp"
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/tracker.hpp>
 #include <lttng/tracker.h>
+#include <type_traits>
 
 struct lttng_process_attr_tracker_handle {
        char *session_name;
index d2f49b281ed4226e1e26d1391a974990e558dc3c..bd5da44f6a74ddc2226ee12cb41395c3c35100a1 100644 (file)
@@ -9,7 +9,7 @@
 #define MSGPACK_LTTNG_CONFIG_H
 
 #include <limits.h>
-#include <common/compat/endian.h>
+#include <common/compat/endian.hpp>
 
 #if BYTE_ORDER == LITTLE_ENDIAN
 #define MSGPACK_ENDIAN_LITTLE_BYTE 1
index d3a21e2fcc392fe5bedb4f5b06dc56b9b393bf1d..5dabf55b6e560d403374ee054981bfb101963aa3 100644 (file)
@@ -5,27 +5,28 @@
  *
  */
 
-#include <stdio.h>
+#include <fcntl.h>
+#include <limits.h>
 #include <poll.h>
+#include <popt.h>
+#include <pthread.h>
 #include <signal.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
+#include <stddef.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stddef.h>
-#include <sys/select.h>
 #include <sys/epoll.h>
-#include <popt.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <limits.h>
-#include <pthread.h>
 #include <sys/mman.h>
-#include <common/compat/time.h>
-#include <common/error.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <common/compat/time.hpp>
+#include <common/error.hpp>
 
 #define BUF_SIZE 256
 #define NB_FD 1
index 76d801e9b024ee3fcbcd78e6722dbe0e762fd361..439d862d4b0fbbaf117dd2fa0be3fffa5699b9c6 100644 (file)
@@ -9,7 +9,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
 #include <sys/types.h>
 #include <inttypes.h>
 #include <stdlib.h>
 #include <lttng/lttng.h>
 
 #include <urcu/list.h>
-#include <common/common.h>
+#include <common/common.hpp>
 
-#include <bin/lttng-relayd/lttng-viewer-abi.h>
-#include <common/index/ctf-index.h>
+#include <bin/lttng-relayd/lttng-viewer-abi.hpp>
+#include <common/index/ctf-index.hpp>
 
-#include <common/compat/errno.h>
-#include <common/compat/endian.h>
+#include <common/compat/errno.hpp>
+#include <common/compat/endian.hpp>
 
 #define SESSION1 "test1"
 #define RELAYD_URL "net://localhost"
index 05db3421a132fd878c58aa8f0c323d6fa35e6d1e..9f2314acb8d3f82807ecbd95db581827a601261a 100644 (file)
@@ -5,10 +5,10 @@
  *
  */
 
-#include <common/compat/getenv.h>
-#include <common/consumer/consumer.h>
-#include <common/pipe.h>
-#include <common/error.h>
+#include <common/compat/getenv.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/pipe.hpp>
+#include <common/error.hpp>
 #include <unistd.h>
 #include <stdbool.h>
 #include <lttng/constant.h>
index 40e2e126fbfa3e50a86ab1be143b91cd5eb8e0b5..21efa3996dff702c341973768ea9336d398f60d4 100644 (file)
@@ -14,8 +14,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <common/pipe.h>
-#include <common/error.h>
+#include <common/pipe.hpp>
+#include <common/error.hpp>
 
 int lttng_opt_verbose;
 int lttng_opt_mi;
index c6205ef63757c29e45169cb8a607602c2cccfa05..15f98bf9a1b4fa50265e412e34adbdeff6496ddc 100644 (file)
@@ -22,8 +22,8 @@
 #include <signal.h>
 #include <poll.h>
 
-#include <common/compat/errno.h>
-#include <common/macros.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
 #include <lttng/lttng.h>
 
 #include <tap/tap.h>
index fa3fe7f418141e41b3cd57626cdda89a906f19c2..f0517ed14b911f9e62fc2bbf2ccd2d2e0036f76e 100644 (file)
@@ -6,10 +6,10 @@
  *
  */
 
-#include <common/compat/getenv.h>
-#include <common/consumer/consumer.h>
-#include <common/pipe.h>
-#include <common/error.h>
+#include <common/compat/getenv.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/pipe.hpp>
+#include <common/error.hpp>
 #include <unistd.h>
 #include <stdbool.h>
 #include <lttng/constant.h>
index 62c8f5dd06300225448ba499684c97b7e7dc6157..969cab11eabb05050d1d96f80929f88516367d19 100644 (file)
@@ -17,7 +17,7 @@
 
 #include <tap/tap.h>
 
-#include <common/macros.h>
+#include <common/macros.hpp>
 #include <lttng/lttng.h>
 
 #define TEST_COUNT 1
index 11459d4bdf32bd0497b19ecab055c20f00ea149d..1e2a676dc4000003eec31a6eccb2736ff5d2c42f 100644 (file)
@@ -15,7 +15,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <lttng/lttng.h>
-#include <common/macros.h>
+#include <common/macros.hpp>
 
 #define TEST_COUNT 70
 
index 54eb78303348cbe3b8675a3a45193904e2e8b376..cbcfbfb82baadc4b12bccad2bf157bba8286a4dc 100644 (file)
@@ -7,8 +7,8 @@
 
 /* Utility to register some triggers, for test purposes. */
 
-#include <common/filter/filter-ast.h>
-#include <common/macros.h>
+#include <common/filter/filter-ast.hpp>
+#include <common/macros.hpp>
 #include <lttng/lttng.h>
 
 #include <stdlib.h>
index a12a5b76bc5bc836c4519360baaba4d8f6d320fb..a38cd515e217cfaee7cc55845f285790dd8067f2 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #include <stdlib.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
 #include <string.h>
 #include <stdio.h>
 #include <lttng/lttng-export.h>
index dbe6c1d86283adf7c3cc1ef4f6780eb81696e54e..80240f1f5da47eb5d676b77cb99da9596717a0e1 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 #include <stdlib.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
 #include <string.h>
 #include <stdio.h>
 #include <unistd.h>
index bab2644cc537ee21838761af01cface924ecf7f8..e4288928fad5235245086f8f47087bcb4eb2ab3c 100644 (file)
@@ -11,7 +11,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 
-#include <common/compat/errno.h>
+#include <common/compat/errno.hpp>
 
 /*
  * libfoo has a direct dependency on libbar.
index e1c65e917bbd0828499b8d2685383b89c53e0e5a..874f47f9b09bb55c1e803a291c4ef43589e62aef 100644 (file)
@@ -6,9 +6,9 @@
  */
 
 #include <tap/tap.h>
-#include <common/ini-config/ini-config.h>
-#include <common/utils.h>
-#include <common/path.h>
+#include <common/ini-config/ini-config.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
 #include <string.h>
 #include <lttng/constant.h>
 
index 8657be1dcb4eb4c587c5e90bf36de24818ccca4e..de2197ed0d964d690c846a2b95c1cff256af832f 100644 (file)
 
 #include <tap/tap.h>
 
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/action/action-internal.h>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/action/action-internal.hpp>
 #include <lttng/action/action.h>
 #include <lttng/action/notify.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <lttng/action/rate-policy-internal.hpp>
 #include <lttng/action/rate-policy.h>
 #include <lttng/action/rotate-session.h>
 #include <lttng/action/snapshot-session.h>
index a129d4a9a0ec6fbf38ef6d80c40e307f8e9afcf4..764549b83da41c7e289090286d4d22326c819dd1 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 
-#include <common/buffer-view.h>
+#include <common/buffer-view.hpp>
 #include <tap/tap.h>
 
 static const int TEST_COUNT = 5;
index 6271901096c7e242bcc47af8621dab8eb5fe3a7d..9ed6b89418e9225ce2481fe390a2186c76f21938 100644 (file)
 
 #include <lttng/event.h>
 #include <lttng/event-rule/user-tracepoint.h>
-#include <lttng/condition/condition-internal.h>
+#include <lttng/condition/condition-internal.hpp>
 #include <lttng/condition/event-rule-matches.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/event-rule-matches-internal.hpp>
 #include <lttng/domain.h>
 #include <lttng/log-level-rule.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
 
 /* For error.h */
 int lttng_opt_quiet = 1;
index 8dd7dd11a58aac396ca839659ed15abf4c63e65e..8a4e614993379ff42e01779b9cde562507d91b93 100644 (file)
@@ -14,9 +14,9 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/compat/directory-handle.h>
-#include <common/compat/errno.h>
-#include <common/error.h>
+#include <common/compat/directory-handle.hpp>
+#include <common/compat/errno.hpp>
+#include <common/error.hpp>
 #include <tap/tap.h>
 
 #define TEST_COUNT 9
index fae7eb26ebe214f567a37bdf12bcd0abbf49e73a..577dea93229ce1ffc12c785508383b20e217b83e 100644 (file)
@@ -5,8 +5,8 @@
  *
  */
 
-#include <common/bytecode/bytecode.h>
-#include <lttng/event-expr-internal.h>
+#include <common/bytecode/bytecode.hpp>
+#include <lttng/event-expr-internal.hpp>
 #include <lttng/event-expr.h>
 #include <tap/tap.h>
 
index d0e33a1f8d1a11db7de06cc4e9409cfbc35ab581..351937444b00fd2a7debca8670a8b7f67343ff0a 100644 (file)
 
 #include <tap/tap.h>
 
-#include <common/payload-view.h>
-#include <common/payload.h>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
 #include <lttng/domain.h>
-#include <lttng/event-rule/jul-logging-internal.h>
+#include <lttng/event-rule/jul-logging-internal.hpp>
 #include <lttng/event-rule/jul-logging.h>
-#include <lttng/event-rule/kernel-kprobe-internal.h>
+#include <lttng/event-rule/kernel-kprobe-internal.hpp>
 #include <lttng/event-rule/kernel-kprobe.h>
-#include <lttng/event-rule/kernel-syscall-internal.h>
+#include <lttng/event-rule/kernel-syscall-internal.hpp>
 #include <lttng/event-rule/kernel-syscall.h>
-#include <lttng/event-rule/python-logging-internal.h>
+#include <lttng/event-rule/python-logging-internal.hpp>
 #include <lttng/event-rule/python-logging.h>
-#include <lttng/event-rule/kernel-tracepoint-internal.h>
+#include <lttng/event-rule/kernel-tracepoint-internal.hpp>
 #include <lttng/event-rule/kernel-tracepoint.h>
-#include <lttng/event-rule/kernel-uprobe-internal.h>
+#include <lttng/event-rule/kernel-uprobe-internal.hpp>
 #include <lttng/event-rule/kernel-uprobe.h>
-#include <lttng/event-rule/user-tracepoint-internal.h>
+#include <lttng/event-rule/user-tracepoint-internal.hpp>
 #include <lttng/event-rule/user-tracepoint.h>
 #include <lttng/event.h>
-#include <lttng/kernel-probe-internal.h>
+#include <lttng/kernel-probe-internal.hpp>
 #include <lttng/kernel-probe.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/userspace-probe-internal.hpp>
 #include <lttng/userspace-probe.h>
-#include "bin/lttng/loglevel.h"
+#include "bin/lttng/loglevel.hpp"
 
 /* For error.h. */
 int lttng_opt_quiet = 1;
index 544dc84eafee3b6015ef64183c1a071125d51a2b..63f3d0afa31921ab78a2b3086d3c1292e6bb97a5 100644 (file)
 
 #include <urcu.h>
 
-#include <common/compat/directory-handle.h>
-#include <common/compat/errno.h>
-#include <common/error.h>
-#include <common/fs-handle.h>
-#include <common/fd-tracker/fd-tracker.h>
+#include <common/compat/directory-handle.hpp>
+#include <common/compat/errno.hpp>
+#include <common/error.hpp>
+#include <common/fs-handle.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
 
 /* For error.h */
 int lttng_opt_quiet = 1;
index cf2f53564d11969553e8eaca56ce5f0e0ae24078..eae335be205026b0abd549cf166cf342d32b40aa 100644 (file)
@@ -11,9 +11,9 @@
 #include <unistd.h>
 #include <time.h>
 
-#include <common/compat/errno.h>
-#include <bin/lttng-sessiond/trace-kernel.h>
-#include <common/defaults.h>
+#include <common/compat/errno.hpp>
+#include <bin/lttng-sessiond/trace-kernel.hpp>
+#include <common/defaults.hpp>
 
 #include <tap/tap.h>
 
index 91211eb4e8190e0c39549f2d41ad1070d2aa8a13..1ec6945d4aae72de31fb67a4f4cf9d609991d0e0 100644 (file)
@@ -14,9 +14,9 @@
 
 #include <tap/tap.h>
 
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/kernel-probe-internal.h>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/kernel-probe-internal.hpp>
 #include <lttng/kernel-probe.h>
 
 /* For error.h */
index 8948006654392073152e37179abe70285d31272a..b756387fb29415f14cffa7cc1936b108d7a1334a 100644 (file)
@@ -14,9 +14,9 @@
 
 #include <tap/tap.h>
 
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/log-level-rule-internal.h>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/log-level-rule-internal.hpp>
 #include <lttng/log-level-rule.h>
 
 /* For error.h. */
index 8e2006f3d5f5d2eb02db03faf2e79c05394c64d6..e870cbef6dab355eab2e8f6151c642589b1bd8e3 100644 (file)
@@ -24,7 +24,7 @@
 #include <lttng/notification/notification.h>
 #include <lttng/trigger/trigger.h>
 
-#include <common/macros.h>
+#include <common/macros.hpp>
 
 /* For error.h */
 int lttng_opt_quiet = 1;
index 53565f5eb58db06345c7de63edd8d558ecc61083..de50ed383b5a6ec8cfc4e1160124a30385f703c2 100644 (file)
@@ -7,9 +7,9 @@
 
 #include <unistd.h>
 
-#include <common/compat/fcntl.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
+#include <common/compat/fcntl.hpp>
+#include <common/payload.hpp>
+#include <common/payload-view.hpp>
 #include <tap/tap.h>
 
 static const int TEST_COUNT = 5;
index d9ae4b7b6ba63fc94100c4bae3a3f9f126c8759a..95c095f5a0bd6720a25663e6a28d679fd43a5349 100644 (file)
@@ -14,9 +14,9 @@
 
 #include <tap/tap.h>
 
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
 #include <lttng/action/rate-policy.h>
 
 /* For error.h. */
index 1fde89cbe44132f0cb848552917df5015c5135b7..42cb0156a8246f2262e56679e12aeda36c7c4331 100644 (file)
@@ -11,9 +11,9 @@
 #include <string.h>
 #include <tap/tap.h>
 
-#include <common/time.h>
+#include <common/time.hpp>
 
-#include "backward-compatibility-group-by.h"
+#include "backward-compatibility-group-by.hpp"
 
 /* Number of TAP tests in this file */
 #define NUM_TESTS_PER_TEST 1
index c403e2355c8227598e1c33adb4fbc5db6576b96c..05c1f81b687fdabe6698cfb715927defca9aef90 100644 (file)
@@ -8,20 +8,20 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#include <time.h>
 #include <sys/types.h>
+#include <time.h>
+#include <unistd.h>
 #include <urcu.h>
 
 #include <tap/tap.h>
 
-#include <common/compat/errno.h>
-#include <bin/lttng-sessiond/session.h>
-#include <bin/lttng-sessiond/ust-app.h>
-#include <bin/lttng-sessiond/health-sessiond.h>
-#include <bin/lttng-sessiond/thread.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/common.h>
+#include <bin/lttng-sessiond/health-sessiond.hpp>
+#include <bin/lttng-sessiond/session.hpp>
+#include <bin/lttng-sessiond/thread.hpp>
+#include <bin/lttng-sessiond/ust-app.hpp>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
 
 #define SESSION1 "test1"
 
index 9f1f450947aa542cc31e081a01fb33954733b57f..ff06bf9b6774ade76bb419822fca0c3afe4532a8 100644 (file)
@@ -9,7 +9,7 @@
 #include <stdbool.h>
 #include <string.h>
 #include <stdarg.h>
-#include <common/string-utils/string-utils.h>
+#include <common/string-utils/string-utils.hpp>
 #include <tap/tap.h>
 
 /* Number of TAP tests in this file */
index 2d59ba8eeac6457ba4d2399fa4cbf2fbddd9157a..2ff65a679749838586fb47846306a740cc0b3f0f 100644 (file)
@@ -6,16 +6,16 @@
  */
 
 #include <algorithm>
-#include <common/compat/fcntl.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
-#include <common/unix.h>
-#include <common/utils.h>
-#include <common/defaults.h>
+#include <common/compat/fcntl.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/payload.hpp>
+#include <common/payload-view.hpp>
+#include <common/unix.hpp>
+#include <common/utils.hpp>
+#include <common/defaults.hpp>
 #include <tap/tap.h>
 #include <stdbool.h>
-#include <common/error.h>
+#include <common/error.hpp>
 #include <lttng/constant.h>
 #include <stdio.h>
 #include <pthread.h>
index a65ce6218c3ff9ca9e8d813a97187b07981f693d..e89396e34ed28ebd7fa047221177d5492e953cb4 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <tap/tap.h>
 
-#include <common/uri.h>
+#include <common/uri.hpp>
 
 /* For error.h */
 int lttng_opt_quiet = 1;
index e62f6b571e5db99e34a893575633506815446812..9cfdac4f31c08473d82ae10ad206dc2c28577191 100644 (file)
 #include <urcu.h>
 
 #include <lttng/lttng.h>
-#include <bin/lttng-sessiond/lttng-ust-abi.h>
-#include <common/defaults.h>
-#include <common/compat/errno.h>
-#include <bin/lttng-sessiond/trace-ust.h>
-#include <bin/lttng-sessiond/ust-app.h>
-#include <bin/lttng-sessiond/notification-thread.h>
+#include <bin/lttng-sessiond/lttng-ust-abi.hpp>
+#include <common/defaults.hpp>
+#include <common/compat/errno.hpp>
+#include <bin/lttng-sessiond/trace-ust.hpp>
+#include <bin/lttng-sessiond/ust-app.hpp>
+#include <bin/lttng-sessiond/notification-thread.hpp>
 
 #include <lttng/ust-sigbus.h>
 
index eb6d94a5eedb876bb39d25deb1645c7c2cc68733..f34ef5d0ea27f7da28484eafcfef21416c6e66b8 100644 (file)
 
 #include <tap/tap.h>
 
-#include <common/compat/poll.h>
-#include <common/readwrite.h>
-#include <common/pipe.h>
-#include <common/dynamic-array.h>
+#include <common/compat/poll.hpp>
+#include <common/readwrite.hpp>
+#include <common/pipe.hpp>
+#include <common/dynamic-array.hpp>
 
 /* Verification without trashing test order in the child process */
 #define childok(e, test, ...) do { \
index 2ce437372968ed63063956a417f2d8f294d468ec..55e584b8bc9b34745a074e3f73732c1f2e3c5259 100644 (file)
@@ -7,7 +7,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "common/compat/pthread.h"
+#include "common/compat/pthread.hpp"
 
 #include <tap/tap.h>
 
index e85cbbced9c4af4a546d629a445a70fb361a1697..3cb1a81604c585ae12fe898ebbb0109deffb8586 100644 (file)
@@ -15,9 +15,9 @@
 
 #include <tap/tap.h>
 
-#include <common/utils.h>
-#include <common/path.h>
-#include <common/common.h>
+#include <common/utils.hpp>
+#include <common/path.hpp>
+#include <common/common.hpp>
 
 /* For error.h */
 int lttng_opt_quiet = 1;
index 2cd917272efd9af93879cac367b72138b1d8d604..296ed88b85283906dc9688c7e415c256d3508d94 100644 (file)
@@ -10,7 +10,7 @@
 
 #include <tap/tap.h>
 
-#include <common/utils.h>
+#include <common/utils.hpp>
 
 /* For error.h */
 int lttng_opt_quiet = 1;
index e444464bc4abba9563fe4448e4c57bb85c1a5a97..97c2c78ba39d3a6ed91a1330275905ad08cdab6f 100644 (file)
@@ -11,7 +11,7 @@
 
 #include <tap/tap.h>
 
-#include <common/utils.h>
+#include <common/utils.hpp>
 
 /* For error.h */
 int lttng_opt_quiet = 1;
index 2355084a51748fefd2137bb67e5745ce38f8822b..26ec6b6c68825a281246d942e79ea1540fb8df8f 100644 (file)
@@ -11,7 +11,7 @@
 
 #include <tap/tap.h>
 
-#include "common/uuid.h"
+#include "common/uuid.hpp"
 
 #define NR_TESTS 21
 
index 5b3805c6b026b4d9d168a7f4a8923fdc31307a2b..55a7ba7ebddb055b0f61346a9ee8e69abb433091 100644 (file)
@@ -24,4 +24,4 @@ SUBDIRS += \
          gen-ust-events-ns
 endif # IS_LINUX
 
-noinst_HEADERS = signal-helper.h
+noinst_HEADERS = signal-helper.hpp
index 7ecf22b358859b33f56c686ff9d60ed701679663..80afdb6d63ed27c99510c7068436a7539d23bcf2 100644 (file)
 #include <unistd.h>
 #include <inttypes.h>
 
-#include <common/compat/tid.h>
-#include <common/macros.h>
+#include <common/compat/tid.hpp>
+#include <common/macros.hpp>
 
-#include "signal-helper.h"
+#include "signal-helper.hpp"
 #include "utils.h"
 
 #define LTTNG_PROC_NS_PATH_MAX 40
index 6a246867d39c824422e0db778ecdf85ef46528fc..9b19d2d2d6d5424866a388ede519700ea0de2793 100644 (file)
@@ -9,8 +9,8 @@
 #include <stdio.h>
 #include <sys/syscall.h>
 #include <unistd.h>
-#include <common/error.h>
-#include <common/align.h>
+#include <common/error.hpp>
+#include <common/align.hpp>
 
 #include "utils.h"
 
index 84d8bf563b06599440a07d3503889ad63099ecc1..ba506b1131b57eeb1e2f8313e16dc90546ba5d60 100644 (file)
 #include <unistd.h>
 #include <inttypes.h>
 
-#include <common/compat/tid.h>
-#include <common/macros.h>
+#include <common/compat/tid.hpp>
+#include <common/macros.hpp>
 
-#include "signal-helper.h"
+#include "signal-helper.hpp"
 #include "utils.h"
 
 #define TRACEPOINT_DEFINE
index cf8819977dc79d83596b1da1d31a746d6b271cb9..b66f1ce8c6efc099c1aa5eb0aa71ed602e97426f 100644 (file)
@@ -22,7 +22,7 @@
 #include <poll.h>
 #include <errno.h>
 #include "utils.h"
-#include "signal-helper.h"
+#include "signal-helper.hpp"
 
 #define TRACEPOINT_DEFINE
 #include "tp.h"
index d68501bee553406e00b2cb8f78a673a231493067..d59dfa3d81c919cf1993bb7487ac5a302e8f1bb6 100644 (file)
@@ -7,7 +7,7 @@
 
 #define _LGPL_SOURCE
 #include <stdio.h>
-#include "signal-helper.h"
+#include "signal-helper.hpp"
 
 #define TRACEPOINT_DEFINE
 #include "tp.h"
index ec71023de4d872632d59aef98d1f14037bc854bc..a2aae040f9b01cefb419332afdc0175f10c1546d 100644 (file)
@@ -17,7 +17,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include "utils.h"
-#include "signal-helper.h"
+#include "signal-helper.hpp"
 
 #define TRACEPOINT_DEFINE
 #include "tp.h"
index f0f6cc63c372465363bda2b453c466d810580f3f..31aa3798f99432c198696d55100d9d347c5210c2 100644 (file)
@@ -17,9 +17,9 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/macros.h>
+#include <common/macros.hpp>
 #include <lttng/tracef.h>
-#include "signal-helper.h"
+#include "signal-helper.hpp"
 
 const char *str = "test string";
 
diff --git a/tests/utils/testapp/signal-helper.h b/tests/utils/testapp/signal-helper.h
deleted file mode 100644 (file)
index ceadcb3..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_TESTAPP_SIGNAL_HELPER_H
-#define LTTNG_TESTAPP_SIGNAL_HELPER_H
-
-#include <signal.h>
-
-static volatile int should_quit;
-
-static
-void sighandler(int sig)
-{
-       if (sig == SIGTERM) {
-               should_quit = 1;
-       }
-}
-
-static
-int set_signal_handler(void)
-{
-       int ret;
-       struct sigaction sa {};
-       sa.sa_flags = 0;
-       sa.sa_handler = sighandler;
-
-       ret = sigemptyset(&sa.sa_mask);
-       if (ret) {
-               perror("sigemptyset");
-               goto end;
-       }
-
-       ret = sigaction(SIGTERM, &sa, NULL);
-       if (ret) {
-               perror("sigaction");
-               goto end;
-       }
-end:
-       return ret;
-}
-
-#endif /* LTTNG_TESTAPP_SIGNAL_HELPER_H */
diff --git a/tests/utils/testapp/signal-helper.hpp b/tests/utils/testapp/signal-helper.hpp
new file mode 100644 (file)
index 0000000..ceadcb3
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_TESTAPP_SIGNAL_HELPER_H
+#define LTTNG_TESTAPP_SIGNAL_HELPER_H
+
+#include <signal.h>
+
+static volatile int should_quit;
+
+static
+void sighandler(int sig)
+{
+       if (sig == SIGTERM) {
+               should_quit = 1;
+       }
+}
+
+static
+int set_signal_handler(void)
+{
+       int ret;
+       struct sigaction sa {};
+       sa.sa_flags = 0;
+       sa.sa_handler = sighandler;
+
+       ret = sigemptyset(&sa.sa_mask);
+       if (ret) {
+               perror("sigemptyset");
+               goto end;
+       }
+
+       ret = sigaction(SIGTERM, &sa, NULL);
+       if (ret) {
+               perror("sigaction");
+               goto end;
+       }
+end:
+       return ret;
+}
+
+#endif /* LTTNG_TESTAPP_SIGNAL_HELPER_H */
index 6483ae8996e00103613ad3c9fd1e351dab1cf822..7d095c131fe1e60b05c6ea3133ded09ff578ba9f 100644 (file)
@@ -3,4 +3,4 @@
 # no optimization
 AM_CPPFLAGS = -O0
 noinst_PROGRAMS = userspace-probe-elf-cxx-binary
-userspace_probe_elf_cxx_binary_SOURCES = userspace-probe-elf-cxx-binary.cpp test_class.cpp test_class.h
+userspace_probe_elf_cxx_binary_SOURCES = userspace-probe-elf-cxx-binary.cpp test_class.cpp test_class.hpp
index 83bde0b205bd1e8eb8ffc69ab63f09db1155b42f..05a20c7a188466471b8a39370178b295eaa122da 100644 (file)
@@ -5,7 +5,7 @@
  *
  */
 
-#include "test_class.h"
+#include "test_class.hpp"
 test_class::test_class() {
        test_member = 1;
 }
diff --git a/tests/utils/testapp/userspace-probe-elf-cxx-binary/test_class.h b/tests/utils/testapp/userspace-probe-elf-cxx-binary/test_class.h
deleted file mode 100644 (file)
index aa518e4..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-or-later
- *
- */
-
-class test_class
-{
-public:
-       test_class();
-       void test_method();
-       volatile int test_member;
-};
-
-
diff --git a/tests/utils/testapp/userspace-probe-elf-cxx-binary/test_class.hpp b/tests/utils/testapp/userspace-probe-elf-cxx-binary/test_class.hpp
new file mode 100644 (file)
index 0000000..aa518e4
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ */
+
+class test_class
+{
+public:
+       test_class();
+       void test_method();
+       volatile int test_member;
+};
+
+
index 2e169c8fc4fc466d04ee70f0eb479250639d3924..544628ff9deee18bdf9e45d4c65f1745277e593c 100644 (file)
@@ -5,7 +5,7 @@
  *
  */
 
-#include "test_class.h"
+#include "test_class.hpp"
 
 volatile int not_a_function = 0;
 
index fee74e961245d02e0322f70c86c9e7d21e33cd43..0f1bd28c7e7a3da58d09abc63c5c3270347b7071 100644 (file)
@@ -5,8 +5,8 @@
  *
  */
 
-#include <common/compat/time.h>
-#include <common/time.h>
+#include <common/compat/time.hpp>
+#include <common/time.hpp>
 #include <fcntl.h>
 #include <poll.h>
 #include <stdbool.h>
@@ -17,8 +17,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <common/compat/errno.h>
-#include <common/macros.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
 
 #include "utils.h"
 
index bc5fc3e51990bd5b46cce987e71b686619f9875e..9bfd50bda83d8e8ed829e2a7277eef2ae419cc28 100644 (file)
@@ -34,7 +34,7 @@
 #include <libxml/parser.h>
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
-#include <common/defaults.h>
+#include <common/defaults.hpp>
 
 #if defined(LIBXML_XPATH_ENABLED)
 
index 92f08f203221458b5c1dce0250ce9162fa34db58..b185161b5178b84ce9e80bb4c2a4cfd0027174bc 100644 (file)
@@ -25,9 +25,7 @@
 #include <libxml/parser.h>
 
 #include <lttng/lttng-error.h>
-#include <common/macros.h>
-
-#include <common/macros.h>
+#include <common/macros.hpp>
 
 struct validation_ctx {
        xmlSchemaParserCtxtPtr parser_ctx;
This page took 0.73045 seconds and 5 git commands to generate.