Skip to contentSkip to conversation

kernel-shark: The road to 1.0

PATCH In review Steven Rostedt 2 participants 7 messages Jul 10, 2019 – Jul 17, 2019

lore
Share & tools
lore
#0 lore raw

cover kernel-shark: The road to 1.0

Some fixes for getting to 1.0.

Steven Rostedt (VMware) (3):
revert: "kernel-shark: Remove a duplicate error message"
kernel-shark: Show the standard error of kshark-record
kernel-shark: Use '<br>' for dialog and '\n' for console error messages

Yordan Karadzhov (VMware) (1):
kernel-shark: Remove the "make install" suggestion for capture errors

----

 kernel-shark/src/KsMainWindow.cpp | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)
#1 lore raw

PATCH 1/4 revert: "kernel-shark: Remove a duplicate error message"

From: "Steven Rostedt (VMware)" <[email protected]>

It turns out that if the kshark-record dialog does not show up for some reason, then without this "duplicate" message, the user gets no message at all to why the dialog did not appear.

---
 kernel-shark/src/KsMainWindow.cpp | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
kernel-shark/src/KsMainWindow.cpp +26 -0
index 8826cf5cf8b2..198b410480a1 100644
@@ -1154,9 +1154,35 @@ void KsMainWindow::_captureStarted()
 	_captureLocalServer.listen("KSCapture");
 }
 
+/**
+ * If the authorization could not be obtained because the user dismissed
+ * the authentication dialog (clicked Cancel), pkexec exits with a return
+ * value of 126.
+ */
+#define PKEXEC_DISMISS_RET	126
+
 void KsMainWindow::_captureFinished(int ret, QProcess::ExitStatus st)
 {
+	QProcess *capture = (QProcess *)sender();
+
 	_captureLocalServer.close();
+
+	if (ret == PKEXEC_DISMISS_RET) {
+		/*
+		 * Authorization could not be obtained because the user
+		 * dismissed the authentication dialog.
+		 */
+		return;
+	}
+
+	if (ret != 0 || st != QProcess::NormalExit) {
+		QString message = "Capture process failed:<br>";
+
+		message += capture->errorString();
+		message += "<br>Try doing:<br> sudo make install";
+
+		_error(message, "captureFinishedErr", false, false);
+	}
 }
 
 void KsMainWindow::_captureError(QProcess::ProcessError error)
Signature · 1 line
2.20.1
#3 lore raw

PATCH 3/4 kernel-shark: Show the standard error of kshark-record

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

When kshark-record fails, report the standard error which can be very useful for debugging the issue that when wrong. For example, after removing the kshark lib functions, instead of just having "Unknow error" print when kshark-record dialog fails, I now get:

/usr/local/bin/kshark-record: error while loading shared libraries: libkshark-gui.so.0.9.8: cannot open shared object file: No such file or directory

---
 kernel-shark/src/KsMainWindow.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel-shark/src/KsMainWindow.cpp +2 -1
index 13b50795340c..54aa6d782ad1 100644
@@ -1179,7 +1179,7 @@ void KsMainWindow::_captureFinished(int ret, QProcess::ExitStatus st)
 		QString message = "Capture process failed:<br>";
 
 		message += capture->errorString();
-
+		message += capture->readAllStandardError();
 		_error(message, "captureFinishedErr", false, false);
 	}
 }
@@ -1190,6 +1190,7 @@ void KsMainWindow::_captureError(QProcess::ProcessError error)
 	QString message = "Capture process failed:<br>";
 
 	message += capture->errorString();
+	message += capture->readAllStandardError();
 	_error(message, "captureFinishedErr", false, false);
 }
 
Signature · 1 line
2.20.1
#4 lore raw

PATCH 4/4 kernel-shark: Use <br> for dialog and \n for console error messages

In reply to Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

The Qt dialog boxes require '<br>' to print a new line but consoles require a '\n'. Instead of printing '<br>' to the console or '\n' to the dialog, always have the '\n' turn into '<br>' for the dialog and all '<br>' turn into '\n' for the console.

---
 kernel-shark/src/KsMainWindow.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
kernel-shark/src/KsMainWindow.cpp +7 -2
index 54aa6d782ad1..29d44d9a9230 100644
@@ -1028,10 +1028,12 @@ void KsMainWindow::loadDataFile(const QString& fileName)
 	}
 }
 
-void KsMainWindow::_error(const QString &text, const QString &errCode,
+void KsMainWindow::_error(const QString &mesg, const QString &errCode,
 			  bool resize, bool unloadPlugins)
 {
 	QErrorMessage *em = new QErrorMessage(this);
+	QString text = mesg;
+	QString html = mesg;
 
 	if (resize)
 		_resizeEmpty();
@@ -1039,8 +1041,11 @@ void KsMainWindow::_error(const QString &text, const QString &errCode,
 	if (unloadPlugins)
 		_plugins.unloadAll();
 
+	text.replace("<br>", "\n", Qt::CaseInsensitive);
+	html.replace("\n", "<br>", Qt::CaseInsensitive);
+
 	qCritical().noquote() << "ERROR: " << text;
-	em->showMessage(text, errCode);
+	em->showMessage(html, errCode);
 	em->exec();
 }
 
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/4 kernel-shark: Remove the "make install" suggestion for capture errors

In reply to Steven Rostedt

From: "Yordan Karadzhov (VMware)" <[email protected]>

The message is not appropriate, although it is most likely that the error occurs because the user didn't install KernelShark and it runs the executable from its build location.

[ Steve: Although I hit this warning without needing a make install ;-) ]

[ Removed "duplicate" print of it as well ]
---
 kernel-shark/src/KsMainWindow.cpp | 3 ---
 1 file changed, 3 deletions(-)
kernel-shark/src/KsMainWindow.cpp +0 -3
index 198b410480a1..13b50795340c 100644
@@ -1179,7 +1179,6 @@ void KsMainWindow::_captureFinished(int ret, QProcess::ExitStatus st)
 		QString message = "Capture process failed:<br>";
 
 		message += capture->errorString();
-		message += "<br>Try doing:<br> sudo make install";
 
 		_error(message, "captureFinishedErr", false, false);
 	}
@@ -1191,8 +1190,6 @@ void KsMainWindow::_captureError(QProcess::ProcessError error)
 	QString message = "Capture process failed:<br>";
 
 	message += capture->errorString();
-	message += "<br>Try doing:<br> sudo make install";
-
 	_error(message, "captureFinishedErr", false, false);
 }
 
Signature · 1 line
2.20.1
#6 lore raw
In reply to Steven Rostedt
Quoted 10 lines · On Wed, 10 Jul 2019 09:46:36 -0400 Steven Rostedt <[email protected]> wrote:

Some fixes for getting to 1.0.

Steven Rostedt (VMware) (3):
revert: "kernel-shark: Remove a duplicate error message"
kernel-shark: Show the standard error of kshark-record
kernel-shark: Use '<br>' for dialog and '\n' for console error messages

Yordan Karadzhov (VMware) (1):
kernel-shark: Remove the "make install" suggestion for capture errors

Hi Yordan,

Can you review these patches?

Thanks!

-- Steve

Reviewed-by on v1 4/4
#5 lore raw

Re: [PATCH 4/4] kernel-shark: Use <br> for dialog and \n for console error messages

In reply to Steven Rostedt
Quoted 34 lines · Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

The Qt dialog boxes require '<br>' to print a new line but consoles require a '\n'. Instead of printing '<br>' to the console or '\n' to the dialog, always have the '\n' turn into '<br>' for the dialog and all '<br>' turn into '\n' for the console.

---
  kernel-shark/src/KsMainWindow.cpp | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
kernel-shark/src/KsMainWindow.cpp +3 -1
index 54aa6d782ad1..29d44d9a9230 100644
@@ -1028,10 +1028,12 @@ void KsMainWindow::loadDataFile(const QString& fileName)
  	}
  }
 
-void KsMainWindow::_error(const QString &text, const QString &errCode,
+void KsMainWindow::_error(const QString &mesg, const QString &errCode,
  			  bool resize, bool unloadPlugins)
  {
  	QErrorMessage *em = new QErrorMessage(this);
+	QString text = mesg;
+	QString html = mesg;
 
  	if (resize)
  		_resizeEmpty();
@@ -1039,8 +1041,11 @@ void KsMainWindow::_error(const QString &text, const QString &errCode,
  	if (unloadPlugins)
  		_plugins.unloadAll();

kernel-shark/src/KsMainWindow.cpp void KsMainWindow::_error(const QString &text, const QString &errCode, · line 1051

Quoted 10 lines
kernel-shark/src/KsMainWindow.cpp +4 -1
 
+	text.replace("<br>", "\n", Qt::CaseInsensitive);
+	html.replace("\n", "<br>", Qt::CaseInsensitive);
+
  	qCritical().noquote() << "ERROR: " << text;
-	em->showMessage(text, errCode);
+	em->showMessage(html, errCode);
  	em->exec();
  }
 

All patches look good to me.
Thanks!
Yordan