#include <babeltrace/ctf/metadata.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/ctf/events-internal.h>
+#include <babeltrace/trace-handle-internal.h>
+#include <babeltrace/context-internal.h>
#include <babeltrace/uuid.h>
#include <babeltrace/endian.h>
#include <inttypes.h>
void (*packet_seek)(struct stream_pos *pos, size_t index,
int whence),
FILE *metadata_fp);
+static
+void ctf_set_context(struct trace_descriptor *descriptor,
+ struct bt_context *ctx);
+static
+void ctf_set_handle(struct trace_descriptor *descriptor,
+ struct bt_trace_handle *handle);
static
void ctf_close_trace(struct trace_descriptor *descriptor);
.open_trace = ctf_open_trace,
.open_mmap_trace = ctf_open_mmap_trace,
.close_trace = ctf_close_trace,
+ .set_context = ctf_set_context,
+ .set_handle = ctf_set_handle,
};
/*
g_free(td);
}
+static
+void ctf_set_context(struct trace_descriptor *descriptor,
+ struct bt_context *ctx)
+{
+ struct ctf_trace *td = container_of(descriptor, struct ctf_trace,
+ parent);
+
+ td->ctx = ctx;
+}
+
+static
+void ctf_set_handle(struct trace_descriptor *descriptor,
+ struct bt_trace_handle *handle)
+{
+ struct ctf_trace *td = container_of(descriptor, struct ctf_trace,
+ parent);
+
+ td->handle = handle;
+}
+
void __attribute__((constructor)) ctf_init(void)
{
int ret;
return -1;
}
+struct bt_context *bt_ctf_event_get_context(const struct bt_ctf_event *event)
+{
+ struct bt_context *ret = NULL;
+ struct ctf_file_stream *cfs;
+ struct ctf_stream *stream;
+ struct ctf_stream_class *stream_class;
+ struct ctf_trace *trace;
+
+ cfs = container_of(event->stream, struct ctf_file_stream,
+ parent);
+ stream = &cfs->parent;
+ stream_class = stream->stream_class;
+ trace = stream_class->trace;
+
+ if (trace->ctx)
+ ret = trace->ctx;
+
+ return ret;
+}
+
+int bt_ctf_event_get_handle_id(const struct bt_ctf_event *event)
+{
+ int ret = -1;
+ struct ctf_file_stream *cfs;
+ struct ctf_stream *stream;
+ struct ctf_stream_class *stream_class;
+ struct ctf_trace *trace;
+
+ cfs = container_of(event->stream, struct ctf_file_stream,
+ parent);
+ stream = &cfs->parent;
+ stream_class = stream->stream_class;
+ trace = stream_class->trace;
+
+ if (trace->handle)
+ ret = trace->handle->id;
+
+ return ret;
+}
+
uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *event)
{
if (event && event->stream->has_timestamp)
/* struct bt_context is opaque to the user */
struct bt_context;
struct stream_pos;
+struct bt_ctf_event;
/*
* bt_context_create : create a Babeltrace context
void bt_context_get(struct bt_context *ctx);
void bt_context_put(struct bt_context *ctx);
+/*
+ * bt_ctf_get_context : get the context associated with an event
+ *
+ * Returns NULL on error
+ */
+struct bt_context *bt_ctf_event_get_context(const struct bt_ctf_event *event);
+
#endif /* _BABELTRACE_CONTEXT_H */
/* Heap of streams, ordered to always get the lowest timestam */
struct ptr_heap *stream_heap;
char path[PATH_MAX];
+
+ struct bt_context *ctx;
+ struct bt_trace_handle *handle;
};
#define CTF_STREAM_SET_FIELD(ctf_stream, field) \
#include <babeltrace/format.h>
#include <babeltrace/ctf/types.h>
#include <babeltrace/ctf-ir/metadata.h>
+#include <babeltrace/trace-handle-internal.h>
+#include <babeltrace/context-internal.h>
#include <sys/types.h>
#include <dirent.h>
#include <assert.h>
/* forward declaration */
struct stream_pos;
+struct bt_context;
+struct bt_trace_handle;
/* Parent trace descriptor */
struct trace_descriptor {
size_t index, int whence),
FILE *metadata_fp);
void (*close_trace)(struct trace_descriptor *descriptor);
+ void (*set_context)(struct trace_descriptor *descriptor,
+ struct bt_context *ctx);
+ void (*set_handle)(struct trace_descriptor *descriptor,
+ struct bt_trace_handle *handle);
};
extern struct format *bt_lookup_format(bt_intern_str qname);
* It is a unique identifier representing a trace file.
*/
struct bt_trace_handle;
+struct bt_ctf_event;
/*
* bt_trace_handle_get_path : returns the path of a trace_handle.
*/
uint64_t bt_trace_handle_get_timestamp_end(struct bt_context *ctx, int handle_id);
+/*
+ * bt_ctf_event_get_handle_id : get the handle id associated with an event
+ *
+ * Returns -1 on error
+ */
+int bt_ctf_event_get_handle_id(const struct bt_ctf_event *event);
+
#endif /* _BABELTRACE_TRACE_HANDLE_H */
strncpy(handle->path, path, PATH_MAX);
handle->path[PATH_MAX - 1] = '\0';
+ if (fmt->set_handle)
+ fmt->set_handle(td, handle);
+ if (fmt->set_context)
+ fmt->set_context(td, ctx);
+
/* Add new handle to container */
g_hash_table_insert(ctx->trace_handles,
(gpointer) (unsigned long) handle->id,