From: Mathieu Desnoyers Date: Tue, 23 Apr 2013 13:05:52 +0000 (-0400) Subject: Add backward ref from bt_stream_pos to bt_trace_descriptor X-Git-Tag: v1.1.1~26 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=ca334c7230d120ffe211efbfd6efe467b5d4d794 Add backward ref from bt_stream_pos to bt_trace_descriptor Signed-off-by: Mathieu Desnoyers --- diff --git a/converter/babeltrace-log.c b/converter/babeltrace-log.c index 8ea64ab3..563a90f5 100644 --- a/converter/babeltrace-log.c +++ b/converter/babeltrace-log.c @@ -252,7 +252,7 @@ void trace_text(FILE *input, int output) int ret; memset(&pos, 0, sizeof(pos)); - ret = ctf_init_pos(&pos, output, O_RDWR); + ret = ctf_init_pos(&pos, NULL, output, O_RDWR); if (ret) { fprintf(stderr, "Error in ctf_init_pos\n"); return; diff --git a/formats/bt-dummy/bt-dummy.c b/formats/bt-dummy/bt-dummy.c index 9fde1c96..6192e888 100644 --- a/formats/bt-dummy/bt-dummy.c +++ b/formats/bt-dummy/bt-dummy.c @@ -54,6 +54,7 @@ struct bt_trace_descriptor *bt_dummy_open_trace(const char *path, int flags, pos = g_new0(struct ctf_text_stream_pos, 1); pos->parent.rw_table = NULL; pos->parent.event_cb = bt_dummy_write_event; + pos->parent.trace = &pos->trace_descriptor; return &pos->trace_descriptor; } diff --git a/formats/ctf-metadata/ctf-metadata.c b/formats/ctf-metadata/ctf-metadata.c index 578e8da8..a5a74c31 100644 --- a/formats/ctf-metadata/ctf-metadata.c +++ b/formats/ctf-metadata/ctf-metadata.c @@ -95,6 +95,7 @@ struct bt_trace_descriptor *ctf_metadata_open_trace(const char *path, int flags, goto error; pos->fp = fp; pos->parent.pre_trace_cb = ctf_metadata_trace_pre_handler; + pos->parent.trace = &pos->trace_descriptor; pos->print_names = 0; break; case O_RDONLY: diff --git a/formats/ctf-text/ctf-text.c b/formats/ctf-text/ctf-text.c index d6bafd31..a508cf68 100644 --- a/formats/ctf-text/ctf-text.c +++ b/formats/ctf-text/ctf-text.c @@ -561,6 +561,7 @@ struct bt_trace_descriptor *ctf_text_open_trace(const char *path, int flags, pos->fp = fp; pos->parent.rw_table = write_dispatch_table; pos->parent.event_cb = ctf_text_write_event; + pos->parent.trace = &pos->trace_descriptor; pos->print_names = 0; break; case O_RDONLY: diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 25f2caff..01035f3d 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -606,7 +606,8 @@ error: return ret; } -int ctf_init_pos(struct ctf_stream_pos *pos, int fd, int open_flags) +int ctf_init_pos(struct ctf_stream_pos *pos, struct bt_trace_descriptor *trace, + int fd, int open_flags) { pos->fd = fd; if (fd >= 0) { @@ -624,12 +625,14 @@ int ctf_init_pos(struct ctf_stream_pos *pos, int fd, int open_flags) pos->flags = MAP_PRIVATE; pos->parent.rw_table = read_dispatch_table; pos->parent.event_cb = ctf_read_event; + pos->parent.trace = trace; break; case O_RDWR: pos->prot = PROT_WRITE; /* Write has priority */ pos->flags = MAP_SHARED; pos->parent.rw_table = write_dispatch_table; pos->parent.event_cb = ctf_write_event; + pos->parent.trace = trace; if (fd >= 0) ctf_packet_seek(&pos->parent, 0, SEEK_SET); /* position for write */ break; @@ -1643,7 +1646,7 @@ int ctf_open_file_stream_read(struct ctf_trace *td, const char *path, int flags, goto error_def; } - ret = ctf_init_pos(&file_stream->pos, fd, flags); + ret = ctf_init_pos(&file_stream->pos, &td->parent, fd, flags); if (ret) goto error_def; ret = create_trace_definitions(td, &file_stream->parent); diff --git a/formats/ctf/types/float.c b/formats/ctf/types/float.c index 2e0bd5ce..2daadf91 100644 --- a/formats/ctf/types/float.c +++ b/formats/ctf/types/float.c @@ -197,7 +197,7 @@ int ctf_float_read(struct bt_stream_pos *ppos, struct bt_definition *definition) } tmpfloat = container_of(tmpdef, struct definition_float, p); memset(&destp, 0, sizeof(destp)); - ctf_init_pos(&destp, -1, O_RDWR); + ctf_init_pos(&destp, NULL, -1, O_RDWR); mmap_align_set_addr(&mma, (char *) u.bits); destp.base_mma = &mma; destp.packet_size = sizeof(u) * CHAR_BIT; @@ -253,7 +253,7 @@ int ctf_float_write(struct bt_stream_pos *ppos, struct bt_definition *definition goto end; } tmpfloat = container_of(tmpdef, struct definition_float, p); - ctf_init_pos(&srcp, -1, O_RDONLY); + ctf_init_pos(&srcp, NULL, -1, O_RDONLY); mmap_align_set_addr(&mma, (char *) u.bits); srcp.base_mma = &mma; srcp.packet_size = sizeof(u) * CHAR_BIT; diff --git a/include/babeltrace/ctf/types.h b/include/babeltrace/ctf/types.h index 781b9429..715cdbd0 100644 --- a/include/babeltrace/ctf/types.h +++ b/include/babeltrace/ctf/types.h @@ -121,7 +121,8 @@ int ctf_sequence_write(struct bt_stream_pos *pos, struct bt_definition *definiti void ctf_packet_seek(struct bt_stream_pos *pos, size_t index, int whence); -int ctf_init_pos(struct ctf_stream_pos *pos, int fd, int open_flags); +int ctf_init_pos(struct ctf_stream_pos *pos, struct bt_trace_descriptor *trace, + int fd, int open_flags); int ctf_fini_pos(struct ctf_stream_pos *pos); /* diff --git a/include/babeltrace/types.h b/include/babeltrace/types.h index 026d28c6..8d660bea 100644 --- a/include/babeltrace/types.h +++ b/include/babeltrace/types.h @@ -119,6 +119,7 @@ struct bt_stream_pos { struct bt_trace_descriptor *trace); int (*post_trace_cb)(struct bt_stream_pos *pos, struct bt_trace_descriptor *trace); + struct bt_trace_descriptor *trace; }; static inline