Fix kernelshark issues introduced by the migration to Qt6
cover Fix kernelshark issues introduced by the migration to Qt6
There were 3 majors issues:
- A segfault when loading a trace file (patch 0001)
- The trace table height was very small (patch 0032)
- The trace table columns width were reducing when clicking Marker A or B (patch 0032)
Also fix most of the warnings reported by Clang-Tidy and Clazy, and by gcc with -Wextra.
Benjamin ROBIN (34):
kernelshark: Fix modelReset() signaling, rename update to updateGeom
kernelshark: Add .gitignore
kernelshark: Remove function param when not used, whenever possible
kernelshark: Do not create a temporary container for looping over QMap
kernelshark: Prevent potential detach of QMap container
kernelshark: Fix used after free of QByteArray raw data
kernelshark: Fix potential memory leak in KsGLWidget
kernelshark: Use lambda parameter instead of captured local variable
kernelshark: Keep overridden method protected instead of public
kernelshark: Use sliced() or first() instead of mid/right/left()
kernelshark: Prevent potential divide by zero in Shape::center()
kernelshark: Fix potential access to uninitialized variable
kernelshark: Remove unused locals variables
kernelshark: Fix range-loop-reference Clazy warning
kernelshark: Fix moving a temp object prevents copy elision warning
kernelshark: Add receiver object to connect() call
kernelshark: Return by reference the list of header in KsModels
kernelshark: Fix detaching-temporary Clazy warning
kernelshark: Fix qfileinfo-exists Clazy warning
kernelshark: Fix potential memory leaks in libkshark-configio
kernelshark: Fix potential access to uninitialized variable
kernelshark: Fix potential double free of histo->map, histo->bin_count
kernelshark: Fix 'const' type qualifier on return type has no effect
kernelshark: Fix potential memory leaks in libkshark-tepdata
kernelshark: Fix typo in comment of KsGLWidget::resizeGL()
kernelshark: Remove unused KsDataWidget::wipPtr() and broken function
kernelshark: In KsTimeOffsetDialog() constructor use parent param
kernelshark: Fixed loop counter incremented suspiciously twice
kernelshark: Fix tepdata_dump_entry() for event_id = KS_EVENT_OVERFLOW
kernelshark: Use static_cast instead of C cast in KsMainWindow
kernelshark: Fix comparison of integers of different signs warnings
kernelshark: Fix KsTableView columns width, and KsTraceViewer size
kernelshark: Allow to reduce a bit more the graph height
kernelshark: Cleanup of KsDualMarker methods
.gitignore | 15 ++++++ examples/configio.c | 3 +- examples/datafilter.c | 15 +++--- examples/datahisto.c | 2 +- src/KsAdvFilteringDialog.cpp | 24 ++++------ src/KsAdvFilteringDialog.hpp | 2 +- src/KsDualMarker.hpp | 10 +--- src/KsGLWidget.cpp | 48 +++++++++---------- src/KsGLWidget.hpp | 43 ++++++++--------- src/KsMainWindow.cpp | 8 ++-- src/KsModels.hpp | 11 +++-- src/KsPlotTools.cpp | 14 +++--- src/KsPlotTools.hpp | 2 +- src/KsSession.cpp | 4 +- src/KsTraceGraph.cpp | 7 ++- src/KsTraceViewer.cpp | 71 ++++++++-------------------- src/KsTraceViewer.hpp | 11 +++-- src/KsUtils.cpp | 9 ++-- src/KsUtils.hpp | 4 +- src/KsWidgetsLib.cpp | 2 +- src/KsWidgetsLib.hpp | 15 ++---- src/libkshark-collection.c | 14 +++--- src/libkshark-configio.c | 84 +++++++++++++++++++--------------- src/libkshark-hash.c | 5 +- src/libkshark-model.c | 19 ++++---- src/libkshark-tepdata.c | 31 ++++++++----- src/libkshark.c | 17 +++---- src/libkshark.h | 20 ++++---- src/plugins/KVMComboDialog.cpp | 7 +-- src/plugins/sched_events.c | 2 +- tests/test-input.c | 4 +- tests/test-input_ctrl.c | 4 +- 32 files changed, 257 insertions(+), 270 deletions(-) create mode 100644 .gitignore
--
2.43.0
PATCH 1/34 kernelshark: Fix modelReset() signaling, rename update to updateGeom
Fix segfault introduced by the migration to Qt6.
There was a public update() function in KsGLWidget class which overrides QWidget::update(). The QAbstractTableModel::modelReset signal was connected to the QWidget::update slot using "old" connect syntax. This was working since QWidget::update was declared as a slot, and registered in QWidget meta information.
When migrating to Qt6, the new connect syntax was used, which accidentally connect the KsGLWidget::update function instead of QWidget::update.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=218350
--- src/KsGLWidget.cpp | 4 ++-- src/KsGLWidget.hpp | 2 +- src/KsTraceGraph.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
src/KsGLWidget.cpp +2 -2
@@ -53,7 +53,7 @@ KsGLWidget::KsGLWidget(QWidget *parent) setMouseTracking(true); connect(&_model, &QAbstractTableModel::modelReset, - this, &KsGLWidget::update); + this, qOverload<>(&KsGLWidget::update)); } void KsGLWidget::_freeGraphs()
@@ -89,7 +89,7 @@ void KsGLWidget::initializeGL() ksplot_init_font(&_font, 15, TT_FONT_FILE); _labelSize = _getMaxLabelSize() + FONT_WIDTH * 2; - update(); + updateGeom(); } /**
src/KsGLWidget.hpp +1 -1
@@ -86,7 +86,7 @@ public: void reset(); /** Reprocess all graphs. */ - void update() {resizeGL(width(), height());} + void updateGeom() {resizeGL(width(), height());} void mousePressEvent(QMouseEvent *event);
src/KsTraceGraph.cpp +1 -1
@@ -614,7 +614,7 @@ void KsTraceGraph::updateGeom() * widget is extended to maximum. */ - _glWindow.update(); + _glWindow.updateGeom(); } /**
Signature · 1 line
2.43.0
PATCH 2/34 kernelshark: Add .gitignore
In reply to Benjamin ROBIN--- .gitignore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .gitignore
.gitignore new file +15 -0
@@ -0,0 +1,15 @@ + +# Ignore everything in bin directory except kshark-su-record +/bin/* +!/bin/kshark-su-record + +# Ignore generated files +CMakeLists.txt.user +/libkshark.pc +/org.freedesktop.kshark-record.policy +/kernelshark.desktop +/src/KsCmakeDef.hpp +/lib/* +/tests/*.so +/tests/kshark-tests +/tests/kshark-gui-tests
Signature · 1 line
2.43.0
PATCH 3/34 kernelshark: Remove function param when not used, whenever possible
In reply to Benjamin ROBIN--- src/KsAdvFilteringDialog.cpp | 4 ++-- src/KsAdvFilteringDialog.hpp | 2 +- src/KsMainWindow.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
src/KsAdvFilteringDialog.cpp +2 -2
@@ -80,7 +80,7 @@ KsAdvFilteringDialog::KsAdvFilteringDialog(QWidget *parent) _getFilters(kshark_ctx); if (_filters.count()) { - _makeFilterTable(kshark_ctx); + _makeFilterTable(); lamAddLine(); }
@@ -264,7 +264,7 @@ void KsAdvFilteringDialog::_getFilters(kshark_context *kshark_ctx) } } -void KsAdvFilteringDialog::_makeFilterTable(struct kshark_context *kshark_ctx) +void KsAdvFilteringDialog::_makeFilterTable() { QMapIterator<int, QString> f(_filters); QTableWidgetItem *i1, *i2, *i3;
src/KsAdvFilteringDialog.hpp +1 -1
@@ -80,7 +80,7 @@ private: void _getFilters(kshark_context *kshark_ctx); - void _makeFilterTable(kshark_context *kshark_ctx); + void _makeFilterTable(); QStringList _getEventFields(int eventId);
src/KsMainWindow.cpp +2 -2
@@ -1434,12 +1434,12 @@ void KsMainWindow::loadSession(const QString &fileName) _session.loadUserPlugins(kshark_ctx, &_plugins); pb.setValue(20); - auto lamLoadJob = [&] (KsDataStore *d) { + auto lamLoadJob = [&] () { _session.loadDataStreams(kshark_ctx, &_data); loadDone = true; }; - std::thread job = std::thread(lamLoadJob, &_data); + std::thread job = std::thread(lamLoadJob); for (int i = 0; i < 150; ++i) { /*
Signature · 1 line
2.43.0
PATCH 4/34 kernelshark: Do not create a temporary container for looping over QMap
In reply to Benjamin ROBINUse const_iterator instead. Fix container-anti-pattern Clazy warning
--- src/KsAdvFilteringDialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
src/KsAdvFilteringDialog.cpp +3 -3
@@ -276,8 +276,8 @@ void KsAdvFilteringDialog::_makeFilterTable() headers << "Delete" << "Stream" << "Event" << " Id" << "Filter"; _table->init(headers, _filters.count()); - for(auto f : _filters.keys()) { - QStringList thisFilter = _filters.value(f).split(":"); + for (auto it = _filters.cbegin(), end = _filters.cend(); it != end; ++it) { + QStringList thisFilter = it.value().split(":"); i1 = new QTableWidgetItem(thisFilter[0]); _table->setItem(count, 1, i1);
@@ -285,7 +285,7 @@ void KsAdvFilteringDialog::_makeFilterTable() i1 = new QTableWidgetItem(thisFilter[1]); _table->setItem(count, 2, i1); - i2 = new QTableWidgetItem(tr("%1").arg(f)); + i2 = new QTableWidgetItem(tr("%1").arg(it.key())); _table->setItem(count, 3, i2); i3 = new QTableWidgetItem(thisFilter[2]);
Signature · 1 line
2.43.0
Re: [PATCH 04/34] kernelshark: Do not create a temporary container for looping over QMap
Quoted 12 lines · Benjamin ROBIN
Use
const_iteratorinstead. Fix container-anti-pattern Clazy warningSigned-off-by Benjamin ROBIN <[email protected]>--- src/KsAdvFilteringDialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)src/KsAdvFilteringDialog.cpp +0
-0
src/KsAdvFilteringDialog.cpp void KsAdvFilteringDialog::_makeFilterTable() · line 279
Quoted 6 lines
src/KsAdvFilteringDialog.cpp +1
-2@@ -276,8 +276,8 @@ void KsAdvFilteringDialog::_makeFilterTable() headers << "Delete" << "Stream" << "Event" << " Id" << "Filter"; _table->init(headers, _filters.count()); - for(auto f : _filters.keys()) { - QStringList thisFilter = _filters.value(f).split(":"); + for (auto it = _filters.cbegin(), end = _filters.cend(); it != end; ++it) {
Do we need to use iterator here?
Perhaps you can do something like:
for (const auto &[key, val] : _filters) {
Thanks!
Y.
Quoted 13 lines
src/KsAdvFilteringDialog.cpp +2
-1+ QStringList thisFilter = it.value().split(":"); i1 = new QTableWidgetItem(thisFilter[0]); _table->setItem(count, 1, i1);@@ -285,7 +285,7 @@ void KsAdvFilteringDialog::_makeFilterTable() i1 = new QTableWidgetItem(thisFilter[1]); _table->setItem(count, 2, i1); - i2 = new QTableWidgetItem(tr("%1").arg(f)); + i2 = new QTableWidgetItem(tr("%1").arg(it.key())); _table->setItem(count, 3, i2); i3 = new QTableWidgetItem(thisFilter[2]);
Re: [PATCH 04/34] kernelshark: Do not create a temporary container for looping over QMap
Quoted 24 lines · Yordan Karadzhov
Quoted 12 lines · Benjamin ROBIN
Use
const_iteratorinstead. Fix container-anti-pattern Clazy warningSigned-off-by Benjamin ROBIN <[email protected]>--- src/KsAdvFilteringDialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)src/KsAdvFilteringDialog.cpp +0
-0src/KsAdvFilteringDialog.cpp void KsAdvFilteringDialog::_makeFilterTable() · line 278
Quoted 5 lines
src/KsAdvFilteringDialog.cpp +1
-2@@ -276,8 +276,8 @@ void KsAdvFilteringDialog::_makeFilterTable() headers << "Delete" << "Stream" << "Event" << " Id" << "Filter"; _table->init(headers, _filters.count()); - for(auto f : _filters.keys()) { - QStringList thisFilter = _filters.value(f).split(":"); + for (auto it = _filters.cbegin(), end = _filters.cend(); it != end; ++it) {Do we need to use iterator here?
Perhaps you can do something like:
Quoted 1 line
for (const auto &[key, val] :
_filters) {
Unfortunately, you cannot do that, as far as I know (this not compile). C++ range-based for loop is using iterator behind the scene. See [1]. And there is still the problem of range-loop-detach (see patch 0005). Using const iterator is the most explicit and safe way to iterate over a container in Qt, so why not using it?
[1] https://en.cppreference.com/w/cpp/language/range-for
Quoted 13 lines
Thanks!
Y.Quoted 10 lines
src/KsAdvFilteringDialog.cpp +2
-1+ QStringList thisFilter = it.value().split(":"); i1 = new QTableWidgetItem(thisFilter[0]); _table->setItem(count, 1, i1);@@ -285,7 +285,7 @@ void KsAdvFilteringDialog::_makeFilterTable() i1 = new QTableWidgetItem(thisFilter[1]); _table->setItem(count, 2, i1); - i2 = new QTableWidgetItem(tr("%1").arg(f)); + i2 = new QTableWidgetItem(tr("%1").arg(it.key())); _table->setItem(count, 3, i2); i3 = new QTableWidgetItem(thisFilter[2]);
Re: [PATCH 04/34] kernelshark: Do not create a temporary container for looping over QMap
Quoted 25 lines · Benjamin ROBIN
Quoted 24 lines · Yordan Karadzhov
Quoted 12 lines · Benjamin ROBIN
Use
const_iteratorinstead. Fix container-anti-pattern Clazy warningSigned-off-by Benjamin ROBIN <[email protected]>--- src/KsAdvFilteringDialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)src/KsAdvFilteringDialog.cpp +0
-0src/KsAdvFilteringDialog.cpp void KsAdvFilteringDialog::_makeFilterTable() · line 278
Quoted 5 lines
src/KsAdvFilteringDialog.cpp +1
-2@@ -276,8 +276,8 @@ void KsAdvFilteringDialog::_makeFilterTable() headers << "Delete" << "Stream" << "Event" << " Id" << "Filter"; _table->init(headers, _filters.count()); - for(auto f : _filters.keys()) { - QStringList thisFilter = _filters.value(f).split(":"); + for (auto it = _filters.cbegin(), end = _filters.cend(); it != end; ++it) {Do we need to use iterator here?
Perhaps you can do something like:
Quoted 7 lines
Quoted 1 line
for (const auto &[key, val] :
_filters) {Unfortunately, you cannot do that, as far as I know (this not compile). C++ range-based for loop is using iterator behind the scene. See [1]. And there is still the problem of range-loop-detach (see patch 0005). Using const iterator is the most explicit and safe way to iterate over a container in Qt, so why not using it?
I see your point. I am applying this patch together with all v2 patches you sent.
Are you considering sending new version of the "[31/34] Fix comparison of integers of different signs warnings"?
Thanks,
Y.
Quoted 16 lines
[1] https://en.cppreference.com/w/cpp/language/range-for
Quoted 13 lines
Thanks!
Y.Quoted 10 lines
src/KsAdvFilteringDialog.cpp +2
-1+ QStringList thisFilter = it.value().split(":"); i1 = new QTableWidgetItem(thisFilter[0]); _table->setItem(count, 1, i1);@@ -285,7 +285,7 @@ void KsAdvFilteringDialog::_makeFilterTable() i1 = new QTableWidgetItem(thisFilter[1]); _table->setItem(count, 2, i1); - i2 = new QTableWidgetItem(tr("%1").arg(f)); + i2 = new QTableWidgetItem(tr("%1").arg(it.key())); _table->setItem(count, 3, i2); i3 = new QTableWidgetItem(thisFilter[2]);
Re: [PATCH 04/34] kernelshark: Do not create a temporary container for looping over QMap
Quoted 36 lines · Yordan Karadzhov
Quoted 25 lines · Benjamin ROBIN
Quoted 24 lines · Yordan Karadzhov
Quoted 12 lines · Benjamin ROBIN
Use
const_iteratorinstead. Fix container-anti-pattern Clazy warningSigned-off-by Benjamin ROBIN <[email protected]>--- src/KsAdvFilteringDialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)src/KsAdvFilteringDialog.cpp +0
-0src/KsAdvFilteringDialog.cpp void KsAdvFilteringDialog::_makeFilterTable() · line 278
Quoted 5 lines
src/KsAdvFilteringDialog.cpp +1
-2@@ -276,8 +276,8 @@ void KsAdvFilteringDialog::_makeFilterTable() headers << "Delete" << "Stream" << "Event" << " Id" << "Filter"; _table->init(headers, _filters.count()); - for(auto f : _filters.keys()) { - QStringList thisFilter = _filters.value(f).split(":"); + for (auto it = _filters.cbegin(), end = _filters.cend(); it != end; ++it) {Do we need to use iterator here?
Perhaps you can do something like:Quoted 7 lines
Quoted 1 line
for (const auto &[key, val] :
_filters) {Unfortunately, you cannot do that, as far as I know (this not compile). C++ range-based for loop is using iterator behind the scene. See [1]. And there is still the problem of range-loop-detach (see patch 0005). Using const iterator is the most explicit and safe way to iterate over a container in Qt, so why not using it?
Quoted 5 lines
I see your point. I am applying this patch together with all v2 patches you sent.
Are you considering sending new version of the "[31/34] Fix comparison of integers of different signs warnings"?
I did not have time last weekend, nor this weekend to take a deep loop into it. Fixing types is not that easy:
- I need a better understanding of the code base, otherwise I will break stuff.
- I don't know if there are other projects that rely on these lib headers files. Is it possible to refactor every part of the project without breaking something else?
- My patch tried to fix at various places warnings using mainly cast, but there are so many other places where the types are wrong (or at least not the optimal one).
- This task is not that small. It requires a bit more time.
So, in summary, this patch is currently on hold. I may work on it later this year... Sorry about that.
Thanks,
Benjamin
Quoted 15 lines
Quoted 15 lines
[1] https://en.cppreference.com/w/cpp/language/range-for
Quoted 13 lines
Thanks!
Y.Quoted 10 lines
src/KsAdvFilteringDialog.cpp +2
-1+ QStringList thisFilter = it.value().split(":"); i1 = new QTableWidgetItem(thisFilter[0]); _table->setItem(count, 1, i1);@@ -285,7 +285,7 @@ void KsAdvFilteringDialog::_makeFilterTable() i1 = new QTableWidgetItem(thisFilter[1]); _table->setItem(count, 2, i1); - i2 = new QTableWidgetItem(tr("%1").arg(f)); + i2 = new QTableWidgetItem(tr("%1").arg(it.key())); _table->setItem(count, 3, i2); i3 = new QTableWidgetItem(thisFilter[2]);
PATCH 5/34 kernelshark: Prevent potential detach of QMap container
In reply to Benjamin ROBINUse const_iterator instead. Fix range-loop-detach Clazy warning
--- src/KsGLWidget.cpp | 5 +++-- src/plugins/KVMComboDialog.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-)
src/KsGLWidget.cpp +3 -2
@@ -137,9 +137,10 @@ void KsGLWidget::paintGL() /* Draw the time axis. */ _drawAxisX(size); - for (auto const &stream: _graphs) - for (auto const &g: stream) + for (auto it = _graphs.cbegin(), end = _graphs.cend(); it != end; ++it) { + for (auto const &g: it.value()) g->draw(size); + } for (auto const &s: _shapes) { if (!s)
src/plugins/KVMComboDialog.cpp +4 -2
@@ -308,13 +308,15 @@ void KsComboPlotDialog::_applyPress() int nPlots(0); _plotMap[guestId] = _streamCombos(guestId); - for (auto const &stream: _plotMap) - for (auto const &combo: stream) { + + for (auto it = _plotMap.cbegin(), end = _plotMap.cend(); it != end; ++it) { + for (auto const &combo: it.value()) { allCombosVec.append(2); combo[0] >> allCombosVec; combo[1] >> allCombosVec; ++nPlots; } + } emit apply(nPlots, allCombosVec); }
Signature · 1 line
2.43.0
Re: [PATCH 05/34] kernelshark: Prevent potential detach of QMap container
Quoted 2 lines · Benjamin ROBIN
Use
const_iteratorinstead. Fix range-loop-detach Clazy warning
Please provide a better explanation of the problem you are trying to solve with this patch.
Thanks!
Y.
Quoted 45 lines
Signed-off-by Benjamin ROBIN <[email protected]>--- src/KsGLWidget.cpp | 5 +++-- src/plugins/KVMComboDialog.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-)src/KsGLWidget.cpp +3
-2@@ -137,9 +137,10 @@ void KsGLWidget::paintGL() /* Draw the time axis. */ _drawAxisX(size); - for (auto const &stream: _graphs) - for (auto const &g: stream) + for (auto it = _graphs.cbegin(), end = _graphs.cend(); it != end; ++it) { + for (auto const &g: it.value()) g->draw(size); + } for (auto const &s: _shapes) { if (!s)src/plugins/KVMComboDialog.cpp +4
-2@@ -308,13 +308,15 @@ void KsComboPlotDialog::_applyPress() int nPlots(0); _plotMap[guestId] = _streamCombos(guestId); - for (auto const &stream: _plotMap) - for (auto const &combo: stream) { + + for (auto it = _plotMap.cbegin(), end = _plotMap.cend(); it != end; ++it) { + for (auto const &combo: it.value()) { allCombosVec.append(2); combo[0] >> allCombosVec; combo[1] >> allCombosVec; ++nPlots; } + } emit apply(nPlots, allCombosVec); }
PATCH v2 5/34 kernelshark: Prevent potential detach of QMap container
Use const_iterator instead. Fix range-loop-detach Clazy warning. Indeed when using C++11 range-loops, the .begin() and .end() functions are called, instead of .cbegin() and .cend(). This imply before looping over the QMap, it may perform a deep-copy of it (if shared).
See also the explanation given by Qt documentation of qAsConst(). Another solution is to use "std::as_const" cast on the QMap object.
--- src/KsGLWidget.cpp | 5 +++-- src/plugins/KVMComboDialog.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-)
src/KsGLWidget.cpp +3 -2
@@ -137,9 +137,10 @@ void KsGLWidget::paintGL() /* Draw the time axis. */ _drawAxisX(size); - for (auto const &stream: _graphs) - for (auto const &g: stream) + for (auto it = _graphs.cbegin(), end = _graphs.cend(); it != end; ++it) { + for (auto const &g: it.value()) g->draw(size); + } for (auto const &s: _shapes) { if (!s)
src/plugins/KVMComboDialog.cpp +4 -2
@@ -308,13 +308,15 @@ void KsComboPlotDialog::_applyPress() int nPlots(0); _plotMap[guestId] = _streamCombos(guestId); - for (auto const &stream: _plotMap) - for (auto const &combo: stream) { + + for (auto it = _plotMap.cbegin(), end = _plotMap.cend(); it != end; ++it) { + for (auto const &combo: it.value()) { allCombosVec.append(2); combo[0] >> allCombosVec; combo[1] >> allCombosVec; ++nPlots; } + } emit apply(nPlots, allCombosVec); }
Signature · 1 line
2.43.0
PATCH 6/34 kernelshark: Fix used after free of QByteArray raw data
In reply to Benjamin ROBINIn KsAdvFilteringDialog::_applyPress(), QByteArray raw data, obtained from _filterEdit, is accessed after being freed.
Also prevent any unnecessary copy.
--- src/KsAdvFilteringDialog.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
src/KsAdvFilteringDialog.cpp +3 -11
@@ -443,8 +443,6 @@ void KsAdvFilteringDialog::_applyPress() QMapIterator<int, QString> f(_filters); kshark_context *kshark_ctx(NULL); kshark_data_stream *stream; - const char *text; - char *filter; int i(0); if (!kshark_instance(&kshark_ctx))
@@ -476,18 +474,12 @@ void KsAdvFilteringDialog::_applyPress() emit dataReload(); }; - text = _filterEdit.text().toLocal8Bit().data(); - if (strlen(text) == 0) { + QByteArray filter = _filterEdit.text().toLocal8Bit(); + if (filter.isEmpty()) { job_done(); return; } - filter = (char*) malloc(strlen(text) + 1); - strcpy(filter, text); - - kshark_tep_add_filter_str(stream, filter); - - free(filter); - + kshark_tep_add_filter_str(stream, filter.constData()); job_done(); }
Signature · 1 line
2.43.0
PATCH 7/34 kernelshark: Fix potential memory leak in KsGLWidget
In reply to Benjamin ROBINIn KsGLWidget::_newCPUGraph() and in KsGLWidget::_newTaskGraph() allocate KsPlot::Graph after getting data stream successfully. Also remove unused "name" local variable in both functions.
--- src/KsGLWidget.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
src/KsGLWidget.cpp +9 -16
@@ -794,13 +794,8 @@ void KsGLWidget::_makePluginShapes() KsPlot::Graph *KsGLWidget::_newCPUGraph(int sd, int cpu) { - QString name; - /* The CPU graph needs to know only the colors of the tasks. */ - KsPlot::Graph *graph = new KsPlot::Graph(_model.histo(), - &_pidColors, - &_pidColors); - - kshark_context *kshark_ctx(nullptr); + KsPlot::Graph *graph = nullptr; + kshark_context *kshark_ctx = nullptr; kshark_data_stream *stream; kshark_entry_collection *col;
@@ -811,6 +806,8 @@ KsPlot::Graph *KsGLWidget::_newCPUGraph(int sd, int cpu) if (!stream) return nullptr; + /* The CPU graph needs to know only the colors of the tasks. */ + graph = new KsPlot::Graph(_model.histo(), &_pidColors, &_pidColors); graph->setIdleSuppressed(true, stream->idle_pid); graph->setHeight(KS_GRAPH_HEIGHT); graph->setLabelText(KsUtils::cpuPlotName(cpu).toStdString());
@@ -827,15 +824,8 @@ KsPlot::Graph *KsGLWidget::_newCPUGraph(int sd, int cpu) KsPlot::Graph *KsGLWidget::_newTaskGraph(int sd, int pid) { - QString name; - /* - * The Task graph needs to know the colors of the tasks and the colors - * of the CPUs. - */ - KsPlot::Graph *graph = new KsPlot::Graph(_model.histo(), - &_pidColors, - &_cpuColors); - kshark_context *kshark_ctx(nullptr); + KsPlot::Graph *graph = nullptr; + kshark_context *kshark_ctx = nullptr; kshark_entry_collection *col; kshark_data_stream *stream;
@@ -846,6 +836,9 @@ KsPlot::Graph *KsGLWidget::_newTaskGraph(int sd, int pid) if (!stream) return nullptr; + /* The Task graph needs to know the colors of the tasks and the colors + * of the CPUs */ + graph = new KsPlot::Graph(_model.histo(), &_pidColors, &_cpuColors); graph->setHeight(KS_GRAPH_HEIGHT); graph->setLabelText(KsUtils::taskPlotName(sd, pid).toStdString());
Signature · 1 line
2.43.0
PATCH 8/34 kernelshark: Use lambda parameter instead of captured local variable
In reply to Benjamin ROBINIn KsGLWidget::_find(), fix lamFindEntryByCPU() and lamFindEntryByPid() which had a parameter "b": use it instead of using captured "bin" local variable.
--- src/KsGLWidget.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
src/KsGLWidget.cpp +6 -6
@@ -986,15 +986,15 @@ bool KsGLWidget::_find(int bin, int sd, int cpu, int pid, * The click is over the CPU graphs. First try the exact * match. */ - if (lamGetEntryByCPU(bin)) + if (lamGetEntryByCPU(b)) return true; /* Now look for a match, nearby the position of the click. */ for (int i = 1; i < variance; ++i) { - if (bin + i <= hSize && lamGetEntryByCPU(bin + i)) + if (b + i <= hSize && lamGetEntryByCPU(b + i)) return true; - if (bin - i >= 0 && lamGetEntryByCPU(bin - i)) + if (b - i >= 0 && lamGetEntryByCPU(b - i)) return true; }
@@ -1007,15 +1007,15 @@ bool KsGLWidget::_find(int bin, int sd, int cpu, int pid, * The click is over the Task graphs. First try the exact * match. */ - if (lamGetEntryByPid(bin)) + if (lamGetEntryByPid(b)) return true; /* Now look for a match, nearby the position of the click. */ for (int i = 1; i < variance; ++i) { - if ((bin + i <= hSize) && lamGetEntryByPid(bin + i)) + if ((b + i <= hSize) && lamGetEntryByPid(b + i)) return true; - if ((bin - i >= 0) && lamGetEntryByPid(bin - i)) + if ((b - i >= 0) && lamGetEntryByPid(b - i)) return true; }
Signature · 1 line
2.43.0
PATCH 9/34 kernelshark: Keep overridden method protected instead of public
In reply to Benjamin ROBINAlso add "override" keyword when missing.
--- src/KsGLWidget.hpp | 41 +++++++++++++++++++++-------------------- src/KsModels.hpp | 9 +++++---- src/KsPlotTools.hpp | 2 +- src/KsTraceViewer.hpp | 9 +++++---- src/KsWidgetsLib.hpp | 9 +++++---- 5 files changed, 37 insertions(+), 33 deletions(-)
src/KsGLWidget.hpp +21 -20
@@ -75,12 +75,6 @@ public: ~KsGLWidget(); - void initializeGL() override; - - void resizeGL(int w, int h) override; - - void paintGL() override; - void render(); void reset();
@@ -88,20 +82,6 @@ public: /** Reprocess all graphs. */ void updateGeom() {resizeGL(width(), height());} - void mousePressEvent(QMouseEvent *event); - - void mouseMoveEvent(QMouseEvent *event); - - void mouseReleaseEvent(QMouseEvent *event); - - void mouseDoubleClickEvent(QMouseEvent *event); - - void wheelEvent(QWheelEvent * event); - - void keyPressEvent(QKeyEvent *event); - - void keyReleaseEvent(QKeyEvent *event); - void loadData(KsDataStore *data, bool resetPlots); void loadColors();
@@ -214,6 +194,27 @@ public: /** Free the list of plugin-defined shapes. */ void freePluginShapes(); +protected: + void initializeGL() override; + + void resizeGL(int w, int h) override; + + void paintGL() override; + + void mousePressEvent(QMouseEvent *event) override; + + void mouseMoveEvent(QMouseEvent *event) override; + + void mouseReleaseEvent(QMouseEvent *event) override; + + void mouseDoubleClickEvent(QMouseEvent *event) override; + + void wheelEvent(QWheelEvent * event) override; + + void keyPressEvent(QKeyEvent *event) override; + + void keyReleaseEvent(QKeyEvent *event) override; + signals: /** * This signal is emitted when the mouse moves over a visible
src/KsModels.hpp +5 -4
@@ -172,9 +172,6 @@ class KsFilterProxyModel : public QSortFilterProxyModel public: explicit KsFilterProxyModel(QObject *parent = nullptr); - bool filterAcceptsRow(int sourceRow, - const QModelIndex &sourceParent) const override; - void fill(KsDataStore *data); void setSource(KsViewModel *s);
@@ -224,9 +221,13 @@ public: /** A mutex used by the condition variable. */ std::mutex _mutex; - /** A flag used to stop the serch for all threads. */ + /** A flag used to stop the search for all threads. */ bool _searchStop; +protected: + bool filterAcceptsRow(int sourceRow, + const QModelIndex &sourceParent) const override; + private: int _searchProgress;
src/KsPlotTools.hpp +1 -1
@@ -662,7 +662,7 @@ private: /** The vertical size (height) of the graphical element. */ int _height; - void _draw(const Color &col, float size) const; + void _draw(const Color &col, float size) const override; }; }; // KsPlot
src/KsTraceViewer.hpp +5 -4
@@ -79,10 +79,6 @@ public: void setTopRow(size_t r); - void resizeEvent(QResizeEvent* event) override; - - void keyReleaseEvent(QKeyEvent *event); - void markSwitch(); void showRow(size_t r, bool mark);
@@ -101,6 +97,11 @@ public: _model.loadColors(); } +protected: + void resizeEvent(QResizeEvent* event) override; + + void keyReleaseEvent(QKeyEvent *event) override; + signals: /** Signal emitted when new row is selected. */ void select(size_t);
src/KsWidgetsLib.hpp +5 -4
@@ -261,20 +261,21 @@ public: */ int sd() const {return _sd;} + /** The user provided an input. The widget has been modified. */ + bool _userInput; + +protected: /** * Reimplemented event handler used to update the geometry of the widget on * resize events. */ - void resizeEvent(QResizeEvent* event) + void resizeEvent(QResizeEvent* event) override { KsUtils::setElidedText(&_streamLabel, _streamName, Qt::ElideLeft, width()); QApplication::processEvents(); } - /** The user provided an input. The widget has been modified. */ - bool _userInput; - protected: QToolBar _tb;
Signature · 1 line
2.43.0
PATCH 10/34 kernelshark: Use sliced() or first() instead of mid/right/left()
In reply to Benjamin ROBINFix Clazy warning and it is faster.
--- src/KsMainWindow.cpp | 2 +- src/KsUtils.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
src/KsMainWindow.cpp +1 -1
@@ -1275,7 +1275,7 @@ void KsMainWindow::_load(const QString& fileName, bool append) pbLabel += fileName; } else { pbLabel += "..."; - pbLabel += fileName.mid(fileName.size() - 37, 37); + pbLabel += fileName.sliced(fileName.size() - 37); } setWindowTitle("Kernel Shark");
src/KsUtils.cpp +2 -2
@@ -534,8 +534,8 @@ QVector<int> parseIdList(QString v_str) int i = item.indexOf('-'); if (i > 0) { /* This item is an interval. */ - int to = item.right(item.size() - i - 1).toInt(); - int from = item.left(i).toInt(); + int to = item.sliced(i + 1).toInt(); + int from = item.first(i).toInt(); int s = v.size(); v.resize(s + to - from + 1);
Signature · 1 line
2.43.0
PATCH 11/34 kernelshark: Prevent potential divide by zero in Shape::center()
In reply to Benjamin ROBIN--- src/KsPlotTools.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
src/KsPlotTools.cpp +8 -6
@@ -318,13 +318,15 @@ ksplot_point Shape::center() const { ksplot_point c = {0, 0}; - for (size_t i = 0; i < _nPoints; ++i) { - c.x += _points[i].x; - c.y += _points[i].y; - } + if (_nPoints > 0) { + for (size_t i = 0; i < _nPoints; ++i) { + c.x += _points[i].x; + c.y += _points[i].y; + } - c.x /= _nPoints; - c.y /= _nPoints; + c.x /= _nPoints; + c.y /= _nPoints; + } return c; }
Signature · 1 line
2.43.0
Re: [PATCH 11/34] kernelshark: Prevent potential divide by zero in Shape::center()
Quoted 10 lines · Benjamin ROBIN
Signed-off-by Benjamin ROBIN <[email protected]>--- src/KsPlotTools.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)src/KsPlotTools.cpp +0
-0
src/KsPlotTools.cpp ksplot_point Shape::center() const · line 321
Quoted 8 lines
src/KsPlotTools.cpp +1
-4@@ -318,13 +318,15 @@ ksplot_point Shape::center() const { ksplot_point c = {0, 0}; - for (size_t i = 0; i < _nPoints; ++i) { - c.x += _points[i].x; - c.y += _points[i].y; - } + if (_nPoints > 0) {
Can we just have
if (_nPoints == 0)
return c;
Thanks,
Y.
Quoted 13 lines
src/KsPlotTools.cpp +7
-2+ for (size_t i = 0; i < _nPoints; ++i) { + c.x += _points[i].x; + c.y += _points[i].y; + } - c.x /= _nPoints; - c.y /= _nPoints; + c.x /= _nPoints; + c.y /= _nPoints; + } return c; }
PATCH v2 11/34 kernelshark: Prevent potential divide by zero in Shape::center()
--- src/KsPlotTools.cpp | 3 +++ 1 file changed, 3 insertions(+)
src/KsPlotTools.cpp +3 -0
@@ -318,6 +318,9 @@ ksplot_point Shape::center() const { ksplot_point c = {0, 0}; + if (_nPoints == 0) + return c; + for (size_t i = 0; i < _nPoints; ++i) { c.x += _points[i].x; c.y += _points[i].y;
Signature · 1 line
2.43.0
PATCH 12/34 kernelshark: Fix potential access to uninitialized variable
In reply to Benjamin ROBINIf "nStreams" is zero, jstream may be accessed while uninitialized in KsSession::_savePlots() and in KsSession::_getPlots()
--- src/KsSession.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/KsSession.cpp +2 -2
@@ -348,7 +348,7 @@ void KsSession::loadGraphs(kshark_context *kshark_ctx, void KsSession::_savePlots(int sd, KsGLWidget *glw, bool cpu) { kshark_config_doc *streamsConf = kshark_config_alloc(KS_CONFIG_JSON); - json_object *jallStreams, *jstream, *jstreamId, *jplots; + json_object *jallStreams, *jstream = nullptr, *jstreamId, *jplots; QVector<int> plotIds; int nStreams;
@@ -438,7 +438,7 @@ void KsSession::_saveComboPlots(KsGLWidget *glw) QVector<int> KsSession::_getPlots(int sd, bool cpu) { kshark_config_doc *streamsConf = kshark_config_alloc(KS_CONFIG_JSON); - json_object *jallStreams, *jstream, *jstreamId, *jplots; + json_object *jallStreams, *jstream = nullptr, *jstreamId, *jplots; int nStreams, nPlots, id; const char *plotKey; QVector<int> plots;
Signature · 1 line
2.43.0
PATCH 13/34 kernelshark: Remove unused locals variables
In reply to Benjamin ROBIN--- src/KsTraceGraph.cpp | 1 - src/KsUtils.cpp | 1 - src/plugins/KVMComboDialog.cpp | 1 - 3 files changed, 3 deletions(-)
src/KsTraceGraph.cpp +0 -1
@@ -331,7 +331,6 @@ void KsTraceGraph::_setPointerInfo(size_t i) QString aux(lanMakeString(kshark_get_aux_info(e))); QString info(lanMakeString(kshark_get_info(e))); QString comm(lanMakeString(kshark_get_task(e))); - QString elidedText; int labelWidth; uint64_t sec, usec; char *pointer;
src/KsUtils.cpp +0 -1
@@ -1414,7 +1414,6 @@ void KsPluginManager::updatePlugins(int sd, QVector<int> pluginStates) kshark_context *kshark_ctx(nullptr); kshark_data_stream *stream; kshark_dpi_list *plugin; - QVector<int> vec; int i(0); if (!kshark_instance(&kshark_ctx))
src/plugins/KVMComboDialog.cpp +0 -1
@@ -342,7 +342,6 @@ void KsComboPlotDialog::_guestStreamChanged(int) return; int newGuestId = _guestStreamComboBox.currentData().toInt(); - QVector<int> vcpuCBs(_guestMapCount, 0); _plotMap[_currentGuestStream] = _streamCombos(_currentGuestStream);
Signature · 1 line
2.43.0
PATCH 14/34 kernelshark: Fix range-loop-reference Clazy warning
In reply to Benjamin ROBIN--- src/KsUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/KsUtils.cpp +1 -1
@@ -530,7 +530,7 @@ QVector<int> parseIdList(QString v_str) QStringList list = v_str.split(",", KS_SPLIT_SkipEmptyParts); QVector<int> v; - for (auto item: list) { + for (const auto &item: list) { int i = item.indexOf('-'); if (i > 0) { /* This item is an interval. */
Signature · 1 line
2.43.0
PATCH 15/34 kernelshark: Fix moving a temp object prevents copy elision warning
In reply to Benjamin ROBIN--- src/KsTraceViewer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/KsTraceViewer.cpp +1 -1
@@ -855,7 +855,7 @@ void KsTraceViewer::_searchItemsMT() QVector<QList<int>> res; for (auto &m: maps) - res.append(std::move(m.get())); + res.append(m.get()); lamSearchMerge(_matchList, res); }
Signature · 1 line
2.43.0
PATCH 16/34 kernelshark: Add receiver object to connect() call
In reply to Benjamin ROBINWhen calling a lambda, this is recommended to pass the receiver object
--- src/KsTraceViewer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/KsTraceViewer.cpp +1 -1
@@ -139,7 +139,7 @@ KsTraceViewer::KsTraceViewer(QWidget *parent) } }; connect(&_selectionModel, &QItemSelectionModel::selectionChanged, - lamSelectionChanged); + this, lamSelectionChanged); _searchFSM.placeInToolBar(&_toolbar);
Signature · 1 line
2.43.0
PATCH 17/34 kernelshark: Return by reference the list of header in KsModels
In reply to Benjamin ROBIN--- src/KsModels.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/KsModels.hpp +1 -1
@@ -81,7 +81,7 @@ public: void update(KsDataStore *data); /** Get the list of column's headers. */ - QStringList header() const {return _header;} + const QStringList& header() const {return _header;} QString getValueStr(int column, int row) const;
Signature · 1 line
2.43.0
PATCH 18/34 kernelshark: Fix detaching-temporary Clazy warning
In reply to Benjamin ROBINUse QList::at() instead of QList::operator[]()
--- src/KsTraceViewer.cpp | 4 ++-- src/KsUtils.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
src/KsTraceViewer.cpp +2 -2
@@ -624,11 +624,11 @@ void KsTraceViewer::_resizeToContents() * column by hand. */ col = KsViewModel::TRACE_VIEW_COL_STREAM; - columnSize = STRING_WIDTH(_model.header()[col]) + FONT_WIDTH; + columnSize = STRING_WIDTH(_model.header().at(col)) + FONT_WIDTH; _view.setColumnWidth(col, columnSize); col = KsViewModel::TRACE_VIEW_COL_CPU; - columnSize = STRING_WIDTH(_model.header()[col]) + FONT_WIDTH * 2; + columnSize = STRING_WIDTH(_model.header().at(col)) + FONT_WIDTH * 2; _view.setColumnWidth(col, columnSize); col = KsViewModel::TRACE_VIEW_COL_INDEX;
src/KsUtils.hpp +2 -2
@@ -25,10 +25,10 @@ #include "KsPlotTools.hpp" /** Macro providing the height of the screen in pixels. */ -#define SCREEN_HEIGHT QGuiApplication::screens()[0]->geometry().height() +#define SCREEN_HEIGHT QGuiApplication::screens().at(0)->geometry().height() /** Macro providing the width of the screen in pixels. */ -#define SCREEN_WIDTH QGuiApplication::screens()[0]->geometry().width() +#define SCREEN_WIDTH QGuiApplication::screens().at(0)->geometry().width() //! @cond Doxygen_Suppress
Signature · 1 line
2.43.0
PATCH 19/34 kernelshark: Fix qfileinfo-exists Clazy warning
In reply to Benjamin ROBINUse static QFileInfo::exists() instead
--- src/KsUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/KsUtils.cpp +1 -1
@@ -471,7 +471,7 @@ QString getSaveFile(QWidget *parent, if (!fileName.isEmpty() && !fileName.endsWith(extension)) { fileName += extension; - if (QFileInfo(fileName).exists()) { + if (QFileInfo::exists(fileName)) { if (!KsWidgetsLib::fileExistsDialog(fileName)) fileName.clear(); }
Signature · 1 line
2.43.0
PATCH 20/34 kernelshark: Fix potential memory leaks in libkshark-configio
In reply to Benjamin ROBINAllocate a new kshark_config_doc only if the format is supported.
--- src/libkshark-configio.c | 74 ++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 33 deletions(-)
src/libkshark-configio.c +41 -33
@@ -675,23 +675,25 @@ struct kshark_config_doc * kshark_export_plugin_file(struct kshark_plugin_list *plugin, enum kshark_config_formats format) { - /* Create a new Configuration document. */ - struct kshark_config_doc *conf = -kshark_config_new ("kshark.config.library" , format); - -if (!conf) -return NULL ; + struct kshark_config_doc *conf;switch (format) {case KS_CONFIG_JSON : -kshark_plugin_to_json (plugin, conf->conf_doc); -return conf; +break ;default :fprintf (stderr,"Document format %d not supported\n" , - conf->format); + format);return NULL ; } + +/* Create a new Configuration document. */ + conf =kshark_config_new ("kshark.config.library" , format); +if (!conf) +return NULL ; + +kshark_plugin_to_json (plugin, conf->conf_doc); +return conf; } static bool kshark_all_plugins_to_json(struct kshark_context *kshark_ctx,
@@ -739,22 +741,24 @@ struct kshark_config_doc * kshark_export_all_plugins(struct kshark_context *kshark_ctx, enum kshark_config_formats format) { - struct kshark_config_doc *conf = -kshark_config_new ("kshark.config.plugins" ,KS_CONFIG_JSON ); - -if (!conf) -return NULL ; + struct kshark_config_doc *conf;switch (format) {case KS_CONFIG_JSON : -kshark_all_plugins_to_json (kshark_ctx, conf->conf_doc); -return conf; +break ;default :fprintf (stderr,"Document format %d not supported\n" , - conf->format); + format);return NULL ; } + + conf =kshark_config_new ("kshark.config.plugins" , format); +if (!conf) +return NULL ; + +kshark_all_plugins_to_json (kshark_ctx, conf->conf_doc); +return conf; } static bool kshark_plugin_from_json(struct kshark_context *kshark_ctx,
@@ -867,22 +871,24 @@ struct kshark_config_doc * kshark_export_stream_plugins(struct kshark_data_stream *stream, enum kshark_config_formats format) { - struct kshark_config_doc *conf = -kshark_config_new ("kshark.config.plugins" ,KS_CONFIG_JSON ); - -if (!conf) -return NULL ; + struct kshark_config_doc *conf;switch (format) {case KS_CONFIG_JSON : -kshark_stream_plugins_to_json (stream, conf->conf_doc); -return conf; +break ;default :fprintf (stderr,"Document format %d not supported\n" , - conf->format); + format);return NULL ; } + + conf =kshark_config_new ("kshark.config.plugins" ,KS_CONFIG_JSON ); +if (!conf) +return NULL ; + +kshark_stream_plugins_to_json (stream, conf->conf_doc); +return conf; } static bool kshark_stream_plugins_from_json(struct kshark_context *kshark_ctx,
@@ -1019,23 +1025,25 @@ struct kshark_config_doc * kshark_export_model(struct kshark_trace_histo *histo, enum kshark_config_formats format) { - /* Create a new Configuration document. */ - struct kshark_config_doc *conf = -kshark_config_new ("kshark.config.model" , format); - -if (!conf) -return NULL ; + struct kshark_config_doc *conf;switch (format) {case KS_CONFIG_JSON : -kshark_model_to_json (histo, conf->conf_doc); -return conf; +break ;default :fprintf (stderr,"Document format %d not supported\n" , format);return NULL ; } + +/* Create a new Configuration document. */ + conf =kshark_config_new ("kshark.config.model" , format); +if (!conf) +return NULL ; + +kshark_model_to_json (histo, conf->conf_doc); +return conf; } static bool kshark_model_from_json(struct kshark_trace_histo *histo,
Signature · 1 line
2.43.0
Re: [PATCH 20/34] kernelshark: Fix potential memory leaks in libkshark-configio
Quoted 51 lines · Benjamin ROBIN
Allocate a new
kshark_config_doconly if the format is supported.Signed-off-by Benjamin ROBIN <[email protected]>--- src/libkshark-configio.c | 74 ++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 33 deletions(-)src/libkshark-configio.c +11
-10@@ -675,23 +675,25 @@ struct kshark_config_doc * kshark_export_plugin_file(struct kshark_plugin_list *plugin, enum kshark_config_formats format) { - /* Create a new Configuration document. */ - struct kshark_config_doc *conf = -kshark_config_new ("kshark.config.library" , format); - -if (!conf) -return NULL ; + struct kshark_config_doc *conf;switch (format) {case KS_CONFIG_JSON : -kshark_plugin_to_json (plugin, conf->conf_doc); -return conf; +break ;default :fprintf (stderr,"Document format %d not supported\n" , - conf->format); + format);return NULL ; } + +/* Create a new Configuration document. */ + conf =kshark_config_new ("kshark.config.library" , format); +if (!conf) +return NULL ; + +kshark_plugin_to_json (plugin, conf->conf_doc); +return conf; } static bool kshark_all_plugins_to_json(struct kshark_context *kshark_ctx,@@ -739,22 +741,24 @@ struct kshark_config_doc * kshark_export_all_plugins(struct kshark_context *kshark_ctx, enum kshark_config_formats format) { - struct kshark_config_doc *conf =
src/libkshark-configio.c struct kshark_config_doc * · line 751
Quoted 10 lines
src/libkshark-configio.c +1
-6-kshark_config_new ("kshark.config.plugins" ,KS_CONFIG_JSON ); - -if (!conf) -return NULL ; +struct kshark_config_doc *conf;switch (format) {case KS_CONFIG_JSON : -kshark_all_plugins_to_json (kshark_ctx, conf->conf_doc); -return conf;
I agree that this code is a bit confusing. Long time ago we had the idea that we will support not only 'json' but also other formats. And that we will have other 'kshark_plugin_to_xxx()' APIs. This is the reason to have this 'switch'.
Please keep the code as it is and just call kshark_free_config_doc() in the default (error) case.
Quoted 23 lines
src/libkshark-configio.c +9
-2+break ;default :fprintf (stderr,"Document format %d not supported\n" , - conf->format); + format);return NULL ; } + + conf =kshark_config_new ("kshark.config.plugins" , format); +if (!conf) +return NULL ; + +kshark_all_plugins_to_json (kshark_ctx, conf->conf_doc); +return conf; } static bool kshark_plugin_from_json(struct kshark_context *kshark_ctx,@@ -867,22 +871,24 @@ struct kshark_config_doc * kshark_export_stream_plugins(struct kshark_data_stream *stream, enum kshark_config_formats format) { - struct kshark_config_doc *conf =
src/libkshark-configio.c struct kshark_config_doc * · line 879
Quoted 10 lines
src/libkshark-configio.c +1
-6-kshark_config_new ("kshark.config.plugins" ,KS_CONFIG_JSON ); - -if (!conf) -return NULL ; +struct kshark_config_doc *conf;switch (format) {case KS_CONFIG_JSON : -kshark_stream_plugins_to_json (stream, conf->conf_doc); -return conf;
Same comment applies here.
Thanks!
Y.
Quoted 52 lines
src/libkshark-configio.c +19
-9+break ;default :fprintf (stderr,"Document format %d not supported\n" , - conf->format); + format);return NULL ; } + + conf =kshark_config_new ("kshark.config.plugins" ,KS_CONFIG_JSON ); +if (!conf) +return NULL ; + +kshark_stream_plugins_to_json (stream, conf->conf_doc); +return conf; } static bool kshark_stream_plugins_from_json(struct kshark_context *kshark_ctx,@@ -1019,23 +1025,25 @@ struct kshark_config_doc * kshark_export_model(struct kshark_trace_histo *histo, enum kshark_config_formats format) { - /* Create a new Configuration document. */ - struct kshark_config_doc *conf = -kshark_config_new ("kshark.config.model" , format); - -if (!conf) -return NULL ; + struct kshark_config_doc *conf;switch (format) {case KS_CONFIG_JSON : -kshark_model_to_json (histo, conf->conf_doc); -return conf; +break ;default :fprintf (stderr,"Document format %d not supported\n" , format);return NULL ; } + +/* Create a new Configuration document. */ + conf =kshark_config_new ("kshark.config.model" , format); +if (!conf) +return NULL ; + +kshark_model_to_json (histo, conf->conf_doc); +return conf; } static bool kshark_model_from_json(struct kshark_trace_histo *histo,
PATCH v2 20/34 kernelshark: Fix potential memory leaks in libkshark-configio
Free previously allocated kshark_config_doc if format is not supported.
Also allow to call kshark_export_*() functions that allocate a new kshark_config_doc with format equal to KS_CONFIG_AUTO.
--- src/libkshark-configio.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
src/libkshark-configio.c +13 -8
@@ -515,7 +515,7 @@ kshark_export_trace_file(const char *file, const char *name,if (!conf)return NULL ; -switch (format) { +switch (conf->format) {case KS_CONFIG_JSON :kshark_trace_file_to_json (file, name, conf->conf_doc);return conf;
@@ -523,6 +523,7 @@ kshark_export_trace_file(const char *file, const char *name,default :fprintf (stderr,"Document format %d not supported\n" , conf->format); +kshark_free_config_doc (conf);return NULL ; } }
@@ -682,7 +683,7 @@ kshark_export_plugin_file(struct kshark_plugin_list *plugin,if (!conf)return NULL ; -switch (format) { +switch (conf->format) {case KS_CONFIG_JSON :kshark_plugin_to_json (plugin, conf->conf_doc);return conf;
@@ -690,6 +691,7 @@ kshark_export_plugin_file(struct kshark_plugin_list *plugin,default :fprintf (stderr,"Document format %d not supported\n" , conf->format); +kshark_free_config_doc (conf);return NULL ; } }
@@ -740,12 +742,12 @@ kshark_export_all_plugins(struct kshark_context *kshark_ctx, enum kshark_config_formats format) {struct kshark_config_doc *conf = -kshark_config_new ("kshark.config.plugins" ,KS_CONFIG_JSON ); +kshark_config_new ("kshark.config.plugins" , format);if (!conf)return NULL ; -switch (format) { +switch (conf->format) {case KS_CONFIG_JSON :kshark_all_plugins_to_json (kshark_ctx, conf->conf_doc);return conf;
@@ -753,6 +755,7 @@ kshark_export_all_plugins(struct kshark_context *kshark_ctx,default :fprintf (stderr,"Document format %d not supported\n" , conf->format); +kshark_free_config_doc (conf);return NULL ; } }
@@ -868,12 +871,12 @@ kshark_export_stream_plugins(struct kshark_data_stream *stream, enum kshark_config_formats format) {struct kshark_config_doc *conf = -kshark_config_new ("kshark.config.plugins" ,KS_CONFIG_JSON ); +kshark_config_new ("kshark.config.plugins" , format);if (!conf)return NULL ; -switch (format) { +switch (conf->format) {case KS_CONFIG_JSON :kshark_stream_plugins_to_json (stream, conf->conf_doc);return conf;
@@ -881,6 +884,7 @@ kshark_export_stream_plugins(struct kshark_data_stream *stream,default :fprintf (stderr,"Document format %d not supported\n" , conf->format); +kshark_free_config_doc (conf);return NULL ; } }
@@ -1026,14 +1030,15 @@ kshark_export_model(struct kshark_trace_histo *histo,if (!conf)return NULL ; -switch (format) { +switch (conf->format) {case KS_CONFIG_JSON :kshark_model_to_json (histo, conf->conf_doc);return conf;default :fprintf (stderr,"Document format %d not supported\n" , - format); + conf->format); +kshark_free_config_doc (conf);return NULL ; } }
Signature · 1 line
2.43.0
PATCH 21/34 kernelshark: Fix potential access to uninitialized variable
In reply to Benjamin ROBINAlways call json_object_put() with a valid "jlist" pointer.
--- src/libkshark-configio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/libkshark-configio.c +2 -2
@@ -777,7 +777,7 @@ static bool kshark_plugin_from_json(struct kshark_context *kshark_ctx,static bool kshark_all_plugins_from_json (struct kshark_context *kshark_ctx,struct json_object *jobj) { -struct json_object *jlist, *jfile; +struct json_object *jlist =NULL , *jfile =NULL ;int i, n_plugins;if (!kshark_ctx || !jobj)
@@ -902,7 +902,7 @@ static bool kshark_stream_plugins_from_json(struct kshark_context *kshark_ctx,int i, n_plugins;bool active; - jplg = jname = jstatus =NULL ; + jlist = jplg = jname = jstatus =NULL ;if (!kshark_ctx || !stream || !jobj)return false;
Signature · 1 line
2.43.0
PATCH 22/34 kernelshark: Fix potential double free of histo->map, histo->bin_count
In reply to Benjamin ROBIN--- src/libkshark-model.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
src/libkshark-model.c +2 -1
@@ -104,7 +104,8 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo,free (histo->bin_count);free (histo->map); - + histo->map =NULL ; + histo->bin_count =NULL ;return ; }
Signature · 1 line
2.43.0
PATCH 23/34 kernelshark: Fix 'const' type qualifier on return type has no effect
In reply to Benjamin ROBINAlso fix clang build, which allow to execute Clang-Tidy and Clazy
--- src/libkshark-tepdata.c | 12 ++++++------ src/libkshark.h | 20 ++++++++++---------- tests/test-input.c | 4 ++-- tests/test-input_ctrl.c | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-)
src/libkshark-tepdata.c +6 -6
@@ -634,8 +634,8 @@ ssize_t kshark_load_tep_records(struct kshark_context *kshark_ctx, int sd,return -ENOMEM ; } -static const int tepdata_get_event_id (struct kshark_data_stream *stream, -const struct kshark_entry *entry) +static int tepdata_get_event_id (struct kshark_data_stream *stream, +const struct kshark_entry *entry) {int event_id =KS_EMPTY_BIN ;struct tep_record *record;
@@ -727,8 +727,8 @@ static char *tepdata_get_event_name(struct kshark_data_stream *stream,return buffer; } -static const int tepdata_get_pid (struct kshark_data_stream *stream, -const struct kshark_entry *entry) +static int tepdata_get_pid (struct kshark_data_stream *stream, +const struct kshark_entry *entry) {struct tep_record *record;int pid =KS_EMPTY_BIN ;
@@ -1054,8 +1054,8 @@ static char *tepdata_dump_entry(struct kshark_data_stream *stream,return entry_str; } -static const int tepdata_find_event_id (struct kshark_data_stream *stream, -const char *event_name) +static int tepdata_find_event_id (struct kshark_data_stream *stream, +const char *event_name) {struct tep_event *event;char *buffer, *system, *name;
src/libkshark.h +10 -10
@@ -142,8 +142,8 @@ typedef char *(*stream_get_str_func) (struct kshark_data_stream *, const struct kshark_entry *);/** A function type to be used by the method interface of the data stream. */ -typedef const int (*stream_get_int_func ) (struct kshark_data_stream *, -const struct kshark_entry *); +typedef int (*stream_get_int_func ) (struct kshark_data_stream *, +const struct kshark_entry *);/** A function type to be used by the method interface of the data stream. */ typedef int (*stream_find_id_func) (struct kshark_data_stream *,
@@ -176,16 +176,16 @@ typedef kshark_event_field_format const char *);/** A function type to be used by the method interface of the data stream. */ -typedef const int (*stream_read_event_field ) (struct kshark_data_stream *, -const struct kshark_entry *, -const char *, -int64_t *); +typedef int (*stream_read_event_field ) (struct kshark_data_stream *, +const struct kshark_entry *, +const char *, +int64_t *);/** A function type to be used by the method interface of the data stream. */ -typedef const int (*stream_read_record_field ) (struct kshark_data_stream *, -void *, -const char *, -int64_t *); +typedef int (*stream_read_record_field ) (struct kshark_data_stream *, +void *, +const char *, +int64_t *);struct kshark_context ;
tests/test-input.c +2 -2
@@ -69,8 +69,8 @@ bool KSHARK_INPUT_CHECK(const char *file, char **format)return false; } -static const int get_pid (struct kshark_data_stream *stream, -const struct kshark_entry *entry) +static int get_pid (struct kshark_data_stream *stream, +const struct kshark_entry *entry) {return entry->pid; }
tests/test-input_ctrl.c +2 -2
@@ -71,8 +71,8 @@ bool KSHARK_INPUT_CHECK(const char *file, char **format)return false; } -static const int get_pid (struct kshark_data_stream *stream, -const struct kshark_entry *entry) +static int get_pid (struct kshark_data_stream *stream, +const struct kshark_entry *entry) {return entry->pid; }
Signature · 1 line
2.43.0
PATCH 24/34 kernelshark: Fix potential memory leaks in libkshark-tepdata
In reply to Benjamin ROBIN- In tepdata_get_field_names(), buffer was never free on error
- In kshark_tep_open_buffer(), names were never free if kshark_get_data_stream() failed
- In kshark_tep_open_buffer(), prevent any double free error with "name" and "file" fields of buffer_stream
- In kshark_tep_init_all_buffers(), return failure code if failed to copy "name" and "file" fields of buffer_stream
--- src/libkshark-tepdata.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
src/libkshark-tepdata.c +11 -5
@@ -949,6 +949,7 @@ static int tepdata_get_field_names(struct kshark_data_stream *stream,for (i =0 ; i < nr_fields; ++i)free (buffer[i]); +free (buffer);return -EFAULT ; }
@@ -1424,8 +1425,10 @@ int kshark_tep_open_buffer(struct kshark_context *kshark_ctx, int sd, sd_buffer =kshark_add_stream (kshark_ctx); buffer_stream =kshark_get_data_stream (kshark_ctx, sd_buffer); -if (!buffer_stream) -return -EFAULT ; +if (!buffer_stream) { + ret = -EFAULT ; + goto fail; + }for (i =0 ; i < n_buffers; ++i) {if (strcmp (buffer_name, names[i]) ==0 ) {
@@ -1438,7 +1441,8 @@ int kshark_tep_open_buffer(struct kshark_context *kshark_ctx, int sd,if (!buffer_stream->name || !buffer_stream->file) {free (buffer_stream->name);free (buffer_stream->file); - + buffer_stream->name =NULL ; + buffer_stream->file =NULL ; ret = -ENOMEM ;break ; }
@@ -1449,6 +1453,7 @@ int kshark_tep_open_buffer(struct kshark_context *kshark_ctx, int sd, } } +fail:for (i =0 ; i < n_buffers; ++i)free (names[i]);free (names);
@@ -1500,8 +1505,9 @@ int kshark_tep_init_all_buffers(struct kshark_context *kshark_ctx,if (!buffer_stream->name || !buffer_stream->file) {free (buffer_stream->name);free (buffer_stream->file); - ret = -ENOMEM ; -break ; + buffer_stream->name =NULL ; + buffer_stream->file =NULL ; +return -ENOMEM ; } ret =kshark_tep_stream_init (buffer_stream, buffer_input);
Signature · 1 line
2.43.0
Re: [PATCH 24/34] kernelshark: Fix potential memory leaks in libkshark-tepdata
Quoted 49 lines · Benjamin ROBIN
- In
tepdata_get_field_names(), buffer was never free on error
- Inkshark_tep_open_buffer(), names were never free ifkshark_get_data_stream()failed
- Inkshark_tep_open_buffer(), prevent any double free error with "name" and "file" fields ofbuffer_stream
- Inkshark_tep_init_all_buffers(), return failure code if failed to copy "name" and "file" fields ofbuffer_streamSigned-off-by Benjamin ROBIN <[email protected]>--- src/libkshark-tepdata.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)src/libkshark-tepdata.c +7
-3@@ -949,6 +949,7 @@ static int tepdata_get_field_names(struct kshark_data_stream *stream,for (i =0 ; i < nr_fields; ++i)free (buffer[i]); +free (buffer);return -EFAULT ; }@@ -1424,8 +1425,10 @@ int kshark_tep_open_buffer(struct kshark_context *kshark_ctx, int sd, sd_buffer =kshark_add_stream (kshark_ctx); buffer_stream =kshark_get_data_stream (kshark_ctx, sd_buffer); -if (!buffer_stream) -return -EFAULT ; +if (!buffer_stream) { + ret = -EFAULT ; + goto fail; + }for (i =0 ; i < n_buffers; ++i) {if (strcmp (buffer_name, names[i]) ==0 ) {@@ -1438,7 +1441,8 @@ int kshark_tep_open_buffer(struct kshark_context *kshark_ctx, int sd,if (!buffer_stream->name || !buffer_stream->file) {free (buffer_stream->name);free (buffer_stream->file); - + buffer_stream->name =NULL ; + buffer_stream->file =NULL ; ret = -ENOMEM ;break ; }
src/libkshark-tepdata.c int kshark_tep_open_buffer(struct kshark_context *kshark_ctx, int sd, · line 1456
Quoted 4 lines
src/libkshark-tepdata.c +1
-0@@ -1449,6 +1453,7 @@ int kshark_tep_open_buffer(struct kshark_context *kshark_ctx, int sd, } } +fail:
This is not a true 'fail' because the code below gets executed even if everything is fine. Perhaps you can use "free" or "end" or something similar?
Thanks,
Y.
Quoted 15 lines
src/libkshark-tepdata.c +3
-2for (i =0 ; i < n_buffers; ++i)free (names[i]);free (names);@@ -1500,8 +1505,9 @@ int kshark_tep_init_all_buffers(struct kshark_context *kshark_ctx,if (!buffer_stream->name || !buffer_stream->file) {free (buffer_stream->name);free (buffer_stream->file); - ret = -ENOMEM ; -break ; + buffer_stream->name =NULL ; + buffer_stream->file =NULL ; +return -ENOMEM ; } ret =kshark_tep_stream_init (buffer_stream, buffer_input);
PATCH v2 24/34 kernelshark: Fix potential memory leaks in libkshark-tepdata
- In tepdata_get_field_names(), buffer was never free on error
- In kshark_tep_open_buffer(), names were never free if kshark_get_data_stream() failed
- In kshark_tep_open_buffer(), prevent any double free error with "name" and "file" fields of buffer_stream
- In kshark_tep_init_all_buffers(), return failure code if failed to copy "name" and "file" fields of buffer_stream
--- src/libkshark-tepdata.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
src/libkshark-tepdata.c +11 -5
@@ -949,6 +949,7 @@ static int tepdata_get_field_names(struct kshark_data_stream *stream,for (i =0 ; i < nr_fields; ++i)free (buffer[i]); +free (buffer);return -EFAULT ; }
@@ -1424,8 +1425,10 @@ int kshark_tep_open_buffer(struct kshark_context *kshark_ctx, int sd, sd_buffer =kshark_add_stream (kshark_ctx); buffer_stream =kshark_get_data_stream (kshark_ctx, sd_buffer); -if (!buffer_stream) -return -EFAULT ; +if (!buffer_stream) { + ret = -EFAULT ; + goto end; + }for (i =0 ; i < n_buffers; ++i) {if (strcmp (buffer_name, names[i]) ==0 ) {
@@ -1438,7 +1441,8 @@ int kshark_tep_open_buffer(struct kshark_context *kshark_ctx, int sd,if (!buffer_stream->name || !buffer_stream->file) {free (buffer_stream->name);free (buffer_stream->file); - + buffer_stream->name =NULL ; + buffer_stream->file =NULL ; ret = -ENOMEM ;break ; }
@@ -1449,6 +1453,7 @@ int kshark_tep_open_buffer(struct kshark_context *kshark_ctx, int sd, } } +end:for (i =0 ; i < n_buffers; ++i)free (names[i]);free (names);
@@ -1500,8 +1505,9 @@ int kshark_tep_init_all_buffers(struct kshark_context *kshark_ctx,if (!buffer_stream->name || !buffer_stream->file) {free (buffer_stream->name);free (buffer_stream->file); - ret = -ENOMEM ; -break ; + buffer_stream->name =NULL ; + buffer_stream->file =NULL ; +return -ENOMEM ; } ret =kshark_tep_stream_init (buffer_stream, buffer_input);
Signature · 1 line
2.43.0
PATCH 25/34 kernelshark: Fix typo in comment of KsGLWidget::resizeGL()
In reply to Benjamin ROBIN--- src/KsGLWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/KsGLWidget.cpp +1 -1
@@ -93,7 +93,7 @@ void KsGLWidget::initializeGL() } /** - * Reimplemented function used to reprocess all graphs whene the widget has + * Reimplemented function used to reprocess all graphs when the widget has * been resized. */ void KsGLWidget::resizeGL(int w, int h)
Signature · 1 line
2.43.0
PATCH 26/34 kernelshark: Remove unused KsDataWidget::wipPtr() and broken function
In reply to Benjamin ROBIN--- src/KsWidgetsLib.hpp | 6 ------ 1 file changed, 6 deletions(-)
src/KsWidgetsLib.hpp +0 -6
@@ -123,12 +123,6 @@ public: explicit KsDataWidget(QWidget *parent = nullptr) : QWidget(parent), _workInProgress(nullptr) {} - /** Set a pointer to the KsWorkInProgress widget. */ - const KsWorkInProgress *wipPtr(KsWorkInProgress *wip) const - { - return _workInProgress; - } - /** Set the pointer to the KsWorkInProgress widget. */ void setWipPtr(KsWorkInProgress *wip) {
Signature · 1 line
2.43.0
PATCH 27/34 kernelshark: In KsTimeOffsetDialog() constructor use parent param
In reply to Benjamin ROBINPass parent parameter to QDialog() constructor
--- src/KsWidgetsLib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/KsWidgetsLib.cpp +1 -1
@@ -209,7 +209,7 @@ bool fileExistsDialog(QString fileName) } /** Create KsTimeOffsetDialog. */ -KsTimeOffsetDialog::KsTimeOffsetDialog(QWidget *parent) +KsTimeOffsetDialog::KsTimeOffsetDialog(QWidget *parent) : QDialog(parent) { kshark_context *kshark_ctx(nullptr); QVector<int> streamIds;
Signature · 1 line
2.43.0
PATCH 28/34 kernelshark: Fixed loop counter incremented suspiciously twice
In reply to Benjamin ROBIN--- examples/datafilter.c | 6 ------ 1 file changed, 6 deletions(-)
examples/datafilter.c +0 -6
@@ -69,7 +69,6 @@ int main(int argc, char **argv)/* Print to the screen the first 10 visible entries. */ count =0 ; - i =0 ;for (i =0 ; i < n_rows; ++i) {if (data[i]->visible &KS_TEXT_VIEW_FILTER_MASK ) { entry_str =kshark_dump_entry (data[i]);
@@ -79,8 +78,6 @@ int main(int argc, char **argv)if (++count >10 )break ; } - - ++i; }puts ("\n\n" );
@@ -102,7 +99,6 @@ int main(int argc, char **argv)/* Print to the screen the first 10 visible entries. */ count =0 ; - i =0 ;for (i =0 ; i < n_rows; ++i) {if (data[i]->visible &KS_TEXT_VIEW_FILTER_MASK ) { entry_str =kshark_dump_entry (data[i]);
@@ -112,8 +108,6 @@ int main(int argc, char **argv)if (++count >10 )break ; } - - ++i; }puts ("\n\n" );
Signature · 1 line
2.43.0
PATCH 29/34 kernelshark: Fix tepdata_dump_entry() for event_id = KS_EVENT_OVERFLOW
In reply to Benjamin ROBINGenerated string was dropped, and did generate a memory leak, because of the missing break.
--- src/libkshark-tepdata.c | 1 + 1 file changed, 1 insertion(+)
src/libkshark-tepdata.c +1 -0
@@ -1047,6 +1047,7 @@ static char *tepdata_dump_entry(struct kshark_data_stream *stream,case KS_EVENT_OVERFLOW : entry_str =tepdata_dump_custom_entry (stream, entry, missed_events_dump); +break ;default :return NULL ; }
Signature · 1 line
2.43.0
PATCH 30/34 kernelshark: Use static_cast instead of C cast in KsMainWindow
In reply to Benjamin ROBIN--- src/KsMainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/KsMainWindow.cpp +1 -1
@@ -1546,7 +1546,7 @@ void KsMainWindow::_captureFinished(int ret, QProcess::ExitStatus st) void KsMainWindow::_captureError(QProcess::ProcessError error) { - QProcess *capture = (QProcess *)sender(); + QProcess *capture = static_cast<QProcess*>(sender()); _captureErrorMessage(capture); }
Signature · 1 line
2.43.0
PATCH 31/34 kernelshark: Fix comparison of integers of different signs warnings
In reply to Benjamin ROBINMost of them have been fixed, but a few still remain.
--- examples/configio.c | 3 ++- examples/datafilter.c | 9 ++++++--- examples/datahisto.c | 2 +- src/libkshark-collection.c | 14 ++++++++------ src/libkshark-configio.c | 6 ++++-- src/libkshark-hash.c | 5 +++-- src/libkshark-model.c | 16 +++++++++------- src/libkshark-tepdata.c | 2 +- src/libkshark.c | 17 +++++++++-------- src/plugins/sched_events.c | 2 +- 10 files changed, 44 insertions(+), 32 deletions(-)
examples/configio.c +2 -1
@@ -8,7 +8,8 @@ int main(int argc, char **argv)struct kshark_config_doc *conf, *filter, *hello;struct kshark_context *kshark_ctx;struct kshark_data_stream *stream; -int sd, *ids =NULL , i; +int sd, *ids =NULL ; +size_t i;/* Create a new kshark session. */ kshark_ctx =NULL ;
examples/datafilter.c +6 -3
@@ -23,6 +23,7 @@ int main(int argc, char **argv)struct kshark_entry **data =NULL ;int *pids, *evt_ids;char *entry_str; +int rt;/* Create a new kshark session. */ kshark_ctx =NULL ;
@@ -31,15 +32,17 @@ int main(int argc, char **argv)/* Open a trace data file produced by trace-cmd. */ if (argc >1 ) - sd =kshark_open (kshark_ctx, argv[1 ]); + rt =kshark_open (kshark_ctx, argv[1 ]);else - sd =kshark_open (kshark_ctx, default_file); + rt =kshark_open (kshark_ctx, default_file); -if (sd <0 ) { +if (rt <0 ) {kshark_free (kshark_ctx);return 1 ; } + sd = (size_t )rt; +/* Load the content of the file into an array of entries. */ n_rows =kshark_load_entries (kshark_ctx, sd, &data);
examples/datahisto.c +1 -1
@@ -70,7 +70,7 @@ void dump_bin(struct kshark_trace_histo *histo, int bin, int sd,void dump_histo (struct kshark_trace_histo *histo,int sd,const char *type,int val) { -size_t bin; +int bin;for (bin =0 ; bin < histo->n_bins; ++bin)dump_bin (histo, bin, sd, type, val);
src/libkshark-collection.c +8 -6
@@ -518,14 +518,16 @@ static int map_collection_front_request(const struct kshark_entry_collection *col, struct kshark_entry_request *req) { - size_t req_first, req_end; -ssize_t col_index; + size_t req_first, req_end, col_index; +ssize_t r;int req_count; - col_index =map_collection_request_init (col, req, true, &req_end); -if (col_index ==KS_EMPTY_BIN ) + r =map_collection_request_init (col, req, true, &req_end); +if (r ==KS_EMPTY_BIN )return 0 ; + col_index = (size_t )r; +/* * Now loop over the intervals of the collection going forwards till * the end of the inputted request and create a separate request for
@@ -746,7 +748,7 @@ kshark_find_data_collection(struct kshark_entry_collection *col,while (col) {if (col->cond == cond && col->stream_id == sd && - col->n_val == n_val && + (size_t )col->n_val == n_val &&val_compare (col->values, values, n_val))return col;
@@ -899,7 +901,7 @@ void kshark_unregister_data_collection(struct kshark_entry_collection **col,for (list = *col; list; list = list->next) {if (list->cond == cond && list->stream_id == sd && - list->n_val == n_val && + (size_t )list->n_val == n_val &&val_compare (list->values, values, n_val)) { *last = list->next;kshark_free_data_collection (list);
src/libkshark-configio.c +4 -2
@@ -1117,7 +1117,8 @@ static bool kshark_event_filter_to_json(struct kshark_data_stream *stream,json_object *jfilter_data, *jname;struct kshark_hash_id *filter;char *name_str; -int i, *ids; +int *ids; +size_t i; filter =kshark_get_filter (stream, filter_type);if (!filter)
@@ -1286,7 +1287,8 @@ static bool kshark_filter_array_to_json(struct kshark_hash_id *filter, struct json_object *jobj) {json_object *jfilter_data, *jpid =NULL ; -int i, *ids; +int *ids; +size_t i;/* * If this Json document already contains a description of the filter,
src/libkshark-hash.c +3 -2
@@ -169,7 +169,7 @@ void kshark_hash_id_clear(struct kshark_hash_id *hash) {struct kshark_hash_id_item *item, *next;size_t size; -int i; +size_t i;if (!hash || ! hash->hash)return ;
@@ -212,7 +212,8 @@ int *kshark_hash_ids(struct kshark_hash_id *hash) {struct kshark_hash_id_item *item;size_t size =hash_size (hash); -int count =0 , i; +size_t i; +int count =0 ;int *ids;if (!hash->count)
src/libkshark-model.c +9 -7
@@ -97,6 +97,8 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo,int64_t corrected_range, delta_range, range = max - min;struct kshark_entry *last; +assert (min <= max); +if (n <=0 ) { histo->n_bins = histo->bin_size =0 ; histo->min = min;
@@ -110,7 +112,7 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo, }/* The size of the bin must be >= 1, hence the range must be >= n. */ -if (range < n) { +if ((size_t )range < n) { range = n; max = min + n; }
@@ -119,7 +121,7 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo,* If the number of bins changes, allocate memory for the descriptor of * the model. */ -if (n != histo->n_bins) { +if (n != (size_t )histo->n_bins) {if (!ksmodel_histo_alloc (histo, n)) {ksmodel_clear (histo);return ;
@@ -282,7 +284,7 @@ static void ksmodel_set_next_bin_edge(struct kshark_trace_histo *histo,* case we have to increase the size of the very last bin in order to * make sure that the last entry of the dataset will fall into it. */ -if (next_bin == histo->n_bins -1 ) +if (next_bin == (size_t )(histo->n_bins -1 )) ++time_max;/*
@@ -544,7 +546,7 @@ void ksmodel_shift_forward(struct kshark_trace_histo *histo, size_t n)void ksmodel_shift_backward (struct kshark_trace_histo *histo,size_t n) {size_t last_row =0 ; -int bin; +size_t bin;if (!histo->data_size)return ;
@@ -561,7 +563,7 @@ void ksmodel_shift_backward(struct kshark_trace_histo *histo, size_t n) histo->min -= n * histo->bin_size; histo->max -= n * histo->bin_size; -if (n >= histo->n_bins) { +if (n >= (size_t )histo->n_bins) {/* * No overlap between the new and the old range. Recalculate * all bins from scratch. First calculate the new range.
@@ -649,7 +651,7 @@ void ksmodel_jump_to(struct kshark_trace_histo *histo, int64_t ts)static void ksmodel_zoom (struct kshark_trace_histo *histo,double r,int mark,bool zoom_in) { -size_t range, min, max, delta_min; +int64_t range, min, max, delta_min;double delta_tot;if (!histo->data_size)
@@ -668,7 +670,7 @@ static void ksmodel_zoom(struct kshark_trace_histo *histo,* Avoid overzooming. If needed, adjust the Scale factor to a the value * which provides bin_size >= 5. */ -if (zoom_in && (size_t ) (range * (1. - r)) < histo->n_bins *5 ) +if (zoom_in && (int )(range * (1. - r)) < (histo->n_bins *5 )) r =1. - (histo->n_bins *5. ) / range;/*
src/libkshark-tepdata.c +1 -1
@@ -239,7 +239,7 @@ static int get_next_pid(struct kshark_data_stream *stream, ret =tep_read_number_field (get_sched_next (stream), record->data, &val); -return ret ? : val; +return ret ? : (int )val; } static void register_command(struct kshark_data_stream *stream,
src/libkshark.c +9 -8
@@ -1371,9 +1371,10 @@ void kshark_clear_all_filters(struct kshark_context *kshark_ctx, {struct kshark_data_stream *stream;int *stream_ids, i; +size_t j; -for (i =0 ; i < n_entries; ++i) -set_all_visible (&data[i]->visible); +for (j =0 ; j < n_entries; ++j) +set_all_visible (&data[j]->visible); stream_ids =kshark_all_streams (kshark_ctx);for (i =0 ; i < kshark_ctx->n_streams; i++) {
@@ -1942,7 +1943,7 @@ kshark_merge_data_entries(struct kshark_entry_data_set *buffers, int n_buffers)return NULL ; } -for (i =0 ; i < n_buffers; ++i) { +for (i =0 ; i < (size_t )n_buffers; ++i) { count[i] =0 ;if (buffers[i].n_rows >0 ) tot += buffers[i].n_rows;
@@ -2111,7 +2112,7 @@ kshark_merge_data_matrices(struct kshark_matrix_data_set *buffers, int n_buffers {struct kshark_matrix_data_set merged_data;size_t i, tot =0 , count[n_buffers]; -int i_first; +int i_first, j;bool status; merged_data.n_rows =-1 ;
@@ -2121,10 +2122,10 @@ kshark_merge_data_matrices(struct kshark_matrix_data_set *buffers, int n_buffers goto end; } -for (i =0 ; i < n_buffers; ++i) { - count[i] =0 ; -if (buffers[i].n_rows >0 ) - tot += buffers[i].n_rows; +for (j =0 ; j < n_buffers; ++j) { + count[j] =0 ; +if (buffers[j].n_rows >0 ) + tot += buffers[j].n_rows; } status = kshark_data_matrix_alloc(tot, &merged_data.event_array,
src/plugins/sched_events.c +1 -1
@@ -115,7 +115,7 @@ static void plugin_sched_swith_action(struct kshark_data_stream *stream, ret =tep_read_number_field (plugin_ctx->sched_switch_next_field, record->data, &next_pid); -if (ret ==0 && next_pid >=0 ) { +if (ret ==0 ) {plugin_sched_set_pid (&ks_field, entry->pid); ret = tep_read_number_field(plugin_ctx->sched_switch_prev_state_field,
Signature · 1 line
2.43.0
Re: [PATCH 31/34] kernelshark: Fix comparison of integers of different signs warnings
Quoted 35 lines · Benjamin ROBIN
Most of them have been fixed, but a few still remain.
Signed-off-by Benjamin ROBIN <[email protected]>--- examples/configio.c | 3 ++- examples/datafilter.c | 9 ++++++--- examples/datahisto.c | 2 +- src/libkshark-collection.c | 14 ++++++++------ src/libkshark-configio.c | 6 ++++-- src/libkshark-hash.c | 5 +++-- src/libkshark-model.c | 16 +++++++++------- src/libkshark-tepdata.c | 2 +- src/libkshark.c | 17 +++++++++-------- src/plugins/sched_events.c | 2 +- 10 files changed, 44 insertions(+), 32 deletions(-)examples/configio.c +2
-1@@ -8,7 +8,8 @@ int main(int argc, char **argv)struct kshark_config_doc *conf, *filter, *hello;struct kshark_context *kshark_ctx;struct kshark_data_stream *stream; -int sd, *ids =NULL , i; +int sd, *ids =NULL ; +size_t i;/* Create a new kshark session. */ kshark_ctx =NULL ;examples/datafilter.c +0
-0
examples/datafilter.c int main(int argc, char **argv) · line 26
Quoted 4 lines
examples/datafilter.c +1
-0@@ -23,6 +23,7 @@ int main(int argc, char **argv)struct kshark_entry **data =NULL ;int *pids, *evt_ids;char *entry_str; +int rt;
'sd' should be of type int. No need to declare 'rt'.
Quoted 42 lines
examples/datafilter.c +5
-3/* Create a new kshark session. */ kshark_ctx =NULL ;@@ -31,15 +32,17 @@ int main(int argc, char **argv)/* Open a trace data file produced by trace-cmd. */ if (argc >1 ) - sd =kshark_open (kshark_ctx, argv[1 ]); + rt =kshark_open (kshark_ctx, argv[1 ]);else - sd =kshark_open (kshark_ctx, default_file); + rt =kshark_open (kshark_ctx, default_file); -if (sd <0 ) { +if (rt <0 ) {kshark_free (kshark_ctx);return 1 ; } + sd = (size_t )rt; +/* Load the content of the file into an array of entries. */ n_rows =kshark_load_entries (kshark_ctx, sd, &data);examples/datahisto.c +1
-1@@ -70,7 +70,7 @@ void dump_bin(struct kshark_trace_histo *histo, int bin, int sd,void dump_histo (struct kshark_trace_histo *histo,int sd,const char *type,int val) { -size_t bin; +int bin;for (bin =0 ; bin < histo->n_bins; ++bin)dump_bin (histo, bin, sd, type, val);src/libkshark-collection.c +0
-0
src/libkshark-collection.c static int · line 522
Quoted 7 lines
src/libkshark-collection.c +2
-2@@ -518,14 +518,16 @@ static int map_collection_front_request(const struct kshark_entry_collection *col, struct kshark_entry_request *req) { - size_t req_first, req_end; -ssize_t col_index; + size_t req_first, req_end, col_index; +ssize_t r;
We are trying to use self explanatory variable names if possible. In many places in the code for variables like this one we use 'ret'.
Quoted 83 lines
src/libkshark-collection.c +6
-4int req_count; - col_index =map_collection_request_init (col, req, true, &req_end); -if (col_index ==KS_EMPTY_BIN ) + r =map_collection_request_init (col, req, true, &req_end); +if (r ==KS_EMPTY_BIN )return 0 ; + col_index = (size_t )r; +/* * Now loop over the intervals of the collection going forwards till * the end of the inputted request and create a separate request for @@ -746,7 +748,7 @@ kshark_find_data_collection(struct kshark_entry_collection *col,while (col) {if (col->cond == cond && col->stream_id == sd && - col->n_val == n_val && + (size_t )col->n_val == n_val &&val_compare (col->values, values, n_val))return col;@@ -899,7 +901,7 @@ void kshark_unregister_data_collection(struct kshark_entry_collection **col,for (list = *col; list; list = list->next) {if (list->cond == cond && list->stream_id == sd && - list->n_val == n_val && + (size_t )list->n_val == n_val &&val_compare (list->values, values, n_val)) { *last = list->next;kshark_free_data_collection (list);src/libkshark-configio.c +4
-2@@ -1117,7 +1117,8 @@ static bool kshark_event_filter_to_json(struct kshark_data_stream *stream,json_object *jfilter_data, *jname;struct kshark_hash_id *filter;char *name_str; -int i, *ids; +int *ids; +size_t i; filter =kshark_get_filter (stream, filter_type);if (!filter)@@ -1286,7 +1287,8 @@ static bool kshark_filter_array_to_json(struct kshark_hash_id *filter, struct json_object *jobj) {json_object *jfilter_data, *jpid =NULL ; -int i, *ids; +int *ids; +size_t i;/* * If this Json document already contains a description of the filter, src/libkshark-hash.c +3
-2@@ -169,7 +169,7 @@ void kshark_hash_id_clear(struct kshark_hash_id *hash) {struct kshark_hash_id_item *item, *next;size_t size; -int i; +size_t i;if (!hash || ! hash->hash)return ;@@ -212,7 +212,8 @@ int *kshark_hash_ids(struct kshark_hash_id *hash) {struct kshark_hash_id_item *item;size_t size =hash_size (hash); -int count =0 , i; +size_t i; +int count =0 ;int *ids;if (!hash->count)src/libkshark-model.c +0
-0
src/libkshark-model.c static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo, · line 100
Quoted 4 lines
src/libkshark-model.c +1
-0@@ -97,6 +97,8 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo,int64_t corrected_range, delta_range, range = max - min;struct kshark_entry *last; +assert (min <= max);
Having this assert() makes it safe to declare 'range' as size_t.
Quoted 14 lines
src/libkshark-model.c +2
-1+if (n <=0 ) { histo->n_bins = histo->bin_size =0 ; histo->min = min;@@ -110,7 +112,7 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo, }/* The size of the bin must be >= 1, hence the range must be >= n. */ -if (range < n) { +if ((size_t )range < n) { range = n; max = min + n; }
src/libkshark-model.c static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo, · line 122
Quoted 4 lines
src/libkshark-model.c +0
-1@@ -119,7 +121,7 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo,* If the number of bins changes, allocate memory for the descriptor of * the model. */ -if (n != histo->n_bins) {
I think the problem here is that the function argument 'n' is declared with wrong type. It must match the type of histo->n_bins which is int.
Quoted 89 lines
src/libkshark-model.c +6
-5+if (n != (size_t )histo->n_bins) {if (!ksmodel_histo_alloc (histo, n)) {ksmodel_clear (histo);return ;@@ -282,7 +284,7 @@ static void ksmodel_set_next_bin_edge(struct kshark_trace_histo *histo,* case we have to increase the size of the very last bin in order to * make sure that the last entry of the dataset will fall into it. */ -if (next_bin == histo->n_bins -1 ) +if (next_bin == (size_t )(histo->n_bins -1 )) ++time_max;/* @@ -544,7 +546,7 @@ void ksmodel_shift_forward(struct kshark_trace_histo *histo, size_t n)void ksmodel_shift_backward (struct kshark_trace_histo *histo,size_t n) {size_t last_row =0 ; -int bin; +size_t bin;if (!histo->data_size)return ;@@ -561,7 +563,7 @@ void ksmodel_shift_backward(struct kshark_trace_histo *histo, size_t n) histo->min -= n * histo->bin_size; histo->max -= n * histo->bin_size; -if (n >= histo->n_bins) { +if (n >= (size_t )histo->n_bins) {/* * No overlap between the new and the old range. Recalculate * all bins from scratch. First calculate the new range. @@ -649,7 +651,7 @@ void ksmodel_jump_to(struct kshark_trace_histo *histo, int64_t ts)static void ksmodel_zoom (struct kshark_trace_histo *histo,double r,int mark,bool zoom_in) { -size_t range, min, max, delta_min; +int64_t range, min, max, delta_min;double delta_tot;if (!histo->data_size)@@ -668,7 +670,7 @@ static void ksmodel_zoom(struct kshark_trace_histo *histo,* Avoid overzooming. If needed, adjust the Scale factor to a the value * which provides bin_size >= 5. */ -if (zoom_in && (size_t ) (range * (1. - r)) < histo->n_bins *5 ) +if (zoom_in && (int )(range * (1. - r)) < (histo->n_bins *5 )) r =1. - (histo->n_bins *5. ) / range;/* src/libkshark-tepdata.c +1
-1@@ -239,7 +239,7 @@ static int get_next_pid(struct kshark_data_stream *stream, ret =tep_read_number_field (get_sched_next (stream), record->data, &val); -return ret ? : val; +return ret ? : (int )val; } static void register_command(struct kshark_data_stream *stream,src/libkshark.c +4
-3@@ -1371,9 +1371,10 @@ void kshark_clear_all_filters(struct kshark_context *kshark_ctx, {struct kshark_data_stream *stream;int *stream_ids, i; +size_t j; -for (i =0 ; i < n_entries; ++i) -set_all_visible (&data[i]->visible); +for (j =0 ; j < n_entries; ++j) +set_all_visible (&data[j]->visible); stream_ids =kshark_all_streams (kshark_ctx);for (i =0 ; i < kshark_ctx->n_streams; i++) {@@ -1942,7 +1943,7 @@ kshark_merge_data_entries(struct kshark_entry_data_set *buffers, int n_buffers)return NULL ; } -for (i =0 ; i < n_buffers; ++i) { +for (i =0 ; i < (size_t )n_buffers; ++i) { count[i] =0 ;if (buffers[i].n_rows >0 ) tot += buffers[i].n_rows;
src/libkshark.c kshark_merge_data_matrices(struct kshark_matrix_data_set *buffers, int n_buffers · line 2114
Quoted 3 lines
src/libkshark.c +0
-0@@ -2111,7 +2112,7 @@ kshark_merge_data_matrices(struct kshark_matrix_data_set *buffers, int n_buffers {struct kshark_matrix_data_set merged_data;size_t i, tot =0 , count[n_buffers];
Note that 'n_buffers' must be size_t as well. Better fix this.
Quoted 33 lines
src/libkshark.c +5
-5-int i_first; +int i_first, j;bool status; merged_data.n_rows =-1 ;@@ -2121,10 +2122,10 @@ kshark_merge_data_matrices(struct kshark_matrix_data_set *buffers, int n_buffers goto end; } -for (i =0 ; i < n_buffers; ++i) { - count[i] =0 ; -if (buffers[i].n_rows >0 ) - tot += buffers[i].n_rows; +for (j =0 ; j < n_buffers; ++j) { + count[j] =0 ; +if (buffers[j].n_rows >0 ) + tot += buffers[j].n_rows; } status = kshark_data_matrix_alloc(tot, &merged_data.event_array,src/plugins/sched_events.c +1
-1@@ -115,7 +115,7 @@ static void plugin_sched_swith_action(struct kshark_data_stream *stream, ret =tep_read_number_field (plugin_ctx->sched_switch_next_field, record->data, &next_pid); -if (ret ==0 && next_pid >=0 ) { +if (ret ==0 ) {plugin_sched_set_pid (&ks_field, entry->pid); ret = tep_read_number_field(plugin_ctx->sched_switch_prev_state_field,
PATCH 32/34 kernelshark: Fix KsTableView columns width, and KsTraceViewer size
In reply to Benjamin ROBIN- Use QSizePolicy::Expanding for KsTraceViewer object to use full height
- Do not use StyleSheet for KsTableView. When the StyleSheet is updated Qt6 redraw the whole table but with default column width without querying items sizeHint(). So instead use QPalette::Highlight.
- Simplify _resizeToContents() since the columns have a proper width with Qt6
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=218351
--- src/KsTraceViewer.cpp | 67 ++++++++++++------------------------------- src/KsTraceViewer.hpp | 2 ++ 2 files changed, 20 insertions(+), 49 deletions(-)
src/KsTraceViewer.cpp +18 -49
@@ -83,7 +83,7 @@ KsTraceViewer::KsTraceViewer(QWidget *parent) _mState(nullptr), _data(nullptr) { - this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); + this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); /* Make a search toolbar. */ _toolbar.setOrientation(Qt::Horizontal);
@@ -125,6 +125,7 @@ KsTraceViewer::KsTraceViewer(QWidget *parent) int defaultRowHeight = FONT_HEIGHT * 1.25; auto lamSelectionChanged = [this, defaultRowHeight] (const QItemSelection &selected, const QItemSelection &deselected) { + if (deselected.count()) { _view.verticalHeader()->resizeSection(deselected.indexes().first().row(), defaultRowHeight);
@@ -208,33 +209,13 @@ void KsTraceViewer::loadData(KsDataStore *data) /** Connect the QTableView widget and the State machine of the Dual marker. */ void KsTraceViewer::setMarkerSM(KsDualMarkerSM *m) { - QString styleSheetA, styleSheetB; - _mState = m; _model.setMarkerColors(_mState->markerA()._color, _mState->markerB()._color); - /* - * Assign a property to State A of the Dual marker state machine. When - * the marker is in State A the background color of the selected row - * will be the same as the color of Marker A. - */ - styleSheetA = "selection-background-color : " + - _mState->markerA()._color.name() + ";"; - - _mState->stateAPtr()->assignProperty(&_view, "styleSheet", - styleSheetA); - - /* - * Assign a property to State B. When the marker is in State B the - * background color of the selected row will be the same as the color - * of Marker B. - */ - styleSheetB = "selection-background-color : " + - _mState->markerB()._color.name() + ";"; - - _mState->stateBPtr()->assignProperty(&_view, "styleSheet", - styleSheetB); + _viewPalette = _view.palette(); + _viewPalette.setColor(QPalette::Highlight, _mState->activeMarker()._color); + _view.setPalette(_viewPalette); } /** Reset (empty) the table. */
@@ -502,35 +483,38 @@ void KsTraceViewer::markSwitch() ssize_t row; /* The state of the Dual marker has changed. Get the new active marker. */ - DualMarkerState state = _mState->getState(); + DualMarkerState actState = _mState->getState(); + DualMarkerState pasState = !actState; /* First deal with the passive marker. */ - if (_mState->getMarker(!state)._isSet) { + KsGraphMark &pasMark = _mState->getMarker(pasState); + if (pasMark._isSet) { /* * The passive marker is set. Use the model to color the row of * the passive marker. */ - _model.selectRow(!state, _mState->getMarker(!state)._pos); + _model.selectRow(pasState, pasMark._pos); } else { /* * The passive marker is not set. * Make sure that the model colors nothing. */ - _model.selectRow(!state, KS_NO_ROW_SELECTED); + _model.selectRow(pasState, KS_NO_ROW_SELECTED); } /* * Now deal with the active marker. This has to be done after dealing * with the model, because changing the model clears the selection. */ - if (_mState->getMarker(state)._isSet) { + KsGraphMark &actMark = _mState->getMarker(actState); + if (actMark._isSet) { /* * The active marker is set. Use QTableView to select its row. * The index in the source model is used to retrieve the value * of the row number in the proxy model. */ - row =_mState->getMarker(state)._pos; + row = actMark._pos; QModelIndex index = _proxyModel.mapFromSource(_model.index(row, 0));
@@ -552,6 +536,9 @@ void KsTraceViewer::markSwitch() _view.clearSelection(); } + _viewPalette.setColor(QPalette::Highlight, actMark._color); + _view.setPalette(_viewPalette); + row = selectedRow(); if (row >= 0) { _setSearchIterator(row);
@@ -604,7 +591,7 @@ void KsTraceViewer::keyReleaseEvent(QKeyEvent *event) void KsTraceViewer::_resizeToContents() { - int col, rows, columnSize, markRow = selectedRow(); + int markRow = selectedRow(); _view.setVisible(false); _view.resizeColumnsToContents();
@@ -617,24 +604,6 @@ void KsTraceViewer::_resizeToContents() */ if (markRow == KS_NO_ROW_SELECTED) _view.clearSelection(); - - /* - * Because of some unknown reason some of the columns doesn't get - * resized properly by the code above. We will resize this - * column by hand. - */ - col = KsViewModel::TRACE_VIEW_COL_STREAM; - columnSize = STRING_WIDTH(_model.header().at(col)) + FONT_WIDTH; - _view.setColumnWidth(col, columnSize); - - col = KsViewModel::TRACE_VIEW_COL_CPU; - columnSize = STRING_WIDTH(_model.header().at(col)) + FONT_WIDTH * 2; - _view.setColumnWidth(col, columnSize); - - col = KsViewModel::TRACE_VIEW_COL_INDEX; - rows = _model.rowCount({}); - columnSize = STRING_WIDTH(QString("%1").arg(rows)) + FONT_WIDTH; - _view.setColumnWidth(col, columnSize); } //! @cond Doxygen_Suppress
src/KsTraceViewer.hpp +2 -0
@@ -123,6 +123,8 @@ private: KsTableView _view; + QPalette _viewPalette; + KsViewModel _model; KsFilterProxyModel _proxyModel;
Signature · 1 line
2.43.0
PATCH 33/34 kernelshark: Allow to reduce a bit more the graph height
In reply to Benjamin ROBINWith this configuration, at least one core on the graph can be seen
--- src/KsTraceGraph.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/KsTraceGraph.cpp +2 -2
@@ -593,8 +593,8 @@ void KsTraceGraph::updateGeom() _layout.contentsMargins().top() + _layout.contentsMargins().bottom(); - if (hMin > KS_GRAPH_HEIGHT * 8) - hMin = KS_GRAPH_HEIGHT * 8; + if (hMin > KS_GRAPH_HEIGHT * 6) + hMin = KS_GRAPH_HEIGHT * 6; setMinimumHeight(hMin);
Signature · 1 line
2.43.0
Re: [PATCH 33/34] kernelshark: Allow to reduce a bit more the graph height
Quoted 1 line · Benjamin ROBIN
With this configuration, at least one core on the graph can be seen
Please provide a better explanation of the problem you are trying to solve with this patch. It seems that you decrease the minimum height of the widget. How is this going to make "at least one core on the graph can be seen"?
And please make sure you signed all your patches.
Thanks!
Y.
Quoted 19 lines
--- src/KsTraceGraph.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)src/KsTraceGraph.cpp +2
-2@@ -593,8 +593,8 @@ void KsTraceGraph::updateGeom() _layout.contentsMargins().top() + _layout.contentsMargins().bottom(); - if (hMin > KS_GRAPH_HEIGHT * 8) - hMin = KS_GRAPH_HEIGHT * 8; + if (hMin > KS_GRAPH_HEIGHT * 6) + hMin = KS_GRAPH_HEIGHT * 6; setMinimumHeight(hMin);
PATCH v2 33/34 kernelshark: Allow to reduce a bit more the graph height
Reduce minimum height of the graph widget which allows the user (using the splitter widget) to expand a bit more the trace viewer (KsTraceViewer) which provide the table view (KsTableView).
This is very useful when a user has a very small screen.
With this configuration, at least one CPU core on the graph (KsTraceGraph) can be seen, so the graph widget is still perfectly usable.
--- src/KsTraceGraph.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/KsTraceGraph.cpp +2 -2
@@ -593,8 +593,8 @@ void KsTraceGraph::updateGeom() _layout.contentsMargins().top() + _layout.contentsMargins().bottom(); - if (hMin > KS_GRAPH_HEIGHT * 8) - hMin = KS_GRAPH_HEIGHT * 8; + if (hMin > KS_GRAPH_HEIGHT * 6) + hMin = KS_GRAPH_HEIGHT * 6; setMinimumHeight(hMin);
Signature · 1 line
2.43.0
PATCH 34/34 kernelshark: Cleanup of KsDualMarker methods
In reply to Benjamin ROBINRemove stateAPtr and stateBPtr methods since no longer needed
--- src/KsDualMarker.hpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
src/KsDualMarker.hpp +2 -8
@@ -144,22 +144,16 @@ public: /** Get the marker B. */ KsGraphMark &markerB() {return _markB;} - /** Get a pointer to the State A object. */ - QState *stateAPtr() {return _stateA;} - - /** Get a pointer to the State B object. */ - QState *stateBPtr() {return _stateB;} - void updateMarkers(const KsDataStore &data, KsGLWidget *glw); void updateLabels(); /** Get the index inside the data array marker A points to. */ - ssize_t markerAPos() {return markerA()._isSet ? markerA()._pos : -1;} + ssize_t markerAPos() {return _markA._isSet ? _markA._pos : -1;} /** Get the index inside the data array marker B points to. */ - ssize_t markerBPos() {return markerB()._isSet ? markerB()._pos : -1;} + ssize_t markerBPos() {return _markB._isSet ? _markB._pos : -1;} signals: /**
Signature · 1 line
2.43.0
Hi Benjamin,
I am applying most of the patches from your patch-set. I have some minor comments about few of the changes that I will make in the individual patches.
Once again, thanks a lot for helping us to improve kernelshark!
Cheers,
Yordan
Quoted 84 lines · Benjamin ROBIN
There were 3 majors issues:
- A segfault when loading a trace file (patch 0001)
- The trace table height was very small (patch 0032)
- The trace table columns width were reducing when clicking Marker A or B (patch 0032)Also fix most of the warnings reported by Clang-Tidy and Clazy, and by gcc with -Wextra.
Benjamin ROBIN (34):
kernelshark: FixmodelReset()signaling, rename update to updateGeom
kernelshark: Add .gitignore
kernelshark: Remove function param when not used, whenever possible
kernelshark: Do not create a temporary container for looping over QMap
kernelshark: Prevent potential detach of QMap container
kernelshark: Fix used after free of QByteArray raw data
kernelshark: Fix potential memory leak in KsGLWidget
kernelshark: Use lambda parameter instead of captured local variable
kernelshark: Keep overridden method protected instead of public
kernelshark: Usesliced()orfirst()instead of mid/right/left()
kernelshark: Prevent potential divide by zero inShape::center()
kernelshark: Fix potential access to uninitialized variable
kernelshark: Remove unused locals variables
kernelshark: Fix range-loop-reference Clazy warning
kernelshark: Fix moving a temp object prevents copy elision warning
kernelshark: Add receiver object toconnect()call
kernelshark: Return by reference the list of header in KsModels
kernelshark: Fix detaching-temporary Clazy warning
kernelshark: Fix qfileinfo-exists Clazy warning
kernelshark: Fix potential memory leaks in libkshark-configio
kernelshark: Fix potential access to uninitialized variable
kernelshark: Fix potential double free ofhisto->map,histo->bin_count
kernelshark: Fix 'const' type qualifier on return type has no effect
kernelshark: Fix potential memory leaks in libkshark-tepdata
kernelshark: Fix typo in comment ofKsGLWidget::resizeGL()
kernelshark: Remove unusedKsDataWidget::wipPtr()and broken function
kernelshark: InKsTimeOffsetDialog()constructor use parent param
kernelshark: Fixed loop counter incremented suspiciously twice
kernelshark: Fixtepdata_dump_entry()forevent_id=KS_EVENT_OVERFLOW
kernelshark: Usestatic_castinstead of C cast in KsMainWindow
kernelshark: Fix comparison of integers of different signs warnings
kernelshark: Fix KsTableView columns width, and KsTraceViewer size
kernelshark: Allow to reduce a bit more the graph height
kernelshark: Cleanup of KsDualMarker methods.gitignore | 15 ++++++ examples/configio.c | 3 +- examples/datafilter.c | 15 +++--- examples/datahisto.c | 2 +- src/KsAdvFilteringDialog.cpp | 24 ++++------ src/KsAdvFilteringDialog.hpp | 2 +- src/KsDualMarker.hpp | 10 +--- src/KsGLWidget.cpp | 48 +++++++++---------- src/KsGLWidget.hpp | 43 ++++++++--------- src/KsMainWindow.cpp | 8 ++-- src/KsModels.hpp | 11 +++-- src/KsPlotTools.cpp | 14 +++--- src/KsPlotTools.hpp | 2 +- src/KsSession.cpp | 4 +- src/KsTraceGraph.cpp | 7 ++- src/KsTraceViewer.cpp | 71 ++++++++-------------------- src/KsTraceViewer.hpp | 11 +++-- src/KsUtils.cpp | 9 ++-- src/KsUtils.hpp | 4 +- src/KsWidgetsLib.cpp | 2 +- src/KsWidgetsLib.hpp | 15 ++---- src/libkshark-collection.c | 14 +++--- src/libkshark-configio.c | 84 +++++++++++++++++++--------------- src/libkshark-hash.c | 5 +- src/libkshark-model.c | 19 ++++---- src/libkshark-tepdata.c | 31 ++++++++----- src/libkshark.c | 17 +++---- src/libkshark.h | 20 ++++---- src/plugins/KVMComboDialog.cpp | 7 +-- src/plugins/sched_events.c | 2 +- tests/test-input.c | 4 +- tests/test-input_ctrl.c | 4 +- 32 files changed, 257 insertions(+), 270 deletions(-)create mode 100644 .gitignore
--
2.43.0
Quoted 11 lines · Yordan Karadzhov
Hi Benjamin,
I am applying most of the patches from your patch-set. I have some minor comments about few of the changes that I will make in the individual patches.
Once again, thanks a lot for helping us to improve kernelshark!
Cheers,
Yordan
Hi Yordan,
Do you think it is possible to create a new release since all the major bugs were resolved?
Indeed, the KernelShark version 2.3.0 is currently not usable, and this is this version that is provided in the Arch repository. The Arch maintainers would prefer a new release instead of applying a ton of patches.
Thanks,
Benjamin
Quoted 85 lines · Benjamin ROBIN
Quoted 84 lines
There were 3 majors issues:
- A segfault when loading a trace file (patch 0001)
- The trace table height was very small (patch 0032)
- The trace table columns width were reducing when clicking Marker A or B (patch 0032)Also fix most of the warnings reported by Clang-Tidy and Clazy, and by gcc with -Wextra.
Benjamin ROBIN (34):
kernelshark: FixmodelReset()signaling, rename update to updateGeom
kernelshark: Add .gitignore
kernelshark: Remove function param when not used, whenever possible
kernelshark: Do not create a temporary container for looping over QMap
kernelshark: Prevent potential detach of QMap container
kernelshark: Fix used after free of QByteArray raw data
kernelshark: Fix potential memory leak in KsGLWidget
kernelshark: Use lambda parameter instead of captured local variable
kernelshark: Keep overridden method protected instead of public
kernelshark: Usesliced()orfirst()instead of mid/right/left()
kernelshark: Prevent potential divide by zero inShape::center()
kernelshark: Fix potential access to uninitialized variable
kernelshark: Remove unused locals variables
kernelshark: Fix range-loop-reference Clazy warning
kernelshark: Fix moving a temp object prevents copy elision warning
kernelshark: Add receiver object toconnect()call
kernelshark: Return by reference the list of header in KsModels
kernelshark: Fix detaching-temporary Clazy warning
kernelshark: Fix qfileinfo-exists Clazy warning
kernelshark: Fix potential memory leaks in libkshark-configio
kernelshark: Fix potential access to uninitialized variable
kernelshark: Fix potential double free ofhisto->map,histo->bin_count
kernelshark: Fix 'const' type qualifier on return type has no effect
kernelshark: Fix potential memory leaks in libkshark-tepdata
kernelshark: Fix typo in comment ofKsGLWidget::resizeGL()
kernelshark: Remove unusedKsDataWidget::wipPtr()and broken function
kernelshark: InKsTimeOffsetDialog()constructor use parent param
kernelshark: Fixed loop counter incremented suspiciously twice
kernelshark: Fixtepdata_dump_entry()forevent_id=KS_EVENT_OVERFLOW
kernelshark: Usestatic_castinstead of C cast in KsMainWindow
kernelshark: Fix comparison of integers of different signs warnings
kernelshark: Fix KsTableView columns width, and KsTraceViewer size
kernelshark: Allow to reduce a bit more the graph height
kernelshark: Cleanup of KsDualMarker methods.gitignore | 15 ++++++ examples/configio.c | 3 +- examples/datafilter.c | 15 +++--- examples/datahisto.c | 2 +- src/KsAdvFilteringDialog.cpp | 24 ++++------ src/KsAdvFilteringDialog.hpp | 2 +- src/KsDualMarker.hpp | 10 +--- src/KsGLWidget.cpp | 48 +++++++++---------- src/KsGLWidget.hpp | 43 ++++++++--------- src/KsMainWindow.cpp | 8 ++-- src/KsModels.hpp | 11 +++-- src/KsPlotTools.cpp | 14 +++--- src/KsPlotTools.hpp | 2 +- src/KsSession.cpp | 4 +- src/KsTraceGraph.cpp | 7 ++- src/KsTraceViewer.cpp | 71 ++++++++-------------------- src/KsTraceViewer.hpp | 11 +++-- src/KsUtils.cpp | 9 ++-- src/KsUtils.hpp | 4 +- src/KsWidgetsLib.cpp | 2 +- src/KsWidgetsLib.hpp | 15 ++---- src/libkshark-collection.c | 14 +++--- src/libkshark-configio.c | 84 +++++++++++++++++++--------------- src/libkshark-hash.c | 5 +- src/libkshark-model.c | 19 ++++---- src/libkshark-tepdata.c | 31 ++++++++----- src/libkshark.c | 17 +++---- src/libkshark.h | 20 ++++---- src/plugins/KVMComboDialog.cpp | 7 +-- src/plugins/sched_events.c | 2 +- tests/test-input.c | 4 +- tests/test-input_ctrl.c | 4 +- 32 files changed, 257 insertions(+), 270 deletions(-)create mode 100644 .gitignore
--
2.43.0
Hi Benjamin,
We still have one unresolved bug that was reported by Sudip.
I will do my best to get this sorted out and have a new release by the end of next week.
Thanks,
Y.
Quoted 109 lines · Benjamin ROBIN
Quoted 11 lines · Yordan Karadzhov
Hi Benjamin,
I am applying most of the patches from your patch-set. I have some minor comments about few of the changes that I will make in the individual patches.
Once again, thanks a lot for helping us to improve kernelshark!
Cheers,
YordanHi Yordan,
Do you think it is possible to create a new release since all the major bugs were resolved?
Indeed, the KernelShark version 2.3.0 is currently not usable, and this is this version that is provided in the Arch repository. The Arch maintainers would prefer a new release instead of applying a ton of patches.Thanks,
BenjaminQuoted 85 lines · Benjamin ROBIN
Quoted 84 lines
There were 3 majors issues:
- A segfault when loading a trace file (patch 0001)
- The trace table height was very small (patch 0032)
- The trace table columns width were reducing when clicking Marker A or B (patch 0032)Also fix most of the warnings reported by Clang-Tidy and Clazy, and by gcc with -Wextra.
Benjamin ROBIN (34):
kernelshark: FixmodelReset()signaling, rename update to updateGeom
kernelshark: Add .gitignore
kernelshark: Remove function param when not used, whenever possible
kernelshark: Do not create a temporary container for looping over QMap
kernelshark: Prevent potential detach of QMap container
kernelshark: Fix used after free of QByteArray raw data
kernelshark: Fix potential memory leak in KsGLWidget
kernelshark: Use lambda parameter instead of captured local variable
kernelshark: Keep overridden method protected instead of public
kernelshark: Usesliced()orfirst()instead of mid/right/left()
kernelshark: Prevent potential divide by zero inShape::center()
kernelshark: Fix potential access to uninitialized variable
kernelshark: Remove unused locals variables
kernelshark: Fix range-loop-reference Clazy warning
kernelshark: Fix moving a temp object prevents copy elision warning
kernelshark: Add receiver object toconnect()call
kernelshark: Return by reference the list of header in KsModels
kernelshark: Fix detaching-temporary Clazy warning
kernelshark: Fix qfileinfo-exists Clazy warning
kernelshark: Fix potential memory leaks in libkshark-configio
kernelshark: Fix potential access to uninitialized variable
kernelshark: Fix potential double free ofhisto->map,histo->bin_count
kernelshark: Fix 'const' type qualifier on return type has no effect
kernelshark: Fix potential memory leaks in libkshark-tepdata
kernelshark: Fix typo in comment ofKsGLWidget::resizeGL()
kernelshark: Remove unusedKsDataWidget::wipPtr()and broken function
kernelshark: InKsTimeOffsetDialog()constructor use parent param
kernelshark: Fixed loop counter incremented suspiciously twice
kernelshark: Fixtepdata_dump_entry()forevent_id=KS_EVENT_OVERFLOW
kernelshark: Usestatic_castinstead of C cast in KsMainWindow
kernelshark: Fix comparison of integers of different signs warnings
kernelshark: Fix KsTableView columns width, and KsTraceViewer size
kernelshark: Allow to reduce a bit more the graph height
kernelshark: Cleanup of KsDualMarker methods.gitignore | 15 ++++++ examples/configio.c | 3 +- examples/datafilter.c | 15 +++--- examples/datahisto.c | 2 +- src/KsAdvFilteringDialog.cpp | 24 ++++------ src/KsAdvFilteringDialog.hpp | 2 +- src/KsDualMarker.hpp | 10 +--- src/KsGLWidget.cpp | 48 +++++++++---------- src/KsGLWidget.hpp | 43 ++++++++--------- src/KsMainWindow.cpp | 8 ++-- src/KsModels.hpp | 11 +++-- src/KsPlotTools.cpp | 14 +++--- src/KsPlotTools.hpp | 2 +- src/KsSession.cpp | 4 +- src/KsTraceGraph.cpp | 7 ++- src/KsTraceViewer.cpp | 71 ++++++++-------------------- src/KsTraceViewer.hpp | 11 +++-- src/KsUtils.cpp | 9 ++-- src/KsUtils.hpp | 4 +- src/KsWidgetsLib.cpp | 2 +- src/KsWidgetsLib.hpp | 15 ++---- src/libkshark-collection.c | 14 +++--- src/libkshark-configio.c | 84 +++++++++++++++++++--------------- src/libkshark-hash.c | 5 +- src/libkshark-model.c | 19 ++++---- src/libkshark-tepdata.c | 31 ++++++++----- src/libkshark.c | 17 +++---- src/libkshark.h | 20 ++++---- src/plugins/KVMComboDialog.cpp | 7 +-- src/plugins/sched_events.c | 2 +- tests/test-input.c | 4 +- tests/test-input_ctrl.c | 4 +- 32 files changed, 257 insertions(+), 270 deletions(-)create mode 100644 .gitignore
--
2.43.0
Looking at these patches I think my issue should be fixed now. Let me try the latest HEAD tonight.
Signature · 2 lines
Regards Sudip
Quoted 120 lines · Yordan Karadzhov
Hi Benjamin,
We still have one unresolved bug that was reported by Sudip. I will do my best to get this sorted out and have a new release by the end of next week.
Thanks,
Y.Quoted 109 lines · Benjamin ROBIN
Quoted 11 lines · Yordan Karadzhov
Hi Benjamin,
I am applying most of the patches from your patch-set. I have some minor comments about few of the changes that I will make in the individual patches.
Once again, thanks a lot for helping us to improve kernelshark!
Cheers,
YordanHi Yordan,
Do you think it is possible to create a new release since all the major bugs were resolved?
Indeed, the KernelShark version 2.3.0 is currently not usable, and this is this version that is provided in the Arch repository. The Arch maintainers would prefer a new release instead of applying a ton of patches.Thanks,
BenjaminQuoted 85 lines · Benjamin ROBIN
Quoted 84 lines
There were 3 majors issues:
- A segfault when loading a trace file (patch 0001)
- The trace table height was very small (patch 0032)
- The trace table columns width were reducing when clicking Marker A or B (patch 0032)Also fix most of the warnings reported by Clang-Tidy and Clazy, and by gcc with -Wextra.
Benjamin ROBIN (34):
kernelshark: FixmodelReset()signaling, rename update to updateGeom
kernelshark: Add .gitignore
kernelshark: Remove function param when not used, whenever possible
kernelshark: Do not create a temporary container for looping over QMap
kernelshark: Prevent potential detach of QMap container
kernelshark: Fix used after free of QByteArray raw data
kernelshark: Fix potential memory leak in KsGLWidget
kernelshark: Use lambda parameter instead of captured local variable
kernelshark: Keep overridden method protected instead of public
kernelshark: Usesliced()orfirst()instead of mid/right/left()
kernelshark: Prevent potential divide by zero inShape::center()
kernelshark: Fix potential access to uninitialized variable
kernelshark: Remove unused locals variables
kernelshark: Fix range-loop-reference Clazy warning
kernelshark: Fix moving a temp object prevents copy elision warning
kernelshark: Add receiver object toconnect()call
kernelshark: Return by reference the list of header in KsModels
kernelshark: Fix detaching-temporary Clazy warning
kernelshark: Fix qfileinfo-exists Clazy warning
kernelshark: Fix potential memory leaks in libkshark-configio
kernelshark: Fix potential access to uninitialized variable
kernelshark: Fix potential double free ofhisto->map,histo->bin_count
kernelshark: Fix 'const' type qualifier on return type has no effect
kernelshark: Fix potential memory leaks in libkshark-tepdata
kernelshark: Fix typo in comment ofKsGLWidget::resizeGL()
kernelshark: Remove unusedKsDataWidget::wipPtr()and broken function
kernelshark: InKsTimeOffsetDialog()constructor use parent param
kernelshark: Fixed loop counter incremented suspiciously twice
kernelshark: Fixtepdata_dump_entry()forevent_id=KS_EVENT_OVERFLOW
kernelshark: Usestatic_castinstead of C cast in KsMainWindow
kernelshark: Fix comparison of integers of different signs warnings
kernelshark: Fix KsTableView columns width, and KsTraceViewer size
kernelshark: Allow to reduce a bit more the graph height
kernelshark: Cleanup of KsDualMarker methods.gitignore | 15 ++++++ examples/configio.c | 3 +- examples/datafilter.c | 15 +++--- examples/datahisto.c | 2 +- src/KsAdvFilteringDialog.cpp | 24 ++++------ src/KsAdvFilteringDialog.hpp | 2 +- src/KsDualMarker.hpp | 10 +--- src/KsGLWidget.cpp | 48 +++++++++---------- src/KsGLWidget.hpp | 43 ++++++++--------- src/KsMainWindow.cpp | 8 ++-- src/KsModels.hpp | 11 +++-- src/KsPlotTools.cpp | 14 +++--- src/KsPlotTools.hpp | 2 +- src/KsSession.cpp | 4 +- src/KsTraceGraph.cpp | 7 ++- src/KsTraceViewer.cpp | 71 ++++++++-------------------- src/KsTraceViewer.hpp | 11 +++-- src/KsUtils.cpp | 9 ++-- src/KsUtils.hpp | 4 +- src/KsWidgetsLib.cpp | 2 +- src/KsWidgetsLib.hpp | 15 ++---- src/libkshark-collection.c | 14 +++--- src/libkshark-configio.c | 84 +++++++++++++++++++--------------- src/libkshark-hash.c | 5 +- src/libkshark-model.c | 19 ++++---- src/libkshark-tepdata.c | 31 ++++++++----- src/libkshark.c | 17 +++---- src/libkshark.h | 20 ++++---- src/plugins/KVMComboDialog.cpp | 7 +-- src/plugins/sched_events.c | 2 +- tests/test-input.c | 4 +- tests/test-input_ctrl.c | 4 +- 32 files changed, 257 insertions(+), 270 deletions(-)create mode 100644 .gitignore
--
2.43.0
I have now tested and can confirm that the patches from Benjamin has fixed the problem I was seeing on Debian also. A new release will be better for me also, instead of adding all those patches to Debian package.
Thanks Benjamin for the fixes.
Signature · 2 lines
Regards Sudip
Quoted 131 lines · Sudip Mukherjee
Looking at these patches I think my issue should be fixed now. Let me try the latest HEAD tonight.
--
Regards
SudipQuoted 120 lines · Yordan Karadzhov
Hi Benjamin,
We still have one unresolved bug that was reported by Sudip. I will do my best to get this sorted out and have a new release by the end of next week.
Thanks,
Y.Quoted 109 lines · Benjamin ROBIN
Quoted 11 lines · Yordan Karadzhov
Hi Benjamin,
I am applying most of the patches from your patch-set. I have some minor comments about few of the changes that I will make in the individual patches.
Once again, thanks a lot for helping us to improve kernelshark!
Cheers,
YordanHi Yordan,
Do you think it is possible to create a new release since all the major bugs were resolved?
Indeed, the KernelShark version 2.3.0 is currently not usable, and this is this version that is provided in the Arch repository. The Arch maintainers would prefer a new release instead of applying a ton of patches.Thanks,
BenjaminQuoted 85 lines · Benjamin ROBIN
Quoted 84 lines
There were 3 majors issues:
- A segfault when loading a trace file (patch 0001)
- The trace table height was very small (patch 0032)
- The trace table columns width were reducing when clicking Marker A or B (patch 0032)Also fix most of the warnings reported by Clang-Tidy and Clazy, and by gcc with -Wextra.
Benjamin ROBIN (34):
kernelshark: FixmodelReset()signaling, rename update to updateGeom
kernelshark: Add .gitignore
kernelshark: Remove function param when not used, whenever possible
kernelshark: Do not create a temporary container for looping over QMap
kernelshark: Prevent potential detach of QMap container
kernelshark: Fix used after free of QByteArray raw data
kernelshark: Fix potential memory leak in KsGLWidget
kernelshark: Use lambda parameter instead of captured local variable
kernelshark: Keep overridden method protected instead of public
kernelshark: Usesliced()orfirst()instead of mid/right/left()
kernelshark: Prevent potential divide by zero inShape::center()
kernelshark: Fix potential access to uninitialized variable
kernelshark: Remove unused locals variables
kernelshark: Fix range-loop-reference Clazy warning
kernelshark: Fix moving a temp object prevents copy elision warning
kernelshark: Add receiver object toconnect()call
kernelshark: Return by reference the list of header in KsModels
kernelshark: Fix detaching-temporary Clazy warning
kernelshark: Fix qfileinfo-exists Clazy warning
kernelshark: Fix potential memory leaks in libkshark-configio
kernelshark: Fix potential access to uninitialized variable
kernelshark: Fix potential double free ofhisto->map,histo->bin_count
kernelshark: Fix 'const' type qualifier on return type has no effect
kernelshark: Fix potential memory leaks in libkshark-tepdata
kernelshark: Fix typo in comment ofKsGLWidget::resizeGL()
kernelshark: Remove unusedKsDataWidget::wipPtr()and broken function
kernelshark: InKsTimeOffsetDialog()constructor use parent param
kernelshark: Fixed loop counter incremented suspiciously twice
kernelshark: Fixtepdata_dump_entry()forevent_id=KS_EVENT_OVERFLOW
kernelshark: Usestatic_castinstead of C cast in KsMainWindow
kernelshark: Fix comparison of integers of different signs warnings
kernelshark: Fix KsTableView columns width, and KsTraceViewer size
kernelshark: Allow to reduce a bit more the graph height
kernelshark: Cleanup of KsDualMarker methods.gitignore | 15 ++++++ examples/configio.c | 3 +- examples/datafilter.c | 15 +++--- examples/datahisto.c | 2 +- src/KsAdvFilteringDialog.cpp | 24 ++++------ src/KsAdvFilteringDialog.hpp | 2 +- src/KsDualMarker.hpp | 10 +--- src/KsGLWidget.cpp | 48 +++++++++---------- src/KsGLWidget.hpp | 43 ++++++++--------- src/KsMainWindow.cpp | 8 ++-- src/KsModels.hpp | 11 +++-- src/KsPlotTools.cpp | 14 +++--- src/KsPlotTools.hpp | 2 +- src/KsSession.cpp | 4 +- src/KsTraceGraph.cpp | 7 ++- src/KsTraceViewer.cpp | 71 ++++++++-------------------- src/KsTraceViewer.hpp | 11 +++-- src/KsUtils.cpp | 9 ++-- src/KsUtils.hpp | 4 +- src/KsWidgetsLib.cpp | 2 +- src/KsWidgetsLib.hpp | 15 ++---- src/libkshark-collection.c | 14 +++--- src/libkshark-configio.c | 84 +++++++++++++++++++--------------- src/libkshark-hash.c | 5 +- src/libkshark-model.c | 19 ++++---- src/libkshark-tepdata.c | 31 ++++++++----- src/libkshark.c | 17 +++---- src/libkshark.h | 20 ++++---- src/plugins/KVMComboDialog.cpp | 7 +-- src/plugins/sched_events.c | 2 +- tests/test-input.c | 4 +- tests/test-input_ctrl.c | 4 +- 32 files changed, 257 insertions(+), 270 deletions(-)create mode 100644 .gitignore
--
2.43.0