Skip empty entries in memory and storage dump.

This commit is contained in:
chriseth
2019-05-23 12:27:56 +02:00
parent d707a26a90
commit 91312e657b
12 changed files with 28 additions and 126 deletions
+1 -3
View File
@@ -35,7 +35,5 @@ void yulFuzzerUtil::interpret(
state.maxMemSize = _maxMemory;
Interpreter interpreter(state, _dialect);
interpreter(*_ast);
_os << "Trace:" << endl;
for (auto const& line: interpreter.trace())
_os << " " << line << endl;
state.dumpTraceAndState(_os);
}
+21
View File
@@ -32,12 +32,33 @@
#include <libdevcore/FixedHash.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/algorithm/cxx11/all_of.hpp>
#include <ostream>
using namespace std;
using namespace dev;
using namespace yul;
using namespace yul::test;
void InterpreterState::dumpTraceAndState(ostream& _out) const
{
_out << "Trace:" << endl;
for (auto const& line: trace)
_out << " " << line << endl;
_out << "Memory dump:\n";
for (size_t i = 0; i < memory.size(); i += 0x20)
{
bytesConstRef data(memory.data() + i, 0x20);
if (boost::algorithm::all_of_equal(data, 0))
continue;
_out << " " << std::hex << std::setw(4) << i << ": " << toHex(data.toBytes()) << endl;
}
_out << "Storage dump:" << endl;
for (auto const& slot: storage)
if (slot.second != h256(0))
_out << " " << slot.first.hex() << ": " << slot.second.hex() << endl;
}
void Interpreter::operator()(ExpressionStatement const& _expressionStatement)
{
+2
View File
@@ -92,6 +92,8 @@ struct InterpreterState
size_t maxSteps = 0;
size_t numSteps = 0;
LoopState loopState = LoopState::Default;
void dumpTraceAndState(std::ostream& _out) const;
};
/**
+1 -9
View File
@@ -98,15 +98,7 @@ void interpret(string const& _source)
{
}
cout << "Trace:" << endl;
for (auto const& line: interpreter.trace())
cout << " " << line << endl;
cout << "Memory dump:" << endl;
for (size_t i = 0; i < state.memory.size(); i += 0x20)
cout << " " << std::hex << std::setw(4) << i << ": " << toHex(bytesConstRef(state.memory.data() + i, 0x20).toBytes()) << endl;
cout << "Storage dump:" << endl;
for (auto const& slot: state.storage)
cout << " " << slot.first.hex() << ": " << slot.second.hex() << endl;
state.dumpTraceAndState(cout);
}
}