Replaces the ctf_event_definition to keep the bt_ namespace.
Signed-off-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
struct bt_ctf_iter *iter;
struct ctf_text_stream_pos *sout;
struct bt_iter_pos begin_pos;
- struct ctf_event_definition *ctf_event;
+ struct bt_ctf_event *ctf_event;
int ret;
sout = container_of(td_write, struct ctf_text_stream_pos,
goto error_iter;
}
while ((ctf_event = bt_ctf_iter_read_event(iter))) {
- ret = sout->parent.event_cb(&sout->parent, ctf_event->stream);
+ ret = sout->parent.event_cb(&sout->parent, ctf_event->parent->stream);
if (ret) {
fprintf(stderr, "[error] Writing event failed.\n");
goto end;
*/
int bt_ctf_iter_add_callback(struct bt_ctf_iter *iter,
bt_intern_str event, void *private_data, int flags,
- enum bt_cb_ret (*callback)(struct ctf_event_definition *ctf_data,
+ enum bt_cb_ret (*callback)(struct bt_ctf_event *ctf_data,
void *private_data),
struct bt_dependencies *depends,
struct bt_dependencies *weak_depends,
}
static
-struct ctf_event_definition *extract_ctf_stream_event(struct ctf_stream_definition *stream)
+int extract_ctf_stream_event(struct ctf_stream_definition *stream,
+ struct bt_ctf_event *event)
{
struct ctf_stream_declaration *stream_class = stream->stream_class;
struct ctf_event_declaration *event_class;
- struct ctf_event_definition *event;
uint64_t id = stream->event_id;
if (id >= stream_class->events_by_id->len) {
fprintf(stderr, "[error] Event id %" PRIu64 " is outside range.\n", id);
- return NULL;
+ return -1;
}
- event = g_ptr_array_index(stream->events_by_id, id);
- if (!event) {
+ event->parent = g_ptr_array_index(stream->events_by_id, id);
+ if (!event->parent) {
fprintf(stderr, "[error] Event id %" PRIu64 " is unknown.\n", id);
- return NULL;
+ return -1;
}
event_class = g_ptr_array_index(stream_class->events_by_id, id);
if (!event_class) {
fprintf(stderr, "[error] Event id %" PRIu64 " is unknown.\n", id);
- return NULL;
+ return -1;
}
- return event;
+ return 0;
}
void process_callbacks(struct bt_ctf_iter *iter,
struct bt_callback *cb;
int i;
enum bt_cb_ret ret;
- struct ctf_event_definition *ctf_data;
+ struct bt_ctf_event ctf_data;
- ctf_data = extract_ctf_stream_event(stream);
+ ret = extract_ctf_stream_event(stream, &ctf_data);
/* process all events callback first */
if (iter->main_callbacks.callback) {
cb = &g_array_index(iter->main_callbacks.callback, struct bt_callback, i);
if (!cb)
goto end;
- ret = cb->callback(ctf_data, cb->private_data);
+ ret = cb->callback(&ctf_data, cb->private_data);
switch (ret) {
case BT_CB_OK_STOP:
case BT_CB_ERROR_STOP:
cb = &g_array_index(bt_chain->callback, struct bt_callback, i);
if (!cb)
goto end;
- ret = cb->callback(ctf_data, cb->private_data);
+ ret = cb->callback(&ctf_data, cb->private_data);
switch (ret) {
case BT_CB_OK_STOP:
case BT_CB_ERROR_STOP:
*/
__thread int bt_ctf_last_field_error = 0;
-const struct definition *bt_ctf_get_top_level_scope(const struct ctf_event_definition *event,
+const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *ctf_event,
enum bt_ctf_scope scope)
{
struct definition *tmp = NULL;
+ struct ctf_event_definition *event = ctf_event->parent;
switch (scope) {
case BT_TRACE_PACKET_HEADER:
return NULL;
}
-const struct definition *bt_ctf_get_field(const struct ctf_event_definition *event,
+const struct definition *bt_ctf_get_field(const struct bt_ctf_event *ctf_event,
const struct definition *scope,
const char *field)
{
return NULL;
}
-const struct definition *bt_ctf_get_index(const struct ctf_event_definition *event,
+const struct definition *bt_ctf_get_index(const struct bt_ctf_event *ctf_event,
const struct definition *field,
unsigned int index)
{
return ret;
}
-const char *bt_ctf_event_name(const struct ctf_event_definition *event)
+const char *bt_ctf_event_name(const struct bt_ctf_event *ctf_event)
{
struct ctf_event_declaration *event_class;
struct ctf_stream_declaration *stream_class;
+ struct ctf_event_definition *event = ctf_event->parent;
if (!event)
return NULL;
return CTF_TYPE_UNKNOWN;
}
-int bt_ctf_get_field_list(const struct ctf_event_definition *event,
+int bt_ctf_get_field_list(const struct bt_ctf_event *ctf_event,
const struct definition *scope,
struct definition const * const **list,
unsigned int *count)
return -1;
}
-struct bt_context *bt_ctf_event_get_context(const struct ctf_event_definition *event)
+struct bt_context *bt_ctf_event_get_context(const struct bt_ctf_event *ctf_event)
{
struct bt_context *ret = NULL;
struct ctf_file_stream *cfs;
struct ctf_trace *trace;
+ struct ctf_event_definition *event = ctf_event->parent;
cfs = container_of(event->stream, struct ctf_file_stream,
parent);
return ret;
}
-int bt_ctf_event_get_handle_id(const struct ctf_event_definition *event)
+int bt_ctf_event_get_handle_id(const struct bt_ctf_event *ctf_event)
{
int ret = -1;
struct ctf_file_stream *cfs;
struct ctf_trace *trace;
+ struct ctf_event_definition *event = ctf_event->parent;
cfs = container_of(event->stream, struct ctf_file_stream,
parent);
return ret;
}
-uint64_t bt_ctf_get_timestamp_raw(const struct ctf_event_definition *event)
+uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *ctf_event)
{
+ struct ctf_event_definition *event = ctf_event->parent;
if (event && event->stream->has_timestamp)
return ctf_get_timestamp_raw(event->stream,
event->stream->timestamp);
return -1ULL;
}
-uint64_t bt_ctf_get_timestamp(const struct ctf_event_definition *event)
+uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *ctf_event)
{
+ struct ctf_event_definition *event = ctf_event->parent;
if (event && event->stream->has_timestamp)
return ctf_get_timestamp(event->stream,
event->stream->timestamp);
return &iter->parent;
}
-struct ctf_event_definition *bt_ctf_iter_read_event(struct bt_ctf_iter *iter)
+struct bt_ctf_event *bt_ctf_iter_read_event(struct bt_ctf_iter *iter)
{
struct ctf_file_stream *file_stream;
- struct ctf_event_definition *ret = &iter->current_ctf_event;
+ struct bt_ctf_event *ret = &iter->current_ctf_event;
struct ctf_stream_definition *stream;
file_stream = heap_maximum(iter->parent.stream_heap);
goto stop;
}
stream = &file_stream->parent;
- ret = g_ptr_array_index(stream->events_by_id,
+ ret->parent = g_ptr_array_index(stream->events_by_id,
stream->event_id);
- if (ret->stream->stream_id > iter->callbacks->len)
+ if (ret->parent->stream->stream_id > iter->callbacks->len)
goto end;
- process_callbacks(iter, ret->stream);
+ process_callbacks(iter, ret->parent->stream);
end:
return ret;
/* struct bt_context is opaque to the user */
struct bt_context;
struct stream_pos;
-struct ctf_event_definition;
+struct bt_ctf_event;
/*
* bt_context_create : create a Babeltrace context
*
* Returns NULL on error
*/
-struct bt_context *bt_ctf_event_get_context(const struct ctf_event_definition *event);
+struct bt_context *bt_ctf_event_get_context(const struct bt_ctf_event *event);
#endif /* _BABELTRACE_CONTEXT_H */
struct bt_dependencies *depends;
struct bt_dependencies *weak_depends;
struct bt_dependencies *provides;
- enum bt_cb_ret (*callback)(struct ctf_event_definition *ctf_data,
+ enum bt_cb_ret (*callback)(struct bt_ctf_event *ctf_data,
void *private_data);
};
*/
int bt_ctf_iter_add_callback(struct bt_ctf_iter *iter,
bt_intern_str event, void *private_data, int flags,
- enum bt_cb_ret (*callback)(struct ctf_event_definition *ctf_data,
+ enum bt_cb_ret (*callback)(struct bt_ctf_event *ctf_data,
void *caller_data),
struct bt_dependencies *depends,
struct bt_dependencies *weak_depends,
struct ctf_stream_definition;
+/*
+ * These structures are public mappings to internal ctf_event structures.
+ */
+struct bt_ctf_event {
+ struct ctf_event_definition *parent;
+};
+
+struct bt_ctf_event_decl {
+ struct ctf_event_declaration *parent;
+};
+
struct bt_ctf_iter {
struct bt_iter parent;
- struct ctf_event_definition current_ctf_event; /* last read event */
+ struct bt_ctf_event current_ctf_event; /* last read event */
GArray *callbacks; /* Array of struct bt_stream_callbacks */
struct bt_callback_chain main_callbacks; /* For all events */
/*
#include <stdint.h>
struct definition;
-struct ctf_event_definition;
+struct bt_ctf_event;
/*
* the top-level scopes in CTF
* between the enum and the actual definition of top-level scopes.
* On error return NULL.
*/
-const struct definition *bt_ctf_get_top_level_scope(const struct ctf_event_definition *event,
+const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *event,
enum bt_ctf_scope scope);
/*
* bt_ctf_event_get_name: returns the name of the event or NULL on error
*/
-const char *bt_ctf_event_name(const struct ctf_event_definition *event);
+const char *bt_ctf_event_name(const struct bt_ctf_event *event);
/*
* bt_ctf_get_timestamp_raw: returns the timestamp of the event as written in
* the packet or -1ULL on error
*/
-uint64_t bt_ctf_get_timestamp_raw(const struct ctf_event_definition *event);
+uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *event);
/*
* bt_ctf_get_timestamp: returns the timestamp of the event offsetted with the
* system clock source or -1ULL on error
*/
-uint64_t bt_ctf_get_timestamp(const struct ctf_event_definition *event);
+uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *event);
/*
* bt_ctf_get_field_list: set list pointer to an array of definition
* pointers and set count to the number of elements in the array.
* Return 0 on success and a negative value on error.
*/
-int bt_ctf_get_field_list(const struct ctf_event_definition *event,
+int bt_ctf_get_field_list(const struct bt_ctf_event *event,
const struct definition *scope,
struct definition const * const **list,
unsigned int *count);
/*
* bt_ctf_get_field: returns the definition of a specific field
*/
-const struct definition *bt_ctf_get_field(const struct ctf_event_definition *event,
+const struct definition *bt_ctf_get_field(const struct bt_ctf_event *event,
const struct definition *scope,
const char *field);
* bt_ctf_get_index: if the field is an array or a sequence, return the element
* at position index, otherwise return NULL;
*/
-const struct definition *bt_ctf_get_index(const struct ctf_event_definition *event,
+const struct definition *bt_ctf_get_index(const struct bt_ctf_event *event,
const struct definition *field,
unsigned int index);
#include <babeltrace/iterator.h>
struct bt_ctf_iter;
-struct ctf_event_definition;
+struct bt_ctf_event;
/*
* bt_ctf_iter_create - Allocate a CTF trace collection iterator.
*
* Return current event on success, NULL on end of trace.
*/
-struct ctf_event_definition *bt_ctf_iter_read_event(struct bt_ctf_iter *iter);
+struct bt_ctf_event *bt_ctf_iter_read_event(struct bt_ctf_iter *iter);
#endif /* _BABELTRACE_CTF_ITERATOR_H */
* It is a unique identifier representing a trace file.
*/
struct bt_trace_handle;
-struct ctf_event_definition;
+struct bt_ctf_event;
/*
* bt_trace_handle_get_path : returns the path of a trace_handle.
*
* Returns -1 on error
*/
-int bt_ctf_event_get_handle_id(const struct ctf_event_definition *event);
+int bt_ctf_event_get_handle_id(const struct bt_ctf_event *event);
#endif /* _BABELTRACE_TRACE_HANDLE_H */