aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Jentzsch <jentzsch.software@gmail.com>2014-10-28 19:11:52 +0800
committerChristoph Jentzsch <jentzsch.software@gmail.com>2014-10-28 19:11:52 +0800
commit01e9cf0cadecdf0c452d2363a394fe8254c89fc0 (patch)
treea725d309468cb25cdc6e893206740db1202f6609
parent6b4d35259aa52e05468df69bcf74f0005afeb97f (diff)
downloaddexon-solidity-01e9cf0cadecdf0c452d2363a394fe8254c89fc0.tar.gz
dexon-solidity-01e9cf0cadecdf0c452d2363a394fe8254c89fc0.tar.zst
dexon-solidity-01e9cf0cadecdf0c452d2363a394fe8254c89fc0.zip
Fixed storage output in VMTRACE for vm tests
-rw-r--r--vm.cpp37
-rw-r--r--vm.h29
2 files changed, 35 insertions, 31 deletions
diff --git a/vm.cpp b/vm.cpp
index 40a0a862..e6c82349 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -130,7 +130,7 @@ bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data,
m_ms.internal.resize(m_ms.internal.size() + 1);
- auto ret = m_s.call(_receiveAddress,_codeAddressOverride ? _codeAddressOverride : _receiveAddress, _myAddressOverride ? _myAddressOverride : myAddress, _value, gasPrice, _data, _gas, _out, origin, &sub, &(m_ms.internal.back()), simpleTrace<ExtVM>(), 1);
+ auto ret = m_s.call(_receiveAddress,_codeAddressOverride ? _codeAddressOverride : _receiveAddress, _myAddressOverride ? _myAddressOverride : myAddress, _value, gasPrice, _data, _gas, _out, origin, &sub, &(m_ms.internal.back()), Executive::simpleTrace(), 1);
if (!m_ms.internal.back().from)
m_ms.internal.pop_back();
@@ -421,6 +421,39 @@ void FakeExtVM::importCallCreates(mArray& _callcreates)
}
}
+eth::OnOpFunc FakeExtVM::simpleTrace()
+{
+ return [](uint64_t steps, eth::Instruction inst, bigint newMemSize, bigint gasCost, void* voidVM, void const* voidExt)
+ {
+ FakeExtVM const& ext = *(FakeExtVM const*)voidExt;
+ eth::VM& vm = *(eth::VM*)voidVM;
+
+ std::ostringstream o;
+ o << std::endl << " STACK" << std::endl;
+ for (auto i: vm.stack())
+ o << (h256)i << std::endl;
+ o << " MEMORY" << std::endl << memDump(vm.memory());
+ o << " STORAGE" << std::endl;
+
+ for (auto const& i: ext.state().storage(ext.myAddress))
+ o << std::showbase << std::hex << i.first << ": " << i.second << std::endl;
+
+ for (auto const& i: std::get<2>(ext.addresses.find(ext.myAddress)->second))
+ o << std::showbase << std::hex << i.first << ": " << i.second << std::endl;
+
+ dev::LogOutputStream<eth::VMTraceChannel, false>(true) << o.str();
+ dev::LogOutputStream<eth::VMTraceChannel, false>(false) << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << std::dec << vm.gas() << " | -" << std::dec << gasCost << " | " << newMemSize << "x32" << " ]";
+
+ if (eth::VMTraceChannel::verbosity <= g_logVerbosity)
+ {
+ std::ofstream f;
+ f.open("./vmtrace.log", std::ofstream::app);
+ f << o.str();
+ f << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << std::dec << vm.gas() << " | -" << std::dec << gasCost << " | " << newMemSize << "x32";
+ }
+ };
+}
+
// THIS IS BROKEN AND NEEDS TO BE REMOVED.
h160 FakeState::createNewAddress(Address _newAddress, Address _sender, u256 _endowment, u256 _gasPrice, u256* _gas, bytesConstRef _code, Address _origin, SubState* o_sub, Manifest* o_ms, OnOpFunc const& _onOp, unsigned _level)
{
@@ -517,7 +550,7 @@ void doTests(json_spirit::mValue& v, bool _fillin)
VM vm(fev.gas);
try
{
- output = vm.go(fev, fev.simpleTrace<FakeExtVM>()).toVector();
+ output = vm.go(fev, fev.simpleTrace()).toVector();
}
catch (Exception const& _e)
{
diff --git a/vm.h b/vm.h
index f3aae694..ddc6ddb3 100644
--- a/vm.h
+++ b/vm.h
@@ -81,9 +81,7 @@ public:
json_spirit::mArray exportCallCreates();
void importCallCreates(json_spirit::mArray& _callcreates);
- template<typename ExtVMType>
eth::OnOpFunc simpleTrace();
-
FakeState state() const { return m_s; }
std::map<Address, std::tuple<u256, u256, std::map<u256, u256>, bytes>> addresses;
@@ -97,32 +95,5 @@ private:
eth::Manifest m_ms;
};
-template<typename ExtVMType>
-eth::OnOpFunc FakeExtVM::simpleTrace()
-{
- return [](uint64_t steps, eth::Instruction inst, bigint newMemSize, bigint gasCost, void* voidVM, void const* voidExt)
- {
- ExtVMType const& ext = *(ExtVMType const*)voidExt;
- eth::VM& vm = *(eth::VM*)voidVM;
-
- std::ostringstream o;
- o << std::endl << " STACK" << std::endl;
- for (auto i: vm.stack())
- o << (h256)i << std::endl;
- o << " MEMORY" << std::endl << memDump(vm.memory());
- o << " STORAGE" << std::endl;
- for (auto const& i: ext.state().storage(ext.myAddress))
- o << std::showbase << std::hex << i.first << ": " << i.second << std::endl;
- dev::LogOutputStream<eth::VMTraceChannel, false>(true) << o.str();
- dev::LogOutputStream<eth::VMTraceChannel, false>(false) << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << std::dec << vm.gas() << " | -" << std::dec << gasCost << " | " << newMemSize << "x32" << " ]";
- if (eth::VMTraceChannel::verbosity <= g_logVerbosity)
- {
- std::ofstream f;
- f.open("./vmtrace.log", std::ofstream::app);
- f << o.str();
- f << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << std::dec << vm.gas() << " | -" << std::dec << gasCost << " | " << newMemSize << "x32";
- }
- };
-}
} } // Namespace Close