X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Fctf%2Ffs-src%2Fquery.cpp;h=b11d6f81db23e1938305c7f55263393aa058a705;hb=c7e1be4b771715840b4bc3d635f72eeaf1d2e984;hp=846dde6be4f59b23ffe75ac95c04c03bc8e74df2;hpb=4164020e790fa6c0700715936b40a3fa46df479e;p=babeltrace.git diff --git a/src/plugins/ctf/fs-src/query.cpp b/src/plugins/ctf/fs-src/query.cpp index 846dde6b..b11d6f81 100644 --- a/src/plugins/ctf/fs-src/query.cpp +++ b/src/plugins/ctf/fs-src/query.cpp @@ -6,25 +6,23 @@ * Babeltrace CTF file system Reader Component queries */ +#include +#include +#include + +#include + #define BT_LOG_OUTPUT_LEVEL log_level #define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/QUERY" +#include "logging/comp-logging.h" #include "logging/log.h" -#include "query.hpp" -#include -#include -#include -#include -#include -#include #include "common/assert.h" -#include "metadata.hpp" + #include "../common/metadata/decoder.hpp" -#include "common/common.h" -#include "common/macros.h" -#include #include "fs.hpp" -#include "logging/comp-logging.h" +#include "metadata.hpp" +#include "query.hpp" #define METADATA_TEXT_SIG "/* CTF 1.8" @@ -35,7 +33,6 @@ struct range bool set = false; }; -BT_HIDDEN bt_component_class_query_method_status metadata_info_query(bt_self_component_class_source *self_comp_class_src, const bt_value *params, bt_logging_level log_level, const bt_value **user_result) @@ -53,6 +50,8 @@ metadata_info_query(bt_self_component_class_source *self_comp_class_src, const b struct ctf_metadata_decoder *decoder = NULL; ctf_metadata_decoder_config decoder_cfg {}; enum ctf_metadata_decoder_status decoder_status; + GString *g_metadata_text = NULL; + const char *plaintext; result = bt_value_map_create(); if (!result) { @@ -86,7 +85,7 @@ metadata_info_query(bt_self_component_class_source *self_comp_class_src, const b path = bt_value_string_get(path_value); BT_ASSERT(path); - metadata_fp = ctf_fs_metadata_open_file(path); + metadata_fp = ctf_fs_metadata_open_file(path, log_level, self_comp_class); if (!metadata_fp) { BT_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp_class, "Cannot open trace metadata: path=\"%s\".", path); @@ -119,7 +118,21 @@ metadata_info_query(bt_self_component_class_source *self_comp_class_src, const b goto error; } - ret = bt_value_map_insert_string_entry(result, "text", ctf_metadata_decoder_get_text(decoder)); + plaintext = ctf_metadata_decoder_get_text(decoder); + g_metadata_text = g_string_new(NULL); + + if (!g_metadata_text) { + goto error; + } + + if (strncmp(plaintext, METADATA_TEXT_SIG, sizeof(METADATA_TEXT_SIG) - 1) != 0) { + g_string_assign(g_metadata_text, METADATA_TEXT_SIG); + g_string_append(g_metadata_text, " */\n\n"); + } + + g_string_append(g_metadata_text, plaintext); + + ret = bt_value_map_insert_string_entry(result, "text", g_metadata_text->str); if (ret) { BT_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp_class, "Cannot insert metadata text into query result."); @@ -144,6 +157,9 @@ error: } end: + if (g_metadata_text) { + g_string_free(g_metadata_text, TRUE); + } ctf_metadata_decoder_destroy(decoder); if (metadata_fp) { @@ -296,7 +312,6 @@ end: return ret; } -BT_HIDDEN bt_component_class_query_method_status trace_infos_query(bt_self_component_class_source *self_comp_class_src, const bt_value *params, bt_logging_level log_level, const bt_value **user_result) @@ -321,7 +336,7 @@ trace_infos_query(bt_self_component_class_source *self_comp_class_src, const bt_ goto error; } - ctf_fs = ctf_fs_component_create(log_level, NULL); + ctf_fs = ctf_fs_component_create(log_level); if (!ctf_fs) { goto error; } @@ -373,7 +388,6 @@ end: return status; } -BT_HIDDEN bt_component_class_query_method_status support_info_query(bt_self_component_class_source *comp_class, const bt_value *params, bt_logging_level log_level, const bt_value **user_result)