mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Skip empty entries in memory and storage dump.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -92,6 +92,8 @@ struct InterpreterState
|
||||
size_t maxSteps = 0;
|
||||
size_t numSteps = 0;
|
||||
LoopState loopState = LoopState::Default;
|
||||
|
||||
void dumpTraceAndState(std::ostream& _out) const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user