Refactoring: type description structures
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 7 Apr 2021 18:52:27 +0000 (14:52 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 14 Apr 2021 20:38:35 +0000 (16:38 -0400)
Refactoring:

- Type description structures: new API based on structure inheritance
  rather than union,
- Rely on compound literals,
- Rename description fields: name -> event_name,
- Rename types (lttng_kernel_ namespace):
  - struct lttng_kernel_event_desc,
  - struct lttng_kernel_event_field,
  - struct lttng_kernel_ctx.
- Move some internal definitions (not used by probes) to
  events-internal.h.
- Streamline context registration API,
- Introduce the LTTNG_CREATE_FIELD_METADATA define for the tracepoint
  code generation pass which generates the type descriptions, allowing
  to describe structures as an array of fields, and use enumerations
  from those fields.
- Adapt all tracepoint instrumentation to those changes.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I9a968a62888c52438a1f62ec24fcced4c3fd6ddf

60 files changed:
include/instrumentation/events/net.h
include/instrumentation/syscalls/headers/syscalls_integers_override.h
include/instrumentation/syscalls/headers/syscalls_pointers_override.h
include/lttng/events-internal.h
include/lttng/events.h
include/lttng/lttng-bytecode.h
include/lttng/tracepoint-event-impl.h
src/Kbuild
src/lttng-abi.c
src/lttng-bytecode-interpreter.c
src/lttng-bytecode-specialize.c
src/lttng-bytecode.c
src/lttng-context-callstack-legacy-impl.h
src/lttng-context-callstack-stackwalk-impl.h
src/lttng-context-callstack.c
src/lttng-context-cgroup-ns.c
src/lttng-context-cpu-id.c
src/lttng-context-egid.c
src/lttng-context-euid.c
src/lttng-context-gid.c
src/lttng-context-hostname.c
src/lttng-context-interruptible.c
src/lttng-context-ipc-ns.c
src/lttng-context-migratable.c
src/lttng-context-mnt-ns.c
src/lttng-context-need-reschedule.c
src/lttng-context-net-ns.c
src/lttng-context-nice.c
src/lttng-context-perf-counters.c
src/lttng-context-pid-ns.c
src/lttng-context-pid.c
src/lttng-context-ppid.c
src/lttng-context-preemptible.c
src/lttng-context-prio.c
src/lttng-context-procname.c
src/lttng-context-sgid.c
src/lttng-context-suid.c
src/lttng-context-tid.c
src/lttng-context-time-ns.c
src/lttng-context-uid.c
src/lttng-context-user-ns.c
src/lttng-context-uts-ns.c
src/lttng-context-vegid.c
src/lttng-context-veuid.c
src/lttng-context-vgid.c
src/lttng-context-vpid.c
src/lttng-context-vppid.c
src/lttng-context-vsgid.c
src/lttng-context-vsuid.c
src/lttng-context-vtid.c
src/lttng-context-vuid.c
src/lttng-context.c
src/lttng-event-notifier-notification.c
src/lttng-events.c
src/lttng-probes.c
src/lttng-ring-buffer-client.h
src/lttng-syscalls.c
src/probes/lttng-kprobes.c
src/probes/lttng-kretprobes.c
src/probes/lttng-uprobes.c

index fac99b56fffbbe86a664be9d612fda07756019bf..be59533d4953e2e313f236bf4921cc455f041146 100644 (file)
@@ -29,154 +29,6 @@ static inline unsigned char __has_network_hdr(struct sk_buff *skb)
        return skb_network_header(skb) != skb->head;
 }
 
-static struct lttng_event_field emptyfields[] = {
-};
-
-/* Structures for transport headers. */
-
-static struct lttng_event_field tcpfields[] = {
-       [0] = {
-               .name = "source_port",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [1] = {
-               .name = "dest_port",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [2] = {
-               .name = "seq",
-               .type = __type_integer(uint32_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [3] = {
-               .name = "ack_seq",
-               .type = __type_integer(uint32_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [4] = {
-               .name = "data_offset",
-               .type = __type_integer(uint8_t, 4, 4, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [5] = {
-               .name = "reserved",
-               .type = __type_integer(uint8_t, 3, 1, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [6] = {
-               .name = "flags",
-               .type = __type_integer(uint8_t, 9, 1, 0,
-                               __BIG_ENDIAN, 16, none),
-       },
-       [7] = {
-               .name = "window_size",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [8] = {
-               .name = "checksum",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 16, none),
-       },
-       [9] = {
-               .name = "urg_ptr",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-};
-
-static struct lttng_event_field udpfields[] = {
-       [0] = {
-               .name = "source_port",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [1] = {
-               .name = "dest_port",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [2] = {
-               .name = "len",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [3] = {
-               .name = "check",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-};
-
-static struct lttng_event_field icmpfields[] = {
-       [0] = {
-               .name = "type",
-               .type = __type_integer(uint8_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [1] = {
-               .name = "code",
-               .type = __type_integer(uint8_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [2] = {
-               .name = "checksum",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [3] = {
-               .name = "gateway",
-               .type = __type_integer(uint32_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-};
-
-
-static struct lttng_event_field transport_fields[] = {
-       [0] = {
-               .name = "unknown",
-               .type = {
-                       .type = lttng_kernel_type_struct_nestable,
-                       .u.struct_nestable.nr_fields = ARRAY_SIZE(emptyfields),
-                       .u.struct_nestable.fields = emptyfields,
-                       .u.struct_nestable.alignment = 0,
-               },
-               .nofilter = 1,
-       },
-       [1] = {
-               .name = "tcp",
-               .type = {
-                       .type = lttng_kernel_type_struct_nestable,
-                       .u.struct_nestable.nr_fields = ARRAY_SIZE(tcpfields),
-                       .u.struct_nestable.fields = tcpfields,
-                       .u.struct_nestable.alignment = 0,
-               },
-               .nofilter = 1,
-       },
-       [2] = {
-               .name = "udp",
-               .type = {
-                       .type = lttng_kernel_type_struct_nestable,
-                       .u.struct_nestable.nr_fields = ARRAY_SIZE(udpfields),
-                       .u.struct_nestable.fields = udpfields,
-                       .u.struct_nestable.alignment = 0,
-               },
-               .nofilter = 1,
-       },
-       [3] = {
-               .name = "icmp",
-               .type = {
-                       .type = lttng_kernel_type_struct_nestable,
-                       .u.struct_nestable.nr_fields = ARRAY_SIZE(icmpfields),
-                       .u.struct_nestable.fields = icmpfields,
-                       .u.struct_nestable.alignment = 0,
-               },
-               .nofilter = 1,
-       },
-};
-
 enum transport_header_types {
        TH_NONE = 0,
        TH_TCP = 1,
@@ -235,303 +87,6 @@ static inline enum transport_header_types __get_transport_header_type(struct sk_
        return TH_NONE;
 }
 
-static struct lttng_kernel_enum_entry proto_transport_enum_entries[] = {
-       [0] = {
-               .start = { .value = 0, .signedness = 0, },
-               .end = { .value = IPPROTO_ICMP - 1, .signedness = 0, },
-               .string = "_unknown",
-       },
-       [1] = {
-               .start = { .value = IPPROTO_ICMP, .signedness = 0, },
-               .end = { .value = IPPROTO_ICMP, .signedness = 0, },
-               .string = "_icmp",
-       },
-       [2] = {
-               .start = { .value = IPPROTO_ICMP + 1, .signedness = 0, },
-               .end = { .value = IPPROTO_TCP - 1, .signedness = 0, },
-               .string = "_unknown",
-       },
-       [3] = {
-               .start = { .value = IPPROTO_TCP, .signedness = 0, },
-               .end = { .value = IPPROTO_TCP, .signedness = 0, },
-               .string = "_tcp",
-       },
-       [4] = {
-               .start = { .value = IPPROTO_TCP + 1, .signedness = 0, },
-               .end = { .value = IPPROTO_UDP - 1, .signedness = 0, },
-               .string = "_unknown",
-       },
-       [5] = {
-               .start = { .value = IPPROTO_UDP, .signedness = 0, },
-               .end = { .value = IPPROTO_UDP, .signedness = 0, },
-               .string = "_udp",
-       },
-       [6] = {
-               .start = { .value = IPPROTO_UDP + 1, .signedness = 0, },
-               .end = { .value = 255, .signedness = 0, },
-               .string = "_unknown",
-       },
-};
-
-static const struct lttng_kernel_enum_desc proto_transport_header_type = {
-       .name = "proto_transport_header_type",
-       .entries = proto_transport_enum_entries,
-       .nr_entries = ARRAY_SIZE(proto_transport_enum_entries),
-};
-
-static struct lttng_kernel_enum_entry transport_enum_entries[] = {
-       [0] = {
-               .start = { .value = TH_NONE, .signedness = 0, },
-               .end = { .value = TH_NONE, .signedness = 0, },
-               .string = "_unknown",
-       },
-       [1] = {
-               .start = { .value = TH_TCP, .signedness = 0, },
-               .end = { .value = TH_TCP, .signedness = 0, },
-               .string = "_tcp",
-       },
-       [2] = {
-               .start = { .value = TH_UDP, .signedness = 0, },
-               .end = { .value = TH_UDP, .signedness = 0, },
-               .string = "_udp",
-       },
-       [3] = {
-               .start = { .value = TH_ICMP, .signedness = 0, },
-               .end = { .value = TH_ICMP, .signedness = 0, },
-               .string = "_icmp",
-       },
-};
-
-static const struct lttng_kernel_enum_desc transport_header_type = {
-       .name = "transport_header_type",
-       .entries = transport_enum_entries,
-       .nr_entries = ARRAY_SIZE(transport_enum_entries),
-};
-
-/* Structures for network headers. */
-
-static struct lttng_event_field ipv4fields[] = {
-       [0] = {
-               .name = "version",
-               .type = __type_integer(uint8_t, 4, 4, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [1] = {
-               .name = "ihl",
-               .type = __type_integer(uint8_t, 4, 4, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [2] = {
-               .name = "tos",
-               .type = __type_integer(uint8_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [3] = {
-               .name = "tot_len",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [4] = {
-               .name = "id",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 16, none),
-       },
-       [5] = {
-               .name = "frag_off",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [6] = {
-               .name = "ttl",
-               .type = __type_integer(uint8_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [7] = {
-               .name = "protocol",
-               .type = {
-                       .type = lttng_kernel_type_enum_nestable,
-                       .u.enum_nestable.desc =
-                               &proto_transport_header_type,
-                       .u.enum_nestable.container_type =
-                               __LTTNG_COMPOUND_LITERAL(struct lttng_type,
-                                       __type_integer(uint8_t, 0, 0, -1,
-                                               __BIG_ENDIAN, 10, none)),
-               },
-       },
-       [8] = {
-               .name = "checksum",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 16, none),
-       },
-       [9] = {
-               .name = "saddr",
-               .type = {
-                       .type = lttng_kernel_type_array_nestable,
-                       .u.array_nestable.elem_type =
-                               __LTTNG_COMPOUND_LITERAL(struct lttng_type,
-                                       __type_integer(uint8_t, 0, 0, 0,
-                                               __BIG_ENDIAN, 10, none)),
-                       .u.array_nestable.length = 4,
-                       .u.array_nestable.alignment = lttng_alignof(uint8_t),
-               },
-       },
-       [10] = {
-               .name = "daddr",
-               .type = {
-                       .type = lttng_kernel_type_array_nestable,
-                       .u.array_nestable.elem_type =
-                               __LTTNG_COMPOUND_LITERAL(struct lttng_type,
-                                       __type_integer(uint8_t, 0, 0, 0,
-                                               __BIG_ENDIAN, 10, none)),
-                       .u.array_nestable.length = 4,
-                       .u.array_nestable.alignment = lttng_alignof(uint8_t),
-               },
-       },
-       [11] = {
-               .name = "transport_header_type",
-               .type = {
-                       .type = lttng_kernel_type_enum_nestable,
-                       .u.enum_nestable.desc = &transport_header_type,
-                       .u.enum_nestable.container_type =
-                               __LTTNG_COMPOUND_LITERAL(struct lttng_type,
-                                       __type_integer(uint8_t, 0, 0, -1,
-                                               __BYTE_ORDER, 10, none)),
-               },
-       },
-       [12] = {
-               .name = "transport_header",
-               .type = {
-                       .type = lttng_kernel_type_variant_nestable,
-                       .u.variant_nestable.tag_name = "transport_header_type",
-                       .u.variant_nestable.choices = transport_fields,
-                       .u.variant_nestable.nr_choices = ARRAY_SIZE(transport_fields),
-                       .u.variant_nestable.alignment = 0,
-               },
-       },
-};
-
-static struct lttng_event_field ipv6fields[] = {
-       [0] = {
-               .name = "version",
-               .type = __type_integer(uint8_t, 4, 4, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [1] = {
-               .name = "prio",
-               .type = __type_integer(uint8_t, 4, 4, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [2] = {
-               .name = "flow_lbl",
-               .type = {
-                       .type = lttng_kernel_type_array_nestable,
-                       .u.array_nestable.elem_type =
-                               __LTTNG_COMPOUND_LITERAL(struct lttng_type,
-                                       __type_integer(uint8_t, 0, 0, 0,
-                                               __BIG_ENDIAN, 16, none)),
-                       .u.array_nestable.length = 3,
-                       .u.array_nestable.alignment = lttng_alignof(uint8_t),
-               },
-       },
-       [3] = {
-               .name = "payload_len",
-               .type = __type_integer(uint16_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [4] = {
-               .name = "nexthdr",
-               .type = {
-                       .type = lttng_kernel_type_enum_nestable,
-                       .u.enum_nestable.desc =
-                               &proto_transport_header_type,
-                       .u.enum_nestable.container_type =
-                               __LTTNG_COMPOUND_LITERAL(struct lttng_type,
-                                       __type_integer(uint8_t, 0, 0, -1,
-                                               __BIG_ENDIAN, 10, none)),
-               },
-       },
-       [5] = {
-               .name = "hop_limit",
-               .type = __type_integer(uint8_t, 0, 0, 0,
-                               __BIG_ENDIAN, 10, none),
-       },
-       [6] = {
-               .name = "saddr",
-               .type = {
-                       .type = lttng_kernel_type_array_nestable,
-                       .u.array_nestable.elem_type =
-                               __LTTNG_COMPOUND_LITERAL(struct lttng_type,
-                                       __type_integer(uint16_t, 0, 0, 0,
-                                               __BIG_ENDIAN, 16, none)),
-                       .u.array_nestable.length = 8,
-                       .u.array_nestable.alignment = lttng_alignof(uint16_t),
-               },
-       },
-       [7] = {
-               .name = "daddr",
-               .type = {
-                       .type = lttng_kernel_type_array_nestable,
-                       .u.array_nestable.elem_type =
-                               __LTTNG_COMPOUND_LITERAL(struct lttng_type,
-                                       __type_integer(uint16_t, 0, 0, 0,
-                                               __BIG_ENDIAN, 16, none)),
-                       .u.array_nestable.length = 8,
-                       .u.array_nestable.alignment = lttng_alignof(uint16_t),
-               },
-       },
-       [8] = {
-               .name = "transport_header_type",
-               .type = {
-                       .type = lttng_kernel_type_enum_nestable,
-                       .u.enum_nestable.desc = &transport_header_type,
-                       .u.enum_nestable.container_type =
-                               __LTTNG_COMPOUND_LITERAL(struct lttng_type,
-                                       __type_integer(uint8_t, 0, 0, -1,
-                                               __BYTE_ORDER, 10, none)),
-               },
-       },
-       [9] = {
-               .name = "transport_header",
-               .type = {
-                       .type = lttng_kernel_type_variant_nestable,
-                       .u.variant_nestable.tag_name = "transport_header_type",
-                       .u.variant_nestable.choices = transport_fields,
-                       .u.variant_nestable.nr_choices = ARRAY_SIZE(transport_fields),
-                       .u.variant_nestable.alignment = 0,
-               },
-       },
-};
-
-static struct lttng_event_field network_fields[] = {
-       [0] = {
-               .name = "unknown",
-               .type = {
-                       .type = lttng_kernel_type_struct_nestable,
-                       .u.struct_nestable.nr_fields = 0,
-                       .u.struct_nestable.fields = emptyfields,
-                       .u.struct_nestable.alignment = 0,
-               },
-       },
-       [1] = {
-               .name = "ipv4",
-               .type = {
-                       .type = lttng_kernel_type_struct_nestable,
-                       .u.struct_nestable.nr_fields = ARRAY_SIZE(ipv4fields),
-                       .u.struct_nestable.fields = ipv4fields,
-                       .u.struct_nestable.alignment = 0,
-               },
-       },
-       [2] = {
-               .name = "ipv6",
-               .type = {
-                       .type = lttng_kernel_type_struct_nestable,
-                       .u.struct_nestable.nr_fields = ARRAY_SIZE(ipv6fields),
-                       .u.struct_nestable.fields = ipv6fields,
-                       .u.struct_nestable.alignment = 0,
-               },
-       },
-};
-
 enum network_header_types {
        NH_NONE,
        NH_IPV4,
@@ -552,6 +107,217 @@ static inline unsigned char __get_network_header_type(struct sk_buff *skb)
 
 #endif
 
+#ifdef LTTNG_CREATE_FIELD_METADATA
+
+static const struct lttng_kernel_event_field *emptyfields[] = {
+};
+
+/* Structures for transport headers. */
+
+static const struct lttng_kernel_event_field *tcpfields[] = {
+       [0] = lttng_kernel_static_event_field("source_port",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [1] = lttng_kernel_static_event_field("dest_port",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [2] = lttng_kernel_static_event_field("seq",
+               lttng_kernel_static_type_integer_from_type(uint32_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [3] = lttng_kernel_static_event_field("ack_seq",
+               lttng_kernel_static_type_integer_from_type(uint32_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [4] = lttng_kernel_static_event_field("data_offset",
+               lttng_kernel_static_type_integer(4, 4, 0, __BIG_ENDIAN, 10),
+               false, false, false),
+       [5] = lttng_kernel_static_event_field("reserved",
+               lttng_kernel_static_type_integer(3, 1, 0, __BIG_ENDIAN, 10),
+               false, false, false),
+       [6] = lttng_kernel_static_event_field("flags",
+               lttng_kernel_static_type_integer(9, 1, 0, __BIG_ENDIAN, 16),
+               false, false, false),
+       [7] = lttng_kernel_static_event_field("window_size",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [8] = lttng_kernel_static_event_field("checksum",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 16),
+               false, false, false),
+       [9] = lttng_kernel_static_event_field("urg_ptr",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 10),
+               false, false, false),
+};
+
+static const struct lttng_kernel_event_field *udpfields[] = {
+       [0] = lttng_kernel_static_event_field("source_port",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [1] = lttng_kernel_static_event_field("dest_port",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [2] = lttng_kernel_static_event_field("len",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [3] = lttng_kernel_static_event_field("check",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 10),
+               false, false, false),
+};
+
+static const struct lttng_kernel_event_field *icmpfields[] = {
+       [0] = lttng_kernel_static_event_field("type",
+               lttng_kernel_static_type_integer_from_type(uint8_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [1] = lttng_kernel_static_event_field("code",
+               lttng_kernel_static_type_integer_from_type(uint8_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [2] = lttng_kernel_static_event_field("checksum",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [3] = lttng_kernel_static_event_field("gateway",
+               lttng_kernel_static_type_integer_from_type(uint32_t, __BIG_ENDIAN, 10),
+               false, false, false),
+};
+
+static const struct lttng_kernel_event_field *transport_fields[] = {
+       [0] = lttng_kernel_static_event_field("unknown",
+               lttng_kernel_static_type_struct(ARRAY_SIZE(emptyfields), emptyfields, 0),
+               false, false, true),
+       [1] = lttng_kernel_static_event_field("tcp",
+               lttng_kernel_static_type_struct(ARRAY_SIZE(tcpfields), tcpfields, 0),
+               false, false, true),
+       [2] = lttng_kernel_static_event_field("udp",
+               lttng_kernel_static_type_struct(ARRAY_SIZE(udpfields), udpfields, 0),
+               false, false, true),
+       [3] = lttng_kernel_static_event_field("icmp",
+               lttng_kernel_static_type_struct(ARRAY_SIZE(icmpfields), icmpfields, 0),
+               false, false, true),
+};
+
+#endif /* LTTNG_CREATE_FIELD_METADATA */
+
+LTTNG_TRACEPOINT_ENUM(proto_transport_header_type,
+       TP_ENUM_VALUES(
+               ctf_enum_range("_unknown", 0, IPPROTO_ICMP - 1)
+               ctf_enum_value("_icmp", IPPROTO_ICMP)
+               ctf_enum_range("_unknown", IPPROTO_ICMP + 1, IPPROTO_TCP - 1)
+               ctf_enum_value("_tcp", IPPROTO_TCP)
+               ctf_enum_range("_unknown", IPPROTO_TCP + 1, IPPROTO_UDP - 1)
+               ctf_enum_value("_udp", IPPROTO_UDP)
+               ctf_enum_range("_unknown", IPPROTO_UDP + 1, 255)
+       )
+)
+
+LTTNG_TRACEPOINT_ENUM(transport_header_type,
+       TP_ENUM_VALUES(
+               ctf_enum_value("_unknown", TH_NONE)
+               ctf_enum_value("_tcp", TH_TCP)
+               ctf_enum_value("_udp", TH_UDP)
+               ctf_enum_value("_icmp", TH_ICMP)
+       )
+)
+
+#ifdef LTTNG_CREATE_FIELD_METADATA
+
+/* Structures for network headers. */
+
+static const struct lttng_kernel_event_field *ipv4fields[] = {
+       [0] = lttng_kernel_static_event_field("version",
+               lttng_kernel_static_type_integer(4, 4, 0, __BIG_ENDIAN, 10),
+               false, false, false),
+       [1] = lttng_kernel_static_event_field("ihl",
+               lttng_kernel_static_type_integer(4, 4, 0, __BIG_ENDIAN, 10),
+               false, false, false),
+       [2] = lttng_kernel_static_event_field("tos",
+               lttng_kernel_static_type_integer_from_type(uint8_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [3] = lttng_kernel_static_event_field("tot_len",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [4] = lttng_kernel_static_event_field("id",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 16),
+               false, false, false),
+       [5] = lttng_kernel_static_event_field("frag_off",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [6] = lttng_kernel_static_event_field("ttl",
+               lttng_kernel_static_type_integer_from_type(uint8_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [7] = lttng_kernel_static_event_field("protocol",
+               lttng_kernel_static_type_enum(&__enum_proto_transport_header_type,
+                       lttng_kernel_static_type_integer_from_type(uint8_t, __BIG_ENDIAN, 10)),
+               false, false, false),
+       [8] = lttng_kernel_static_event_field("checksum",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 16),
+               false, false, false),
+       [9] = lttng_kernel_static_event_field("saddr",
+               lttng_kernel_static_type_array(4,
+                       lttng_kernel_static_type_integer_from_type(uint8_t, __BIG_ENDIAN, 10),
+                       lttng_alignof(uint8_t), none),
+               false, false, false),
+       [10] = lttng_kernel_static_event_field("daddr",
+               lttng_kernel_static_type_array(4,
+                       lttng_kernel_static_type_integer_from_type(uint8_t, __BIG_ENDIAN, 10),
+                       lttng_alignof(uint8_t), none),
+               false, false, false),
+       [11] = lttng_kernel_static_event_field("transport_header_type",
+               lttng_kernel_static_type_enum(&__enum_transport_header_type,
+                       lttng_kernel_static_type_integer_from_type(uint8_t, __BYTE_ORDER, 10)),
+               false, false, false),
+       [12] = lttng_kernel_static_event_field("transport_header",
+               lttng_kernel_static_type_variant(ARRAY_SIZE(transport_fields), transport_fields,
+                       "transport_header_type", 0),
+               false, false, false),
+};
+
+static const struct lttng_kernel_event_field *ipv6fields[] = {
+       [0] = lttng_kernel_static_event_field("version",
+               lttng_kernel_static_type_integer(4, 4, 0, __BIG_ENDIAN, 10),
+               false, false, false),
+       [1] = lttng_kernel_static_event_field("prio",
+               lttng_kernel_static_type_integer(4, 4, 0, __BIG_ENDIAN, 10),
+               false, false, false),
+       [2] = lttng_kernel_static_event_field("flow_lbl",
+               lttng_kernel_static_type_array(3, lttng_kernel_static_type_integer_from_type(uint8_t, __BIG_ENDIAN, 16), lttng_alignof(uint8_t), none),
+               false, false, false),
+       [3] = lttng_kernel_static_event_field("payload_len",
+               lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [4] = lttng_kernel_static_event_field("nexthdr",
+               lttng_kernel_static_type_enum(&__enum_proto_transport_header_type,
+                       lttng_kernel_static_type_integer_from_type(uint8_t, __BIG_ENDIAN, 10)),
+               false, false, false),
+       [5] = lttng_kernel_static_event_field("hop_limit",
+               lttng_kernel_static_type_integer_from_type(uint8_t, __BIG_ENDIAN, 10),
+               false, false, false),
+       [6] = lttng_kernel_static_event_field("saddr",
+               lttng_kernel_static_type_array(8, lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 16), lttng_alignof(uint16_t), none),
+               false, false, false),
+       [7] = lttng_kernel_static_event_field("daddr",
+               lttng_kernel_static_type_array(8, lttng_kernel_static_type_integer_from_type(uint16_t, __BIG_ENDIAN, 16), lttng_alignof(uint16_t), none),
+               false, false, false),
+       [8] = lttng_kernel_static_event_field("transport_header_type",
+               lttng_kernel_static_type_enum(&__enum_transport_header_type,
+                       lttng_kernel_static_type_integer_from_type(uint8_t, __BYTE_ORDER, 10)),
+               false, false, false),
+       [9] = lttng_kernel_static_event_field("transport_header",
+               lttng_kernel_static_type_variant(ARRAY_SIZE(transport_fields),
+                       transport_fields, "transport_header_type", 0),
+               false, false, false),
+};
+
+static const struct lttng_kernel_event_field *network_fields[] = {
+       [0] = lttng_kernel_static_event_field("unknown",
+               lttng_kernel_static_type_struct(0, emptyfields, 0),
+               false, false, false),
+       [1] = lttng_kernel_static_event_field("ipv4",
+               lttng_kernel_static_type_struct(ARRAY_SIZE(ipv4fields), ipv4fields, 0),
+               false, false, false),
+       [2] = lttng_kernel_static_event_field("ipv6",
+               lttng_kernel_static_type_struct(ARRAY_SIZE(ipv6fields), ipv6fields, 0),
+               false, false, false),
+};
+
+#endif /* LTTNG_CREATE_FIELD_METADATA */
+
 LTTNG_TRACEPOINT_ENUM(net_network_header,
        TP_ENUM_VALUES(
                ctf_enum_value("_unknown", NH_NONE)
@@ -591,14 +357,8 @@ LTTNG_TRACEPOINT_EVENT_CLASS(net_dev_template,
                        network_header_type, __get_network_header_type(skb))
                ctf_custom_field(
                        ctf_custom_type(
-                               {
-                                       .type = lttng_kernel_type_variant_nestable,
-                                       .u.variant_nestable.tag_name = "network_header_type",
-                                       .u.variant_nestable.choices = network_fields,
-                                       .u.variant_nestable.nr_choices =
-                                               ARRAY_SIZE(network_fields),
-                                       .u.variant_nestable.alignment = 0,
-                               }
+                               lttng_kernel_static_type_variant(ARRAY_SIZE(network_fields),
+                                       network_fields, "network_header_type", 0)
                        ),
                        network_header,
                        ctf_custom_code(
index 4a61a5c7f2197c1e50034685feef2b2b169b1077..334aea8f48369387c4d446878194d77378514772 100644 (file)
@@ -88,46 +88,29 @@ SC_LTTNG_TRACEPOINT_ENUM(lttng_mmap_flags_options,
 )
 
 #define LTTNG_MMAP_FLAGS_TYPE                                          \
-{                                                                      \
-       .name = "type",                                                 \
-       .type = {                                                       \
-               .type = lttng_kernel_type_enum_nestable,                                \
-               .u = {                                                  \
-                       .enum_nestable = {                              \
-                               .desc = &__enum_lttng_mmap_flags_mapping_type,          \
-                               .container_type =  __LTTNG_COMPOUND_LITERAL(            \
-                                       struct lttng_type, __type_integer(uint32_t,     \
-                                               4, 1, -1, __BYTE_ORDER, 16, none)),     \
-                       },                                              \
-               },                                                      \
-       },                                                              \
-}
+       lttng_kernel_static_event_field("type",                         \
+               lttng_kernel_static_type_enum(&__enum_lttng_mmap_flags_mapping_type, \
+                               lttng_kernel_static_type_integer(4, 1, 0, __BYTE_ORDER, 16)), \
+               false, false, false)
 
 #define LTTNG_MMAP_FLAGS_OPTIONS                                       \
-{                                                                      \
-       .name = "options",                                              \
-       .type = {                                                       \
-               .type = lttng_kernel_type_enum_nestable,                                \
-               .u = {                                                  \
-                       .enum_nestable = {                              \
-                               .desc = &__enum_lttng_mmap_flags_options,           \
-                               .container_type = __LTTNG_COMPOUND_LITERAL(         \
-                                       struct lttng_type, __type_integer(uint32_t, \
-                                               28, 1, -1, __BYTE_ORDER, 16, none)),\
-                       },                                              \
-               },                                                      \
-       },                                                              \
-}
+       lttng_kernel_static_event_field("options",                      \
+               lttng_kernel_static_type_enum(&__enum_lttng_mmap_flags_options, \
+                               lttng_kernel_static_type_integer(28, 1, 0, __BYTE_ORDER, 16)), \
+               false, false, false)
 
 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
 #define LTTNG_MMAP_FLAGS                       \
+lttng_kernel_static_event_field_array(         \
        [0] = LTTNG_MMAP_FLAGS_TYPE,            \
-       [1] = LTTNG_MMAP_FLAGS_OPTIONS,
-
+       [1] = LTTNG_MMAP_FLAGS_OPTIONS,         \
+)
 #else
 #define LTTNG_MMAP_FLAGS                       \
+lttng_kernel_static_event_field_array(         \
        [0] = LTTNG_MMAP_FLAGS_OPTIONS,         \
-       [1] = LTTNG_MMAP_FLAGS_TYPE,
+       [1] = LTTNG_MMAP_FLAGS_TYPE,            \
+)
 #endif
 
 /*
@@ -149,15 +132,7 @@ SC_LTTNG_TRACEPOINT_EVENT(mmap,
                sc_in(
                        ctf_custom_field(
                                ctf_custom_type(
-                                       {
-                                               .type = lttng_kernel_type_struct_nestable,
-                                               .u.struct_nestable.nr_fields = 2,
-                                               .u.struct_nestable.fields =
-                                                       __LTTNG_COMPOUND_LITERAL(struct lttng_event_field,
-                                                               LTTNG_MMAP_FLAGS
-                                                       ),
-                                               .u.struct_nestable.alignment = lttng_alignof(uint32_t) * CHAR_BIT,
-                                       }
+                                       lttng_kernel_static_type_struct(2, LTTNG_MMAP_FLAGS, lttng_alignof(uint32_t) * CHAR_BIT)
                                ),
                                flags,
                                ctf_custom_code(
index 0dbdd82b9dbe4d2d7d7807fb580efed19ba71402..2b4918104e24990597f8881f1eda099e056b2824 100644 (file)
@@ -117,48 +117,32 @@ SC_LTTNG_TRACEPOINT_ENUM(lttng_clone_option_flags,
 )
 
 #define LTTNG_CLONE_FLAGS_EXIT_SIGNAL                                  \
-{                                                                      \
-       .name = "exit_signal",                                          \
-       .type = {                                                       \
-               .type = lttng_kernel_type_enum_nestable,                                \
-               .u = {                                                  \
-                       .enum_nestable = {                              \
-                               .desc = &__enum_lttng_clone_exit_signal_flags,          \
-                               .container_type =  __LTTNG_COMPOUND_LITERAL(            \
-                                       struct lttng_type, __type_integer(unsigned long,        \
-                                               CLONE_EXIT_SIGNAL_FLAG_RESERVED_BITS,   \
-                                               1, -1, __BYTE_ORDER, 16, none)),        \
-                       },                                              \
-               },                                                      \
-       },                                                              \
-}
+       lttng_kernel_static_event_field("exit_signal",                  \
+               lttng_kernel_static_type_enum(&__enum_lttng_clone_exit_signal_flags, \
+                       lttng_kernel_static_type_integer(CLONE_EXIT_SIGNAL_FLAG_RESERVED_BITS, \
+                               1, 0, __BYTE_ORDER, 16)),               \
+               false, false, false)
 
 #define LTTNG_CLONE_FLAGS_OPTIONS                                      \
-{                                                                      \
-       .name = "options",                                              \
-       .type = {                                                       \
-               .type = lttng_kernel_type_enum_nestable,                                \
-               .u = {                                                  \
-                       .enum_nestable = {                              \
-                               .desc = &__enum_lttng_clone_option_flags,               \
-                               .container_type =  __LTTNG_COMPOUND_LITERAL(            \
-                                       struct lttng_type, __type_integer(unsigned long,\
-                                               sizeof(unsigned long) * CHAR_BIT - CLONE_EXIT_SIGNAL_FLAG_RESERVED_BITS, \
-                                               1, -1, __BYTE_ORDER, 16, none)),        \
-                       },                                              \
-               },                                                      \
-       },                                                              \
-}
+       lttng_kernel_static_event_field("options",                      \
+               lttng_kernel_static_type_enum(&__enum_lttng_clone_option_flags, \
+                       lttng_kernel_static_type_integer(               \
+                               sizeof(unsigned long) * CHAR_BIT - CLONE_EXIT_SIGNAL_FLAG_RESERVED_BITS, \
+                               1, 0, __BYTE_ORDER, 16)),               \
+               false, false, false)
 
 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
 #define LTTNG_CLONE_FLAGS                      \
+lttng_kernel_static_event_field_array(         \
        [0] = LTTNG_CLONE_FLAGS_EXIT_SIGNAL,    \
-       [1] = LTTNG_CLONE_FLAGS_OPTIONS,
-
+       [1] = LTTNG_CLONE_FLAGS_OPTIONS,        \
+)
 #else
 #define LTTNG_CLONE_FLAGS                      \
+lttng_kernel_static_event_field_array(         \
        [0] = LTTNG_CLONE_FLAGS_OPTIONS,        \
-       [1] = LTTNG_CLONE_FLAGS_EXIT_SIGNAL,
+       [1] = LTTNG_CLONE_FLAGS_EXIT_SIGNAL,    \
+)
 #endif
 
 
@@ -174,15 +158,7 @@ SC_LTTNG_TRACEPOINT_EVENT(clone,
                sc_in(
                        ctf_custom_field(
                                ctf_custom_type(
-                                       {
-                                               .type = lttng_kernel_type_struct_nestable,
-                                               .u.struct_nestable.nr_fields = 2,
-                                               .u.struct_nestable.fields =
-                                                       __LTTNG_COMPOUND_LITERAL(struct lttng_event_field,
-                                                               LTTNG_CLONE_FLAGS
-                                                       ),
-                                               .u.struct_nestable.alignment = lttng_alignof(unsigned long) * CHAR_BIT,
-                                       }
+                                       lttng_kernel_static_type_struct(2, LTTNG_CLONE_FLAGS, lttng_alignof(unsigned long) * CHAR_BIT)
                                ),
                                flags,
                                ctf_custom_code(
@@ -315,7 +291,7 @@ end:        ; /* Label at end of compound statement. */                                     \
 #define LTTNG_SYSCALL_SELECT_fds_field_LE(name, input)                                                 \
        ctf_custom_field(                                                                               \
                ctf_custom_type(                                                                        \
-                       __type_integer(uint8_t, 0, 0, 0, __BYTE_ORDER, 10, none)                        \
+                       lttng_kernel_static_type_integer_from_type(uint8_t, __BYTE_ORDER, 10)           \
                ),                                                                                      \
                _ ## name ## _length,                                                                   \
                ctf_custom_code(                                                                        \
@@ -330,13 +306,11 @@ end:      ; /* Label at end of compound statement. */                                     \
        )                                                                                               \
        ctf_custom_field(                                                                               \
                ctf_custom_type(                                                                        \
-                       {                                                                               \
-                               .type = lttng_kernel_type_sequence_nestable,                                    \
-                               .u.sequence_nestable.length_name = "_" #name "_length",                 \
-                               .u.sequence_nestable.elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
-                                       __type_integer(uint8_t, 0, 0, 0, __BYTE_ORDER, 16, none)),      \
-                               .u.sequence_nestable.alignment = 0,                                     \
-                       }                                                                               \
+                       lttng_kernel_static_type_sequence(                                              \
+                               "_" #name "_length",                                                    \
+                               lttng_kernel_static_type_integer_from_type(uint8_t, __BYTE_ORDER, 16),  \
+                               0,                                                                      \
+                               none)                                                                   \
                ),                                                                                      \
                name,                                                                                   \
                ctf_custom_code(                                                                        \
@@ -363,7 +337,7 @@ end:        ; /* Label at end of compound statement. */                                     \
 #define LTTNG_SYSCALL_SELECT_fds_field_BE(name, input)                                                 \
        ctf_custom_field(                                                                               \
                ctf_custom_type(                                                                        \
-                       __type_integer(uint8_t, 0, 0, 0, __BYTE_ORDER, 10, none)                        \
+                       lttng_kernel_static_type_integer_from_type(uint8_t, __BYTE_ORDER, 10)           \
                ),                                                                                      \
                _ ## name ## _length,                                                                   \
                ctf_custom_code(                                                                        \
@@ -378,12 +352,10 @@ end:      ; /* Label at end of compound statement. */                                     \
        )                                                                                               \
        ctf_custom_field(                                                                               \
                ctf_custom_type(                                                                        \
-                       {                                                                               \
-                               .type = lttng_kernel_type_sequence_nestable,                                    \
-                               .u.sequence_nestable.elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
-                                       __type_integer(uint8_t, 0, 0, 0, __BYTE_ORDER, 16, none)),      \
-                               .u.sequence_nestable.alignment = 0,                                     \
-                       }                                                                               \
+                       lttng_kernel_static_type_sequence("_" #name "_length",                          \
+                               lttng_kernel_static_type_integer_from_type(uint8_t, __BYTE_ORDER, 16),  \
+                               0,                                                                      \
+                               none)                                                                   \
                ),                                                                                      \
                name,                                                                                   \
                ctf_custom_code(                                                                        \
@@ -496,64 +468,41 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(pselect6,
 /*
  * Only extract the values specified by iBCS2 for now.
  */
-static struct lttng_event_field lttng_pollfd_flag_fields[] = {
-       [ilog2(POLLIN)] = {
-               .name = "POLLIN",
-               .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
-       },
-       [ilog2(POLLPRI)] = {
-               .name = "POLLPRI",
-               .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
-       },
-       [ilog2(POLLOUT)] = {
-               .name = "POLLOUT",
-               .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
-       },
-       [ilog2(POLLERR)] = {
-               .name = "POLLERR",
-               .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
-       },
-       [ilog2(POLLHUP)] = {
-               .name = "POLLHUP",
-               .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
-       },
-       [ilog2(POLLNVAL)] = {
-               .name = "POLLNVAL",
-               .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
-       },
-       [ilog2(LTTNG_POLL_NRFLAGS)] = {
-               .name = "padding",
-               .type = __type_integer(int, POLL_FLAGS_PADDING_SIZE, 1, 0,
-                               __LITTLE_ENDIAN, 10, none),
-       },
+static const struct lttng_kernel_event_field *lttng_pollfd_flag_fields[] = {
+       [ilog2(POLLIN)] = lttng_kernel_static_event_field("POLLIN",
+                               lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10),
+                               false, false, false),
+       [ilog2(POLLPRI)] = lttng_kernel_static_event_field("POLLPRI",
+                               lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10),
+                               false, false, false),
+       [ilog2(POLLOUT)] = lttng_kernel_static_event_field("POLLOUT",
+                               lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10),
+                               false, false, false),
+       [ilog2(POLLERR)] = lttng_kernel_static_event_field("POLLERR",
+                               lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10),
+                               false, false, false),
+       [ilog2(POLLHUP)] = lttng_kernel_static_event_field("POLLHUP",
+                               lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10),
+                               false, false, false),
+       [ilog2(POLLNVAL)] = lttng_kernel_static_event_field("POLLNVAL",
+                               lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10),
+                               false, false, false),
+       [ilog2(LTTNG_POLL_NRFLAGS)] = lttng_kernel_static_event_field("padding",
+                               lttng_kernel_static_type_integer(POLL_FLAGS_PADDING_SIZE, 1, 0, __LITTLE_ENDIAN, 10),
+                               false, false, false),
 };
 
-static struct lttng_event_field lttng_pollfd_fields[] = {
-       [0] = {
-               .name = "fd",
-               .type = __type_integer(int, 0, 0, 0, __BYTE_ORDER, 10, none),
-       },
-       [1] = {
-               .name = "raw_events",
-               .type = __type_integer(short, 0, 0, 0, __BYTE_ORDER, 16, none),
-       },
-       [2] = {
-               .name = "events",
-               .type = {
-                       .type = lttng_kernel_type_struct_nestable,
-                       .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_pollfd_flag_fields),
-                       .u.struct_nestable.fields = lttng_pollfd_flag_fields,
-                       .u.struct_nestable.alignment = 0,
-               }
-       },
+static const struct lttng_kernel_event_field *lttng_pollfd_fields[] = {
+       [0] = lttng_kernel_static_event_field("fd", lttng_kernel_static_type_integer_from_type(int, __BYTE_ORDER, 10),
+                               false, false, false),
+       [1] = lttng_kernel_static_event_field("raw_events", lttng_kernel_static_type_integer_from_type(uint16_t, __BYTE_ORDER, 16),
+                               false, false, false),
+       [2] = lttng_kernel_static_event_field("events",
+               lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_pollfd_flag_fields),
+                       lttng_pollfd_flag_fields, 0),
+               false, false, false),
 };
 
-static struct lttng_type lttng_pollfd_elem = {
-       .type = lttng_kernel_type_struct_nestable,
-       .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_pollfd_fields),
-       .u.struct_nestable.fields = lttng_pollfd_fields,
-       .u.struct_nestable.alignment = 0,
-};
 #endif /* ONCE_LTTNG_TRACE_POLL_H */
 
 #define LTTNG_SYSCALL_POLL_locvar                              \
@@ -621,11 +570,10 @@ end:                                                                                      \
        sc_in(                                                                                  \
                ctf_custom_field(                                                               \
                        ctf_custom_type(                                                        \
-                               {                                                               \
-                                       .type = lttng_kernel_type_sequence_nestable,                    \
-                                       .u.sequence_nestable.length_name = "fds_length",        \
-                                       .u.sequence_nestable.elem_type = &lttng_pollfd_elem,    \
-                               }                                                               \
+                               lttng_kernel_static_type_sequence("fds_length",                 \
+                                       lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_pollfd_fields), lttng_pollfd_fields, 0), \
+                                       0,                                                      \
+                                       none)                                                   \
                        ),                                                                      \
                        fds,                                                                    \
                        ctf_custom_code(                                                        \
@@ -644,11 +592,10 @@ end:                                                                                      \
        sc_out(                                                                                 \
                ctf_custom_field(                                                               \
                        ctf_custom_type(                                                        \
-                               {                                                               \
-                                       .type = lttng_kernel_type_sequence_nestable,                    \
-                                       .u.sequence_nestable.length_name = "fds_length",        \
-                                       .u.sequence_nestable.elem_type = &lttng_pollfd_elem,    \
-                               }                                                               \
+                               lttng_kernel_static_type_sequence("fds_length",                 \
+                                       lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_pollfd_fields), lttng_pollfd_fields, 0), \
+                                       0,                                                      \
+                                       none)                                                   \
                        ),                                                                      \
                        fds,                                                                    \
                        ctf_custom_code(                                                        \
@@ -763,74 +710,55 @@ SC_LTTNG_TRACEPOINT_ENUM(lttng_epoll_op,
 /*
  * Only extract the values specified by iBCS2 for now.
  */
-static struct lttng_event_field lttng_epoll_ctl_events_fields[] = {
+static const struct lttng_kernel_event_field *lttng_epoll_ctl_events_fields[] = {
        /* 0x0001 */
-       [ilog2(POLLIN)] = {
-               .name = "EPOLLIN",
-               .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
-       },
+       [ilog2(POLLIN)] = lttng_kernel_static_event_field("EPOLLIN",
+                       lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10),
+                       false, false, false),
        /* 0x0002 */
-       [ilog2(POLLPRI)] = {
-               .name = "EPOLLPRI",
-               .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
-       },
+       [ilog2(POLLPRI)] = lttng_kernel_static_event_field("EPOLLPRI",
+                       lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10),
+                       false, false, false),
        /* 0x0004 */
-       [ilog2(POLLOUT)] = {
-               .name = "EPOLLOUT",
-               .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
-       },
+       [ilog2(POLLOUT)] = lttng_kernel_static_event_field("EPOLLOUT",
+                       lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10),
+                       false, false, false),
        /* 0x0008 */
-       [ilog2(POLLERR)] = {
-               .name = "EPOLLERR",
-               .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
-       },
+       [ilog2(POLLERR)] = lttng_kernel_static_event_field("EPOLLERR",
+                       lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10),
+                       false, false, false),
        /* 0x0010 */
-       [ilog2(POLLHUP)] = {
-               .name = "EPOLLHUP",
-               .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
-       },
-       [ilog2(LTTNG_EPOLL_NRFLAGS)] = {
-               .name = "padding",
-               .type = __type_integer(int, EPOLL_FLAGS_PADDING_SIZE, 1, 0,
-                               __LITTLE_ENDIAN, 10, none),
-       },
-
+       [ilog2(POLLHUP)] = lttng_kernel_static_event_field("EPOLLHUP",
+                       lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10),
+                       false, false, false),
+       [ilog2(LTTNG_EPOLL_NRFLAGS)] = lttng_kernel_static_event_field("padding",
+                       lttng_kernel_static_type_integer(EPOLL_FLAGS_PADDING_SIZE, 1, 0, __LITTLE_ENDIAN, 10),
+                       false, false, false),
 };
 
-static struct lttng_event_field lttng_epoll_data_fields[] = {
-       [0] = {
-               .name = "u64",
-               .type = __type_integer(uint64_t, 0, 0, 0, __BYTE_ORDER, 16, none),
-       },
-       [1] = {
-               .name = "fd",
-               .type = __type_integer(int, 0, 0, 0, __BYTE_ORDER, 10, none),
-       },
+static const struct lttng_kernel_event_field *lttng_epoll_data_fields[] = {
+       [0] = lttng_kernel_static_event_field("u64",
+                       lttng_kernel_static_type_integer_from_type(uint64_t, __BYTE_ORDER, 16),
+                       false, false, false),
+       [1] = lttng_kernel_static_event_field("fd",
+                       lttng_kernel_static_type_integer_from_type(int, __BYTE_ORDER, 10),
+                       false, false, false),
 };
 
-static struct lttng_event_field epoll_ctl_fields[] = {
-       [0] = {
-               .name = "data_union",
-               .type = {
-                       .type = lttng_kernel_type_struct_nestable,
-                       .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_epoll_data_fields),
-                       .u.struct_nestable.fields = lttng_epoll_data_fields,
-                       .u.struct_nestable.alignment = 0,
-               }
-       },
-       [1] = {
-               .name = "raw_events",
-               .type = __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER, 16, none),
-       },
-       [2] = {
-               .name = "events",
-               .type = {
-                       .type = lttng_kernel_type_struct_nestable,
-                       .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_epoll_ctl_events_fields),
-                       .u.struct_nestable.fields = lttng_epoll_ctl_events_fields,
-                       .u.struct_nestable.alignment = 0,
-               }
-       },
+static const struct lttng_kernel_event_field *epoll_ctl_fields[] = {
+       [0] = lttng_kernel_static_event_field("data_union",
+               lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_epoll_data_fields),
+                               lttng_epoll_data_fields,
+                               0),
+               false, false, false),
+       [1] = lttng_kernel_static_event_field("raw_events",
+               lttng_kernel_static_type_integer_from_type(uint32_t, __BYTE_ORDER, 16),
+               false, false, false),
+       [2] = lttng_kernel_static_event_field("events",
+               lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_epoll_ctl_events_fields),
+                               lttng_epoll_ctl_events_fields,
+                               0),
+               false, false, false),
 };
 #endif /* ONCE_LTTNG_TRACE_EPOLL_CTL_H */
 
@@ -857,12 +785,7 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_ctl,
                sc_in(
                        ctf_custom_field(
                                ctf_custom_type(
-                                       {
-                                               .type = lttng_kernel_type_struct_nestable,
-                                               .u.struct_nestable.nr_fields = ARRAY_SIZE(epoll_ctl_fields),
-                                               .u.struct_nestable.fields = epoll_ctl_fields,
-                                               .u.struct_nestable.alignment = 0,
-                                       }
+                                       lttng_kernel_static_type_struct(ARRAY_SIZE(epoll_ctl_fields), epoll_ctl_fields, 0)
                                ),
                                event,
                                ctf_custom_code(
@@ -891,37 +814,16 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_ctl,
 #ifndef ONCE_LTTNG_TRACE_EPOLL_H
 #define ONCE_LTTNG_TRACE_EPOLL_H
 
-static struct lttng_event_field lttng_epoll_wait_fields[] = {
-       [0] = {
-               .name = "data_union",
-               .type = {
-                       .type = lttng_kernel_type_struct_nestable,
-                       .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_epoll_data_fields),
-                       .u.struct_nestable.fields = lttng_epoll_data_fields,
-                       .u.struct_nestable.alignment = 0,
-               }
-       },
-       [1] = {
-               .name = "raw_events",
-               .type = __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER, 16, none),
-       },
-       [2] = {
-               .name = "events",
-               .type = {
-                       .type = lttng_kernel_type_struct_nestable,
-                       .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_epoll_ctl_events_fields),
-                       .u.struct_nestable.fields = lttng_epoll_ctl_events_fields,
-                       .u.struct_nestable.alignment = 0,
-               }
-       },
-};
-
-static struct lttng_type lttng_epoll_wait_elem = {
-       .type = lttng_kernel_type_struct_nestable,
-       .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_epoll_wait_fields),
-       .u.struct_nestable.fields = lttng_epoll_wait_fields,
-       .u.struct_nestable.alignment = 0,
-};
+static const struct lttng_kernel_event_field *lttng_epoll_wait_fields[] = lttng_kernel_static_event_field_array(
+       [0] = lttng_kernel_static_event_field("data_union",
+                       lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_epoll_data_fields), lttng_epoll_data_fields, 0),
+                       false, false, false),
+       [1] = lttng_kernel_static_event_field("raw_events", lttng_kernel_static_type_integer_from_type(uint32_t, __BYTE_ORDER, 16),
+                       false, false, false),
+       [2] = lttng_kernel_static_event_field("events",
+                       lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_epoll_ctl_events_fields), lttng_epoll_ctl_events_fields, 0),
+                       false, false, false),
+);
 
 #endif /* ONCE_LTTNG_TRACE_EPOLL_H */
 
@@ -960,7 +862,7 @@ static struct lttng_type lttng_epoll_wait_elem = {
                        tp_locvar->fds_length = ret;                            \
                }                                                               \
                                                                                \
-               tp_locvar->events = lttng_tp_mempool_alloc(                             \
+               tp_locvar->events = lttng_tp_mempool_alloc(                     \
                        maxalloc * sizeof(struct epoll_event));                 \
                if (!tp_locvar->events) {                                       \
                        tp_locvar->fds_length = 0;                              \
@@ -979,13 +881,10 @@ static struct lttng_type lttng_epoll_wait_elem = {
 #define LTTNG_SYSCALL_EPOLL_WAIT_fds_field                                             \
        ctf_custom_field(                                                               \
                ctf_custom_type(                                                        \
-                       {                                                               \
-                               .type = lttng_kernel_type_sequence_nestable,                    \
-                               .u.sequence_nestable.length_name =                      \
-                                       "fds_length",                                   \
-                               .u.sequence_nestable.elem_type =                        \
-                                       &lttng_epoll_wait_elem,                         \
-                       }                                                               \
+                       lttng_kernel_static_type_sequence("fds_length",                 \
+                               lttng_kernel_static_type_struct(ARRAY_SIZE(lttng_epoll_wait_fields), lttng_epoll_wait_fields, 0), \
+                               0,                                                      \
+                               none)                                                   \
                ),                                                                      \
                fds,                                                                    \
                ctf_custom_code(                                                        \
index 6749b38388ac38ce8737a5c11cac43bb63be2a4c..0c7628483271c06c0b012444371bbaced4e100a8 100644 (file)
@@ -8,4 +8,80 @@
 #ifndef _LTTNG_EVENTS_INTERNAL_H
 #define _LTTNG_EVENTS_INTERNAL_H
 
+#include <lttng/events.h>
+
+static inline
+const struct lttng_kernel_type_integer *lttng_kernel_get_type_integer(const struct lttng_kernel_type_common *type)
+{
+       if (type->type != lttng_kernel_type_integer)
+               return NULL;
+       return container_of(type, const struct lttng_kernel_type_integer, parent);
+}
+
+static inline
+const struct lttng_kernel_type_string *lttng_kernel_get_type_string(const struct lttng_kernel_type_common *type)
+{
+       if (type->type != lttng_kernel_type_string)
+               return NULL;
+       return container_of(type, const struct lttng_kernel_type_string, parent);
+}
+
+static inline
+const struct lttng_kernel_type_enum *lttng_kernel_get_type_enum(const struct lttng_kernel_type_common *type)
+{
+       if (type->type != lttng_kernel_type_enum)
+               return NULL;
+       return container_of(type, const struct lttng_kernel_type_enum, parent);
+}
+
+static inline
+const struct lttng_kernel_type_array *lttng_kernel_get_type_array(const struct lttng_kernel_type_common *type)
+{
+       if (type->type != lttng_kernel_type_array)
+               return NULL;
+       return container_of(type, const struct lttng_kernel_type_array, parent);
+}
+
+static inline
+const struct lttng_kernel_type_sequence *lttng_kernel_get_type_sequence(const struct lttng_kernel_type_common *type)
+{
+       if (type->type != lttng_kernel_type_sequence)
+               return NULL;
+       return container_of(type, const struct lttng_kernel_type_sequence, parent);
+}
+
+static inline
+const struct lttng_kernel_type_struct *lttng_kernel_get_type_struct(const struct lttng_kernel_type_common *type)
+{
+       if (type->type != lttng_kernel_type_struct)
+               return NULL;
+       return container_of(type, const struct lttng_kernel_type_struct, parent);
+}
+
+static inline
+const struct lttng_kernel_type_variant *lttng_kernel_get_type_variant(const struct lttng_kernel_type_common *type)
+{
+       if (type->type != lttng_kernel_type_variant)
+               return NULL;
+       return container_of(type, const struct lttng_kernel_type_variant, parent);
+}
+
+static inline bool lttng_kernel_type_is_bytewise_integer(const struct lttng_kernel_type_common *type)
+{
+       const struct lttng_kernel_type_integer *type_integer = lttng_kernel_get_type_integer(type);
+
+       if (!type_integer)
+               return false;
+       switch (type_integer->size) {
+       case 8:         /* Fall-through. */
+       case 16:        /* Fall-through. */
+       case 32:        /* Fall-through. */
+       case 64:
+               break;
+       default:
+               return false;
+       }
+       return true;
+}
+
 #endif /* _LTTNG_EVENTS_INTERNAL_H */
index 05e8618438f8e1c9d4c63e562d7c65a626655da0..7fbc88795493494a29b18e595b1c113b02cae4c5 100644 (file)
@@ -38,11 +38,11 @@ struct lib_ring_buffer_config;
 enum lttng_kernel_type {
        lttng_kernel_type_integer,
        lttng_kernel_type_string,
-       lttng_kernel_type_enum_nestable,
-       lttng_kernel_type_array_nestable,
-       lttng_kernel_type_sequence_nestable,
-       lttng_kernel_type_struct_nestable,
-       lttng_kernel_type_variant_nestable,
+       lttng_kernel_type_enum,
+       lttng_kernel_type_array,
+       lttng_kernel_type_sequence,
+       lttng_kernel_type_struct,
+       lttng_kernel_type_variant,
        NR_LTTNG_KERNEL_TYPES,
 };
 
@@ -71,81 +71,238 @@ struct lttng_kernel_enum_entry {
        } options;
 };
 
-#define __type_integer(_type, _size, _alignment, _signedness,  \
-               _byte_order, _base, _encoding)  \
-       {                                                       \
-           .type = lttng_kernel_type_integer,                          \
-           .u.integer =                                        \
-               {                                               \
-                 .size = (_size) ? : sizeof(_type) * CHAR_BIT, \
-                 .alignment = (_alignment) ? : lttng_alignof(_type) * CHAR_BIT, \
-                 .signedness = (_signedness) >= 0 ? (_signedness) : lttng_is_signed_type(_type), \
-                 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
-                 .base = _base,                                \
-                 .encoding = lttng_kernel_string_encoding_##_encoding,         \
-               },                                              \
-       }                                                       \
-
-struct lttng_integer_type {
+/*
+ * struct lttng_kernel_type_common is fixed-size. Its children inherits
+ * from it by embedding struct lttng_kernel_type_common as its first field.
+ */
+struct lttng_kernel_type_common {
+       enum lttng_kernel_type type;
+};
+
+struct lttng_kernel_type_integer {
+       struct lttng_kernel_type_common parent;
        unsigned int size;              /* in bits */
        unsigned short alignment;       /* in bits */
        unsigned int signedness:1,
                reverse_byte_order:1;
        unsigned int base;              /* 2, 8, 10, 16, for pretty print */
+};
+
+struct lttng_kernel_type_string {
+       struct lttng_kernel_type_common parent;
        enum lttng_kernel_string_encoding encoding;
 };
 
-struct lttng_type {
-       enum lttng_kernel_type type;
-       union {
-               struct lttng_integer_type integer;
-               struct {
-                       enum lttng_kernel_string_encoding encoding;
-               } string;
-               struct {
-                       const struct lttng_kernel_enum_desc *desc;      /* Enumeration mapping */
-                       const struct lttng_type *container_type;
-               } enum_nestable;
-               struct {
-                       const struct lttng_type *elem_type;
-                       unsigned int length;                    /* Num. elems. */
-                       unsigned int alignment;
-               } array_nestable;
-               struct {
-                       const char *length_name;                /* Length field name. */
-                       const struct lttng_type *elem_type;
-                       unsigned int alignment;                 /* Alignment before elements. */
-               } sequence_nestable;
-               struct {
-                       unsigned int nr_fields;
-                       const struct lttng_event_field *fields; /* Array of fields. */
-                       unsigned int alignment;
-               } struct_nestable;
-               struct {
-                       const char *tag_name;
-                       const struct lttng_event_field *choices; /* Array of fields. */
-                       unsigned int nr_choices;
-                       unsigned int alignment;
-               } variant_nestable;
-       } u;
+struct lttng_kernel_type_enum {
+       struct lttng_kernel_type_common parent;
+       const struct lttng_kernel_enum_desc *desc;      /* Enumeration mapping */
+       const struct lttng_kernel_type_common *container_type;
+};
+
+struct lttng_kernel_type_array {
+       struct lttng_kernel_type_common parent;
+       const struct lttng_kernel_type_common *elem_type;
+       unsigned int length;                    /* Num. elems. */
+       unsigned int alignment;
+       enum lttng_kernel_string_encoding encoding;
+};
+
+struct lttng_kernel_type_sequence {
+       struct lttng_kernel_type_common parent;
+       const char *length_name;        /* Length field name. */
+       const struct lttng_kernel_type_common *elem_type;
+       unsigned int alignment;         /* Alignment before elements. */
+       enum lttng_kernel_string_encoding encoding;
+};
+
+struct lttng_kernel_type_struct {
+       struct lttng_kernel_type_common parent;
+       unsigned int nr_fields;
+       const struct lttng_kernel_event_field **fields; /* Array of pointers to fields. */
+       unsigned int alignment;
+};
+
+struct lttng_kernel_type_variant {
+       struct lttng_kernel_type_common parent;
+       const char *tag_name;
+       const struct lttng_kernel_event_field **choices; /* Array of pointers to fields. */
+       unsigned int nr_choices;
+       unsigned int alignment;
 };
 
 struct lttng_kernel_enum_desc {
        const char *name;
-       const struct lttng_kernel_enum_entry *entries;
+       const struct lttng_kernel_enum_entry **entries;
        unsigned int nr_entries;
 };
 
 /* Event field description */
 
-struct lttng_event_field {
+struct lttng_kernel_event_field {
        const char *name;
-       struct lttng_type type;
+       const struct lttng_kernel_type_common *type;
        unsigned int nowrite:1,         /* do not write into trace */
                        user:1,         /* fetch from user-space */
                        nofilter:1;     /* do not consider for filter */
 };
 
+#define lttng_kernel_static_type_integer(_size, _alignment, _signedness, _byte_order, _base)           \
+       ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_integer, { \
+               .parent = {                                                                             \
+                       .type = lttng_kernel_type_integer,                                                      \
+               },                                                                                      \
+               .size = (_size),                                                                        \
+               .alignment = (_alignment),                                                              \
+               .signedness = (_signedness),                                                            \
+               .reverse_byte_order = (_byte_order) != __BYTE_ORDER,                                    \
+               .base = (_base),                                                                        \
+       }))
+
+#define lttng_kernel_static_type_integer_from_type(_type, _byte_order, _base)                          \
+       lttng_kernel_static_type_integer(sizeof(_type) * CHAR_BIT,                                      \
+                       lttng_alignof(_type) * CHAR_BIT,                                                \
+                       lttng_is_signed_type(_type),                                                    \
+                       _byte_order,                                                                    \
+                       _base)
+
+#define lttng_kernel_static_type_enum(_desc, _container_type)                                          \
+       ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_enum, { \
+               .parent = {                                                                             \
+                       .type = lttng_kernel_type_enum,                                                 \
+               },                                                                                      \
+               .desc = (_desc),                                                                        \
+               .container_type = (_container_type),                                                    \
+       }))
+
+#define lttng_kernel_static_type_array(_length, _elem_type, _alignment, _encoding)                     \
+       ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_array, { \
+               .parent = {                                                                             \
+                       .type = lttng_kernel_type_array,                                                \
+               },                                                                                      \
+               .length = (_length),                                                                    \
+               .alignment = (_alignment),                                                              \
+               .encoding = lttng_kernel_string_encoding_##_encoding,                                   \
+               .elem_type = (_elem_type),                                                              \
+       }))
+
+#define lttng_kernel_static_type_array_text(_length)                                                   \
+       lttng_kernel_static_type_array(_length,                                                         \
+               lttng_kernel_static_type_integer(sizeof(char) * CHAR_BIT,                               \
+                               lttng_alignof(char) * CHAR_BIT, lttng_is_signed_type(char),             \
+                               __BYTE_ORDER, 10),                                                      \
+               0, UTF8)
+
+#define lttng_kernel_static_type_sequence(_length_name, _elem_type, _alignment, _encoding)                     \
+       ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_sequence, { \
+               .parent = {                                                                             \
+                       .type = lttng_kernel_type_sequence,                                             \
+               },                                                                                      \
+               .length_name = (_length_name),                                                          \
+               .alignment = (_alignment),                                                              \
+               .encoding = lttng_kernel_string_encoding_##_encoding,                                   \
+               .elem_type = (_elem_type),                                                              \
+       }))
+
+#define lttng_kernel_static_type_string(_encoding)                                                     \
+       ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_string, { \
+               .parent = {                                                                             \
+                       .type = lttng_kernel_type_string,                                               \
+               },                                                                                      \
+               .encoding = lttng_kernel_string_encoding_##_encoding,                                   \
+       }))
+
+#define lttng_kernel_static_type_struct(_nr_fields, _fields, _alignment)                               \
+       ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_struct, { \
+               .parent = {                                                                             \
+                       .type = lttng_kernel_type_struct,                                               \
+               },                                                                                      \
+               .nr_fields = (_nr_fields),                                                              \
+               .fields = _fields,                                                                      \
+               .alignment = (_alignment),                                                              \
+       }))
+
+#define lttng_kernel_static_type_variant(_nr_choices, _choices, _tag_name, _alignment)                 \
+       ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_variant, { \
+               .parent = {                                                                             \
+                       .type = lttng_kernel_type_variant,                                              \
+               },                                                                                      \
+               .tag_name = (_tag_name),                                                                \
+               .choices = _choices,                                                                    \
+               .nr_choices = (_nr_choices),                                                            \
+               .alignment = (_alignment),                                                              \
+       }))
+
+#define lttng_kernel_static_event_field(_name, _type, _nowrite, _user, _nofilter)                      \
+       __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_event_field, {                               \
+               .name = (_name),                                                                        \
+               .type = (_type),                                                                        \
+               .nowrite = (_nowrite),                                                                  \
+               .user = (_user),                                                                        \
+               .nofilter = (_nofilter),                                                                \
+       })
+
+#define lttng_kernel_static_event_field_array(_fields...)                                              \
+       __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_event_field *,                               \
+               _fields                                                                                 \
+       )
+
+#define lttng_kernel_static_ctx_field(_event_field, _get_size, _get_size_arg, _record, _get_value, _destroy, _priv) \
+       __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, {                                 \
+               .event_field = (_event_field),                                                          \
+               .get_size = (_get_size),                                                                \
+               .get_size_arg = (_get_size_arg),                                                        \
+               .record = (_record),                                                                    \
+               .get_value = (_get_value),                                                              \
+               .destroy = (_destroy),                                                                  \
+               .priv = (_priv),                                                                        \
+       })
+
+#define lttng_kernel_static_enum_entry_value(_string, _value)                                          \
+       __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_enum_entry, {                                \
+               .start = {                                                                              \
+                       .signedness = lttng_is_signed_type(__typeof__(_value)),                         \
+                       .value = lttng_is_signed_type(__typeof__(_value)) ?                             \
+                               (long long) (_value) : (_value),                                        \
+               },                                                                                      \
+               .end = {                                                                                \
+                       .signedness = lttng_is_signed_type(__typeof__(_value)),                         \
+                       .value = lttng_is_signed_type(__typeof__(_value)) ?                             \
+                               (long long) (_value) : (_value),                                        \
+               },                                                                                      \
+               .string = (_string),                                                                    \
+       }),
+
+#define lttng_kernel_static_enum_entry_range(_string, _range_start, _range_end)                                \
+       __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_enum_entry, {                                \
+               .start = {                                                                              \
+                       .signedness = lttng_is_signed_type(__typeof__(_range_start)),                   \
+                       .value = lttng_is_signed_type(__typeof__(_range_start)) ?                       \
+                               (long long) (_range_start) : (_range_start),                            \
+               },                                                                                      \
+               .end = {                                                                                \
+                       .signedness = lttng_is_signed_type(__typeof__(_range_end)),                     \
+                       .value = lttng_is_signed_type(__typeof__(_range_end)) ?                         \
+                               (long long) (_range_end) : (_range_end),                                \
+               },                                                                                      \
+               .string = (_string),                                                                    \
+       }),
+
+#define lttng_kernel_static_enum_entry_auto(_string)                                                   \
+       __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_enum_entry, {                                \
+               .start = {                                                                              \
+                       .signedness = -1,                                                               \
+                       .value = -1,                                                                    \
+               },                                                                                      \
+               .end = {                                                                                \
+                       .signedness = -1,                                                               \
+                       .value = -1,                                                                    \
+               },                                                                                      \
+               .string = (_string),                                                                    \
+               .options = {                                                                            \
+                       .is_auto = 1,                                                                   \
+               }                                                                                       \
+       }),
+
 union lttng_ctx_value {
        int64_t s64;
        const char *str;
@@ -154,7 +311,7 @@ union lttng_ctx_value {
 
 /*
  * We need to keep this perf counter field separately from struct
- * lttng_ctx_field because cpu hotplug needs fixed-location addresses.
+ * lttng_kernel_ctx_field because cpu hotplug needs fixed-location addresses.
  */
 struct lttng_perf_counter_field {
 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
@@ -166,6 +323,8 @@ struct lttng_perf_counter_field {
 #endif
        struct perf_event_attr *attr;
        struct perf_event **e;  /* per-cpu array */
+       char *name;
+       struct lttng_kernel_event_field *event_field;
 };
 
 struct lttng_probe_ctx {
@@ -174,51 +333,43 @@ struct lttng_probe_ctx {
        uint8_t interruptible;
 };
 
-struct lttng_ctx_field {
-       struct lttng_event_field event_field;
+struct lttng_kernel_ctx_field {
+       const struct lttng_kernel_event_field *event_field;
        size_t (*get_size)(size_t offset);
-       size_t (*get_size_arg)(size_t offset, struct lttng_ctx_field *field,
+       size_t (*get_size_arg)(size_t offset, struct lttng_kernel_ctx_field *field,
                               struct lib_ring_buffer_ctx *ctx,
                               struct lttng_channel *chan);
-       void (*record)(struct lttng_ctx_field *field,
+       void (*record)(struct lttng_kernel_ctx_field *field,
                       struct lib_ring_buffer_ctx *ctx,
                       struct lttng_channel *chan);
-       void (*get_value)(struct lttng_ctx_field *field,
+       void (*get_value)(struct lttng_kernel_ctx_field *field,
                         struct lttng_probe_ctx *lttng_probe_ctx,
                         union lttng_ctx_value *value);
-       union {
-               struct lttng_perf_counter_field *perf_counter;
-       } u;
-       void (*destroy)(struct lttng_ctx_field *field);
-       /*
-        * Private data to keep state between get_size and record.
-        * User must perform its own synchronization to protect against
-        * concurrent and reentrant contexts.
-        */
+       void (*destroy)(struct lttng_kernel_ctx_field *field);
        void *priv;
 };
 
-struct lttng_ctx {
-       struct lttng_ctx_field *fields;
+struct lttng_kernel_ctx {
+       struct lttng_kernel_ctx_field *fields;
        unsigned int nr_fields;
        unsigned int allocated_fields;
        size_t largest_align;   /* in bytes */
 };
 
-struct lttng_event_desc {
-       const char *name;               /* lttng-modules name */
-       const char *kname;              /* Linux kernel name (tracepoints) */
-       void *probe_callback;
-       const struct lttng_event_ctx *ctx;      /* context */
-       const struct lttng_event_field *fields; /* event payload */
+struct lttng_kernel_event_desc {
+       const char *event_name;         /* lttng-modules name */
+       const char *event_kname;        /* Linux kernel name (tracepoints) */
+       const struct lttng_kernel_probe_desc *probe_desc;
+       void (*probe_callback)(void);
+       const struct lttng_kernel_event_field **fields; /* event payload */
        unsigned int nr_fields;
        struct module *owner;
        void *event_notifier_callback;
 };
 
-struct lttng_probe_desc {
-       const char *provider;
-       const struct lttng_event_desc **event_desc;
+struct lttng_kernel_probe_desc {
+       const char *provider_name;
+       const struct lttng_kernel_event_desc **event_desc;
        unsigned int nr_events;
        struct list_head head;                  /* chain registered probes */
        struct list_head lazy_init_head;
@@ -274,7 +425,7 @@ struct lttng_bytecode_runtime {
        } interpreter_funcs;
        int link_failed;
        struct list_head node;  /* list of bytecode runtime in event */
-       struct lttng_ctx *ctx;
+       struct lttng_kernel_ctx *ctx;
 };
 
 /*
@@ -324,9 +475,9 @@ struct lttng_event {
        unsigned int id;
        struct lttng_channel *chan;
        int enabled;
-       const struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_desc *desc;
        void *filter;
-       struct lttng_ctx *ctx;
+       struct lttng_kernel_ctx *ctx;
        enum lttng_kernel_instrumentation instrumentation;
        union {
                struct lttng_kprobe kprobe;
@@ -364,7 +515,7 @@ struct lttng_event_notifier {
        uint64_t error_counter_index;
        int enabled;
        int registered;                 /* has reg'd tracepoint probe */
-       const struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_desc *desc;
        void *filter;
        struct list_head list;          /* event_notifier list in event_notifier group */
 
@@ -429,7 +580,7 @@ struct lttng_event_enabler {
         * Unused, but kept around to make it explicit that the tracer can do
         * it.
         */
-       struct lttng_ctx *ctx;
+       struct lttng_kernel_ctx *ctx;
 };
 
 struct lttng_event_notifier_enabler {
@@ -577,7 +728,7 @@ struct lttng_channel {
        unsigned int id;
        struct channel *chan;           /* Channel buffers */
        int enabled;
-       struct lttng_ctx *ctx;
+       struct lttng_kernel_ctx *ctx;
        /* Event ID management */
        struct lttng_session *session;
        struct file *file;              /* File associated to channel */
@@ -700,7 +851,6 @@ struct lttng_event_notifier_group {
        struct list_head enablers_head; /* List of enablers */
        struct list_head event_notifiers_head; /* List of event notifier */
        struct lttng_event_notifier_ht event_notifiers_ht; /* Hash table of event notifiers */
-       struct lttng_ctx *ctx;          /* Contexts for filters. */
        struct lttng_channel_ops *ops;
        struct lttng_transport *transport;
        struct channel *chan;           /* Ring buffer channel for event notifier group. */
@@ -814,20 +964,20 @@ void lttng_metadata_channel_destroy(struct lttng_channel *chan);
 struct lttng_event *lttng_event_create(struct lttng_channel *chan,
                                struct lttng_kernel_event *event_param,
                                void *filter,
-                               const struct lttng_event_desc *event_desc,
+                               const struct lttng_kernel_event_desc *event_desc,
                                enum lttng_kernel_instrumentation itype);
 struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
                                struct lttng_kernel_event *event_param,
                                void *filter,
-                               const struct lttng_event_desc *event_desc,
+                               const struct lttng_kernel_event_desc *event_desc,
                                enum lttng_kernel_instrumentation itype);
 struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan,
                struct lttng_kernel_old_event *old_event_param,
                void *filter,
-               const struct lttng_event_desc *internal_desc);
+               const struct lttng_kernel_event_desc *internal_desc);
 
 struct lttng_event_notifier *lttng_event_notifier_create(
-                               const struct lttng_event_desc *event_notifier_desc,
+                               const struct lttng_kernel_event_desc *event_notifier_desc,
                                uint64_t id,
                                uint64_t error_counter_idx,
                                struct lttng_event_notifier_group *event_notifier_group,
@@ -835,7 +985,7 @@ struct lttng_event_notifier *lttng_event_notifier_create(
                                void *filter,
                                enum lttng_kernel_instrumentation itype);
 struct lttng_event_notifier *_lttng_event_notifier_create(
-                               const struct lttng_event_desc *event_notifier_desc,
+                               const struct lttng_kernel_event_desc *event_notifier_desc,
                                uint64_t id,
                                uint64_t error_counter_idx,
                                struct lttng_event_notifier_group *event_notifier_group,
@@ -863,10 +1013,10 @@ int lttng_abi_compat_old_init(void);
 void lttng_abi_exit(void);
 void lttng_abi_compat_old_exit(void);
 
-int lttng_probe_register(struct lttng_probe_desc *desc);
-void lttng_probe_unregister(struct lttng_probe_desc *desc);
-const struct lttng_event_desc *lttng_event_desc_get(const char *name);
-void lttng_event_desc_put(const struct lttng_event_desc *desc);
+int lttng_probe_register(struct lttng_kernel_probe_desc *desc);
+void lttng_probe_unregister(struct lttng_kernel_probe_desc *desc);
+const struct lttng_kernel_event_desc *lttng_event_desc_get(const char *name);
+void lttng_event_desc_put(const struct lttng_kernel_event_desc *desc);
 int lttng_probes_init(void);
 void lttng_probes_exit(void);
 
@@ -891,7 +1041,7 @@ int lttng_session_list_tracker_ids(struct lttng_session *session,
 void lttng_clock_ref(void);
 void lttng_clock_unref(void);
 
-int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
+int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
                struct lttng_enabler *enabler);
 
 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
@@ -988,8 +1138,8 @@ int lttng_event_notifier_enabler_attach_capture_bytecode(
                struct lttng_event_notifier_enabler *event_notifier_enabler,
                struct lttng_kernel_capture_bytecode __user *bytecode);
 
-void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc,
-               struct lttng_ctx *ctx,
+void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_desc,
+               struct lttng_kernel_ctx *ctx,
                struct list_head *instance_bytecode_runtime_head,
                struct list_head *enabler_bytecode_runtime_head);
 void lttng_free_event_filter_runtime(struct lttng_event *event);
@@ -997,62 +1147,59 @@ void lttng_free_event_notifier_filter_runtime(struct lttng_event_notifier *event
 
 int lttng_probes_init(void);
 
-extern struct lttng_ctx *lttng_static_ctx;
+extern struct lttng_kernel_ctx *lttng_static_ctx;
 
 int lttng_context_init(void);
 void lttng_context_exit(void);
-struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
-ssize_t lttng_append_context_index(struct lttng_ctx **ctx_p);
-struct lttng_ctx_field *lttng_get_context_field_from_index(struct lttng_ctx *ctx,
+int lttng_kernel_context_append(struct lttng_kernel_ctx **ctx_p,
+               const struct lttng_kernel_ctx_field *f);
+void lttng_kernel_context_remove_last(struct lttng_kernel_ctx **ctx_p);
+struct lttng_kernel_ctx_field *lttng_kernel_get_context_field_from_index(struct lttng_kernel_ctx *ctx,
                size_t index);
-void lttng_context_update(struct lttng_ctx *ctx);
-int lttng_find_context(struct lttng_ctx *ctx, const char *name);
-int lttng_get_context_index(struct lttng_ctx *ctx, const char *name);
-void lttng_remove_context_field(struct lttng_ctx **ctx,
-                               struct lttng_ctx_field *field);
-void lttng_remove_context_field_index(struct lttng_ctx **ctx_p, size_t index);
-void lttng_destroy_context(struct lttng_ctx *ctx);
-int lttng_add_pid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_prio_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_nice_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_tid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_need_reschedule_to_ctx(struct lttng_ctx **ctx);
+int lttng_kernel_find_context(struct lttng_kernel_ctx *ctx, const char *name);
+int lttng_kernel_get_context_index(struct lttng_kernel_ctx *ctx, const char *name);
+void lttng_kernel_destroy_context(struct lttng_kernel_ctx *ctx);
+int lttng_add_pid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_cpu_id_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_procname_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_prio_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_nice_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_vpid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_tid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_vtid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_ppid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_vppid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_need_reschedule_to_ctx(struct lttng_kernel_ctx **ctx);
 #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
-int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx);
 #else
 static inline
-int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx)
 {
        return -ENOSYS;
 }
 #endif
 #ifdef CONFIG_PREEMPT_RT_FULL
-int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx);
 #else
 static inline
-int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx)
 {
        return -ENOSYS;
 }
 #endif
 
-int lttng_add_callstack_to_ctx(struct lttng_ctx **ctx, int type);
+int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx **ctx, int type);
 
 #if defined(CONFIG_CGROUPS) && \
        ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \
         LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0))
-int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx);
 #else
 static inline
-int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
        return -ENOSYS;
 }
@@ -1060,10 +1207,10 @@ int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx)
 
 #if defined(CONFIG_IPC_NS) && \
        (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
-int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx);
 #else
 static inline
-int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
        return -ENOSYS;
 }
@@ -1071,10 +1218,10 @@ int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx)
 
 #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
        (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
-int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx);
 #else
 static inline
-int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
        return -ENOSYS;
 }
@@ -1082,10 +1229,10 @@ int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx)
 
 #if defined(CONFIG_NET_NS) && \
        (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
-int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx);
 #else
 static inline
-int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
        return -ENOSYS;
 }
@@ -1093,10 +1240,10 @@ int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx)
 
 #if defined(CONFIG_PID_NS) && \
        (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
-int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx);
 #else
 static inline
-int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
        return -ENOSYS;
 }
@@ -1104,10 +1251,10 @@ int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx)
 
 #if defined(CONFIG_USER_NS) && \
        (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
-int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx);
 #else
 static inline
-int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
        return -ENOSYS;
 }
@@ -1115,10 +1262,10 @@ int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx)
 
 #if defined(CONFIG_UTS_NS) && \
        (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
-int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx);
 #else
 static inline
-int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
        return -ENOSYS;
 }
@@ -1126,33 +1273,33 @@ int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx)
 
 #if defined(CONFIG_TIME_NS) && \
        (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0))
-int lttng_add_time_ns_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx);
 #else
 static inline
-int lttng_add_time_ns_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
        return -ENOSYS;
 }
 #endif
 
-int lttng_add_uid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_euid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_suid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_gid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_egid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_sgid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx);
-int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_uid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_euid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_suid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_gid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_egid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_sgid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_vuid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_veuid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_vsuid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_vgid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_vegid_to_ctx(struct lttng_kernel_ctx **ctx);
+int lttng_add_vsgid_to_ctx(struct lttng_kernel_ctx **ctx);
 
 #if defined(CONFIG_PERF_EVENTS)
 int lttng_add_perf_counter_to_ctx(uint32_t type,
                                  uint64_t config,
                                  const char *name,
-                                 struct lttng_ctx **ctx);
+                                 struct lttng_kernel_ctx **ctx);
 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
                struct lttng_cpuhp_node *node);
 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
@@ -1162,7 +1309,7 @@ static inline
 int lttng_add_perf_counter_to_ctx(uint32_t type,
                                  uint64_t config,
                                  const char *name,
-                                 struct lttng_ctx **ctx)
+                                 struct lttng_kernel_ctx **ctx)
 {
        return -ENOSYS;
 }
@@ -1357,20 +1504,4 @@ extern const struct file_operations lttng_syscall_list_fops;
 
 #define TRACEPOINT_HAS_DATA_ARG
 
-static inline bool lttng_is_bytewise_integer(const struct lttng_type *type)
-{
-       if (type->type != lttng_kernel_type_integer)
-               return false;
-       switch (type->u.integer.size) {
-       case 8:         /* Fall-through. */
-       case 16:        /* Fall-through. */
-       case 32:        /* Fall-through. */
-       case 64:
-               break;
-       default:
-               return false;
-       }
-       return true;
-}
-
 #endif /* _LTTNG_EVENTS_H */
index ac4c738bf12efc4260b15cc11677acffaaeed1c5..b72d9a2a8c590197e515a90a4c7278d7cfc2b09a 100644 (file)
@@ -96,7 +96,7 @@ struct bytecode_get_index_data {
         * interpreter needs to find it from the event fields and types to
         * support variants.
         */
-       const struct lttng_event_field *field;
+       const struct lttng_kernel_event_field *field;
        struct {
                size_t len;
                enum object_type type;
@@ -108,7 +108,7 @@ struct bytecode_get_index_data {
 struct vstack_load {
        enum load_type type;
        enum object_type object_type;
-       const struct lttng_event_field *field;
+       const struct lttng_kernel_event_field *field;
        bool rev_bo;    /* reverse byte order */
 };
 
@@ -185,7 +185,7 @@ struct load_ptr {
                uint64_t u64;
                double d;
        } u;
-       const struct lttng_event_field *field;
+       const struct lttng_kernel_event_field *field;
 };
 
 struct estack_entry {
@@ -277,7 +277,7 @@ struct lttng_interpreter_output {
                        size_t nr_elem;
 
                        /* Inner type. */
-                       const struct lttng_type *nested_type;
+                       const struct lttng_kernel_type_common *nested_type;
                } sequence;
        } u;
 };
@@ -287,7 +287,7 @@ const char *lttng_bytecode_print_op(enum bytecode_op op);
 void lttng_bytecode_filter_sync_state(struct lttng_bytecode_runtime *runtime);
 void lttng_bytecode_capture_sync_state(struct lttng_bytecode_runtime *runtime);
 int lttng_bytecode_validate(struct bytecode_runtime *bytecode);
-int lttng_bytecode_specialize(const struct lttng_event_desc *event_desc,
+int lttng_bytecode_specialize(const struct lttng_kernel_event_desc *event_desc,
                struct bytecode_runtime *bytecode);
 
 uint64_t lttng_bytecode_filter_interpret_false(void *filter_data,
index f488586a3a851791e6f2a64d6380a54d91047d37..fd16f64179197b08027bb902b7b689f1c8c3f5f7 100644 (file)
@@ -217,54 +217,17 @@ void __event_notifier_template_proto___##_name(void);
 /* Enumeration entry (single value) */
 #undef ctf_enum_value
 #define ctf_enum_value(_string, _value)                                        \
-       {                                                               \
-               .start = {                                              \
-                       .signedness = lttng_is_signed_type(__typeof__(_value)), \
-                       .value = lttng_is_signed_type(__typeof__(_value)) ? \
-                               (long long) (_value) : (_value),        \
-               },                                                      \
-               .end = {                                                \
-                       .signedness = lttng_is_signed_type(__typeof__(_value)), \
-                       .value = lttng_is_signed_type(__typeof__(_value)) ? \
-                               (long long) (_value) : (_value),        \
-               },                                                      \
-               .string = (_string),                                    \
-       },
+       lttng_kernel_static_enum_entry_value(_string, _value)
 
 /* Enumeration entry (range) */
 #undef ctf_enum_range
 #define ctf_enum_range(_string, _range_start, _range_end)              \
-       {                                                               \
-               .start = {                                              \
-                       .signedness = lttng_is_signed_type(__typeof__(_range_start)), \
-                       .value = lttng_is_signed_type(__typeof__(_range_start)) ? \
-                               (long long) (_range_start) : (_range_start), \
-               },                                                      \
-               .end = {                                                \
-                       .signedness = lttng_is_signed_type(__typeof__(_range_end)), \
-                       .value = lttng_is_signed_type(__typeof__(_range_end)) ? \
-                               (long long) (_range_end) : (_range_end), \
-               },                                                      \
-               .string = (_string),                                    \
-       },
+       lttng_kernel_static_enum_entry_range(_string, _range_start, _range_end)
 
 /* Enumeration entry (automatic value; follows the rules of CTF) */
 #undef ctf_enum_auto
-#define ctf_enum_auto(_string)                                 \
-       {                                                               \
-               .start = {                                              \
-                       .signedness = -1,                               \
-                       .value = -1,                                    \
-               },                                                      \
-               .end = {                                                \
-                       .signedness = -1,                               \
-                       .value = -1,                                    \
-               },                                                      \
-               .string = (_string),                                    \
-               .options = {                                            \
-                       .is_auto = 1,                                   \
-               }                                                       \
-       },
+#define ctf_enum_auto(_string)                                         \
+       lttng_kernel_static_enum_entry_auto(_string)
 
 #undef TP_ENUM_VALUES
 #define TP_ENUM_VALUES(...)                                            \
@@ -272,7 +235,7 @@ void __event_notifier_template_proto___##_name(void);
 
 #undef LTTNG_TRACEPOINT_ENUM
 #define LTTNG_TRACEPOINT_ENUM(_name, _values)                          \
-       const struct lttng_kernel_enum_entry __enum_values__##_name[] = { \
+       static const struct lttng_kernel_enum_entry *__enum_values__##_name[] = { \
                _values                                                 \
        };
 
@@ -291,170 +254,77 @@ void __event_notifier_template_proto___##_name(void);
 #include <lttng/events-nowrite.h>
 
 #undef _ctf_integer_ext
-#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
-       {                                                       \
-         .name = #_item,                                       \
-         .type = __type_integer(_type, 0, 0, -1, _byte_order, _base, none), \
-         .nowrite = _nowrite,                                  \
-         .user = _user,                                        \
-         .nofilter = 0,                                        \
-       },
+#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite)      \
+       lttng_kernel_static_event_field(#_item,                                         \
+               lttng_kernel_static_type_integer_from_type(_type, _byte_order, _base),  \
+               _nowrite, _user, 0),
 
 #undef _ctf_array_encoded
 #define _ctf_array_encoded(_type, _item, _src, _length,                \
                _encoding, _byte_order, _elem_type_base, _user, _nowrite) \
-       {                                                       \
-         .name = #_item,                                       \
-         .type =                                               \
-               {                                               \
-                 .type = lttng_kernel_type_array_nestable,             \
-                 .u =                                          \
-                       {                                       \
-                         .array_nestable =                     \
-                               {                               \
-                                 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
-                                       __type_integer(_type, 0, 0, -1, _byte_order, _elem_type_base, _encoding)), \
-                                 .length = _length,            \
-                                 .alignment = 0,               \
-                               }                               \
-                       }                                       \
-               },                                              \
-         .nowrite = _nowrite,                                  \
-         .user = _user,                                        \
-         .nofilter = 0,                                        \
-       },
+       lttng_kernel_static_event_field(#_item,                 \
+               lttng_kernel_static_type_array(_length,         \
+                       lttng_kernel_static_type_integer_from_type(_type, _byte_order, _elem_type_base), \
+                       0,                                      \
+                       _encoding),                             \
+               _nowrite, _user, 0),
 
 #undef _ctf_array_bitfield
 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
-       {                                                       \
-         .name = #_item,                                       \
-         .type =                                               \
-               {                                               \
-                 .type = lttng_kernel_type_array_nestable,             \
-                 .u =                                          \
-                       {                                       \
-                         .array_nestable =                     \
-                               {                               \
-                                 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
-                                       __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none)), \
-                                 .length = (_length) * sizeof(_type) * CHAR_BIT, \
-                                 .alignment = lttng_alignof(_type), \
-                               }                               \
-                       }                                       \
-               },                                              \
-         .nowrite = _nowrite,                                  \
-         .user = _user,                                        \
-         .nofilter = 0,                                        \
-       },
-
+       lttng_kernel_static_event_field(#_item,                 \
+               lttng_kernel_static_type_array((_length) * sizeof(_type) * CHAR_BIT, \
+                       lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), \
+                       lttng_alignof(_type),                   \
+                       none),                                  \
+               _nowrite, _user, 0),
 
 #undef _ctf_sequence_encoded
 #define _ctf_sequence_encoded(_type, _item, _src,              \
                        _length_type, _src_length, _encoding,   \
                        _byte_order, _elem_type_base, _user, _nowrite) \
-       {                                                       \
-         .name = "_" #_item "_length",                         \
-         .type = __type_integer(_length_type, 0, 0, -1, __BYTE_ORDER, 10, none), \
-         .nowrite = _nowrite,                                  \
-         .nofilter = 1,                                        \
-       },                                                      \
-       {                                                       \
-         .name = #_item,                                       \
-         .type =                                               \
-               {                                               \
-                 .type = lttng_kernel_type_sequence_nestable,          \
-                 .u =                                          \
-                       {                                       \
-                         .sequence_nestable =                  \
-                               {                               \
-                                 .length_name = "_" #_item "_length", \
-                                 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
-                                       __type_integer(_type, 0, 0, -1, _byte_order, _elem_type_base, _encoding)), \
-                                 .alignment = 0,               \
-                               },                              \
-                       },                                      \
-               },                                              \
-         .nowrite = _nowrite,                                  \
-         .user = _user,                                        \
-         .nofilter = 0,                                        \
-       },
+       lttng_kernel_static_event_field("_" #_item "_length",   \
+               lttng_kernel_static_type_integer_from_type(_length_type, __BYTE_ORDER, 10), \
+               _nowrite, 0, 1),                                \
+       lttng_kernel_static_event_field(#_item,                 \
+               lttng_kernel_static_type_sequence("_" #_item "_length", \
+                       lttng_kernel_static_type_integer_from_type(_type, _byte_order, _elem_type_base), \
+                       0,                                      \
+                       _encoding),                             \
+               _nowrite, _user, 0),
 
 #undef _ctf_sequence_bitfield
 #define _ctf_sequence_bitfield(_type, _item, _src,             \
                        _length_type, _src_length,              \
                        _user, _nowrite)                        \
-       {                                                       \
-         .name = "_" #_item "_length",                         \
-         .type = __type_integer(_length_type, 0, 0, -1, __BYTE_ORDER, 10, none), \
-         .nowrite = _nowrite,                                  \
-         .nofilter = 1,                                        \
-       },                                                      \
-       {                                                       \
-         .name = #_item,                                       \
-         .type =                                               \
-               {                                               \
-                 .type = lttng_kernel_type_sequence_nestable,          \
-                 .u =                                          \
-                       {                                       \
-                         .sequence_nestable =                  \
-                               {                               \
-                                 .length_name = "_" #_item "_length", \
-                                 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
-                                       __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none)), \
-                                 .alignment = lttng_alignof(_type), \
-                               },                              \
-                       },                                      \
-               },                                              \
-         .nowrite = _nowrite,                                  \
-         .user = _user,                                        \
-         .nofilter = 0,                                        \
-       },
+       lttng_kernel_static_event_field("_" #_item "_length",   \
+               lttng_kernel_static_type_integer_from_type(_length_type, __BYTE_ORDER, 10), \
+               _nowrite, 0, 1),                                \
+       lttng_kernel_static_event_field(#_item,                 \
+               lttng_kernel_static_type_sequence("_" #_item "_length", \
+                       lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), \
+                       lttng_alignof(_type),                   \
+                       none),                                  \
+               _nowrite, _user, 0),
 
 #undef _ctf_string
 #define _ctf_string(_item, _src, _user, _nowrite)              \
-       {                                                       \
-         .name = #_item,                                       \
-         .type =                                               \
-               {                                               \
-                 .type = lttng_kernel_type_string,                     \
-                 .u =                                          \
-                       {                                       \
-                         .string = { .encoding = lttng_kernel_string_encoding_UTF8 }, \
-                       },                                      \
-               },                                              \
-         .nowrite = _nowrite,                                  \
-         .user = _user,                                        \
-         .nofilter = 0,                                        \
-       },
+       lttng_kernel_static_event_field(#_item,                 \
+               lttng_kernel_static_type_string(UTF8),          \
+               _nowrite, _user, 0),
+
+#undef _ctf_unused
+#define _ctf_unused(_src)
 
 #undef _ctf_enum
 #define _ctf_enum(_name, _type, _item, _src, _user, _nowrite)  \
-       {                                                       \
-               .name = #_item,                                 \
-               .type = {                                       \
-                       .type = lttng_kernel_type_enum_nestable,                \
-                       .u = {                                  \
-                               .enum_nestable = {              \
-                                       .desc = &__enum_##_name, \
-                                       .container_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
-                                               __type_integer(_type, 0, 0, -1, __BYTE_ORDER, 10, none)), \
-                               },                              \
-                       },                                      \
-               },                                              \
-               .nowrite = _nowrite,                            \
-               .user = _user,                                  \
-               .nofilter = 0,                                  \
-       },
+       lttng_kernel_static_event_field(#_item,                 \
+               lttng_kernel_static_type_enum(&__enum_##_name,  \
+                       lttng_kernel_static_type_integer_from_type(_type, __BYTE_ORDER, 10)), \
+               _nowrite, _user, 0),
 
 #undef ctf_custom_field
 #define ctf_custom_field(_type, _item, _code)                  \
-       {                                                       \
-               .name = #_item,                                 \
-               .type = _type,                                  \
-               .nowrite = 0,                                   \
-               .user = 0,                                      \
-               .nofilter = 1,                                  \
-       },
+       lttng_kernel_static_event_field(#_item, PARAMS(_type), 0, 0, 1),
 
 #undef ctf_custom_type
 #define ctf_custom_type(...)   __VA_ARGS__
@@ -464,7 +334,7 @@ void __event_notifier_template_proto___##_name(void);
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
-       static const struct lttng_event_field __event_fields___##_name[] = { \
+       static const struct lttng_kernel_event_field *__event_fields___##_name[] = { \
                _fields                                                      \
        };
 
@@ -480,7 +350,9 @@ void __event_notifier_template_proto___##_name(void);
                .nr_entries = ARRAY_SIZE(__enum_values__##_name),                       \
        };
 
+#define LTTNG_CREATE_FIELD_METADATA
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+#undef LTTNG_CREATE_FIELD_METADATA
 
 /*
  * Stage 3 of the trace events.
@@ -1544,14 +1416,14 @@ __post:                                                                       \
 
 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)     \
-static const struct lttng_event_desc __event_desc___##_map = {         \
+static const struct lttng_kernel_event_desc __event_desc___##_map = {  \
+       .event_name = #_map,                                            \
+       .event_kname = #_name,                                          \
+       .probe_callback = (void *) TP_PROBE_CB(_template),              \
        .fields = __event_fields___##_template,                         \
-       .name = #_map,                                                  \
-       .kname = #_name,                                                \
-       .probe_callback = (void *) TP_PROBE_CB(_template),              \
        .nr_fields = ARRAY_SIZE(__event_fields___##_template),          \
        .owner = THIS_MODULE,                                           \
-       .event_notifier_callback = (void *) TP_EVENT_NOTIFIER_PROBE_CB(_template),              \
+       .event_notifier_callback = (void *) TP_EVENT_NOTIFIER_PROBE_CB(_template),      \
 };
 
 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP
@@ -1579,7 +1451,7 @@ static const struct lttng_event_desc __event_desc___##_map = {            \
 #define TP_ID1(_token, _system)        _token##_system
 #define TP_ID(_token, _system) TP_ID1(_token, _system)
 
-static const struct lttng_event_desc *TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
+static const struct lttng_kernel_event_desc *TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 };
 
@@ -1596,8 +1468,8 @@ static const struct lttng_event_desc *TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
 #define TP_ID(_token, _system) TP_ID1(_token, _system)
 
 /* non-const because list head will be modified when registered. */
-static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = {
-       .provider = __stringify(TRACE_SYSTEM),
+static __used struct lttng_kernel_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = {
+       .provider_name = __stringify(TRACE_SYSTEM),
        .event_desc = TP_ID(__event_desc___, TRACE_SYSTEM),
        .nr_events = ARRAY_SIZE(TP_ID(__event_desc___, TRACE_SYSTEM)),
        .head = { NULL, NULL },
index e3896e8125b212fc5eab6754011aeea3261a08b6..616c1ddee1e0572f2669e2557bc2f2ee5b8a288f 100644 (file)
@@ -47,8 +47,9 @@ lttng-tracer-objs := lib/msgpack/msgpack.o \
                      lttng-context-vsgid.o \
                      lttng-context-interruptible.o \
                      lttng-context-need-reschedule.o \
-                     lttng-context-callstack.o lttng-calibrate.o \
+                     lttng-calibrate.o \
                      lttng-context-hostname.o \
+                    lttng-context-callstack.o \
                      probes/lttng.o \
                      lttng-tracker-id.o \
                      lttng-bytecode.o lttng-bytecode-interpreter.o \
index 5b6ef1f6e6d5de74514113b05a53678bf1cb071f..13d737d95679a57636d26f7b6e5c7bf2efa043b3 100644 (file)
@@ -258,7 +258,7 @@ void lttng_abi_tracer_abi_version(struct lttng_kernel_tracer_abi_version *v)
 static
 long lttng_abi_add_context(struct file *file,
        struct lttng_kernel_context *context_param,
-       struct lttng_ctx **ctx, struct lttng_session *session)
+       struct lttng_kernel_ctx **ctx, struct lttng_session *session)
 {
 
        if (session->been_active)
index fcbfe0b133a4d44410b33e957dc347347c8236e8..22c0ceb0d19ec9ad233437288b6c3deeccd019dd 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <lttng/lttng-bytecode.h>
 #include <lttng/string-utils.h>
+#include <lttng/events-internal.h>
 
 /*
  * get_char should be called with page fault handler disabled if it is expected
@@ -276,20 +277,20 @@ static int context_get_index(struct lttng_probe_ctx *lttng_probe_ctx,
                uint32_t idx)
 {
 
-       struct lttng_ctx_field *ctx_field;
-       struct lttng_event_field *field;
+       struct lttng_kernel_ctx_field *ctx_field;
+       const struct lttng_kernel_event_field *field;
        union lttng_ctx_value v;
 
        ctx_field = &lttng_static_ctx->fields[idx];
-       field = &ctx_field->event_field;
+       field = ctx_field->event_field;
        ptr->type = LOAD_OBJECT;
        /* field is only used for types nested within variants. */
        ptr->field = NULL;
 
-       switch (field->type.type) {
+       switch (field->type->type) {
        case lttng_kernel_type_integer:
                ctx_field->get_value(ctx_field, lttng_probe_ctx, &v);
-               if (field->type.u.integer.signedness) {
+               if (lttng_kernel_get_type_integer(field->type)->signedness) {
                        ptr->object_type = OBJECT_TYPE_S64;
                        ptr->u.s64 = v.s64;
                        ptr->ptr = &ptr->u.s64;
@@ -299,13 +300,13 @@ static int context_get_index(struct lttng_probe_ctx *lttng_probe_ctx,
                        ptr->ptr = &ptr->u.u64;
                }
                break;
-       case lttng_kernel_type_enum_nestable:
+       case lttng_kernel_type_enum:
        {
-               const struct lttng_integer_type *itype =
-                       &field->type.u.enum_nestable.container_type->u.integer;
+               const struct lttng_kernel_type_enum *enum_type = lttng_kernel_get_type_enum(field->type);
+               const struct lttng_kernel_type_integer *integer_type = lttng_kernel_get_type_integer(enum_type->container_type);
 
                ctx_field->get_value(ctx_field, lttng_probe_ctx, &v);
-               if (itype->signedness) {
+               if (integer_type->signedness) {
                        ptr->object_type = OBJECT_TYPE_SIGNED_ENUM;
                        ptr->u.s64 = v.s64;
                        ptr->ptr = &ptr->u.s64;
@@ -316,12 +317,15 @@ static int context_get_index(struct lttng_probe_ctx *lttng_probe_ctx,
                }
                break;
        }
-       case lttng_kernel_type_array_nestable:
-               if (!lttng_is_bytewise_integer(field->type.u.array_nestable.elem_type)) {
+       case lttng_kernel_type_array:
+       {
+               const struct lttng_kernel_type_array *array_type = lttng_kernel_get_type_array(field->type);
+
+               if (!lttng_kernel_type_is_bytewise_integer(array_type->elem_type)) {
                        printk(KERN_WARNING "LTTng: bytecode: Array nesting only supports integer types.\n");
                        return -EINVAL;
                }
-               if (field->type.u.array_nestable.elem_type->u.integer.encoding == lttng_kernel_string_encoding_none) {
+               if (array_type->encoding == lttng_kernel_string_encoding_none) {
                        printk(KERN_WARNING "LTTng: bytecode: Only string arrays are supported for contexts.\n");
                        return -EINVAL;
                }
@@ -329,12 +333,16 @@ static int context_get_index(struct lttng_probe_ctx *lttng_probe_ctx,
                ctx_field->get_value(ctx_field, lttng_probe_ctx, &v);
                ptr->ptr = v.str;
                break;
-       case lttng_kernel_type_sequence_nestable:
-               if (!lttng_is_bytewise_integer(field->type.u.sequence_nestable.elem_type)) {
+       }
+       case lttng_kernel_type_sequence:
+       {
+               const struct lttng_kernel_type_sequence *sequence_type = lttng_kernel_get_type_sequence(field->type);
+
+               if (!lttng_kernel_type_is_bytewise_integer(sequence_type->elem_type)) {
                        printk(KERN_WARNING "LTTng: bytecode: Sequence nesting only supports integer types.\n");
                        return -EINVAL;
                }
-               if (field->type.u.sequence_nestable.elem_type->u.integer.encoding == lttng_kernel_string_encoding_none) {
+               if (sequence_type->encoding == lttng_kernel_string_encoding_none) {
                        printk(KERN_WARNING "LTTng: bytecode: Only string sequences are supported for contexts.\n");
                        return -EINVAL;
                }
@@ -342,19 +350,20 @@ static int context_get_index(struct lttng_probe_ctx *lttng_probe_ctx,
                ctx_field->get_value(ctx_field, lttng_probe_ctx, &v);
                ptr->ptr = v.str;
                break;
+       }
        case lttng_kernel_type_string:
                ptr->object_type = OBJECT_TYPE_STRING;
                ctx_field->get_value(ctx_field, lttng_probe_ctx, &v);
                ptr->ptr = v.str;
                break;
-       case lttng_kernel_type_struct_nestable:
+       case lttng_kernel_type_struct:
                printk(KERN_WARNING "LTTng: bytecode: Structure type cannot be loaded.\n");
                return -EINVAL;
-       case lttng_kernel_type_variant_nestable:
+       case lttng_kernel_type_variant:
                printk(KERN_WARNING "LTTng: bytecode: Variant type cannot be loaded.\n");
                return -EINVAL;
        default:
-               printk(KERN_WARNING "LTTng: bytecode: Unknown type: %d", (int) field->type.type);
+               printk(KERN_WARNING "LTTng: bytecode: Unknown type: %d", (int) field->type->type);
                return -EINVAL;
        }
        return 0;
@@ -382,7 +391,7 @@ static int dynamic_get_index(struct lttng_probe_ctx *lttng_probe_ctx,
                        stack_top->u.ptr.ptr = ptr;
                        stack_top->u.ptr.object_type = gid->elem.type;
                        stack_top->u.ptr.rev_bo = gid->elem.rev_bo;
-                       BUG_ON(stack_top->u.ptr.field->type.type != lttng_kernel_type_array_nestable);
+                       BUG_ON(stack_top->u.ptr.field->type->type != lttng_kernel_type_array);
                        stack_top->u.ptr.field = NULL;
                        break;
                }
@@ -401,7 +410,7 @@ static int dynamic_get_index(struct lttng_probe_ctx *lttng_probe_ctx,
                        stack_top->u.ptr.ptr = ptr;
                        stack_top->u.ptr.object_type = gid->elem.type;
                        stack_top->u.ptr.rev_bo = gid->elem.rev_bo;
-                       BUG_ON(stack_top->u.ptr.field->type.type != lttng_kernel_type_sequence_nestable);
+                       BUG_ON(stack_top->u.ptr.field->type->type != lttng_kernel_type_sequence);
                        stack_top->u.ptr.field = NULL;
                        break;
                }
@@ -672,14 +681,14 @@ again:
                        output->type = LTTNG_INTERPRETER_TYPE_SEQUENCE;
                        output->u.sequence.ptr = *(const char **) (ax->u.ptr.ptr + sizeof(unsigned long));
                        output->u.sequence.nr_elem = *(unsigned long *) ax->u.ptr.ptr;
-                       output->u.sequence.nested_type = ax->u.ptr.field->type.u.sequence_nestable.elem_type;
+                       output->u.sequence.nested_type = lttng_kernel_get_type_sequence(ax->u.ptr.field->type)->elem_type;
                        break;
                case OBJECT_TYPE_ARRAY:
                        /* Skip count (unsigned long) */
                        output->type = LTTNG_INTERPRETER_TYPE_SEQUENCE;
                        output->u.sequence.ptr = *(const char **) (ax->u.ptr.ptr + sizeof(unsigned long));
-                       output->u.sequence.nr_elem = ax->u.ptr.field->type.u.array_nestable.length;
-                       output->u.sequence.nested_type = ax->u.ptr.field->type.u.array_nestable.elem_type;
+                       output->u.sequence.nr_elem = lttng_kernel_get_type_array(ax->u.ptr.field->type)->length;
+                       output->u.sequence.nested_type = lttng_kernel_get_type_array(ax->u.ptr.field->type)->elem_type;
                        break;
                case OBJECT_TYPE_SIGNED_ENUM:
                        ret = dynamic_load_field(ax);
@@ -1476,7 +1485,7 @@ uint64_t bytecode_interpret(void *interpreter_data,
                {
                        struct load_op *insn = (struct load_op *) pc;
                        struct field_ref *ref = (struct field_ref *) insn->data;
-                       struct lttng_ctx_field *ctx_field;
+                       struct lttng_kernel_ctx_field *ctx_field;
                        union lttng_ctx_value v;
 
                        dbg_printk("get context ref offset %u type string\n",
@@ -1504,7 +1513,7 @@ uint64_t bytecode_interpret(void *interpreter_data,
                {
                        struct load_op *insn = (struct load_op *) pc;
                        struct field_ref *ref = (struct field_ref *) insn->data;
-                       struct lttng_ctx_field *ctx_field;
+                       struct lttng_kernel_ctx_field *ctx_field;
                        union lttng_ctx_value v;
 
                        dbg_printk("get context ref offset %u type s64\n",
index 091879eae9cbdc15cf9905500863d2968fe52aed..5c57754893ecc6e80e0e1c488aa728782f08780a 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/slab.h>
 #include <lttng/lttng-bytecode.h>
 #include <lttng/align.h>
+#include <lttng/events-internal.h>
 
 static ssize_t bytecode_reserve_data(struct bytecode_runtime *runtime,
                size_t align, size_t len)
@@ -206,18 +207,20 @@ static int specialize_get_index(struct bytecode_runtime *runtime,
                switch (stack_top->load.object_type) {
                case OBJECT_TYPE_ARRAY:
                {
-                       const struct lttng_integer_type *integer_type;
-                       const struct lttng_event_field *field;
+                       const struct lttng_kernel_event_field *field;
+                       const struct lttng_kernel_type_array *array_type;
+                       const struct lttng_kernel_type_integer *integer_type;
                        uint32_t elem_len, num_elems;
                        int signedness;
 
                        field = stack_top->load.field;
-                       if (!lttng_is_bytewise_integer(field->type.u.array_nestable.elem_type)) {
+                       array_type = lttng_kernel_get_type_array(field->type);
+                       if (!lttng_kernel_type_is_bytewise_integer(array_type->elem_type)) {
                                ret = -EINVAL;
                                goto end;
                        }
-                       integer_type = &field->type.u.array_nestable.elem_type->u.integer;
-                       num_elems = field->type.u.array_nestable.length;
+                       integer_type = lttng_kernel_get_type_integer(array_type->elem_type);
+                       num_elems = array_type->length;
                        elem_len = integer_type->size;
                        signedness = integer_type->signedness;
                        if (index >= num_elems) {
@@ -239,17 +242,19 @@ static int specialize_get_index(struct bytecode_runtime *runtime,
                }
                case OBJECT_TYPE_SEQUENCE:
                {
-                       const struct lttng_integer_type *integer_type;
-                       const struct lttng_event_field *field;
+                       const struct lttng_kernel_event_field *field;
+                       const struct lttng_kernel_type_sequence *sequence_type;
+                       const struct lttng_kernel_type_integer *integer_type;
                        uint32_t elem_len;
                        int signedness;
 
                        field = stack_top->load.field;
-                       if (!lttng_is_bytewise_integer(field->type.u.sequence_nestable.elem_type)) {
+                       sequence_type = lttng_kernel_get_type_sequence(field->type);
+                       if (!lttng_kernel_type_is_bytewise_integer(sequence_type->elem_type)) {
                                ret = -EINVAL;
                                goto end;
                        }
-                       integer_type = &field->type.u.sequence_nestable.elem_type->u.integer;
+                       integer_type = lttng_kernel_get_type_integer(sequence_type->elem_type);
                        elem_len = integer_type->size;
                        signedness = integer_type->signedness;
                        ret = specialize_get_index_object_type(&stack_top->load.object_type,
@@ -305,7 +310,7 @@ end:
        return ret;
 }
 
-static int specialize_context_lookup_name(struct lttng_ctx *ctx,
+static int specialize_context_lookup_name(struct lttng_kernel_ctx *ctx,
                struct bytecode_runtime *bytecode,
                struct load_op *insn)
 {
@@ -314,43 +319,46 @@ static int specialize_context_lookup_name(struct lttng_ctx *ctx,
 
        offset = ((struct get_symbol *) insn->data)->offset;
        name = bytecode->p.bc->bc.data + bytecode->p.bc->bc.reloc_offset + offset;
-       return lttng_get_context_index(ctx, name);
+       return lttng_kernel_get_context_index(ctx, name);
 }
 
-static int specialize_load_object(const struct lttng_event_field *field,
+static int specialize_load_object(const struct lttng_kernel_event_field *field,
                struct vstack_load *load, bool is_context)
 {
        load->type = LOAD_OBJECT;
 
-       switch (field->type.type) {
+       switch (field->type->type) {
        case lttng_kernel_type_integer:
-               if (field->type.u.integer.signedness)
+               if (lttng_kernel_get_type_integer(field->type)->signedness)
                        load->object_type = OBJECT_TYPE_S64;
                else
                        load->object_type = OBJECT_TYPE_U64;
                load->rev_bo = false;
                break;
-       case lttng_kernel_type_enum_nestable:
+       case lttng_kernel_type_enum:
        {
-               const struct lttng_integer_type *itype =
-                       &field->type.u.enum_nestable.container_type->u.integer;
+               const struct lttng_kernel_type_enum *enum_type = lttng_kernel_get_type_enum(field->type);
+               const struct lttng_kernel_type_integer *integer_type = lttng_kernel_get_type_integer(enum_type->container_type);
 
-               if (itype->signedness)
+               if (integer_type->signedness)
                        load->object_type = OBJECT_TYPE_SIGNED_ENUM;
                else
                        load->object_type = OBJECT_TYPE_UNSIGNED_ENUM;
                load->rev_bo = false;
                break;
        }
-       case lttng_kernel_type_array_nestable:
-               if (!lttng_is_bytewise_integer(field->type.u.array_nestable.elem_type)) {
+       case lttng_kernel_type_array:
+       {
+               const struct lttng_kernel_type_array *array_type = lttng_kernel_get_type_array(field->type);
+
+               if (!lttng_kernel_type_is_bytewise_integer(array_type->elem_type)) {
                        printk(KERN_WARNING "LTTng: bytecode: Array nesting only supports integer types.\n");
                        return -EINVAL;
                }
                if (is_context) {
                        load->object_type = OBJECT_TYPE_STRING;
                } else {
-                       if (field->type.u.array_nestable.elem_type->u.integer.encoding == lttng_kernel_string_encoding_none) {
+                       if (array_type->encoding == lttng_kernel_string_encoding_none) {
                                load->object_type = OBJECT_TYPE_ARRAY;
                                load->field = field;
                        } else {
@@ -358,15 +366,19 @@ static int specialize_load_object(const struct lttng_event_field *field,
                        }
                }
                break;
-       case lttng_kernel_type_sequence_nestable:
-               if (!lttng_is_bytewise_integer(field->type.u.sequence_nestable.elem_type)) {
+       }
+       case lttng_kernel_type_sequence:
+       {
+               const struct lttng_kernel_type_sequence *sequence_type = lttng_kernel_get_type_sequence(field->type);
+
+               if (!lttng_kernel_type_is_bytewise_integer(sequence_type->elem_type)) {
                        printk(KERN_WARNING "LTTng: bytecode: Sequence nesting only supports integer types.\n");
                        return -EINVAL;
                }
                if (is_context) {
                        load->object_type = OBJECT_TYPE_STRING;
                } else {
-                       if (field->type.u.sequence_nestable.elem_type->u.integer.encoding == lttng_kernel_string_encoding_none) {
+                       if (sequence_type->encoding == lttng_kernel_string_encoding_none) {
                                load->object_type = OBJECT_TYPE_SEQUENCE;
                                load->field = field;
                        } else {
@@ -374,30 +386,31 @@ static int specialize_load_object(const struct lttng_event_field *field,
                        }
                }
                break;
+       }
        case lttng_kernel_type_string:
                load->object_type = OBJECT_TYPE_STRING;
                break;
-       case lttng_kernel_type_struct_nestable:
+       case lttng_kernel_type_struct:
                printk(KERN_WARNING "LTTng: bytecode: Structure type cannot be loaded.\n");
                return -EINVAL;
-       case lttng_kernel_type_variant_nestable:
+       case lttng_kernel_type_variant:
                printk(KERN_WARNING "LTTng: bytecode: Variant type cannot be loaded.\n");
                return -EINVAL;
        default:
-               printk(KERN_WARNING "LTTng: bytecode: Unknown type: %d", (int) field->type.type);
+               printk(KERN_WARNING "LTTng: bytecode: Unknown type: %d", (int) field->type->type);
                return -EINVAL;
        }
        return 0;
 }
 
-static int specialize_context_lookup(struct lttng_ctx *ctx,
+static int specialize_context_lookup(struct lttng_kernel_ctx *ctx,
                struct bytecode_runtime *runtime,
                struct load_op *insn,
                struct vstack_load *load)
 {
        int idx, ret;
-       struct lttng_ctx_field *ctx_field;
-       struct lttng_event_field *field;
+       const struct lttng_kernel_ctx_field *ctx_field;
+       const struct lttng_kernel_event_field *field;
        struct bytecode_get_index_data gid;
        ssize_t data_offset;
 
@@ -406,7 +419,7 @@ static int specialize_context_lookup(struct lttng_ctx *ctx,
                return -ENOENT;
        }
        ctx_field = &lttng_static_ctx->fields[idx];
-       field = &ctx_field->event_field;
+       field = ctx_field->event_field;
        ret = specialize_load_object(field, load, true);
        if (ret)
                return ret;
@@ -426,7 +439,7 @@ static int specialize_context_lookup(struct lttng_ctx *ctx,
        return 0;
 }
 
-static int specialize_payload_lookup(const struct lttng_event_desc *event_desc,
+static int specialize_payload_lookup(const struct lttng_kernel_event_desc *event_desc,
                struct bytecode_runtime *runtime,
                struct load_op *insn,
                struct vstack_load *load)
@@ -436,7 +449,7 @@ static int specialize_payload_lookup(const struct lttng_event_desc *event_desc,
        unsigned int i, nr_fields;
        bool found = false;
        uint32_t field_offset = 0;
-       const struct lttng_event_field *field;
+       const struct lttng_kernel_event_field *field;
        int ret;
        struct bytecode_get_index_data gid;
        ssize_t data_offset;
@@ -445,7 +458,7 @@ static int specialize_payload_lookup(const struct lttng_event_desc *event_desc,
        offset = ((struct get_symbol *) insn->data)->offset;
        name = runtime->p.bc->bc.data + runtime->p.bc->bc.reloc_offset + offset;
        for (i = 0; i < nr_fields; i++) {
-               field = &event_desc->fields[i];
+               field = event_desc->fields[i];
                if (field->nofilter) {
                        continue;
                }
@@ -454,13 +467,13 @@ static int specialize_payload_lookup(const struct lttng_event_desc *event_desc,
                        break;
                }
                /* compute field offset on stack */
-               switch (field->type.type) {
+               switch (field->type->type) {
                case lttng_kernel_type_integer:
-               case lttng_kernel_type_enum_nestable:
+               case lttng_kernel_type_enum:
                        field_offset += sizeof(int64_t);
                        break;
-               case lttng_kernel_type_array_nestable:
-               case lttng_kernel_type_sequence_nestable:
+               case lttng_kernel_type_array:
+               case lttng_kernel_type_sequence:
                        field_offset += sizeof(unsigned long);
                        field_offset += sizeof(void *);
                        break;
@@ -500,14 +513,14 @@ end:
        return ret;
 }
 
-int lttng_bytecode_specialize(const struct lttng_event_desc *event_desc,
+int lttng_bytecode_specialize(const struct lttng_kernel_event_desc *event_desc,
                struct bytecode_runtime *bytecode)
 {
        void *pc, *next_pc, *start_pc;
        int ret = -EINVAL;
        struct vstack _stack;
        struct vstack *stack = &_stack;
-       struct lttng_ctx *ctx = bytecode->p.ctx;
+       struct lttng_kernel_ctx *ctx = bytecode->p.ctx;
 
        vstack_init(stack);
 
index 3e9b3e53745e07fadd5fdfa8845d0523f74091d1..6ed20f7ea054bb13e86d0816046fe860a13608b4 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 
 #include <lttng/lttng-bytecode.h>
+#include <lttng/events-internal.h>
 
 static const char *opnames[] = {
        [ BYTECODE_OP_UNKNOWN ] = "UNKNOWN",
@@ -167,14 +168,14 @@ const char *lttng_bytecode_print_op(enum bytecode_op op)
 }
 
 static
-int apply_field_reloc(const struct lttng_event_desc *event_desc,
+int apply_field_reloc(const struct lttng_kernel_event_desc *event_desc,
                struct bytecode_runtime *runtime,
                uint32_t runtime_len,
                uint32_t reloc_offset,
                const char *field_name,
                enum bytecode_op bytecode_op)
 {
-       const struct lttng_event_field *fields, *field = NULL;
+       const struct lttng_kernel_event_field **fields, *field = NULL;
        unsigned int nr_fields, i;
        struct load_op *op;
        uint32_t field_offset = 0;
@@ -189,26 +190,26 @@ int apply_field_reloc(const struct lttng_event_desc *event_desc,
                return -EINVAL;
        nr_fields = event_desc->nr_fields;
        for (i = 0; i < nr_fields; i++) {
-               if (fields[i].nofilter)
+               if (fields[i]->nofilter)
                        continue;
-               if (!strcmp(fields[i].name, field_name)) {
-                       field = &fields[i];
+               if (!strcmp(fields[i]->name, field_name)) {
+                       field = fields[i];
                        break;
                }
                /* compute field offset */
-               switch (fields[i].type.type) {
+               switch (fields[i]->type->type) {
                case lttng_kernel_type_integer:
-               case lttng_kernel_type_enum_nestable:
+               case lttng_kernel_type_enum:
                        field_offset += sizeof(int64_t);
                        break;
-               case lttng_kernel_type_array_nestable:
-                       if (!lttng_is_bytewise_integer(fields[i].type.u.array_nestable.elem_type))
+               case lttng_kernel_type_array:
+                       if (!lttng_kernel_type_is_bytewise_integer(lttng_kernel_get_type_array(fields[i]->type)->elem_type))
                                return -EINVAL;
                        field_offset += sizeof(unsigned long);
                        field_offset += sizeof(void *);
                        break;
-               case lttng_kernel_type_sequence_nestable:
-                       if (!lttng_is_bytewise_integer(fields[i].type.u.sequence_nestable.elem_type))
+               case lttng_kernel_type_sequence:
+                       if (!lttng_kernel_type_is_bytewise_integer(lttng_kernel_get_type_sequence(fields[i]->type)->elem_type))
                                return -EINVAL;
                        field_offset += sizeof(unsigned long);
                        field_offset += sizeof(void *);
@@ -216,8 +217,8 @@ int apply_field_reloc(const struct lttng_event_desc *event_desc,
                case lttng_kernel_type_string:
                        field_offset += sizeof(void *);
                        break;
-               case lttng_kernel_type_struct_nestable: /* Unsupported. */
-               case lttng_kernel_type_variant_nestable:        /* Unsupported. */
+               case lttng_kernel_type_struct /* Unsupported. */
+               case lttng_kernel_type_variant: /* Unsupported. */
                default:
                        return -EINVAL;
                }
@@ -238,16 +239,17 @@ int apply_field_reloc(const struct lttng_event_desc *event_desc,
                struct field_ref *field_ref;
 
                field_ref = (struct field_ref *) op->data;
-               switch (field->type.type) {
+               switch (field->type->type) {
                case lttng_kernel_type_integer:
-               case lttng_kernel_type_enum_nestable:
+               case lttng_kernel_type_enum:
                        op->op = BYTECODE_OP_LOAD_FIELD_REF_S64;
                        break;
-               case lttng_kernel_type_array_nestable:
+               case lttng_kernel_type_array:
                {
-                       const struct lttng_type *elem_type = field->type.u.array_nestable.elem_type;
+                       const struct lttng_kernel_type_array *array_type = lttng_kernel_get_type_array(field->type);
+                       const struct lttng_kernel_type_common *elem_type = array_type->elem_type;
 
-                       if (!lttng_is_bytewise_integer(elem_type) || elem_type->u.integer.encoding == lttng_kernel_string_encoding_none)
+                       if (!lttng_kernel_type_is_bytewise_integer(elem_type) || array_type->encoding == lttng_kernel_string_encoding_none)
                                return -EINVAL;
                        if (field->user)
                                op->op = BYTECODE_OP_LOAD_FIELD_REF_USER_SEQUENCE;
@@ -255,11 +257,12 @@ int apply_field_reloc(const struct lttng_event_desc *event_desc,
                                op->op = BYTECODE_OP_LOAD_FIELD_REF_SEQUENCE;
                        break;
                }
-               case lttng_kernel_type_sequence_nestable:
+               case lttng_kernel_type_sequence:
                {
-                       const struct lttng_type *elem_type = field->type.u.sequence_nestable.elem_type;
+                       const struct lttng_kernel_type_sequence *sequence_type = lttng_kernel_get_type_sequence(field->type);
+                       const struct lttng_kernel_type_common *elem_type = sequence_type->elem_type;
 
-                       if (!lttng_is_bytewise_integer(elem_type) || elem_type->u.integer.encoding == lttng_kernel_string_encoding_none)
+                       if (!lttng_kernel_type_is_bytewise_integer(elem_type) || sequence_type->encoding == lttng_kernel_string_encoding_none)
                                return -EINVAL;
                        if (field->user)
                                op->op = BYTECODE_OP_LOAD_FIELD_REF_USER_SEQUENCE;
@@ -273,8 +276,8 @@ int apply_field_reloc(const struct lttng_event_desc *event_desc,
                        else
                                op->op = BYTECODE_OP_LOAD_FIELD_REF_STRING;
                        break;
-               case lttng_kernel_type_struct_nestable: /* Unsupported. */
-               case lttng_kernel_type_variant_nestable:        /* Unsupported. */
+               case lttng_kernel_type_struct /* Unsupported. */
+               case lttng_kernel_type_variant: /* Unsupported. */
                default:
                        return -EINVAL;
                }
@@ -296,13 +299,13 @@ int apply_context_reloc(struct bytecode_runtime *runtime,
                enum bytecode_op bytecode_op)
 {
        struct load_op *op;
-       struct lttng_ctx_field *ctx_field;
+       struct lttng_kernel_ctx_field *ctx_field;
        int idx;
 
        dbg_printk("Apply context reloc: %u %s\n", reloc_offset, context_name);
 
        /* Get context index */
-       idx = lttng_get_context_index(lttng_static_ctx, context_name);
+       idx = lttng_kernel_get_context_index(lttng_static_ctx, context_name);
        if (idx < 0)
                return -ENOENT;
 
@@ -320,38 +323,40 @@ int apply_context_reloc(struct bytecode_runtime *runtime,
                struct field_ref *field_ref;
 
                field_ref = (struct field_ref *) op->data;
-               switch (ctx_field->event_field.type.type) {
+               switch (ctx_field->event_field->type->type) {
                case lttng_kernel_type_integer:
-               case lttng_kernel_type_enum_nestable:
+               case lttng_kernel_type_enum:
                        op->op = BYTECODE_OP_GET_CONTEXT_REF_S64;
                        break;
                        /* Sequence and array supported as string */
                case lttng_kernel_type_string:
-                       BUG_ON(ctx_field->event_field.user);
+                       BUG_ON(ctx_field->event_field->user);
                        op->op = BYTECODE_OP_GET_CONTEXT_REF_STRING;
                        break;
-               case lttng_kernel_type_array_nestable:
+               case lttng_kernel_type_array:
                {
-                       const struct lttng_type *elem_type = ctx_field->event_field.type.u.array_nestable.elem_type;
+                       const struct lttng_kernel_type_array *array_type = lttng_kernel_get_type_array(ctx_field->event_field->type);
+                       const struct lttng_kernel_type_common *elem_type = array_type->elem_type;
 
-                       if (!lttng_is_bytewise_integer(elem_type) || elem_type->u.integer.encoding == lttng_kernel_string_encoding_none)
+                       if (!lttng_kernel_type_is_bytewise_integer(elem_type) || array_type->encoding == lttng_kernel_string_encoding_none)
                                return -EINVAL;
-                       BUG_ON(ctx_field->event_field.user);
+                       BUG_ON(ctx_field->event_field->user);
                        op->op = BYTECODE_OP_GET_CONTEXT_REF_STRING;
                        break;
                }
-               case lttng_kernel_type_sequence_nestable:
+               case lttng_kernel_type_sequence:
                {
-                       const struct lttng_type *elem_type = ctx_field->event_field.type.u.sequence_nestable.elem_type;
+                       const struct lttng_kernel_type_sequence *sequence_type = lttng_kernel_get_type_sequence(ctx_field->event_field->type);
+                       const struct lttng_kernel_type_common *elem_type = sequence_type->elem_type;
 
-                       if (!lttng_is_bytewise_integer(elem_type) || elem_type->u.integer.encoding == lttng_kernel_string_encoding_none)
+                       if (!lttng_kernel_type_is_bytewise_integer(elem_type) || sequence_type->encoding == lttng_kernel_string_encoding_none)
                                return -EINVAL;
-                       BUG_ON(ctx_field->event_field.user);
+                       BUG_ON(ctx_field->event_field->user);
                        op->op = BYTECODE_OP_GET_CONTEXT_REF_STRING;
                        break;
                }
-               case lttng_kernel_type_struct_nestable: /* Unsupported. */
-               case lttng_kernel_type_variant_nestable:        /* Unsupported. */
+               case lttng_kernel_type_struct /* Unsupported. */
+               case lttng_kernel_type_variant: /* Unsupported. */
                default:
                        return -EINVAL;
                }
@@ -366,7 +371,7 @@ int apply_context_reloc(struct bytecode_runtime *runtime,
 }
 
 static
-int apply_reloc(const struct lttng_event_desc *event_desc,
+int apply_reloc(const struct lttng_kernel_event_desc *event_desc,
                struct bytecode_runtime *runtime,
                uint32_t runtime_len,
                uint32_t reloc_offset,
@@ -420,8 +425,8 @@ int bytecode_is_linked(struct lttng_bytecode_node *bytecode,
  * bytecode runtime.
  */
 static
-int link_bytecode(const struct lttng_event_desc *event_desc,
-               struct lttng_ctx *ctx,
+int link_bytecode(const struct lttng_kernel_event_desc *event_desc,
+               struct lttng_kernel_ctx *ctx,
                struct lttng_bytecode_node *bytecode,
                struct list_head *bytecode_runtime_head,
                struct list_head *insert_loc)
@@ -542,8 +547,8 @@ void lttng_bytecode_capture_sync_state(struct lttng_bytecode_runtime *runtime)
  * This function is called after we confirmed that name enabler and the
  * instance are matching names (or glob pattern matching).
  */
-void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc,
-               struct lttng_ctx *ctx,
+void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_desc,
+               struct lttng_kernel_ctx *ctx,
                struct list_head *instance_bytecode_head,
                struct list_head *enabler_bytecode_head)
 {
index 8d78fb95700891b0a2f2dc622b6c36b2b5f3fce6..b74b966a21b7c3e74663fdff6b60b827aff7ce67 100644 (file)
@@ -56,18 +56,6 @@ static struct lttng_cs_type cs_types[] = {
        },
 };
 
-static
-const char *lttng_cs_ctx_mode_name(enum lttng_cs_ctx_modes mode)
-{
-       return cs_types[mode].name;
-}
-
-static
-const char *lttng_cs_ctx_mode_length_name(enum lttng_cs_ctx_modes mode)
-{
-       return cs_types[mode].length_name;
-}
-
 static
 int init_type(enum lttng_cs_ctx_modes mode)
 {
@@ -108,7 +96,7 @@ void lttng_cs_set_init(struct lttng_cs __percpu *cs_set)
 DEFINE_PER_CPU(int, callstack_user_nesting);
 
 static
-struct stack_trace *stack_trace_context(struct lttng_ctx_field *field,
+struct stack_trace *stack_trace_context(struct lttng_kernel_ctx_field *field,
                                        struct lib_ring_buffer_ctx *ctx)
 {
        int buffer_nesting, cs_user_nesting;
@@ -140,7 +128,7 @@ struct stack_trace *stack_trace_context(struct lttng_ctx_field *field,
 }
 
 static
-size_t lttng_callstack_length_get_size(size_t offset, struct lttng_ctx_field *field,
+size_t lttng_callstack_length_get_size(size_t offset, struct lttng_kernel_ctx_field *field,
                                struct lib_ring_buffer_ctx *ctx,
                                struct lttng_channel *chan)
 {
@@ -156,7 +144,7 @@ size_t lttng_callstack_length_get_size(size_t offset, struct lttng_ctx_field *fi
  * resulting callstack is saved to be accessed in the record step.
  */
 static
-size_t lttng_callstack_sequence_get_size(size_t offset, struct lttng_ctx_field *field,
+size_t lttng_callstack_sequence_get_size(size_t offset, struct lttng_kernel_ctx_field *field,
                                        struct lib_ring_buffer_ctx *ctx,
                                        struct lttng_channel *chan)
 {
@@ -201,7 +189,7 @@ size_t lttng_callstack_sequence_get_size(size_t offset, struct lttng_ctx_field *
 }
 
 static
-void lttng_callstack_length_record(struct lttng_ctx_field *field,
+void lttng_callstack_length_record(struct lttng_kernel_ctx_field *field,
                        struct lib_ring_buffer_ctx *ctx,
                        struct lttng_channel *chan)
 {
@@ -219,7 +207,7 @@ void lttng_callstack_length_record(struct lttng_ctx_field *field,
        chan->ops->event_write(ctx, &nr_seq_entries, sizeof(unsigned int));
 }
 static
-void lttng_callstack_sequence_record(struct lttng_ctx_field *field,
+void lttng_callstack_sequence_record(struct lttng_kernel_ctx_field *field,
                        struct lib_ring_buffer_ctx *ctx,
                        struct lttng_channel *chan)
 {
index 42f4273d8abae4f1f63069e443228f56b385b472..7c452491ea46458f7f524c2f189904266f392728 100644 (file)
@@ -40,32 +40,6 @@ unsigned int (*save_func_kernel)(unsigned long *store, unsigned int size,
 static
 unsigned int (*save_func_user)(unsigned long *store, unsigned int size);
 
-static
-const char *lttng_cs_ctx_mode_name(enum lttng_cs_ctx_modes mode)
-{
-       switch (mode) {
-       case CALLSTACK_KERNEL:
-               return "callstack_kernel";
-       case CALLSTACK_USER:
-               return "callstack_user";
-       default:
-               return NULL;
-       }
-}
-
-static
-const char *lttng_cs_ctx_mode_length_name(enum lttng_cs_ctx_modes mode)
-{
-       switch (mode) {
-       case CALLSTACK_KERNEL:
-               return "_callstack_kernel_length";
-       case CALLSTACK_USER:
-               return "_callstack_user_length";
-       default:
-               return NULL;
-       }
-}
-
 static
 int init_type_callstack_kernel(void)
 {
@@ -124,7 +98,7 @@ void lttng_cs_set_init(struct lttng_cs __percpu *cs_set)
 DEFINE_PER_CPU(int, callstack_user_nesting);
 
 static
-struct lttng_stack_trace *stack_trace_context(struct lttng_ctx_field *field,
+struct lttng_stack_trace *stack_trace_context(struct lttng_kernel_ctx_field *field,
                                        struct lib_ring_buffer_ctx *ctx)
 {
        int buffer_nesting, cs_user_nesting;
@@ -156,7 +130,7 @@ struct lttng_stack_trace *stack_trace_context(struct lttng_ctx_field *field,
 }
 
 static
-size_t lttng_callstack_length_get_size(size_t offset, struct lttng_ctx_field *field,
+size_t lttng_callstack_length_get_size(size_t offset, struct lttng_kernel_ctx_field *field,
                                struct lib_ring_buffer_ctx *ctx,
                                struct lttng_channel *chan)
 {
@@ -172,7 +146,7 @@ size_t lttng_callstack_length_get_size(size_t offset, struct lttng_ctx_field *fi
  * resulting callstack is saved to be accessed in the record step.
  */
 static
-size_t lttng_callstack_sequence_get_size(size_t offset, struct lttng_ctx_field *field,
+size_t lttng_callstack_sequence_get_size(size_t offset, struct lttng_kernel_ctx_field *field,
                                        struct lib_ring_buffer_ctx *ctx,
                                        struct lttng_channel *chan)
 {
@@ -220,7 +194,7 @@ size_t lttng_callstack_sequence_get_size(size_t offset, struct lttng_ctx_field *
 }
 
 static
-void lttng_callstack_length_record(struct lttng_ctx_field *field,
+void lttng_callstack_length_record(struct lttng_kernel_ctx_field *field,
                        struct lib_ring_buffer_ctx *ctx,
                        struct lttng_channel *chan)
 {
@@ -239,7 +213,7 @@ void lttng_callstack_length_record(struct lttng_ctx_field *field,
 }
 
 static
-void lttng_callstack_sequence_record(struct lttng_ctx_field *field,
+void lttng_callstack_sequence_record(struct lttng_kernel_ctx_field *field,
                        struct lib_ring_buffer_ctx *ctx,
                        struct lttng_channel *chan)
 {
index dc61c71077f5172470a9013286c247b32e690159..82816875975ceb2fdd46cb6684bc545a0137d41b 100644 (file)
@@ -56,6 +56,8 @@
 #include "lttng-context-callstack-legacy-impl.h"
 #endif
 
+#define NR_FIELDS      2
+
 static
 void field_data_free(struct field_data *fdata)
 {
@@ -88,85 +90,101 @@ error_alloc:
 }
 
 static
-void lttng_callstack_sequence_destroy(struct lttng_ctx_field *field)
+void lttng_callstack_sequence_destroy(struct lttng_kernel_ctx_field *field)
 {
        struct field_data *fdata = field->priv;
 
        field_data_free(fdata);
 }
 
-static const struct lttng_type sequence_elem_type =
-       __type_integer(unsigned long, 0, 0, -1, __BYTE_ORDER, 16, none);
+static const struct lttng_kernel_event_field *event_fields_kernel[NR_FIELDS] = {
+       lttng_kernel_static_event_field("_callstack_kernel_length",
+               lttng_kernel_static_type_integer_from_type(unsigned int, __BYTE_ORDER, 10),
+               false, false, false),
+       lttng_kernel_static_event_field("callstack_kernel",
+               lttng_kernel_static_type_sequence("_callstack_kernel_length",
+                       lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16),
+                       0, none),
+               false, false, false),
+};
+
+static const struct lttng_kernel_event_field *event_fields_user[NR_FIELDS] = {
+       lttng_kernel_static_event_field("_callstack_user_length",
+               lttng_kernel_static_type_integer_from_type(unsigned int, __BYTE_ORDER, 10),
+               false, false, false),
+       lttng_kernel_static_event_field("callstack_user",
+               lttng_kernel_static_type_sequence("_callstack_user_length",
+                       lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16),
+                       0, none),
+               false, false, false),
+};
+
+const struct lttng_kernel_event_field **lttng_cs_event_fields(enum lttng_cs_ctx_modes mode)
+{
+       switch (mode) {
+       case CALLSTACK_KERNEL:
+               return event_fields_kernel;
+       case CALLSTACK_USER:
+               return event_fields_user;
+       default:
+               return NULL;
+       }
+}
 
 static
-int __lttng_add_callstack_generic(struct lttng_ctx **ctx,
+int __lttng_add_callstack_generic(struct lttng_kernel_ctx **ctx,
                enum lttng_cs_ctx_modes mode)
 {
-       const char *ctx_name = lttng_cs_ctx_mode_name(mode);
-       const char *ctx_length_name = lttng_cs_ctx_mode_length_name(mode);
-       struct lttng_ctx_field *length_field, *sequence_field;
-       ssize_t length_index, sequence_index;
-       struct lttng_event_field *field;
+       const struct lttng_kernel_event_field **event_fields;
+       struct lttng_kernel_ctx_field ctx_field;
        struct field_data *fdata;
-       int ret;
+       int ret, i;
 
        ret = init_type(mode);
        if (ret)
                return ret;
-       if (lttng_find_context(*ctx, ctx_name))
-               return -EEXIST;
-       length_index = lttng_append_context_index(ctx);
-       if (length_index < 0) {
-               ret = -ENOMEM;
-               goto error_length;
+       event_fields = lttng_cs_event_fields(mode);
+       if (!event_fields) {
+               return -EINVAL;
        }
-       sequence_index = lttng_append_context_index(ctx);
-       if (sequence_index < 0) {
-               ret = -ENOMEM;
-               goto error_sequence;
+       for (i = 0; i < NR_FIELDS; i++) {
+               if (lttng_kernel_find_context(*ctx, event_fields[i]->name))
+                       return -EEXIST;
        }
-       length_field = lttng_get_context_field_from_index(*ctx, length_index);
-       WARN_ON_ONCE(!length_field);
-       sequence_field = lttng_get_context_field_from_index(*ctx, sequence_index);
-       WARN_ON_ONCE(!sequence_field);
        fdata = field_data_create(mode);
        if (!fdata) {
                ret = -ENOMEM;
                goto error_create;
        }
+       memset(&ctx_field, 0, sizeof(ctx_field));
+       ctx_field.event_field = event_fields[0];
+       ctx_field.get_size_arg = lttng_callstack_length_get_size;
+       ctx_field.record = lttng_callstack_length_record;
+       ctx_field.priv = fdata;
+       ret = lttng_kernel_context_append(ctx, &ctx_field);
+       if (ret) {
+               ret = -ENOMEM;
+               goto error_append0;
+       }
 
-       field = &length_field->event_field;
-       field->name = ctx_length_name;
-       field->type.type = lttng_kernel_type_integer;
-       field->type.u.integer.size = sizeof(unsigned int) * CHAR_BIT;
-       field->type.u.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
-       field->type.u.integer.signedness = lttng_is_signed_type(unsigned int);
-       field->type.u.integer.reverse_byte_order = 0;
-       field->type.u.integer.base = 10;
-       field->type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       length_field->get_size_arg = lttng_callstack_length_get_size;
-       length_field->record = lttng_callstack_length_record;
-       length_field->priv = fdata;
-
-       field = &sequence_field->event_field;
-       field->name = ctx_name;
-       field->type.type = lttng_kernel_type_sequence_nestable;
-       field->type.u.sequence_nestable.length_name = ctx_length_name;
-       field->type.u.sequence_nestable.elem_type = &sequence_elem_type;
-       field->type.u.sequence_nestable.alignment = 0;
-       sequence_field->get_size_arg = lttng_callstack_sequence_get_size;
-       sequence_field->record = lttng_callstack_sequence_record;
-       sequence_field->priv = fdata;
-       sequence_field->destroy = lttng_callstack_sequence_destroy;
-
-       wrapper_vmalloc_sync_mappings();
+       memset(&ctx_field, 0, sizeof(ctx_field));
+       ctx_field.event_field = event_fields[1];
+       ctx_field.get_size_arg = lttng_callstack_sequence_get_size;
+       ctx_field.record = lttng_callstack_sequence_record;
+       ctx_field.destroy = lttng_callstack_sequence_destroy;
+       ctx_field.priv = fdata;
+       ret = lttng_kernel_context_append(ctx, &ctx_field);
+       if (ret) {
+               ret = -ENOMEM;
+               goto error_append1;
+       }
        return 0;
 
+error_append1:
+       lttng_kernel_context_remove_last(ctx);
+error_append0:
+       field_data_free(fdata);
 error_create:
-       lttng_remove_context_field_index(ctx, sequence_index);
-error_sequence:
-       lttng_remove_context_field_index(ctx, length_index);
-error_length:
        return ret;
 }
 
@@ -184,7 +202,7 @@ error_length:
  *
  * Return 0 for success, or error code.
  */
-int lttng_add_callstack_to_ctx(struct lttng_ctx **ctx, int type)
+int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx **ctx, int type)
 {
        switch (type) {
        case LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL:
index bb7587ff7737f7d53b8d80def54322ef8c27f1bf..f34e9cf6508ada2315d4867c00afcf90b0f547de 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/sched.h>
 #include <linux/cgroup.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <wrapper/namespace.h>
@@ -34,7 +35,7 @@ size_t cgroup_ns_get_size(size_t offset)
 }
 
 static
-void cgroup_ns_record(struct lttng_ctx_field *field,
+void cgroup_ns_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -55,7 +56,7 @@ void cgroup_ns_record(struct lttng_ctx_field *field,
 }
 
 static
-void cgroup_ns_get_value(struct lttng_ctx_field *field,
+void cgroup_ns_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -74,31 +75,25 @@ void cgroup_ns_get_value(struct lttng_ctx_field *field,
        value->s64 = cgroup_ns_inum;
 }
 
-int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("cgroup_ns",
+               lttng_kernel_static_type_integer_from_type(unsigned int, __BYTE_ORDER, 10),
+               false, false, false),
+       cgroup_ns_get_size,
+       NULL,
+       cgroup_ns_record,
+       cgroup_ns_get_value,
+       NULL, NULL);
+
+int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "cgroup_ns")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "cgroup_ns";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(unsigned int);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = cgroup_ns_get_size;
-       field->record = cgroup_ns_record;
-       field->get_value = cgroup_ns_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_cgroup_ns_to_ctx);
 
index c02aad7e7d1d296765bfa03f39af199047ba66ca..47c4aa20f5d3dfec78a3b4317780122bcbcf9f57 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <lttng/tracer.h>
@@ -26,7 +27,7 @@ size_t cpu_id_get_size(size_t offset)
 }
 
 static
-void cpu_id_record(struct lttng_ctx_field *field,
+void cpu_id_record(struct lttng_kernel_ctx_field *field,
                struct lib_ring_buffer_ctx *ctx,
                struct lttng_channel *chan)
 {
@@ -38,37 +39,31 @@ void cpu_id_record(struct lttng_ctx_field *field,
 }
 
 static
-void cpu_id_get_value(struct lttng_ctx_field *field,
+void cpu_id_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = smp_processor_id();
 }
 
-int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("cpu_id",
+               lttng_kernel_static_type_integer_from_type(int, __BYTE_ORDER, 10),
+               false, false, false),
+       cpu_id_get_size,
+       NULL,
+       cpu_id_record,
+       cpu_id_get_value,
+       NULL, NULL);
+
+int lttng_add_cpu_id_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "cpu_id")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "cpu_id";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(int) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(int) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(int);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = cpu_id_get_size;
-       field->record = cpu_id_record;
-       field->get_value = cpu_id_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_cpu_id_to_ctx);
index 0d20c3f0782a3f85c01dc4f331d51054a423ad3f..027991ccb7f01a6c5348bf5d35cdfb2827bf5319 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -28,7 +29,7 @@ size_t egid_get_size(size_t offset)
 }
 
 static
-void egid_record(struct lttng_ctx_field *field,
+void egid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,37 +41,31 @@ void egid_record(struct lttng_ctx_field *field,
 }
 
 static
-void egid_get_value(struct lttng_ctx_field *field,
+void egid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = lttng_current_egid();
 }
 
-int lttng_add_egid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("egid",
+               lttng_kernel_static_type_integer_from_type(gid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       egid_get_size,
+       NULL,
+       egid_record,
+       egid_get_value,
+       NULL, NULL);
+
+int lttng_add_egid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "egid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "egid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(gid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(gid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = egid_get_size;
-       field->record = egid_record;
-       field->get_value = egid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_egid_to_ctx);
index 3105cb7a28e2cfd45a9ab8e2ee80470aca812526..3888da1dba3b4e2e63f575d3d6bbbb2bb4e589fc 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -28,7 +29,7 @@ size_t euid_get_size(size_t offset)
 }
 
 static
-void euid_record(struct lttng_ctx_field *field,
+void euid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,37 +41,31 @@ void euid_record(struct lttng_ctx_field *field,
 }
 
 static
-void euid_get_value(struct lttng_ctx_field *field,
+void euid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = lttng_current_euid();
 }
 
-int lttng_add_euid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("euid",
+               lttng_kernel_static_type_integer_from_type(uid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       euid_get_size,
+       NULL,
+       euid_record,
+       euid_get_value,
+       NULL, NULL);
+
+int lttng_add_euid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "euid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "euid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(uid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(uid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = euid_get_size;
-       field->record = euid_record;
-       field->get_value = euid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_euid_to_ctx);
index 8f33e937f25c1d4392bc5836a2ec2ef9608e62e1..4a45bcdf6b883438dd5808d17fc8427d81dd1d6d 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -28,7 +29,7 @@ size_t gid_get_size(size_t offset)
 }
 
 static
-void gid_record(struct lttng_ctx_field *field,
+void gid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,37 +41,31 @@ void gid_record(struct lttng_ctx_field *field,
 }
 
 static
-void gid_get_value(struct lttng_ctx_field *field,
+void gid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = lttng_current_gid();
 }
 
-int lttng_add_gid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("gid",
+               lttng_kernel_static_type_integer_from_type(gid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       gid_get_size,
+       NULL,
+       gid_record,
+       gid_get_value,
+       NULL, NULL);
+
+int lttng_add_gid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "gid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "gid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(gid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(gid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = gid_get_size;
-       field->record = gid_record;
-       field->get_value = gid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_gid_to_ctx);
index 55116cfbfedd111df407170a9d3f2fef24805b2a..d00c5356ae6c1f5715214bf78052377f960943f4 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/sched.h>
 #include <linux/utsname.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <lttng/tracer.h>
@@ -28,7 +29,7 @@ size_t hostname_get_size(size_t offset)
 }
 
 static
-void hostname_record(struct lttng_ctx_field *field,
+void hostname_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -53,7 +54,7 @@ void hostname_record(struct lttng_ctx_field *field,
 }
 
 static
-void hostname_get_value(struct lttng_ctx_field *field,
+void hostname_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -75,32 +76,24 @@ void hostname_get_value(struct lttng_ctx_field *field,
        value->str = hostname;
 }
 
-static const struct lttng_type hostname_array_elem_type =
-       __type_integer(char, 0, 0, -1, __BYTE_ORDER, 10, UTF8);
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("hostname",
+               lttng_kernel_static_type_array_text(LTTNG_HOSTNAME_CTX_LEN),
+               false, false, false),
+       hostname_get_size,
+       NULL,
+       hostname_record,
+       hostname_get_value,
+       NULL, NULL);
 
-int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "hostname")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "hostname";
-       field->event_field.type.type = lttng_kernel_type_array_nestable;
-       field->event_field.type.u.array_nestable.elem_type =
-               &hostname_array_elem_type;
-       field->event_field.type.u.array_nestable.length = LTTNG_HOSTNAME_CTX_LEN;
-       field->event_field.type.u.array_nestable.alignment = 0;
-
-       field->get_size = hostname_get_size;
-       field->record = hostname_record;
-       field->get_value = hostname_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_hostname_to_ctx);
index 7229a2a72aab7223c5178688182f858e417ac5ff..5cc64b2be46037c8d385ea961d72ccc5e95cb9c5 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/sched.h>
 #include <linux/irqflags.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <lttng/tracer.h>
@@ -31,7 +32,7 @@ size_t interruptible_get_size(size_t offset)
 }
 
 static
-void interruptible_record(struct lttng_ctx_field *field,
+void interruptible_record(struct lttng_kernel_ctx_field *field,
                struct lib_ring_buffer_ctx *ctx,
                struct lttng_channel *chan)
 {
@@ -43,7 +44,7 @@ void interruptible_record(struct lttng_ctx_field *field,
 }
 
 static
-void interruptible_get_value(struct lttng_ctx_field *field,
+void interruptible_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -52,30 +53,24 @@ void interruptible_get_value(struct lttng_ctx_field *field,
        value->s64 = interruptible;
 }
 
-int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("interruptible",
+               lttng_kernel_static_type_integer_from_type(int8_t, __BYTE_ORDER, 10),
+               false, false, false),
+       interruptible_get_size,
+       NULL,
+       interruptible_record,
+       interruptible_get_value,
+       NULL, NULL);
+
+int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "interruptible")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "interruptible";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(int8_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(int8_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(int8_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = interruptible_get_size;
-       field->record = interruptible_record;
-       field->get_value = interruptible_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_interruptible_to_ctx);
index e6f83e94b3e983a06bea1eccf48e63112cb4f36b..113ffb750648c86048be062c21aa4eae9b309796 100644 (file)
@@ -33,7 +33,7 @@ size_t ipc_ns_get_size(size_t offset)
 }
 
 static
-void ipc_ns_record(struct lttng_ctx_field *field,
+void ipc_ns_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -54,7 +54,7 @@ void ipc_ns_record(struct lttng_ctx_field *field,
 }
 
 static
-void ipc_ns_get_value(struct lttng_ctx_field *field,
+void ipc_ns_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -73,31 +73,25 @@ void ipc_ns_get_value(struct lttng_ctx_field *field,
        value->s64 = ipc_ns_inum;
 }
 
-int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("ipc_ns",
+               lttng_kernel_static_type_integer_from_type(unsigned int, __BYTE_ORDER, 10),
+               false, false, false),
+       ipc_ns_get_size,
+       NULL,
+       ipc_ns_record,
+       ipc_ns_get_value,
+       NULL, NULL);
+
+int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "ipc_ns")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "ipc_ns";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(unsigned int);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = ipc_ns_get_size;
-       field->record = ipc_ns_record;
-       field->get_value = ipc_ns_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_ipc_ns_to_ctx);
 
index 797f8ecaf01f059a44292dcc8c65fd42096fae4d..210c6d3059d604e05c7e57f770694590851350ca 100644 (file)
@@ -27,7 +27,7 @@ size_t migratable_get_size(size_t offset)
 }
 
 static
-void migratable_record(struct lttng_ctx_field *field,
+void migratable_record(struct lttng_kernel_ctx_field *field,
                struct lib_ring_buffer_ctx *ctx,
                struct lttng_channel *chan)
 {
@@ -38,16 +38,16 @@ void migratable_record(struct lttng_ctx_field *field,
 }
 
 static
-void migratable_get_value(struct lttng_ctx_field *field,
+void migratable_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = !current->migrate_disable;
 }
 
-int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       struct lttng_kernel_ctx_field *field;
 
        field = lttng_append_context(ctx);
        if (!field)
index 7f215a8a1500b5e998e14934124d18e0fa972c76..232c5defff7442b285f618d978f21457ba23f0ef 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <linux/nsproxy.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -35,7 +36,7 @@ size_t mnt_ns_get_size(size_t offset)
 }
 
 static
-void mnt_ns_record(struct lttng_ctx_field *field,
+void mnt_ns_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -56,7 +57,7 @@ void mnt_ns_record(struct lttng_ctx_field *field,
 }
 
 static
-void mnt_ns_get_value(struct lttng_ctx_field *field,
+void mnt_ns_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -75,31 +76,25 @@ void mnt_ns_get_value(struct lttng_ctx_field *field,
        value->s64 = mnt_ns_inum;
 }
 
-int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("mnt_ns",
+               lttng_kernel_static_type_integer_from_type(unsigned int, __BYTE_ORDER, 10),
+               false, false, false),
+       mnt_ns_get_size,
+       NULL,
+       mnt_ns_record,
+       mnt_ns_get_value,
+       NULL, NULL);
+
+int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "mnt_ns")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "mnt_ns";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(unsigned int);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = mnt_ns_get_size;
-       field->record = mnt_ns_record;
-       field->get_value = mnt_ns_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_mnt_ns_to_ctx);
 
index 3a5517dd9048d6eb0b7584bf02d00564661dba3c..6f3d61d6c0942a0df5f875a5f99246026c7f33a3 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/sched.h>
 #include <linux/irqflags.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <lttng/tracer.h>
@@ -27,7 +28,7 @@ size_t need_reschedule_get_size(size_t offset)
 }
 
 static
-void need_reschedule_record(struct lttng_ctx_field *field,
+void need_reschedule_record(struct lttng_kernel_ctx_field *field,
                struct lib_ring_buffer_ctx *ctx,
                struct lttng_channel *chan)
 {
@@ -38,37 +39,31 @@ void need_reschedule_record(struct lttng_ctx_field *field,
 }
 
 static
-void need_reschedule_get_value(struct lttng_ctx_field *field,
+void need_reschedule_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = test_tsk_need_resched(current);;
 }
 
-int lttng_add_need_reschedule_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("need_reschedule",
+               lttng_kernel_static_type_integer_from_type(uint8_t, __BYTE_ORDER, 10),
+               false, false, false),
+       need_reschedule_get_size,
+       NULL,
+       need_reschedule_record,
+       need_reschedule_get_value,
+       NULL, NULL);
+
+int lttng_add_need_reschedule_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "need_reschedule")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "need_reschedule";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(uint8_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(uint8_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(uint8_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = need_reschedule_get_size;
-       field->record = need_reschedule_record;
-       field->get_value = need_reschedule_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_need_reschedule_to_ctx);
index 8ccaaefd7e9c9d3dacf7a307d216f4c5e5b5fc05..1c8adf4962502b840fabb4d9e0488c6159632df7 100644 (file)
@@ -34,7 +34,7 @@ size_t net_ns_get_size(size_t offset)
 }
 
 static
-void net_ns_record(struct lttng_ctx_field *field,
+void net_ns_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -55,7 +55,7 @@ void net_ns_record(struct lttng_ctx_field *field,
 }
 
 static
-void net_ns_get_value(struct lttng_ctx_field *field,
+void net_ns_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -74,31 +74,25 @@ void net_ns_get_value(struct lttng_ctx_field *field,
        value->s64 = net_ns_inum;
 }
 
-int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("net_ns",
+               lttng_kernel_static_type_integer_from_type(unsigned int, __BYTE_ORDER, 10),
+               false, false, false),
+       net_ns_get_size,
+       NULL,
+       net_ns_record,
+       net_ns_get_value,
+       NULL, NULL);
+
+int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "net_ns")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "net_ns";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(unsigned int);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = net_ns_get_size;
-       field->record = net_ns_record;
-       field->get_value = net_ns_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_net_ns_to_ctx);
 
index b914c03a697f8b0f1febc7fd1bb8801140b696ba..22b8696536903412d1dfccb9f950050d3c8be420 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <lttng/tracer.h>
@@ -26,7 +27,7 @@ size_t nice_get_size(size_t offset)
 }
 
 static
-void nice_record(struct lttng_ctx_field *field,
+void nice_record(struct lttng_kernel_ctx_field *field,
                struct lib_ring_buffer_ctx *ctx,
                struct lttng_channel *chan)
 {
@@ -38,37 +39,31 @@ void nice_record(struct lttng_ctx_field *field,
 }
 
 static
-void nice_get_value(struct lttng_ctx_field *field,
+void nice_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = task_nice(current);
 }
 
-int lttng_add_nice_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("nice",
+               lttng_kernel_static_type_integer_from_type(int, __BYTE_ORDER, 10),
+               false, false, false),
+       nice_get_size,
+       NULL,
+       nice_record,
+       nice_get_value,
+       NULL, NULL);
+
+int lttng_add_nice_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "nice")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "nice";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(int) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(int) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(int);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = nice_get_size;
-       field->record = nice_record;
-       field->get_value = nice_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_nice_to_ctx);
index 6f0bb791a1ec99a516c5c2d0864a59ba7064f178..75be9bf96491cc7716958bff42225cfef20f8141 100644 (file)
@@ -30,14 +30,15 @@ size_t perf_counter_get_size(size_t offset)
 }
 
 static
-void perf_counter_record(struct lttng_ctx_field *field,
+void perf_counter_record(struct lttng_kernel_ctx_field *field,
                         struct lib_ring_buffer_ctx *ctx,
                         struct lttng_channel *chan)
 {
+       struct lttng_perf_counter_field *perf_field = field->priv;
        struct perf_event *event;
        uint64_t value;
 
-       event = field->u.perf_counter->e[ctx->cpu];
+       event = perf_field->e[ctx->cpu];
        if (likely(event)) {
                if (unlikely(event->state == PERF_EVENT_STATE_ERROR)) {
                        value = 0;
@@ -76,19 +77,20 @@ void overflow_callback(struct perf_event *event, int nmi,
 #endif
 
 static
-void lttng_destroy_perf_counter_field(struct lttng_ctx_field *field)
+void lttng_destroy_perf_counter_ctx_field(struct lttng_kernel_ctx_field *field)
 {
-       struct perf_event **events = field->u.perf_counter->e;
+       struct lttng_perf_counter_field *perf_field = field->priv;
+       struct perf_event **events = perf_field->e;
 
 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
        {
                int ret;
 
                ret = cpuhp_state_remove_instance(lttng_hp_online,
-                       &field->u.perf_counter->cpuhp_online.node);
+                       &perf_field->cpuhp_online.node);
                WARN_ON(ret);
                ret = cpuhp_state_remove_instance(lttng_hp_prepare,
-                       &field->u.perf_counter->cpuhp_prepare.node);
+                       &perf_field->cpuhp_prepare.node);
                WARN_ON(ret);
        }
 #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
@@ -100,14 +102,15 @@ void lttng_destroy_perf_counter_field(struct lttng_ctx_field *field)
                        perf_event_release_kernel(events[cpu]);
                put_online_cpus();
 #ifdef CONFIG_HOTPLUG_CPU
-               unregister_cpu_notifier(&field->u.perf_counter->nb);
+               unregister_cpu_notifier(&perf_field->nb);
 #endif
        }
 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
-       kfree(field->event_field.name);
-       kfree(field->u.perf_counter->attr);
+       kfree(perf_field->name);
+       kfree(perf_field->attr);
+       kfree(perf_field->event_field);
        lttng_kvfree(events);
-       kfree(field->u.perf_counter);
+       kfree(perf_field);
 }
 
 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
@@ -212,21 +215,42 @@ int lttng_perf_counter_cpu_hp_callback(struct notifier_block *nb,
 
 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
 
+static const struct lttng_kernel_type_common *field_type =
+       lttng_kernel_static_type_integer_from_type(uint64_t, __BYTE_ORDER, 10);
+
 int lttng_add_perf_counter_to_ctx(uint32_t type,
                                  uint64_t config,
                                  const char *name,
-                                 struct lttng_ctx **ctx)
+                                 struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       struct lttng_kernel_ctx_field ctx_field;
+       struct lttng_kernel_event_field *event_field;
        struct lttng_perf_counter_field *perf_field;
        struct perf_event **events;
        struct perf_event_attr *attr;
        int ret;
        char *name_alloc;
 
+       if (lttng_kernel_find_context(*ctx, name))
+               return -EEXIST;
+       name_alloc = kstrdup(name, GFP_KERNEL);
+       if (!name_alloc) {
+               ret = -ENOMEM;
+               goto name_alloc_error;
+       }
+       event_field = kzalloc(sizeof(*event_field), GFP_KERNEL);
+       if (!event_field) {
+               ret = -ENOMEM;
+               goto event_field_alloc_error;
+       }
+       event_field->name = name_alloc;
+       event_field->type = field_type;
+
        events = lttng_kvzalloc(num_possible_cpus() * sizeof(*events), GFP_KERNEL);
-       if (!events)
-               return -ENOMEM;
+       if (!events) {
+               ret = -ENOMEM;
+               goto event_alloc_error;
+       }
 
        attr = kzalloc(sizeof(struct perf_event_attr), GFP_KERNEL);
        if (!attr) {
@@ -247,22 +271,14 @@ int lttng_add_perf_counter_to_ctx(uint32_t type,
        }
        perf_field->e = events;
        perf_field->attr = attr;
+       perf_field->name = name_alloc;
+       perf_field->event_field = event_field;
 
-       name_alloc = kstrdup(name, GFP_KERNEL);
-       if (!name_alloc) {
-               ret = -ENOMEM;
-               goto name_alloc_error;
-       }
-
-       field = lttng_append_context(ctx);
-       if (!field) {
-               ret = -ENOMEM;
-               goto append_context_error;
-       }
-       if (lttng_find_context(*ctx, name_alloc)) {
-               ret = -EEXIST;
-               goto find_error;
-       }
+       ctx_field.event_field = event_field;
+       ctx_field.get_size = perf_counter_get_size;
+       ctx_field.record = perf_counter_record;
+       ctx_field.destroy = lttng_destroy_perf_counter_ctx_field;
+       ctx_field.priv = perf_field;
 
 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
 
@@ -306,24 +322,15 @@ int lttng_add_perf_counter_to_ctx(uint32_t type,
        }
 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
 
-       field->destroy = lttng_destroy_perf_counter_field;
-
-       field->event_field.name = name_alloc;
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(uint64_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(uint64_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(uint64_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = perf_counter_get_size;
-       field->record = perf_counter_record;
-       field->u.perf_counter = perf_field;
-       lttng_context_update(*ctx);
-
-       wrapper_vmalloc_sync_mappings();
+       ret = lttng_kernel_context_append(ctx, &ctx_field);
+       if (ret) {
+               ret = -ENOMEM;
+               goto append_context_error;
+       }
        return 0;
 
+       /* Error handling. */
+append_context_error:
 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
 cpuhp_online_error:
        {
@@ -350,15 +357,15 @@ counter_error:
 #endif
        }
 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
-find_error:
-       lttng_remove_context_field(ctx, field);
-append_context_error:
-       kfree(name_alloc);
-name_alloc_error:
        kfree(perf_field);
 error_alloc_perf_field:
        kfree(attr);
 error_attr:
        lttng_kvfree(events);
+event_alloc_error:
+       kfree(event_field);
+event_field_alloc_error:
+       kfree(name_alloc);
+name_alloc_error:
        return ret;
 }
index 1a18897cb40ea3864f7fc6d80dc712b04b0895f2..1c3cc2bc7e6b8e1a35777bab70a6a7b86c717fe0 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/sched.h>
 #include <linux/pid_namespace.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <wrapper/namespace.h>
@@ -33,7 +34,7 @@ size_t pid_ns_get_size(size_t offset)
 }
 
 static
-void pid_ns_record(struct lttng_ctx_field *field,
+void pid_ns_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -55,7 +56,7 @@ void pid_ns_record(struct lttng_ctx_field *field,
 }
 
 static
-void pid_ns_get_value(struct lttng_ctx_field *field,
+void pid_ns_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -75,31 +76,25 @@ void pid_ns_get_value(struct lttng_ctx_field *field,
        value->s64 = pid_ns_inum;
 }
 
-int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("pid_ns",
+               lttng_kernel_static_type_integer_from_type(unsigned int, __BYTE_ORDER, 10),
+               false, false, false),
+       pid_ns_get_size,
+       NULL,
+       pid_ns_record,
+       pid_ns_get_value,
+       NULL, NULL);
+
+int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "pid_ns")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "pid_ns";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(unsigned int);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = pid_ns_get_size;
-       field->record = pid_ns_record;
-       field->get_value = pid_ns_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_pid_ns_to_ctx);
 
index c52973bfc48f0e629d4750b8377dc1691cbd5e60..6f613725aad4815791616637ed3ef2a5e470fe52 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <lttng/tracer.h>
@@ -26,7 +27,7 @@ size_t pid_get_size(size_t offset)
 }
 
 static
-void pid_record(struct lttng_ctx_field *field,
+void pid_record(struct lttng_kernel_ctx_field *field,
                struct lib_ring_buffer_ctx *ctx,
                struct lttng_channel *chan)
 {
@@ -38,37 +39,31 @@ void pid_record(struct lttng_ctx_field *field,
 }
 
 static
-void pid_get_value(struct lttng_ctx_field *field,
+void pid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = task_tgid_nr(current);
 }
 
-int lttng_add_pid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("pid",
+               lttng_kernel_static_type_integer_from_type(pid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       pid_get_size,
+       NULL,
+       pid_record,
+       pid_get_value,
+       NULL, NULL);
+
+int lttng_add_pid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "pid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "pid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(pid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = pid_get_size;
-       field->record = pid_record;
-       field->get_value = pid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_pid_to_ctx);
index 4d065bce25713d5ab75eaf50ad04cbc0003c3503..63d02b89fc02c3a10f11ea2d5e073245768ed78c 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/sched.h>
 #include <linux/syscalls.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <lttng/tracer.h>
@@ -27,7 +28,7 @@ size_t ppid_get_size(size_t offset)
 }
 
 static
-void ppid_record(struct lttng_ctx_field *field,
+void ppid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -48,7 +49,7 @@ void ppid_record(struct lttng_ctx_field *field,
 }
 
 static
-void ppid_get_value(struct lttng_ctx_field *field,
+void ppid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -67,30 +68,24 @@ void ppid_get_value(struct lttng_ctx_field *field,
        value->s64 = ppid;
 }
 
-int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("ppid",
+               lttng_kernel_static_type_integer_from_type(pid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       ppid_get_size,
+       NULL,
+       ppid_record,
+       ppid_get_value,
+       NULL, NULL);
+
+int lttng_add_ppid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "ppid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "ppid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(pid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = ppid_get_size;
-       field->record = ppid_record;
-       field->get_value = ppid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_ppid_to_ctx);
index 0e67b250a524147ce8881ab71c7c6b42edd11663..9098f4b06b1a006e7823ac4b3d3293347440f92c 100644 (file)
@@ -35,7 +35,7 @@ size_t preemptible_get_size(size_t offset)
 }
 
 static
-void preemptible_record(struct lttng_ctx_field *field,
+void preemptible_record(struct lttng_kernel_ctx_field *field,
                struct lib_ring_buffer_ctx *ctx,
                struct lttng_channel *chan)
 {
@@ -50,7 +50,7 @@ void preemptible_record(struct lttng_ctx_field *field,
 }
 
 static
-void preemptible_get_value(struct lttng_ctx_field *field,
+void preemptible_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -63,9 +63,9 @@ void preemptible_get_value(struct lttng_ctx_field *field,
                value->s64 = 0;
 }
 
-int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       struct lttng_kernel_ctx_field *field;
 
        field = lttng_append_context(ctx);
        if (!field)
index a1840251828971b8eeb3705e96ea7fbaba559a23..b6f6c461c381ebc3a137a764a8028fe6765e86e0 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <wrapper/kallsyms.h>
@@ -53,7 +54,7 @@ size_t prio_get_size(size_t offset)
 }
 
 static
-void prio_record(struct lttng_ctx_field *field,
+void prio_record(struct lttng_kernel_ctx_field *field,
                struct lib_ring_buffer_ctx *ctx,
                struct lttng_channel *chan)
 {
@@ -65,44 +66,31 @@ void prio_record(struct lttng_ctx_field *field,
 }
 
 static
-void prio_get_value(struct lttng_ctx_field *field,
+void prio_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = wrapper_task_prio_sym(current);
 }
 
-int lttng_add_prio_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("prio",
+               lttng_kernel_static_type_integer_from_type(int, __BYTE_ORDER, 10),
+               false, false, false),
+       prio_get_size,
+       NULL,
+       prio_record,
+       prio_get_value,
+       NULL, NULL);
+
+int lttng_add_prio_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
        int ret;
 
-       if (!wrapper_task_prio_sym) {
-               ret = wrapper_task_prio_init();
-               if (ret)
-                       return ret;
-       }
-
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "prio")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "prio";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(int) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(int) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(int);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = prio_get_size;
-       field->record = prio_record;
-       field->get_value = prio_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_prio_to_ctx);
index e627b976869b6c6816c997290caa8eb9187b586a..3254c2e9c9448f458bda20b919ede304f00a7df5 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <lttng/tracer.h>
@@ -32,7 +33,7 @@ size_t procname_get_size(size_t offset)
  * could lead to crash in IRQ context and deadlock of the lockdep tracer.
  */
 static
-void procname_record(struct lttng_ctx_field *field,
+void procname_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,38 +41,31 @@ void procname_record(struct lttng_ctx_field *field,
 }
 
 static
-void procname_get_value(struct lttng_ctx_field *field,
+void procname_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->str = current->comm;
 }
 
-static const struct lttng_type procname_array_elem_type =
-       __type_integer(char, 0, 0, -1, __BYTE_ORDER, 10, UTF8);
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("procname",
+               lttng_kernel_static_type_array_text(sizeof(current->comm)),
+               false, false, false),
+       procname_get_size,
+       NULL,
+       procname_record,
+       procname_get_value,
+       NULL, NULL);
 
-int lttng_add_procname_to_ctx(struct lttng_ctx **ctx)
+int lttng_add_procname_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "procname")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "procname";
-       field->event_field.type.type = lttng_kernel_type_array_nestable;
-       field->event_field.type.u.array_nestable.elem_type = &procname_array_elem_type;
-       field->event_field.type.u.array_nestable.length = sizeof(current->comm);
-       field->event_field.type.u.array_nestable.alignment = 0;
-
-       field->get_size = procname_get_size;
-       field->record = procname_record;
-       field->get_value = procname_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_procname_to_ctx);
index 0cb536e432ecd5965e144333a73eb2c14cb8ac29..28a448773f45b7729b33eccc598b079f808dbd46 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -28,7 +29,7 @@ size_t sgid_get_size(size_t offset)
 }
 
 static
-void sgid_record(struct lttng_ctx_field *field,
+void sgid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,37 +41,31 @@ void sgid_record(struct lttng_ctx_field *field,
 }
 
 static
-void sgid_get_value(struct lttng_ctx_field *field,
+void sgid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = lttng_current_sgid();
 }
 
-int lttng_add_sgid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("sgid",
+               lttng_kernel_static_type_integer_from_type(gid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       sgid_get_size,
+       NULL,
+       sgid_record,
+       sgid_get_value,
+       NULL, NULL);
+
+int lttng_add_sgid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "sgid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "sgid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(gid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(gid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = sgid_get_size;
-       field->record = sgid_record;
-       field->get_value = sgid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_sgid_to_ctx);
index 86cbb9e17d6922146952900d90809f1368afac3e..9a03468d363356e91b3bab94b3420e3d94b1ca2f 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -28,7 +29,7 @@ size_t suid_get_size(size_t offset)
 }
 
 static
-void suid_record(struct lttng_ctx_field *field,
+void suid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,37 +41,31 @@ void suid_record(struct lttng_ctx_field *field,
 }
 
 static
-void suid_get_value(struct lttng_ctx_field *field,
+void suid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = lttng_current_suid();
 }
 
-int lttng_add_suid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("suid",
+               lttng_kernel_static_type_integer_from_type(uid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       suid_get_size,
+       NULL,
+       suid_record,
+       suid_get_value,
+       NULL, NULL);
+
+int lttng_add_suid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "suid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "suid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(uid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(uid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = suid_get_size;
-       field->record = suid_record;
-       field->get_value = suid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_suid_to_ctx);
index 22a04476704c41eabdcf1b578f363452184e935b..89228a1f8194a4d784c6b2dab94290f58c5ab947 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <lttng/tracer.h>
@@ -26,7 +27,7 @@ size_t tid_get_size(size_t offset)
 }
 
 static
-void tid_record(struct lttng_ctx_field *field,
+void tid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -38,7 +39,7 @@ void tid_record(struct lttng_ctx_field *field,
 }
 
 static
-void tid_get_value(struct lttng_ctx_field *field,
+void tid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -48,30 +49,24 @@ void tid_get_value(struct lttng_ctx_field *field,
        value->s64 = tid;
 }
 
-int lttng_add_tid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("tid",
+               lttng_kernel_static_type_integer_from_type(pid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       tid_get_size,
+       NULL,
+       tid_record,
+       tid_get_value,
+       NULL, NULL);
+
+int lttng_add_tid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "tid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "tid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(pid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = tid_get_size;
-       field->record = tid_record;
-       field->get_value = tid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_tid_to_ctx);
index 723b8bab0e730f88c211e12b078fa8558cd3ac16..831bbd45e2c9e7ba63d05946b603d8c91b836222 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/nsproxy.h>
 #include <linux/time_namespace.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <wrapper/namespace.h>
@@ -33,7 +34,7 @@ size_t time_ns_get_size(size_t offset)
 }
 
 static
-void time_ns_record(struct lttng_ctx_field *field,
+void time_ns_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -54,7 +55,7 @@ void time_ns_record(struct lttng_ctx_field *field,
 }
 
 static
-void time_ns_get_value(struct lttng_ctx_field *field,
+void time_ns_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -73,31 +74,25 @@ void time_ns_get_value(struct lttng_ctx_field *field,
        value->s64 = time_ns_inum;
 }
 
-int lttng_add_time_ns_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("time_ns",
+               lttng_kernel_static_type_integer_from_type(unsigned int, __BYTE_ORDER, 10),
+               false, false, false),
+       time_ns_get_size,
+       NULL,
+       time_ns_record,
+       time_ns_get_value,
+       NULL, NULL);
+
+int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "time_ns")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "time_ns";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(unsigned int);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = time_ns_get_size;
-       field->record = time_ns_record;
-       field->get_value = time_ns_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_time_ns_to_ctx);
 
index 710b22a67a41d021cb73aebf83af842858afb494..841d2ea726a1341b100f7d16a709da6d7546dd29 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -28,7 +29,7 @@ size_t uid_get_size(size_t offset)
 }
 
 static
-void uid_record(struct lttng_ctx_field *field,
+void uid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,37 +41,31 @@ void uid_record(struct lttng_ctx_field *field,
 }
 
 static
-void uid_get_value(struct lttng_ctx_field *field,
+void uid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = lttng_current_uid();
 }
 
-int lttng_add_uid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("uid",
+               lttng_kernel_static_type_integer_from_type(uid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       uid_get_size,
+       NULL,
+       uid_record,
+       uid_get_value,
+       NULL, NULL);
+
+int lttng_add_uid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "uid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "uid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(uid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(uid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = uid_get_size;
-       field->record = uid_record;
-       field->get_value = uid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_uid_to_ctx);
index 85153db230ac446844eb0547cd179861cee8a27c..bbd689dfa15d64ab699fd2329ca4758c246b2512 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/sched.h>
 #include <linux/user_namespace.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <wrapper/namespace.h>
@@ -33,7 +34,7 @@ size_t user_ns_get_size(size_t offset)
 }
 
 static
-void user_ns_record(struct lttng_ctx_field *field,
+void user_ns_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -47,7 +48,7 @@ void user_ns_record(struct lttng_ctx_field *field,
 }
 
 static
-void user_ns_get_value(struct lttng_ctx_field *field,
+void user_ns_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -59,31 +60,25 @@ void user_ns_get_value(struct lttng_ctx_field *field,
        value->s64 = user_ns_inum;
 }
 
-int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("user_ns",
+               lttng_kernel_static_type_integer_from_type(unsigned int, __BYTE_ORDER, 10),
+               false, false, false),
+       user_ns_get_size,
+       NULL,
+       user_ns_record,
+       user_ns_get_value,
+       NULL, NULL);
+
+int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "user_ns")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "user_ns";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(unsigned int);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = user_ns_get_size;
-       field->record = user_ns_record;
-       field->get_value = user_ns_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_user_ns_to_ctx);
 
index 554f18b1fa8e63dd0d0f8f050b27b789531de01d..04ddc80ff7b8e9d0ce2ab2eb9967e529a07956be 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/sched.h>
 #include <linux/utsname.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <wrapper/namespace.h>
@@ -33,7 +34,7 @@ size_t uts_ns_get_size(size_t offset)
 }
 
 static
-void uts_ns_record(struct lttng_ctx_field *field,
+void uts_ns_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -54,7 +55,7 @@ void uts_ns_record(struct lttng_ctx_field *field,
 }
 
 static
-void uts_ns_get_value(struct lttng_ctx_field *field,
+void uts_ns_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -73,31 +74,25 @@ void uts_ns_get_value(struct lttng_ctx_field *field,
        value->s64 = uts_ns_inum;
 }
 
-int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("uts_ns",
+               lttng_kernel_static_type_integer_from_type(unsigned int, __BYTE_ORDER, 10),
+               false, false, false),
+       uts_ns_get_size,
+       NULL,
+       uts_ns_record,
+       uts_ns_get_value,
+       NULL, NULL);
+
+int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "uts_ns")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "uts_ns";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(unsigned int);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = uts_ns_get_size;
-       field->record = uts_ns_record;
-       field->get_value = uts_ns_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_uts_ns_to_ctx);
 
index eebbe1cc8c105ce6497827781ff232feb79213f4..0c775890bc49d9118a1dcee32fa5c00707807dfc 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -28,7 +29,7 @@ size_t vegid_get_size(size_t offset)
 }
 
 static
-void vegid_record(struct lttng_ctx_field *field,
+void vegid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,37 +41,31 @@ void vegid_record(struct lttng_ctx_field *field,
 }
 
 static
-void vegid_get_value(struct lttng_ctx_field *field,
+void vegid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = lttng_current_vegid();
 }
 
-int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("vegid",
+               lttng_kernel_static_type_integer_from_type(gid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       vegid_get_size,
+       NULL,
+       vegid_record,
+       vegid_get_value,
+       NULL, NULL);
+
+int lttng_add_vegid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "vegid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "vegid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(gid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(gid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = vegid_get_size;
-       field->record = vegid_record;
-       field->get_value = vegid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_vegid_to_ctx);
index 63e7bd422472c855437a9f729e067500abd88e5d..0796872986f8a5650a7fd2deac6894660918acb6 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -28,7 +29,7 @@ size_t veuid_get_size(size_t offset)
 }
 
 static
-void veuid_record(struct lttng_ctx_field *field,
+void veuid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,37 +41,31 @@ void veuid_record(struct lttng_ctx_field *field,
 }
 
 static
-void veuid_get_value(struct lttng_ctx_field *field,
+void veuid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = lttng_current_veuid();
 }
 
-int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("veuid",
+               lttng_kernel_static_type_integer_from_type(uid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       veuid_get_size,
+       NULL,
+       veuid_record,
+       veuid_get_value,
+       NULL, NULL);
+
+int lttng_add_veuid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "veuid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "veuid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(uid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(uid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = veuid_get_size;
-       field->record = veuid_record;
-       field->get_value = veuid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_veuid_to_ctx);
index e8167c977af5a3afaf02db368ab606445977ae8e..00dd91d6e592764f5cca16a78d59388fa80032db 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -28,7 +29,7 @@ size_t vgid_get_size(size_t offset)
 }
 
 static
-void vgid_record(struct lttng_ctx_field *field,
+void vgid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,37 +41,31 @@ void vgid_record(struct lttng_ctx_field *field,
 }
 
 static
-void vgid_get_value(struct lttng_ctx_field *field,
+void vgid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = lttng_current_vgid();
 }
 
-int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("vgid",
+               lttng_kernel_static_type_integer_from_type(gid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       vgid_get_size,
+       NULL,
+       vgid_record,
+       vgid_get_value,
+       NULL, NULL);
+
+int lttng_add_vgid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "vgid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "vgid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(gid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(gid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = vgid_get_size;
-       field->record = vgid_record;
-       field->get_value = vgid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_vgid_to_ctx);
index e0531958d814d448595b75349b5fa1a6ca8546f0..4732f2804164d1542ef9ed574cf520a3c05f576d 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <lttng/tracer.h>
@@ -26,7 +27,7 @@ size_t vpid_get_size(size_t offset)
 }
 
 static
-void vpid_record(struct lttng_ctx_field *field,
+void vpid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -44,7 +45,7 @@ void vpid_record(struct lttng_ctx_field *field,
 }
 
 static
-void vpid_get_value(struct lttng_ctx_field *field,
+void vpid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -60,30 +61,24 @@ void vpid_get_value(struct lttng_ctx_field *field,
        value->s64 = vpid;
 }
 
-int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("vpid",
+               lttng_kernel_static_type_integer_from_type(pid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       vpid_get_size,
+       NULL,
+       vpid_record,
+       vpid_get_value,
+       NULL, NULL);
+
+int lttng_add_vpid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "vpid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "vpid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(pid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = vpid_get_size;
-       field->record = vpid_record;
-       field->get_value = vpid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_vpid_to_ctx);
index b93e292f61c01603db0ad1ab55f7ce942d4d8b25..714cf664cba3fcddcd16588ef94e87b2b5881672 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/sched.h>
 #include <linux/syscalls.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <lttng/tracer.h>
@@ -27,7 +28,7 @@ size_t vppid_get_size(size_t offset)
 }
 
 static
-void vppid_record(struct lttng_ctx_field *field,
+void vppid_record(struct lttng_kernel_ctx_field *field,
                  struct lib_ring_buffer_ctx *ctx,
                  struct lttng_channel *chan)
 {
@@ -59,7 +60,7 @@ void vppid_record(struct lttng_ctx_field *field,
 }
 
 static
-void vppid_get_value(struct lttng_ctx_field *field,
+void vppid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -89,30 +90,24 @@ void vppid_get_value(struct lttng_ctx_field *field,
        value->s64 = vppid;
 }
 
-int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("vppid",
+               lttng_kernel_static_type_integer_from_type(pid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       vppid_get_size,
+       NULL,
+       vppid_record,
+       vppid_get_value,
+       NULL, NULL);
+
+int lttng_add_vppid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "vppid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "vppid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(pid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = vppid_get_size;
-       field->record = vppid_record;
-       field->get_value = vppid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_vppid_to_ctx);
index 2bb8db7e3b84df70cda9ec77dd003e3de62d06d0..0ca4f08853c5705623e338a2d50182c8e16f48da 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -28,7 +29,7 @@ size_t vsgid_get_size(size_t offset)
 }
 
 static
-void vsgid_record(struct lttng_ctx_field *field,
+void vsgid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,37 +41,31 @@ void vsgid_record(struct lttng_ctx_field *field,
 }
 
 static
-void vsgid_get_value(struct lttng_ctx_field *field,
+void vsgid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = lttng_current_vsgid();
 }
 
-int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("vsgid",
+               lttng_kernel_static_type_integer_from_type(gid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       vsgid_get_size,
+       NULL,
+       vsgid_record,
+       vsgid_get_value,
+       NULL, NULL);
+
+int lttng_add_vsgid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "vsgid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "vsgid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(gid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(gid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = vsgid_get_size;
-       field->record = vsgid_record;
-       field->get_value = vsgid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_vsgid_to_ctx);
index 9571992ab5eaf666b2b46394ca5466c6a75059a1..82a8a4727c80db9f68d0d96966b5a483c53d6f8d 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -28,7 +29,7 @@ size_t vsuid_get_size(size_t offset)
 }
 
 static
-void vsuid_record(struct lttng_ctx_field *field,
+void vsuid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,37 +41,31 @@ void vsuid_record(struct lttng_ctx_field *field,
 }
 
 static
-void vsuid_get_value(struct lttng_ctx_field *field,
+void vsuid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = lttng_current_vsuid();
 }
 
-int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("vsuid",
+               lttng_kernel_static_type_integer_from_type(uid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       vsuid_get_size,
+       NULL,
+       vsuid_record,
+       vsuid_get_value,
+       NULL, NULL);
+
+int lttng_add_vsuid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "vsuid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "vsuid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(uid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(uid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = vsuid_get_size;
-       field->record = vsuid_record;
-       field->get_value = vsuid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_vsuid_to_ctx);
index 106fa4e55c36f5c27639afed05dd9d453f6b3611..76750adc8b84e4520b54cae67a7c7b0951386080 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
 #include <lttng/tracer.h>
@@ -26,7 +27,7 @@ size_t vtid_get_size(size_t offset)
 }
 
 static
-void vtid_record(struct lttng_ctx_field *field,
+void vtid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -44,7 +45,7 @@ void vtid_record(struct lttng_ctx_field *field,
 }
 
 static
-void vtid_get_value(struct lttng_ctx_field *field,
+void vtid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
@@ -60,30 +61,24 @@ void vtid_get_value(struct lttng_ctx_field *field,
        value->s64 = vtid;
 }
 
-int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("vtid",
+               lttng_kernel_static_type_integer_from_type(pid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       vtid_get_size,
+       NULL,
+       vtid_record,
+       vtid_get_value,
+       NULL, NULL);
+
+int lttng_add_vtid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "vtid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "vtid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(pid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = vtid_get_size;
-       field->record = vtid_record;
-       field->get_value = vtid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_vtid_to_ctx);
index 978cc54559ba9fd04f57f60db4ddde035031a1e8..ef9a492865fbf4e57cb3d5dffca094d83b8a667b 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 #include <ringbuffer/frontend_types.h>
 #include <wrapper/vmalloc.h>
@@ -28,7 +29,7 @@ size_t vuid_get_size(size_t offset)
 }
 
 static
-void vuid_record(struct lttng_ctx_field *field,
+void vuid_record(struct lttng_kernel_ctx_field *field,
                 struct lib_ring_buffer_ctx *ctx,
                 struct lttng_channel *chan)
 {
@@ -40,37 +41,31 @@ void vuid_record(struct lttng_ctx_field *field,
 }
 
 static
-void vuid_get_value(struct lttng_ctx_field *field,
+void vuid_get_value(struct lttng_kernel_ctx_field *field,
                struct lttng_probe_ctx *lttng_probe_ctx,
                union lttng_ctx_value *value)
 {
        value->s64 = lttng_current_vuid();
 }
 
-int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx)
+static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
+       lttng_kernel_static_event_field("vuid",
+               lttng_kernel_static_type_integer_from_type(uid_t, __BYTE_ORDER, 10),
+               false, false, false),
+       vuid_get_size,
+       NULL,
+       vuid_record,
+       vuid_get_value,
+       NULL, NULL);
+
+int lttng_add_vuid_to_ctx(struct lttng_kernel_ctx **ctx)
 {
-       struct lttng_ctx_field *field;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
-               return -ENOMEM;
-       if (lttng_find_context(*ctx, "vuid")) {
-               lttng_remove_context_field(ctx, field);
+       if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
                return -EEXIST;
-       }
-       field->event_field.name = "vuid";
-       field->event_field.type.type = lttng_kernel_type_integer;
-       field->event_field.type.u.integer.size = sizeof(uid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
-       field->event_field.type.u.integer.signedness = lttng_is_signed_type(uid_t);
-       field->event_field.type.u.integer.reverse_byte_order = 0;
-       field->event_field.type.u.integer.base = 10;
-       field->event_field.type.u.integer.encoding = lttng_kernel_string_encoding_none;
-       field->get_size = vuid_get_size;
-       field->record = vuid_record;
-       field->get_value = vuid_get_value;
-       lttng_context_update(*ctx);
+       ret = lttng_kernel_context_append(ctx, ctx_field);
        wrapper_vmalloc_sync_mappings();
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(lttng_add_vuid_to_ctx);
index 5c83ffb239eb61fabb7484b5a9c4b12efb7ed692..0176dd9472e3ef40e35f5ea0436581e437671d9f 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <wrapper/vmalloc.h>   /* for wrapper_vmalloc_sync_mappings() */
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/tracer.h>
 
 /*
 /*
  * Static array of contexts, for $ctx filters.
  */
-struct lttng_ctx *lttng_static_ctx;
+struct lttng_kernel_ctx *lttng_static_ctx;
 
-int lttng_find_context(struct lttng_ctx *ctx, const char *name)
+int lttng_kernel_find_context(struct lttng_kernel_ctx *ctx, const char *name)
 {
        unsigned int i;
+       const char *subname;
 
        if (!ctx)
                return 0;
+       if (strncmp(name, "$ctx.", strlen("$ctx.")) == 0) {
+               subname = name + strlen("$ctx.");
+       } else {
+               subname = name;
+       }
        for (i = 0; i < ctx->nr_fields; i++) {
                /* Skip allocated (but non-initialized) contexts */
-               if (!ctx->fields[i].event_field.name)
+               if (!ctx->fields[i].event_field->name)
                        continue;
-               if (!strcmp(ctx->fields[i].event_field.name, name))
+               if (!strcmp(ctx->fields[i].event_field->name, subname))
                        return 1;
        }
        return 0;
 }
-EXPORT_SYMBOL_GPL(lttng_find_context);
+EXPORT_SYMBOL_GPL(lttng_kernel_find_context);
 
-int lttng_get_context_index(struct lttng_ctx *ctx, const char *name)
+int lttng_kernel_get_context_index(struct lttng_kernel_ctx *ctx, const char *name)
 {
        unsigned int i;
        const char *subname;
@@ -56,187 +63,137 @@ int lttng_get_context_index(struct lttng_ctx *ctx, const char *name)
        }
        for (i = 0; i < ctx->nr_fields; i++) {
                /* Skip allocated (but non-initialized) contexts */
-               if (!ctx->fields[i].event_field.name)
+               if (!ctx->fields[i].event_field->name)
                        continue;
-               if (!strcmp(ctx->fields[i].event_field.name, subname))
+               if (!strcmp(ctx->fields[i].event_field->name, subname))
                        return i;
        }
        return -1;
 }
-EXPORT_SYMBOL_GPL(lttng_get_context_index);
+EXPORT_SYMBOL_GPL(lttng_kernel_get_context_index);
 
-struct lttng_ctx_field *lttng_get_context_field_from_index(struct lttng_ctx *ctx,
+struct lttng_kernel_ctx_field *lttng_kernel_get_context_field_from_index(struct lttng_kernel_ctx *ctx,
                size_t index)
 {
        if (index >= ctx->nr_fields)
                return NULL;
        return &ctx->fields[index];
 }
-EXPORT_SYMBOL_GPL(lttng_get_context_field_from_index);
+EXPORT_SYMBOL_GPL(lttng_kernel_get_context_field_from_index);
 
 /*
  * Note: as we append context information, the pointer location may change.
+ * lttng_kernel_context_add_field leaves the new last context initialized to NULL.
  */
-ssize_t lttng_append_context_index(struct lttng_ctx **ctx_p)
+static
+int lttng_kernel_context_add_field(struct lttng_kernel_ctx **ctx_p)
 {
-       struct lttng_ctx *ctx;
-       ssize_t pos = -1;
+       struct lttng_kernel_ctx *ctx;
 
        if (!*ctx_p) {
-               *ctx_p = kzalloc(sizeof(struct lttng_ctx), GFP_KERNEL);
+               *ctx_p = kzalloc(sizeof(struct lttng_kernel_ctx), GFP_KERNEL);
                if (!*ctx_p)
-                       goto end;
+                       return -ENOMEM;
                (*ctx_p)->largest_align = 1;
        }
        ctx = *ctx_p;
        if (ctx->nr_fields + 1 > ctx->allocated_fields) {
-               struct lttng_ctx_field *new_fields;
+               struct lttng_kernel_ctx_field *new_fields;
 
                ctx->allocated_fields = max_t(size_t, 1, 2 * ctx->allocated_fields);
-               new_fields = lttng_kvzalloc(ctx->allocated_fields * sizeof(struct lttng_ctx_field), GFP_KERNEL);
+               new_fields = lttng_kvzalloc(ctx->allocated_fields * sizeof(*new_fields), GFP_KERNEL);
                if (!new_fields)
-                       goto end;
+                       return -ENOMEM;
                if (ctx->fields)
                        memcpy(new_fields, ctx->fields, sizeof(*ctx->fields) * ctx->nr_fields);
                lttng_kvfree(ctx->fields);
                ctx->fields = new_fields;
        }
-       pos = ctx->nr_fields++;
-end:
-       return pos;
+       ctx->nr_fields++;
+       return 0;
 }
-EXPORT_SYMBOL_GPL(lttng_append_context_index);
 
-/*
- * Note: as we append context information, the pointer location may change.
- */
-struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx_p)
+static size_t get_type_max_align(const struct lttng_kernel_type_common *type)
 {
-       ssize_t pos;
-
-       pos = lttng_append_context_index(ctx_p);
-       if (pos < 0)
-               return NULL;
-       return &(*ctx_p)->fields[pos];
+       switch (type->type) {
+       case lttng_kernel_type_integer:
+               return lttng_kernel_get_type_integer(type)->alignment;
+       case lttng_kernel_type_string:
+               return CHAR_BIT;
+       case lttng_kernel_type_enum:
+               return get_type_max_align(lttng_kernel_get_type_enum(type)->container_type);
+       case lttng_kernel_type_array:
+               return max_t(size_t, get_type_max_align(lttng_kernel_get_type_array(type)->elem_type),
+                               lttng_kernel_get_type_array(type)->alignment);
+       case lttng_kernel_type_sequence:
+               return max_t(size_t, get_type_max_align(lttng_kernel_get_type_sequence(type)->elem_type),
+                               lttng_kernel_get_type_sequence(type)->alignment);
+       case lttng_kernel_type_struct:
+       {
+               unsigned int i;
+               size_t field_align = 0;
+               const struct lttng_kernel_type_struct *struct_type = lttng_kernel_get_type_struct(type);
+
+               for (i = 0; i < struct_type->nr_fields; i++) {
+                       field_align = max_t(size_t,
+                               get_type_max_align(struct_type->fields[i]->type),
+                               field_align);
+               }
+               return field_align;
+       }
+       case lttng_kernel_type_variant:
+               /* Variants are not accounted in the overall alignment of the type they are embedded in. */
+               return 0;
+       default:
+               WARN_ON_ONCE(1);
+               return 0;
+       }
 }
-EXPORT_SYMBOL_GPL(lttng_append_context);
 
 /*
  * lttng_context_update() should be called at least once between context
  * modification and trace start.
  */
-void lttng_context_update(struct lttng_ctx *ctx)
+static
+void lttng_context_update(struct lttng_kernel_ctx *ctx)
 {
        int i;
        size_t largest_align = 8;       /* in bits */
 
        for (i = 0; i < ctx->nr_fields; i++) {
-               struct lttng_type *type;
                size_t field_align = 8;
 
-               type = &ctx->fields[i].event_field.type;
-               switch (type->type) {
-               case lttng_kernel_type_integer:
-                       field_align = type->u.integer.alignment;
-                       break;
-               case lttng_kernel_type_array_nestable:
-               {
-                       const struct lttng_type *nested_type;
-
-                       nested_type = type->u.array_nestable.elem_type;
-                       switch (nested_type->type) {
-                       case lttng_kernel_type_integer:
-                               field_align = nested_type->u.integer.alignment;
-                               break;
-                       case lttng_kernel_type_string:
-                               break;
-
-                       case lttng_kernel_type_array_nestable:
-                       case lttng_kernel_type_sequence_nestable:
-                       case lttng_kernel_type_struct_nestable:
-                       case lttng_kernel_type_variant_nestable:
-                       default:
-                               WARN_ON_ONCE(1);
-                               break;
-                       }
-                       field_align = max_t(size_t, field_align,
-                                       type->u.array_nestable.alignment);
-                       break;
-               }
-               case lttng_kernel_type_sequence_nestable:
-               {
-                       const struct lttng_type *nested_type;
-
-                       nested_type = type->u.sequence_nestable.elem_type;
-                       switch (nested_type->type) {
-                       case lttng_kernel_type_integer:
-                               field_align = nested_type->u.integer.alignment;
-                               break;
-
-                       case lttng_kernel_type_string:
-                               break;
-
-                       case lttng_kernel_type_array_nestable:
-                       case lttng_kernel_type_sequence_nestable:
-                       case lttng_kernel_type_struct_nestable:
-                       case lttng_kernel_type_variant_nestable:
-                       default:
-                               WARN_ON_ONCE(1);
-                               break;
-                       }
-                       field_align = max_t(size_t, field_align,
-                                       type->u.sequence_nestable.alignment);
-                       break;
-               }
-               case lttng_kernel_type_string:
-                       break;
-
-               case lttng_kernel_type_struct_nestable:
-               case lttng_kernel_type_variant_nestable:
-                       break;
-
-               case lttng_kernel_type_enum_nestable:
-               default:
-                       WARN_ON_ONCE(1);
-                       break;
-               }
+               field_align = get_type_max_align(ctx->fields[i].event_field->type);
                largest_align = max_t(size_t, largest_align, field_align);
        }
        ctx->largest_align = largest_align >> 3;        /* bits to bytes */
 }
 
-/* Keep same order. */
-void lttng_remove_context_field_index(struct lttng_ctx **ctx_p, size_t index)
+int lttng_kernel_context_append(struct lttng_kernel_ctx **ctx_p,
+               const struct lttng_kernel_ctx_field *f)
 {
-       struct lttng_ctx *ctx = *ctx_p;
+       int ret;
 
-       WARN_ON_ONCE(ctx->nr_fields >= index);
-       if (index != ctx->nr_fields - 1) {
-               memmove(&ctx->fields[index], &ctx->fields[index + 1],
-                       (ctx->nr_fields - index - 1) * sizeof(struct lttng_ctx_field));
-       }
-       /* Clear last item. */
-       memset(&ctx->fields[ctx->nr_fields - 1], 0, sizeof(struct lttng_ctx_field));
-       ctx->nr_fields--;
+       ret = lttng_kernel_context_add_field(ctx_p);
+       if (ret)
+               return ret;
+       (*ctx_p)->fields[(*ctx_p)->nr_fields - 1] = *f;
+       lttng_context_update(*ctx_p);
+       return 0;
 }
-EXPORT_SYMBOL_GPL(lttng_remove_context_field_index);
 
-/*
- * Remove last context field.
- */
-void lttng_remove_context_field(struct lttng_ctx **ctx_p,
-                               struct lttng_ctx_field *field)
+void lttng_kernel_context_remove_last(struct lttng_kernel_ctx **ctx_p)
 {
-       struct lttng_ctx *ctx;
+       struct lttng_kernel_ctx *ctx = *ctx_p;
 
-       ctx = *ctx_p;
+       if (!ctx->nr_fields)
+               return;
+       memset(&ctx->fields[ctx->nr_fields - 1], 0, sizeof(struct lttng_kernel_ctx_field));
        ctx->nr_fields--;
-       WARN_ON_ONCE(&ctx->fields[ctx->nr_fields] != field);
-       memset(&ctx->fields[ctx->nr_fields], 0, sizeof(struct lttng_ctx_field));
+       lttng_context_update(ctx);
 }
-EXPORT_SYMBOL_GPL(lttng_remove_context_field);
 
-void lttng_destroy_context(struct lttng_ctx *ctx)
+void lttng_kernel_destroy_context(struct lttng_kernel_ctx *ctx)
 {
        int i;
 
@@ -352,6 +309,6 @@ int lttng_context_init(void)
 
 void lttng_context_exit(void)
 {
-       lttng_destroy_context(lttng_static_ctx);
+       lttng_kernel_destroy_context(lttng_static_ctx);
        lttng_static_ctx = NULL;
 }
index 906ed109a8a1e01c7f95011387f724b8b898d86a..1a40fed74101f86118aef131e46396c04904cf7a 100644 (file)
@@ -11,6 +11,7 @@
 #include <lttng/events.h>
 #include <lttng/msgpack.h>
 #include <lttng/event-notifier-notification.h>
+#include <lttng/events-internal.h>
 #include <wrapper/barrier.h>
 
 /*
@@ -95,7 +96,7 @@ end:
 
 static
 int64_t capture_sequence_element_signed(uint8_t *ptr,
-               const struct lttng_integer_type *type)
+               const struct lttng_kernel_type_integer *type)
 {
        int64_t value = 0;
        unsigned int size = type->size;
@@ -144,7 +145,7 @@ int64_t capture_sequence_element_signed(uint8_t *ptr,
 
 static
 uint64_t capture_sequence_element_unsigned(uint8_t *ptr,
-               const struct lttng_integer_type *type)
+               const struct lttng_kernel_type_integer *type)
 {
        uint64_t value = 0;
        unsigned int size = type->size;
@@ -194,8 +195,8 @@ uint64_t capture_sequence_element_unsigned(uint8_t *ptr,
 int capture_sequence(struct lttng_msgpack_writer *writer,
                struct lttng_interpreter_output *output)
 {
-       const struct lttng_integer_type *integer_type = NULL;
-       const struct lttng_type *nested_type;
+       const struct lttng_kernel_type_integer *integer_type = NULL;
+       const struct lttng_kernel_type_common *nested_type;
        uint8_t *ptr;
        bool signedness;
        int ret, i;
@@ -210,11 +211,11 @@ int capture_sequence(struct lttng_msgpack_writer *writer,
        nested_type = output->u.sequence.nested_type;
        switch (nested_type->type) {
        case lttng_kernel_type_integer:
-               integer_type = &nested_type->u.integer;
+               integer_type = lttng_kernel_get_type_integer(nested_type);
                break;
-       case lttng_kernel_type_enum_nestable:
+       case lttng_kernel_type_enum:
                /* Treat enumeration as an integer. */
-               integer_type = &nested_type->u.enum_nestable.container_type->u.integer;
+               integer_type = lttng_kernel_get_type_integer(lttng_kernel_get_type_enum(nested_type)->container_type);
                break;
        default:
                /* Capture of array of non-integer are not supported. */
index 57ff55b71e45e80c32b8c54547b584a8d47a4899..21653efd242cf414042ded43afb5ae226ded8286 100644 (file)
@@ -82,11 +82,12 @@ static
 void _lttng_metadata_channel_hangup(struct lttng_metadata_stream *stream);
 static
 int _lttng_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_common *type,
+               enum lttng_kernel_string_encoding parent_encoding,
                size_t nesting);
 static
 int _lttng_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting);
 
 void synchronize_trace(void)
@@ -814,7 +815,7 @@ void _lttng_channel_destroy(struct lttng_channel *chan)
        chan->ops->channel_destroy(chan->chan);
        module_put(chan->transport->owner);
        list_del(&chan->list);
-       lttng_destroy_context(chan->ctx);
+       lttng_kernel_destroy_context(chan->ctx);
        kfree(chan);
 }
 
@@ -844,7 +845,7 @@ void _lttng_metadata_channel_hangup(struct lttng_metadata_stream *stream)
 struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
                                struct lttng_kernel_event *event_param,
                                void *filter,
-                               const struct lttng_event_desc *event_desc,
+                               const struct lttng_kernel_event_desc *event_desc,
                                enum lttng_kernel_instrumentation itype)
 {
        struct lttng_session *session = chan->session;
@@ -860,7 +861,7 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
 
        switch (itype) {
        case LTTNG_KERNEL_TRACEPOINT:
-               event_name = event_desc->name;
+               event_name = event_desc->event_name;
                break;
 
        case LTTNG_KERNEL_KPROBE:       /* Fall-through */
@@ -882,7 +883,7 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
                LTTNG_EVENT_HT_SIZE, event_name);
        lttng_hlist_for_each_entry(event, head, hlist) {
                WARN_ON_ONCE(!event->desc);
-               if (!strncmp(event->desc->name, event_name,
+               if (!strncmp(event->desc->event_name, event_name,
                                        LTTNG_KERNEL_SYM_NAME_LEN - 1)
                                && chan == event->chan) {
                        ret = -EEXIST;
@@ -1086,7 +1087,7 @@ full:
 }
 
 struct lttng_event_notifier *_lttng_event_notifier_create(
-               const struct lttng_event_desc *event_desc,
+               const struct lttng_kernel_event_desc *event_desc,
                uint64_t token, uint64_t error_counter_index,
                struct lttng_event_notifier_group *event_notifier_group,
                struct lttng_kernel_event_notifier *event_notifier_param,
@@ -1100,7 +1101,7 @@ struct lttng_event_notifier *_lttng_event_notifier_create(
 
        switch (itype) {
        case LTTNG_KERNEL_TRACEPOINT:
-               event_name = event_desc->name;
+               event_name = event_desc->event_name;
                break;
 
        case LTTNG_KERNEL_KPROBE:       /* Fall-through */
@@ -1122,7 +1123,7 @@ struct lttng_event_notifier *_lttng_event_notifier_create(
                LTTNG_EVENT_NOTIFIER_HT_SIZE, event_name);
        lttng_hlist_for_each_entry(event_notifier, head, hlist) {
                WARN_ON_ONCE(!event_notifier->desc);
-               if (!strncmp(event_notifier->desc->name, event_name,
+               if (!strncmp(event_notifier->desc->event_name, event_name,
                                        LTTNG_KERNEL_SYM_NAME_LEN - 1)
                                && event_notifier_group == event_notifier->group
                                && token == event_notifier->user_token) {
@@ -1325,7 +1326,7 @@ int lttng_kernel_counter_clear(struct lttng_counter *counter,
 struct lttng_event *lttng_event_create(struct lttng_channel *chan,
                                struct lttng_kernel_event *event_param,
                                void *filter,
-                               const struct lttng_event_desc *event_desc,
+                               const struct lttng_kernel_event_desc *event_desc,
                                enum lttng_kernel_instrumentation itype)
 {
        struct lttng_event *event;
@@ -1338,7 +1339,7 @@ struct lttng_event *lttng_event_create(struct lttng_channel *chan,
 }
 
 struct lttng_event_notifier *lttng_event_notifier_create(
-               const struct lttng_event_desc *event_desc,
+               const struct lttng_kernel_event_desc *event_desc,
                uint64_t id, uint64_t error_counter_index,
                struct lttng_event_notifier_group *event_notifier_group,
                struct lttng_kernel_event_notifier *event_notifier_param,
@@ -1358,7 +1359,7 @@ struct lttng_event_notifier *lttng_event_notifier_create(
 static
 void register_event(struct lttng_event *event)
 {
-       const struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_desc *desc;
        int ret = -EINVAL;
 
        if (event->registered)
@@ -1367,7 +1368,7 @@ void register_event(struct lttng_event *event)
        desc = event->desc;
        switch (event->instrumentation) {
        case LTTNG_KERNEL_TRACEPOINT:
-               ret = lttng_wrapper_tracepoint_probe_register(desc->kname,
+               ret = lttng_wrapper_tracepoint_probe_register(desc->event_kname,
                                                  desc->probe_callback,
                                                  event);
                break;
@@ -1396,7 +1397,7 @@ void register_event(struct lttng_event *event)
  */
 int _lttng_event_unregister(struct lttng_event *event)
 {
-       const struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_desc *desc;
        int ret = -EINVAL;
 
        if (!event->registered)
@@ -1405,7 +1406,7 @@ int _lttng_event_unregister(struct lttng_event *event)
        desc = event->desc;
        switch (event->instrumentation) {
        case LTTNG_KERNEL_TRACEPOINT:
-               ret = lttng_wrapper_tracepoint_probe_unregister(event->desc->kname,
+               ret = lttng_wrapper_tracepoint_probe_unregister(event->desc->event_kname,
                                                  event->desc->probe_callback,
                                                  event);
                break;
@@ -1446,7 +1447,7 @@ int _lttng_event_unregister(struct lttng_event *event)
 static
 void register_event_notifier(struct lttng_event_notifier *event_notifier)
 {
-       const struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_desc *desc;
        int ret = -EINVAL;
 
        if (event_notifier->registered)
@@ -1455,7 +1456,7 @@ void register_event_notifier(struct lttng_event_notifier *event_notifier)
        desc = event_notifier->desc;
        switch (event_notifier->instrumentation) {
        case LTTNG_KERNEL_TRACEPOINT:
-               ret = lttng_wrapper_tracepoint_probe_register(desc->kname,
+               ret = lttng_wrapper_tracepoint_probe_register(desc->event_kname,
                                                  desc->event_notifier_callback,
                                                  event_notifier);
                break;
@@ -1483,7 +1484,7 @@ static
 int _lttng_event_notifier_unregister(
                struct lttng_event_notifier *event_notifier)
 {
-       const struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_desc *desc;
        int ret = -EINVAL;
 
        if (!event_notifier->registered)
@@ -1492,7 +1493,7 @@ int _lttng_event_notifier_unregister(
        desc = event_notifier->desc;
        switch (event_notifier->instrumentation) {
        case LTTNG_KERNEL_TRACEPOINT:
-               ret = lttng_wrapper_tracepoint_probe_unregister(event_notifier->desc->kname,
+               ret = lttng_wrapper_tracepoint_probe_unregister(event_notifier->desc->event_kname,
                                                  event_notifier->desc->event_notifier_callback,
                                                  event_notifier);
                break;
@@ -1559,7 +1560,7 @@ void _lttng_event_destroy(struct lttng_event *event)
                WARN_ON_ONCE(1);
        }
        list_del(&event->list);
-       lttng_destroy_context(event->ctx);
+       lttng_kernel_destroy_context(event->ctx);
        lttng_free_event_filter_runtime(event);
        /* Free event enabler refs */
        list_for_each_entry_safe(enabler_ref, tmp_enabler_ref,
@@ -1884,7 +1885,7 @@ int lttng_match_enabler_name(const char *desc_name,
        return 1;
 }
 
-int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
+int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
                struct lttng_enabler *enabler)
 {
        const char *desc_name, *enabler_name;
@@ -1893,7 +1894,7 @@ int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
        enabler_name = enabler->event_param.name;
        switch (enabler->event_param.instrumentation) {
        case LTTNG_KERNEL_TRACEPOINT:
-               desc_name = desc->name;
+               desc_name = desc->event_name;
                switch (enabler->format_type) {
                case LTTNG_ENABLER_FORMAT_STAR_GLOB:
                        return lttng_match_enabler_star_glob(desc_name, enabler_name);
@@ -1905,7 +1906,7 @@ int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
                break;
 
        case LTTNG_KERNEL_SYSCALL:
-               desc_name = desc->name;
+               desc_name = desc->event_name;
                if (!strncmp(desc_name, "compat_", strlen("compat_"))) {
                        desc_name += strlen("compat_");
                        compat = true;
@@ -2024,8 +2025,8 @@ static
 void lttng_create_tracepoint_event_if_missing(struct lttng_event_enabler *event_enabler)
 {
        struct lttng_session *session = event_enabler->chan->session;
-       struct lttng_probe_desc *probe_desc;
-       const struct lttng_event_desc *desc;
+       struct lttng_kernel_probe_desc *probe_desc;
+       const struct lttng_kernel_event_desc *desc;
        int i;
        struct list_head *probe_list;
 
@@ -2051,7 +2052,7 @@ void lttng_create_tracepoint_event_if_missing(struct lttng_event_enabler *event_
                         */
                        head = utils_borrow_hash_table_bucket(
                                session->events_ht.table, LTTNG_EVENT_HT_SIZE,
-                               desc->name);
+                               desc->event_name);
                        lttng_hlist_for_each_entry(event, head, hlist) {
                                if (event->desc == desc
                                                && event->chan == event_enabler->chan)
@@ -2069,7 +2070,7 @@ void lttng_create_tracepoint_event_if_missing(struct lttng_event_enabler *event_
                                        LTTNG_KERNEL_TRACEPOINT);
                        if (!event) {
                                printk(KERN_INFO "LTTng: Unable to create event %s\n",
-                                       probe_desc->event_desc[i]->name);
+                                       probe_desc->event_desc[i]->event_name);
                        }
                }
        }
@@ -2079,8 +2080,8 @@ static
 void lttng_create_tracepoint_event_notifier_if_missing(struct lttng_event_notifier_enabler *event_notifier_enabler)
 {
        struct lttng_event_notifier_group *event_notifier_group = event_notifier_enabler->group;
-       struct lttng_probe_desc *probe_desc;
-       const struct lttng_event_desc *desc;
+       struct lttng_kernel_probe_desc *probe_desc;
+       const struct lttng_kernel_event_desc *desc;
        int i;
        struct list_head *probe_list;
 
@@ -2106,7 +2107,7 @@ void lttng_create_tracepoint_event_notifier_if_missing(struct lttng_event_notifi
                         */
                        head = utils_borrow_hash_table_bucket(
                                event_notifier_group->event_notifiers_ht.table,
-                               LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->name);
+                               LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->event_name);
                        lttng_hlist_for_each_entry(event_notifier, head, hlist) {
                                if (event_notifier->desc == desc
                                                && event_notifier->user_token == event_notifier_enabler->base.user_token)
@@ -2125,7 +2126,7 @@ void lttng_create_tracepoint_event_notifier_if_missing(struct lttng_event_notifi
                                LTTNG_KERNEL_TRACEPOINT);
                        if (IS_ERR(event_notifier)) {
                                printk(KERN_INFO "Unable to create event_notifier %s\n",
-                                       probe_desc->event_desc[i]->name);
+                                       probe_desc->event_desc[i]->event_name);
                        }
                }
        }
@@ -2507,7 +2508,7 @@ void lttng_event_enabler_destroy(struct lttng_event_enabler *event_enabler)
        lttng_enabler_destroy(lttng_event_enabler_as_enabler(event_enabler));
 
        /* Destroy contexts */
-       lttng_destroy_context(event_enabler->ctx);
+       lttng_kernel_destroy_context(event_enabler->ctx);
 
        list_del(&event_enabler->node);
        kfree(event_enabler);
@@ -3001,7 +3002,7 @@ int print_tabs(struct lttng_session *session, size_t nesting)
 
 static
 int lttng_field_name_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        return lttng_metadata_printf(session, " _%s;\n", field->name);
@@ -3009,30 +3010,30 @@ int lttng_field_name_statedump(struct lttng_session *session,
 
 static
 int _lttng_integer_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_integer *type,
+               enum lttng_kernel_string_encoding parent_encoding,
                size_t nesting)
 {
        int ret;
 
-       WARN_ON_ONCE(type->type != lttng_kernel_type_integer);
        ret = print_tabs(session, nesting);
        if (ret)
                return ret;
        ret = lttng_metadata_printf(session,
                "integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s }",
-               type->u.integer.size,
-               type->u.integer.alignment,
-               type->u.integer.signedness,
-               (type->u.integer.encoding == lttng_kernel_string_encoding_none)
+               type->size,
+               type->alignment,
+               type->signedness,
+               (parent_encoding == lttng_kernel_string_encoding_none)
                        ? "none"
-                       : (type->u.integer.encoding == lttng_kernel_string_encoding_UTF8)
+                       : (parent_encoding == lttng_kernel_string_encoding_UTF8)
                                ? "UTF8"
                                : "ASCII",
-               type->u.integer.base,
+               type->base,
 #if __BYTE_ORDER == __BIG_ENDIAN
-               type->u.integer.reverse_byte_order ? " byte_order = le;" : ""
+               type->reverse_byte_order ? " byte_order = le;" : ""
 #else
-               type->u.integer.reverse_byte_order ? " byte_order = be;" : ""
+               type->reverse_byte_order ? " byte_order = be;" : ""
 #endif
        );
        return ret;
@@ -3043,15 +3044,13 @@ int _lttng_integer_type_statedump(struct lttng_session *session,
  */
 static
 int _lttng_struct_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_struct *type,
                size_t nesting)
 {
        int ret;
        uint32_t i, nr_fields;
        unsigned int alignment;
 
-       WARN_ON_ONCE(type->type != lttng_kernel_type_struct_nestable);
-
        ret = print_tabs(session, nesting);
        if (ret)
                return ret;
@@ -3059,11 +3058,11 @@ int _lttng_struct_type_statedump(struct lttng_session *session,
                "struct {\n");
        if (ret)
                return ret;
-       nr_fields = type->u.struct_nestable.nr_fields;
+       nr_fields = type->nr_fields;
        for (i = 0; i < nr_fields; i++) {
-               const struct lttng_event_field *iter_field;
+               const struct lttng_kernel_event_field *iter_field;
 
-               iter_field = &type->u.struct_nestable.fields[i];
+               iter_field = type->fields[i];
                ret = _lttng_field_statedump(session, iter_field, nesting + 1);
                if (ret)
                        return ret;
@@ -3071,7 +3070,7 @@ int _lttng_struct_type_statedump(struct lttng_session *session,
        ret = print_tabs(session, nesting);
        if (ret)
                return ret;
-       alignment = type->u.struct_nestable.alignment;
+       alignment = type->alignment;
        if (alignment) {
                ret = lttng_metadata_printf(session,
                        "} align(%u)",
@@ -3088,13 +3087,13 @@ int _lttng_struct_type_statedump(struct lttng_session *session,
  */
 static
 int _lttng_struct_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret;
 
        ret = _lttng_struct_type_statedump(session,
-                       &field->type, nesting);
+                       lttng_kernel_get_type_struct(field->type), nesting);
        if (ret)
                return ret;
        return lttng_field_name_statedump(session, field, nesting);
@@ -3105,31 +3104,30 @@ int _lttng_struct_field_statedump(struct lttng_session *session,
  */
 static
 int _lttng_variant_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_variant *type,
                size_t nesting)
 {
        int ret;
        uint32_t i, nr_choices;
 
-       WARN_ON_ONCE(type->type != lttng_kernel_type_variant_nestable);
        /*
         * CTF 1.8 does not allow expressing nonzero variant alignment in a nestable way.
         */
-       if (type->u.variant_nestable.alignment != 0)
+       if (type->alignment != 0)
                return -EINVAL;
        ret = print_tabs(session, nesting);
        if (ret)
                return ret;
        ret = lttng_metadata_printf(session,
                "variant <_%s> {\n",
-               type->u.variant_nestable.tag_name);
+               type->tag_name);
        if (ret)
                return ret;
-       nr_choices = type->u.variant_nestable.nr_choices;
+       nr_choices = type->nr_choices;
        for (i = 0; i < nr_choices; i++) {
-               const struct lttng_event_field *iter_field;
+               const struct lttng_kernel_event_field *iter_field;
 
-               iter_field = &type->u.variant_nestable.choices[i];
+               iter_field = type->choices[i];
                ret = _lttng_field_statedump(session, iter_field, nesting + 1);
                if (ret)
                        return ret;
@@ -3147,13 +3145,13 @@ int _lttng_variant_type_statedump(struct lttng_session *session,
  */
 static
 int _lttng_variant_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret;
 
        ret = _lttng_variant_type_statedump(session,
-                       &field->type, nesting);
+                       lttng_kernel_get_type_variant(field->type), nesting);
        if (ret)
                return ret;
        return lttng_field_name_statedump(session, field, nesting);
@@ -3164,21 +3162,23 @@ int _lttng_variant_field_statedump(struct lttng_session *session,
  */
 static
 int _lttng_array_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret;
-       const struct lttng_type *elem_type;
+       const struct lttng_kernel_type_array *array_type;
+       const struct lttng_kernel_type_common *elem_type;
 
-       WARN_ON_ONCE(field->type.type != lttng_kernel_type_array_nestable);
+       array_type = lttng_kernel_get_type_array(field->type);
+       WARN_ON_ONCE(!array_type);
 
-       if (field->type.u.array_nestable.alignment) {
+       if (array_type->alignment) {
                ret = print_tabs(session, nesting);
                if (ret)
                        return ret;
                ret = lttng_metadata_printf(session,
                "struct { } align(%u) _%s_padding;\n",
-                               field->type.u.array_nestable.alignment * CHAR_BIT,
+                               array_type->alignment * CHAR_BIT,
                                field->name);
                if (ret)
                        return ret;
@@ -3187,12 +3187,13 @@ int _lttng_array_field_statedump(struct lttng_session *session,
         * Nested compound types: Only array of structures and variants are
         * currently supported.
         */
-       elem_type = field->type.u.array_nestable.elem_type;
+       elem_type = array_type->elem_type;
        switch (elem_type->type) {
        case lttng_kernel_type_integer:
-       case lttng_kernel_type_struct_nestable:
-       case lttng_kernel_type_variant_nestable:
-               ret = _lttng_type_statedump(session, elem_type, nesting);
+       case lttng_kernel_type_struct:
+       case lttng_kernel_type_variant:
+               ret = _lttng_type_statedump(session, elem_type,
+                               array_type->encoding, nesting);
                if (ret)
                        return ret;
                break;
@@ -3203,7 +3204,7 @@ int _lttng_array_field_statedump(struct lttng_session *session,
        ret = lttng_metadata_printf(session,
                " _%s[%u];\n",
                field->name,
-               field->type.u.array_nestable.length);
+               array_type->length);
        return ret;
 }
 
@@ -3212,24 +3213,26 @@ int _lttng_array_field_statedump(struct lttng_session *session,
  */
 static
 int _lttng_sequence_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret;
        const char *length_name;
-       const struct lttng_type *elem_type;
+       const struct lttng_kernel_type_sequence *sequence_type;
+       const struct lttng_kernel_type_common *elem_type;
 
-       WARN_ON_ONCE(field->type.type != lttng_kernel_type_sequence_nestable);
+       sequence_type = lttng_kernel_get_type_sequence(field->type);
+       WARN_ON_ONCE(!sequence_type);
 
-       length_name = field->type.u.sequence_nestable.length_name;
+       length_name = sequence_type->length_name;
 
-       if (field->type.u.sequence_nestable.alignment) {
+       if (sequence_type->alignment) {
                ret = print_tabs(session, nesting);
                if (ret)
                        return ret;
                ret = lttng_metadata_printf(session,
                "struct { } align(%u) _%s_padding;\n",
-                               field->type.u.sequence_nestable.alignment * CHAR_BIT,
+                               sequence_type->alignment * CHAR_BIT,
                                field->name);
                if (ret)
                        return ret;
@@ -3239,12 +3242,13 @@ int _lttng_sequence_field_statedump(struct lttng_session *session,
         * Nested compound types: Only array of structures and variants are
         * currently supported.
         */
-       elem_type = field->type.u.sequence_nestable.elem_type;
+       elem_type = sequence_type->elem_type;
        switch (elem_type->type) {
        case lttng_kernel_type_integer:
-       case lttng_kernel_type_struct_nestable:
-       case lttng_kernel_type_variant_nestable:
-               ret = _lttng_type_statedump(session, elem_type, nesting);
+       case lttng_kernel_type_struct:
+       case lttng_kernel_type_variant:
+               ret = _lttng_type_statedump(session, elem_type,
+                               sequence_type->encoding, nesting);
                if (ret)
                        return ret;
                break;
@@ -3255,7 +3259,7 @@ int _lttng_sequence_field_statedump(struct lttng_session *session,
        ret = lttng_metadata_printf(session,
                " _%s[ _%s ];\n",
                field->name,
-               field->type.u.sequence_nestable.length_name);
+               sequence_type->length_name);
        return ret;
 }
 
@@ -3264,20 +3268,20 @@ int _lttng_sequence_field_statedump(struct lttng_session *session,
  */
 static
 int _lttng_enum_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_enum *type,
                size_t nesting)
 {
        const struct lttng_kernel_enum_desc *enum_desc;
-       const struct lttng_type *container_type;
+       const struct lttng_kernel_type_common *container_type;
        int ret;
        unsigned int i, nr_entries;
 
-       container_type = type->u.enum_nestable.container_type;
+       container_type = type->container_type;
        if (container_type->type != lttng_kernel_type_integer) {
                ret = -EINVAL;
                goto end;
        }
-       enum_desc = type->u.enum_nestable.desc;
+       enum_desc = type->desc;
        nr_entries = enum_desc->nr_entries;
 
        ret = print_tabs(session, nesting);
@@ -3286,7 +3290,8 @@ int _lttng_enum_type_statedump(struct lttng_session *session,
        ret = lttng_metadata_printf(session, "enum : ");
        if (ret)
                goto end;
-       ret = _lttng_integer_type_statedump(session, container_type, 0);
+       ret = _lttng_integer_type_statedump(session, lttng_kernel_get_type_integer(container_type),
+                       lttng_kernel_string_encoding_none, 0);
        if (ret)
                goto end;
        ret = lttng_metadata_printf(session, " {\n");
@@ -3294,7 +3299,7 @@ int _lttng_enum_type_statedump(struct lttng_session *session,
                goto end;
        /* Dump all entries */
        for (i = 0; i < nr_entries; i++) {
-               const struct lttng_kernel_enum_entry *entry = &enum_desc->entries[i];
+               const struct lttng_kernel_enum_entry *entry = enum_desc->entries[i];
                int j, len;
 
                ret = print_tabs(session, nesting + 1);
@@ -3380,12 +3385,15 @@ end:
  */
 static
 int _lttng_enum_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret;
+       const struct lttng_kernel_type_enum *enum_type;
 
-       ret = _lttng_enum_type_statedump(session, &field->type, nesting);
+       enum_type = lttng_kernel_get_type_enum(field->type);
+       WARN_ON_ONCE(!enum_type);
+       ret = _lttng_enum_type_statedump(session, enum_type, nesting);
        if (ret)
                return ret;
        return lttng_field_name_statedump(session, field, nesting);
@@ -3393,12 +3401,13 @@ int _lttng_enum_field_statedump(struct lttng_session *session,
 
 static
 int _lttng_integer_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret;
 
-       ret = _lttng_integer_type_statedump(session, &field->type, nesting);
+       ret = _lttng_integer_type_statedump(session, lttng_kernel_get_type_integer(field->type),
+                       lttng_kernel_string_encoding_none, nesting);
        if (ret)
                return ret;
        return lttng_field_name_statedump(session, field, nesting);
@@ -3406,32 +3415,33 @@ int _lttng_integer_field_statedump(struct lttng_session *session,
 
 static
 int _lttng_string_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_string *type,
                size_t nesting)
 {
        int ret;
 
-       WARN_ON_ONCE(type->type != lttng_kernel_type_string);
        /* Default encoding is UTF8 */
        ret = print_tabs(session, nesting);
        if (ret)
                return ret;
        ret = lttng_metadata_printf(session,
                "string%s",
-               type->u.string.encoding == lttng_kernel_string_encoding_ASCII ?
+               type->encoding == lttng_kernel_string_encoding_ASCII ?
                        " { encoding = ASCII; }" : "");
        return ret;
 }
 
 static
 int _lttng_string_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
+       const struct lttng_kernel_type_string *string_type;
        int ret;
 
-       WARN_ON_ONCE(field->type.type != lttng_kernel_type_string);
-       ret = _lttng_string_type_statedump(session, &field->type, nesting);
+       string_type = lttng_kernel_get_type_string(field->type);
+       WARN_ON_ONCE(!string_type);
+       ret = _lttng_string_type_statedump(session, string_type, nesting);
        if (ret)
                return ret;
        return lttng_field_name_statedump(session, field, nesting);
@@ -3442,31 +3452,42 @@ int _lttng_string_field_statedump(struct lttng_session *session,
  */
 static
 int _lttng_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_common *type,
+               enum lttng_kernel_string_encoding parent_encoding,
                size_t nesting)
 {
        int ret = 0;
 
        switch (type->type) {
        case lttng_kernel_type_integer:
-               ret = _lttng_integer_type_statedump(session, type, nesting);
+               ret = _lttng_integer_type_statedump(session,
+                               lttng_kernel_get_type_integer(type),
+                               parent_encoding, nesting);
                break;
-       case lttng_kernel_type_enum_nestable:
-               ret = _lttng_enum_type_statedump(session, type, nesting);
+       case lttng_kernel_type_enum:
+               ret = _lttng_enum_type_statedump(session,
+                               lttng_kernel_get_type_enum(type),
+                               nesting);
                break;
        case lttng_kernel_type_string:
-               ret = _lttng_string_type_statedump(session, type, nesting);
+               ret = _lttng_string_type_statedump(session,
+                               lttng_kernel_get_type_string(type),
+                               nesting);
                break;
-       case lttng_kernel_type_struct_nestable:
-               ret = _lttng_struct_type_statedump(session, type, nesting);
+       case lttng_kernel_type_struct:
+               ret = _lttng_struct_type_statedump(session,
+                               lttng_kernel_get_type_struct(type),
+                               nesting);
                break;
-       case lttng_kernel_type_variant_nestable:
-               ret = _lttng_variant_type_statedump(session, type, nesting);
+       case lttng_kernel_type_variant:
+               ret = _lttng_variant_type_statedump(session,
+                               lttng_kernel_get_type_variant(type),
+                               nesting);
                break;
 
        /* Nested arrays and sequences are not supported yet. */
-       case lttng_kernel_type_array_nestable:
-       case lttng_kernel_type_sequence_nestable:
+       case lttng_kernel_type_array:
+       case lttng_kernel_type_sequence:
        default:
                WARN_ON_ONCE(1);
                return -EINVAL;
@@ -3479,31 +3500,31 @@ int _lttng_type_statedump(struct lttng_session *session,
  */
 static
 int _lttng_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret = 0;
 
-       switch (field->type.type) {
+       switch (field->type->type) {
        case lttng_kernel_type_integer:
                ret = _lttng_integer_field_statedump(session, field, nesting);
                break;
-       case lttng_kernel_type_enum_nestable:
+       case lttng_kernel_type_enum:
                ret = _lttng_enum_field_statedump(session, field, nesting);
                break;
        case lttng_kernel_type_string:
                ret = _lttng_string_field_statedump(session, field, nesting);
                break;
-       case lttng_kernel_type_struct_nestable:
+       case lttng_kernel_type_struct:
                ret = _lttng_struct_field_statedump(session, field, nesting);
                break;
-       case lttng_kernel_type_array_nestable:
+       case lttng_kernel_type_array:
                ret = _lttng_array_field_statedump(session, field, nesting);
                break;
-       case lttng_kernel_type_sequence_nestable:
+       case lttng_kernel_type_sequence:
                ret = _lttng_sequence_field_statedump(session, field, nesting);
                break;
-       case lttng_kernel_type_variant_nestable:
+       case lttng_kernel_type_variant:
                ret = _lttng_variant_field_statedump(session, field, nesting);
                break;
 
@@ -3516,7 +3537,7 @@ int _lttng_field_statedump(struct lttng_session *session,
 
 static
 int _lttng_context_metadata_statedump(struct lttng_session *session,
-                                   struct lttng_ctx *ctx)
+                                   struct lttng_kernel_ctx *ctx)
 {
        int ret = 0;
        int i;
@@ -3524,9 +3545,9 @@ int _lttng_context_metadata_statedump(struct lttng_session *session,
        if (!ctx)
                return 0;
        for (i = 0; i < ctx->nr_fields; i++) {
-               const struct lttng_ctx_field *field = &ctx->fields[i];
+               const struct lttng_kernel_ctx_field *field = &ctx->fields[i];
 
-               ret = _lttng_field_statedump(session, &field->event_field, 2);
+               ret = _lttng_field_statedump(session, field->event_field, 2);
                if (ret)
                        return ret;
        }
@@ -3537,12 +3558,12 @@ static
 int _lttng_fields_metadata_statedump(struct lttng_session *session,
                                   struct lttng_event *event)
 {
-       const struct lttng_event_desc *desc = event->desc;
+       const struct lttng_kernel_event_desc *desc = event->desc;
        int ret = 0;
        int i;
 
        for (i = 0; i < desc->nr_fields; i++) {
-               const struct lttng_event_field *field = &desc->fields[i];
+               const struct lttng_kernel_event_field *field = desc->fields[i];
 
                ret = _lttng_field_statedump(session, field, 2);
                if (ret)
@@ -3575,7 +3596,7 @@ int _lttng_event_metadata_statedump(struct lttng_session *session,
                "       name = \"%s\";\n"
                "       id = %u;\n"
                "       stream_id = %u;\n",
-               event->desc->name,
+               event->desc->event_name,
                event->id,
                event->chan->id);
        if (ret)
index 3033094bbb88f6ec4e43d3d319dd422e339c64fa..a320b6287948ab3225cdaa69622f0348f48f05d8 100644 (file)
@@ -39,25 +39,25 @@ EXPORT_PER_CPU_SYMBOL_GPL(lttng_dynamic_len_stack);
  * Called under sessions lock.
  */
 static
-int check_event_provider(struct lttng_probe_desc *desc)
+int check_event_provider(struct lttng_kernel_probe_desc *desc)
 {
        int i;
        size_t provider_name_len;
 
-       provider_name_len = strnlen(desc->provider,
+       provider_name_len = strnlen(desc->provider_name,
                                LTTNG_KERNEL_SYM_NAME_LEN - 1);
        for (i = 0; i < desc->nr_events; i++) {
-               if (strncmp(desc->event_desc[i]->name,
-                               desc->provider,
+               if (strncmp(desc->event_desc[i]->event_name,
+                               desc->provider_name,
                                provider_name_len))
                        return 0;       /* provider mismatch */
                /*
                 * The event needs to contain at least provider name + _ +
                 * one or more letter.
                 */
-               if (strlen(desc->event_desc[i]->name) <= provider_name_len + 1)
+               if (strlen(desc->event_desc[i]->event_name) <= provider_name_len + 1)
                        return 0;       /* provider mismatch */
-               if (desc->event_desc[i]->name[provider_name_len] != '_')
+               if (desc->event_desc[i]->event_name[provider_name_len] != '_')
                        return 0;       /* provider mismatch */
        }
        return 1;
@@ -67,9 +67,9 @@ int check_event_provider(struct lttng_probe_desc *desc)
  * Called under sessions lock.
  */
 static
-void lttng_lazy_probe_register(struct lttng_probe_desc *desc)
+void lttng_lazy_probe_register(struct lttng_kernel_probe_desc *desc)
 {
-       struct lttng_probe_desc *iter;
+       struct lttng_kernel_probe_desc *iter;
        struct list_head *probe_list;
 
        /*
@@ -87,7 +87,7 @@ void lttng_lazy_probe_register(struct lttng_probe_desc *desc)
         */
 
        /*
-        * We sort the providers by struct lttng_probe_desc pointer
+        * We sort the providers by struct lttng_kernel_probe_desc pointer
         * address.
         */
        probe_list = &_probe_list;
@@ -103,7 +103,7 @@ void lttng_lazy_probe_register(struct lttng_probe_desc *desc)
        list_add(&desc->head, probe_list);
 desc_added:
        pr_debug("LTTng: just registered probe %s containing %u events\n",
-               desc->provider, desc->nr_events);
+               desc->provider_name, desc->nr_events);
 }
 
 /*
@@ -112,7 +112,7 @@ desc_added:
 static
 void fixup_lazy_probes(void)
 {
-       struct lttng_probe_desc *iter, *tmp;
+       struct lttng_kernel_probe_desc *iter, *tmp;
        int ret;
 
        lazy_nesting++;
@@ -140,20 +140,20 @@ struct list_head *lttng_get_probe_list_head(void)
 }
 
 static
-const struct lttng_probe_desc *find_provider(const char *provider)
+const struct lttng_kernel_probe_desc *find_provider(const char *provider)
 {
-       struct lttng_probe_desc *iter;
+       struct lttng_kernel_probe_desc *iter;
        struct list_head *probe_list;
 
        probe_list = lttng_get_probe_list_head();
        list_for_each_entry(iter, probe_list, head) {
-               if (!strcmp(iter->provider, provider))
+               if (!strcmp(iter->provider_name, provider))
                        return iter;
        }
        return NULL;
 }
 
-int lttng_probe_register(struct lttng_probe_desc *desc)
+int lttng_probe_register(struct lttng_kernel_probe_desc *desc)
 {
        int ret = 0;
 
@@ -162,14 +162,14 @@ int lttng_probe_register(struct lttng_probe_desc *desc)
        /*
         * Check if the provider has already been registered.
         */
-       if (find_provider(desc->provider)) {
+       if (find_provider(desc->provider_name)) {
                ret = -EEXIST;
                goto end;
        }
        list_add(&desc->lazy_init_head, &lazy_probe_init);
        desc->lazy = 1;
        pr_debug("LTTng: adding probe %s containing %u events to lazy registration list\n",
-               desc->provider, desc->nr_events);
+               desc->provider_name, desc->nr_events);
        /*
         * If there is at least one active session, we need to register
         * the probe immediately, since we cannot delay event
@@ -183,14 +183,14 @@ end:
 }
 EXPORT_SYMBOL_GPL(lttng_probe_register);
 
-void lttng_probe_unregister(struct lttng_probe_desc *desc)
+void lttng_probe_unregister(struct lttng_kernel_probe_desc *desc)
 {
        lttng_lock_sessions();
        if (!desc->lazy)
                list_del(&desc->head);
        else
                list_del(&desc->lazy_init_head);
-       pr_debug("LTTng: just unregistered probe %s\n", desc->provider);
+       pr_debug("LTTng: just unregistered probe %s\n", desc->provider_name);
        lttng_unlock_sessions();
 }
 EXPORT_SYMBOL_GPL(lttng_probe_unregister);
@@ -200,14 +200,14 @@ EXPORT_SYMBOL_GPL(lttng_probe_unregister);
  * Called with sessions lock held.
  */
 static
-const struct lttng_event_desc *find_event_desc(const char *name)
+const struct lttng_kernel_event_desc *find_event_desc(const char *name)
 {
-       struct lttng_probe_desc *probe_desc;
+       struct lttng_kernel_probe_desc *probe_desc;
        int i;
 
        list_for_each_entry(probe_desc, &_probe_list, head) {
                for (i = 0; i < probe_desc->nr_events; i++) {
-                       if (!strcmp(probe_desc->event_desc[i]->name, name))
+                       if (!strcmp(probe_desc->event_desc[i]->event_name, name))
                                return probe_desc->event_desc[i];
                        }
        }
@@ -217,9 +217,9 @@ const struct lttng_event_desc *find_event_desc(const char *name)
 /*
  * Called with sessions lock held.
  */
-const struct lttng_event_desc *lttng_event_desc_get(const char *name)
+const struct lttng_kernel_event_desc *lttng_event_desc_get(const char *name)
 {
-       const struct lttng_event_desc *event_desc;
+       const struct lttng_kernel_event_desc *event_desc;
        int ret;
 
        event_desc = find_event_desc(name);
@@ -234,7 +234,7 @@ EXPORT_SYMBOL_GPL(lttng_event_desc_get);
 /*
  * Called with sessions lock held.
  */
-void lttng_event_desc_put(const struct lttng_event_desc *event_desc)
+void lttng_event_desc_put(const struct lttng_kernel_event_desc *event_desc)
 {
        module_put(event_desc->owner);
 }
@@ -243,7 +243,7 @@ EXPORT_SYMBOL_GPL(lttng_event_desc_put);
 static
 void *tp_list_start(struct seq_file *m, loff_t *pos)
 {
-       struct lttng_probe_desc *probe_desc;
+       struct lttng_kernel_probe_desc *probe_desc;
        struct list_head *probe_list;
        int iter = 0, i;
 
@@ -262,7 +262,7 @@ void *tp_list_start(struct seq_file *m, loff_t *pos)
 static
 void *tp_list_next(struct seq_file *m, void *p, loff_t *ppos)
 {
-       struct lttng_probe_desc *probe_desc;
+       struct lttng_kernel_probe_desc *probe_desc;
        struct list_head *probe_list;
        int iter = 0, i;
 
@@ -287,10 +287,10 @@ void tp_list_stop(struct seq_file *m, void *p)
 static
 int tp_list_show(struct seq_file *m, void *p)
 {
-       const struct lttng_event_desc *probe_desc = p;
+       const struct lttng_kernel_event_desc *probe_desc = p;
 
        seq_printf(m,   "event { name = %s; };\n",
-                  probe_desc->name);
+                  probe_desc->event_name);
        return 0;
 }
 
index 4f8699c0227aa7c844d3e3db6ef3c33e32f32bea..6055d66bc63ee1437b3d3d4fc8a45e520a7e65d0 100644 (file)
@@ -74,7 +74,7 @@ static inline notrace u64 lib_ring_buffer_clock_read(struct channel *chan)
 }
 
 static inline
-size_t ctx_get_aligned_size(size_t offset, struct lttng_ctx *ctx,
+size_t ctx_get_aligned_size(size_t offset, struct lttng_kernel_ctx *ctx,
                size_t ctx_len)
 {
        size_t orig_offset = offset;
@@ -87,7 +87,7 @@ size_t ctx_get_aligned_size(size_t offset, struct lttng_ctx *ctx,
 }
 
 static inline
-void ctx_get_struct_size(struct lttng_ctx *ctx, size_t *ctx_len,
+void ctx_get_struct_size(struct lttng_kernel_ctx *ctx, size_t *ctx_len,
                struct lttng_channel *chan, struct lib_ring_buffer_ctx *bufctx)
 {
        int i;
@@ -110,7 +110,7 @@ void ctx_get_struct_size(struct lttng_ctx *ctx, size_t *ctx_len,
 static inline
 void ctx_record(struct lib_ring_buffer_ctx *bufctx,
                struct lttng_channel *chan,
-               struct lttng_ctx *ctx)
+               struct lttng_kernel_ctx *ctx)
 {
        int i;
 
index 3fce0914d2d6a392f955cb724915373e4a830abc..de84a18be2f41c1e6731e5868ab1c8fe5260933a 100644 (file)
@@ -294,8 +294,8 @@ typedef __kernel_old_time_t time_t;
 struct trace_syscall_entry {
        void *event_func;
        void *event_notifier_func;
-       const struct lttng_event_desc *desc;
-       const struct lttng_event_field *fields;
+       const struct lttng_kernel_event_desc *desc;
+       const struct lttng_kernel_event_field **fields;
        unsigned int nrargs;
 };
 
@@ -1111,7 +1111,7 @@ int lttng_create_syscall_event_if_missing(const struct trace_syscall_entry *tabl
 
        /* Allocate events for each syscall matching enabler, insert into table */
        for (i = 0; i < table_len; i++) {
-               const struct lttng_event_desc *desc = table[i].desc;
+               const struct lttng_kernel_event_desc *desc = table[i].desc;
                struct lttng_kernel_event ev;
                struct lttng_event *event;
                struct hlist_head *head;
@@ -1129,7 +1129,7 @@ int lttng_create_syscall_event_if_missing(const struct trace_syscall_entry *tabl
                 */
                head = utils_borrow_hash_table_bucket(
                        session->events_ht.table, LTTNG_EVENT_HT_SIZE,
-                       desc->name);
+                       desc->event_name);
                lttng_hlist_for_each_entry(event, head, hlist) {
                        if (event->desc == desc
                                && event->chan == event_enabler->chan)
@@ -1158,7 +1158,7 @@ int lttng_create_syscall_event_if_missing(const struct trace_syscall_entry *tabl
                        ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT;
                        break;
                }
-               strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN - 1);
+               strncpy(ev.name, desc->event_name, LTTNG_KERNEL_SYM_NAME_LEN - 1);
                ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
                ev.instrumentation = LTTNG_KERNEL_SYSCALL;
                event = _lttng_event_create(chan, &ev, filter,
@@ -1223,12 +1223,12 @@ int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler, voi
        }
 #endif
        if (hlist_empty(&chan->sc_unknown)) {
-               const struct lttng_event_desc *desc =
+               const struct lttng_kernel_event_desc *desc =
                        &__event_desc___syscall_entry_unknown;
                struct lttng_event *event;
 
                memset(&ev, 0, sizeof(ev));
-               strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
+               strncpy(ev.name, desc->event_name, LTTNG_KERNEL_SYM_NAME_LEN);
                ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
                ev.instrumentation = LTTNG_KERNEL_SYSCALL;
                ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY;
@@ -1243,12 +1243,12 @@ int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler, voi
        }
 
        if (hlist_empty(&chan->sc_compat_unknown)) {
-               const struct lttng_event_desc *desc =
+               const struct lttng_kernel_event_desc *desc =
                        &__event_desc___compat_syscall_entry_unknown;
                struct lttng_event *event;
 
                memset(&ev, 0, sizeof(ev));
-               strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
+               strncpy(ev.name, desc->event_name, LTTNG_KERNEL_SYM_NAME_LEN);
                ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
                ev.instrumentation = LTTNG_KERNEL_SYSCALL;
                ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY;
@@ -1263,12 +1263,12 @@ int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler, voi
        }
 
        if (hlist_empty(&chan->compat_sc_exit_unknown)) {
-               const struct lttng_event_desc *desc =
+               const struct lttng_kernel_event_desc *desc =
                        &__event_desc___compat_syscall_exit_unknown;
                struct lttng_event *event;
 
                memset(&ev, 0, sizeof(ev));
-               strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
+               strncpy(ev.name, desc->event_name, LTTNG_KERNEL_SYM_NAME_LEN);
                ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
                ev.instrumentation = LTTNG_KERNEL_SYSCALL;
                ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT;
@@ -1283,12 +1283,12 @@ int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler, voi
        }
 
        if (hlist_empty(&chan->sc_exit_unknown)) {
-               const struct lttng_event_desc *desc =
+               const struct lttng_kernel_event_desc *desc =
                        &__event_desc___syscall_exit_unknown;
                struct lttng_event *event;
 
                memset(&ev, 0, sizeof(ev));
-               strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
+               strncpy(ev.name, desc->event_name, LTTNG_KERNEL_SYM_NAME_LEN);
                ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
                ev.instrumentation = LTTNG_KERNEL_SYSCALL;
                ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT;
@@ -1465,7 +1465,7 @@ int create_unknown_event_notifier(
                enum sc_type type)
 {
        struct lttng_event_notifier *notifier;
-       const struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_desc *desc;
        struct lttng_event_notifier_group *group = event_notifier_enabler->group;
        struct lttng_kernel_event_notifier event_notifier_param;
        uint64_t user_token = event_notifier_enabler->base.user_token;
@@ -1512,7 +1512,7 @@ int create_unknown_event_notifier(
         * Check if already created.
         */
        head = utils_borrow_hash_table_bucket(group->event_notifiers_ht.table,
-               LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->name);
+               LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->event_name);
        lttng_hlist_for_each_entry(notifier, head, hlist) {
                if (notifier->desc == desc &&
                                notifier->user_token == base_enabler->user_token)
@@ -1522,7 +1522,7 @@ int create_unknown_event_notifier(
                goto end;
 
        memset(&event_notifier_param, 0, sizeof(event_notifier_param));
-       strncat(event_notifier_param.event.name, desc->name,
+       strncat(event_notifier_param.event.name, desc->event_name,
                LTTNG_KERNEL_SYM_NAME_LEN - strlen(event_notifier_param.event.name) - 1);
 
        event_notifier_param.event.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
@@ -1536,7 +1536,7 @@ int create_unknown_event_notifier(
                event_notifier_param.event.instrumentation);
        if (IS_ERR(notifier)) {
                printk(KERN_INFO "Unable to create unknown notifier %s\n",
-                       desc->name);
+                       desc->event_name);
                ret = -ENOMEM;
                goto end;
        }
@@ -1553,7 +1553,7 @@ static int create_matching_event_notifiers(
                size_t table_len, enum sc_type type)
 {
        struct lttng_event_notifier_group *group = event_notifier_enabler->group;
-       const struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_desc *desc;
        uint64_t user_token = event_notifier_enabler->base.user_token;
        uint64_t error_counter_index = event_notifier_enabler->error_counter_index;
        unsigned int i;
@@ -1580,7 +1580,7 @@ static int create_matching_event_notifiers(
                 * Check if already created.
                 */
                head = utils_borrow_hash_table_bucket(group->event_notifiers_ht.table,
-                       LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->name);
+                       LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->event_name);
                lttng_hlist_for_each_entry(event_notifier, head, hlist) {
                        if (event_notifier->desc == desc
                                && event_notifier->user_token == event_notifier_enabler->base.user_token)
@@ -1608,7 +1608,7 @@ static int create_matching_event_notifiers(
                        event_notifier_param.event.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT;
                        break;
                }
-               strncat(event_notifier_param.event.name, desc->name,
+               strncat(event_notifier_param.event.name, desc->event_name,
                        LTTNG_KERNEL_SYM_NAME_LEN - strlen(event_notifier_param.event.name) - 1);
                event_notifier_param.event.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
                event_notifier_param.event.instrumentation = LTTNG_KERNEL_SYSCALL;
@@ -1618,7 +1618,7 @@ static int create_matching_event_notifiers(
                        filter, event_notifier_param.event.instrumentation);
                if (IS_ERR(event_notifier)) {
                        printk(KERN_INFO "Unable to create event_notifier %s\n",
-                               desc->name);
+                               desc->event_name);
                        ret = -ENOMEM;
                        goto end;
                }
@@ -1777,7 +1777,7 @@ int get_syscall_nr(const char *syscall_name)
                entry = &sc_table[i];
                if (!entry->desc)
                        continue;
-               it_name = entry->desc->name;
+               it_name = entry->desc->event_name;
                it_name += strlen(SYSCALL_ENTRY_STR);
                if (!strcmp(syscall_name, it_name)) {
                        syscall_nr = i;
@@ -1800,7 +1800,7 @@ int get_compat_syscall_nr(const char *syscall_name)
                entry = &compat_sc_table[i];
                if (!entry->desc)
                        continue;
-               it_name = entry->desc->name;
+               it_name = entry->desc->event_name;
                it_name += strlen(COMPAT_SYSCALL_ENTRY_STR);
                if (!strcmp(syscall_name, it_name)) {
                        syscall_nr = i;
@@ -1920,7 +1920,7 @@ int lttng_syscall_filter_enable_event_notifier(
        WARN_ON_ONCE(notifier->instrumentation != LTTNG_KERNEL_SYSCALL);
 
        ret = lttng_syscall_filter_enable(group->sc_filter,
-               notifier->desc->name, notifier->u.syscall.abi,
+               notifier->desc->event_name, notifier->u.syscall.abi,
                notifier->u.syscall.entryexit);
        if (ret) {
                goto end;
@@ -1971,7 +1971,7 @@ int lttng_syscall_filter_enable_event(
        WARN_ON_ONCE(event->instrumentation != LTTNG_KERNEL_SYSCALL);
 
        return lttng_syscall_filter_enable(channel->sc_filter,
-               event->desc->name, event->u.syscall.abi,
+               event->desc->event_name, event->u.syscall.abi,
                event->u.syscall.entryexit);
 }
 
@@ -2044,7 +2044,7 @@ int lttng_syscall_filter_disable_event_notifier(
        WARN_ON_ONCE(notifier->instrumentation != LTTNG_KERNEL_SYSCALL);
 
        ret = lttng_syscall_filter_disable(group->sc_filter,
-               notifier->desc->name, notifier->u.syscall.abi,
+               notifier->desc->event_name, notifier->u.syscall.abi,
                notifier->u.syscall.entryexit);
        WARN_ON_ONCE(ret != 0);
 
@@ -2057,7 +2057,7 @@ int lttng_syscall_filter_disable_event(
                struct lttng_event *event)
 {
        return lttng_syscall_filter_disable(channel->sc_filter,
-               event->desc->name, event->u.syscall.abi,
+               event->desc->event_name, event->u.syscall.abi,
                event->u.syscall.entryexit);
 }
 
@@ -2140,10 +2140,10 @@ int syscall_list_show(struct seq_file *m, void *p)
                return 0;
        if (table == sc_table) {
                index = entry - table;
-               name = &entry->desc->name[strlen(SYSCALL_ENTRY_STR)];
+               name = &entry->desc->event_name[strlen(SYSCALL_ENTRY_STR)];
        } else {
                index = (entry - table) + ARRAY_SIZE(sc_table);
-               name = &entry->desc->name[strlen(COMPAT_SYSCALL_ENTRY_STR)];
+               name = &entry->desc->event_name[strlen(COMPAT_SYSCALL_ENTRY_STR)];
        }
        seq_printf(m,   "syscall { index = %lu; name = %s; bitness = %u; };\n",
                index, name, bitness);
index 01bc16e4e534cf6c5f02544455252f3df192eb32..6e8cb20f2600380d197a52d8fcc9fe6dcb2a73b3 100644 (file)
@@ -65,46 +65,52 @@ int lttng_kprobes_event_notifier_handler_pre(struct kprobe *p, struct pt_regs *r
        return 0;
 }
 
+static const struct lttng_kernel_type_common *event_type =
+       lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16);
+
 /*
  * Create event description
  */
 static
 int lttng_create_kprobe_event(const char *name, struct lttng_event *event)
 {
-       struct lttng_event_field *field;
-       struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_field **fieldp_array;
+       struct lttng_kernel_event_field *field;
+       struct lttng_kernel_event_desc *desc;
        int ret;
 
-       desc = kzalloc(sizeof(*event->desc), GFP_KERNEL);
+       desc = kzalloc(sizeof(*desc), GFP_KERNEL);
        if (!desc)
                return -ENOMEM;
-       desc->name = kstrdup(name, GFP_KERNEL);
-       if (!desc->name) {
+       desc->event_name = kstrdup(name, GFP_KERNEL);
+       if (!desc->event_name) {
                ret = -ENOMEM;
                goto error_str;
        }
        desc->nr_fields = 1;
-       desc->fields = field =
-               kzalloc(1 * sizeof(struct lttng_event_field), GFP_KERNEL);
+       fieldp_array = kzalloc(1 * sizeof(struct lttng_kernel_event_field *), GFP_KERNEL);
+       if (!fieldp_array) {
+               ret = -ENOMEM;
+               goto error_fieldp_array;
+       }
+       desc->fields = fieldp_array;
+       desc->fields[0] = field =
+               kzalloc(sizeof(struct lttng_kernel_event_field), GFP_KERNEL);
        if (!field) {
                ret = -ENOMEM;
                goto error_field;
        }
        field->name = "ip";
-       field->type.type = lttng_kernel_type_integer;
-       field->type.u.integer.size = sizeof(unsigned long) * CHAR_BIT;
-       field->type.u.integer.alignment = lttng_alignof(unsigned long) * CHAR_BIT;
-       field->type.u.integer.signedness = lttng_is_signed_type(unsigned long);
-       field->type.u.integer.reverse_byte_order = 0;
-       field->type.u.integer.base = 16;
-       field->type.u.integer.encoding = lttng_kernel_string_encoding_none;
+       field->type = event_type;
        desc->owner = THIS_MODULE;
        event->desc = desc;
 
        return 0;
 
 error_field:
-       kfree(desc->name);
+       kfree(fieldp_array);
+error_fieldp_array:
+       kfree(desc->event_name);
 error_str:
        kfree(desc);
        return ret;
@@ -116,14 +122,14 @@ error_str:
 static
 int lttng_create_kprobe_event_notifier(const char *name, struct lttng_event_notifier *event_notifier)
 {
-       struct lttng_event_desc *desc;
+       struct lttng_kernel_event_desc *desc;
        int ret;
 
-       desc = kzalloc(sizeof(*event_notifier->desc), GFP_KERNEL);
+       desc = kzalloc(sizeof(*desc), GFP_KERNEL);
        if (!desc)
                return -ENOMEM;
-       desc->name = kstrdup(name, GFP_KERNEL);
-       if (!desc->name) {
+       desc->event_name = kstrdup(name, GFP_KERNEL);
+       if (!desc->event_name) {
                ret = -ENOMEM;
                goto error_str;
        }
@@ -211,7 +217,7 @@ int lttng_kprobes_register_event(const char *name,
 
 register_error:
        kfree(event->desc->fields);
-       kfree(event->desc->name);
+       kfree(event->desc->event_name);
        kfree(event->desc);
 error:
        return ret;
@@ -236,7 +242,7 @@ int lttng_kprobes_register_event_notifier(const char *symbol_name,
        return 0;
 
 register_error:
-       kfree(event_notifier->desc->name);
+       kfree(event_notifier->desc->event_name);
        kfree(event_notifier->desc);
 error:
        return ret;
@@ -258,8 +264,9 @@ EXPORT_SYMBOL_GPL(lttng_kprobes_unregister_event_notifier);
 void lttng_kprobes_destroy_event_private(struct lttng_event *event)
 {
        kfree(event->u.kprobe.symbol_name);
+       kfree(event->desc->fields[0]);
        kfree(event->desc->fields);
-       kfree(event->desc->name);
+       kfree(event->desc->event_name);
        kfree(event->desc);
 }
 EXPORT_SYMBOL_GPL(lttng_kprobes_destroy_event_private);
@@ -267,7 +274,7 @@ EXPORT_SYMBOL_GPL(lttng_kprobes_destroy_event_private);
 void lttng_kprobes_destroy_event_notifier_private(struct lttng_event_notifier *event_notifier)
 {
        kfree(event_notifier->u.kprobe.symbol_name);
-       kfree(event_notifier->desc->name);
+       kfree(event_notifier->desc->event_name);
        kfree(event_notifier->desc);
 }
 EXPORT_SYMBOL_GPL(lttng_kprobes_destroy_event_notifier_private);
index c9991d9105145fa89e16b4424760a7bd4a97e09d..6b794eb8668303287b1c7f134453d8ec2751d1fe 100644 (file)
@@ -86,6 +86,9 @@ int lttng_kretprobes_handler_exit(struct kretprobe_instance *krpi,
        return _lttng_kretprobes_handler(krpi, regs, EVENT_EXIT);
 }
 
+static const struct lttng_kernel_type_common *event_type =
+       lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16);
+
 /*
  * Create event description
  */
@@ -93,14 +96,15 @@ static
 int lttng_create_kprobe_event(const char *name, struct lttng_event *event,
                              enum lttng_kretprobe_type type)
 {
-       struct lttng_event_field *fields;
-       struct lttng_event_desc *desc;
-       int ret;
+       const struct lttng_kernel_event_field **fieldp_array;
+       struct lttng_kernel_event_field *field;
+       struct lttng_kernel_event_desc *desc;
        char *alloc_name;
        size_t name_len;
        const char *suffix = NULL;
+       int ret;
 
-       desc = kzalloc(sizeof(*event->desc), GFP_KERNEL);
+       desc = kzalloc(sizeof(*desc), GFP_KERNEL);
        if (!desc)
                return -ENOMEM;
        name_len = strlen(name);
@@ -120,39 +124,44 @@ int lttng_create_kprobe_event(const char *name, struct lttng_event *event,
        }
        strcpy(alloc_name, name);
        strcat(alloc_name, suffix);
-       desc->name = alloc_name;
+       desc->event_name = alloc_name;
        desc->nr_fields = 2;
-       desc->fields = fields =
-               kzalloc(2 * sizeof(struct lttng_event_field), GFP_KERNEL);
-       if (!desc->fields) {
+       fieldp_array = kzalloc(desc->nr_fields * sizeof(struct lttng_kernel_event_field *), GFP_KERNEL);
+       if (!fieldp_array) {
+               ret = -ENOMEM;
+               goto error_fieldp_array;
+       }
+       desc->fields = fieldp_array;
+
+       field = kzalloc(sizeof(struct lttng_kernel_event_field), GFP_KERNEL);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_field0;
+       }
+       field->name = "ip";
+       field->type = event_type;
+       desc->fields[0] = field;
+
+       field = kzalloc(sizeof(struct lttng_kernel_event_field), GFP_KERNEL);
+       if (!field) {
                ret = -ENOMEM;
-               goto error_fields;
+               goto error_field1;
        }
-       fields[0].name = "ip";
-       fields[0].type.type = lttng_kernel_type_integer;
-       fields[0].type.u.integer.size = sizeof(unsigned long) * CHAR_BIT;
-       fields[0].type.u.integer.alignment = lttng_alignof(unsigned long) * CHAR_BIT;
-       fields[0].type.u.integer.signedness = lttng_is_signed_type(unsigned long);
-       fields[0].type.u.integer.reverse_byte_order = 0;
-       fields[0].type.u.integer.base = 16;
-       fields[0].type.u.integer.encoding = lttng_kernel_string_encoding_none;
-
-       fields[1].name = "parent_ip";
-       fields[1].type.type = lttng_kernel_type_integer;
-       fields[1].type.u.integer.size = sizeof(unsigned long) * CHAR_BIT;
-       fields[1].type.u.integer.alignment = lttng_alignof(unsigned long) * CHAR_BIT;
-       fields[1].type.u.integer.signedness = lttng_is_signed_type(unsigned long);
-       fields[1].type.u.integer.reverse_byte_order = 0;
-       fields[1].type.u.integer.base = 16;
-       fields[1].type.u.integer.encoding = lttng_kernel_string_encoding_none;
+       field->name = "parent_ip";
+       field->type = event_type;
+       desc->fields[1] = field;
 
        desc->owner = THIS_MODULE;
        event->desc = desc;
 
        return 0;
 
-error_fields:
-       kfree(desc->name);
+error_field1:
+       kfree(desc->fields[0]);
+error_field0:
+       kfree(fieldp_array);
+error_fieldp_array:
+       kfree(desc->event_name);
 error_str:
        kfree(desc);
        return ret;
@@ -233,12 +242,16 @@ register_error:
 name_error:
        kfree(lttng_krp);
 krp_error:
+       kfree(event_exit->desc->fields[0]);
+       kfree(event_exit->desc->fields[1]);
        kfree(event_exit->desc->fields);
-       kfree(event_exit->desc->name);
+       kfree(event_exit->desc->event_name);
        kfree(event_exit->desc);
 event_exit_error:
+       kfree(event_entry->desc->fields[0]);
+       kfree(event_entry->desc->fields[1]);
        kfree(event_entry->desc->fields);
-       kfree(event_entry->desc->name);
+       kfree(event_entry->desc->event_name);
        kfree(event_entry->desc);
 error:
        return ret;
@@ -270,8 +283,10 @@ void _lttng_kretprobes_release(struct kref *kref)
 
 void lttng_kretprobes_destroy_private(struct lttng_event *event)
 {
+       kfree(event->desc->fields[0]);
+       kfree(event->desc->fields[1]);
        kfree(event->desc->fields);
-       kfree(event->desc->name);
+       kfree(event->desc->event_name);
        kfree(event->desc);
        kref_put(&event->u.kretprobe.lttng_krp->kref_alloc,
                _lttng_kretprobes_release);
index 816b7fc1be209c952c11eedddf5df5fcc83e1338..89b474d1d0e5ed19e93f69f6f6e11256dd19f2ed 100644 (file)
@@ -79,49 +79,52 @@ int lttng_uprobes_event_notifier_handler_pre(struct uprobe_consumer *uc, struct
        return 0;
 }
 
+static const struct lttng_kernel_type_common *event_type =
+       lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16);
+
 /*
  * Create event description.
  */
 static
 int lttng_create_uprobe_event(const char *name, struct lttng_event *event)
 {
-       struct lttng_event_desc *desc;
-       struct lttng_event_field *fields;
+       const struct lttng_kernel_event_field **fieldp_array;
+       struct lttng_kernel_event_field *field;
+       struct lttng_kernel_event_desc *desc;
        int ret;
 
-       desc = kzalloc(sizeof(*event->desc), GFP_KERNEL);
+       desc = kzalloc(sizeof(*desc), GFP_KERNEL);
        if (!desc)
                return -ENOMEM;
-       desc->name = kstrdup(name, GFP_KERNEL);
-       if (!desc->name) {
+       desc->event_name = kstrdup(name, GFP_KERNEL);
+       if (!desc->event_name) {
                ret = -ENOMEM;
                goto error_str;
        }
-
        desc->nr_fields = 1;
-       desc->fields = fields =
-               kzalloc(1 * sizeof(struct lttng_event_field), GFP_KERNEL);
-
-       if (!desc->fields) {
+       fieldp_array = kzalloc(1 * sizeof(struct lttng_kernel_event_field *), GFP_KERNEL);
+       if (!fieldp_array) {
                ret = -ENOMEM;
-               goto error_fields;
+               goto error_fieldp_array;
        }
-       fields[0].name = "ip";
-       fields[0].type.type = lttng_kernel_type_integer;
-       fields[0].type.u.integer.size = sizeof(unsigned long) * CHAR_BIT;
-       fields[0].type.u.integer.alignment = lttng_alignof(unsigned long) * CHAR_BIT;
-       fields[0].type.u.integer.signedness = lttng_is_signed_type(unsigned long);
-       fields[0].type.u.integer.reverse_byte_order = 0;
-       fields[0].type.u.integer.base = 16;
-       fields[0].type.u.integer.encoding = lttng_kernel_string_encoding_none;
-
+       desc->fields = fieldp_array;
+       desc->fields[0] = field =
+               kzalloc(sizeof(struct lttng_kernel_event_field), GFP_KERNEL);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_field;
+       }
+       field->name = "ip";
+       field->type = event_type;
        desc->owner = THIS_MODULE;
        event->desc = desc;
 
        return 0;
 
-error_fields:
-       kfree(desc->name);
+error_field:
+       kfree(fieldp_array);
+error_fieldp_array:
+       kfree(desc->event_name);
 error_str:
        kfree(desc);
        return ret;
@@ -133,14 +136,14 @@ error_str:
 static
 int lttng_create_uprobe_event_notifier(const char *name, struct lttng_event_notifier *event_notifier)
 {
-       struct lttng_event_desc *desc;
+       struct lttng_kernel_event_desc *desc;
        int ret;
 
-       desc = kzalloc(sizeof(*event_notifier->desc), GFP_KERNEL);
+       desc = kzalloc(sizeof(*desc), GFP_KERNEL);
        if (!desc)
                return -ENOMEM;
-       desc->name = kstrdup(name, GFP_KERNEL);
-       if (!desc->name) {
+       desc->event_name = kstrdup(name, GFP_KERNEL);
+       if (!desc->event_name) {
                ret = -ENOMEM;
                goto error_str;
        }
@@ -291,7 +294,7 @@ int lttng_uprobes_register_event(const char *name, int fd, struct lttng_event *e
        return 0;
 
 register_error:
-       kfree(event->desc->name);
+       kfree(event->desc->event_name);
        kfree(event->desc);
 error:
        return ret;
@@ -314,7 +317,7 @@ int lttng_uprobes_register_event_notifier(const char *name, int fd,
        return 0;
 
 register_error:
-       kfree(event_notifier->desc->name);
+       kfree(event_notifier->desc->event_name);
        kfree(event_notifier->desc);
 error:
        return ret;
@@ -353,7 +356,9 @@ EXPORT_SYMBOL_GPL(lttng_uprobes_unregister_event_notifier);
 void lttng_uprobes_destroy_event_private(struct lttng_event *event)
 {
        iput(event->u.uprobe.inode);
-       kfree(event->desc->name);
+       kfree(event->desc->fields[0]);
+       kfree(event->desc->fields);
+       kfree(event->desc->event_name);
        kfree(event->desc);
 }
 EXPORT_SYMBOL_GPL(lttng_uprobes_destroy_event_private);
@@ -361,7 +366,7 @@ EXPORT_SYMBOL_GPL(lttng_uprobes_destroy_event_private);
 void lttng_uprobes_destroy_event_notifier_private(struct lttng_event_notifier *event_notifier)
 {
        iput(event_notifier->u.uprobe.inode);
-       kfree(event_notifier->desc->name);
+       kfree(event_notifier->desc->event_name);
        kfree(event_notifier->desc);
 }
 EXPORT_SYMBOL_GPL(lttng_uprobes_destroy_event_notifier_private);
This page took 0.159348 seconds and 4 git commands to generate.