Log uts information on launch of the session and relay daemon
[lttng-tools.git] / src / common / kernel-probe.cpp
index a05b451c38dc406a68b4c5631841aaf649db96c8..b01b44b960a72bf77b92d34ef9fcb41d1657e32d 100644 (file)
@@ -6,16 +6,16 @@
  */
 
 #include "lttng/lttng-error.h"
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
 #include <fcntl.h>
 #include <lttng/constant.h>
-#include <lttng/kernel-probe-internal.h>
+#include <lttng/kernel-probe-internal.hpp>
 #include <lttng/kernel-probe.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -82,9 +82,8 @@ void lttng_kernel_probe_location_symbol_destroy(
 
        LTTNG_ASSERT(location);
 
-       location_symbol = container_of(location,
-                       struct lttng_kernel_probe_location_symbol,
-                       parent);
+       location_symbol = lttng::utils::container_of(location,
+                       &lttng_kernel_probe_location_symbol::parent);
 
        LTTNG_ASSERT(location_symbol);
 
@@ -117,7 +116,7 @@ lttng_kernel_probe_location_address_create(uint64_t address)
        struct lttng_kernel_probe_location *ret = NULL;
        struct lttng_kernel_probe_location_address *location;
 
-       location = (lttng_kernel_probe_location_address *) zmalloc(sizeof(*location));
+       location = zmalloc<lttng_kernel_probe_location_address>();
        if (!location) {
                PERROR("Error allocating userspace probe location.");
                goto end;
@@ -154,7 +153,7 @@ lttng_kernel_probe_location_symbol_create(const char *symbol_name,
                goto error;
        }
 
-       location = (lttng_kernel_probe_location_symbol *) zmalloc(sizeof(*location));
+       location = zmalloc<lttng_kernel_probe_location_symbol>();
        if (!location) {
                PERROR("Failed to allocate kernel symbol probe location");
                goto error;
@@ -195,8 +194,8 @@ lttng_kernel_probe_location_address_get_address(
                goto end;
        }
 
-       address_location = container_of(location,
-                       struct lttng_kernel_probe_location_address, parent);
+       address_location = lttng::utils::container_of(location,
+                       &lttng_kernel_probe_location_address::parent);
        *offset = address_location->address;
 end:
        return ret;
@@ -214,8 +213,8 @@ const char *lttng_kernel_probe_location_symbol_get_name(
                goto end;
        }
 
-       symbol_location = container_of(location,
-                       struct lttng_kernel_probe_location_symbol, parent);
+       symbol_location = lttng::utils::container_of(location,
+                       &lttng_kernel_probe_location_symbol::parent);
        ret = symbol_location->symbol_name;
 end:
        return ret;
@@ -239,8 +238,8 @@ lttng_kernel_probe_location_symbol_get_offset(
                goto end;
        }
 
-       symbol_location = container_of(location,
-                       struct lttng_kernel_probe_location_symbol, parent);
+       symbol_location = lttng::utils::container_of(location,
+                       &lttng_kernel_probe_location_symbol::parent);
        *offset = symbol_location->offset;
 end:
        return ret;
@@ -267,8 +266,8 @@ int lttng_kernel_probe_location_symbol_serialize(
                        LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
 
        original_payload_size = payload->buffer.size;
-       location_symbol = container_of(location,
-                       struct lttng_kernel_probe_location_symbol, parent);
+       location_symbol = lttng::utils::container_of(location,
+                       &lttng_kernel_probe_location_symbol::parent);
 
        if (!location_symbol->symbol_name) {
                ret = -LTTNG_ERR_INVALID;
@@ -319,9 +318,8 @@ int lttng_kernel_probe_location_address_serialize(
                        LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS);
 
        original_payload_size = payload->buffer.size;
-       location_address = container_of(location,
-                       struct lttng_kernel_probe_location_address,
-                       parent);
+       location_address = lttng::utils::container_of(location,
+                       &lttng_kernel_probe_location_address::parent);
 
        location_address_comm.address = location_address->address;
 
@@ -518,9 +516,8 @@ unsigned long lttng_kernel_probe_location_address_hash(
        unsigned long hash = hash_key_ulong(
                        (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS,
                        lttng_ht_seed);
-       struct lttng_kernel_probe_location_address *address_location =
-                       container_of(location, typeof(*address_location),
-                               parent);
+       struct lttng_kernel_probe_location_address *address_location = lttng::utils::container_of(
+                       location, &lttng_kernel_probe_location_address::parent);
 
        hash ^= hash_key_u64(&address_location->address, lttng_ht_seed);
 
@@ -535,10 +532,8 @@ bool lttng_kernel_probe_location_address_is_equal(
        bool is_equal = false;
        struct lttng_kernel_probe_location_address *a, *b;
 
-       a = container_of(_a, struct lttng_kernel_probe_location_address,
-                       parent);
-       b = container_of(_b, struct lttng_kernel_probe_location_address,
-                       parent);
+       a = lttng::utils::container_of(_a, &lttng_kernel_probe_location_address::parent);
+       b = lttng::utils::container_of(_b, &lttng_kernel_probe_location_address::parent);
 
        if (a->address != b->address) {
                goto end;
@@ -555,11 +550,9 @@ unsigned long lttng_kernel_probe_location_symbol_hash(
                const struct lttng_kernel_probe_location *location)
 {
        unsigned long hash = hash_key_ulong(
-                       (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET,
-                       lttng_ht_seed);
-       struct lttng_kernel_probe_location_symbol *symbol_location =
-                       container_of(location, typeof(*symbol_location),
-                               parent);
+                       (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET, lttng_ht_seed);
+       struct lttng_kernel_probe_location_symbol *symbol_location = lttng::utils::container_of(
+                       location, &lttng_kernel_probe_location_symbol::parent);
 
        hash ^= hash_key_str(symbol_location->symbol_name, lttng_ht_seed);
        hash ^= hash_key_u64(&symbol_location->offset, lttng_ht_seed);
@@ -575,10 +568,10 @@ bool lttng_kernel_probe_location_symbol_is_equal(
        bool is_equal = false;
        struct lttng_kernel_probe_location_symbol *a, *b;
 
-       a = container_of(_a, struct lttng_kernel_probe_location_symbol,
-                       parent);
-       b = container_of(_b, struct lttng_kernel_probe_location_symbol,
-                       parent);
+       a = lttng::utils::container_of(_a,
+                       &lttng_kernel_probe_location_symbol::parent);
+       b = lttng::utils::container_of(_b,
+                       &lttng_kernel_probe_location_symbol::parent);
 
        LTTNG_ASSERT(a->symbol_name);
        LTTNG_ASSERT(b->symbol_name);
@@ -625,15 +618,12 @@ lttng_kernel_probe_location_symbol_copy(
                const struct lttng_kernel_probe_location *location)
 {
        struct lttng_kernel_probe_location *new_location = NULL;
-       struct lttng_kernel_probe_location_symbol *symbol_location;
        enum lttng_kernel_probe_location_status status;
        const char *symbol_name = NULL;
        uint64_t offset;
 
        LTTNG_ASSERT(location);
        LTTNG_ASSERT(location->type == LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
-       symbol_location = container_of(
-                       location, typeof(*symbol_location), parent);
 
         /* Get probe location offset */
        status = lttng_kernel_probe_location_symbol_get_offset(location, &offset);
@@ -664,17 +654,13 @@ lttng_kernel_probe_location_address_copy(
                const struct lttng_kernel_probe_location *location)
 {
        struct lttng_kernel_probe_location *new_location = NULL;
-       struct lttng_kernel_probe_location_address *address_location;
        enum lttng_kernel_probe_location_status status;
        uint64_t address;
 
        LTTNG_ASSERT(location);
        LTTNG_ASSERT(location->type == LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS);
-       address_location = container_of(
-                       location, typeof(*address_location), parent);
-
 
-        /* Get probe location fields */
+       /* Get probe location fields */
        status = lttng_kernel_probe_location_address_get_address(location, &address);
        if (status != LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK) {
                ERR("Get kernel probe address failed.");
This page took 0.025768 seconds and 4 git commands to generate.