Fix: liblttng-ctl comm: lttng_event is not packed
[lttng-tools.git] / include / lttng / event-internal.h
CommitLineData
2d1318e4
JG
1/*
2 * event-internal.h
3 *
4 * Linux Trace Toolkit Control Library
5 *
ab5be9fa 6 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
2d1318e4 7 *
ab5be9fa 8 * SPDX-License-Identifier: LGPL-2.1-only
2d1318e4 9 *
2d1318e4
JG
10 */
11
12#ifndef LTTNG_EVENT_INTERNAL_H
13#define LTTNG_EVENT_INTERNAL_H
14
76fcf151
JG
15#include <common/macros.h>
16#include <lttng/event.h>
8ddd72ef 17#include <lttng/lttng-error.h>
76fcf151 18
8ddd72ef 19struct lttng_event_exclusion;
2d1318e4 20struct lttng_userspace_probe_location;
8ddd72ef
JR
21struct lttng_dynamic_buffer;
22struct lttng_buffer_view;
23
24struct lttng_event_comm {
25 int8_t event_type;
26 int8_t loglevel_type;
27 int32_t loglevel;
28 int8_t enabled;
29 int32_t pid;
30 uint32_t flags;
31
32 /* Payload. */
33 /* Includes terminator `\0`. */
34 uint32_t name_len;
35 uint32_t exclusion_count;
36 /* Includes terminator `\0`. */
37 uint32_t filter_expression_len;
38 uint32_t bytecode_len;
39
40 /* Type specific payload. */
41 uint32_t userspace_probe_location_len;
42 uint32_t lttng_event_probe_attr_len;
43 uint32_t lttng_event_function_attr_len;
44
45 /*
46 * Contain:
47 * - name [name_len],
48 * - exclusions if any
49 * - char filter_expression[filter_expression_len],
50 * - unsigned char filter_bytecode[bytecode_len],
51 * - userspace probe location [userspace_probe_location_len],
52 * - probe or ftrace based on event type.
53 */
54
55 char payload[];
56} LTTNG_PACKED;
57
58struct lttng_event_exclusion_comm {
59 /* Includes terminator `\0`. */
60 uint32_t len;
61 char payload [];
62} LTTNG_PACKED;
63
64struct lttng_event_probe_attr_comm {
65 uint64_t addr;
66 uint64_t offset;
67 /* Includes terminator `\0`. */
68 uint32_t symbol_name_len;
69
70 char payload[];
71} LTTNG_PACKED;
72
73struct lttng_event_function_attr_comm {
74 /* Includes terminator `\0`. */
75 uint32_t symbol_name_len;
76
77 char payload[];
78} LTTNG_PACKED;
2d1318e4
JG
79
80struct lttng_event_extended {
81 /*
82 * exclusions and filter_expression are only set when the lttng_event
83 * was created/allocated by a list operation. These two elements must
84 * not be free'd as they are part of the same contiguous buffer that
85 * contains all events returned by the listing.
86 */
87 char *filter_expression;
88 struct {
89 unsigned int count;
90 /* Array of strings of fixed LTTNG_SYMBOL_NAME_LEN length. */
91 char *strings;
92 } exclusions;
93 struct lttng_userspace_probe_location *probe_location;
94};
95
76fcf151
JG
96struct lttng_event *lttng_event_copy(const struct lttng_event *event);
97
8ddd72ef
JR
98ssize_t lttng_event_create_from_payload(struct lttng_payload_view *view,
99 struct lttng_event **out_event,
100 struct lttng_event_exclusion **out_exclusion,
101 char **out_filter_expression,
102 struct lttng_bytecode **out_bytecode);
103
104int lttng_event_serialize(const struct lttng_event *event,
105 unsigned int exclusion_count,
106 char **exclusion_list,
107 char *filter_expression,
108 size_t bytecode_len,
109 struct lttng_bytecode *bytecode,
110 struct lttng_payload *payload);
111
112enum lttng_error_code lttng_events_create_and_flatten_from_payload(
113 struct lttng_payload_view *view,
114 unsigned int count,
115 struct lttng_event **events);
116
2d1318e4 117#endif /* LTTNG_EVENT_INTERNAL_H */
This page took 0.034824 seconds and 4 git commands to generate.