From c50d2a7af8f63f3f4d2c0a6fce9a6e214d2baeda Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Mon, 2 Apr 2012 18:02:00 -0400 Subject: [PATCH] API fix/breakage : reexporting bt_ctf_event Replaces the ctf_event_definition to keep the bt_ namespace. Signed-off-by: Julien Desfossez Signed-off-by: Mathieu Desnoyers --- converter/babeltrace.c | 4 ++-- formats/ctf/callbacks.c | 26 ++++++++++----------- formats/ctf/events.c | 24 ++++++++++++------- formats/ctf/iterator.c | 10 ++++---- include/babeltrace/context.h | 4 ++-- include/babeltrace/ctf/callbacks-internal.h | 2 +- include/babeltrace/ctf/callbacks.h | 2 +- include/babeltrace/ctf/events-internal.h | 13 ++++++++++- include/babeltrace/ctf/events.h | 16 ++++++------- include/babeltrace/ctf/iterator.h | 4 ++-- include/babeltrace/trace-handle.h | 4 ++-- 11 files changed, 63 insertions(+), 46 deletions(-) diff --git a/converter/babeltrace.c b/converter/babeltrace.c index fc590ecc..a6c1f548 100644 --- a/converter/babeltrace.c +++ b/converter/babeltrace.c @@ -407,7 +407,7 @@ int convert_trace(struct trace_descriptor *td_write, 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, @@ -420,7 +420,7 @@ int convert_trace(struct trace_descriptor *td_write, 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; diff --git a/formats/ctf/callbacks.c b/formats/ctf/callbacks.c index 8e0d61e6..05ddf499 100644 --- a/formats/ctf/callbacks.c +++ b/formats/ctf/callbacks.c @@ -64,7 +64,7 @@ struct bt_dependencies *babeltrace_dependencies_create(const char *first, ...) */ 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, @@ -146,29 +146,29 @@ int bt_ctf_iter_add_callback(struct bt_ctf_iter *iter, } 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, @@ -179,9 +179,9 @@ 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) { @@ -189,7 +189,7 @@ void process_callbacks(struct bt_ctf_iter *iter, 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: @@ -217,7 +217,7 @@ void process_callbacks(struct bt_ctf_iter *iter, 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: diff --git a/formats/ctf/events.c b/formats/ctf/events.c index 714216f3..b33796bc 100644 --- a/formats/ctf/events.c +++ b/formats/ctf/events.c @@ -38,10 +38,11 @@ */ __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: @@ -83,7 +84,7 @@ error: 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) { @@ -114,7 +115,7 @@ const struct definition *bt_ctf_get_field(const struct ctf_event_definition *eve 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) { @@ -134,10 +135,11 @@ const struct definition *bt_ctf_get_index(const struct ctf_event_definition *eve 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; @@ -161,7 +163,7 @@ enum ctf_type_id bt_ctf_field_type(const struct definition *def) 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) @@ -247,11 +249,12 @@ error: 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); @@ -262,11 +265,12 @@ struct bt_context *bt_ctf_event_get_context(const struct ctf_event_definition *e 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); @@ -277,8 +281,9 @@ int bt_ctf_event_get_handle_id(const struct ctf_event_definition *event) 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); @@ -286,8 +291,9 @@ uint64_t bt_ctf_get_timestamp_raw(const struct ctf_event_definition *event) 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); diff --git a/formats/ctf/iterator.c b/formats/ctf/iterator.c index 5cc7dbad..f7b25f15 100644 --- a/formats/ctf/iterator.c +++ b/formats/ctf/iterator.c @@ -86,10 +86,10 @@ struct bt_iter *bt_ctf_get_iter(struct bt_ctf_iter *iter) 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); @@ -98,13 +98,13 @@ struct ctf_event_definition *bt_ctf_iter_read_event(struct bt_ctf_iter *iter) 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; diff --git a/include/babeltrace/context.h b/include/babeltrace/context.h index 9fa22fbf..4a85ff99 100644 --- a/include/babeltrace/context.h +++ b/include/babeltrace/context.h @@ -29,7 +29,7 @@ /* 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 @@ -102,6 +102,6 @@ void bt_context_put(struct bt_context *ctx); * * 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 */ diff --git a/include/babeltrace/ctf/callbacks-internal.h b/include/babeltrace/ctf/callbacks-internal.h index e9528da5..b76f82e1 100644 --- a/include/babeltrace/ctf/callbacks-internal.h +++ b/include/babeltrace/ctf/callbacks-internal.h @@ -31,7 +31,7 @@ struct bt_callback { 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); }; diff --git a/include/babeltrace/ctf/callbacks.h b/include/babeltrace/ctf/callbacks.h index 43d7af1c..328762ca 100644 --- a/include/babeltrace/ctf/callbacks.h +++ b/include/babeltrace/ctf/callbacks.h @@ -84,7 +84,7 @@ void babeltrace_dependencies_destroy(struct bt_dependencies *dep); */ 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, diff --git a/include/babeltrace/ctf/events-internal.h b/include/babeltrace/ctf/events-internal.h index bd50100d..b01fda4b 100644 --- a/include/babeltrace/ctf/events-internal.h +++ b/include/babeltrace/ctf/events-internal.h @@ -31,9 +31,20 @@ 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 */ /* diff --git a/include/babeltrace/ctf/events.h b/include/babeltrace/ctf/events.h index 2fc82db2..80fbdcf2 100644 --- a/include/babeltrace/ctf/events.h +++ b/include/babeltrace/ctf/events.h @@ -26,7 +26,7 @@ #include struct definition; -struct ctf_event_definition; +struct bt_ctf_event; /* * the top-level scopes in CTF @@ -77,32 +77,32 @@ enum ctf_string_encoding { * 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); @@ -110,7 +110,7 @@ int bt_ctf_get_field_list(const struct ctf_event_definition *event, /* * 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); @@ -118,7 +118,7 @@ const struct definition *bt_ctf_get_field(const struct ctf_event_definition *eve * 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); diff --git a/include/babeltrace/ctf/iterator.h b/include/babeltrace/ctf/iterator.h index 7aeb032c..1071def8 100644 --- a/include/babeltrace/ctf/iterator.h +++ b/include/babeltrace/ctf/iterator.h @@ -26,7 +26,7 @@ #include struct bt_ctf_iter; -struct ctf_event_definition; +struct bt_ctf_event; /* * bt_ctf_iter_create - Allocate a CTF trace collection iterator. @@ -68,6 +68,6 @@ void bt_ctf_iter_destroy(struct bt_ctf_iter *iter); * * 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 */ diff --git a/include/babeltrace/trace-handle.h b/include/babeltrace/trace-handle.h index 0c83bf74..31877ee1 100644 --- a/include/babeltrace/trace-handle.h +++ b/include/babeltrace/trace-handle.h @@ -31,7 +31,7 @@ * 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. @@ -55,6 +55,6 @@ uint64_t bt_trace_handle_get_timestamp_end(struct bt_context *ctx, int handle_id * * 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 */ -- 2.34.1