Validate match of all session channel's UUID
[lttng-ust.git] / liblttng-ust / lttng-context-ip.c
index 84c7349981fe6936d9c9cc29fa374fcdb725735e..b56e0db157e43cafd57a64e2e04e415cb84f7595 100644 (file)
@@ -1,33 +1,23 @@
 /*
- * lttng-context-ip.c
- *
- * LTTng UST Instruction Pointer Context.
+ * SPDX-License-Identifier: LGPL-2.1-only
  *
  * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * LTTng UST Instruction Pointer Context.
  */
 
+#define _LGPL_SOURCE
+#include <stddef.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <lttng/ust-events.h>
 #include <lttng/ust-tracer.h>
-#include <lttng/ringbuffer-config.h>
+#include <lttng/ringbuffer-context.h>
+
+#include "context-internal.h"
 
 static
-size_t ip_get_size(struct lttng_ctx_field *field, size_t offset)
+size_t ip_get_size(struct lttng_ust_ctx_field *field, size_t offset)
 {
        size_t size = 0;
 
@@ -37,9 +27,9 @@ size_t ip_get_size(struct lttng_ctx_field *field, size_t offset)
 }
 
 static
-void ip_record(struct lttng_ctx_field *field,
+void ip_record(struct lttng_ust_ctx_field *field,
                 struct lttng_ust_lib_ring_buffer_ctx *ctx,
-                struct lttng_channel *chan)
+                struct lttng_ust_channel_buffer *chan)
 {
        void *ip;
 
@@ -48,27 +38,42 @@ void ip_record(struct lttng_ctx_field *field,
        chan->ops->event_write(ctx, &ip, sizeof(ip));
 }
 
-int lttng_add_ip_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_ip_to_ctx(struct lttng_ust_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       struct lttng_ust_ctx_field *field;
+       struct lttng_ust_type_common *type;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
+       type = lttng_ust_create_type_integer(sizeof(void *) * CHAR_BIT,
+                       lttng_alignof(void *) * CHAR_BIT,
+                       lttng_is_signed_type(void *),
+                       BYTE_ORDER, 16);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "ip")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
        }
-       field->event_field.name = "ip";
-       field->event_field.type.atype = atype_integer;
-       field->event_field.type.u.basic.integer.size = sizeof(void *) * CHAR_BIT;
-       field->event_field.type.u.basic.integer.alignment = lttng_alignof(void *) * CHAR_BIT;
-       field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(void *);
-       field->event_field.type.u.basic.integer.reverse_byte_order = 0;
-       field->event_field.type.u.basic.integer.base = 16;
-       field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+       field->event_field->name = strdup("ip");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
+       }
+       field->event_field->type = type;
        field->get_size = ip_get_size;
        field->record = ip_record;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
This page took 0.024802 seconds and 4 git commands to generate.