Linux-Trace-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 1/3] kernel-shark: Fix all warnings showing when bulding with gcc 10.2.1
@ 2020-09-30 15:07 Yordan Karadzhov (VMware)
  2020-09-30 15:07 ` [PATCH v2 2/3] kernel-shark: Check if Qt has been found when building the examples Yordan Karadzhov (VMware)
  2020-09-30 15:07 ` [PATCH v2 3/3] kernel-shark: Fix symbol resolving during linking Yordan Karadzhov (VMware)
  0 siblings, 2 replies; 3+ messages in thread
From: Yordan Karadzhov (VMware) @ 2020-09-30 15:07 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, Yordan Karadzhov (VMware)

Tested on Fedora 32:
gcc (GCC) 10.2.1 20200723 (Red Hat 10.2.1-1)

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/KsAdvFilteringDialog.cpp |  6 +++---
 src/KsCaptureDialog.cpp      |  2 +-
 src/KsTraceGraph.cpp         | 36 +++++++++++++++++++++---------------
 src/KsTraceGraph.hpp         |  2 ++
 src/KsUtils.cpp              |  4 ++--
 src/KsUtils.hpp              |  6 +++---
 src/KsWidgetsLib.cpp         |  6 +++---
 7 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/src/KsAdvFilteringDialog.cpp b/src/KsAdvFilteringDialog.cpp
index 6af1aea..8dc53bb 100644
--- a/src/KsAdvFilteringDialog.cpp
+++ b/src/KsAdvFilteringDialog.cpp
@@ -170,7 +170,7 @@ void KsAdvFilteringDialog::_setSystemCombo(struct kshark_context *kshark_ctx)
 		}
 	}
 
-	qSort(sysList);
+	std::sort(sysList.begin(), sysList.end());
 	_systemComboBox.addItems(sysList);
 
 	i = _systemComboBox.findText("ftrace");
@@ -291,7 +291,7 @@ void KsAdvFilteringDialog::_systemChanged(const QString &sysName)
 			evtsList << events[i]->name;
 	}
 
-	qSort(evtsList);
+	std::sort(evtsList.begin(), evtsList.end());
 	_eventComboBox.addItems(evtsList);
 
 	i = _eventComboBox.findText("function");
@@ -310,7 +310,7 @@ KsAdvFilteringDialog::_getEventFormatFields(struct tep_event *event)
 
 	free(fields);
 
-	qSort(fieldList);
+	std::sort(fieldList.begin(), fieldList.end());
 	return fieldList;
 }
 
diff --git a/src/KsCaptureDialog.cpp b/src/KsCaptureDialog.cpp
index d6f8014..63fd5d6 100644
--- a/src/KsCaptureDialog.cpp
+++ b/src/KsCaptureDialog.cpp
@@ -219,7 +219,7 @@ QStringList KsCaptureControl::_getPlugins()
 	}
 
 	free (all_plugins);
-	qSort(pluginList);
+	std::sort(pluginList.begin(), pluginList.end());
 
 	return pluginList;
 }
diff --git a/src/KsTraceGraph.cpp b/src/KsTraceGraph.cpp
index 90f83f3..7b656c0 100644
--- a/src/KsTraceGraph.cpp
+++ b/src/KsTraceGraph.cpp
@@ -279,14 +279,25 @@ void KsTraceGraph::_stopUpdating()
 	_keyPressed = false;
 }
 
+QString KsTraceGraph::_t2str(uint64_t sec, uint64_t usec) {
+	QString usecStr;
+	QTextStream ts(&usecStr);
+
+	ts.setFieldAlignment(QTextStream::AlignRight);
+	ts.setFieldWidth(6);
+	ts.setPadChar('0');
+
+	ts << usec;
+
+	return QString::number(sec) + "." + usecStr;
+}
+
 void KsTraceGraph::_resetPointer(uint64_t ts, int cpu, int pid)
 {
 	uint64_t sec, usec;
-	QString pointer;
 
 	kshark_convert_nano(ts, &sec, &usec);
-	pointer.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
-	_labelP2.setText(pointer);
+	_labelP2.setText(_t2str(sec, usec));
 
 	if (pid > 0 && cpu >= 0) {
 		struct kshark_context *kshark_ctx(NULL);
@@ -316,13 +327,12 @@ void KsTraceGraph::_setPointerInfo(size_t i)
 	QString lat(kshark_get_latency_easy(e));
 	QString info(kshark_get_info_easy(e));
 	QString comm(kshark_get_task_easy(e));
-	QString pointer, elidedText;
 	int labelWidth, width;
+	QString elidedText;
 	uint64_t sec, usec;
 
 	kshark_convert_nano(e->ts, &sec, &usec);
-	pointer.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
-	_labelP2.setText(pointer);
+	_labelP2.setText(_t2str(sec, usec));
 
 	comm.append("-");
 	comm.append(QString("%1").arg(kshark_get_pid_easy(e)));
@@ -445,7 +455,7 @@ void KsTraceGraph::addCPUPlot(int cpu)
 		return;
 
 	_glWindow._cpuList.append(cpu);
-	qSort(_glWindow._cpuList);
+	std::sort(_glWindow._cpuList.begin(), _glWindow._cpuList.end());
 	_selfUpdate();
 }
 
@@ -456,7 +466,7 @@ void KsTraceGraph::addTaskPlot(int pid)
 		return;
 
 	_glWindow._taskList.append(pid);
-	qSort(_glWindow._taskList);
+	std::sort(_glWindow._taskList.begin(), _glWindow._taskList.end());
 	_selfUpdate();
 }
 
