1 #ifndef _BABELTRACE_CTF_EVENTS_H
2 #define _BABELTRACE_CTF_EVENTS_H
9 * Copyright 2011-2012 EfficiOS Inc. and Linux Foundation
11 * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 * Julien Desfossez <julien.desfossez@efficios.com>
14 * Permission is hereby granted, free of charge, to any person obtaining
15 * a copy of this software and associated documentation files (the
16 * "Software"), to deal in the Software without restriction, including
17 * without limitation the rights to use, copy, modify, merge, publish,
18 * distribute, sublicense, and/or sell copies of the Software, and to
19 * permit persons to whom the Software is furnished to do so, subject to
20 * the following conditions:
22 * The above copyright notice and this permission notice shall be
23 * included in all copies or substantial portions of the Software.
32 * the top-level scopes in CTF
35 BT_TRACE_PACKET_HEADER
= 0,
36 BT_STREAM_PACKET_CONTEXT
= 1,
37 BT_STREAM_EVENT_HEADER
= 2,
38 BT_STREAM_EVENT_CONTEXT
= 3,
44 * the supported CTF types
53 CTF_TYPE_UNTAGGED_VARIANT
,
61 * the supported CTF string encodings
63 enum ctf_string_encoding
{
71 * bt_ctf_get_top_level_scope: return a definition of the top-level scope
73 * Top-level scopes are defined in the bt_ctf_scope enum.
74 * In order to get a field or a field list, the user needs to pass a
75 * scope as argument, this scope can be a top-level scope or a scope
76 * relative to an arbitrary field. This function provides the mapping
77 * between the enum and the actual definition of top-level scopes.
78 * On error return NULL.
80 const struct definition
*bt_ctf_get_top_level_scope(const struct bt_ctf_event
*event
,
81 enum bt_ctf_scope scope
);
84 * bt_ctf_event_get_name: returns the name of the event or NULL on error
86 const char *bt_ctf_event_name(const struct bt_ctf_event
*event
);
89 * bt_ctf_get_timestamp_raw: returns the timestamp of the event as written in
90 * the packet or -1ULL on error
92 uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event
*event
);
95 * bt_ctf_get_timestamp: returns the timestamp of the event offsetted with the
96 * system clock source or -1ULL on error
98 uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event
*event
);
101 * bt_ctf_get_field_list: set list pointer to an array of definition
102 * pointers and set count to the number of elements in the array.
103 * Return 0 on success and a negative value on error.
105 int bt_ctf_get_field_list(const struct bt_ctf_event
*event
,
106 const struct definition
*scope
,
107 struct definition
const * const **list
,
108 unsigned int *count
);
111 * bt_ctf_get_field: returns the definition of a specific field
113 const struct definition
*bt_ctf_get_field(const struct bt_ctf_event
*event
,
114 const struct definition
*scope
,
118 * bt_ctf_get_index: if the field is an array or a sequence, return the element
119 * at position index, otherwise return NULL;
121 const struct definition
*bt_ctf_get_index(const struct bt_ctf_event
*event
,
122 const struct definition
*field
,
126 * bt_ctf_field_name: returns the name of a field or NULL on error
128 const char *bt_ctf_field_name(const struct definition
*def
);
131 * bt_ctf_field_type: returns the type of a field or -1 if unknown
133 enum ctf_type_id
bt_ctf_field_type(const struct definition
*def
);
136 * bt_ctf_get_int_signedness: return the signedness of an integer
138 * return 0 if unsigned
142 int bt_ctf_get_int_signedness(const struct definition
*field
);
145 * bt_ctf_get_int_base: return the base of an int or a negative value on error
147 int bt_ctf_get_int_base(const struct definition
*field
);
150 * bt_ctf_get_int_byte_order: return the byte order of an int or a negative
153 int bt_ctf_get_int_byte_order(const struct definition
*field
);
156 * bt_ctf_get_encoding: return the encoding of an int or a string.
157 * return a negative value on error
159 enum ctf_string_encoding
bt_ctf_get_encoding(const struct definition
*field
);
162 * bt_ctf_get_array_len: return the len of an array or a negative
165 int bt_ctf_get_array_len(const struct definition
*field
);
168 * Field access functions
170 * These functions return the value associated with the field passed in
173 * If the field does not exist or is not of the type requested, the value
174 * returned is undefined. To check if an error occured, use the
175 * bt_ctf_field_error() function after accessing a field.
177 uint64_t bt_ctf_get_uint64(const struct definition
*field
);
178 int64_t bt_ctf_get_int64(const struct definition
*field
);
179 char *bt_ctf_get_char_array(const struct definition
*field
);
180 char *bt_ctf_get_string(const struct definition
*field
);
183 * bt_ctf_field_error: returns the last error code encountered while
184 * accessing a field and reset the error flag.
185 * Return 0 if no error, a negative value otherwise.
187 int bt_ctf_field_get_error(void);
189 #endif /* _BABELTRACE_CTF_EVENTS_H */