X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Fctf%2Ffs-sink%2Ffs-sink-trace.c;h=60f668ea3df5929e26eaa41134e2bfb2363febeb;hb=72d458a311ee9b8c2cc84d8ade5754e5ea517fcb;hp=d41e1d9f31a4c2ed3fe47f0f24539a3a2d498b3c;hpb=d9c39b0a4ad9517178899334c0ca89fd20901609;p=babeltrace.git diff --git a/src/plugins/ctf/fs-sink/fs-sink-trace.c b/src/plugins/ctf/fs-sink/fs-sink-trace.c index d41e1d9f..60f668ea 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-trace.c +++ b/src/plugins/ctf/fs-sink/fs-sink-trace.c @@ -1,23 +1,7 @@ /* - * Copyright 2019 Philippe Proulx - * - * 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. + * SPDX-License-Identifier: MIT * - * 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. + * Copyright 2019 Philippe Proulx */ #define BT_COMP_LOG_SELF_COMP (trace->fs_sink->self_comp) @@ -133,6 +117,15 @@ GString *make_unique_trace_path(const char *path) return unique_path; } +/* + * Disable `deprecated-declarations` warnings for + * lttng_validate_datetime() because we're using `GTimeVal` and + * g_time_val_from_iso8601() which are deprecated since GLib 2.56 + * (Babeltrace supports older versions too). + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /* * Validate that the input string `datetime` is an ISO8601-compliant string (the * format used by LTTng in the metadata). @@ -162,6 +155,8 @@ end: return ret; } +#pragma GCC diagnostic pop + static int append_lttng_trace_path_ust_uid(const struct fs_sink_trace *trace, GString *path, const bt_trace *tc) @@ -178,9 +173,9 @@ int append_lttng_trace_path_ust_uid(const struct fs_sink_trace *trace, g_string_append_printf(path, G_DIR_SEPARATOR_S "%" PRId64, bt_value_integer_signed_get(v)); - v = bt_trace_borrow_environment_entry_value_by_name_const(tc, "isa_length"); + v = bt_trace_borrow_environment_entry_value_by_name_const(tc, "architecture_bit_width"); if (!v || !bt_value_is_signed_integer(v)) { - BT_COMP_LOGI_STR("Couldn't get environment value: name=\"isa_length\""); + BT_COMP_LOGI_STR("Couldn't get environment value: name=\"architecture_bit_width\""); goto error; } @@ -396,12 +391,9 @@ static GString *make_trace_path_rel(const struct fs_sink_trace *trace) { GString *path = NULL; + const char *trace_name; - if (trace->fs_sink->assume_single_trace) { - /* Use output directory directly */ - path = g_string_new(""); - goto end; - } + BT_ASSERT(!trace->fs_sink->assume_single_trace); /* First, try to build a path using environment fields written by LTTng. */ path = make_lttng_trace_path_rel(trace); @@ -410,7 +402,7 @@ GString *make_trace_path_rel(const struct fs_sink_trace *trace) } /* Otherwise, use the trace name, if available. */ - const char *trace_name = bt_trace_get_name(trace->ir_trace); + trace_name = bt_trace_get_name(trace->ir_trace); if (trace_name) { path = g_string_new(trace_name); goto end; @@ -435,25 +427,33 @@ GString *make_trace_path(const struct fs_sink_trace *trace, const char *output_b GString *full_path = NULL; GString *unique_full_path = NULL; - rel_path = make_trace_path_rel(trace); - if (!rel_path) { - goto end; - } + if (trace->fs_sink->assume_single_trace) { + /* Use output directory directly */ + unique_full_path = g_string_new(output_base_directory); + if (!unique_full_path) { + goto end; + } + } else { + rel_path = make_trace_path_rel(trace); + if (!rel_path) { + goto end; + } - rel_path_san = sanitize_trace_path(rel_path->str); - if (!rel_path_san) { - goto end; - } + rel_path_san = sanitize_trace_path(rel_path->str); + if (!rel_path_san) { + goto end; + } - full_path = g_string_new(NULL); - if (!full_path) { - goto end; - } + full_path = g_string_new(NULL); + if (!full_path) { + goto end; + } - g_string_printf(full_path, "%s" G_DIR_SEPARATOR_S "%s", - output_base_directory, rel_path_san->str); + g_string_printf(full_path, "%s" G_DIR_SEPARATOR_S "%s", + output_base_directory, rel_path_san->str); - unique_full_path = make_unique_trace_path(full_path->str); + unique_full_path = make_unique_trace_path(full_path->str); + } end: if (rel_path) { @@ -506,17 +506,17 @@ void fs_sink_trace_destroy(struct fs_sink_trace *trace) fh = fopen(trace->metadata_path->str, "wb"); if (!fh) { BT_COMP_LOGF_ERRNO("In trace destruction listener: " - "cannot open metadata file for writing: ", + "cannot open metadata file for writing", ": path=\"%s\"", trace->metadata_path->str); - abort(); + bt_common_abort(); } len = fwrite(tsdl->str, sizeof(*tsdl->str), tsdl->len, fh); if (len != tsdl->len) { BT_COMP_LOGF_ERRNO("In trace destruction listener: " - "cannot write metadata file: ", + "cannot write metadata file", ": path=\"%s\"", trace->metadata_path->str); - abort(); + bt_common_abort(); } if (!trace->fs_sink->quiet) { @@ -528,28 +528,26 @@ void fs_sink_trace_destroy(struct fs_sink_trace *trace) trace->path = NULL; } - g_string_free(trace->metadata_path, TRUE); - trace->metadata_path = NULL; - - fs_sink_ctf_trace_destroy(trace->trace); - trace->trace = NULL; - g_free(trace); - -end: if (fh) { int ret = fclose(fh); if (ret != 0) { BT_COMP_LOGW_ERRNO("In trace destruction listener: " - "cannot close metadata file: ", + "cannot close metadata file", ": path=\"%s\"", trace->metadata_path->str); } } - if (tsdl) { - g_string_free(tsdl, TRUE); - } + g_string_free(trace->metadata_path, TRUE); + trace->metadata_path = NULL; + + fs_sink_ctf_trace_destroy(trace->trace); + trace->trace = NULL; + g_free(trace); + g_string_free(tsdl, TRUE); + +end: return; }