*/
#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 <fcntl.h>
+
+#include <common/align.hpp>
+#include <common/compat/string.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 <lttng/constant.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/userspace-probe-internal.hpp>
+
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-static
-int lttng_userspace_probe_location_function_set_binary_fd_handle(
- struct lttng_userspace_probe_location *location,
- struct fd_handle *binary_fd_handle);
+static int lttng_userspace_probe_location_function_set_binary_fd_handle(
+ struct lttng_userspace_probe_location *location, struct fd_handle *binary_fd_handle);
-static
-int lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
- struct lttng_userspace_probe_location *location,
- struct fd_handle *binary_fd_handle);
+static int lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
+ struct lttng_userspace_probe_location *location, struct fd_handle *binary_fd_handle);
-static
-enum lttng_error_code lttng_userspace_probe_location_lookup_method_mi_serialize(
- const struct lttng_userspace_probe_location_lookup_method
- *method,
- struct mi_writer *writer);
+static enum lttng_error_code lttng_userspace_probe_location_lookup_method_mi_serialize(
+ const struct lttng_userspace_probe_location_lookup_method *method,
+ struct mi_writer *writer);
-static
-enum lttng_error_code lttng_userspace_probe_location_tracepoint_mi_serialize(
- const struct lttng_userspace_probe_location *location,
- struct mi_writer *writer);
+static enum lttng_error_code lttng_userspace_probe_location_tracepoint_mi_serialize(
+ const struct lttng_userspace_probe_location *location, struct mi_writer *writer);
-static
-enum lttng_error_code lttng_userspace_probe_location_function_mi_serialize(
- const struct lttng_userspace_probe_location *location,
- struct mi_writer *writer);
+static enum lttng_error_code lttng_userspace_probe_location_function_mi_serialize(
+ const struct lttng_userspace_probe_location *location, struct mi_writer *writer);
enum lttng_userspace_probe_location_lookup_method_type
lttng_userspace_probe_location_lookup_method_get_type(
- const struct lttng_userspace_probe_location_lookup_method *lookup_method)
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
return lookup_method ? lookup_method->type :
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_UNKNOWN;
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_UNKNOWN;
}
void lttng_userspace_probe_location_lookup_method_destroy(
- struct lttng_userspace_probe_location_lookup_method *lookup_method)
+ struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
- if (!lookup_method){
+ if (!lookup_method) {
return;
}
struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_lookup_method_function_elf_create(void)
{
- struct lttng_userspace_probe_location_lookup_method *ret = NULL;
+ struct lttng_userspace_probe_location_lookup_method *ret = nullptr;
struct lttng_userspace_probe_location_lookup_method_elf *elf_method;
- elf_method = (lttng_userspace_probe_location_lookup_method_elf *) zmalloc(sizeof(*elf_method));
+ elf_method = zmalloc<lttng_userspace_probe_location_lookup_method_elf>();
if (!elf_method) {
PERROR("zmalloc");
goto end;
struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_lookup_method_tracepoint_sdt_create(void)
{
- struct lttng_userspace_probe_location_lookup_method *ret = NULL;
+ struct lttng_userspace_probe_location_lookup_method *ret = nullptr;
struct lttng_userspace_probe_location_lookup_method_sdt *sdt_method;
- sdt_method = (lttng_userspace_probe_location_lookup_method_sdt *) zmalloc(sizeof(*sdt_method));
+ sdt_method = zmalloc<lttng_userspace_probe_location_lookup_method_sdt>();
if (!sdt_method) {
PERROR("zmalloc");
goto end;
return ret;
}
-enum lttng_userspace_probe_location_type lttng_userspace_probe_location_get_type(
- const struct lttng_userspace_probe_location *location)
+enum lttng_userspace_probe_location_type
+lttng_userspace_probe_location_get_type(const struct lttng_userspace_probe_location *location)
{
- return location ? location->type :
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_UNKNOWN;
+ return location ? location->type : LTTNG_USERSPACE_PROBE_LOCATION_TYPE_UNKNOWN;
}
-static
-void lttng_userspace_probe_location_function_destroy(
- struct lttng_userspace_probe_location *location)
+static void
+lttng_userspace_probe_location_function_destroy(struct lttng_userspace_probe_location *location)
{
- struct lttng_userspace_probe_location_function *location_function = NULL;
+ struct lttng_userspace_probe_location_function *location_function = nullptr;
LTTNG_ASSERT(location);
- location_function = container_of(location,
- struct lttng_userspace_probe_location_function, parent);
+ location_function = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
LTTNG_ASSERT(location_function);
free(location);
}
-static
-void lttng_userspace_probe_location_tracepoint_destroy(
- struct lttng_userspace_probe_location *location)
+static void
+lttng_userspace_probe_location_tracepoint_destroy(struct lttng_userspace_probe_location *location)
{
- struct lttng_userspace_probe_location_tracepoint *location_tracepoint = NULL;
+ struct lttng_userspace_probe_location_tracepoint *location_tracepoint = nullptr;
LTTNG_ASSERT(location);
- location_tracepoint = container_of(location,
- struct lttng_userspace_probe_location_tracepoint,
- parent);
+ location_tracepoint = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
LTTNG_ASSERT(location_tracepoint);
free(location);
}
-void lttng_userspace_probe_location_destroy(
- struct lttng_userspace_probe_location *location)
+void lttng_userspace_probe_location_destroy(struct lttng_userspace_probe_location *location)
{
if (!location) {
return;
}
- lttng_userspace_probe_location_lookup_method_destroy(
- location->lookup_method);
+ lttng_userspace_probe_location_lookup_method_destroy(location->lookup_method);
switch (location->type) {
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
/* Both are valid file descriptors. */
ret = fstat(a, &a_stat);
if (ret) {
- PERROR("Failed to fstat userspace probe location binary fd %d",
- a);
+ PERROR("Failed to fstat userspace probe location binary fd %d", a);
goto end;
}
ret = fstat(b, &b_stat);
if (ret) {
- PERROR("Failed to fstat userspace probe location binary fd %d",
- b);
+ PERROR("Failed to fstat userspace probe location binary fd %d", b);
goto end;
}
- is_equal = (a_stat.st_ino == b_stat.st_ino) &&
- (a_stat.st_dev == b_stat.st_dev);
+ is_equal = (a_stat.st_ino == b_stat.st_ino) && (a_stat.st_dev == b_stat.st_dev);
end:
return is_equal;
}
-static unsigned long lttng_userspace_probe_location_function_hash(
- const struct lttng_userspace_probe_location *location)
+static unsigned long
+lttng_userspace_probe_location_function_hash(const struct lttng_userspace_probe_location *location)
{
- unsigned long hash = hash_key_ulong(
- (void *) LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION,
- lttng_ht_seed);
+ unsigned long hash = hash_key_ulong((void *) LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION,
+ lttng_ht_seed);
struct lttng_userspace_probe_location_function *function_location =
- container_of(location, typeof(*function_location),
- parent);
+ lttng::utils::container_of(location,
+ <tng_userspace_probe_location_function::parent);
hash ^= hash_key_str(function_location->function_name, lttng_ht_seed);
hash ^= hash_key_str(function_location->binary_path, lttng_ht_seed);
return hash;
}
-static bool lttng_userspace_probe_location_function_is_equal(
- const struct lttng_userspace_probe_location *_a,
- const struct lttng_userspace_probe_location *_b)
+static bool
+lttng_userspace_probe_location_function_is_equal(const struct lttng_userspace_probe_location *_a,
+ const struct lttng_userspace_probe_location *_b)
{
bool is_equal = false;
struct lttng_userspace_probe_location_function *a, *b;
- a = container_of(_a, struct lttng_userspace_probe_location_function,
- parent);
- b = container_of(_b, struct lttng_userspace_probe_location_function,
- parent);
+ a = lttng::utils::container_of(_a, <tng_userspace_probe_location_function::parent);
+ b = lttng::utils::container_of(_b, <tng_userspace_probe_location_function::parent);
if (a->instrumentation_type != b->instrumentation_type) {
goto end;
LTTNG_ASSERT(a->function_name);
LTTNG_ASSERT(b->function_name);
- if (strcmp(a->function_name, b->function_name)) {
+ if (strcmp(a->function_name, b->function_name) != 0) {
goto end;
}
LTTNG_ASSERT(a->binary_path);
LTTNG_ASSERT(b->binary_path);
- if (strcmp(a->binary_path, b->binary_path)) {
+ if (strcmp(a->binary_path, b->binary_path) != 0) {
goto end;
}
is_equal = fd_is_equal(a->binary_fd_handle ? fd_handle_get_fd(a->binary_fd_handle) : -1,
- b->binary_fd_handle ? fd_handle_get_fd(b->binary_fd_handle) : -1);
+ b->binary_fd_handle ? fd_handle_get_fd(b->binary_fd_handle) : -1);
end:
return is_equal;
}
static struct lttng_userspace_probe_location *
-lttng_userspace_probe_location_function_create_no_check(const char *binary_path,
- const char *function_name,
- struct lttng_userspace_probe_location_lookup_method *lookup_method,
- bool open_binary)
+lttng_userspace_probe_location_function_create_no_check(
+ const char *binary_path,
+ const char *function_name,
+ struct lttng_userspace_probe_location_lookup_method *lookup_method,
+ bool open_binary)
{
int binary_fd = -1;
- struct fd_handle *binary_fd_handle = NULL;
- char *function_name_copy = NULL, *binary_path_copy = NULL;
- struct lttng_userspace_probe_location *ret = NULL;
+ struct fd_handle *binary_fd_handle = nullptr;
+ char *function_name_copy = nullptr, *binary_path_copy = nullptr;
+ struct lttng_userspace_probe_location *ret = nullptr;
struct lttng_userspace_probe_location_function *location;
if (open_binary) {
goto error;
}
- location = (lttng_userspace_probe_location_function *) zmalloc(sizeof(*location));
+ location = zmalloc<lttng_userspace_probe_location_function>();
if (!location) {
PERROR("Error allocating userspace probe location");
goto error;
location->function_name = function_name_copy;
location->binary_path = binary_path_copy;
location->binary_fd_handle = binary_fd_handle;
- binary_fd_handle = NULL;
+ binary_fd_handle = nullptr;
location->instrumentation_type =
- LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY;
+ LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY;
ret = &location->parent;
ret->lookup_method = lookup_method;
}
static unsigned long lttng_userspace_probe_location_tracepoint_hash(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
- unsigned long hash = hash_key_ulong(
- (void *) LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT,
- lttng_ht_seed);
- struct lttng_userspace_probe_location_tracepoint *tp_location =
- container_of(location, typeof(*tp_location), parent);
+ unsigned long hash = hash_key_ulong((void *) LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT,
+ lttng_ht_seed);
+ struct lttng_userspace_probe_location_tracepoint *tp_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
hash ^= hash_key_str(tp_location->probe_name, lttng_ht_seed);
hash ^= hash_key_str(tp_location->provider_name, lttng_ht_seed);
return hash;
}
-static bool lttng_userspace_probe_location_tracepoint_is_equal(
- const struct lttng_userspace_probe_location *_a,
- const struct lttng_userspace_probe_location *_b)
+static bool
+lttng_userspace_probe_location_tracepoint_is_equal(const struct lttng_userspace_probe_location *_a,
+ const struct lttng_userspace_probe_location *_b)
{
bool is_equal = false;
struct lttng_userspace_probe_location_tracepoint *a, *b;
- a = container_of(_a, struct lttng_userspace_probe_location_tracepoint,
- parent);
- b = container_of(_b, struct lttng_userspace_probe_location_tracepoint,
- parent);
+ a = lttng::utils::container_of(_a, <tng_userspace_probe_location_tracepoint::parent);
+ b = lttng::utils::container_of(_b, <tng_userspace_probe_location_tracepoint::parent);
LTTNG_ASSERT(a->probe_name);
LTTNG_ASSERT(b->probe_name);
- if (strcmp(a->probe_name, b->probe_name)) {
+ if (strcmp(a->probe_name, b->probe_name) != 0) {
goto end;
}
LTTNG_ASSERT(a->provider_name);
LTTNG_ASSERT(b->provider_name);
- if (strcmp(a->provider_name, b->provider_name)) {
+ if (strcmp(a->provider_name, b->provider_name) != 0) {
goto end;
}
LTTNG_ASSERT(a->binary_path);
LTTNG_ASSERT(b->binary_path);
- if (strcmp(a->binary_path, b->binary_path)) {
+ if (strcmp(a->binary_path, b->binary_path) != 0) {
goto end;
}
is_equal = fd_is_equal(a->binary_fd_handle ? fd_handle_get_fd(a->binary_fd_handle) : -1,
- b->binary_fd_handle ? fd_handle_get_fd(b->binary_fd_handle) : -1);
+ b->binary_fd_handle ? fd_handle_get_fd(b->binary_fd_handle) : -1);
end:
return is_equal;
}
static struct lttng_userspace_probe_location *
-lttng_userspace_probe_location_tracepoint_create_no_check(const char *binary_path,
- const char *provider_name, const char *probe_name,
- struct lttng_userspace_probe_location_lookup_method *lookup_method,
- bool open_binary)
+lttng_userspace_probe_location_tracepoint_create_no_check(
+ const char *binary_path,
+ const char *provider_name,
+ const char *probe_name,
+ struct lttng_userspace_probe_location_lookup_method *lookup_method,
+ bool open_binary)
{
int binary_fd = -1;
- struct fd_handle *binary_fd_handle = NULL;
- char *probe_name_copy = NULL;
- char *provider_name_copy = NULL;
- char *binary_path_copy = NULL;
- struct lttng_userspace_probe_location *ret = NULL;
+ struct fd_handle *binary_fd_handle = nullptr;
+ char *probe_name_copy = nullptr;
+ char *provider_name_copy = nullptr;
+ char *binary_path_copy = nullptr;
+ struct lttng_userspace_probe_location *ret = nullptr;
struct lttng_userspace_probe_location_tracepoint *location;
if (open_binary) {
goto error;
}
- location = (lttng_userspace_probe_location_tracepoint *) zmalloc(sizeof(*location));
+ location = zmalloc<lttng_userspace_probe_location_tracepoint>();
if (!location) {
PERROR("zmalloc");
goto error;
location->provider_name = provider_name_copy;
location->binary_path = binary_path_copy;
location->binary_fd_handle = binary_fd_handle;
- binary_fd_handle = NULL;
+ binary_fd_handle = nullptr;
ret = &location->parent;
ret->lookup_method = lookup_method;
return ret;
}
-struct lttng_userspace_probe_location *
-lttng_userspace_probe_location_function_create(const char *binary_path,
- const char *function_name,
- struct lttng_userspace_probe_location_lookup_method *lookup_method)
+struct lttng_userspace_probe_location *lttng_userspace_probe_location_function_create(
+ const char *binary_path,
+ const char *function_name,
+ struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
- struct lttng_userspace_probe_location *ret = NULL;
+ struct lttng_userspace_probe_location *ret = nullptr;
if (!binary_path || !function_name) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- switch (lttng_userspace_probe_location_lookup_method_get_type(
- lookup_method)) {
+ switch (lttng_userspace_probe_location_lookup_method_get_type(lookup_method)) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
break;
}
ret = lttng_userspace_probe_location_function_create_no_check(
- binary_path, function_name, lookup_method, true);
+ binary_path, function_name, lookup_method, true);
end:
return ret;
}
-struct lttng_userspace_probe_location *
-lttng_userspace_probe_location_tracepoint_create(const char *binary_path,
- const char *provider_name, const char *probe_name,
- struct lttng_userspace_probe_location_lookup_method *lookup_method)
+struct lttng_userspace_probe_location *lttng_userspace_probe_location_tracepoint_create(
+ const char *binary_path,
+ const char *provider_name,
+ const char *probe_name,
+ struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
- struct lttng_userspace_probe_location *ret = NULL;
+ struct lttng_userspace_probe_location *ret = nullptr;
if (!binary_path || !probe_name || !provider_name) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- switch (lttng_userspace_probe_location_lookup_method_get_type(
- lookup_method)) {
+ switch (lttng_userspace_probe_location_lookup_method_get_type(lookup_method)) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
break;
default:
}
ret = lttng_userspace_probe_location_tracepoint_create_no_check(
- binary_path, provider_name, probe_name, lookup_method, true);
+ binary_path, provider_name, probe_name, lookup_method, true);
end:
return ret;
}
static struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_lookup_method_function_elf_copy(
- const struct lttng_userspace_probe_location_lookup_method *lookup_method)
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
- struct lttng_userspace_probe_location_lookup_method *parent = NULL;
+ struct lttng_userspace_probe_location_lookup_method *parent = nullptr;
struct lttng_userspace_probe_location_lookup_method_elf *elf_method;
LTTNG_ASSERT(lookup_method);
LTTNG_ASSERT(lookup_method->type ==
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF);
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF);
- elf_method = (lttng_userspace_probe_location_lookup_method_elf *) zmalloc(sizeof(*elf_method));
+ elf_method = zmalloc<lttng_userspace_probe_location_lookup_method_elf>();
if (!elf_method) {
PERROR("Error allocating ELF userspace probe lookup method");
goto error;
goto end;
error:
- parent = NULL;
+ parent = nullptr;
end:
return parent;
}
static struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_lookup_method_tracepoint_sdt_copy(
- struct lttng_userspace_probe_location_lookup_method *lookup_method)
+ struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
- struct lttng_userspace_probe_location_lookup_method *parent = NULL;
+ struct lttng_userspace_probe_location_lookup_method *parent = nullptr;
struct lttng_userspace_probe_location_lookup_method_sdt *sdt_method;
LTTNG_ASSERT(lookup_method);
LTTNG_ASSERT(lookup_method->type ==
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT);
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT);
- sdt_method = (lttng_userspace_probe_location_lookup_method_sdt *) zmalloc(sizeof(*sdt_method));
+ sdt_method = zmalloc<lttng_userspace_probe_location_lookup_method_sdt>();
if (!sdt_method) {
PERROR("zmalloc");
goto error;
goto end;
error:
- parent = NULL;
+ parent = nullptr;
end:
return parent;
}
static struct lttng_userspace_probe_location *
-lttng_userspace_probe_location_function_copy(
- const struct lttng_userspace_probe_location *location)
+lttng_userspace_probe_location_function_copy(const struct lttng_userspace_probe_location *location)
{
enum lttng_userspace_probe_location_lookup_method_type lookup_type;
- struct lttng_userspace_probe_location *new_location = NULL;
- struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
- const char *binary_path = NULL;
- const char *function_name = NULL;
+ struct lttng_userspace_probe_location *new_location = nullptr;
+ struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
+ const char *binary_path = nullptr;
+ const char *function_name = nullptr;
struct lttng_userspace_probe_location_function *function_location;
LTTNG_ASSERT(location);
LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
- function_location = container_of(
- location, typeof(*function_location), parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
- /* Get probe location fields */
+ /* Get probe location fields */
binary_path = lttng_userspace_probe_location_function_get_binary_path(location);
if (!binary_path) {
ERR("Userspace probe binary path is NULL");
/*
* Duplicate probe location method fields
*/
- lookup_type = lttng_userspace_probe_location_lookup_method_get_type(
- location->lookup_method);
+ lookup_type =
+ lttng_userspace_probe_location_lookup_method_get_type(location->lookup_method);
switch (lookup_type) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
- lookup_method =
- lttng_userspace_probe_location_lookup_method_function_elf_copy(
- location->lookup_method);
+ lookup_method = lttng_userspace_probe_location_lookup_method_function_elf_copy(
+ location->lookup_method);
if (!lookup_method) {
goto error;
}
/* Create the probe_location */
new_location = lttng_userspace_probe_location_function_create_no_check(
- binary_path, function_name, lookup_method, false);
+ binary_path, function_name, lookup_method, false);
if (!new_location) {
goto destroy_lookup_method;
}
/* Set the duplicated fd to the new probe_location */
- if (lttng_userspace_probe_location_function_set_binary_fd_handle(new_location,
- function_location->binary_fd_handle) < 0) {
+ if (lttng_userspace_probe_location_function_set_binary_fd_handle(
+ new_location, function_location->binary_fd_handle) < 0) {
goto destroy_probe_location;
}
destroy_lookup_method:
lttng_userspace_probe_location_lookup_method_destroy(lookup_method);
error:
- new_location = NULL;
+ new_location = nullptr;
end:
return new_location;
}
-static struct lttng_userspace_probe_location *
-lttng_userspace_probe_location_tracepoint_copy(
- const struct lttng_userspace_probe_location *location)
+static struct lttng_userspace_probe_location *lttng_userspace_probe_location_tracepoint_copy(
+ const struct lttng_userspace_probe_location *location)
{
enum lttng_userspace_probe_location_lookup_method_type lookup_type;
- struct lttng_userspace_probe_location *new_location = NULL;
- struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
- const char *binary_path = NULL;
- const char *probe_name = NULL;
- const char *provider_name = NULL;
+ struct lttng_userspace_probe_location *new_location = nullptr;
+ struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
+ const char *binary_path = nullptr;
+ const char *probe_name = nullptr;
+ const char *provider_name = nullptr;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
LTTNG_ASSERT(location);
LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
- tracepoint_location = container_of(
- location, typeof(*tracepoint_location), parent);
+ tracepoint_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
/* Get probe location fields */
binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(location);
/*
* Duplicate probe location method fields
*/
- lookup_type = lttng_userspace_probe_location_lookup_method_get_type(
- location->lookup_method);
+ lookup_type =
+ lttng_userspace_probe_location_lookup_method_get_type(location->lookup_method);
switch (lookup_type) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
- lookup_method =
- lttng_userspace_probe_location_lookup_method_tracepoint_sdt_copy(
- location->lookup_method);
+ lookup_method = lttng_userspace_probe_location_lookup_method_tracepoint_sdt_copy(
+ location->lookup_method);
if (!lookup_method) {
goto error;
}
/* Create the probe_location */
new_location = lttng_userspace_probe_location_tracepoint_create_no_check(
- binary_path, provider_name, probe_name, lookup_method, false);
+ binary_path, provider_name, probe_name, lookup_method, false);
if (!new_location) {
goto destroy_lookup_method;
}
/* Set the duplicated fd to the new probe_location */
- if (lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(new_location,
- tracepoint_location->binary_fd_handle) < 0) {
+ if (lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
+ new_location, tracepoint_location->binary_fd_handle) < 0) {
goto destroy_probe_location;
}
destroy_lookup_method:
lttng_userspace_probe_location_lookup_method_destroy(lookup_method);
error:
- new_location = NULL;
+ new_location = nullptr;
end:
return new_location;
}
const char *lttng_userspace_probe_location_function_get_binary_path(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
struct lttng_userspace_probe_location_function *function_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- function_location = container_of(location,
- struct lttng_userspace_probe_location_function,
- parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
ret = function_location->binary_path;
end:
return ret;
}
const char *lttng_userspace_probe_location_tracepoint_get_binary_path(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- tracepoint_location = container_of(location,
- struct lttng_userspace_probe_location_tracepoint,
- parent);
+ tracepoint_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
ret = tracepoint_location->binary_path;
end:
return ret;
}
const char *lttng_userspace_probe_location_function_get_function_name(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
struct lttng_userspace_probe_location_function *function_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- function_location = container_of(location,
- struct lttng_userspace_probe_location_function, parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
ret = function_location->function_name;
end:
return ret;
}
const char *lttng_userspace_probe_location_tracepoint_get_probe_name(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- tracepoint_location = container_of(location,
- struct lttng_userspace_probe_location_tracepoint, parent);
+ tracepoint_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
ret = tracepoint_location->probe_name;
end:
return ret;
}
const char *lttng_userspace_probe_location_tracepoint_get_provider_name(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
- const char *ret = NULL;
+ const char *ret = nullptr;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- tracepoint_location = container_of(location,
- struct lttng_userspace_probe_location_tracepoint, parent);
+ tracepoint_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
ret = tracepoint_location->provider_name;
end:
return ret;
}
int lttng_userspace_probe_location_function_get_binary_fd(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
int ret = -1;
struct lttng_userspace_probe_location_function *function_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- function_location = container_of(location,
- struct lttng_userspace_probe_location_function, parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
ret = function_location->binary_fd_handle ?
- fd_handle_get_fd(function_location->binary_fd_handle) : -1;
+ fd_handle_get_fd(function_location->binary_fd_handle) :
+ -1;
end:
return ret;
}
enum lttng_userspace_probe_location_function_instrumentation_type
lttng_userspace_probe_location_function_get_instrumentation_type(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
enum lttng_userspace_probe_location_function_instrumentation_type type;
struct lttng_userspace_probe_location_function *function_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
type = LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_UNKNOWN;
goto end;
}
- function_location = container_of(location,
- struct lttng_userspace_probe_location_function, parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
type = function_location->instrumentation_type;
end:
return type;
enum lttng_userspace_probe_location_status
lttng_userspace_probe_location_function_set_instrumentation_type(
- const struct lttng_userspace_probe_location *location,
- enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type)
+ const struct lttng_userspace_probe_location *location,
+ enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type)
{
enum lttng_userspace_probe_location_status status =
- LTTNG_USERSPACE_PROBE_LOCATION_STATUS_OK;
+ LTTNG_USERSPACE_PROBE_LOCATION_STATUS_OK;
struct lttng_userspace_probe_location_function *function_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION ||
- instrumentation_type !=
- LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION ||
+ instrumentation_type !=
+ LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
status = LTTNG_USERSPACE_PROBE_LOCATION_STATUS_INVALID;
goto end;
}
- function_location = container_of(location,
- struct lttng_userspace_probe_location_function, parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
function_location->instrumentation_type = instrumentation_type;
end:
return status;
}
int lttng_userspace_probe_location_tracepoint_get_binary_fd(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
int ret = -1;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- tracepoint_location = container_of(location,
- struct lttng_userspace_probe_location_tracepoint, parent);
+ tracepoint_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
ret = tracepoint_location->binary_fd_handle ?
- fd_handle_get_fd(tracepoint_location->binary_fd_handle) : -1;
+ fd_handle_get_fd(tracepoint_location->binary_fd_handle) :
+ -1;
end:
return ret;
}
static struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_function_get_lookup_method(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
- struct lttng_userspace_probe_location_lookup_method *ret = NULL;
+ struct lttng_userspace_probe_location_lookup_method *ret = nullptr;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
static struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_tracepoint_get_lookup_method(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
- struct lttng_userspace_probe_location_lookup_method *ret = NULL;
+ struct lttng_userspace_probe_location_lookup_method *ret = nullptr;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
const struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_get_lookup_method(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
- struct lttng_userspace_probe_location_lookup_method *ret = NULL;
+ struct lttng_userspace_probe_location_lookup_method *ret = nullptr;
LTTNG_ASSERT(location);
switch (location->type) {
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
- ret = lttng_userspace_probe_location_function_get_lookup_method(
- location);
+ ret = lttng_userspace_probe_location_function_get_lookup_method(location);
break;
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
- ret = lttng_userspace_probe_location_tracepoint_get_lookup_method(
- location);
+ ret = lttng_userspace_probe_location_tracepoint_get_lookup_method(location);
break;
default:
ERR("Unknowned lookup method.");
return ret;
}
-static
-int lttng_userspace_probe_location_lookup_method_serialize(
- struct lttng_userspace_probe_location_lookup_method *method,
- struct lttng_payload *payload)
+static int lttng_userspace_probe_location_lookup_method_serialize(
+ struct lttng_userspace_probe_location_lookup_method *method, struct lttng_payload *payload)
{
int ret;
- struct lttng_userspace_probe_location_lookup_method_comm
- lookup_method_comm;
+ struct lttng_userspace_probe_location_lookup_method_comm lookup_method_comm;
- lookup_method_comm.type = (int8_t) (method ? method->type :
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT);
+ lookup_method_comm.type =
+ (int8_t) (method ?
+ method->type :
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT);
if (payload) {
- ret = lttng_dynamic_buffer_append(&payload->buffer, &lookup_method_comm,
- sizeof(lookup_method_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &lookup_method_comm, sizeof(lookup_method_comm));
if (ret) {
goto end;
}
return ret;
}
-static
-int lttng_userspace_probe_location_function_serialize(
- const struct lttng_userspace_probe_location *location,
- struct lttng_payload *payload)
+static int lttng_userspace_probe_location_function_serialize(
+ const struct lttng_userspace_probe_location *location, struct lttng_payload *payload)
{
int ret;
size_t function_name_len, binary_path_len;
LTTNG_ASSERT(location);
LTTNG_ASSERT(lttng_userspace_probe_location_get_type(location) ==
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
- location_function = container_of(location,
- struct lttng_userspace_probe_location_function,
- parent);
+ location_function = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
if (!location_function->function_name || !location_function->binary_path) {
ret = -LTTNG_ERR_INVALID;
goto end;
location_function_comm.binary_path_len = binary_path_len + 1;
if (payload) {
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- &location_function_comm,
- sizeof(location_function_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &location_function_comm, sizeof(location_function_comm));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
ret = lttng_dynamic_buffer_append(&payload->buffer,
- location_function->function_name,
- location_function_comm.function_name_len);
+ location_function->function_name,
+ location_function_comm.function_name_len);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
ret = lttng_dynamic_buffer_append(&payload->buffer,
- location_function->binary_path,
- location_function_comm.binary_path_len);
+ location_function->binary_path,
+ location_function_comm.binary_path_len);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- ret = lttng_payload_push_fd_handle(
- payload, location_function->binary_fd_handle);
+ ret = lttng_payload_push_fd_handle(payload, location_function->binary_fd_handle);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
}
- ret = sizeof(location_function_comm) +
- location_function_comm.function_name_len +
- location_function_comm.binary_path_len;
+ ret = sizeof(location_function_comm) + location_function_comm.function_name_len +
+ location_function_comm.binary_path_len;
end:
return ret;
}
-static
-int lttng_userspace_probe_location_tracepoint_serialize(
- const struct lttng_userspace_probe_location *location,
- struct lttng_payload *payload)
+static int lttng_userspace_probe_location_tracepoint_serialize(
+ const struct lttng_userspace_probe_location *location, struct lttng_payload *payload)
{
int ret;
size_t probe_name_len, provider_name_len, binary_path_len;
LTTNG_ASSERT(location);
LTTNG_ASSERT(lttng_userspace_probe_location_get_type(location) ==
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
-
- location_tracepoint = container_of(location,
- struct lttng_userspace_probe_location_tracepoint,
- parent);
- if (!location_tracepoint->probe_name ||
- !location_tracepoint->provider_name ||
- !location_tracepoint->binary_path) {
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
+
+ location_tracepoint = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
+ if (!location_tracepoint->probe_name || !location_tracepoint->provider_name ||
+ !location_tracepoint->binary_path) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
if (payload) {
ret = lttng_dynamic_buffer_append(&payload->buffer,
- &location_tracepoint_comm,
- sizeof(location_tracepoint_comm));
+ &location_tracepoint_comm,
+ sizeof(location_tracepoint_comm));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
ret = lttng_dynamic_buffer_append(&payload->buffer,
- location_tracepoint->probe_name,
- location_tracepoint_comm.probe_name_len);
+ location_tracepoint->probe_name,
+ location_tracepoint_comm.probe_name_len);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
ret = lttng_dynamic_buffer_append(&payload->buffer,
- location_tracepoint->provider_name,
- location_tracepoint_comm.provider_name_len);
+ location_tracepoint->provider_name,
+ location_tracepoint_comm.provider_name_len);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
ret = lttng_dynamic_buffer_append(&payload->buffer,
- location_tracepoint->binary_path,
- location_tracepoint_comm.binary_path_len);
+ location_tracepoint->binary_path,
+ location_tracepoint_comm.binary_path_len);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- ret = lttng_payload_push_fd_handle(
- payload, location_tracepoint->binary_fd_handle);
+ ret = lttng_payload_push_fd_handle(payload, location_tracepoint->binary_fd_handle);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
}
- ret = sizeof(location_tracepoint_comm) +
- location_tracepoint_comm.probe_name_len +
- location_tracepoint_comm.provider_name_len +
- location_tracepoint_comm.binary_path_len;
+ ret = sizeof(location_tracepoint_comm) + location_tracepoint_comm.probe_name_len +
+ location_tracepoint_comm.provider_name_len +
+ location_tracepoint_comm.binary_path_len;
end:
return ret;
}
-int lttng_userspace_probe_location_serialize(
- const struct lttng_userspace_probe_location *location,
- struct lttng_payload *payload)
+int lttng_userspace_probe_location_serialize(const struct lttng_userspace_probe_location *location,
+ struct lttng_payload *payload)
{
int ret, buffer_use = 0;
struct lttng_userspace_probe_location_comm location_generic_comm;
location_generic_comm.type = (int8_t) location->type;
if (payload) {
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- &location_generic_comm,
- sizeof(location_generic_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &location_generic_comm, sizeof(location_generic_comm));
if (ret) {
goto end;
}
switch (lttng_userspace_probe_location_get_type(location)) {
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
- ret = lttng_userspace_probe_location_function_serialize(
- location, payload);
+ ret = lttng_userspace_probe_location_function_serialize(location, payload);
break;
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
- ret = lttng_userspace_probe_location_tracepoint_serialize(
- location, payload);
+ ret = lttng_userspace_probe_location_tracepoint_serialize(location, payload);
break;
default:
ERR("Unsupported probe location type");
}
buffer_use += ret;
- ret = lttng_userspace_probe_location_lookup_method_serialize(
- location->lookup_method, payload);
+ ret = lttng_userspace_probe_location_lookup_method_serialize(location->lookup_method,
+ payload);
if (ret < 0) {
goto end;
}
return ret;
}
-static
-int lttng_userspace_probe_location_function_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_userspace_probe_location **location)
+static int lttng_userspace_probe_location_function_create_from_payload(
+ struct lttng_payload_view *view, struct lttng_userspace_probe_location **location)
{
struct lttng_userspace_probe_location_function_comm *location_function_comm;
const char *function_name_src, *binary_path_src;
- char *function_name = NULL, *binary_path = NULL;
+ char *function_name = nullptr, *binary_path = nullptr;
int ret = 0;
size_t expected_size;
struct fd_handle *binary_fd_handle = lttng_payload_view_pop_fd_handle(view);
goto end;
}
- location_function_comm =
- (typeof(location_function_comm)) view->buffer.data;
+ location_function_comm = (typeof(location_function_comm)) view->buffer.data;
expected_size = sizeof(*location_function_comm) +
- location_function_comm->function_name_len +
- location_function_comm->binary_path_len;
+ location_function_comm->function_name_len + location_function_comm->binary_path_len;
if (view->buffer.size < expected_size) {
ret = -LTTNG_ERR_INVALID;
}
function_name_src = view->buffer.data + sizeof(*location_function_comm);
- binary_path_src = function_name_src +
- location_function_comm->function_name_len;
+ binary_path_src = function_name_src + location_function_comm->function_name_len;
- if (!lttng_buffer_view_contains_string(&view->buffer, function_name_src,
- location_function_comm->function_name_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &view->buffer, function_name_src, location_function_comm->function_name_len)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- if (!lttng_buffer_view_contains_string(&view->buffer, binary_path_src,
- location_function_comm->binary_path_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &view->buffer, binary_path_src, location_function_comm->binary_path_len)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
}
*location = lttng_userspace_probe_location_function_create_no_check(
- binary_path, function_name, NULL, false);
+ binary_path, function_name, nullptr, false);
if (!(*location)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- ret = lttng_userspace_probe_location_function_set_binary_fd_handle(
- *location, binary_fd_handle);
+ ret = lttng_userspace_probe_location_function_set_binary_fd_handle(*location,
+ binary_fd_handle);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
return ret;
}
-static
-int lttng_userspace_probe_location_tracepoint_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_userspace_probe_location **location)
+static int lttng_userspace_probe_location_tracepoint_create_from_payload(
+ struct lttng_payload_view *view, struct lttng_userspace_probe_location **location)
{
struct lttng_userspace_probe_location_tracepoint_comm *location_tracepoint_comm;
const char *probe_name_src, *provider_name_src, *binary_path_src;
- char *probe_name = NULL, *provider_name = NULL, *binary_path = NULL;
+ char *probe_name = nullptr, *provider_name = nullptr, *binary_path = nullptr;
int ret = 0;
size_t expected_size;
struct fd_handle *binary_fd_handle = lttng_payload_view_pop_fd_handle(view);
goto end;
}
- location_tracepoint_comm =
- (typeof(location_tracepoint_comm)) view->buffer.data;
+ location_tracepoint_comm = (typeof(location_tracepoint_comm)) view->buffer.data;
expected_size = sizeof(*location_tracepoint_comm) +
- location_tracepoint_comm->probe_name_len +
- location_tracepoint_comm->provider_name_len +
- location_tracepoint_comm->binary_path_len;
+ location_tracepoint_comm->probe_name_len +
+ location_tracepoint_comm->provider_name_len +
+ location_tracepoint_comm->binary_path_len;
if (view->buffer.size < expected_size) {
ret = -LTTNG_ERR_INVALID;
}
probe_name_src = view->buffer.data + sizeof(*location_tracepoint_comm);
- provider_name_src = probe_name_src +
- location_tracepoint_comm->probe_name_len;
- binary_path_src = provider_name_src +
- location_tracepoint_comm->provider_name_len;
+ provider_name_src = probe_name_src + location_tracepoint_comm->probe_name_len;
+ binary_path_src = provider_name_src + location_tracepoint_comm->provider_name_len;
- if (!lttng_buffer_view_contains_string(&view->buffer, probe_name_src,
- location_tracepoint_comm->probe_name_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &view->buffer, probe_name_src, location_tracepoint_comm->probe_name_len)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- if (!lttng_buffer_view_contains_string(&view->buffer, provider_name_src,
- location_tracepoint_comm->provider_name_len)) {
+ if (!lttng_buffer_view_contains_string(&view->buffer,
+ provider_name_src,
+ location_tracepoint_comm->provider_name_len)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- if (!lttng_buffer_view_contains_string(&view->buffer, binary_path_src,
- location_tracepoint_comm->binary_path_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &view->buffer, binary_path_src, location_tracepoint_comm->binary_path_len)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
}
*location = lttng_userspace_probe_location_tracepoint_create_no_check(
- binary_path, provider_name, probe_name, NULL, false);
+ binary_path, provider_name, probe_name, nullptr, false);
if (!(*location)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- ret = lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
- *location, binary_fd_handle);
+ ret = lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(*location,
+ binary_fd_handle);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
return ret;
}
-static
-int lttng_userspace_probe_location_lookup_method_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_userspace_probe_location_lookup_method **lookup_method)
+static int lttng_userspace_probe_location_lookup_method_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_userspace_probe_location_lookup_method **lookup_method)
{
int ret;
struct lttng_userspace_probe_location_lookup_method_comm *lookup_comm;
}
lookup_comm = (typeof(lookup_comm)) view->buffer.data;
- type = (enum lttng_userspace_probe_location_lookup_method_type)
- lookup_comm->type;
+ type = (enum lttng_userspace_probe_location_lookup_method_type) lookup_comm->type;
switch (type) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
- *lookup_method = NULL;
+ *lookup_method = nullptr;
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
- *lookup_method =
- lttng_userspace_probe_location_lookup_method_function_elf_create();
+ *lookup_method = lttng_userspace_probe_location_lookup_method_function_elf_create();
if (!(*lookup_method)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
int lttng_userspace_probe_location_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_userspace_probe_location **location)
+ struct lttng_payload_view *view, struct lttng_userspace_probe_location **location)
{
struct lttng_userspace_probe_location_lookup_method *lookup_method;
enum lttng_userspace_probe_location_type type;
int ret;
struct lttng_userspace_probe_location_comm *probe_location_comm;
struct lttng_payload_view probe_location_comm_view =
- lttng_payload_view_from_view(
- view, 0, sizeof(*probe_location_comm));
+ lttng_payload_view_from_view(view, 0, sizeof(*probe_location_comm));
LTTNG_ASSERT(view);
LTTNG_ASSERT(location);
- lookup_method = NULL;
+ lookup_method = nullptr;
if (!lttng_payload_view_is_valid(&probe_location_comm_view)) {
ret = -LTTNG_ERR_INVALID;
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
{
struct lttng_payload_view location_view =
- lttng_payload_view_from_view(
- view, consumed, -1);
+ lttng_payload_view_from_view(view, consumed, -1);
- ret = lttng_userspace_probe_location_function_create_from_payload(
- &location_view, location);
+ ret = lttng_userspace_probe_location_function_create_from_payload(&location_view,
+ location);
if (ret < 0) {
goto end;
}
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
{
struct lttng_payload_view location_view =
- lttng_payload_view_from_view(view, consumed, -1);
+ lttng_payload_view_from_view(view, consumed, -1);
- ret = lttng_userspace_probe_location_tracepoint_create_from_payload(
- &location_view, location);
+ ret = lttng_userspace_probe_location_tracepoint_create_from_payload(&location_view,
+ location);
if (ret < 0) {
goto end;
}
{
struct lttng_payload_view lookup_method_view =
- lttng_payload_view_from_view(
- view, consumed, -1);
+ lttng_payload_view_from_view(view, consumed, -1);
ret = lttng_userspace_probe_location_lookup_method_create_from_payload(
- &lookup_method_view, &lookup_method);
+ &lookup_method_view, &lookup_method);
}
if (ret < 0) {
ret = -LTTNG_ERR_INVALID;
LTTNG_ASSERT(lookup_method);
(*location)->lookup_method = lookup_method;
- lookup_method = NULL;
+ lookup_method = nullptr;
ret += consumed;
end:
return ret;
}
-static
-int lttng_userspace_probe_location_function_set_binary_fd_handle(
- struct lttng_userspace_probe_location *location,
- struct fd_handle *binary_fd)
+static int lttng_userspace_probe_location_function_set_binary_fd_handle(
+ struct lttng_userspace_probe_location *location, struct fd_handle *binary_fd)
{
int ret = 0;
struct lttng_userspace_probe_location_function *function_location;
LTTNG_ASSERT(location);
LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
- function_location = container_of(location,
- struct lttng_userspace_probe_location_function, parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
fd_handle_put(function_location->binary_fd_handle);
fd_handle_get(binary_fd);
function_location->binary_fd_handle = binary_fd;
return ret;
}
-static
-int lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
- struct lttng_userspace_probe_location *location,
- struct fd_handle *binary_fd)
+static int lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
+ struct lttng_userspace_probe_location *location, struct fd_handle *binary_fd)
{
int ret = 0;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
LTTNG_ASSERT(location);
LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
- tracepoint_location = container_of(location,
- struct lttng_userspace_probe_location_tracepoint, parent);
+ tracepoint_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
fd_handle_put(tracepoint_location->binary_fd_handle);
fd_handle_get(binary_fd);
tracepoint_location->binary_fd_handle = binary_fd;
return ret;
}
-static
-int lttng_userspace_probe_location_function_flatten(
- const struct lttng_userspace_probe_location *location,
- struct lttng_dynamic_buffer *buffer)
+static int lttng_userspace_probe_location_function_flatten(
+ const struct lttng_userspace_probe_location *location, struct lttng_dynamic_buffer *buffer)
{
struct lttng_userspace_probe_location_lookup_method_elf flat_lookup_method;
struct lttng_userspace_probe_location_function *probe_function;
LTTNG_ASSERT(location);
- if (location->lookup_method && location->lookup_method->type !=
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF) {
+ if (location->lookup_method &&
+ location->lookup_method->type !=
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- probe_function = container_of(location,
- struct lttng_userspace_probe_location_function,
- parent);
+ probe_function = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
LTTNG_ASSERT(probe_function->function_name);
LTTNG_ASSERT(probe_function->binary_path);
- storage_needed +=
- sizeof(struct lttng_userspace_probe_location_function);
+ storage_needed += sizeof(struct lttng_userspace_probe_location_function);
function_name_len = strlen(probe_function->function_name) + 1;
binary_path_len = strlen(probe_function->binary_path) + 1;
storage_needed += function_name_len + binary_path_len;
}
if (lttng_dynamic_buffer_get_capacity_left(buffer) < storage_needed) {
- ret = lttng_dynamic_buffer_set_capacity(buffer,
- buffer->size + storage_needed);
+ ret = lttng_dynamic_buffer_set_capacity(buffer, buffer->size + storage_needed);
if (ret) {
goto end;
}
*/
if (location->lookup_method) {
flat_probe.parent.lookup_method =
- (struct lttng_userspace_probe_location_lookup_method *)
- (flat_probe_start + sizeof(flat_probe) +
- function_name_len + binary_path_len + padding_needed);
+ (struct lttng_userspace_probe_location_lookup_method
+ *) (flat_probe_start + sizeof(flat_probe) + function_name_len +
+ binary_path_len + padding_needed);
} else {
- flat_probe.parent.lookup_method = NULL;
+ flat_probe.parent.lookup_method = nullptr;
}
flat_probe.function_name = flat_probe_start + sizeof(flat_probe);
flat_probe.binary_path = flat_probe.function_name + function_name_len;
- flat_probe.binary_fd_handle = NULL;
- ret = lttng_dynamic_buffer_append(buffer, &flat_probe,
- sizeof(flat_probe));
+ flat_probe.binary_fd_handle = nullptr;
+ ret = lttng_dynamic_buffer_append(buffer, &flat_probe, sizeof(flat_probe));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(buffer,
- probe_function->function_name, function_name_len);
+ ret = lttng_dynamic_buffer_append(buffer, probe_function->function_name, function_name_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(buffer,
- probe_function->binary_path, binary_path_len);
+ ret = lttng_dynamic_buffer_append(buffer, probe_function->binary_path, binary_path_len);
if (ret) {
goto end;
}
/* Insert padding before the lookup method. */
- ret = lttng_dynamic_buffer_set_size(buffer,
- buffer->size + padding_needed);
+ ret = lttng_dynamic_buffer_set_size(buffer, buffer->size + padding_needed);
if (ret) {
goto end;
}
memset(&flat_lookup_method, 0, sizeof(flat_lookup_method));
flat_lookup_method.parent.type =
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF;
- ret = lttng_dynamic_buffer_append(buffer,
- &flat_lookup_method, sizeof(flat_lookup_method));
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF;
+ ret = lttng_dynamic_buffer_append(buffer, &flat_lookup_method, sizeof(flat_lookup_method));
if (ret) {
goto end;
}
return ret;
}
-static
-int lttng_userspace_probe_location_tracepoint_flatten(
- const struct lttng_userspace_probe_location *location,
- struct lttng_dynamic_buffer *buffer)
+static int lttng_userspace_probe_location_tracepoint_flatten(
+ const struct lttng_userspace_probe_location *location, struct lttng_dynamic_buffer *buffer)
{
struct lttng_userspace_probe_location_lookup_method_sdt flat_lookup_method;
struct lttng_userspace_probe_location_tracepoint *probe_tracepoint;
LTTNG_ASSERT(location);
/* Only SDT tracepoints are supported at the moment */
- if (location->lookup_method && location->lookup_method->type !=
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT) {
+ if (location->lookup_method &&
+ location->lookup_method->type !=
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- probe_tracepoint = container_of(location,
- struct lttng_userspace_probe_location_tracepoint,
- parent);
+ probe_tracepoint = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
LTTNG_ASSERT(probe_tracepoint->probe_name);
LTTNG_ASSERT(probe_tracepoint->provider_name);
LTTNG_ASSERT(probe_tracepoint->binary_path);
if (location->lookup_method) {
/* NOTE: elf look-up method is assumed here. */
- storage_needed +=
- sizeof(struct lttng_userspace_probe_location_lookup_method_elf);
+ storage_needed += sizeof(struct lttng_userspace_probe_location_lookup_method_elf);
}
/*
}
if (lttng_dynamic_buffer_get_capacity_left(buffer) < storage_needed) {
- ret = lttng_dynamic_buffer_set_capacity(buffer,
- buffer->size + storage_needed);
+ ret = lttng_dynamic_buffer_set_capacity(buffer, buffer->size + storage_needed);
if (ret) {
goto end;
}
*/
if (location->lookup_method) {
flat_probe.parent.lookup_method =
- (struct lttng_userspace_probe_location_lookup_method *)
- (flat_probe_start + sizeof(flat_probe) +
- probe_name_len + provider_name_len +
- binary_path_len + padding_needed);
+ (struct lttng_userspace_probe_location_lookup_method
+ *) (flat_probe_start + sizeof(flat_probe) + probe_name_len +
+ provider_name_len + binary_path_len + padding_needed);
} else {
- flat_probe.parent.lookup_method = NULL;
+ flat_probe.parent.lookup_method = nullptr;
}
flat_probe.probe_name = flat_probe_start + sizeof(flat_probe);
flat_probe.provider_name = flat_probe.probe_name + probe_name_len;
flat_probe.binary_path = flat_probe.provider_name + provider_name_len;
- flat_probe.binary_fd_handle = NULL;
+ flat_probe.binary_fd_handle = nullptr;
ret = lttng_dynamic_buffer_append(buffer, &flat_probe, sizeof(flat_probe));
if (ret) {
goto end;
}
/* Append all the fields to the buffer */
- ret = lttng_dynamic_buffer_append(buffer,
- probe_tracepoint->probe_name, probe_name_len);
+ ret = lttng_dynamic_buffer_append(buffer, probe_tracepoint->probe_name, probe_name_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(buffer,
- probe_tracepoint->provider_name, provider_name_len);
+ ret = lttng_dynamic_buffer_append(
+ buffer, probe_tracepoint->provider_name, provider_name_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(buffer,
- probe_tracepoint->binary_path, binary_path_len);
+ ret = lttng_dynamic_buffer_append(buffer, probe_tracepoint->binary_path, binary_path_len);
if (ret) {
goto end;
}
memset(&flat_lookup_method, 0, sizeof(flat_lookup_method));
flat_lookup_method.parent.type =
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT;
- ret = lttng_dynamic_buffer_append(buffer,
- &flat_lookup_method, sizeof(flat_lookup_method));
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT;
+ ret = lttng_dynamic_buffer_append(buffer, &flat_lookup_method, sizeof(flat_lookup_method));
if (ret) {
goto end;
}
return ret;
}
-int lttng_userspace_probe_location_flatten(
- const struct lttng_userspace_probe_location *location,
- struct lttng_dynamic_buffer *buffer)
+int lttng_userspace_probe_location_flatten(const struct lttng_userspace_probe_location *location,
+ struct lttng_dynamic_buffer *buffer)
{
int ret;
if (!location) {
return ret;
}
-struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
- const struct lttng_userspace_probe_location *location)
+struct lttng_userspace_probe_location *
+lttng_userspace_probe_location_copy(const struct lttng_userspace_probe_location *location)
{
- struct lttng_userspace_probe_location *new_location = NULL;
+ struct lttng_userspace_probe_location *new_location = nullptr;
enum lttng_userspace_probe_location_type type;
if (!location) {
type = lttng_userspace_probe_location_get_type(location);
switch (type) {
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
- new_location =
- lttng_userspace_probe_location_function_copy(location);
+ new_location = lttng_userspace_probe_location_function_copy(location);
if (!new_location) {
goto err;
}
break;
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
- new_location =
- lttng_userspace_probe_location_tracepoint_copy(location);
+ new_location = lttng_userspace_probe_location_tracepoint_copy(location);
if (!new_location) {
goto err;
}
break;
default:
- new_location = NULL;
+ new_location = nullptr;
goto err;
}
err:
}
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)
+ const struct lttng_userspace_probe_location_lookup_method *a,
+ const struct lttng_userspace_probe_location_lookup_method *b)
{
bool is_equal = false;
return is_equal;
}
-bool lttng_userspace_probe_location_is_equal(
- const struct lttng_userspace_probe_location *a,
- const struct lttng_userspace_probe_location *b)
+bool lttng_userspace_probe_location_is_equal(const struct lttng_userspace_probe_location *a,
+ const struct lttng_userspace_probe_location *b)
{
bool is_equal = false;
goto end;
}
- if (!lttng_userspace_probe_location_lookup_method_is_equal(
- a->lookup_method, b->lookup_method)) {
+ if (!lttng_userspace_probe_location_lookup_method_is_equal(a->lookup_method,
+ b->lookup_method)) {
goto end;
}
return is_equal;
}
-unsigned long lttng_userspace_probe_location_hash(
- const struct lttng_userspace_probe_location *location)
+unsigned long
+lttng_userspace_probe_location_hash(const struct lttng_userspace_probe_location *location)
{
return location->hash(location);
}
-enum lttng_error_code lttng_userspace_probe_location_mi_serialize(
- const struct lttng_userspace_probe_location *location,
- struct mi_writer *writer)
+enum lttng_error_code
+lttng_userspace_probe_location_mi_serialize(const struct lttng_userspace_probe_location *location,
+ struct mi_writer *writer)
{
- typedef enum lttng_error_code (*mi_fp)(
- const struct lttng_userspace_probe_location *,
- struct mi_writer *);
+ using mi_fp = enum lttng_error_code (*)(const struct lttng_userspace_probe_location *,
+ struct mi_writer *);
int ret;
enum lttng_error_code ret_code;
- mi_fp mi_function = NULL;
+ mi_fp mi_function = nullptr;
LTTNG_ASSERT(location);
LTTNG_ASSERT(writer);
}
/* Open userspace probe location element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_userspace_probe_location);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_userspace_probe_location);
if (ret) {
goto mi_error;
}
}
enum lttng_error_code lttng_userspace_probe_location_lookup_method_mi_serialize(
- const struct lttng_userspace_probe_location_lookup_method
- *method,
- struct mi_writer *writer)
+ const struct lttng_userspace_probe_location_lookup_method *method, struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
switch (lttng_userspace_probe_location_lookup_method_get_type(method)) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
type_element_str =
- mi_lttng_element_userspace_probe_location_lookup_method_function_default;
+ mi_lttng_element_userspace_probe_location_lookup_method_function_default;
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
type_element_str =
- mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
+ mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
type_element_str =
- mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
+ mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
break;
default:
abort();
/* Open userspace probe location lookup method element. */
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_userspace_probe_location_lookup_method);
+ mi_lttng_element_userspace_probe_location_lookup_method);
if (ret) {
goto mi_error;
}
}
static enum lttng_error_code lttng_userspace_probe_location_tracepoint_mi_serialize(
- const struct lttng_userspace_probe_location *location,
- struct mi_writer *writer)
+ const struct lttng_userspace_probe_location *location, struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
- const char *probe_name = NULL;
- const char *provider_name = NULL;
- const char *binary_path = NULL;
- const struct lttng_userspace_probe_location_lookup_method
- *lookup_method = NULL;
+ const char *probe_name = nullptr;
+ const char *provider_name = nullptr;
+ const char *binary_path = nullptr;
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
LTTNG_ASSERT(location);
LTTNG_ASSERT(writer);
- probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(
- location);
- provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(
- location);
- binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(
- location);
- lookup_method = lttng_userspace_probe_location_tracepoint_get_lookup_method(
- location);
+ probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(location);
+ provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(location);
+ binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(location);
+ lookup_method = lttng_userspace_probe_location_tracepoint_get_lookup_method(location);
/* Open userspace probe location tracepoint element. */
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_userspace_probe_location_tracepoint);
+ mi_lttng_element_userspace_probe_location_tracepoint);
if (ret) {
goto mi_error;
}
/* Probe name. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_userspace_probe_location_tracepoint_probe_name,
- probe_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ mi_lttng_element_userspace_probe_location_tracepoint_probe_name,
+ probe_name);
if (ret) {
goto mi_error;
}
/* Provider name. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_userspace_probe_location_tracepoint_provider_name,
- provider_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ mi_lttng_element_userspace_probe_location_tracepoint_provider_name,
+ provider_name);
if (ret) {
goto mi_error;
}
/* Binary path. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_userspace_probe_location_binary_path,
- binary_path);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_userspace_probe_location_binary_path, binary_path);
if (ret) {
goto mi_error;
}
/* The lookup method. */
- ret_code = lttng_userspace_probe_location_lookup_method_mi_serialize(
- lookup_method, writer);
+ ret_code = lttng_userspace_probe_location_lookup_method_mi_serialize(lookup_method, writer);
if (ret_code != LTTNG_OK) {
goto end;
}
}
static enum lttng_error_code lttng_userspace_probe_location_function_mi_serialize(
- const struct lttng_userspace_probe_location *location,
- struct mi_writer *writer)
+ const struct lttng_userspace_probe_location *location, struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
- const char *function_name = NULL;
- const char *binary_path = NULL;
- const char *instrumentation_type_str = NULL;
- enum lttng_userspace_probe_location_function_instrumentation_type
- instrumentation_type;
- const struct lttng_userspace_probe_location_lookup_method
- *lookup_method = NULL;
+ const char *function_name = nullptr;
+ const char *binary_path = nullptr;
+ const char *instrumentation_type_str = nullptr;
+ enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method = nullptr;
LTTNG_ASSERT(location);
LTTNG_ASSERT(writer);
- function_name = lttng_userspace_probe_location_function_get_function_name(
- location);
- binary_path = lttng_userspace_probe_location_function_get_binary_path(
- location);
+ function_name = lttng_userspace_probe_location_function_get_function_name(location);
+ binary_path = lttng_userspace_probe_location_function_get_binary_path(location);
instrumentation_type =
- lttng_userspace_probe_location_function_get_instrumentation_type(
- location);
- lookup_method = lttng_userspace_probe_location_function_get_lookup_method(
- location);
+ lttng_userspace_probe_location_function_get_instrumentation_type(location);
+ lookup_method = lttng_userspace_probe_location_function_get_lookup_method(location);
switch (instrumentation_type) {
case LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY:
instrumentation_type_str =
- mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
+ mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
break;
default:
abort();
/* Open userspace probe location function element. */
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_userspace_probe_location_function);
+ mi_lttng_element_userspace_probe_location_function);
if (ret) {
goto mi_error;
}
/* Function name. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_userspace_probe_location_function_name,
- function_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_userspace_probe_location_function_name, function_name);
if (ret) {
goto mi_error;
}
/* Binary path. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_userspace_probe_location_binary_path,
- binary_path);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_userspace_probe_location_binary_path, binary_path);
if (ret) {
goto mi_error;
}
/* Instrumentation type. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_userspace_probe_location_function_instrumentation_type,
- instrumentation_type_str);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ mi_lttng_element_userspace_probe_location_function_instrumentation_type,
+ instrumentation_type_str);
if (ret) {
goto mi_error;
}
/* The lookup method. */
- ret_code = lttng_userspace_probe_location_lookup_method_mi_serialize(
- lookup_method, writer);
+ ret_code = lttng_userspace_probe_location_lookup_method_mi_serialize(lookup_method, writer);
if (ret_code != LTTNG_OK) {
goto end;
}