4 * Linux Trace Toolkit Control Library
6 * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 * This library is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License, version 2.1 only,
10 * as published by the Free Software Foundation.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <lttng/event.h>
24 #include <lttng/lttng-error.h>
26 #include <common/sessiond-comm/sessiond-comm.h>
28 int lttng_event_get_filter_expression(struct lttng_event
*event
,
29 const char **filter_expression
)
32 struct lttcomm_event_extended_header
*ext_header
;
34 if (!event
|| !filter_expression
) {
35 ret
= -LTTNG_ERR_INVALID
;
39 ext_header
= event
->extended
.ptr
;
43 * This can happen since the lttng_event structure is
44 * used for other tasks where this pointer is never set.
46 *filter_expression
= NULL
;
50 if (ext_header
->filter_len
) {
51 *filter_expression
= ((const char *) (ext_header
)) +
54 *filter_expression
= NULL
;
61 int lttng_event_get_exclusion_name_count(struct lttng_event
*event
)
64 struct lttcomm_event_extended_header
*ext_header
;
67 ret
= -LTTNG_ERR_INVALID
;
71 ext_header
= event
->extended
.ptr
;
74 * This can happen since the lttng_event structure is
75 * used for other tasks where this pointer is never set.
81 if (ext_header
->nb_exclusions
> INT_MAX
) {
82 ret
= -LTTNG_ERR_OVERFLOW
;
85 ret
= (int) ext_header
->nb_exclusions
;
90 int lttng_event_get_exclusion_name(struct lttng_event
*event
,
91 size_t index
, const char **exclusion_name
)
94 struct lttcomm_event_extended_header
*ext_header
;
97 if (!event
|| !exclusion_name
) {
98 ret
= -LTTNG_ERR_INVALID
;
102 ext_header
= event
->extended
.ptr
;
104 ret
= -LTTNG_ERR_INVALID
;
108 if (index
>= ext_header
->nb_exclusions
) {
109 ret
= -LTTNG_ERR_INVALID
;
113 at
= (void *) ext_header
+ sizeof(*ext_header
);
114 at
+= ext_header
->filter_len
;
115 at
+= index
* LTTNG_SYMBOL_NAME_LEN
;
116 *exclusion_name
= at
;