diff options
author | Yordan Karadzhov <ykaradzhov@vmware.com> | 2019-05-15 12:09:11 -0700 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-05-21 10:00:12 -0400 |
commit | 9417d1cd55abd027723675784aacb50f59c2b864 (patch) | |
tree | da6c96a060974f43e5554ff04b2ef31d47817953 | |
parent | 8384febecd15060d8ffd81061b87c2c614bba2f9 (diff) | |
download | trace-cmd-9417d1cd55abd027723675784aacb50f59c2b864.tar.gz |
kernel-shark: Handle the case when the marker points to a filtered entry
Markers can point to entries that are filtered out. In such a case
the filtered marker is plotted using a dashed line.
Link: http://lore.kernel.org/linux-trace-devel/20190515190911.20755-7-ykaradzhov@vmware.com
Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r-- | kernel-shark/src/KsDualMarker.cpp | 10 | ||||
-rw-r--r-- | kernel-shark/src/KsPlotTools.cpp | 33 | ||||
-rw-r--r-- | kernel-shark/src/KsPlotTools.hpp | 11 | ||||
-rw-r--r-- | kernel-shark/src/KsTraceViewer.cpp | 22 |
4 files changed, 65 insertions, 11 deletions
diff --git a/kernel-shark/src/KsDualMarker.cpp b/kernel-shark/src/KsDualMarker.cpp index 5dcbaaea..755e2460 100644 --- a/kernel-shark/src/KsDualMarker.cpp +++ b/kernel-shark/src/KsDualMarker.cpp @@ -79,9 +79,19 @@ bool KsGraphMark::set(const KsDataStore &data, kshark_trace_histo *histo, size_t pos, int cpuGraph, int taskGraph) { + uint8_t visFlags; + _isSet = true; _pos = pos; _ts = data.rows()[_pos]->ts; + visFlags = data.rows()[_pos]->visible; + + if ((visFlags & KS_TEXT_VIEW_FILTER_MASK) && + (visFlags & KS_GRAPH_VIEW_FILTER_MASK)) + _mark.setDashed(false); + else + _mark.setDashed(true); + _cpu = cpuGraph; _task = taskGraph; diff --git a/kernel-shark/src/KsPlotTools.cpp b/kernel-shark/src/KsPlotTools.cpp index f95ada5a..a8eddcda 100644 --- a/kernel-shark/src/KsPlotTools.cpp +++ b/kernel-shark/src/KsPlotTools.cpp @@ -379,6 +379,32 @@ void drawLine(const Point &a, const Point &b, size); } +/** + * @brief Draw a dashed line between point "a" and point "b". + * + * @param a: The first finishing point of the line. + * @param b: The second finishing point of the line. + * @param col: The color of the line. + * @param size: The size of the line. + * @param period: The period of the dashed line. + */ +void drawDashedLine(const Point &a, const Point &b, + const Color &col, float size, float period) +{ + int dx = b.x() - a.x(), dy = b.y() - a.y(); + float mod = sqrt(dx * dx + dy * dy); + int n = mod / period; + Point p1, p2; + + for (int i = 0; i < n; ++i) { + p1.setX(a.x() + (i + .25) * dx / n); + p1.setY(a.y() + (i + .25) * dy / n); + p2.setX(a.x() + (i + .75) * dx / n); + p2.setY(a.y() + (i + .75) * dy / n); + drawLine(p1, p2, col, size); + } +} + /** @brief Create a default line. The two points are initialized at (0, 0). */ Line::Line() : Shape(2) @@ -430,6 +456,7 @@ void Polygon::_draw(const Color &col, float size) const * @brief Create a default Mark. */ Mark::Mark() +: _dashed(false) { _visible = false; _cpu._color = Color(225, 255, 100); @@ -440,7 +467,11 @@ Mark::Mark() void Mark::_draw(const Color &col, float size) const { - drawLine(_a, _b, col, size); + if (_dashed) + drawDashedLine(_a, _b, col, size, 3 * _cpu._size / size); + else + drawLine(_a, _b, col, size); + _cpu.draw(); _task.draw(); } diff --git a/kernel-shark/src/KsPlotTools.hpp b/kernel-shark/src/KsPlotTools.hpp index 11c49eb4..ee447f1c 100644 --- a/kernel-shark/src/KsPlotTools.hpp +++ b/kernel-shark/src/KsPlotTools.hpp @@ -204,7 +204,10 @@ private: }; void drawLine(const Point &a, const Point &b, - const Color &col, float s); + const Color &col, float size); + +void drawDashedLine(const Point &a, const Point &b, + const Color &col, float size, float period); /** This class represents a straight line. */ class Line : public Shape { @@ -326,6 +329,9 @@ public: void setTaskVisible(bool v); + /** If True, the Mark will be plotted as a dashed line. */ + void setDashed(bool d) {_dashed = d;} + private: void _draw(const Color &col, float size = 1.) const override; @@ -340,6 +346,9 @@ private: /** A point indicating the position of the Mark in a Task graph. */ Point _task; + + /* If True, plot the Mark as a dashed line. */ + bool _dashed; }; /** This class represents a KernelShark graph's bin. */ diff --git a/kernel-shark/src/KsTraceViewer.cpp b/kernel-shark/src/KsTraceViewer.cpp index 04a38b81..05977c3d 100644 --- a/kernel-shark/src/KsTraceViewer.cpp +++ b/kernel-shark/src/KsTraceViewer.cpp @@ -493,15 +493,19 @@ void KsTraceViewer::markSwitch() QModelIndex index = _proxyModel.mapFromSource(_model.index(row, 0)); - /* - * The row of the active marker will be colored according to - * the assigned property of the current state of the Dual - * marker. Auto-scrolling is temporarily disabled because we - * do not want to scroll to the position of the marker yet. - */ - _view.setAutoScroll(false); - _view.selectRow(index.row()); - _view.setAutoScroll(true); + if (index.isValid()) { + /* + * The row of the active marker will be colored according to + * the assigned property of the current state of the Dual + * marker. Auto-scrolling is temporarily disabled because we + * do not want to scroll to the position of the marker yet. + */ + _view.setAutoScroll(false); + _view.selectRow(index.row()); + _view.setAutoScroll(true); + } else { + _view.clearSelection(); + } } else { _view.clearSelection(); } |