From: Mathieu Desnoyers Date: Thu, 29 Sep 2022 19:06:58 +0000 (-0400) Subject: Fix: move "user" attribute from field to type X-Git-Tag: v2.12.11~6 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=79282ffdd4f0ad1237f99dcc1f0b36f81d797452;p=lttng-modules.git Fix: move "user" attribute from field to type The "user" field attribute (copy from userspace) is not taken into account in the bytecode specialization and interpreter recursive traversal through composed types (LOAD_FIELD bytecode instructions). Those are currently used by the filter expressions which access fields nested within composed types. Move the "user" attribute from the event fields to the integer and string types. This will allow ensuring that the bytecode specialization and interpreter have access to this user attribute even in nested types (e.g. arrays, sequences) in a subsequent change. Signed-off-by: Mathieu Desnoyers Change-Id: I093d61c98bf725b2974f4a19cae560b7fc147f4f --- diff --git a/instrumentation/events/lttng-module/net.h b/instrumentation/events/lttng-module/net.h index c66a6dba..53f95f49 100644 --- a/instrumentation/events/lttng-module/net.h +++ b/instrumentation/events/lttng-module/net.h @@ -36,52 +36,52 @@ static struct lttng_event_field tcpfields[] = { [0] = { .name = "source_port", .type = __type_integer(uint16_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [1] = { .name = "dest_port", .type = __type_integer(uint16_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [2] = { .name = "seq", .type = __type_integer(uint32_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [3] = { .name = "ack_seq", .type = __type_integer(uint32_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [4] = { .name = "data_offset", .type = __type_integer(uint8_t, 4, 4, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [5] = { .name = "reserved", .type = __type_integer(uint8_t, 3, 1, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [6] = { .name = "flags", .type = __type_integer(uint8_t, 9, 1, 0, - __BIG_ENDIAN, 16, none), + __BIG_ENDIAN, 0, 16, none), }, [7] = { .name = "window_size", .type = __type_integer(uint16_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [8] = { .name = "checksum", .type = __type_integer(uint16_t, 0, 0, 0, - __BIG_ENDIAN, 16, none), + __BIG_ENDIAN, 0, 16, none), }, [9] = { .name = "urg_ptr", .type = __type_integer(uint16_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, }; @@ -183,37 +183,37 @@ static struct lttng_event_field ipv4fields[] = { [0] = { .name = "version", .type = __type_integer(uint8_t, 4, 4, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [1] = { .name = "ihl", .type = __type_integer(uint8_t, 4, 4, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [2] = { .name = "tos", .type = __type_integer(uint8_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [3] = { .name = "tot_len", .type = __type_integer(uint16_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [4] = { .name = "id", .type = __type_integer(uint16_t, 0, 0, 0, - __BIG_ENDIAN, 16, none), + __BIG_ENDIAN, 0, 16, none), }, [5] = { .name = "frag_off", .type = __type_integer(uint16_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [6] = { .name = "ttl", .type = __type_integer(uint8_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [7] = { .name = "protocol", @@ -228,6 +228,7 @@ static struct lttng_event_field ipv4fields[] = { .reverse_byte_order = __BIG_ENDIAN != __BYTE_ORDER, .base = 10, + .user = 0, .encoding = lttng_encode_none, }, }, @@ -235,7 +236,7 @@ static struct lttng_event_field ipv4fields[] = { [8] = { .name = "checksum", .type = __type_integer(uint16_t, 0, 0, 0, - __BIG_ENDIAN, 16, none), + __BIG_ENDIAN, 0, 16, none), }, [9] = { .name = "saddr", @@ -243,7 +244,7 @@ static struct lttng_event_field ipv4fields[] = { .atype = atype_array, .u.array.elem_type = __type_integer(uint8_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), .u.array.length = 4, .u.array.elem_alignment = lttng_alignof(uint8_t), }, @@ -254,7 +255,7 @@ static struct lttng_event_field ipv4fields[] = { .atype = atype_array, .u.array.elem_type = __type_integer(uint8_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), .u.array.length = 4, .u.array.elem_alignment = lttng_alignof(uint8_t), }, @@ -270,6 +271,7 @@ static struct lttng_event_field ipv4fields[] = { .signedness = 0, .reverse_byte_order = 0, .base = 10, + .user = 0, .encoding = lttng_encode_none, }, }, @@ -289,12 +291,12 @@ static struct lttng_event_field ipv6fields[] = { [0] = { .name = "version", .type = __type_integer(uint8_t, 4, 4, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [1] = { .name = "prio", .type = __type_integer(uint8_t, 4, 4, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [2] = { .name = "flow_lbl", @@ -302,7 +304,7 @@ static struct lttng_event_field ipv6fields[] = { .atype = atype_array, .u.array.elem_type = __type_integer(uint8_t, 0, 0, 0, - __BIG_ENDIAN, 16, none), + __BIG_ENDIAN, 0, 16, none), .u.array.length = 3, .u.array.elem_alignment = lttng_alignof(uint8_t), }, @@ -310,7 +312,7 @@ static struct lttng_event_field ipv6fields[] = { [3] = { .name = "payload_len", .type = __type_integer(uint16_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [4] = { .name = "nexthdr", @@ -325,6 +327,7 @@ static struct lttng_event_field ipv6fields[] = { .reverse_byte_order = __BIG_ENDIAN != __BYTE_ORDER, .base = 10, + .user = 0, .encoding = lttng_encode_none, }, }, @@ -332,7 +335,7 @@ static struct lttng_event_field ipv6fields[] = { [5] = { .name = "hop_limit", .type = __type_integer(uint8_t, 0, 0, 0, - __BIG_ENDIAN, 10, none), + __BIG_ENDIAN, 0, 10, none), }, [6] = { .name = "saddr", @@ -340,7 +343,7 @@ static struct lttng_event_field ipv6fields[] = { .atype = atype_array, .u.array.elem_type = __type_integer(uint16_t, 0, 0, 0, - __BIG_ENDIAN, 16, none), + __BIG_ENDIAN, 0, 16, none), .u.array.length = 8, .u.array.elem_alignment = lttng_alignof(uint16_t), }, @@ -351,7 +354,7 @@ static struct lttng_event_field ipv6fields[] = { .atype = atype_array, .u.array.elem_type = __type_integer(uint16_t, 0, 0, 0, - __BIG_ENDIAN, 16, none), + __BIG_ENDIAN, 0, 16, none), .u.array.length = 8, .u.array.elem_alignment = lttng_alignof(uint16_t), }, @@ -367,6 +370,7 @@ static struct lttng_event_field ipv6fields[] = { .signedness = 0, .reverse_byte_order = 0, .base = 10, + .user = 0, .encoding = lttng_encode_none, }, }, diff --git a/instrumentation/syscalls/headers/syscalls_pointers_override.h b/instrumentation/syscalls/headers/syscalls_pointers_override.h index cdc56450..2dcef0bd 100644 --- a/instrumentation/syscalls/headers/syscalls_pointers_override.h +++ b/instrumentation/syscalls/headers/syscalls_pointers_override.h @@ -149,9 +149,9 @@ end: ; /* Label at end of compound statement. */ \ ctf_custom_type( \ .atype = atype_sequence, \ .u.sequence.length_type = __type_integer( \ - uint8_t, 0, 0, 0, __BYTE_ORDER, 10, none), \ + uint8_t, 0, 0, 0, __BYTE_ORDER, 0, 10, none), \ .u.sequence.elem_type = __type_integer(uint8_t, 0, 0, 0, \ - __BYTE_ORDER, 16, none), \ + __BYTE_ORDER, 0, 16, none), \ ), \ name, \ ctf_custom_code( \ @@ -186,9 +186,9 @@ end: ; /* Label at end of compound statement. */ \ ctf_custom_type( \ .atype = atype_sequence, \ .u.sequence.length_type = __type_integer( \ - uint8_t, 0, 0, 0, __BYTE_ORDER, 10, none), \ + uint8_t, 0, 0, 0, __BYTE_ORDER, 0, 10, none), \ .u.sequence.elem_type = __type_integer(uint8_t, 0, 0, 0, \ - __BYTE_ORDER, 16, none), \ + __BYTE_ORDER, 0, 16, none), \ ), \ name, \ ctf_custom_code( \ @@ -310,43 +310,43 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(pselect6, static struct lttng_event_field lttng_pollfd_flag_fields[] = { [ilog2(POLLIN)] = { .name = "POLLIN", - .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none), + .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 0, 10, none), }, [ilog2(POLLPRI)] = { .name = "POLLPRI", - .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none), + .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 0, 10, none), }, [ilog2(POLLOUT)] = { .name = "POLLOUT", - .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none), + .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 0, 10, none), }, [ilog2(POLLERR)] = { .name = "POLLERR", - .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none), + .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 0, 10, none), }, [ilog2(POLLHUP)] = { .name = "POLLHUP", - .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none), + .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 0, 10, none), }, [ilog2(POLLNVAL)] = { .name = "POLLNVAL", - .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none), + .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 0, 10, none), }, [ilog2(LTTNG_POLL_NRFLAGS)] = { .name = "padding", .type = __type_integer(int, POLL_FLAGS_PADDING_SIZE, 1, 0, - __LITTLE_ENDIAN, 10, none), + __LITTLE_ENDIAN, 0, 10, none), }, }; static struct lttng_event_field lttng_pollfd_fields[] = { [0] = { .name = "fd", - .type = __type_integer(int, 0, 0, 0, __BYTE_ORDER, 10, none), + .type = __type_integer(int, 0, 0, 0, __BYTE_ORDER, 0, 10, none), }, [1] = { .name = "raw_events", - .type = __type_integer(short, 0, 0, 0, __BYTE_ORDER, 16, none), + .type = __type_integer(short, 0, 0, 0, __BYTE_ORDER, 0, 16, none), }, [2] = { .name = "events", @@ -572,32 +572,32 @@ static struct lttng_event_field lttng_epoll_ctl_events_fields[] = { /* 0x0001 */ [ilog2(POLLIN)] = { .name = "EPOLLIN", - .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none), + .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 0, 10, none), }, /* 0x0002 */ [ilog2(POLLPRI)] = { .name = "EPOLLPRI", - .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none), + .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 0, 10, none), }, /* 0x0004 */ [ilog2(POLLOUT)] = { .name = "EPOLLOUT", - .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none), + .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 0, 10, none), }, /* 0x0008 */ [ilog2(POLLERR)] = { .name = "EPOLLERR", - .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none), + .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 0, 10, none), }, /* 0x0010 */ [ilog2(POLLHUP)] = { .name = "EPOLLHUP", - .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none), + .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 0, 10, none), }, [ilog2(LTTNG_EPOLL_NRFLAGS)] = { .name = "padding", .type = __type_integer(int, EPOLL_FLAGS_PADDING_SIZE, 1, 0, - __LITTLE_ENDIAN, 10, none), + __LITTLE_ENDIAN, 0, 10, none), }, }; @@ -605,11 +605,11 @@ static struct lttng_event_field lttng_epoll_ctl_events_fields[] = { static struct lttng_event_field lttng_epoll_data_fields[] = { [0] = { .name = "u64", - .type = __type_integer(uint64_t, 0, 0, 0, __BYTE_ORDER, 16, none), + .type = __type_integer(uint64_t, 0, 0, 0, __BYTE_ORDER, 0, 16, none), }, [1] = { .name = "fd", - .type = __type_integer(int, 0, 0, 0, __BYTE_ORDER, 10, none), + .type = __type_integer(int, 0, 0, 0, __BYTE_ORDER, 0, 10, none), }, }; @@ -624,7 +624,7 @@ static struct lttng_event_field epoll_ctl_fields[] = { }, [1] = { .name = "raw_events", - .type = __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER, 16, none), + .type = __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER, 0, 16, none), }, [2] = { .name = "events", @@ -702,7 +702,7 @@ static struct lttng_event_field lttng_epoll_wait_fields[] = { }, [1] = { .name = "raw_events", - .type = __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER, 16, none), + .type = __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER, 0, 16, none), }, [2] = { .name = "events", diff --git a/lttng-events.h b/lttng-events.h index e2cd5445..da2637d7 100644 --- a/lttng-events.h +++ b/lttng-events.h @@ -75,7 +75,7 @@ struct lttng_enum_entry { }; #define __type_integer(_type, _size, _alignment, _signedness, \ - _byte_order, _base, _encoding) \ + _byte_order, _user, _base, _encoding) \ { \ .atype = atype_integer, \ .u.basic.integer = \ @@ -83,8 +83,9 @@ struct lttng_enum_entry { .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, \ + .reverse_byte_order = (_byte_order) != __BYTE_ORDER, \ + .base = (_base), \ + .user = (_user), \ .encoding = lttng_encode_##_encoding, \ }, \ } \ @@ -93,7 +94,8 @@ struct lttng_integer_type { unsigned int size; /* in bits */ unsigned short alignment; /* in bits */ unsigned int signedness:1, - reverse_byte_order:1; + reverse_byte_order:1, + user:1; /* fetch from user-space */ unsigned int base; /* 2, 8, 10, 16, for pretty print */ enum lttng_string_encodings encoding; }; @@ -106,6 +108,7 @@ union _lttng_basic_type { } enumeration; struct { enum lttng_string_encodings encoding; + unsigned int user:1; /* fetch from user-space */ } string; }; @@ -161,8 +164,7 @@ struct lttng_enum_desc { struct lttng_event_field { const char *name; struct lttng_type type; - unsigned int nowrite:1, /* do not write into trace */ - user:1; /* fetch from user-space */ + unsigned int nowrite:1; /* do not write into trace */ }; union lttng_ctx_value { diff --git a/lttng-filter.c b/lttng-filter.c index 05ce683e..ec6fd576 100644 --- a/lttng-filter.c +++ b/lttng-filter.c @@ -246,7 +246,7 @@ int apply_field_reloc(struct lttng_event *event, if (elem_type->atype != atype_integer || elem_type->u.basic.integer.encoding == lttng_encode_none) return -EINVAL; - if (field->user) + if (elem_type->u.basic.integer.user) op->op = FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE; else op->op = FILTER_OP_LOAD_FIELD_REF_SEQUENCE; @@ -258,14 +258,14 @@ int apply_field_reloc(struct lttng_event *event, if (elem_type->atype != atype_integer || elem_type->u.basic.integer.encoding == lttng_encode_none) return -EINVAL; - if (field->user) + if (elem_type->u.basic.integer.user) op->op = FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE; else op->op = FILTER_OP_LOAD_FIELD_REF_SEQUENCE; break; } case atype_string: - if (field->user) + if (field->type.u.basic.string.user) op->op = FILTER_OP_LOAD_FIELD_REF_USER_STRING; else op->op = FILTER_OP_LOAD_FIELD_REF_STRING; @@ -334,7 +334,7 @@ int apply_context_reloc(struct lttng_event *event, if (elem_type->atype != atype_integer || elem_type->u.basic.integer.encoding == lttng_encode_none) return -EINVAL; - BUG_ON(ctx_field->event_field.user); + BUG_ON(elem_type->u.basic.integer.user); op->op = FILTER_OP_GET_CONTEXT_REF_STRING; break; } @@ -344,12 +344,12 @@ int apply_context_reloc(struct lttng_event *event, if (elem_type->atype != atype_integer || elem_type->u.basic.integer.encoding == lttng_encode_none) return -EINVAL; - BUG_ON(ctx_field->event_field.user); + BUG_ON(elem_type->u.basic.integer.user); op->op = FILTER_OP_GET_CONTEXT_REF_STRING; break; } case atype_string: - BUG_ON(ctx_field->event_field.user); + BUG_ON(ctx_field->event_field.type.u.basic.string.user); op->op = FILTER_OP_GET_CONTEXT_REF_STRING; break; case atype_struct: /* Unsupported. */ diff --git a/probes/lttng-tracepoint-event-impl.h b/probes/lttng-tracepoint-event-impl.h index 4231afad..b40fbd81 100644 --- a/probes/lttng-tracepoint-event-impl.h +++ b/probes/lttng-tracepoint-event-impl.h @@ -257,9 +257,8 @@ void __event_template_proto___##_name(void); #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),\ + .type = __type_integer(_type, 0, 0, -1, _byte_order, _user, _base, none),\ .nowrite = _nowrite, \ - .user = _user, \ }, #undef _ctf_array_encoded @@ -273,13 +272,12 @@ void __event_template_proto___##_name(void); { \ .array = \ { \ - .elem_type = __type_integer(_type, 0, 0, 0, _byte_order, _base, _encoding), \ + .elem_type = __type_integer(_type, 0, 0, 0, _byte_order, _user, _base, _encoding), \ .length = _length, \ } \ } \ }, \ .nowrite = _nowrite, \ - .user = _user, \ }, #undef _ctf_array_bitfield @@ -293,14 +291,13 @@ void __event_template_proto___##_name(void); { \ .array = \ { \ - .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \ + .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, _user, 10, none), \ .length = (_length) * sizeof(_type) * CHAR_BIT, \ .elem_alignment = lttng_alignof(_type), \ } \ } \ }, \ .nowrite = _nowrite, \ - .user = _user, \ }, @@ -317,13 +314,12 @@ void __event_template_proto___##_name(void); { \ .sequence = \ { \ - .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \ - .elem_type = __type_integer(_type, 0, 0, -1, _byte_order, _base, _encoding), \ + .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 0, 10, none), \ + .elem_type = __type_integer(_type, 0, 0, -1, _byte_order, _user, _base, _encoding), \ }, \ }, \ }, \ .nowrite = _nowrite, \ - .user = _user, \ }, #undef _ctf_sequence_bitfield @@ -339,14 +335,13 @@ void __event_template_proto___##_name(void); { \ .sequence = \ { \ - .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \ - .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \ + .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 0, 10, none), \ + .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, _user, 10, none), \ .elem_alignment = lttng_alignof(_type), \ }, \ }, \ }, \ .nowrite = _nowrite, \ - .user = _user, \ }, #undef _ctf_string @@ -358,11 +353,10 @@ void __event_template_proto___##_name(void); .atype = atype_string, \ .u = \ { \ - .basic = { .string = { .encoding = lttng_encode_UTF8 } } \ + .basic = { .string = { .encoding = lttng_encode_UTF8, .user = (_user), } } \ }, \ }, \ .nowrite = _nowrite, \ - .user = _user, \ }, #undef _ctf_enum @@ -380,6 +374,7 @@ void __event_template_proto___##_name(void); .alignment = lttng_alignof(_type) * CHAR_BIT, \ .signedness = lttng_is_signed_type(_type), \ .reverse_byte_order = 0, \ + .user = (_user), \ .base = 10, \ .encoding = lttng_encode_none, \ }, \ @@ -388,7 +383,6 @@ void __event_template_proto___##_name(void); }, \ }, \ .nowrite = _nowrite, \ - .user = _user, \ }, #undef ctf_custom_field @@ -397,7 +391,6 @@ void __event_template_proto___##_name(void); .name = #_item, \ .type = { _type }, \ .nowrite = 0, \ - .user = 0, \ }, #undef ctf_custom_type