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:
parent
d707a26a90
commit
91312e657b
@ -25,6 +25,8 @@ public:
|
||||
using mutable_value_type = typename std::conditional<std::is_const<_T>::value, typename std::remove_const<_T>::type, _T>::type;
|
||||
using string_type = typename std::conditional<std::is_const<_T>::value, std::string const, std::string>::type;
|
||||
using vector_type = typename std::conditional<std::is_const<_T>::value, std::vector<typename std::remove_const<_T>::type> const, std::vector<_T>>::type;
|
||||
using iterator = _T*;
|
||||
using const_iterator = _T const*;
|
||||
|
||||
static_assert(std::is_pod<value_type>::value, "vector_ref can only be used with PODs due to its low-level treatment of data.");
|
||||
|
||||
|
@ -142,15 +142,7 @@ string YulInterpreterTest::interpret()
|
||||
}
|
||||
|
||||
stringstream result;
|
||||
result << "Trace:" << endl;;
|
||||
for (auto const& line: interpreter.trace())
|
||||
result << " " << line << endl;
|
||||
result << "Memory dump:\n";
|
||||
for (size_t i = 0; i < state.memory.size(); i += 0x20)
|
||||
result << " " << std::hex << std::setw(4) << i << ": " << toHex(bytesConstRef(state.memory.data() + i, 0x20).toBytes()) << endl;
|
||||
result << "Storage dump:" << endl;
|
||||
for (auto const& slot: state.storage)
|
||||
result << " " << slot.first.hex() << ": " << slot.second.hex() << endl;
|
||||
state.dumpTraceAndState(result);
|
||||
return result.str();
|
||||
}
|
||||
|
||||
|
@ -17,98 +17,4 @@ object "main"
|
||||
// MLOAD_FROM_SIZE(32, 32)
|
||||
// SSTORE(1, 0)
|
||||
// Memory dump:
|
||||
// 0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 20: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 40: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 60: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 80: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// a0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// c0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// e0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 100: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 120: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 140: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 160: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 180: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 1a0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 1c0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 1e0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 200: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 220: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 240: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 260: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 280: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 2a0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 2c0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 2e0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 300: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 320: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 340: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 360: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 380: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 3a0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 3c0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 3e0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 400: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 420: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 440: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 460: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 480: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 4a0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 4c0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 4e0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 500: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 520: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 540: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 560: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 580: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 5a0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 5c0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 5e0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 600: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 620: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 640: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 660: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 680: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 6a0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 6c0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 6e0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 700: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 720: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 740: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 760: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 780: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 7a0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 7c0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 7e0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 800: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 820: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 840: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 860: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 880: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 8a0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 8c0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 8e0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 900: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 920: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 940: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 960: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 980: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 9a0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 9c0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 9e0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// a00: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// a20: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// a40: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// a60: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// a80: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// aa0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// ac0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// ae0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// b00: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// b20: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// b40: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// b60: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// Storage dump:
|
||||
// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 0000000000000000000000000000000000000000000000000000000000000001: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
|
@ -10,8 +10,5 @@
|
||||
// CALL(153, 69, 5, 0, 32, 48, 32)
|
||||
// SSTORE(100, 1)
|
||||
// Memory dump:
|
||||
// 0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 20: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 40: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// Storage dump:
|
||||
// 0000000000000000000000000000000000000000000000000000000000000064: 0000000000000000000000000000000000000000000000000000000000000001
|
||||
|
@ -14,7 +14,5 @@
|
||||
// MSTORE_AT_SIZE(40, 32) [0000000000000000000000000000000000000000000000000000000000008000]
|
||||
// MSTORE_AT_SIZE(45, 32) [0000000000000000000000000000000000000000000000000000000000009000]
|
||||
// Memory dump:
|
||||
// 0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 20: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 40: 0000000000000000000000900000000000000000000000000000000000000000
|
||||
// Storage dump:
|
||||
|
@ -30,8 +30,4 @@
|
||||
// SSTORE(0, 0)
|
||||
// Memory dump:
|
||||
// 0: 0001000000000000000000000000000000000000000000000000000000000000
|
||||
// 20: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 40: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 60: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// Storage dump:
|
||||
// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
|
@ -5,6 +5,5 @@
|
||||
// Trace:
|
||||
// MSTORE_AT_SIZE(10, 32) [000000000000000000000000000000000000000000000000000000000000000b]
|
||||
// Memory dump:
|
||||
// 0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 20: 0000000000000000000b00000000000000000000000000000000000000000000
|
||||
// Storage dump:
|
||||
|
@ -8,6 +8,5 @@
|
||||
// Trace:
|
||||
// MSTORE_AT_SIZE(1, 32) [0000000000000000000000000000000000000000000000000000000000000002]
|
||||
// Memory dump:
|
||||
// 0: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
// 20: 0200000000000000000000000000000000000000000000000000000000000000
|
||||
// Storage dump:
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user