Commit | Line | Data |
---|---|---|
97ee3a89 DG |
1 | /* |
2 | * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License as published by the Free | |
6 | * Software Foundation; only version 2 of the License. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
11 | * more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License along with | |
14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | |
15 | * Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | */ | |
17 | ||
18 | #define _GNU_SOURCE | |
19 | #include <stdio.h> | |
20 | #include <stdlib.h> | |
21 | #include <string.h> | |
22 | #include <unistd.h> | |
23 | ||
990570ed DG |
24 | #include <common/common.h> |
25 | #include <common/defaults.h> | |
97ee3a89 DG |
26 | |
27 | #include "trace-ust.h" | |
28 | ||
0177d773 | 29 | /* |
f6a9efaa | 30 | * Find the channel in the hashtable. |
0177d773 | 31 | */ |
bec39940 | 32 | struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, |
f6a9efaa | 33 | char *name) |
0177d773 | 34 | { |
bec39940 DG |
35 | struct lttng_ht_node_str *node; |
36 | struct lttng_ht_iter iter; | |
0177d773 | 37 | |
f6a9efaa | 38 | rcu_read_lock(); |
bec39940 DG |
39 | lttng_ht_lookup(ht, (void *)name, &iter); |
40 | node = lttng_ht_iter_get_node_str(&iter); | |
f6a9efaa DG |
41 | if (node == NULL) { |
42 | rcu_read_unlock(); | |
44d3bd01 DG |
43 | goto error; |
44 | } | |
f6a9efaa | 45 | rcu_read_unlock(); |
44d3bd01 | 46 | |
f6a9efaa | 47 | DBG2("Trace UST channel %s found by name", name); |
0177d773 | 48 | |
f6a9efaa | 49 | return caa_container_of(node, struct ltt_ust_channel, node); |
97ee3a89 DG |
50 | |
51 | error: | |
f6a9efaa | 52 | DBG2("Trace UST channel %s not found by name", name); |
97ee3a89 DG |
53 | return NULL; |
54 | } | |
55 | ||
56 | /* | |
f6a9efaa | 57 | * Find the event in the hashtable. |
97ee3a89 | 58 | */ |
bec39940 | 59 | struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht, |
f6a9efaa | 60 | char *name) |
97ee3a89 | 61 | { |
bec39940 DG |
62 | struct lttng_ht_node_str *node; |
63 | struct lttng_ht_iter iter; | |
97ee3a89 | 64 | |
f6a9efaa | 65 | rcu_read_lock(); |
bec39940 DG |
66 | lttng_ht_lookup(ht, (void *) name, &iter); |
67 | node = lttng_ht_iter_get_node_str(&iter); | |
f6a9efaa DG |
68 | if (node == NULL) { |
69 | rcu_read_unlock(); | |
97ee3a89 DG |
70 | goto error; |
71 | } | |
f6a9efaa | 72 | rcu_read_unlock(); |
97ee3a89 | 73 | |
284d8f55 | 74 | DBG2("Trace UST event found by name %s", name); |
f6a9efaa DG |
75 | |
76 | return caa_container_of(node, struct ltt_ust_event, node); | |
97ee3a89 DG |
77 | |
78 | error: | |
284d8f55 | 79 | DBG2("Trace UST event NOT found by name %s", name); |
97ee3a89 DG |
80 | return NULL; |
81 | } | |
82 | ||
83 | /* | |
84 | * Allocate and initialize a ust session data structure. | |
85 | * | |
86 | * Return pointer to structure or NULL. | |
87 | */ | |
a991f516 | 88 | struct ltt_ust_session *trace_ust_create_session(char *path, int session_id, |
44d3bd01 | 89 | struct lttng_domain *domain) |
97ee3a89 | 90 | { |
0177d773 | 91 | int ret; |
97ee3a89 DG |
92 | struct ltt_ust_session *lus; |
93 | ||
94 | /* Allocate a new ltt ust session */ | |
ba7f0ae5 | 95 | lus = zmalloc(sizeof(struct ltt_ust_session)); |
97ee3a89 | 96 | if (lus == NULL) { |
ba7f0ae5 | 97 | PERROR("create ust session zmalloc"); |
97ee3a89 DG |
98 | goto error; |
99 | } | |
100 | ||
101 | /* Init data structure */ | |
a991f516 | 102 | lus->id = session_id; |
36dc12cc | 103 | lus->start_trace = 0; |
97ee3a89 | 104 | |
f6a9efaa | 105 | /* Alloc UST domain hash tables */ |
bec39940 DG |
106 | lus->domain_pid = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); |
107 | lus->domain_exec = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); | |
f6a9efaa DG |
108 | |
109 | /* Alloc UST global domain channels' HT */ | |
bec39940 | 110 | lus->domain_global.channels = lttng_ht_new(0, LTTNG_HT_TYPE_STRING); |
44d3bd01 | 111 | |
0177d773 | 112 | /* Set session path */ |
48842b30 | 113 | ret = snprintf(lus->pathname, PATH_MAX, "%s/ust", path); |
0177d773 | 114 | if (ret < 0) { |
44d3bd01 | 115 | PERROR("snprintf kernel traces path"); |
44844c29 | 116 | goto error_free_session; |
0177d773 DG |
117 | } |
118 | ||
44d3bd01 DG |
119 | DBG2("UST trace session create successful"); |
120 | ||
97ee3a89 DG |
121 | return lus; |
122 | ||
44844c29 MD |
123 | error_free_session: |
124 | free(lus); | |
97ee3a89 DG |
125 | error: |
126 | return NULL; | |
127 | } | |
128 | ||
129 | /* | |
130 | * Allocate and initialize a ust channel data structure. | |
131 | * | |
132 | * Return pointer to structure or NULL. | |
133 | */ | |
44d3bd01 DG |
134 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, |
135 | char *path) | |
97ee3a89 DG |
136 | { |
137 | int ret; | |
138 | struct ltt_ust_channel *luc; | |
139 | ||
37357452 | 140 | luc = zmalloc(sizeof(struct ltt_ust_channel)); |
97ee3a89 | 141 | if (luc == NULL) { |
ba7f0ae5 | 142 | perror("ltt_ust_channel zmalloc"); |
97ee3a89 DG |
143 | goto error; |
144 | } | |
145 | ||
44d3bd01 | 146 | /* Copy UST channel attributes */ |
48842b30 DG |
147 | luc->attr.overwrite = chan->attr.overwrite; |
148 | luc->attr.subbuf_size = chan->attr.subbuf_size; | |
149 | luc->attr.num_subbuf = chan->attr.num_subbuf; | |
150 | luc->attr.switch_timer_interval = chan->attr.switch_timer_interval; | |
151 | luc->attr.read_timer_interval = chan->attr.read_timer_interval; | |
152 | luc->attr.output = chan->attr.output; | |
44d3bd01 DG |
153 | |
154 | /* Translate to UST output enum */ | |
155 | switch (luc->attr.output) { | |
156 | default: | |
157 | luc->attr.output = LTTNG_UST_MMAP; | |
158 | break; | |
97ee3a89 | 159 | } |
97ee3a89 | 160 | |
97ee3a89 | 161 | /* Copy channel name */ |
0a1459bb | 162 | strncpy(luc->name, chan->name, sizeof(luc->name)); |
97ee3a89 DG |
163 | luc->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; |
164 | ||
f6a9efaa | 165 | /* Init node */ |
bec39940 | 166 | lttng_ht_node_init_str(&luc->node, luc->name); |
f6a9efaa | 167 | /* Alloc hash tables */ |
bec39940 DG |
168 | luc->events = lttng_ht_new(0, LTTNG_HT_TYPE_STRING); |
169 | luc->ctx = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); | |
f6a9efaa | 170 | |
97ee3a89 | 171 | /* Set trace output path */ |
48842b30 | 172 | ret = snprintf(luc->pathname, PATH_MAX, "%s", path); |
97ee3a89 DG |
173 | if (ret < 0) { |
174 | perror("asprintf ust create channel"); | |
44844c29 | 175 | goto error_free_channel; |
97ee3a89 DG |
176 | } |
177 | ||
f6a9efaa DG |
178 | DBG2("Trace UST channel %s created", luc->name); |
179 | ||
97ee3a89 DG |
180 | return luc; |
181 | ||
44844c29 MD |
182 | error_free_channel: |
183 | free(luc); | |
97ee3a89 DG |
184 | error: |
185 | return NULL; | |
186 | } | |
187 | ||
188 | /* | |
189 | * Allocate and initialize a ust event. Set name and event type. | |
190 | * | |
191 | * Return pointer to structure or NULL. | |
192 | */ | |
193 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) | |
194 | { | |
195 | struct ltt_ust_event *lue; | |
97ee3a89 | 196 | |
37357452 | 197 | lue = zmalloc(sizeof(struct ltt_ust_event)); |
44d3bd01 | 198 | if (lue == NULL) { |
ba7f0ae5 | 199 | PERROR("ust event zmalloc"); |
97ee3a89 DG |
200 | goto error; |
201 | } | |
202 | ||
203 | switch (ev->type) { | |
204 | case LTTNG_EVENT_PROBE: | |
44d3bd01 | 205 | lue->attr.instrumentation = LTTNG_UST_PROBE; |
97ee3a89 DG |
206 | break; |
207 | case LTTNG_EVENT_FUNCTION: | |
44d3bd01 | 208 | lue->attr.instrumentation = LTTNG_UST_FUNCTION; |
97ee3a89 DG |
209 | break; |
210 | case LTTNG_EVENT_FUNCTION_ENTRY: | |
44d3bd01 | 211 | lue->attr.instrumentation = LTTNG_UST_FUNCTION; |
97ee3a89 DG |
212 | break; |
213 | case LTTNG_EVENT_TRACEPOINT: | |
44d3bd01 | 214 | lue->attr.instrumentation = LTTNG_UST_TRACEPOINT; |
97ee3a89 DG |
215 | break; |
216 | default: | |
217 | ERR("Unknown ust instrumentation type (%d)", ev->type); | |
44844c29 | 218 | goto error_free_event; |
97ee3a89 DG |
219 | } |
220 | ||
221 | /* Copy event name */ | |
44d3bd01 DG |
222 | strncpy(lue->attr.name, ev->name, LTTNG_UST_SYM_NAME_LEN); |
223 | lue->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; | |
97ee3a89 | 224 | |
0cda4f28 | 225 | switch (ev->loglevel_type) { |
8005f29a MD |
226 | case LTTNG_EVENT_LOGLEVEL_ALL: |
227 | lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_ALL; | |
0cda4f28 | 228 | break; |
8005f29a MD |
229 | case LTTNG_EVENT_LOGLEVEL_RANGE: |
230 | lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_RANGE; | |
231 | break; | |
232 | case LTTNG_EVENT_LOGLEVEL_SINGLE: | |
233 | lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_SINGLE; | |
0cda4f28 MD |
234 | break; |
235 | default: | |
236 | ERR("Unknown ust loglevel type (%d)", ev->type); | |
237 | goto error_free_event; | |
238 | } | |
239 | ||
8005f29a MD |
240 | /* Copy loglevel */ |
241 | lue->attr.loglevel = ev->loglevel; | |
0cda4f28 | 242 | |
f6a9efaa | 243 | /* Init node */ |
bec39940 | 244 | lttng_ht_node_init_str(&lue->node, lue->attr.name); |
f6a9efaa | 245 | /* Alloc context hash tables */ |
bec39940 | 246 | lue->ctx = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); |
97ee3a89 | 247 | |
284d8f55 DG |
248 | DBG2("Trace UST event %s created", lue->attr.name); |
249 | ||
97ee3a89 DG |
250 | return lue; |
251 | ||
44844c29 MD |
252 | error_free_event: |
253 | free(lue); | |
97ee3a89 DG |
254 | error: |
255 | return NULL; | |
256 | } | |
257 | ||
258 | /* | |
259 | * Allocate and initialize a ust metadata. | |
260 | * | |
261 | * Return pointer to structure or NULL. | |
262 | */ | |
263 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path) | |
264 | { | |
265 | int ret; | |
266 | struct ltt_ust_metadata *lum; | |
97ee3a89 | 267 | |
3a009adb | 268 | lum = zmalloc(sizeof(struct ltt_ust_metadata)); |
44d3bd01 | 269 | if (lum == NULL) { |
ba7f0ae5 | 270 | perror("ust metadata zmalloc"); |
97ee3a89 DG |
271 | goto error; |
272 | } | |
273 | ||
274 | /* Set default attributes */ | |
44d3bd01 DG |
275 | lum->attr.overwrite = DEFAULT_CHANNEL_OVERWRITE; |
276 | lum->attr.subbuf_size = DEFAULT_METADATA_SUBBUF_SIZE; | |
277 | lum->attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM; | |
278 | lum->attr.switch_timer_interval = DEFAULT_CHANNEL_SWITCH_TIMER; | |
279 | lum->attr.read_timer_interval = DEFAULT_CHANNEL_READ_TIMER; | |
d41f73b7 | 280 | lum->attr.output = LTTNG_UST_MMAP; |
44d3bd01 | 281 | |
97ee3a89 DG |
282 | lum->handle = -1; |
283 | /* Set metadata trace path */ | |
f6a9efaa | 284 | ret = snprintf(lum->pathname, PATH_MAX, "%s/metadata", path); |
97ee3a89 DG |
285 | if (ret < 0) { |
286 | perror("asprintf ust metadata"); | |
44844c29 | 287 | goto error_free_metadata; |
97ee3a89 DG |
288 | } |
289 | ||
290 | return lum; | |
291 | ||
44844c29 MD |
292 | error_free_metadata: |
293 | free(lum); | |
97ee3a89 DG |
294 | error: |
295 | return NULL; | |
296 | } | |
297 | ||
55cc08a6 DG |
298 | /* |
299 | * Allocate and initialize an UST context. | |
300 | * | |
301 | * Return pointer to structure or NULL. | |
302 | */ | |
303 | struct ltt_ust_context *trace_ust_create_context( | |
304 | struct lttng_event_context *ctx) | |
305 | { | |
306 | struct ltt_ust_context *uctx; | |
9197c5c4 MD |
307 | enum lttng_ust_context_type utype; |
308 | ||
309 | switch (ctx->ctx) { | |
310 | case LTTNG_EVENT_CONTEXT_VTID: | |
311 | utype = LTTNG_UST_CONTEXT_VTID; | |
312 | break; | |
313 | case LTTNG_EVENT_CONTEXT_VPID: | |
314 | utype = LTTNG_UST_CONTEXT_VPID; | |
315 | break; | |
316 | case LTTNG_EVENT_CONTEXT_PTHREAD_ID: | |
317 | utype = LTTNG_UST_CONTEXT_PTHREAD_ID; | |
318 | break; | |
319 | case LTTNG_EVENT_CONTEXT_PROCNAME: | |
320 | utype = LTTNG_UST_CONTEXT_PROCNAME; | |
321 | break; | |
322 | default: | |
323 | ERR("Invalid UST context"); | |
324 | return NULL; | |
325 | } | |
55cc08a6 DG |
326 | |
327 | uctx = zmalloc(sizeof(struct ltt_ust_context)); | |
328 | if (uctx == NULL) { | |
329 | PERROR("zmalloc ltt_ust_context"); | |
330 | goto error; | |
331 | } | |
332 | ||
9197c5c4 | 333 | uctx->ctx.ctx = utype; |
bec39940 | 334 | lttng_ht_node_init_ulong(&uctx->node, (unsigned long) uctx->ctx.ctx); |
55cc08a6 DG |
335 | |
336 | return uctx; | |
337 | ||
338 | error: | |
339 | return NULL; | |
340 | } | |
341 | ||
f6a9efaa DG |
342 | /* |
343 | * RCU safe free context structure. | |
344 | */ | |
345 | static void destroy_context_rcu(struct rcu_head *head) | |
346 | { | |
bec39940 DG |
347 | struct lttng_ht_node_ulong *node = |
348 | caa_container_of(head, struct lttng_ht_node_ulong, head); | |
f6a9efaa DG |
349 | struct ltt_ust_context *ctx = |
350 | caa_container_of(node, struct ltt_ust_context, node); | |
351 | ||
352 | free(ctx); | |
353 | } | |
354 | ||
355 | /* | |
356 | * Cleanup UST context hash table. | |
357 | */ | |
7bd39047 | 358 | static void destroy_contexts(struct lttng_ht *ht) |
f6a9efaa DG |
359 | { |
360 | int ret; | |
bec39940 DG |
361 | struct lttng_ht_node_ulong *node; |
362 | struct lttng_ht_iter iter; | |
f6a9efaa | 363 | |
bec39940 DG |
364 | cds_lfht_for_each_entry(ht->ht, &iter.iter, node, node) { |
365 | ret = lttng_ht_del(ht, &iter); | |
f6a9efaa DG |
366 | if (!ret) { |
367 | call_rcu(&node->head, destroy_context_rcu); | |
368 | } | |
f6a9efaa | 369 | } |
ed52805d | 370 | |
bec39940 | 371 | lttng_ht_destroy(ht); |
f6a9efaa DG |
372 | } |
373 | ||
97ee3a89 DG |
374 | /* |
375 | * Cleanup ust event structure. | |
376 | */ | |
377 | void trace_ust_destroy_event(struct ltt_ust_event *event) | |
378 | { | |
f6a9efaa | 379 | DBG2("Trace destroy UST event %s", event->attr.name); |
7bd39047 | 380 | destroy_contexts(event->ctx); |
ed52805d | 381 | |
97ee3a89 DG |
382 | free(event); |
383 | } | |
384 | ||
f6a9efaa DG |
385 | /* |
386 | * URCU intermediate call to complete destroy event. | |
387 | */ | |
388 | static void destroy_event_rcu(struct rcu_head *head) | |
389 | { | |
bec39940 DG |
390 | struct lttng_ht_node_str *node = |
391 | caa_container_of(head, struct lttng_ht_node_str, head); | |
f6a9efaa DG |
392 | struct ltt_ust_event *event = |
393 | caa_container_of(node, struct ltt_ust_event, node); | |
394 | ||
395 | trace_ust_destroy_event(event); | |
396 | } | |
397 | ||
284d8f55 DG |
398 | /* |
399 | * Cleanup UST events hashtable. | |
400 | */ | |
7bd39047 | 401 | static void destroy_events(struct lttng_ht *events) |
ed52805d DG |
402 | { |
403 | int ret; | |
bec39940 DG |
404 | struct lttng_ht_node_str *node; |
405 | struct lttng_ht_iter iter; | |
ed52805d | 406 | |
bec39940 DG |
407 | cds_lfht_for_each_entry(events->ht, &iter.iter, node, node) { |
408 | ret = lttng_ht_del(events, &iter); | |
7bd39047 DG |
409 | assert(!ret); |
410 | call_rcu(&node->head, destroy_event_rcu); | |
ed52805d DG |
411 | } |
412 | ||
bec39940 | 413 | lttng_ht_destroy(events); |
ed52805d DG |
414 | } |
415 | ||
97ee3a89 DG |
416 | /* |
417 | * Cleanup ust channel structure. | |
418 | */ | |
419 | void trace_ust_destroy_channel(struct ltt_ust_channel *channel) | |
420 | { | |
f6a9efaa | 421 | DBG2("Trace destroy UST channel %s", channel->name); |
97ee3a89 | 422 | |
f6a9efaa DG |
423 | rcu_read_lock(); |
424 | ||
7bd39047 DG |
425 | /* Destroying all events of the channel */ |
426 | destroy_events(channel->events); | |
427 | /* Destroying all context of the channel */ | |
428 | destroy_contexts(channel->ctx); | |
97ee3a89 | 429 | |
97ee3a89 | 430 | free(channel); |
f6a9efaa DG |
431 | |
432 | rcu_read_unlock(); | |
433 | } | |
434 | ||
435 | /* | |
436 | * URCU intermediate call to complete destroy channel. | |
437 | */ | |
438 | static void destroy_channel_rcu(struct rcu_head *head) | |
439 | { | |
bec39940 DG |
440 | struct lttng_ht_node_str *node = |
441 | caa_container_of(head, struct lttng_ht_node_str, head); | |
f6a9efaa DG |
442 | struct ltt_ust_channel *channel = |
443 | caa_container_of(node, struct ltt_ust_channel, node); | |
444 | ||
445 | trace_ust_destroy_channel(channel); | |
97ee3a89 DG |
446 | } |
447 | ||
448 | /* | |
449 | * Cleanup ust metadata structure. | |
450 | */ | |
451 | void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata) | |
452 | { | |
f6a9efaa | 453 | DBG2("Trace UST destroy metadata %d", metadata->handle); |
97ee3a89 | 454 | |
97ee3a89 DG |
455 | free(metadata); |
456 | } | |
457 | ||
458 | /* | |
f6a9efaa | 459 | * Iterate over a hash table containing channels and cleanup safely. |
97ee3a89 | 460 | */ |
bec39940 | 461 | static void destroy_channels(struct lttng_ht *channels) |
f6a9efaa DG |
462 | { |
463 | int ret; | |
bec39940 DG |
464 | struct lttng_ht_node_str *node; |
465 | struct lttng_ht_iter iter; | |
f6a9efaa | 466 | |
24d1723f DG |
467 | rcu_read_lock(); |
468 | ||
bec39940 DG |
469 | cds_lfht_for_each_entry(channels->ht, &iter.iter, node, node) { |
470 | ret = lttng_ht_del(channels, &iter); | |
7bd39047 DG |
471 | assert(!ret); |
472 | call_rcu(&node->head, destroy_channel_rcu); | |
f6a9efaa | 473 | } |
ed52805d | 474 | |
bec39940 | 475 | lttng_ht_destroy(channels); |
24d1723f DG |
476 | |
477 | rcu_read_unlock(); | |
f6a9efaa DG |
478 | } |
479 | ||
480 | /* | |
481 | * Cleanup UST pid domain. | |
482 | */ | |
bec39940 | 483 | static void destroy_domain_pid(struct lttng_ht *ht) |
f6a9efaa DG |
484 | { |
485 | int ret; | |
bec39940 | 486 | struct lttng_ht_iter iter; |
ed52805d | 487 | struct ltt_ust_domain_pid *dpid; |
f6a9efaa | 488 | |
bec39940 DG |
489 | cds_lfht_for_each_entry(ht->ht, &iter.iter, dpid, node.node) { |
490 | ret = lttng_ht_del(ht , &iter); | |
7bd39047 DG |
491 | assert(!ret); |
492 | destroy_channels(dpid->channels); | |
f6a9efaa | 493 | } |
ed52805d | 494 | |
bec39940 | 495 | lttng_ht_destroy(ht); |
f6a9efaa DG |
496 | } |
497 | ||
498 | /* | |
499 | * Cleanup UST exec name domain. | |
500 | */ | |
bec39940 | 501 | static void destroy_domain_exec(struct lttng_ht *ht) |
97ee3a89 | 502 | { |
f6a9efaa | 503 | int ret; |
bec39940 | 504 | struct lttng_ht_iter iter; |
ed52805d | 505 | struct ltt_ust_domain_exec *dexec; |
f6a9efaa | 506 | |
bec39940 DG |
507 | cds_lfht_for_each_entry(ht->ht, &iter.iter, dexec, node.node) { |
508 | ret = lttng_ht_del(ht , &iter); | |
7bd39047 DG |
509 | assert(!ret); |
510 | destroy_channels(dexec->channels); | |
f6a9efaa | 511 | } |
ed52805d | 512 | |
bec39940 | 513 | lttng_ht_destroy(ht); |
f6a9efaa | 514 | } |
97ee3a89 | 515 | |
f6a9efaa DG |
516 | /* |
517 | * Cleanup UST global domain. | |
518 | */ | |
519 | static void destroy_domain_global(struct ltt_ust_domain_global *dom) | |
520 | { | |
521 | destroy_channels(dom->channels); | |
522 | } | |
97ee3a89 | 523 | |
f6a9efaa DG |
524 | /* |
525 | * Cleanup ust session structure | |
526 | */ | |
527 | void trace_ust_destroy_session(struct ltt_ust_session *session) | |
528 | { | |
ed52805d | 529 | /* Extra protection */ |
97ee3a89 DG |
530 | if (session == NULL) { |
531 | return; | |
532 | } | |
533 | ||
f6a9efaa DG |
534 | rcu_read_lock(); |
535 | ||
a991f516 | 536 | DBG2("Trace UST destroy session %d", session->id); |
f6a9efaa | 537 | |
f6a9efaa DG |
538 | /* Cleaning up UST domain */ |
539 | destroy_domain_global(&session->domain_global); | |
540 | destroy_domain_pid(session->domain_pid); | |
541 | destroy_domain_exec(session->domain_exec); | |
44d3bd01 | 542 | |
97ee3a89 | 543 | free(session); |
f6a9efaa DG |
544 | |
545 | rcu_read_unlock(); | |
97ee3a89 | 546 | } |