From caf929fa6105f9dbea79e3c05f9a9cbc7944028a Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 23 Apr 2013 09:22:18 -0400 Subject: [PATCH] Privatize struct bt_trace descriptor, move trace path Signed-off-by: Mathieu Desnoyers --- formats/ctf-text/ctf-text.c | 4 +-- formats/ctf/ctf.c | 8 ++--- include/Makefile.am | 1 + include/babeltrace/ctf-ir/metadata.h | 3 +- include/babeltrace/ctf-text/types.h | 1 + include/babeltrace/format-internal.h | 47 ++++++++++++++++++++++++++++ include/babeltrace/format.h | 5 +-- 7 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 include/babeltrace/format-internal.h diff --git a/formats/ctf-text/ctf-text.c b/formats/ctf-text/ctf-text.c index a508cf68..48ce31b8 100644 --- a/formats/ctf-text/ctf-text.c +++ b/formats/ctf-text/ctf-text.c @@ -316,12 +316,12 @@ int ctf_text_write_event(struct bt_stream_pos *ppos, struct ctf_stream_definitio pos->last_cycles_timestamp = stream->cycles_timestamp; } - if ((opt_trace_field || opt_all_fields) && stream_class->trace->path[0] != '\0') { + if ((opt_trace_field || opt_all_fields) && stream_class->trace->parent.path[0] != '\0') { set_field_names_print(pos, ITEM_HEADER); if (pos->print_names) { fprintf(pos->fp, "trace = "); } - fprintf(pos->fp, "%s", stream_class->trace->path); + fprintf(pos->fp, "%s", stream_class->trace->parent.path); if (pos->print_names) fprintf(pos->fp, ", "); else diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 01035f3d..c3249a01 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -426,9 +426,9 @@ void ctf_print_discarded(FILE *fp, struct ctf_stream_definition *stream, } fprintf(fp, "] in trace UUID "); print_uuid(fp, stream->stream_class->trace->uuid); - if (stream->stream_class->trace->path[0]) + if (stream->stream_class->trace->parent.path[0]) fprintf(fp, ", at path: \"%s\"", - stream->stream_class->trace->path); + stream->stream_class->trace->parent.path); fprintf(fp, ", within stream id %" PRIu64, stream->stream_id); if (stream->path[0]) @@ -1711,8 +1711,8 @@ int ctf_open_trace_read(struct ctf_trace *td, ret = -errno; goto error_dirfd; } - strncpy(td->path, path, sizeof(td->path)); - td->path[sizeof(td->path) - 1] = '\0'; + strncpy(td->parent.path, path, sizeof(td->parent.path)); + td->parent.path[sizeof(td->parent.path) - 1] = '\0'; /* * Keep the metadata file separate. diff --git a/include/Makefile.am b/include/Makefile.am index 824be61b..6a65b5cf 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -19,6 +19,7 @@ noinst_HEADERS = \ babeltrace/clock-internal.h \ babeltrace/compiler.h \ babeltrace/context-internal.h \ + babeltrace/format-internal.h \ babeltrace/iterator-internal.h \ babeltrace/trace-collection.h \ babeltrace/prio_heap.h \ diff --git a/include/babeltrace/ctf-ir/metadata.h b/include/babeltrace/ctf-ir/metadata.h index eb37c2df..e4ab593e 100644 --- a/include/babeltrace/ctf-ir/metadata.h +++ b/include/babeltrace/ctf-ir/metadata.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -176,6 +177,7 @@ struct ctf_tracer_env { struct ctf_trace { struct bt_trace_descriptor parent; + /* root scope */ struct declaration_scope *root_declaration_scope; @@ -215,7 +217,6 @@ struct ctf_trace { /* Heap of streams, ordered to always get the lowest timestamp */ struct ptr_heap *stream_heap; - char path[PATH_MAX]; struct bt_context *ctx; struct bt_trace_handle *handle; diff --git a/include/babeltrace/ctf-text/types.h b/include/babeltrace/ctf-text/types.h index 74a68a14..7b4b7171 100644 --- a/include/babeltrace/ctf-text/types.h +++ b/include/babeltrace/ctf-text/types.h @@ -35,6 +35,7 @@ #include #include #include +#include /* * Inherit from both struct bt_stream_pos and struct bt_trace_descriptor. diff --git a/include/babeltrace/format-internal.h b/include/babeltrace/format-internal.h new file mode 100644 index 00000000..281fd1d9 --- /dev/null +++ b/include/babeltrace/format-internal.h @@ -0,0 +1,47 @@ +#ifndef _BABELTRACE_FORMAT_INTERNAL_H +#define _BABELTRACE_FORMAT_INTERNAL_H + +/* + * BabelTrace + * + * Trace Format Internal Header + * + * Copyright 2010-2013 EfficiOS Inc. and Linux Foundation + * + * Author: Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Parent trace descriptor */ +struct bt_trace_descriptor { + char path[PATH_MAX]; /* trace path */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _BABELTRACE_FORMAT_INTERNAL_H */ diff --git a/include/babeltrace/format.h b/include/babeltrace/format.h index f1f87632..07e854fe 100644 --- a/include/babeltrace/format.h +++ b/include/babeltrace/format.h @@ -44,10 +44,7 @@ typedef int bt_intern_str; struct bt_stream_pos; struct bt_context; struct bt_trace_handle; - -/* Parent trace descriptor */ -struct bt_trace_descriptor { -}; +struct bt_trace_descriptor; struct bt_mmap_stream { int fd; -- 2.34.1