@@ -606,21 +616,17 @@ void KsTraceGraph::_updateGraphLegends()
 void KsTraceGraph::_updateTimeLegends()
 {
 	uint64_t sec, usec, tsMid;
-	QString tMin, tMid, tMax;
 
 	kshark_convert_nano(_glWindow.model()->histo()->min, &sec, &usec);
-	tMin.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
-	_labelXMin.setText(tMin);
+	_labelXMin.setText(_t2str(sec, usec));
 
 	tsMid = (_glWindow.model()->histo()->min +
 		 _glWindow.model()->histo()->max) / 2;
 	kshark_convert_nano(tsMid, &sec, &usec);
-	tMid.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
-	_labelXMid.setText(tMid);
+	_labelXMid.setText(_t2str(sec, usec));
 
 	kshark_convert_nano(_glWindow.model()->histo()->max, &sec, &usec);
-	tMax.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
-	_labelXMax.setText(tMax);
+	_labelXMax.setText(_t2str(sec, usec));
 }
 
 /**
diff --git a/src/KsTraceGraph.hpp b/src/KsTraceGraph.hpp
index c53258c..0eeef14 100644
--- a/src/KsTraceGraph.hpp
+++ b/src/KsTraceGraph.hpp
@@ -108,6 +108,8 @@ private:
 
 	void _markerReDraw();
 
+	QString _t2str(uint64_t sec, uint64_t usec);
+
 	enum class GraphActions {
 		ZoomIn,
 		ZoomOut,
diff --git a/src/KsUtils.cpp b/src/KsUtils.cpp
index 8c61b3f..24f7178 100644
--- a/src/KsUtils.cpp
+++ b/src/KsUtils.cpp
@@ -48,7 +48,7 @@ QVector<int> getPidList()
 
 	free(tempPids);
 
-	qSort(pids);
+	std::sort(pids.begin(), pids.end());
 
 	return pids;
 }
@@ -90,7 +90,7 @@ QVector<int> getFilterIds(tracecmd_filter_id *filter)
 	for (int i = 0; i < n; ++i)
 		v.append(cpuFilter[i]);
 
-	qSort(v);
+	std::sort(v.begin(), v.end());
 
 	free(cpuFilter);
 	return v;
diff --git a/src/KsUtils.hpp b/src/KsUtils.hpp
index 9adacd8..2772b84 100644
--- a/src/KsUtils.hpp
+++ b/src/KsUtils.hpp
@@ -25,10 +25,10 @@
 #include "KsPlotTools.hpp"
 
 /** Macro providing the height of the screen in pixels. */
-#define SCREEN_HEIGHT  QApplication::desktop()->screenGeometry().height()
+#define SCREEN_HEIGHT  QGuiApplication::screens()[0]->geometry().height()
 
 /** Macro providing the width of the screen in pixels. */
-#define SCREEN_WIDTH   QApplication::desktop()->screenGeometry().width()
+#define SCREEN_WIDTH   QGuiApplication::screens()[0]->geometry().width()
 
 //! @cond Doxygen_Suppress
 
@@ -45,7 +45,7 @@ static auto stringWidth = [](QString s)
 	QFont font;
 	QFontMetrics fm(font);
 
-	return fm.width(s);
+	return fm.horizontalAdvance(s);
 };
 
 //! @endcond
