diff options
author | Yordan Karadzhov (VMware) <y.karadz@gmail.com> | 2019-07-24 18:40:38 +0300 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-07-24 14:39:34 -0400 |
commit | 7ca1204d28e97b9bcc5403e394cd77bc757038e7 (patch) | |
tree | f5202b45fab4595910350d34dd7a99138c3b1c39 | |
parent | a9afc4d2f3fc2ec9a6a727d458f3c3b85ffe4169 (diff) | |
download | trace-cmd-7ca1204d28e97b9bcc5403e394cd77bc757038e7.tar.gz |
kernel-shark: Handle errors when loading Capture configurations
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.
Link: http://lore.kernel.org/linux-trace-devel/20190724154039.23705-4-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/KsCaptureDialog.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp index de2d1655..e8efb381 100644 --- a/kernel-shark/src/KsCaptureDialog.cpp +++ b/kernel-shark/src/KsCaptureDialog.cpp @@ -202,7 +202,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; @@ -235,7 +235,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; @@ -247,8 +254,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)); |