diff options
author | Yordan Karadzhov (VMware) <y.karadz@gmail.com> | 2020-12-09 15:45:29 +0200 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2020-12-22 10:54:48 -0500 |
commit | edef93522ef70d1261664199c169da3cebcc1890 (patch) | |
tree | f1912b3d90b74f7821a98041af641bcefe5e6693 | |
parent | 737c50f0b4d9764a3e6a246b33b5dc40700f35a7 (diff) | |
download | kernel-shark-edef93522ef70d1261664199c169da3cebcc1890.tar.gz |
kernel-shark: Add VirtBridge and VirtGap classes
The two simple plotting classes will be used to visualise the
guest->host data correlations.
Link: https://lore.kernel.org/linux-trace-devel/20201209134530.428368-10-y.karadz@gmail.com
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r-- | src/KsPlotTools.cpp | 22 | ||||
-rw-r--r-- | src/KsPlotTools.hpp | 47 |
2 files changed, 69 insertions, 0 deletions
diff --git a/src/KsPlotTools.cpp b/src/KsPlotTools.cpp index 9f983864..8d380094 100644 --- a/src/KsPlotTools.cpp +++ b/src/KsPlotTools.cpp @@ -1460,4 +1460,26 @@ void Graph::draw(float size) } } +void VirtGap::_draw(const Color &col, float size) const +{ + if (_entryPoint.x() - _exitPoint.x() < 4) + return; + + Point p0(_exitPoint.x() + _size, _exitPoint.y()); + Point p1(_exitPoint.x() + _size, _exitPoint.y() - _height); + Point p2(_entryPoint.x() - _size , _entryPoint.y()); + Point p3(_entryPoint.x() - _size , _entryPoint.y() - _height); + + Rectangle g; + + g.setPoint(0, p0); + g.setPoint(1, p1); + g.setPoint(2, p2); + g.setPoint(3, p3); + + g._color = {255, 255, 255}; // The virt. gap is always white. + g.setFill(false); + g.draw(); +} + } // KsPlot diff --git a/src/KsPlotTools.hpp b/src/KsPlotTools.hpp index 4a7ca0a6..b9b93f37 100644 --- a/src/KsPlotTools.hpp +++ b/src/KsPlotTools.hpp @@ -578,6 +578,53 @@ private: int _firstBinOffset(); }; +/** + * This class represents the graphical element visualizing how the execution + * goes from the host to the guest and back. + */ +class VirtBridge : public Polyline { +public: + /** Create a default VirtBridge. */ + VirtBridge() : Polyline(4) {} + + /* Keep this destructor virtual. */ + virtual ~VirtBridge() {} + + /** Set the coordinates of the EntryHost point of the VirtBridge. */ + void setEntryHost(int x, int y) {setPoint(0, x, y);} + + /** Set the coordinates of the EntryGuest point of the VirtBridge. */ + void setEntryGuest(int x, int y) {setPoint(1, x, y);} + + /** Set the coordinates of the ExitGuest point of the VirtBridge. */ + void setExitGuest(int x, int y) {setPoint(2, x, y);} + + /** Set the coordinates of the ExitHost point of the VirtBridge. */ + void setExitHost(int x, int y) {setPoint(3, x, y);} +}; + +/** + * This class represents the graphical element visualizing the time interval + * in the guest during which the execution has been returned to the host. + */ +class VirtGap : public Shape { +public: + /** Create a VirtGap with height "h". */ + VirtGap(int h) :_height(h) {} + + /** The point where the execution exits the VM. */ + Point _exitPoint; + + /** The point where the execution enters the VM. */ + Point _entryPoint; + +private: + /** The vertical size (height) of the graphical element. */ + int _height; + + void _draw(const Color &col, float size) const; +}; + }; // KsPlot #endif /* _KS_PLOT_TOOLS_H */ |