Skip to contentSkip to conversation

kernel-shark-2.alpha: Allow appending multiple datafiles from command line

PATCH New Yordan Karadzhov (VMware) 1 participant 2 messages Apr 3, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 kernel-shark-2.alpha: Allow appending multiple datafiles from command line

Multiple data files can be appended using the "-a" command line option. This can be done with:

kernelshark -i foo -a bar1 -a bar2

or

kernelshark -i foo -a "bar1 bar2"

---
 src/kernelshark.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
src/kernelshark.cpp +5 -4
index bb51f88..590783f 100644
@@ -17,7 +17,8 @@
 
 #define default_input_file (char*)"trace.dat"
 
-static char *prior_input_file, *app_input_file;
+static char *prior_input_file;
+QStringList appInputFiles;
 
 void usage(const char *prog)
 {
@@ -57,7 +58,7 @@ int main(int argc, char **argv)
 			break;
 
 		case 'a':
-			app_input_file = optarg;
+			appInputFiles << QString(optarg).split(" ", QString::SkipEmptyParts);
 			break;
 
 		case 'p':
@@ -99,8 +100,8 @@ int main(int argc, char **argv)
 		if (prior_input_file)
 			ks.loadDataFile(QString(prior_input_file));
 
-		if (app_input_file)
-			ks.appendDataFile(QString(app_input_file));
+		for (auto const &f: appInputFiles)
+			ks.appendDataFile(f);
 	}
 
 	ks.show();
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 kernel-shark-2.alpha: Show the file name in the time offset dialog

This is useful when appending multiple files from the command line.

---
 src/KsMainWindow.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/KsMainWindow.cpp +3 -1
index af8afb3..80a6537 100644
@@ -1255,8 +1255,10 @@ void KsMainWindow::_load(const QString& fileName, bool append)
 
 	if (append) {
 		bool ok;
+		QString description = fileName + "\n\nOffset [usec]:";
+
 		shift = QInputDialog::getDouble(this, tr("Append Trace file"),
-						      tr("Offset [usec]:"), 0,
+						      description, 0,
 						      INT_MIN, INT_MAX, 1, &ok);
 		if (ok)
 			shift *= 1000.;
Signature · 1 line
2.20.1