summaryrefslogtreecommitdiff
path: root/src/sim/probe
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2015-09-25 13:25:34 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2015-09-25 13:25:34 -0400
commit9a0129dcbf3cc223c88b8c0bc46ac9b375c11abf (patch)
tree184f8bcb5f9ef6a1bc530608c00f7469a556e65f /src/sim/probe
parent806e1fbf0f63d386d4ae80ff0d4ab77e6c37f9d6 (diff)
downloadgem5-9a0129dcbf3cc223c88b8c0bc46ac9b375c11abf.tar.xz
mem: Add PacketInfo to be used for packet probe points
This patch fixes a use-after-delete issue in the packet probe points by adding a PacketInfo struct to retain the key fields before passing the packet onwards. We want to probe the packet after it is successfully sent, but by that time the fields may be modified, and the packet may even be deleted. Amazingly enough the issue has gone undetected for months, and only recently popped up in our regressions.
Diffstat (limited to 'src/sim/probe')
-rw-r--r--src/sim/probe/mem.hh20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/sim/probe/mem.hh b/src/sim/probe/mem.hh
index 506287140..2d4b9aeec 100644
--- a/src/sim/probe/mem.hh
+++ b/src/sim/probe/mem.hh
@@ -47,6 +47,24 @@
namespace ProbePoints {
/**
+ * A struct to hold on to the essential fields from a packet, so that
+ * the packet and underlying request can be safely passed on, and
+ * consequently modified or even deleted.
+ */
+struct PacketInfo {
+ MemCmd cmd;
+ Addr addr;
+ uint32_t size;
+ Request::FlagsType flags;
+
+ explicit PacketInfo(const PacketPtr& pkt) :
+ cmd(pkt->cmd),
+ addr(pkt->getAddr()),
+ size(pkt->getSize()),
+ flags(pkt->req->getFlags()) { }
+};
+
+/**
* Packet probe point
*
* This probe point provides a unified interface for components that
@@ -79,7 +97,7 @@ namespace ProbePoints {
* </ul>
*
*/
-typedef ProbePointArg< ::PacketPtr> Packet;
+typedef ProbePointArg<PacketInfo> Packet;
typedef std::unique_ptr<Packet> PacketUPtr;
}