On 5.11.20 г. 21:22 ч., Steven Rostedt wrote:
On Mon, 12 Oct 2020 16:35:23 +0300 "Yordan Karadzhov (VMware)" <y.karadz@xxxxxxxxx> wrote:+int kshark_import_trace_file(struct kshark_context *kshark_ctx, + struct kshark_config_doc *conf) { - const char *file = NULL; + const char *file = NULL, *name = NULL; + int sd = -1; + switch (conf->format) { case KS_CONFIG_JSON: - if (kshark_trace_file_from_json(&file, conf->conf_doc)) - kshark_open(kshark_ctx, file); + if (kshark_trace_file_from_json(&file, &name, "data", + conf->conf_doc)) { + if (strcmp(name, "top") == 0) {Is "top" something that could be named by a user? That is, we could have a conflict if a buffer is called "top"? If this is a special meaning, then we should probably make this something A user can not do, or even better, unlikely to have. And we shouldn't have it hardcoded as "top" anyway, it should be a macro. #define KERNEL_SHARK_TOP_STREAM "/ / / __Top__ / / /" Then everywhere use that. Like in kshark_tep_init_input(): stream->name = strdup(KERNEL_SHARK_TOP_STREAM); And also replace "top" in this code with that macro as well.
Hi Steven,In the review of patch 13/20 you already suggested to replace the name "top" with a non-printable character:
const char top_name[] = { 0x1b, 0x00 }; // Non printable character #define TOP_NAME (char *)&top_name This change will be included in v3. Thanks! Yordan
-- Steve+ sd = kshark_open(kshark_ctx, file); + } else { + int sd_top; + + sd_top = kshark_tep_find_top_stream(kshark_ctx, + file); + if (sd_top < 0) { + /* + * The "top" steam (buffer) has to be + * initialized first. + */ + sd_top = kshark_open(kshark_ctx, file); + } + + if (sd_top >= 0) + sd = kshark_tep_open_buffer(kshark_ctx, + sd_top, + name); + + if (sd >= 0) + kshark_tep_handle_plugins(kshark_ctx, sd); + } + } + + break;+ default:+ fprintf(stderr, "Document format %d not supported\n", + conf->format); break; + } + + return sd; +}