Skip to contentSkip to conversation

Fixes needed befor KS 1.0

PATCH In review Yordan Karadzhov (VMware) 2 participants 5 messages Jul 23, 2019

lore
Share & tools
lore
#0 lore raw

cover Fixes needed befor KS 1.0

Adderssing the issues reported by "howaboutsynergy" here:

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204277

Yordan Karadzhov (VMware) (3):
kernel-shark: Make KsEventsCheckBoxWidget::removeSystem more robust
kernel-shark: Better error message for the constructor of
KsCaptureControl
kernel-shark: Disable Capture if trace-cmd can't function

 kernel-shark/src/KsCaptureDialog.cpp | 25 ++++++++++++++++++++++---
 kernel-shark/src/KsWidgetsLib.cpp    |  9 ++++++---
 2 files changed, 28 insertions(+), 6 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/3 kernel-shark: Make KsEventsCheckBoxWidget::removeSystem more robust

The function has to be able to handle safely the case when the Checkbox tree widget is empty or it does not contain the item to be removed.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204277

Fixes 4a02481fff (Remove all system=ftrace events from Record dialog)
---
 kernel-shark/src/KsWidgetsLib.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
kernel-shark/src/KsWidgetsLib.cpp +6 -3
index 84afec9..330230e 100644
@@ -749,10 +749,13 @@ QStringList KsEventsCheckBoxWidget::getCheckedEvents(bool option)
 
 /** Remove a System from the Checkbox tree. */
 void KsEventsCheckBoxWidget::removeSystem(QString name) {
-	QTreeWidgetItem *item =
-		_tree.findItems(name, Qt::MatchFixedString, 0)[0];
+	auto itemList = _tree.findItems(name, Qt::MatchFixedString, 0);
+	int index;
 
-	int index = _tree.indexOfTopLevelItem(item);
+	if (itemList.isEmpty())
+		return;
+
+	index = _tree.indexOfTopLevelItem(itemList[0]);
 	if (index >= 0)
 		_tree.takeTopLevelItem(index);
 }
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/3 kernel-shark: Better error message for the constructor of KsCaptureControl

In reply to Yordan Karadzhov (VMware)

The error message includes the case when the tracing directory cannot be found or mounted.

---
 kernel-shark/src/KsCaptureDialog.cpp | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
kernel-shark/src/KsCaptureDialog.cpp +10 -4
index 0a29518..2e6e8f9 100644
@@ -55,13 +55,19 @@ KsCaptureControl::KsCaptureControl(QWidget *parent)
 		_topLayout.addWidget(line);
 	};
 
-	if (pluginList.count() == 0) {
+	if (pluginList.count() == 0 || !_localTEP) {
 		/*
-		 * No plugins have been found. Most likely this is because
-		 * the process has no Root privileges.
+		 * No plugins or events have been found. Most likely this is
+		 * because the process has no Root privileges or because
+		 * tracefs cannot be mounted.
 		 */
 		QString message("Error: No events or plugins found.\n");
-		message += "Root privileges are required.";
+
+		if (!_localTEP)
+			message += "Cannot find or mount tracing directory.\n";
+		if (!pluginList.count())
+			message += "Root privileges are required.\n";
+
 		QLabel *errorLabel = new QLabel(message);
 
 		errorLabel->setStyleSheet("QLabel {color : red;}");
Signature · 1 line
2.20.1
#3 lore raw

PATCH 3/3 kernel-shark: Disable Capture if trace-cmd can't function

In reply to Yordan Karadzhov (VMware)

In the case of an error all key buttons of the Record dialog are disabled.

---
 kernel-shark/src/KsCaptureDialog.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)
kernel-shark/src/KsCaptureDialog.cpp +13 -0
index 2e6e8f9..2962917 100644
@@ -74,6 +74,19 @@ KsCaptureControl::KsCaptureControl(QWidget *parent)
 		_topLayout.addWidget(errorLabel);
 
 		lamAddLine();
+
+		/* Disable all key buttons. */
+		QVector<QWidget *> widgets =
+			{&_importSettingsButton,
+			 &_exportSettingsButton,
+			 &_outputBrowseButton,
+			 &_pluginsComboBox,
+			 &_commandCheckBox,
+			 &_applyButton,
+			 &_captureButton};
+
+		for (auto &b: widgets)
+			b->setDisabled(true);
 	}
 
 	pluginList.prepend("nop");
Signature · 1 line
2.20.1
#4 lore raw

Re: [PATCH 3/3] kernel-shark: Disable Capture if trace-cmd can't function

Quoted 2 lines · On Tue, 23 Jul 2019 15:52:04 +0300 "Yordan Karadzhov (VMware)"…

In the case of an error all key buttons of the Record dialog are disabled.

I applied and pushed out your other two patches, but didn't apply this one. As we discussed at our 1:1, I think it's better to at a minimum, just disable the "Capture" button, as that's the only thing that really needs "root". If we can't read the events or the tracers, then they will just stay empty or set to a single default value.

No reason to disable export and import settings, the user can do that, but it wont help them much.

-- Steve

Quoted 30 lines
---
 kernel-shark/src/KsCaptureDialog.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)
kernel-shark/src/KsCaptureDialog.cpp +13 -0
index 2e6e8f9..2962917 100644
@@ -74,6 +74,19 @@ KsCaptureControl::KsCaptureControl(QWidget *parent)
 		_topLayout.addWidget(errorLabel);
 
 		lamAddLine();
+
+		/* Disable all key buttons. */
+		QVector<QWidget *> widgets =
+			{&_importSettingsButton,
+			 &_exportSettingsButton,
+			 &_outputBrowseButton,
+			 &_pluginsComboBox,
+			 &_commandCheckBox,
+			 &_applyButton,
+			 &_captureButton};
+
+		for (auto &b: widgets)
+			b->setDisabled(true);
 	}
 
 	pluginList.prepend("nop");