common: compile libcompat as C++
[lttng-tools.git] / include / lttng / kernel-probe-internal.h
1 /*
2 * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #ifndef LTTNG_KERNEL_PROBE_INTERNAL_H
9 #define LTTNG_KERNEL_PROBE_INTERNAL_H
10
11 #include <common/fd-handle.h>
12 #include <common/macros.h>
13 #include <lttng/kernel-probe.h>
14 #include <lttng/lttng-error.h>
15 #include <stdbool.h>
16 #include <stdint.h>
17 #include <sys/types.h>
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 struct lttng_payload;
24 struct lttng_payload_view;
25 struct lttng_dynamic_buffer;
26 struct mi_writer;
27
28 typedef bool (*kernel_probe_location_equal_cb)(
29 const struct lttng_kernel_probe_location *a,
30 const struct lttng_kernel_probe_location *b);
31 typedef int (*kernel_probe_location_serialize_cb)(
32 const struct lttng_kernel_probe_location *kernel_probe_location,
33 struct lttng_payload *payload);
34 typedef bool (*kernel_probe_location_equal_cb)(
35 const struct lttng_kernel_probe_location *a,
36 const struct lttng_kernel_probe_location *b);
37 typedef ssize_t (*kernel_probe_location_create_from_payload_cb)(
38 struct lttng_payload_view *view,
39 struct lttng_kernel_probe_location **kernel_probe_location);
40 typedef unsigned long (*kernel_probe_location_hash_cb)(
41 const struct lttng_kernel_probe_location *location);
42 typedef enum lttng_error_code (*kernel_probe_location_mi_serialize_cb)(
43 const struct lttng_kernel_probe_location *location,
44 struct mi_writer *writer);
45
46 struct lttng_kernel_probe_location_comm {
47 /* enum lttng_kernel_probe_location_type */
48 int8_t type;
49 /*
50 * Payload is composed of, in that order,
51 * - type-specific payload
52 */
53 char payload[];
54 } LTTNG_PACKED;
55
56 struct lttng_kernel_probe_location_symbol_comm {
57 /* Includes the trailing \0. */
58 uint32_t symbol_len;
59 /* The offset from the symbol. */
60 uint64_t offset;
61 /*
62 * Payload is composed of, in that order,
63 * - symbol name (with trailing \0).
64 */
65 char payload[];
66 } LTTNG_PACKED;
67
68 struct lttng_kernel_probe_location_address_comm {
69 uint64_t address;
70 } LTTNG_PACKED;
71
72 /* Common ancestor of all kernel probe locations. */
73 struct lttng_kernel_probe_location {
74 enum lttng_kernel_probe_location_type type;
75 kernel_probe_location_equal_cb equal;
76 kernel_probe_location_serialize_cb serialize;
77 kernel_probe_location_hash_cb hash;
78 kernel_probe_location_mi_serialize_cb mi_serialize;
79 };
80
81 struct lttng_kernel_probe_location_symbol {
82 struct lttng_kernel_probe_location parent;
83 char *symbol_name;
84 uint64_t offset;
85 };
86
87 struct lttng_kernel_probe_location_address {
88 struct lttng_kernel_probe_location parent;
89 uint64_t address;
90 };
91
92 int lttng_kernel_probe_location_serialize(
93 const struct lttng_kernel_probe_location *location,
94 struct lttng_payload *payload);
95
96 ssize_t lttng_kernel_probe_location_create_from_payload(
97 struct lttng_payload_view *view,
98 struct lttng_kernel_probe_location **probe_location);
99
100 bool lttng_kernel_probe_location_is_equal(
101 const struct lttng_kernel_probe_location *a,
102 const struct lttng_kernel_probe_location *b);
103
104 struct lttng_kernel_probe_location *lttng_kernel_probe_location_copy(
105 const struct lttng_kernel_probe_location *location);
106
107 unsigned long lttng_kernel_probe_location_hash(
108 const struct lttng_kernel_probe_location *location);
109
110 enum lttng_error_code lttng_kernel_probe_location_mi_serialize(
111 const struct lttng_kernel_probe_location *location,
112 struct mi_writer *writer);
113
114 #ifdef __cplusplus
115 }
116 #endif
117
118 #endif /* LTTNG_KERNEL_PROBE_INTERNAL_H */
This page took 0.032066 seconds and 5 git commands to generate.