Rename C++ header files to .hpp 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>
liblttng-ctl: use export list to define exported symbols Symbols are currently exported by default by liblttng-ctl.so (usable by other shared libraries / programs using liblttng-ctl.so), so we must use LTTNG_HIDDEN on all symbols that are meant to be internal to liblttng-ctl.so. Of course, this is easy to forget, so over the years many symbols that were not meant to be exported were exported, and must now stay exported to avoid breaking the ABI. As explained here [1], a better method is to make symbols hidden by default, and mark those we want to be exported as such. I have tried to use this, but when subsequently converting the code to C++, I have noticed that some symbols related to the STL were exported anyway, which is bad. The other alternative, implemented in this patch, is to use an explicit symbol export list [2], using libtool's -export-symbols (which uses the linker's -version-script option). Only the symbols listed here are exported. So, in practice, this patch: - Adds an liblttng-ctl.sym file with the list of exported symbols and adjusts the Makefile to use the -export-symbol option - Removes LTTNG_HIDDEN and all its uses abidiff shows no changes for liblttng-ctl.so between before and after this patch. [1] https://gcc.gnu.org/wiki/Visibility [2] https://www.gnu.org/software/libtool/manual/libtool.html#Link-mode Change-Id: I5d8c558303894b0ad8113c6e52f79a053bb580e1 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: liblttng-ctl: unreported truncations when copying strings gcc 10.2 reports a large number of string truncation warning in liblttng-ctl. Replace the uses of lttng_ctl_copy_string() util by lttng_strncpy() (handling the null source case when applicable) and report the truncations when they occur. Example gcc warning: lttng-ctl.c:86:3: warning: ‘strncpy’ output may be truncated copying 254 bytes from a string of length 254 [-Wstringop-truncation] Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Icca5f4c2490c6796b451999d7694db8597bae719
uprobe: transmit binary file descritptor through lttng_payload Adapt the userspace probe objects to use the lttng_payload interface. This streamlines the acquisition of the file descriptors when those objects are serialized. File descriptors are transmitted in both directions between liblttng-ctl and the session daemon making it possible (and safe) to compare userspace probe instances. Currently the event listing API does not allow us to express userspace probe locations that contain a file descriptor. This is an unfortunate consequence of returning a "flat" array to list events. Indeed, we can't store a file descriptor in the userspace probe locations returned to the user in this API since the destructors of the probe locations are never called. The user simply free()'s the returned array, which would leak the file descriptors. The consequence of this is that we can't allow the creation of event rules using a probe location returned by an lttng_list_events() call. This is not unsolvable, but I'm not sure if there really is a use-case for this. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I0f710cbe9deabfd163206fd03618eba183f3d1d2
Refactor: lttng-ctl: follow terminology of the tracker documentation This commit harmonizes the process attribute tracker API and serialization formats (save/restore and MI) with the documentation with regards to the terminology used. The message of the parent commit adjusting the manual pages of the lttng-track and lttng-untrack commands details those terminology changes and their rationale. Some problems with the API introduced during the 2.12 development cycle are also adressed: Type safety: - The process attribute tracker is made type safe with regards to the platform's native types to express process attributes. Where the original API casted all integral values to integers, this change introduces accessors for all process attribute types (pid_t, uid_t, gid_t). This makes it easier to use the API safely and without producing warnings in user's code. Another benefit of adopting this explicit type-safe approach is that is will make it easier to add new attributes which are not expressible (or non-ambiguously expressible) using `int` and `string` types (e.g. tracking a virtual PID within a given namespace). Ambiguity of INCLUDE_ALL, EXCLUDE_ALL, and INCLUDE_SET states: - The original tracker API has a notion of 'enabled' pid_tracker which is confusing to users: - enable = 0: everything is tracked, - enable = 1: a list of tracked pids is provided, which may be empty. - pid '-1' is *special* and tracks or untracks everything. This was replaced with a 'special' opaque value meaning 'ALL' which, while being clearer, was still confusing and hard to document. The revised API explicitly expresses the notion of a tracking policy (`enum lttng_tracking_policy`). When that policy is set to `LTTNG_TRACKING_POLICY_INCLUDE_SET`, the inclusion set can be queried and/or mutated. On top of being clearer, this aligns more closely with the internal lttng-sessiond daemon API which gets rid of a lot of code to handle those special cases. The resulting code is more verbose, but a lot easier to understand. Moreover, the types introduced (e.g. lttng_process_attr_values) are meant to be re-used if a new `LTTNG_TRACKING_POLICY_EXCLUDE_SET` tracking policy is added in the future. Documentation: - The revised API includes a complete documentation. It documents the API usage, but also adds implementation notes such explicitly mentionning when/where user names and group names are resolved. Client: - While making the changes to use this new API, some error messages are clarified (or added). The resulting output when listing the trackers was also changed to be more compact. The CLI output now also makes use of the terminology used in the documentation for all commands interacting with process attribute trackers. It is now also possible to specify multiple process attribute trackers along with the --all option for the lttng-track and lttng-untrack command. For instance: `lttng tracker --userspace --vpid --vuid --all` is now allowed. The same process attribute tracker can also be specified more than once in a command, as follows: `lttng track --userspace --vpid 43,11 --vpid 55,77` Since the serialization had been changed during the 2.12 cycle, I changed them further to use the API's terminology in the element names. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I5f0ea2849eb024ea6944b2ee7dbadfd893cc0be4
Move to kernel style SPDX license identifiers The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. See https://spdx.org/ids-how for details. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Change-Id: I62e7038e191a061286abcef5550b58f5ee67149d Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: wait for the completion of implicit session rotations A session that has been rotated within its lifetime will be rotated during its destruction to rename the last trace chunk. Currently, the liblttng-ctl library's session destruction function only waits for the data pending to indicate that all data has been consumed. This used to be sufficient, but it is now necessary to wait for the implicit session rotation to complete. The "wait" variant of the session destruction function will wait for any implicit session rotation to compete. A new lttng_destruction_handle class is introduced to allow a client to wait for the destruction of a session and obtain the location of the last trace archive produced by the implicit session rotation. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Add command header to sessiond->client response msg Response messages from the session daemon have this layout for the moment: [message header] (fixed size) [payload data] (0 to n bytes) This patch makes them have this layout: [message header] (fixed size) [command header] (0 to n bytes) [payload data] (0 to n bytes) The command header allows a command to specify additional informations about its payload. The header size is set to 0 for all commands for the moment. Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Health check: implement health check query in sessiond and consumerd At this stage, tests/regression/tools/health/health_check queries sessiond and consumerd with the new API, however, the scripts using this program have not yet been changed, and are therefore expected to fail. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Add a lttng-ctl header to facilitate code separation In order for lttng-ctl.c not to grow into an uncontrollable monster of code, add this helper header and remove static declaration of some functions to be exported out of the C file and set them hidden. Future work on snapshot and trigger will use it in order to better split the code into different files. Signed-off-by: David Goulet <dgoulet@efficios.com>