SoW-2020-0002: Trace Hit Counters: trigger error reporting integration
[lttng-tools.git] / src / bin / lttng-sessiond / trace-kernel.h
CommitLineData
fda89c9b 1/*
ab5be9fa 2 * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
fda89c9b 3 *
ab5be9fa 4 * SPDX-License-Identifier: GPL-2.0-only
fda89c9b 5 *
fda89c9b
DG
6 */
7
62499ad6
DG
8#ifndef _LTT_TRACE_KERNEL_H
9#define _LTT_TRACE_KERNEL_H
fda89c9b 10
9e78d6ae 11#include <urcu/list.h>
d4a2a84a 12
f3ed775e 13#include <lttng/lttng.h>
10a8a223 14#include <common/lttng-kernel.h>
4dbc372b 15#include <common/lttng-kernel-old.h>
ce2a9e76 16#include <common/defaults.h>
54012638 17
00e2e675 18#include "consumer.h"
55c9e7ca 19#include "tracker.h"
00e2e675 20
20fe2104
DG
21/* Kernel event list */
22struct ltt_kernel_event_list {
23 struct cds_list_head head;
24};
25
2463b787
JR
26/* Kernel event rule token list */
27struct ltt_kernel_token_event_rule_ht {
28 struct cds_lfht *ht;
29};
30
8c0faa1d
DG
31/* Channel stream list */
32struct ltt_kernel_stream_list {
33 struct cds_list_head head;
34};
35
36/* Channel list */
37struct ltt_kernel_channel_list {
38 struct cds_list_head head;
39};
40
645328ae
DG
41struct ltt_kernel_context {
42 struct lttng_kernel_context ctx;
43 struct cds_list_head list;
ba985c3a
JG
44 /* Indicates whether or not the context is in a list. */
45 bool in_list;
645328ae
DG
46};
47
20fe2104
DG
48/* Kernel event */
49struct ltt_kernel_event {
20fe2104 50 int fd;
e953ef25 51 int enabled;
d0ae4ea8 52 enum lttng_event_type type;
f34daff7 53 struct lttng_kernel_event *event;
20fe2104 54 struct cds_list_head list;
00a62084 55 char *filter_expression;
2463b787
JR
56 struct lttng_bytecode *filter;
57 struct lttng_userspace_probe_location *userspace_probe_location;
58};
59
60/* Kernel event */
61struct ltt_kernel_token_event_rule {
62 int fd;
63 uint64_t error_counter_index;
64 int enabled;
65 enum lttng_event_type type;
66 struct lttng_trigger *trigger;
67 uint64_t token;
68 const struct lttng_bytecode *filter;
3c02e545 69 struct lttng_userspace_probe_location *userspace_probe_location;
2463b787 70 struct cds_lfht_node ht_node;
20fe2104
DG
71};
72
73/* Kernel channel */
74struct ltt_kernel_channel {
75 int fd;
e1f3997a 76 uint64_t key; /* Key to reference this channel with the consumer. */
d36b8583 77 int enabled;
8c0faa1d 78 unsigned int stream_count;
cbbbb275 79 unsigned int event_count;
753873bf 80 bool published_to_notification_thread;
645328ae 81 struct cds_list_head ctx_list;
f3ed775e 82 struct lttng_channel *channel;
20fe2104 83 struct ltt_kernel_event_list events_list;
8c0faa1d
DG
84 struct ltt_kernel_stream_list stream_list;
85 struct cds_list_head list;
fb5f35b6
DG
86 /* Session pointer which has a reference to this object. */
87 struct ltt_kernel_session *session;
e99f9447 88 bool sent_to_consumer;
20fe2104
DG
89};
90
aaf26714
DG
91/* Metadata */
92struct ltt_kernel_metadata {
93 int fd;
d40f0359 94 uint64_t key; /* Key to reference this channel with the consumer. */
f3ed775e 95 struct lttng_channel *conf;
aaf26714
DG
96};
97
8c0faa1d
DG
98/* Channel stream */
99struct ltt_kernel_stream {
100 int fd;
8c0faa1d 101 int state;
ffe60014 102 int cpu;
6986ab9b 103 bool sent_to_consumer;
00e2e675 104 /* Format is %s_%d respectively channel name and CPU number. */
ce2a9e76 105 char name[DEFAULT_STREAM_NAME_LEN];
1624d5b7
JD
106 uint64_t tracefile_size;
107 uint64_t tracefile_count;
8c0faa1d
DG
108 struct cds_list_head list;
109};
110
20fe2104
DG
111/* Kernel session */
112struct ltt_kernel_session {
113 int fd;
8c0faa1d 114 int metadata_stream_fd;
3bd1e081 115 int consumer_fds_sent;
8c0faa1d
DG
116 unsigned int channel_count;
117 unsigned int stream_count_global;
aaf26714 118 struct ltt_kernel_metadata *metadata;
8c0faa1d 119 struct ltt_kernel_channel_list channel_list;
6df2e2c9
MD
120 /* UID/GID of the user owning the session */
121 uid_t uid;
122 gid_t gid;
00e2e675 123 struct consumer_output *consumer;
53632229 124 /* Tracing session id */
d022620a 125 uint64_t id;
14fb1ebe
DG
126 /* Session is active or not meaning it has been started or stopped. */
127 unsigned int active:1;
2bba9e53
DG
128 /* Tell or not if the session has to output the traces. */
129 unsigned int output_traces;
27babd3a 130 unsigned int snapshot_mode;
85076754 131 unsigned int has_non_default_channel;
a2814ea7 132 bool is_live_session;
82b69413
JG
133 /* Current trace chunk of the ltt_session. */
134 struct lttng_trace_chunk *current_trace_chunk;
55c9e7ca 135 /* Tracker lists */
159b042f
JG
136 struct process_attr_tracker *tracker_pid;
137 struct process_attr_tracker *tracker_vpid;
138 struct process_attr_tracker *tracker_uid;
139 struct process_attr_tracker *tracker_vuid;
140 struct process_attr_tracker *tracker_gid;
141 struct process_attr_tracker *tracker_vgid;
fda89c9b
DG
142};
143
62499ad6
DG
144/*
145 * Lookup functions. NULL is returned if not found.
146 */
147struct ltt_kernel_event *trace_kernel_get_event_by_name(
d0ae4ea8
MD
148 char *name, struct ltt_kernel_channel *channel,
149 enum lttng_event_type type);
00a62084
MD
150struct ltt_kernel_event *trace_kernel_find_event(
151 char *name, struct ltt_kernel_channel *channel,
152 enum lttng_event_type type,
2463b787 153 struct lttng_bytecode *filter);
62499ad6 154struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
df4f5a87 155 const char *name, struct ltt_kernel_session *session);
19e70852 156
54012638 157/*
c363b55d 158 * Create functions malloc() the data structure.
54012638 159 */
dec56f6c 160struct ltt_kernel_session *trace_kernel_create_session(void);
fdd9eb17
DG
161struct ltt_kernel_channel *trace_kernel_create_channel(
162 struct lttng_channel *chan);
71a3bb01 163enum lttng_error_code trace_kernel_create_event(struct lttng_event *ev,
2463b787 164 char *filter_expression, struct lttng_bytecode *filter,
71a3bb01 165 struct ltt_kernel_event **kernel_event);
a4b92340 166struct ltt_kernel_metadata *trace_kernel_create_metadata(void);
00e2e675
DG
167struct ltt_kernel_stream *trace_kernel_create_stream(const char *name,
168 unsigned int count);
645328ae
DG
169struct ltt_kernel_context *trace_kernel_create_context(
170 struct lttng_kernel_context *ctx);
2463b787
JR
171enum lttng_error_code trace_kernel_create_token_event_rule(
172 struct lttng_trigger *trigger,
173 uint64_t token,
174 uint64_t trigger_error_counter_index,
175 struct ltt_kernel_token_event_rule **kernel_token_event_rule);
df3c77c8
JG
176struct ltt_kernel_context *trace_kernel_copy_context(
177 struct ltt_kernel_context *ctx);
2463b787
JR
178enum lttng_error_code trace_kernel_init_trigger_from_event_rule(const struct lttng_event_rule *rule,
179 struct lttng_kernel_trigger *kernel_trigger);
54012638 180
c363b55d
DG
181/*
182 * Destroy functions free() the data structure and remove from linked list if
183 * it's applies.
184 */
62499ad6
DG
185void trace_kernel_destroy_session(struct ltt_kernel_session *session);
186void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata);
187void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel);
188void trace_kernel_destroy_event(struct ltt_kernel_event *event);
189void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream);
645328ae 190void trace_kernel_destroy_context(struct ltt_kernel_context *ctx);
2463b787 191void trace_kernel_destroy_token_event_rule(struct ltt_kernel_token_event_rule *rule);
d070c424 192void trace_kernel_free_session(struct ltt_kernel_session *session);
c363b55d 193
62499ad6 194#endif /* _LTT_TRACE_KERNEL_H */
This page took 0.145456 seconds and 5 git commands to generate.