aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYordan Karadzhov (VMware) <y.karadz@gmail.com>2019-07-24 18:40:36 +0300
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2019-07-24 14:38:29 -0400
commit1e40b00ebc3eb013d6259c261792054792779b31 (patch)
tree4a7cd30f8a4524771dac215dd901cd5a02d857f9
parent5f3fba3f09c87b7cb1e27b1b8b72387a0c427a0c (diff)
downloadtrace-cmd-1e40b00ebc3eb013d6259c261792054792779b31.tar.gz
kernel-shark: kshark_import_event_filter() tolerates non-existing events
Instead of aborting, the function will ignore (skip) the non-existing event and will continue loading the other events in the configuration file. The return type is changed to int in order to provide information about the number of events successfully added to the filter. Link: http://lore.kernel.org/linux-trace-devel/20190724154039.23705-2-y.karadz@gmail.com Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204287 Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--kernel-shark/src/libkshark-configio.c33
-rw-r--r--kernel-shark/src/libkshark.h8
2 files changed, 23 insertions, 18 deletions
diff --git a/kernel-shark/src/libkshark-configio.c b/kernel-shark/src/libkshark-configio.c
index cac27a78..5d7323f8 100644
--- a/kernel-shark/src/libkshark-configio.c
+++ b/kernel-shark/src/libkshark-configio.c
@@ -793,7 +793,7 @@ bool kshark_export_event_filter(struct tep_handle *pevent,
}
}
-static bool kshark_event_filter_from_json(struct tep_handle *pevent,
+static int kshark_event_filter_from_json(struct tep_handle *pevent,
struct tracecmd_filter_id *filter,
const char *filter_name,
struct json_object *jobj)
@@ -801,7 +801,7 @@ static bool kshark_event_filter_from_json(struct tep_handle *pevent,
json_object *jfilter, *jevent, *jsystem, *jname;
const char *system_str, *name_str;
struct tep_event *event;
- int i, length;
+ int i, length, count = 0;
/*
* Use the name of the filter to find the array of events associated
@@ -809,7 +809,7 @@ static bool kshark_event_filter_from_json(struct tep_handle *pevent,
* contain no data for this particular filter.
*/
if (!json_object_object_get_ex(jobj, filter_name, &jfilter))
- return false;
+ return 0;
if (!kshark_json_type_check(jobj, "kshark.config.filter") ||
json_object_get_type(jfilter) != json_type_array)
@@ -829,16 +829,21 @@ static bool kshark_event_filter_from_json(struct tep_handle *pevent,
event = tep_find_event_by_name(pevent, system_str, name_str);
if (!event)
- goto fail;
+ continue;
tracecmd_filter_id_add(filter, event->id);
+ ++count;
}
- return true;
+ if (count != length)
+ count = -count;
+
+ return count;
fail:
fprintf(stderr, "Failed to load event filter from json_object.\n");
- return false;
+ tracecmd_filter_id_clear(filter);
+ return 0;
}
/**
@@ -851,14 +856,14 @@ static bool kshark_event_filter_from_json(struct tep_handle *pevent,
* @param conf: Input location for the kshark_config_doc instance. Currently
* only Json format is supported.
*
- * @returns True, if a filter has been loaded. If the filter configuration
- * document contains no data for this particular filter or in a case
- * of an error, the function returns False.
+ * @returns The total number of events added to the filter. If not all events
+ * listed in the input configuration have been added successfully,
+ * the returned number is negative.
*/
-bool kshark_import_event_filter(struct tep_handle *pevent,
- struct tracecmd_filter_id *filter,
- const char *filter_name,
- struct kshark_config_doc *conf)
+int kshark_import_event_filter(struct tep_handle *pevent,
+ struct tracecmd_filter_id *filter,
+ const char *filter_name,
+ struct kshark_config_doc *conf)
{
switch (conf->format) {
case KS_CONFIG_JSON:
@@ -869,7 +874,7 @@ bool kshark_import_event_filter(struct tep_handle *pevent,
default:
fprintf(stderr, "Document format %d not supported\n",
conf->format);
- return false;
+ return 0;
}
}
diff --git a/kernel-shark/src/libkshark.h b/kernel-shark/src/libkshark.h
index fe353336..04e9cbfc 100644
--- a/kernel-shark/src/libkshark.h
+++ b/kernel-shark/src/libkshark.h
@@ -587,10 +587,10 @@ bool kshark_export_event_filter(struct tep_handle *pevent,
const char *filter_name,
struct kshark_config_doc *conf);
-bool kshark_import_event_filter(struct tep_handle *pevent,
- struct tracecmd_filter_id *filter,
- const char *filter_name,
- struct kshark_config_doc *conf);
+int kshark_import_event_filter(struct tep_handle *pevent,
+ struct tracecmd_filter_id *filter,
+ const char *filter_name,
+ struct kshark_config_doc *conf);
bool kshark_export_user_mask(struct kshark_context *kshark_ctx,
struct kshark_config_doc **conf);