diff --git a/src/KsWidgetsLib.cpp b/src/KsWidgetsLib.cpp
index 330230e..a84aff3 100644
--- a/src/KsWidgetsLib.cpp
+++ b/src/KsWidgetsLib.cpp
@@ -642,7 +642,7 @@ KsCPUCheckBoxWidget::KsCPUCheckBoxWidget(struct tep_handle *tep,
 		cpuItem->setText(0, "  ");
 		cpuItem->setText(1, QString("CPU %1").arg(i));
 		cpuItem->setCheckState(0, Qt::Checked);
-		cpuItem->setBackgroundColor(0, QColor(colors[i].r(),
+		cpuItem->setBackground(0, QColor(colors[i].r(),
 						      colors[i].g(),
 						      colors[i].b()));
 		_tree.addTopLevelItem(cpuItem);
@@ -799,12 +799,12 @@ KsTasksCheckBoxWidget::KsTasksCheckBoxWidget(struct tep_handle *pevent,
 		comm = tep_data_comm_from_pid(kshark_ctx->pevent, pid);
 		comItem = new QTableWidgetItem(tr(comm));
 
-		pidItem->setBackgroundColor(QColor(colors[pid].r(),
+		pidItem->setBackground(QColor(colors[pid].r(),
 						   colors[pid].g(),
 						   colors[pid].b()));
 
 		if (_id[i] == 0)
-			pidItem->setTextColor(Qt::white);
+			pidItem->setForeground(Qt::white);
 
 		_table.setItem(i, 2, comItem);
 	}
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 2/3] kernel-shark: Check if Qt has been found when building the examples
  2020-09-30 15:07 [PATCH v2 1/3] kernel-shark: Fix all warnings showing when bulding with gcc 10.2.1 Yordan Karadzhov (VMware)
@ 2020-09-30 15:07 ` Yordan Karadzhov (VMware)
  2020-09-30 15:07 ` [PATCH v2 3/3] kernel-shark: Fix symbol resolving during linking Yordan Karadzhov (VMware)
  1 sibling, 0 replies; 3+ messages in thread
From: Yordan Karadzhov (VMware) @ 2020-09-30 15:07 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, Yordan Karadzhov (VMware)

Some of the examples depend on Qt. Check is Qt exists befor trying
to build these examples.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 examples/CMakeLists.txt | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 35e6b1e..032f305 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -20,10 +20,14 @@ message(STATUS "dataplot")
 add_executable(dplot          dataplot.cpp)
 target_link_libraries(dplot   kshark-plot)
 
-message(STATUS "widgetdemo")
-add_executable(widgetdemo          widgetdemo.cpp)
-target_link_libraries(widgetdemo   kshark-gui)
+if (Qt5Widgets_FOUND)
 
-message(STATUS "cmd_split")
-add_executable(cmd_split           cmd_split.cpp)
-target_link_libraries(cmd_split    kshark-gui)
+    message(STATUS "widgetdemo")
+    add_executable(widgetdemo          widgetdemo.cpp)
+    target_link_libraries(widgetdemo   kshark-gui)
+
+    message(STATUS "cmd_split")
+    add_executable(cmd_split           cmd_split.cpp)
+    target_link_libraries(cmd_split    kshark-gui)
+
+endif (Qt5Widgets_FOUND)
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 3/3] kernel-shark: Fix symbol resolving during linking
  2020-09-30 15:07 [PATCH v2 1/3] kernel-shark: Fix all warnings showing when bulding with gcc 10.2.1 Yordan Karadzhov (VMware)
  2020-09-30 15:07 ` [PATCH v2 2/3] kernel-shark: Check if Qt has been found when building the examples Yordan Karadzhov (VMware)
@ 2020-09-30 15:07 ` Yordan Karadzhov (VMware)
  1 sibling, 0 replies; 3+ messages in thread
From: Yordan Karadzhov (VMware) @ 2020-09-30 15:07 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, Yordan Karadzhov (VMware)

libtraceevent is the basic library. libtracefs depends on libtraceevent
and libtracecmd depends on both libtracefs and libtraceevent. Having
this in mind, we need to properly order those 3 libraries when linking
the basic library of the KernelShark API (libkshark).

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/CMakeLists.txt | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9666b18..457c100 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -7,9 +7,9 @@ add_library(kshark SHARED libkshark.c
                           libkshark-configio.c
                           libkshark-collection.c)
 
-target_link_libraries(kshark ${TRACEEVENT_LIBRARY}
-                             ${TRACECMD_LIBRARY}
+target_link_libraries(kshark ${TRACECMD_LIBRARY}
                              ${TRACEFS_LIBRARY}
+                             ${TRACEEVENT_LIBRARY}
                              ${JSONC_LIBRARY}
                              ${CMAKE_DL_LIBS})
 
@@ -67,11 +67,8 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
 
     target_link_libraries(kshark-gui kshark-plot
                                      Qt5::Widgets
-                                     Qt5::Network
-                                     ${TRACEEVENT_LIBRARY}
-                                     ${TRACECMD_LIBRARY}
-                                     ${TRACEFS_LIBRARY}
-                                     ${CMAKE_DL_LIBS})
+                                     Qt5::Network)
+
 
     set_target_properties(kshark-gui PROPERTIES  SUFFIX ".so.${KS_VERSION_STRING}")
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 15:07 [PATCH v2 1/3] kernel-shark: Fix all warnings showing when bulding with gcc 10.2.1 Yordan Karadzhov (VMware)
2020-09-30 15:07 ` [PATCH v2 2/3] kernel-shark: Check if Qt has been found when building the examples Yordan Karadzhov (VMware)
2020-09-30 15:07 ` [PATCH v2 3/3] kernel-shark: Fix symbol resolving during linking Yordan Karadzhov (VMware)

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org
	public-inbox-index linux-trace-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git