2 * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; version 2.1 of
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 /* Internal UST API: ust-variant.h */
25 #include <lttng/ust-variant.h>
26 #include <lttng/ust-events.h>
31 static const struct lttng_enum_entry myentries
[NR_ENTRIES
] = {
35 .string
= "_mystring",
45 .string
= "_myuint16",
55 .string
= "_mylonglong",
59 static const struct lttng_enum_desc myenum_desc
= {
62 .nr_entries
= LTTNG_ARRAY_SIZE(myentries
),
65 const struct lttng_event_field myvarfields
[NR_ENTRIES
] = {
69 .atype
= atype_string
,
70 .u
.basic
.string
.encoding
= lttng_encode_UTF8
,
76 .type
= __type_integer(int32_t, BYTE_ORDER
, 10, none
),
81 .type
= __type_integer(uint16_t, BYTE_ORDER
, 10, none
),
86 .type
= __type_integer(char, BYTE_ORDER
, 10, none
),
91 .type
= __type_integer(long long, BYTE_ORDER
, 10, none
),
96 static const struct lttng_event_field
*get_field(const struct lttng_ust_type_variant
*variant
,
99 if (value
>= NR_ENTRIES
|| value
< 0)
101 return &myvarfields
[value
];
104 static int get_choices(const struct lttng_ust_type_variant
*variant
,
105 size_t *nr_choices
, const struct lttng_event_field
**choices
)
107 *nr_choices
= NR_ENTRIES
;
108 *choices
= myvarfields
;
112 static const struct lttng_event_field myfields
[];
114 static const struct lttng_ust_type_variant myvariant
= {
116 .get_field
= get_field
,
117 .get_choices
= get_choices
,
124 static void __event_probe__myprobe___myevent(void * __tp_data
)
128 static const struct lttng_event_field myfields
[] = {
131 .type
.atype
= atype_enum
,
132 .type
.u
.basic
.enumeration
.desc
= &myenum_desc
,
133 .type
.u
.basic
.enumeration
.container_type
= {
134 .size
= sizeof(char) * CHAR_BIT
,
135 .alignment
= lttng_alignof(char) * CHAR_BIT
,
136 .signedness
= lttng_is_signed_type(char),
137 .reverse_byte_order
= 0,
139 .encoding
= lttng_encode_none
,
146 .atype
= atype_variant
,
147 .u
.variant
= &myvariant
,
153 static const struct lttng_event_desc myevent_desc
= {
154 .name
= "myprobe:myevent",
155 .probe_callback
= (void (*)(void)) &__event_probe__myprobe___myevent
,
158 .nr_fields
= LTTNG_ARRAY_SIZE(myfields
),
160 .signature
= "mysig",
163 .model_emf_uri
= NULL
,
168 static const struct lttng_event_desc
*event_desc_array
[] = {
174 static struct lttng_probe_desc __probe_desc___myprobe
= {
175 .provider
= "myprobe",
176 .event_desc
= event_desc_array
,
177 .nr_events
= LTTNG_ARRAY_SIZE(event_desc_array
),
178 .head
= { NULL
, NULL
},
179 .lazy_init_head
= { NULL
, NULL
},
181 .major
= LTTNG_UST_PROVIDER_MAJOR
,
182 .minor
= LTTNG_UST_PROVIDER_MINOR
,
185 int main(int argc
, char **argv
)
189 ret
= lttng_probe_register(&__probe_desc___myprobe
);
193 lttng_probe_unregister(&__probe_desc___myprobe
);