Adding source location support to AssemblyStack and thus debugging Yul sources

This commit is contained in:
Djordje Mijovic
2020-02-25 22:19:03 +01:00
committed by chriseth
parent 44bcff42f5
commit ec083c4878
29 changed files with 136 additions and 101 deletions
+3
View File
@@ -74,6 +74,7 @@ TestCase::TestResult ObjectCompilerTest::run(ostream& _stream, string const& _li
MachineAssemblyObject obj = stack.assemble(AssemblyStack::Machine::EVM);
solAssert(obj.bytecode, "");
solAssert(obj.sourceMappings, "");
m_obtainedResult = "Assembly:\n" + obj.assembly;
if (obj.bytecode->bytecode.empty())
@@ -84,6 +85,8 @@ TestCase::TestResult ObjectCompilerTest::run(ostream& _stream, string const& _li
toHex(obj.bytecode->bytecode) +
"\nOpcodes: " +
boost::trim_copy(evmasm::disassemble(obj.bytecode->bytecode)) +
"\nSourceMappings:" +
(obj.sourceMappings->empty() ? "" : " " + *obj.sourceMappings) +
"\n";
if (m_expectation != m_obtainedResult)
+1
View File
@@ -9,3 +9,4 @@ object "a" {
// data_acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f 48656c6c6f2c20576f726c6421
// Bytecode: fe
// Opcodes: INVALID
// SourceMappings:
+1
View File
@@ -46,3 +46,4 @@ object "a" {
// }
// Bytecode: 600b600d600039600b6000f3fe6000600055600d600052fe
// Opcodes: PUSH1 0xB PUSH1 0xD PUSH1 0x0 CODECOPY PUSH1 0xB PUSH1 0x0 RETURN INVALID PUSH1 0x0 PUSH1 0x0 SSTORE PUSH1 0xD PUSH1 0x0 MSTORE INVALID
// SourceMappings: 26:47:0:-:0;;35:1;26:47;78:26;85:1;78:26
@@ -27,3 +27,4 @@ object "a" {
// }
// Bytecode: 6006600055fe6008600055fe
// Opcodes: PUSH1 0x6 PUSH1 0x0 SSTORE INVALID PUSH1 0x8 PUSH1 0x0 SSTORE INVALID
// SourceMappings: 22:28:0:-:0;29:1;22:28
@@ -14,3 +14,4 @@ object "a" {
// data_acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f 48656c6c6f2c20576f726c6421
// Bytecode: 6006600055fe48656c6c6f2c20576f726c6421
// Opcodes: PUSH1 0x6 PUSH1 0x0 SSTORE INVALID 0x48 PUSH6 0x6C6C6F2C2057 PUSH16 0x726C6421000000000000000000000000
// SourceMappings: 22:30:0:-:0;29:1;22:30
@@ -14,3 +14,4 @@ object "a" {
// data_acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f 48656c6c6f2c20576f726c6421
// Bytecode: 6000600055fe
// Opcodes: PUSH1 0x0 PUSH1 0x0 SSTORE INVALID
// SourceMappings: 22:26:0:-:0;29:1;22:26
@@ -27,3 +27,4 @@ object "a" {
// }
// Bytecode: 6006600055fe
// Opcodes: PUSH1 0x6 PUSH1 0x0 SSTORE INVALID
// SourceMappings: 22:26:0:-:0;29:1;22:26
@@ -14,3 +14,4 @@ object "a" {
// data_acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f 48656c6c6f2c20576f726c6421
// Bytecode: 600d600055fe
// Opcodes: PUSH1 0xD PUSH1 0x0 SSTORE INVALID
// SourceMappings: 22:28:0:-:0;29:1;22:28
@@ -14,3 +14,4 @@ object "a" {
// data_acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f 48656c6c6f2c20576f726c6421
// Bytecode: 6006600055fe
// Opcodes: PUSH1 0x6 PUSH1 0x0 SSTORE INVALID
// SourceMappings: 22:24:0:-:0;29:1;22:24
@@ -28,3 +28,4 @@ object "Contract" {
// sstore
// Bytecode: 6009565b5b565b5b565b6001600055
// Opcodes: PUSH1 0x9 JUMP JUMPDEST JUMPDEST JUMP JUMPDEST JUMPDEST JUMP JUMPDEST PUSH1 0x1 PUSH1 0x0 SSTORE
// SourceMappings: 33:15:0:-:0;;;46:2;;53:15;66:2;;;83:1;80;73:12
@@ -11,3 +11,4 @@ object "a" {
// sstore
// Bytecode: 6001600055
// Opcodes: PUSH1 0x1 PUSH1 0x0 SSTORE
// SourceMappings: 32:1:0:-:0;29;22:12
@@ -38,3 +38,4 @@ object "a" {
// }
// Bytecode: 600060003555fe
// Opcodes: PUSH1 0x0 PUSH1 0x0 CALLDATALOAD SSTORE INVALID
// SourceMappings: 48:1:0:-:0;;35:15;107:20
+1
View File
@@ -11,3 +11,4 @@
// sstore
// Bytecode: 6001600055
// Opcodes: PUSH1 0x1 PUSH1 0x0 SSTORE
// SourceMappings: 14:1:0:-:0;11;4:12
@@ -17,3 +17,4 @@
// sstore
// Bytecode: 600060003555
// Opcodes: PUSH1 0x0 PUSH1 0x0 CALLDATALOAD SSTORE
// SourceMappings: 26:1:0:-:0;;13:15;79:20
+1
View File
@@ -19,3 +19,4 @@ object "a" {
// }
// Bytecode: fe
// Opcodes: INVALID
// SourceMappings:
@@ -37,3 +37,4 @@ object "a" {
// }
// Bytecode: fe
// Opcodes: INVALID
// SourceMappings: