All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yordan Karadzhov <ykaradzhov@vmware.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org, Yordan Karadzhov <y.karadz@gmail.com>
Subject: [PATCH 10/10] kernel-shark-qt: Add KernelShark GUI executable.
Date: Fri, 12 Oct 2018 19:13:18 +0300	[thread overview]
Message-ID: <20181012161318.5302-11-ykaradzhov@vmware.com> (raw)
In-Reply-To: <20181012161318.5302-1-ykaradzhov@vmware.com>

From: Yordan Karadzhov (VMware) <y.karadz@gmail.com>

This patch adds the main executable of the KernelShark GUI.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark-qt/src/CMakeLists.txt  |  4 ++
 kernel-shark-qt/src/kernelshark.cpp | 93 +++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+)
 create mode 100644 kernel-shark-qt/src/kernelshark.cpp

diff --git a/kernel-shark-qt/src/CMakeLists.txt b/kernel-shark-qt/src/CMakeLists.txt
index d8daada..b51980f 100644
--- a/kernel-shark-qt/src/CMakeLists.txt
+++ b/kernel-shark-qt/src/CMakeLists.txt
@@ -63,6 +63,10 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
 
     set_target_properties(kshark-gui PROPERTIES  SUFFIX ".so.${KS_VERSION_STRING}")
 
+    message(STATUS "kernelshark")
+    add_executable(kernelshark          kernelshark.cpp)
+    target_link_libraries(kernelshark   kshark-gui)
+
 endif (Qt5Widgets_FOUND AND Qt5Network_FOUND)
 
 add_subdirectory(plugins)
diff --git a/kernel-shark-qt/src/kernelshark.cpp b/kernel-shark-qt/src/kernelshark.cpp
new file mode 100644
index 0000000..2ec91de
--- /dev/null
+++ b/kernel-shark-qt/src/kernelshark.cpp
@@ -0,0 +1,93 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Copyright (C) 2017 VMware Inc, Yordan Karadzhov <y.karadz@gmail.com>
+ */
+
+// C
+#include <sys/stat.h>
+#include <getopt.h>
+
+// Qt
+#include <QApplication>
+
+// KernelShark
+#include "KsCmakeDef.hpp"
+#include "KsMainWindow.hpp"
+
+#define default_input_file (char*)"trace.dat"
+
+static char *input_file;
+
+void usage(const char *prog)
+{
+	printf("Usage: %s\n", prog);
+	printf("  -h	Display this help message\n");
+	printf("  -v	Display version and exit\n");
+	printf("  -i	input_file, default is %s\n", default_input_file);
+	printf("  -p	register plugin, use plugin name, absolute or relative path\n");
+	printf("  -u	unregister plugin, use plugin name or absolute path\n");
+	printf("  -s	import a session\n");
+}
+
+int main(int argc, char **argv)
+{
+	QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+	QApplication a(argc, argv);
+
+	KsMainWindow ks;
+
+	int c;
+	bool fromSession = false;
+
+	while ((c = getopt(argc, argv, "hvi:p:u:s:")) != -1) {
+		switch(c) {
+		case 'h':
+			usage(argv[0]);
+			return 0;
+
+		case 'v':
+			printf("%s - %s\n", basename(argv[0]), KS_VERSION_STRING);
+			return 0;
+
+		case 'i':
+			input_file = optarg;
+			break;
+
+		case 'p':
+			ks.registerPlugin(QString(optarg));
+			break;
+
+		case 'u':
+			ks.unregisterPlugin(QString(optarg));
+			break;
+
+		case 's':
+			ks.loadSession(QString(optarg));
+			fromSession = true;
+
+		default:
+			break;
+		}
+	}
+
+	if (!fromSession) {
+		if ((argc - optind) >= 1) {
+			if (input_file)
+				usage(argv[0]);
+			input_file = argv[optind];
+		}
+
+		if (!input_file) {
+			struct stat st;
+			if (stat(default_input_file, &st) == 0)
+				input_file = default_input_file;
+		}
+
+		if (input_file)
+			ks.loadDataFile(QString(input_file));
+	}
+
+	ks.show();
+	return a.exec();
+}
-- 
2.17.1

      parent reply	other threads:[~2018-10-12 23:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12 16:13 [PATCH 00/10] Add Qt-based GUI for KernelShark Yordan Karadzhov
2018-10-12 16:13 ` [PATCH 01/10] kernel-shark-qt: Add Dual Marker for KernelShark GUI Yordan Karadzhov
2018-10-12 16:13 ` [PATCH 02/10] kernel-shark-qt: Add model for showing trace data in a text format Yordan Karadzhov
2018-10-12 16:13 ` [PATCH 03/10] kernel-shark-qt: Add Trace Viewer widget Yordan Karadzhov
2018-10-12 16:13 ` [PATCH 04/10] kernel-shark-qt: Add visualization (graph) model Yordan Karadzhov
2018-10-12 16:13 ` [PATCH 05/10] kernel-shark-qt: Add widget for OpenGL rendering Yordan Karadzhov
2018-10-12 16:13 ` [PATCH 06/10] kernel-shark-qt: Add Trace Graph widget Yordan Karadzhov
2018-10-12 16:13 ` [PATCH 07/10] kernel-shark-qt: Add dialog for Advanced filtering Yordan Karadzhov
2018-10-12 16:13 ` [PATCH 08/10] kernel-shark-qt: Add a manager class for GUI sessions Yordan Karadzhov
2018-10-12 16:13 ` [PATCH 09/10] kernel-shark-qt: Add Main Window widget gir the KernelShark GUI Yordan Karadzhov
2018-10-12 16:13 ` Yordan Karadzhov [this message]

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=20181012161318.5302-11-ykaradzhov@vmware.com \
    --to=ykaradzhov@vmware.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=y.karadz@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.