![]() |
LTTng control library C API
|
Macros | |
| #define | LTTNG_NAME_MAX |
| Maximum name length. | |
| #define | LTTNG_SYMBOL_NAME_LEN |
| Maximum symbol length. | |
Functions | |
| enum lttng_error_code | lttng_get_kernel_tracer_status (enum lttng_kernel_tracer_status *status) |
Sets *status to the current status of the LTTng kernel tracer. | |
| int | lttng_session_daemon_alive (void) |
| Returns whether or not liblttng-ctl is able to connect to a listening session daemon. | |
| int | lttng_set_tracing_group (const char *group) |
Sets the current Unix tracing group of liblttng-ctl to group. | |
| const char * | lttng_strerror (int error_code) |
Returns a human-readable message for the general error code error_code. | |
The general LTTng control library C API offers:
Many functions of the LTTng control library C API require a connection to a listening LTTng session daemon (see lttng-sessiond(8)) to control LTTng tracing.
liblttng-ctl connects to a session daemon through a Unix domain socket when you call some of its public functions, not when it loads.
Each Unix user may have its own independent running session daemon. However, liblttng-ctl must connect to the session daemon of the root user (the root session daemon) to control Linux kernel tracing.
How liblttng-ctl chooses which session daemon to connect to is as follows, considering U is the Unix user of the process running liblttng-ctl:
root Connect to the root session daemon.
root Try to connect to the root session daemon.
If the root session daemon isn't running, then connect to the session daemon of U.
The Unix tracing group of the root session daemon is one of:
--group=GROUP option of the root session daemon Exactly GROUP.
In that case, you must call lttng_set_tracing_group(), passing exactly GROUP, before you call a liblttng-ctl function which needs to connect to a session daemon.
--group option of the root session daemon tracing (also the default Unix tracing group of liblttng-ctl, therefore you don't need to call lttng_set_tracing_group()). Check that your application can successfully connect to a session daemon with lttng_session_daemon_alive().
LTTng-instrumented user applications automatically register to both the root and user session daemons. This makes it possible for both session daemons to list the available instrumented applications and their instrumentation points.
| enum lttng_error_code |
General error codes.
Many functions, most of them dating from older liblttng-ctl versions, return this type (or an int value which is equal to the negation of one of those enumerators).
Not all error codes are relevant to a given function: this API documentation makes an effort to document the most relevant status codes for each function. This is not always possible, however, as LTTng is made of multiple interacting components (tracers, consumer daemons, session daemons, and the rest); those error codes can move from one to another and the possible error codes of a given liblttng-ctl function can change from version to version.
| Enumerator | |
|---|---|
| LTTNG_OK | Success. |
| LTTNG_ERR_UNK | Unknown error. |
| LTTNG_ERR_UND | Undefined command. |
| LTTNG_ERR_SESSION_STARTED | Recording session already started (active). |
| LTTNG_ERR_UNKNOWN_DOMAIN | Unknown tracing domain. |
| LTTNG_ERR_NOT_SUPPORTED | Unsupported operation. |
| LTTNG_ERR_NO_SESSION | No recording session found. |
| LTTNG_ERR_CREATE_DIR_FAIL | Failed to create a directory. |
| LTTNG_ERR_SESSION_FAIL | Failed to create a recording session. |
| LTTNG_ERR_NO_SESSIOND | No available session daemon to connect to. |
| LTTNG_ERR_SET_URL | Failed to set an URL. |
| LTTNG_ERR_URL_EXIST | URL already exists. |
| LTTNG_ERR_BUFFER_NOT_SUPPORTED | Unsupported buffer ownership model. |
| LTTNG_ERR_SESS_NOT_FOUND | Nonexistent recording session name. |
| LTTNG_ERR_BUFFER_TYPE_MISMATCH | A channel within the given tracing domain already exists and is configured with another buffer ownership model. |
| LTTNG_ERR_FATAL | Fatal error. |
| LTTNG_ERR_NOMEM | Failed to allocate memory. |
| LTTNG_ERR_EXIST_SESS | Recording session name already exists. |
| LTTNG_ERR_NO_EVENT | Recording event rule not found. |
| LTTNG_ERR_CONNECT_FAIL | Failed to connect to Unix socket. |
| LTTNG_ERR_SNAPSHOT_OUTPUT_EXIST | Snapshot output already exists. |
| LTTNG_ERR_EPERM | Permission denied. |
| LTTNG_ERR_KERN_NA | Linux kernel tracer isn't available. |
| LTTNG_ERR_KERN_VERSION | Incompatible Linux kernel tracer. |
| LTTNG_ERR_KERN_EVENT_EXIST | Linux kernel recording event rule already exists. |
| LTTNG_ERR_KERN_SESS_FAIL | Linux kernel tracer: failed to create a recording session. |
| LTTNG_ERR_KERN_CHAN_EXIST | Linux kernel channel already exists. |
| LTTNG_ERR_KERN_CHAN_FAIL | Failed to create a Linux kernel channel. |
| LTTNG_ERR_KERN_CHAN_NOT_FOUND | Linux kernel channel not found. |
| LTTNG_ERR_KERN_CHAN_DISABLE_FAIL | Failed to disable a Linux kernel channel. |
| LTTNG_ERR_KERN_CHAN_ENABLE_FAIL | Failed to create/enable a Linux kernel channel. |
| LTTNG_ERR_KERN_CONTEXT_FAIL | Failed to add a context field to be recorded to the event records of a Linux kernel channel. |
| LTTNG_ERR_KERN_ENABLE_FAIL | Failed to create/enable a Linux kernel recording event rule. |
| LTTNG_ERR_KERN_DISABLE_FAIL | Failed to disable a Linux kernel recording event rule. |
| LTTNG_ERR_KERN_META_FAIL | Failed to open a Linux kernel trace metadata stream. |
| LTTNG_ERR_KERN_START_FAIL | Linux kernel tracer: failed to start tracing. |
| LTTNG_ERR_KERN_STOP_FAIL | Linux kernel tracer: failed to stop tracing. |
| LTTNG_ERR_KERN_CONSUMER_FAIL | Failed to start a Linux kernel consumer daemon. |
| LTTNG_ERR_KERN_STREAM_FAIL | Failed to create a Linux kernel trace data stream. |
| LTTNG_ERR_START_SESSION_ONCE | The recording session never became active. |
| LTTNG_ERR_SNAPSHOT_FAIL | Failed to take a recording session snapshot. |
| LTTNG_ERR_KERN_LIST_FAIL | Failed to list Linux kernel recording event rules. |
| LTTNG_ERR_UST_EVENT_ENABLED | User space recording event rule already enabled. |
| LTTNG_ERR_UST_SESS_FAIL | User space tracer: failed to create a recording session. |
| LTTNG_ERR_UST_CHAN_EXIST | User space channel already exists. |
| LTTNG_ERR_UST_CHAN_FAIL | |
| LTTNG_ERR_UST_CHAN_NOT_FOUND | User space channel not found. |
| LTTNG_ERR_UST_CHAN_DISABLE_FAIL | |
| LTTNG_ERR_UST_ENABLE_FAIL | Failed to create/enable a user space recording event rule. |
| LTTNG_ERR_UST_DISABLE_FAIL | Failed to disable a user space recording event rule. |
| LTTNG_ERR_UST_START_FAIL | User space tracer: failed to start tracing. |
| LTTNG_ERR_UST_STOP_FAIL | User space tracer: failed to stop tracing. |
| LTTNG_ERR_UST_CONSUMER64_FAIL | Failed to start a 64-bit user space consumer daemon. |
| LTTNG_ERR_UST_CONSUMER32_FAIL | Failed to start a 32-bit user space consumer daemon. |
| LTTNG_ERR_NO_CHANNEL | Recording session has no channels. |
| LTTNG_ERR_SESSION_INVALID_CHAR | Recording session name contains an invalid character. |
| LTTNG_ERR_UST_LIST_FAIL | Failed to list user space recording event rules. |
| LTTNG_ERR_UST_EVENT_EXIST | User space recording event rule already exists. |
| LTTNG_ERR_UST_EVENT_NOT_FOUND | User space recording event rule not found. |
| LTTNG_ERR_UST_CONTEXT_EXIST | Context field to be recorded to the event records of a user space channel already exists. |
| LTTNG_ERR_UST_CONTEXT_INVAL | Invalid/unknown context field type. |
| LTTNG_ERR_NEED_ROOT_SESSIOND | A root session daemon is required, but isn't available. |
| LTTNG_ERR_TRACE_ALREADY_STARTED | Recording session is already active (started). |
| LTTNG_ERR_TRACE_ALREADY_STOPPED | Recording session is already inactive (stopped). |
| LTTNG_ERR_KERN_EVENT_ENOSYS | Linux kernel instrumentation point type not supported. |
| LTTNG_ERR_NEED_CHANNEL_NAME | A channel name is required because a non-default channel exists within the selected recording session and tracing domain. |
| LTTNG_ERR_NO_UST | Channel name is required because a non-default channel exists within the recording session. |
| LTTNG_ERR_SAVE_FILE_EXIST | Recording session configuration file already exists. |
| LTTNG_ERR_SAVE_IO_FAIL | I/O error while writing a recording session configuration file. |
| LTTNG_ERR_LOAD_INVALID_CONFIG | Invalid recording session configuration file. |
| LTTNG_ERR_LOAD_IO_FAIL | I/O error while reading a recording session configuration file. |
| LTTNG_ERR_LOAD_SESSION_NOENT | Recording session configuration file not found. |
| LTTNG_ERR_MAX_SIZE_INVALID | Maximum total size of all the snapshot trace files is invalid. |
| LTTNG_ERR_INVALID | Unsatisfied precondition (invalid parameter, for example). |
| LTTNG_ERR_NO_USTCONSUMERD | No user space consumer daemon available. |
| LTTNG_ERR_NO_KERNCONSUMERD | No Linux kernel consumer daemon available. |
| LTTNG_ERR_URL_DATA_MISS | Missing network data URL. |
| LTTNG_ERR_URL_CTRL_MISS | Missing network control URL. |
| LTTNG_ERR_ENABLE_CONSUMER_FAIL | Failed to communicate with a consumer daemon. |
| LTTNG_ERR_RELAYD_CONNECT_FAIL | Failed to connect to or communicate with a relay daemon (see |
| LTTNG_ERR_RELAYD_VERSION_FAIL | Incompatible relay daemon (see |
| LTTNG_ERR_FILTER_INVAL | |
| LTTNG_ERR_FILTER_NOMEM | Failed to allocate memory for a context and event payload filter object. |
| LTTNG_ERR_NO_CONSUMER | No available consumer daemon. |
| LTTNG_ERR_EXCLUSION_INVAL | Invalid event name exclusion data. |
| LTTNG_ERR_EXCLUSION_NOMEM | Failed to allocate memory for an event name exclusion object. |
| LTTNG_ERR_INVALID_EVENT_NAME | Invalid event name condition part of a recording event rule. |
| LTTNG_ERR_INVALID_CHANNEL_NAME | Invalid channel name. |
| LTTNG_ERR_PROCESS_ATTR_EXISTS | Process attribute is already part of an inclusion set. |
| LTTNG_ERR_PROCESS_ATTR_MISSING | Process attribute isn't part of an inclusion set. |
| LTTNG_ERR_INVALID_CHANNEL_DOMAIN | Invalid tracing domain for channel. |
| LTTNG_ERR_OVERFLOW | Overflow. |
| LTTNG_ERR_SESSION_NOT_STARTED | Recording session isn't active (started). |
| LTTNG_ERR_LIVE_SESSION | Unsupported LTTng live recording session mode. |
| LTTNG_ERR_PER_PID_SESSION | Unsupported process buffer ownership model. |
| LTTNG_ERR_KERN_CONTEXT_UNAVAILABLE | Context field type isn't available on the current Linux kernel. |
| LTTNG_ERR_REGEN_STATEDUMP_FAIL | |
| LTTNG_ERR_REGEN_STATEDUMP_NOMEM | Failed to allocate memory to regenerate the LTTng state dump event records. |
| LTTNG_ERR_NOT_SNAPSHOT_SESSION | Recording session isn't in snapshot mode. |
| LTTNG_ERR_INVALID_TRIGGER | Invalid trigger. |
| LTTNG_ERR_TRIGGER_EXISTS | Trigger already exists (registered). |
| LTTNG_ERR_TRIGGER_NOT_FOUND | Trigger not found. |
| LTTNG_ERR_ROTATION_PENDING | Recording session rotation operation already in progress. |
| LTTNG_ERR_ROTATION_NOT_AVAILABLE | Recording session rotation feature isn't available for the mode of the given recording session. |
| LTTNG_ERR_ROTATION_SCHEDULE_SET | Recording session rotation schedule already set. |
| LTTNG_ERR_ROTATION_SCHEDULE_NOT_SET | Recording session rotation schedule isn't set. |
| LTTNG_ERR_ROTATION_MULTIPLE_AFTER_STOP | LTTng already archived the current trace chunk of the recording session since it became inactive (stopped). |
| LTTNG_ERR_ROTATION_WRONG_VERSION | Linux kernel tracer: unavailable recording session rotation feature. |
| LTTNG_ERR_NO_SESSION_OUTPUT | Recording session has no configured output. |
| LTTNG_ERR_ROTATION_NOT_AVAILABLE_RELAY | Relay daemon: unavailable recording session rotation feature. |
| LTTNG_ERR_AGENT_TRACING_DISABLED | Unavailable logging instrumentation point feature. |
| LTTNG_ERR_PROBE_LOCATION_INVAL | Invalid user space probe location. |
| LTTNG_ERR_ELF_PARSING | Failed to parse ELF file. |
| LTTNG_ERR_SDT_PROBE_SEMAPHORE | SystemTap User-level Statically Defined Tracing (USDT) probe guarded by a semaphore. |
| LTTNG_ERR_ROTATION_FAIL_CONSUMER | Consumer daemon failed to perform a recording session rotation operation. |
| LTTNG_ERR_CHAN_NOT_FOUND | Channel not found. |
| LTTNG_ERR_SNAPSHOT_UNSUPPORTED | Cannot take a snapshot with the current recording session configuration. |
| LTTNG_ERR_SESSION_NOT_EXIST | Nonexistent recording session. |
| LTTNG_ERR_CREATE_TRACE_CHUNK_FAIL_CONSUMER | Consumer daemon failed to create a trace chunk archive. |
| LTTNG_ERR_CLOSE_TRACE_CHUNK_FAIL_CONSUMER | Consumer daemon failed to close a trace chunk archive. |
| LTTNG_ERR_INVALID_PROTOCOL | Invalid protocol. |
| LTTNG_ERR_FILE_CREATION_ERROR | Failed to create a file. |
| LTTNG_ERR_TIMER_STOP_ERROR | Failed to stop a timer. |
| LTTNG_ERR_ROTATION_NOT_AVAILABLE_KERNEL | Linux kernel tracer: recording session rotation feature isn't available. |
| LTTNG_ERR_CLEAR_RELAY_DISALLOWED | The relay daemon (see |
| LTTNG_ERR_CLEAR_NOT_AVAILABLE_RELAY | The relay daemon (see |
| LTTNG_ERR_CLEAR_FAIL_CONSUMER | Consumer daemon failed to clear the recording session. |
| LTTNG_ERR_ROTATION_AFTER_STOP_CLEAR | LTTng already cleared the recording session since it became inactive (stopped). |
| LTTNG_ERR_PROCESS_ATTR_TRACKER_INVALID_TRACKING_POLICY | Invalid operation considering the policy of the process filter. |
| LTTNG_ERR_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD | Failed to initialize the file descriptor of the event notifier group notification. |
| LTTNG_ERR_INVALID_CAPTURE_EXPRESSION | Invalid event field capture expression. |
| LTTNG_ERR_EVENT_NOTIFIER_REGISTRATION | Failed to register the event notifier to the tracer. |
| LTTNG_ERR_EVENT_NOTIFIER_ERROR_ACCOUNTING | Failed to initialize the event notifier error accounting. |
| LTTNG_ERR_EVENT_NOTIFIER_ERROR_ACCOUNTING_FULL | Event notifier error accouting is full. |
| LTTNG_ERR_INVALID_ERROR_QUERY_TARGET | Invalid error query target. |
| LTTNG_ERR_BUFFER_FLUSH_FAILED | Failed to flush a buffer. |
| LTTNG_ERR_PID_TRACKED | Process attribute is already part of an inclusion set. |
| LTTNG_ERR_PID_NOT_TRACKED | Process attribute isn't part of an inclusion set. |
The status of an LTTng kernel tracer.
|
extern |
Sets *status to the current status of the LTTng kernel tracer.
| [out] | status | On success, this function sets *status to the current status of the kernel tracer. |
| LTTNG_OK | Success. |
| LTTNG_ERR_INVALID | Unsatisfied precondition. |
status is not NULL.
|
extern |
Returns whether or not liblttng-ctl is able to connect to a listening session daemon.
How this function tries to connect to a session daemon depends on the current Unix tracing group (initially tracing) of the library. Set the tracing group with lttng_set_tracing_group().
One of:
liblttng-ctl is able to connect to a session daemon.
liblttng-ctl isn't able to connect to a session daemon.
|
extern |
Sets the current Unix tracing group of liblttng-ctl to group.
How the liblttng-ctl functions connect to a session daemon depends on the current Unix tracing group (initially tracing) of the library.
| [in] | group | New Unix tracing group of liblttng-ctl (copied). |
Success.
Unsatisfied precondition.
group is not NULL.group names an existing Unix group.
|
extern |
Returns a human-readable message for the general error code error_code.
| [in] | error_code | Error code (one of the lttng_error_code enumerators), positive or negative, for which to get a corresponding human-readable message. |
error_code.error_code is a valid lttng_error_code enumerator.