From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH 3/4] kernel-shark: Handle errors when loading Capture configurations
Date: Wed, 24 Jul 2019 18:40:38 +0300 [thread overview]
Message-ID: <20190724154039.23705-4-y.karadz@gmail.com> (raw)
In-Reply-To: <20190724154039.23705-1-y.karadz@gmail.com>
A configuration file (Json) for the Capture dialog can contain
non-existing tracer plugin or events. This can happen if the
configuration was exported on one machine and then imported on
another. In such a case the non-existing plugin/events will be
ignored and a warning message will be printed to the console-like
widget.
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
kernel-shark/src/KsCaptureDialog.cpp | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp
index 6e526ff..02bbbbc 100644
--- a/kernel-shark/src/KsCaptureDialog.cpp
+++ b/kernel-shark/src/KsCaptureDialog.cpp
@@ -194,7 +194,7 @@ QStringList KsCaptureControl::_getPlugins()
void KsCaptureControl::_importSettings()
{
- int nEvts = tep_get_events_count(_localTEP);
+ int nEvts = tep_get_events_count(_localTEP), nIds;
kshark_config_doc *conf, *jevents, *temp;
QVector<bool> v(nEvts, false);
tracecmd_filter_id *eventHash;
@@ -227,7 +227,14 @@ void KsCaptureControl::_importSettings()
return;
eventHash = tracecmd_filter_id_hash_alloc();
- kshark_import_event_filter(_localTEP, eventHash, "Events", jevents);
+ nIds = kshark_import_event_filter(_localTEP, eventHash, "Events", jevents);
+ if (nIds < 0) {
+ QString err("WARNING: ");
+ err += "Some of the imported events are not available on this system.\n";
+ err += "All missing events are ignored.\n";
+ emit print(err);
+ }
+
for (int i = 0; i < nEvts; ++i) {
if (tracecmd_filter_id_find(eventHash, events[i]->id))
v[i] = true;
@@ -239,8 +246,19 @@ void KsCaptureControl::_importSettings()
/** Get all available plugins. */
temp = kshark_string_config_alloc();
- if (kshark_config_doc_get(conf, "Plugin", temp))
- _pluginsComboBox.setCurrentText(KS_C_STR_CAST(temp->conf_doc));
+ if (kshark_config_doc_get(conf, "Plugin", temp)) {
+ const char *plugin = KS_C_STR_CAST(temp->conf_doc);
+ int pluginIndex = _pluginsComboBox.findText(plugin);
+
+ if (pluginIndex >= 0) {
+ _pluginsComboBox.setCurrentText(KS_C_STR_CAST(temp->conf_doc));
+ } else {
+ QString err("WARNING: The traceer plugin \"");
+ err += plugin;
+ err += "\" is not available on this machine\n";
+ emit print(err);
+ }
+ }
if (kshark_config_doc_get(conf, "Output", temp))
_outputLineEdit.setText(KS_C_STR_CAST(temp->conf_doc));
--
2.20.1
next prev parent reply other threads:[~2019-07-24 15:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-24 15:40 [PATCH 0/3] Fixes for Capture needed befor KS 1.0 Yordan Karadzhov (VMware)
2019-07-24 15:40 ` [PATCH 1/4] kernel-shark: kshark_import_event_filter() tolerates non-existing events Yordan Karadzhov (VMware)
2019-07-24 15:40 ` [PATCH 2/4] kernel-shark: Allow KsCaptureControl widget to print text to the console Yordan Karadzhov (VMware)
2019-07-24 15:40 ` Yordan Karadzhov (VMware) [this message]
2019-07-24 15:40 ` [PATCH 4/4] kernel-shark: Handle corrupted configuration file for the Capture dialog Yordan Karadzhov (VMware)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190724154039.23705-4-y.karadz@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).