/* For each stream (TODO: order events by timestamp) */
for (stream_id = 0; stream_id < tin->streams->len; stream_id++) {
- struct ctf_stream *stream = g_ptr_array_index(tin->streams, stream_id);
+ struct ctf_stream_class *stream = g_ptr_array_index(tin->streams, stream_id);
if (!stream)
continue;
static
int ctf_text_write_event(struct stream_pos *ppos,
- struct ctf_stream *stream_class)
+ struct ctf_stream_class *stream_class)
{
struct ctf_text_stream_pos *pos =
container_of(ppos, struct ctf_text_stream_pos, parent);
uint64_t id = 0;
int len_index;
int ret;
+ int field_nr = 0;
/* print event header */
if (stream_class->event_header) {
return -EINVAL;
}
+ if (field_nr++ != 0)
+ fprintf(pos->fp, ", ");
+ if (pos->print_names)
+ fprintf(pos->fp, "timestamp = ");
+ else
+ fprintf(pos->fp, "[");
+ fprintf(pos->fp, "%" PRIu64, (uint64_t) 0); /* TODO */
+ if (!pos->print_names)
+ fprintf(pos->fp, "]");
+
+ if (field_nr++ != 0)
+ fprintf(pos->fp, ", ");
if (pos->print_names)
fprintf(pos->fp, "name = ");
- fprintf(pos->fp, "%s", g_quark_to_string(event_class->name));
+ fprintf(pos->fp, "%s: ", g_quark_to_string(event_class->name));
if (stream_class->event_header) {
+ if (field_nr++ != 0)
+ fprintf(pos->fp, ", ");
if (pos->print_names)
- fprintf(pos->fp, ", stream.event.header =");
- else
- fprintf(pos->fp, ",");
- fprintf(pos->fp, " ");
+ fprintf(pos->fp, "stream.event.header = ");
ret = generic_rw(ppos, &stream_class->event_header->p);
if (ret)
goto error;
/* print stream-declared event context */
if (stream_class->event_context) {
+ if (field_nr++ != 0)
+ fprintf(pos->fp, ", ");
if (pos->print_names)
- fprintf(pos->fp, ", stream.event.context =");
- else
- fprintf(pos->fp, ",");
+ fprintf(pos->fp, "stream.event.context = ");
fprintf(pos->fp, " ");
ret = generic_rw(ppos, &stream_class->event_context->p);
if (ret)
/* print event-declared event context */
if (event_class->context) {
+ if (field_nr++ != 0)
+ fprintf(pos->fp, ", ");
if (pos->print_names)
- fprintf(pos->fp, ", event.context =");
- else
- fprintf(pos->fp, ",");
+ fprintf(pos->fp, "event.context = ");
fprintf(pos->fp, " ");
ret = generic_rw(ppos, &event_class->context->p);
if (ret)
/* Read and print event payload */
if (event_class->fields) {
+ if (field_nr++ != 0)
+ fprintf(pos->fp, ", ");
if (pos->print_names)
- fprintf(pos->fp, ", event.fields =");
- else
- fprintf(pos->fp, ",");
+ fprintf(pos->fp, "event.fields = ");
fprintf(pos->fp, " ");
ret = generic_rw(ppos, &event_class->fields->p);
if (ret)
};
static
-int ctf_read_event(struct stream_pos *ppos, struct ctf_stream *stream_class)
+int ctf_read_event(struct stream_pos *ppos, struct ctf_stream_class *stream_class)
{
struct ctf_stream_pos *pos =
container_of(ppos, struct ctf_stream_pos, parent);
}
static
-int ctf_write_event(struct stream_pos *pos, struct ctf_stream *stream_class)
+int ctf_write_event(struct stream_pos *pos, struct ctf_stream_class *stream_class)
{
struct ctf_event *event_class;
uint64_t id = 0;
int create_stream_packet_index(struct ctf_trace *td,
struct ctf_file_stream *file_stream)
{
- struct ctf_stream *stream;
+ struct ctf_stream_class *stream;
int len_index;
struct ctf_stream_pos *pos;
struct stat filestats;
if (td->streams) {
for (i = 0; i < td->streams->len; i++) {
- struct ctf_stream *stream;
+ struct ctf_stream_class *stream;
int j;
stream = g_ptr_array_index(td->streams, i);
for (j = 0; j < stream->files->len; j++) {
}
static
-struct ctf_stream *trace_stream_lookup(struct ctf_trace *trace, uint64_t stream_id)
+struct ctf_stream_class *trace_stream_lookup(struct ctf_trace *trace, uint64_t stream_id)
{
if (trace->streams->len <= stream_id)
return NULL;
static
-int ctf_stream_declaration_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_stream *stream, struct ctf_trace *trace)
+int ctf_stream_declaration_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_stream_class *stream, struct ctf_trace *trace)
{
int ret = 0;
{
int ret = 0;
struct ctf_node *iter;
- struct ctf_stream *stream;
+ struct ctf_stream_class *stream;
struct definition_scope *parent_def_scope;
- stream = g_new0(struct ctf_stream, 1);
+ stream = g_new0(struct ctf_stream_class, 1);
stream->declaration_scope = new_declaration_scope(parent_declaration_scope);
stream->events_by_id = g_ptr_array_new();
stream->event_quark_to_id = g_hash_table_new(g_direct_hash, g_direct_equal);
#define CTF_MAGIC 0xC1FC1FC1
struct ctf_trace;
-struct ctf_stream;
+struct ctf_stream_class;
struct ctf_event;
struct ctf_file_stream {
uint64_t stream_id;
- struct ctf_stream *stream;
- struct ctf_stream_pos pos; /* current stream position */
+ struct ctf_stream_class *stream;
+ struct ctf_stream_pos pos; /* current stream position */
};
#define CTF_TRACE_SET_FIELD(ctf_trace, field) \
struct declaration_scope *declaration_scope;
/* innermost definition scope. to be used as parent of stream. */
struct definition_scope *definition_scope;
- GPtrArray *streams; /* Array of struct ctf_stream pointers */
+ GPtrArray *streams; /* Array of struct ctf_stream_class pointers */
struct ctf_file_stream metadata;
/* Declarations only used when parsing */
(ctf_stream)->(field); \
})
-struct ctf_stream {
+struct ctf_stream_class {
struct ctf_trace *trace;
/* parent is lexical scope conaining the stream scope */
struct declaration_scope *declaration_scope;
struct ctf_event {
/* stream mapped by stream_id */
- struct ctf_stream *stream;
+ struct ctf_stream_class *stream;
/* parent is lexical scope conaining the event scope */
struct declaration_scope *declaration_scope;
/* Preallocate this many fields for structures */
#define DEFAULT_NR_STRUCT_FIELDS 8
-struct ctf_stream;
+struct ctf_stream_class;
struct stream_pos;
struct format;
struct definition;
/* read/write dispatch table. Specific to plugin used for stream. */
rw_dispatch *rw_table; /* rw dispatch table */
int (*event_cb)(struct stream_pos *pos,
- struct ctf_stream *stream_class);
+ struct ctf_stream_class *stream_class);
};
static inline