# HG changeset patch
# User Brad Beckmann <[email protected]>
# Date 1263536247 28800
# Node ID 99684e867755307c35e3c61801a49352e2034e31
# Parent d1afc64b72dfd2451c0f1acf0addc7ac8aebd8e1
ruby: RubyTester senderState management fix
Fixed how ruby manages the sender state when utilizing the ruby tester.
diff -r d1afc64b72df -r 99684e867755 src/cpu/rubytest/Check.cc
--- a/src/cpu/rubytest/Check.cc Thu Jan 14 22:17:27 2010 -0800
+++ b/src/cpu/rubytest/Check.cc Thu Jan 14 22:17:27 2010 -0800
@@ -115,7 +115,9 @@
// push the subblock onto the sender state. The sequencer will update the
// subblock on the return
//
- pkt->senderState = new RubyTester::SenderState(m_address, req->getSize());
+ pkt->senderState = new RubyTester::SenderState(m_address,
+ req->getSize(),
+ pkt->senderState);
if (port->sendTiming(pkt)) {
DPRINTF(RubyTest, "successfully initiated prefetch.\n");
@@ -123,9 +125,13 @@
//
// If the packet did not issue, must delete
//
- delete pkt->senderState;
+ RubyTester::SenderState* senderState =
+ safe_cast<RubyTester::SenderState*>(pkt->senderState);
+ pkt->senderState = senderState->saved;
+ delete senderState;
delete pkt->req;
delete pkt;
+
DPRINTF(RubyTest, "prefetch initiation failed because Port was busy.\n");
}
}
@@ -180,7 +186,9 @@
// push the subblock onto the sender state. The sequencer will update the
// subblock on the return
//
- pkt->senderState = new RubyTester::SenderState(writeAddr, req->getSize());
+ pkt->senderState = new RubyTester::SenderState(writeAddr,
+ req->getSize(),
+ pkt->senderState);
if (port->sendTiming(pkt)) {
DPRINTF(RubyTest, "initiating action - successful\n");
@@ -193,9 +201,13 @@
// If the packet did not issue, must delete
// Note: No need to delete the data, the packet destructor will delete it
//
- delete pkt->senderState;
+ RubyTester::SenderState* senderState =
+ safe_cast<RubyTester::SenderState*>(pkt->senderState);
+ pkt->senderState = senderState->saved;
+ delete senderState;
delete pkt->req;
delete pkt;
+
DPRINTF(RubyTest, "failed to initiate action - sequencer not ready\n");
}
@@ -239,7 +251,9 @@
// push the subblock onto the sender state. The sequencer will update the
// subblock on the return
//
- pkt->senderState = new RubyTester::SenderState(m_address, req->getSize());
+ pkt->senderState = new RubyTester::SenderState(m_address,
+ req->getSize(),
+ pkt->senderState);
if (port->sendTiming(pkt)) {
DPRINTF(RubyTest, "initiating check - successful\n");
@@ -252,9 +266,13 @@
// If the packet did not issue, must delete
// Note: No need to delete the data, the packet destructor will delete it
//
- delete pkt->senderState;
+ RubyTester::SenderState* senderState =
+ safe_cast<RubyTester::SenderState*>(pkt->senderState);
+ pkt->senderState = senderState->saved;
+ delete senderState;
delete pkt->req;
delete pkt;
+
DPRINTF(RubyTest, "failed to initiate check - cpu port not ready\n");
}
diff -r d1afc64b72df -r 99684e867755 src/cpu/rubytest/RubyTester.cc
--- a/src/cpu/rubytest/RubyTester.cc Thu Jan 14 22:17:27 2010 -0800
+++ b/src/cpu/rubytest/RubyTester.cc Thu Jan 14 22:17:27 2010 -0800
@@ -107,20 +107,20 @@
// retrieve the subblock and call hitCallback
//
RubyTester::SenderState* senderState =
- static_cast<RubyTester::SenderState*>(pkt->senderState);
+ safe_cast<RubyTester::SenderState*>(pkt->senderState);
SubBlock* subblock = senderState->subBlock;
assert(subblock != NULL);
// pop the sender state from the packet
pkt->senderState = senderState->saved;
- delete senderState;
tester->hitCallback(idx, subblock);
//
- // Now that the tester has completed, delete the sublock, packet and return
+ // Now that the tester has completed, delete the senderState
+ // (includes sublock) and the packet, then return
//
- delete subblock;
+ delete senderState;
delete pkt->req;
delete pkt;
return true;
diff -r d1afc64b72df -r 99684e867755 src/cpu/rubytest/RubyTester.hh
--- a/src/cpu/rubytest/RubyTester.hh Thu Jan 14 22:17:27 2010 -0800
+++ b/src/cpu/rubytest/RubyTester.hh Thu Jan 14 22:17:27 2010 -0800
@@ -76,6 +76,8 @@
Packet::SenderState *sender_state = NULL)
: saved(sender_state)
{subBlock = new SubBlock(addr, size);}
+
+ ~SenderState() {delete subBlock;}
};
typedef RubyTesterParams Params;
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev