From f3705de1740737f31715ad7758ac4d47b9f5c4f2 Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Tue, 27 Aug 2024 12:59:56 +0200 Subject: [PATCH] Ethdebug instructions and source ranges. --- Changelog.md | 1 + libevmasm/Assembly.cpp | 147 +++++++++---- libevmasm/CMakeLists.txt | 2 + libevmasm/Ethdebug.cpp | 115 +++++++++++ libevmasm/Ethdebug.h | 35 ++++ libevmasm/LinkerObject.h | 31 +++ libsolidity/interface/CompilerStack.cpp | 18 +- libsolidity/interface/StandardCompiler.cpp | 16 +- libyul/YulStack.cpp | 17 +- libyul/YulStack.h | 3 - solc/CommandLineInterface.cpp | 26 +-- test/cmdlineTests.sh | 21 ++ .../debug_info_ethdebug_compatible/args | 1 - .../debug_info_ethdebug_compatible/input.sol | 7 - .../debug_info_ethdebug_compatible/output | 193 ------------------ .../debug_info_ethdebug_incompatible/args | 1 - .../debug_info_ethdebug_incompatible/err | 1 - .../ethdebug_and_ethdebug_runtime_ir/args | 1 - .../input.sol | 7 - .../ethdebug_and_ethdebug_runtime_ir/output | 123 ----------- .../args | 1 - .../input.sol | 7 - .../output | 79 ------- .../ethdebug_enabled_optimization_ir/args | 1 - .../ethdebug_enabled_optimization_ir/err | 1 - .../ethdebug_enabled_optimization_ir/exit | 1 - .../input.sol | 7 - .../args | 1 - .../err | 1 - .../exit | 1 - .../input.sol | 7 - .../ethdebug_eof_container_osaka/args | 1 + .../ethdebug_eof_container_osaka/err | 1 + .../exit | 0 .../input.sol | 1 - .../ethdebug_eof_container_osaka/output | 4 + test/cmdlineTests/ethdebug_ir/args | 1 - test/cmdlineTests/ethdebug_ir/input.sol | 7 - test/cmdlineTests/ethdebug_ir/output | 121 ----------- test/cmdlineTests/ethdebug_iroptimized/args | 1 - .../ethdebug_iroptimized/input.sol | 7 - test/cmdlineTests/ethdebug_iroptimized/output | 77 ------- test/cmdlineTests/ethdebug_no_via_ir/args | 1 - test/cmdlineTests/ethdebug_no_via_ir/err | 1 - test/cmdlineTests/ethdebug_no_via_ir/exit | 1 - .../cmdlineTests/ethdebug_no_via_ir/input.sol | 7 - test/cmdlineTests/ethdebug_runtime_ir/args | 1 - .../ethdebug_runtime_ir/input.sol | 7 - test/cmdlineTests/ethdebug_runtime_ir/output | 121 ----------- .../ethdebug_runtime_iroptimized/args | 1 - .../ethdebug_runtime_iroptimized/input.sol | 7 - .../ethdebug_runtime_iroptimized/output | 77 ------- .../output.json | 23 +-- .../strip-ethdebug | 0 .../output.json | 23 +-- .../strip-ethdebug | 0 .../output.json | 23 +-- .../strip-ethdebug | 0 .../output.json | 15 +- .../strip-ethdebug | 0 .../output.json | 15 +- .../strip-ethdebug | 0 .../output.json | 15 +- .../strip-ethdebug | 0 .../output.json | 15 +- .../strip-ethdebug | 0 .../output.json | 15 +- .../strip-ethdebug | 0 .../output.json | 15 +- .../strip-ethdebug | 0 .../output.json | 10 +- .../strip-ethdebug | 0 .../args | 1 + .../in.yul | 11 + .../input.json | 16 ++ .../output.json | 13 ++ .../args | 1 + .../in.yul | 7 + .../input.json | 11 + .../output.json | 127 ++++++++++++ .../output.json | 10 +- .../strip-ethdebug | 0 .../output.json | 10 +- .../strip-ethdebug | 0 .../in.yul | 22 +- .../output.json | 19 +- .../strip-ethdebug | 0 .../args | 1 + .../in.yul | 19 ++ .../input.json | 11 + .../output.json | 17 ++ .../strip-ethdebug | 0 .../standard_yul_ethdebug_ir/output.json | 10 +- .../standard_yul_ethdebug_ir/strip-ethdebug | 0 .../output.json | 10 +- .../strip-ethdebug | 0 test/cmdlineTests/yul_ethdebug/args | 1 - test/cmdlineTests/yul_ethdebug/input.yul | 18 -- test/cmdlineTests/yul_ethdebug/output | 7 - test/cmdlineTests/yul_ethdebug_ir/args | 1 - test/cmdlineTests/yul_ethdebug_ir/err | 1 - test/cmdlineTests/yul_ethdebug_ir/exit | 1 - test/cmdlineTests/yul_ethdebug_ir/input.yul | 18 -- .../yul_ethdebug_iroptimized/args | 1 - .../yul_ethdebug_iroptimized/input.yul | 18 -- .../yul_ethdebug_iroptimized/output | 26 --- test/cmdlineTests/yul_ethdebug_optimize/args | 1 - test/cmdlineTests/yul_ethdebug_optimize/err | 1 - test/cmdlineTests/yul_ethdebug_optimize/exit | 1 - .../yul_ethdebug_optimize/input.yul | 18 -- .../yul_ethdebug_optimize_iroptimized/args | 1 - .../yul_ethdebug_optimize_iroptimized/err | 1 - .../yul_ethdebug_optimize_iroptimized/exit | 1 - .../input.yul | 18 -- test/cmdlineTests/yul_ethdebug_runtime/args | 1 - test/cmdlineTests/yul_ethdebug_runtime/err | 1 - test/cmdlineTests/yul_ethdebug_runtime/exit | 1 - .../yul_ethdebug_runtime/input.yul | 18 -- test/libevmasm/Assembler.cpp | 41 ++++ test/libsolidity/StandardCompiler.cpp | 41 ++++ 120 files changed, 747 insertions(+), 1293 deletions(-) create mode 100644 libevmasm/Ethdebug.cpp create mode 100644 libevmasm/Ethdebug.h delete mode 100644 test/cmdlineTests/debug_info_ethdebug_compatible/args delete mode 100644 test/cmdlineTests/debug_info_ethdebug_compatible/input.sol delete mode 100644 test/cmdlineTests/debug_info_ethdebug_compatible/output delete mode 100644 test/cmdlineTests/debug_info_ethdebug_incompatible/args delete mode 100644 test/cmdlineTests/debug_info_ethdebug_incompatible/err delete mode 100644 test/cmdlineTests/ethdebug_and_ethdebug_runtime_ir/args delete mode 100644 test/cmdlineTests/ethdebug_and_ethdebug_runtime_ir/input.sol delete mode 100644 test/cmdlineTests/ethdebug_and_ethdebug_runtime_ir/output delete mode 100644 test/cmdlineTests/ethdebug_and_ethdebug_runtime_iroptimized/args delete mode 100644 test/cmdlineTests/ethdebug_and_ethdebug_runtime_iroptimized/input.sol delete mode 100644 test/cmdlineTests/ethdebug_and_ethdebug_runtime_iroptimized/output delete mode 100644 test/cmdlineTests/ethdebug_enabled_optimization_ir/args delete mode 100644 test/cmdlineTests/ethdebug_enabled_optimization_ir/err delete mode 100644 test/cmdlineTests/ethdebug_enabled_optimization_ir/exit delete mode 100644 test/cmdlineTests/ethdebug_enabled_optimization_ir/input.sol delete mode 100644 test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/args delete mode 100644 test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/err delete mode 100644 test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/exit delete mode 100644 test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/input.sol create mode 100644 test/cmdlineTests/ethdebug_eof_container_osaka/args create mode 100644 test/cmdlineTests/ethdebug_eof_container_osaka/err rename test/cmdlineTests/{debug_info_ethdebug_incompatible => ethdebug_eof_container_osaka}/exit (100%) rename test/cmdlineTests/{debug_info_ethdebug_incompatible => ethdebug_eof_container_osaka}/input.sol (99%) create mode 100644 test/cmdlineTests/ethdebug_eof_container_osaka/output delete mode 100644 test/cmdlineTests/ethdebug_ir/args delete mode 100644 test/cmdlineTests/ethdebug_ir/input.sol delete mode 100644 test/cmdlineTests/ethdebug_ir/output delete mode 100644 test/cmdlineTests/ethdebug_iroptimized/args delete mode 100644 test/cmdlineTests/ethdebug_iroptimized/input.sol delete mode 100644 test/cmdlineTests/ethdebug_iroptimized/output delete mode 100644 test/cmdlineTests/ethdebug_no_via_ir/args delete mode 100644 test/cmdlineTests/ethdebug_no_via_ir/err delete mode 100644 test/cmdlineTests/ethdebug_no_via_ir/exit delete mode 100644 test/cmdlineTests/ethdebug_no_via_ir/input.sol delete mode 100644 test/cmdlineTests/ethdebug_runtime_ir/args delete mode 100644 test/cmdlineTests/ethdebug_runtime_ir/input.sol delete mode 100644 test/cmdlineTests/ethdebug_runtime_ir/output delete mode 100644 test/cmdlineTests/ethdebug_runtime_iroptimized/args delete mode 100644 test/cmdlineTests/ethdebug_runtime_iroptimized/input.sol delete mode 100644 test/cmdlineTests/ethdebug_runtime_iroptimized/output create mode 100644 test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/strip-ethdebug create mode 100644 test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_ir/strip-ethdebug create mode 100644 test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/strip-ethdebug create mode 100644 test/cmdlineTests/standard_output_selection_ethdebug_bytecode_ir/strip-ethdebug create mode 100644 test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/strip-ethdebug create mode 100644 test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_ir/strip-ethdebug create mode 100644 test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/strip-ethdebug create mode 100644 test/cmdlineTests/standard_output_selection_ethdebug_ir/strip-ethdebug create mode 100644 test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/strip-ethdebug create mode 100644 test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/strip-ethdebug create mode 100644 test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/args create mode 100644 test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/in.yul create mode 100644 test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/input.json create mode 100644 test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/output.json create mode 100644 test/cmdlineTests/standard_yul_ethdebug_assign_immutable/args create mode 100644 test/cmdlineTests/standard_yul_ethdebug_assign_immutable/in.yul create mode 100644 test/cmdlineTests/standard_yul_ethdebug_assign_immutable/input.json create mode 100644 test/cmdlineTests/standard_yul_ethdebug_assign_immutable/output.json create mode 100644 test/cmdlineTests/standard_yul_ethdebug_bytecode_ir/strip-ethdebug create mode 100644 test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/strip-ethdebug create mode 100644 test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/strip-ethdebug create mode 100644 test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/args create mode 100644 test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/in.yul create mode 100644 test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/input.json create mode 100644 test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/output.json create mode 100644 test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/strip-ethdebug create mode 100644 test/cmdlineTests/standard_yul_ethdebug_ir/strip-ethdebug create mode 100644 test/cmdlineTests/standard_yul_ethdebug_iroptimize/strip-ethdebug delete mode 100644 test/cmdlineTests/yul_ethdebug/args delete mode 100644 test/cmdlineTests/yul_ethdebug/input.yul delete mode 100644 test/cmdlineTests/yul_ethdebug/output delete mode 100644 test/cmdlineTests/yul_ethdebug_ir/args delete mode 100644 test/cmdlineTests/yul_ethdebug_ir/err delete mode 100644 test/cmdlineTests/yul_ethdebug_ir/exit delete mode 100644 test/cmdlineTests/yul_ethdebug_ir/input.yul delete mode 100644 test/cmdlineTests/yul_ethdebug_iroptimized/args delete mode 100644 test/cmdlineTests/yul_ethdebug_iroptimized/input.yul delete mode 100644 test/cmdlineTests/yul_ethdebug_iroptimized/output delete mode 100644 test/cmdlineTests/yul_ethdebug_optimize/args delete mode 100644 test/cmdlineTests/yul_ethdebug_optimize/err delete mode 100644 test/cmdlineTests/yul_ethdebug_optimize/exit delete mode 100644 test/cmdlineTests/yul_ethdebug_optimize/input.yul delete mode 100644 test/cmdlineTests/yul_ethdebug_optimize_iroptimized/args delete mode 100644 test/cmdlineTests/yul_ethdebug_optimize_iroptimized/err delete mode 100644 test/cmdlineTests/yul_ethdebug_optimize_iroptimized/exit delete mode 100644 test/cmdlineTests/yul_ethdebug_optimize_iroptimized/input.yul delete mode 100644 test/cmdlineTests/yul_ethdebug_runtime/args delete mode 100644 test/cmdlineTests/yul_ethdebug_runtime/err delete mode 100644 test/cmdlineTests/yul_ethdebug_runtime/exit delete mode 100644 test/cmdlineTests/yul_ethdebug_runtime/input.yul diff --git a/Changelog.md b/Changelog.md index 13cc8db13346..5a8438c5c5e5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,7 @@ Language Features: Compiler Features: * Error Reporting: Errors reported during code generation now point at the location of the contract when more fine-grained location is not available. + * ethdebug: Experimental support for instructions and source locations. * EVM: Support for the EVM version "Osaka". * EVM Assembly Import: Allow enabling opcode-based optimizer. * General: The experimental EOF backend implements a subset of EOF sufficient to compile arbitrary high-level Solidity syntax via IR with optimization enabled. diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 4dcc6a4b092b..a0711cd41756 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -1281,6 +1281,21 @@ LinkerObject const& Assembly::assembleLegacy() const uint8_t tagPush = static_cast(pushInstruction(bytesPerTag)); uint8_t dataRefPush = static_cast(pushInstruction(bytesPerDataRef)); + LinkerObject::CodeSectionLocation codeSectionLocation; + codeSectionLocation.start = 0; + size_t assemblyItemIndex = 0; + auto assembleInstruction = [&](auto&& _addInstruction) { + size_t start = ret.bytecode.size(); + _addInstruction(); + size_t end = ret.bytecode.size(); + codeSectionLocation.instructionLocations.emplace_back( + LinkerObject::InstructionLocation{ + .start = start, + .end = end, + .assemblyItemIndex = assemblyItemIndex + } + ); + }; for (AssemblyItem const& item: items) { // store position of the invalid jump destination @@ -1290,63 +1305,81 @@ LinkerObject const& Assembly::assembleLegacy() const switch (item.type()) { case Operation: - ret.bytecode += assembleOperation(item); + assembleInstruction([&](){ + ret.bytecode += assembleOperation(item); + }); break; case Push: - ret.bytecode += assemblePush(item); + assembleInstruction([&](){ + ret.bytecode += assemblePush(item); + }); break; case PushTag: { - ret.bytecode.push_back(tagPush); - tagRefs[ret.bytecode.size()] = item.splitForeignPushTag(); - ret.bytecode.resize(ret.bytecode.size() + bytesPerTag); + assembleInstruction([&](){ + ret.bytecode.push_back(tagPush); + tagRefs[ret.bytecode.size()] = item.splitForeignPushTag(); + ret.bytecode.resize(ret.bytecode.size() + bytesPerTag); + }); break; } case PushData: - ret.bytecode.push_back(dataRefPush); - dataRefs.insert(std::make_pair(h256(item.data()), ret.bytecode.size())); - ret.bytecode.resize(ret.bytecode.size() + bytesPerDataRef); + assembleInstruction([&]() { + ret.bytecode.push_back(dataRefPush); + dataRefs.insert(std::make_pair(h256(item.data()), ret.bytecode.size())); + ret.bytecode.resize(ret.bytecode.size() + bytesPerDataRef); + }); break; case PushSub: - assertThrow(item.data() <= std::numeric_limits::max(), AssemblyException, ""); - ret.bytecode.push_back(dataRefPush); - subRefs.insert(std::make_pair(static_cast(item.data()), ret.bytecode.size())); - ret.bytecode.resize(ret.bytecode.size() + bytesPerDataRef); + assembleInstruction([&]() { + assertThrow(item.data() <= std::numeric_limits::max(), AssemblyException, ""); + ret.bytecode.push_back(dataRefPush); + subRefs.insert(std::make_pair(static_cast(item.data()), ret.bytecode.size())); + ret.bytecode.resize(ret.bytecode.size() + bytesPerDataRef); + }); break; case PushSubSize: { - assertThrow(item.data() <= std::numeric_limits::max(), AssemblyException, ""); - auto s = subAssemblyById(static_cast(item.data()))->assemble().bytecode.size(); - item.setPushedValue(u256(s)); - unsigned b = std::max(1, numberEncodingSize(s)); - ret.bytecode.push_back(static_cast(pushInstruction(b))); - ret.bytecode.resize(ret.bytecode.size() + b); - bytesRef byr(&ret.bytecode.back() + 1 - b, b); - toBigEndian(s, byr); + assembleInstruction([&](){ + assertThrow(item.data() <= std::numeric_limits::max(), AssemblyException, ""); + auto s = subAssemblyById(static_cast(item.data()))->assemble().bytecode.size(); + item.setPushedValue(u256(s)); + unsigned b = std::max(1, numberEncodingSize(s)); + ret.bytecode.push_back(static_cast(pushInstruction(b))); + ret.bytecode.resize(ret.bytecode.size() + b); + bytesRef byr(&ret.bytecode.back() + 1 - b, b); + toBigEndian(s, byr); + }); break; } case PushProgramSize: { - ret.bytecode.push_back(dataRefPush); - sizeRefs.push_back(static_cast(ret.bytecode.size())); - ret.bytecode.resize(ret.bytecode.size() + bytesPerDataRef); + assembleInstruction([&](){ + ret.bytecode.push_back(dataRefPush); + sizeRefs.push_back(static_cast(ret.bytecode.size())); + ret.bytecode.resize(ret.bytecode.size() + bytesPerDataRef); + }); break; } case PushLibraryAddress: { - auto const [bytecode, linkRef] = assemblePushLibraryAddress(item, ret.bytecode.size()); - ret.bytecode += bytecode; - ret.linkReferences.insert(linkRef); + assembleInstruction([&]() { + auto const [bytecode, linkRef] = assemblePushLibraryAddress(item, ret.bytecode.size()); + ret.bytecode += bytecode; + ret.linkReferences.insert(linkRef); + }); break; } case PushImmutable: - ret.bytecode.push_back(static_cast(Instruction::PUSH32)); - // Maps keccak back to the "identifier" std::string of that immutable. - ret.immutableReferences[item.data()].first = m_immutables.at(item.data()); - // Record the bytecode offset of the PUSH32 argument. - ret.immutableReferences[item.data()].second.emplace_back(ret.bytecode.size()); - // Advance bytecode by 32 bytes (default initialized). - ret.bytecode.resize(ret.bytecode.size() + 32); + assembleInstruction([&]() { + ret.bytecode.push_back(static_cast(Instruction::PUSH32)); + // Maps keccak back to the "identifier" std::string of that immutable. + ret.immutableReferences[item.data()].first = m_immutables.at(item.data()); + // Record the bytecode offset of the PUSH32 argument. + ret.immutableReferences[item.data()].second.emplace_back(ret.bytecode.size()); + // Advance bytecode by 32 bytes (default initialized). + ret.bytecode.resize(ret.bytecode.size() + 32); + }); break; case VerbatimBytecode: ret.bytecode += assembleVerbatimBytecode(item); @@ -1359,35 +1392,59 @@ LinkerObject const& Assembly::assembleLegacy() const { if (i != offsets.size() - 1) { - ret.bytecode.push_back(uint8_t(Instruction::DUP2)); - ret.bytecode.push_back(uint8_t(Instruction::DUP2)); + assembleInstruction([&]() { + ret.bytecode.push_back(uint8_t(Instruction::DUP2)); + }); + assembleInstruction([&]() { + ret.bytecode.push_back(uint8_t(Instruction::DUP2)); + }); } - // TODO: should we make use of the constant optimizer methods for pushing the offsets? - bytes offsetBytes = toCompactBigEndian(u256(offsets[i])); - ret.bytecode.push_back(static_cast(pushInstruction(static_cast(offsetBytes.size())))); - ret.bytecode += offsetBytes; - ret.bytecode.push_back(uint8_t(Instruction::ADD)); - ret.bytecode.push_back(uint8_t(Instruction::MSTORE)); + assembleInstruction([&]() { + // TODO: should we make use of the constant optimizer methods for pushing the offsets? + bytes offsetBytes = toCompactBigEndian(u256(offsets[i])); + ret.bytecode.push_back(static_cast(pushInstruction(static_cast(offsetBytes.size())))); + ret.bytecode += offsetBytes; + }); + assembleInstruction([&]() { + ret.bytecode.push_back(uint8_t(Instruction::ADD)); + }); + assembleInstruction([&]() { + ret.bytecode.push_back(uint8_t(Instruction::MSTORE)); + }); } if (offsets.empty()) { - ret.bytecode.push_back(uint8_t(Instruction::POP)); - ret.bytecode.push_back(uint8_t(Instruction::POP)); + assembleInstruction([&]() { + ret.bytecode.push_back(uint8_t(Instruction::POP)); + }); + assembleInstruction([&]() { + ret.bytecode.push_back(uint8_t(Instruction::POP)); + }); } immutableReferencesBySub.erase(item.data()); break; } case PushDeployTimeAddress: - ret.bytecode += assemblePushDeployTimeAddress(); + assembleInstruction([&]() { + ret.bytecode += assemblePushDeployTimeAddress(); + }); break; case Tag: - ret.bytecode += assembleTag(item, ret.bytecode.size(), true); + assembleInstruction([&](){ + ret.bytecode += assembleTag(item, ret.bytecode.size(), true); + }); break; default: solAssert(false, "Unexpected opcode while assembling."); } + + ++assemblyItemIndex; } + codeSectionLocation.end = ret.bytecode.size(); + + ret.codeSectionLocations.emplace_back(std::move(codeSectionLocation)); + if (!immutableReferencesBySub.empty()) throw langutil::Error( diff --git a/libevmasm/CMakeLists.txt b/libevmasm/CMakeLists.txt index c1918540e625..a7441b85e264 100644 --- a/libevmasm/CMakeLists.txt +++ b/libevmasm/CMakeLists.txt @@ -4,6 +4,8 @@ set(sources Assembly.h AssemblyItem.cpp AssemblyItem.h + Ethdebug.cpp + Ethdebug.h EVMAssemblyStack.cpp EVMAssemblyStack.h BlockDeduplicator.cpp diff --git a/libevmasm/Ethdebug.cpp b/libevmasm/Ethdebug.cpp new file mode 100644 index 000000000000..7b5de2ba9b59 --- /dev/null +++ b/libevmasm/Ethdebug.cpp @@ -0,0 +1,115 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 + +#include + +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::evmasm::ethdebug; + +namespace +{ + +Json programInstructions(Assembly const* _assembly, LinkerObject const& _linkerObject, unsigned _sourceId) +{ + // e.g. interfaces don't have a valid assembly object. + if (_assembly) + { + solUnimplementedAssert(_assembly->eofVersion() == std::nullopt, "ethdebug does not yet support EOF."); + solUnimplementedAssert(_assembly->codeSections().size() == 1, "ethdebug does not yet support multiple code-sections."); + for (auto const& instruction: _assembly->codeSections()[0].items) + solUnimplementedAssert(instruction.type() != VerbatimBytecode, "Verbatim bytecode is currently not supported by ethdebug."); + } + + solAssert(_linkerObject.codeSectionLocations.size() == 1); + solAssert(_linkerObject.codeSectionLocations[0].end <= _linkerObject.bytecode.size()); + Json instructions = Json::array(); + for (size_t i = 0; i < _linkerObject.codeSectionLocations[0].instructionLocations.size(); ++i) + { + solAssert(_assembly); + LinkerObject::InstructionLocation currentInstruction = _linkerObject.codeSectionLocations[0].instructionLocations[i]; + size_t start = currentInstruction.start; + size_t end = currentInstruction.end; + size_t assemblyItemIndex = currentInstruction.assemblyItemIndex; + solAssert(end <= _linkerObject.bytecode.size()); + solAssert(start < end); + solAssert(assemblyItemIndex < _assembly->codeSections().at(0).items.size()); + Json operation = Json::object(); + operation["mnemonic"] = instructionInfo(static_cast(_linkerObject.bytecode[start]), _assembly->evmVersion()).name; + static size_t constexpr instructionSize = 1; + if (start + instructionSize < end) + { + bytes const argumentData( + _linkerObject.bytecode.begin() + static_cast(start) + instructionSize, + _linkerObject.bytecode.begin() + static_cast(end) + ); + solAssert(!argumentData.empty()); + operation["arguments"] = Json::array({util::toHex(argumentData, util::HexPrefix::Add)}); + } + langutil::SourceLocation const& location = _assembly->codeSections().at(0).items.at(assemblyItemIndex).location(); + Json instruction = Json::object(); + instruction["offset"] = start; + instruction["operation"] = operation; + + instruction["context"] = Json::object(); + instruction["context"]["code"] = Json::object(); + instruction["context"]["code"]["source"] = Json::object(); + instruction["context"]["code"]["source"]["id"] = static_cast(_sourceId); + + instruction["context"]["code"]["range"] = Json::object(); + instruction["context"]["code"]["range"]["offset"] = location.start; + instruction["context"]["code"]["range"]["length"] = location.end - location.start; + instructions.emplace_back(instruction); + } + + return instructions; +} + +} // anonymous namespace + +Json ethdebug::program(std::string_view _name, unsigned _sourceId, Assembly const* _assembly, LinkerObject const& _linkerObject) +{ + Json result = Json::object(); + result["contract"] = Json::object(); + result["contract"]["name"] = _name; + result["contract"]["definition"] = Json::object(); + result["contract"]["definition"]["source"] = Json::object(); + result["contract"]["definition"]["source"]["id"] = _sourceId; + result["environment"] = (!_assembly || _assembly->isCreation()) ? "create" : "call"; + result["instructions"] = programInstructions(_assembly, _linkerObject, _sourceId); + return result; +} + +Json ethdebug::resources(std::vector const& _sources, std::string const& _version) +{ + Json sources = Json::array(); + for (size_t id = 0; id < _sources.size(); ++id) + { + Json source = Json::object(); + source["id"] = id; + source["path"] = _sources[id]; + sources.push_back(source); + } + Json result = Json::object(); + result["compilation"] = Json::object(); + result["compilation"]["compiler"] = Json::object(); + result["compilation"]["compiler"]["name"] = "solc"; + result["compilation"]["compiler"]["version"] = _version; + result["compilation"]["sources"] = sources; + return result; +} diff --git a/libevmasm/Ethdebug.h b/libevmasm/Ethdebug.h new file mode 100644 index 000000000000..72ac16037969 --- /dev/null +++ b/libevmasm/Ethdebug.h @@ -0,0 +1,35 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +// SPDX-License-Identifier: GPL-3.0 + +#pragma once + +#include + +#include +#include + +namespace solidity::evmasm::ethdebug +{ + +// returns ethdebug/format/program. +Json program(std::string_view _name, unsigned _sourceId, Assembly const* _assembly, LinkerObject const& _linkerObject); + +// returns ethdebug/format/info/resources +Json resources(std::vector const& _sources, std::string const& _version); + +} // namespace solidity::evmasm::ethdebug diff --git a/libevmasm/LinkerObject.h b/libevmasm/LinkerObject.h index c103a565a069..34e696d4e159 100644 --- a/libevmasm/LinkerObject.h +++ b/libevmasm/LinkerObject.h @@ -46,6 +46,37 @@ struct LinkerObject /// to a list of offsets into the bytecode that refer to their values. std::map immutableReferences; + struct InstructionLocation + { + /// Absolute position of instruction's opcode within the bytecode. + /// The opcode takes up exactly one byte and is assumed to be followed by its immediate arguments. + size_t start{}; + /// Absolute position of the first byte past the end of the instruction, including potential immediate arguments. + size_t end{}; + /// Index of the AssemblyItem that produced the instruction within the Assembly. + /// While items of most types generate a single instruction, in general it can be more than one. + size_t assemblyItemIndex{}; + }; + struct CodeSectionLocation + { + /// Absolute position of the first byte belonging to the code section. + /// Equal to instructionLocations[0].start if the code section is not empty. + size_t start{}; + /// Absolute position of the first byte past end of the code section. + /// Greater or equal to start. Must be equal if instructionLocations is empty. + size_t end{}; + /// Descriptions of all instructions contained within the code section. + /// The instructions are assumed to fill the whole section, without any gaps or duplicates. + /// The areas between opcodes are assumed to contain their immediate arguments, of size appropriate for the opcode type. + /// The arguments of the last instruction extend to the end of the section. + /// The instructions must be ordered according to their positions (ascending). + std::vector instructionLocations; + }; + /// Descriptions of all code sections in the ascending order of their positions. + /// There are no duplicates and the sections never overlap. + /// Only sections belonging to the top-level assembly are included, even if the bytecode contains subassemblies. + std::vector codeSectionLocations; + struct FunctionDebugData { std::optional bytecodeOffset; diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 9582939f5e25..b927776cee59 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -78,13 +78,14 @@ #include #include - #include #include #include #include #include +#include + #include #include @@ -1196,9 +1197,7 @@ Json CompilerStack::ethdebug() const { solAssert(m_stackState >= AnalysisSuccessful, "Analysis was not successful."); solAssert(!m_contracts.empty()); - Json result = Json::object(); - result["sources"] = sourceNames(); - return result; + return evmasm::ethdebug::resources(sourceNames(), VersionString); } Json CompilerStack::ethdebug(std::string const& _contractName) const @@ -1216,13 +1215,10 @@ Json CompilerStack::ethdebug(Contract const& _contract, bool _runtime) const solAssert(m_stackState >= AnalysisSuccessful, "Analysis was not successful."); solAssert(_contract.contract); solUnimplementedAssert(!isExperimentalSolidity()); - if (_runtime) - { - Json result = Json::object(); - return result; - } - Json result = Json::object(); - return result; + evmasm::LinkerObject const& object = _runtime ? _contract.runtimeObject : _contract.object; + std::shared_ptr const& assembly = _runtime ? _contract.evmRuntimeAssembly : _contract.evmAssembly; + solAssert(sourceIndices().contains(_contract.contract->sourceUnitName())); + return evmasm::ethdebug::program(_contract.contract->name(), sourceIndices()[_contract.contract->sourceUnitName()], assembly.get(), object); } bytes CompilerStack::cborMetadata(std::string const& _contractName, bool _forIR) const diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 6bd5cd2317b3..d5502228bda4 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -1680,19 +1681,6 @@ Json StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) return output; } - for (auto const& fileRequests: _inputsAndSettings.outputSelection) - for (auto const& requests: fileRequests) - for (auto const& request: requests) - if (request == "evm.deployedBytecode.ethdebug") - { - output["errors"].emplace_back(formatError( - Error::Type::JSONError, - "general", - "\"evm.deployedBytecode.ethdebug\" cannot be used for Yul." - )); - return output; - } - YulStack stack( _inputsAndSettings.evmVersion, _inputsAndSettings.eofVersion, @@ -1799,7 +1787,7 @@ Json StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) output["contracts"][sourceName][contractName]["yulCFGJson"] = stack.cfgJson(); if (isEthdebugRequested(_inputsAndSettings.outputSelection)) - output["ethdebug"] = stack.ethdebug(); + output["ethdebug"] = evmasm::ethdebug::resources({sourceName}, VersionString); return output; } diff --git a/libyul/YulStack.cpp b/libyul/YulStack.cpp index 1ad24998ffb5..5adb8d6d5c9a 100644 --- a/libyul/YulStack.cpp +++ b/libyul/YulStack.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -273,12 +274,15 @@ YulStack::assembleWithDeployed(std::optional _deployName) {{m_charStream->name(), 0}} ); } - creationObject.ethdebug["not yet implemented @ MachineAssemblyObject::ethdebug"] = true; + if (debugInfoSelection().ethdebug) + creationObject.ethdebug = evmasm::ethdebug::program(creationObject.assembly->name(), 0, creationObject.assembly.get(), *creationObject.bytecode.get()); if (deployedAssembly) { deployedObject.bytecode = std::make_shared(deployedAssembly->assemble()); deployedObject.assembly = deployedAssembly; + if (debugInfoSelection().ethdebug) + deployedObject.ethdebug = evmasm::ethdebug::program(deployedObject.assembly->name(), 0, deployedObject.assembly.get(), *deployedObject.bytecode.get()); solAssert(deployedAssembly->codeSections().size() == 1); deployedObject.sourceMappings = std::make_unique( evmasm::AssemblyItem::computeSourceMapping( @@ -383,17 +387,6 @@ Json YulStack::astJson() const return m_parserResult->toJson(); } -Json YulStack::ethdebug() const -{ - yulAssert(m_parserResult, ""); - yulAssert(m_parserResult->hasCode(), ""); - yulAssert(m_parserResult->analysisInfo, ""); - - Json result = Json::object(); - result["sources"] = Json::array({m_charStream->name()}); - return result; -} - Json YulStack::cfgJson() const { yulAssert(m_parserResult, ""); diff --git a/libyul/YulStack.h b/libyul/YulStack.h index b745f1b80538..e9d75b6ae9d9 100644 --- a/libyul/YulStack.h +++ b/libyul/YulStack.h @@ -149,9 +149,6 @@ class YulStack: public langutil::CharStreamProvider // return the JSON representation of the YuL CFG (experimental) Json cfgJson() const; - /// @returns a JSON representing the top-level ethdebug data (types, etc.). - Json ethdebug() const; - /// Return the parsed and analyzed object. std::shared_ptr parserResult() const; diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index e57cd77a98a2..4a7f34561fbe 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -43,6 +43,7 @@ #include +#include #include #include @@ -1347,26 +1348,25 @@ void CommandLineInterface::assembleYul(yul::YulStack::Language _language, yul::Y solThrow(CommandLineExecutionError, ""); } - if (m_options.compiler.outputs.ethdebug) - { - Json ethdebugObject = Json::object(); - ethdebugObject["sources"] = m_fileReader.sourceUnits() | ranges::views::keys; - sout() << "======= Debug Data (ethdebug/format/info/resources) =======" << std::endl; - sout() << util::jsonPrint( - ethdebugObject, - m_options.formatting.json - ) << std::endl; - } - for (auto const& [sourceUnitName, yulSource]: m_fileReader.sourceUnits()) { solAssert(_targetMachine == yul::YulStack::Machine::EVM); - std::string machine = "EVM"; - sout() << std::endl << "======= " << sourceUnitName << " (" << machine << ") =======" << std::endl; yul::YulStack const& stack = yulStacks[sourceUnitName]; yul::MachineAssemblyObject const& object = objects[sourceUnitName]; + if (m_options.compiler.outputs.ethdebug) + { + sout() << "======= Debug Data (ethdebug/format/info/resources) =======" << std::endl; + sout() << util::jsonPrint( + evmasm::ethdebug::resources({{sourceUnitName}}, VersionString), + m_options.formatting.json + ) << std::endl; + } + + std::string machine = "EVM"; + sout() << std::endl << "======= " << sourceUnitName << " (" << machine << ") =======" << std::endl; + if (m_options.compiler.outputs.irOptimized) { // NOTE: This actually outputs unoptimized code when the optimizer is disabled but diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index 3c781ea78f07..f68ed53dc066 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -220,6 +220,27 @@ json = re.sub(r"\n\s*\n", "\n", json) json = re.sub(r"},(\n{0,1})\n*(\s*(]|}))", r"}\1\2", json) # Remove trailing comma open("$stdout_path", "w").write(json) EOF + # Only do this to files that actually contain ethdebug output, because jq will reformat + # the whole file and its formatting differs from `solc --pretty-json` + if jq 'has("ethdebug")' "$stdout_path" --exit-status > /dev/null; then + local temporary_file + temporary_file=$(mktemp -t cmdline-ethdebug-XXXXXX.tmp) + if [[ -e ${tdir}/strip-ethdebug ]]; then + jq --indent 4 ' + (. | .. | objects | select(has("ethdebug"))) |= (.ethdebug = "") + ' "$stdout_path" > "$temporary_file" + else + jq --indent 4 ' + if .ethdebug.compilation.compiler.version? != null then + .ethdebug.compilation.compiler.version = "" + else + . + end + ' "$stdout_path" > "$temporary_file" + fi + mv "$temporary_file" "$stdout_path" + fi + sed -i.bak -E -e 's/ Consider adding \\"pragma solidity \^[0-9.]*;\\"//g' "$stdout_path" sed -i.bak -E -e 's/\"opcodes\":[[:space:]]*\"[^"]+\"/\"opcodes\":\"\"/g' "$stdout_path" sed -i.bak -E -e 's/\"sourceMap\":[[:space:]]*\"[0-9:;-]+\"/\"sourceMap\":\"\"/g' "$stdout_path" diff --git a/test/cmdlineTests/debug_info_ethdebug_compatible/args b/test/cmdlineTests/debug_info_ethdebug_compatible/args deleted file mode 100644 index 74342f38f1cc..000000000000 --- a/test/cmdlineTests/debug_info_ethdebug_compatible/args +++ /dev/null @@ -1 +0,0 @@ ---debug-info ethdebug --via-ir --ir --ir-optimized --ethdebug --ethdebug-runtime diff --git a/test/cmdlineTests/debug_info_ethdebug_compatible/input.sol b/test/cmdlineTests/debug_info_ethdebug_compatible/input.sol deleted file mode 100644 index 25b9640ca565..000000000000 --- a/test/cmdlineTests/debug_info_ethdebug_compatible/input.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -pragma solidity >=0.0; - -contract C { - function f() public {} -} - diff --git a/test/cmdlineTests/debug_info_ethdebug_compatible/output b/test/cmdlineTests/debug_info_ethdebug_compatible/output deleted file mode 100644 index 0f9581e7f7f2..000000000000 --- a/test/cmdlineTests/debug_info_ethdebug_compatible/output +++ /dev/null @@ -1,193 +0,0 @@ -======= Debug Data (ethdebug/format/info/resources) ======= -{"sources":["debug_info_ethdebug_compatible/input.sol"]} - -======= debug_info_ethdebug_compatible/input.sol:C ======= -IR: -/// ethdebug: enabled -/// @use-src 0:"debug_info_ethdebug_compatible/input.sol" -object "C_6" { - code { - /// @src 0:60:101 - mstore(64, memoryguard(128)) - if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - - constructor_C_6() - - let _1 := allocate_unbounded() - codecopy(_1, dataoffset("C_6_deployed"), datasize("C_6_deployed")) - - return(_1, datasize("C_6_deployed")) - - function allocate_unbounded() -> memPtr { - memPtr := mload(64) - } - - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { - revert(0, 0) - } - - /// @src 0:60:101 - function constructor_C_6() { - - /// @src 0:60:101 - - } - /// @src 0:60:101 - - } - /// @use-src 0:"debug_info_ethdebug_compatible/input.sol" - object "C_6_deployed" { - code { - /// @src 0:60:101 - mstore(64, memoryguard(128)) - - if iszero(lt(calldatasize(), 4)) - { - let selector := shift_right_224_unsigned(calldataload(0)) - switch selector - - case 0x26121ff0 - { - // f() - - external_fun_f_5() - } - - default {} - } - - revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() - - function shift_right_224_unsigned(value) -> newValue { - newValue := - - shr(224, value) - - } - - function allocate_unbounded() -> memPtr { - memPtr := mload(64) - } - - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { - revert(0, 0) - } - - function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { - revert(0, 0) - } - - function abi_decode_tuple_(headStart, dataEnd) { - if slt(sub(dataEnd, headStart), 0) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - - } - - function abi_encode_tuple__to__fromStack(headStart ) -> tail { - tail := add(headStart, 0) - - } - - function external_fun_f_5() { - - if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - abi_decode_tuple_(4, calldatasize()) - fun_f_5() - let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple__to__fromStack(memPos ) - return(memPos, sub(memEnd, memPos)) - - } - - function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { - revert(0, 0) - } - - /// @src 0:77:99 - function fun_f_5() { - - } - /// @src 0:60:101 - - } - - data ".metadata" hex"" - } - -} - - -Optimized IR: -/// ethdebug: enabled -/// @use-src 0:"debug_info_ethdebug_compatible/input.sol" -object "C_6" { - code { - { - /// @src 0:60:101 - mstore(64, memoryguard(0x80)) - if callvalue() - { - revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - } - let _1 := allocate_unbounded() - codecopy(_1, dataoffset("C_6_deployed"), datasize("C_6_deployed")) - return(_1, datasize("C_6_deployed")) - } - function allocate_unbounded() -> memPtr - { memPtr := mload(64) } - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - { revert(0, 0) } - } - /// @use-src 0:"debug_info_ethdebug_compatible/input.sol" - object "C_6_deployed" { - code { - { - /// @src 0:60:101 - mstore(64, memoryguard(0x80)) - if iszero(lt(calldatasize(), 4)) - { - let selector := shift_right_unsigned(calldataload(0)) - switch selector - case 0x26121ff0 { external_fun_f() } - default { } - } - revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() - } - function shift_right_unsigned(value) -> newValue - { newValue := shr(224, value) } - function allocate_unbounded() -> memPtr - { memPtr := mload(64) } - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - { revert(0, 0) } - function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() - { revert(0, 0) } - function abi_decode(headStart, dataEnd) - { - if slt(sub(dataEnd, headStart), 0) - { - revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() - } - } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_f() - { - if callvalue() - { - revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - } - abi_decode(4, calldatasize()) - let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) - return(memPos, sub(memEnd, memPos)) - } - function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() - { revert(0, 0) } - } - data ".metadata" hex"" - } -} - -Debug Data (ethdebug/format/program): -{} -Debug Data of the runtime part (ethdebug/format/program): -{} diff --git a/test/cmdlineTests/debug_info_ethdebug_incompatible/args b/test/cmdlineTests/debug_info_ethdebug_incompatible/args deleted file mode 100644 index 8afe2c9b3a61..000000000000 --- a/test/cmdlineTests/debug_info_ethdebug_incompatible/args +++ /dev/null @@ -1 +0,0 @@ ---debug-info ethdebug --via-ir --asm diff --git a/test/cmdlineTests/debug_info_ethdebug_incompatible/err b/test/cmdlineTests/debug_info_ethdebug_incompatible/err deleted file mode 100644 index 32401186d0d7..000000000000 --- a/test/cmdlineTests/debug_info_ethdebug_incompatible/err +++ /dev/null @@ -1 +0,0 @@ -Error: --debug-info ethdebug can only be used with --ir / --ir-optimized and/or --ethdebug / --ethdebug-runtime. Optimization (using --optimize) is not yet supported with ethdebug. diff --git a/test/cmdlineTests/ethdebug_and_ethdebug_runtime_ir/args b/test/cmdlineTests/ethdebug_and_ethdebug_runtime_ir/args deleted file mode 100644 index 18053bcdac95..000000000000 --- a/test/cmdlineTests/ethdebug_and_ethdebug_runtime_ir/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug-runtime --ethdebug --via-ir --ir \ No newline at end of file diff --git a/test/cmdlineTests/ethdebug_and_ethdebug_runtime_ir/input.sol b/test/cmdlineTests/ethdebug_and_ethdebug_runtime_ir/input.sol deleted file mode 100644 index 25b9640ca565..000000000000 --- a/test/cmdlineTests/ethdebug_and_ethdebug_runtime_ir/input.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -pragma solidity >=0.0; - -contract C { - function f() public {} -} - diff --git a/test/cmdlineTests/ethdebug_and_ethdebug_runtime_ir/output b/test/cmdlineTests/ethdebug_and_ethdebug_runtime_ir/output deleted file mode 100644 index 38dab05afaba..000000000000 --- a/test/cmdlineTests/ethdebug_and_ethdebug_runtime_ir/output +++ /dev/null @@ -1,123 +0,0 @@ -======= Debug Data (ethdebug/format/info/resources) ======= -{"sources":["ethdebug_and_ethdebug_runtime_ir/input.sol"]} - -======= ethdebug_and_ethdebug_runtime_ir/input.sol:C ======= -IR: -/// ethdebug: enabled -/// @use-src 0:"ethdebug_and_ethdebug_runtime_ir/input.sol" -object "C_6" { - code { - /// @src 0:60:101 "contract C {..." - mstore(64, memoryguard(128)) - if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - - constructor_C_6() - - let _1 := allocate_unbounded() - codecopy(_1, dataoffset("C_6_deployed"), datasize("C_6_deployed")) - - return(_1, datasize("C_6_deployed")) - - function allocate_unbounded() -> memPtr { - memPtr := mload(64) - } - - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { - revert(0, 0) - } - - /// @src 0:60:101 "contract C {..." - function constructor_C_6() { - - /// @src 0:60:101 "contract C {..." - - } - /// @src 0:60:101 "contract C {..." - - } - /// @use-src 0:"ethdebug_and_ethdebug_runtime_ir/input.sol" - object "C_6_deployed" { - code { - /// @src 0:60:101 "contract C {..." - mstore(64, memoryguard(128)) - - if iszero(lt(calldatasize(), 4)) - { - let selector := shift_right_224_unsigned(calldataload(0)) - switch selector - - case 0x26121ff0 - { - // f() - - external_fun_f_5() - } - - default {} - } - - revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() - - function shift_right_224_unsigned(value) -> newValue { - newValue := - - shr(224, value) - - } - - function allocate_unbounded() -> memPtr { - memPtr := mload(64) - } - - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { - revert(0, 0) - } - - function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { - revert(0, 0) - } - - function abi_decode_tuple_(headStart, dataEnd) { - if slt(sub(dataEnd, headStart), 0) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - - } - - function abi_encode_tuple__to__fromStack(headStart ) -> tail { - tail := add(headStart, 0) - - } - - function external_fun_f_5() { - - if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - abi_decode_tuple_(4, calldatasize()) - fun_f_5() - let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple__to__fromStack(memPos ) - return(memPos, sub(memEnd, memPos)) - - } - - function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { - revert(0, 0) - } - - /// @ast-id 5 - /// @src 0:77:99 "function f() public {}" - function fun_f_5() { - - } - /// @src 0:60:101 "contract C {..." - - } - - data ".metadata" hex"" - } - -} - - -Debug Data (ethdebug/format/program): -{} -Debug Data of the runtime part (ethdebug/format/program): -{} diff --git a/test/cmdlineTests/ethdebug_and_ethdebug_runtime_iroptimized/args b/test/cmdlineTests/ethdebug_and_ethdebug_runtime_iroptimized/args deleted file mode 100644 index 09535998b5be..000000000000 --- a/test/cmdlineTests/ethdebug_and_ethdebug_runtime_iroptimized/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug-runtime --ethdebug --via-ir --ir-optimized \ No newline at end of file diff --git a/test/cmdlineTests/ethdebug_and_ethdebug_runtime_iroptimized/input.sol b/test/cmdlineTests/ethdebug_and_ethdebug_runtime_iroptimized/input.sol deleted file mode 100644 index 25b9640ca565..000000000000 --- a/test/cmdlineTests/ethdebug_and_ethdebug_runtime_iroptimized/input.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -pragma solidity >=0.0; - -contract C { - function f() public {} -} - diff --git a/test/cmdlineTests/ethdebug_and_ethdebug_runtime_iroptimized/output b/test/cmdlineTests/ethdebug_and_ethdebug_runtime_iroptimized/output deleted file mode 100644 index 19a3c9e86b90..000000000000 --- a/test/cmdlineTests/ethdebug_and_ethdebug_runtime_iroptimized/output +++ /dev/null @@ -1,79 +0,0 @@ -======= Debug Data (ethdebug/format/info/resources) ======= -{"sources":["ethdebug_and_ethdebug_runtime_iroptimized/input.sol"]} - -======= ethdebug_and_ethdebug_runtime_iroptimized/input.sol:C ======= -Optimized IR: -/// ethdebug: enabled -/// @use-src 0:"ethdebug_and_ethdebug_runtime_iroptimized/input.sol" -object "C_6" { - code { - { - /// @src 0:60:101 "contract C {..." - mstore(64, memoryguard(0x80)) - if callvalue() - { - revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - } - let _1 := allocate_unbounded() - codecopy(_1, dataoffset("C_6_deployed"), datasize("C_6_deployed")) - return(_1, datasize("C_6_deployed")) - } - function allocate_unbounded() -> memPtr - { memPtr := mload(64) } - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - { revert(0, 0) } - } - /// @use-src 0:"ethdebug_and_ethdebug_runtime_iroptimized/input.sol" - object "C_6_deployed" { - code { - { - /// @src 0:60:101 "contract C {..." - mstore(64, memoryguard(0x80)) - if iszero(lt(calldatasize(), 4)) - { - let selector := shift_right_unsigned(calldataload(0)) - switch selector - case 0x26121ff0 { external_fun_f() } - default { } - } - revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() - } - function shift_right_unsigned(value) -> newValue - { newValue := shr(224, value) } - function allocate_unbounded() -> memPtr - { memPtr := mload(64) } - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - { revert(0, 0) } - function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() - { revert(0, 0) } - function abi_decode(headStart, dataEnd) - { - if slt(sub(dataEnd, headStart), 0) - { - revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() - } - } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_f() - { - if callvalue() - { - revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - } - abi_decode(4, calldatasize()) - let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) - return(memPos, sub(memEnd, memPos)) - } - function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() - { revert(0, 0) } - } - data ".metadata" hex"" - } -} - -Debug Data (ethdebug/format/program): -{} -Debug Data of the runtime part (ethdebug/format/program): -{} diff --git a/test/cmdlineTests/ethdebug_enabled_optimization_ir/args b/test/cmdlineTests/ethdebug_enabled_optimization_ir/args deleted file mode 100644 index 38ce714e1b86..000000000000 --- a/test/cmdlineTests/ethdebug_enabled_optimization_ir/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug --via-ir --optimize --ir \ No newline at end of file diff --git a/test/cmdlineTests/ethdebug_enabled_optimization_ir/err b/test/cmdlineTests/ethdebug_enabled_optimization_ir/err deleted file mode 100644 index b2c26e5d8a50..000000000000 --- a/test/cmdlineTests/ethdebug_enabled_optimization_ir/err +++ /dev/null @@ -1 +0,0 @@ -Error: --ethdebug / --ethdebug-runtime output can only be used with --ir / --ir-optimized. Optimization (using --optimize) is not yet supported with ethdebug. diff --git a/test/cmdlineTests/ethdebug_enabled_optimization_ir/exit b/test/cmdlineTests/ethdebug_enabled_optimization_ir/exit deleted file mode 100644 index d00491fd7e5b..000000000000 --- a/test/cmdlineTests/ethdebug_enabled_optimization_ir/exit +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/test/cmdlineTests/ethdebug_enabled_optimization_ir/input.sol b/test/cmdlineTests/ethdebug_enabled_optimization_ir/input.sol deleted file mode 100644 index 25b9640ca565..000000000000 --- a/test/cmdlineTests/ethdebug_enabled_optimization_ir/input.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -pragma solidity >=0.0; - -contract C { - function f() public {} -} - diff --git a/test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/args b/test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/args deleted file mode 100644 index 6edc3b560136..000000000000 --- a/test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug --via-ir --optimize --ir-optimized \ No newline at end of file diff --git a/test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/err b/test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/err deleted file mode 100644 index b2c26e5d8a50..000000000000 --- a/test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/err +++ /dev/null @@ -1 +0,0 @@ -Error: --ethdebug / --ethdebug-runtime output can only be used with --ir / --ir-optimized. Optimization (using --optimize) is not yet supported with ethdebug. diff --git a/test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/exit b/test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/exit deleted file mode 100644 index d00491fd7e5b..000000000000 --- a/test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/exit +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/input.sol b/test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/input.sol deleted file mode 100644 index 25b9640ca565..000000000000 --- a/test/cmdlineTests/ethdebug_enabled_optimization_iroptimized/input.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -pragma solidity >=0.0; - -contract C { - function f() public {} -} - diff --git a/test/cmdlineTests/ethdebug_eof_container_osaka/args b/test/cmdlineTests/ethdebug_eof_container_osaka/args new file mode 100644 index 000000000000..65974c6287da --- /dev/null +++ b/test/cmdlineTests/ethdebug_eof_container_osaka/args @@ -0,0 +1 @@ + --experimental-eof-version 1 --evm-version osaka --ethdebug --via-ir diff --git a/test/cmdlineTests/ethdebug_eof_container_osaka/err b/test/cmdlineTests/ethdebug_eof_container_osaka/err new file mode 100644 index 000000000000..7714685971d2 --- /dev/null +++ b/test/cmdlineTests/ethdebug_eof_container_osaka/err @@ -0,0 +1 @@ +Error: ethdebug does not yet support EOF. diff --git a/test/cmdlineTests/debug_info_ethdebug_incompatible/exit b/test/cmdlineTests/ethdebug_eof_container_osaka/exit similarity index 100% rename from test/cmdlineTests/debug_info_ethdebug_incompatible/exit rename to test/cmdlineTests/ethdebug_eof_container_osaka/exit diff --git a/test/cmdlineTests/debug_info_ethdebug_incompatible/input.sol b/test/cmdlineTests/ethdebug_eof_container_osaka/input.sol similarity index 99% rename from test/cmdlineTests/debug_info_ethdebug_incompatible/input.sol rename to test/cmdlineTests/ethdebug_eof_container_osaka/input.sol index 25b9640ca565..415509ef9aef 100644 --- a/test/cmdlineTests/debug_info_ethdebug_incompatible/input.sol +++ b/test/cmdlineTests/ethdebug_eof_container_osaka/input.sol @@ -4,4 +4,3 @@ pragma solidity >=0.0; contract C { function f() public {} } - diff --git a/test/cmdlineTests/ethdebug_eof_container_osaka/output b/test/cmdlineTests/ethdebug_eof_container_osaka/output new file mode 100644 index 000000000000..9d002fadc317 --- /dev/null +++ b/test/cmdlineTests/ethdebug_eof_container_osaka/output @@ -0,0 +1,4 @@ +======= Debug Data (ethdebug/format/info/resources) ======= +{"compilation":{"compiler":{"name":"solc","version": ""},"sources":[{"id":0,"path":"ethdebug_eof_container_osaka/input.sol"}]}} + +======= ethdebug_eof_container_osaka/input.sol:C ======= diff --git a/test/cmdlineTests/ethdebug_ir/args b/test/cmdlineTests/ethdebug_ir/args deleted file mode 100644 index ac83894b301f..000000000000 --- a/test/cmdlineTests/ethdebug_ir/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug --via-ir --ir \ No newline at end of file diff --git a/test/cmdlineTests/ethdebug_ir/input.sol b/test/cmdlineTests/ethdebug_ir/input.sol deleted file mode 100644 index 25b9640ca565..000000000000 --- a/test/cmdlineTests/ethdebug_ir/input.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -pragma solidity >=0.0; - -contract C { - function f() public {} -} - diff --git a/test/cmdlineTests/ethdebug_ir/output b/test/cmdlineTests/ethdebug_ir/output deleted file mode 100644 index 6713431b680e..000000000000 --- a/test/cmdlineTests/ethdebug_ir/output +++ /dev/null @@ -1,121 +0,0 @@ -======= Debug Data (ethdebug/format/info/resources) ======= -{"sources":["ethdebug_ir/input.sol"]} - -======= ethdebug_ir/input.sol:C ======= -IR: -/// ethdebug: enabled -/// @use-src 0:"ethdebug_ir/input.sol" -object "C_6" { - code { - /// @src 0:60:101 "contract C {..." - mstore(64, memoryguard(128)) - if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - - constructor_C_6() - - let _1 := allocate_unbounded() - codecopy(_1, dataoffset("C_6_deployed"), datasize("C_6_deployed")) - - return(_1, datasize("C_6_deployed")) - - function allocate_unbounded() -> memPtr { - memPtr := mload(64) - } - - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { - revert(0, 0) - } - - /// @src 0:60:101 "contract C {..." - function constructor_C_6() { - - /// @src 0:60:101 "contract C {..." - - } - /// @src 0:60:101 "contract C {..." - - } - /// @use-src 0:"ethdebug_ir/input.sol" - object "C_6_deployed" { - code { - /// @src 0:60:101 "contract C {..." - mstore(64, memoryguard(128)) - - if iszero(lt(calldatasize(), 4)) - { - let selector := shift_right_224_unsigned(calldataload(0)) - switch selector - - case 0x26121ff0 - { - // f() - - external_fun_f_5() - } - - default {} - } - - revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() - - function shift_right_224_unsigned(value) -> newValue { - newValue := - - shr(224, value) - - } - - function allocate_unbounded() -> memPtr { - memPtr := mload(64) - } - - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { - revert(0, 0) - } - - function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { - revert(0, 0) - } - - function abi_decode_tuple_(headStart, dataEnd) { - if slt(sub(dataEnd, headStart), 0) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - - } - - function abi_encode_tuple__to__fromStack(headStart ) -> tail { - tail := add(headStart, 0) - - } - - function external_fun_f_5() { - - if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - abi_decode_tuple_(4, calldatasize()) - fun_f_5() - let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple__to__fromStack(memPos ) - return(memPos, sub(memEnd, memPos)) - - } - - function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { - revert(0, 0) - } - - /// @ast-id 5 - /// @src 0:77:99 "function f() public {}" - function fun_f_5() { - - } - /// @src 0:60:101 "contract C {..." - - } - - data ".metadata" hex"" - } - -} - - -Debug Data (ethdebug/format/program): -{} diff --git a/test/cmdlineTests/ethdebug_iroptimized/args b/test/cmdlineTests/ethdebug_iroptimized/args deleted file mode 100644 index e048da7bbb2f..000000000000 --- a/test/cmdlineTests/ethdebug_iroptimized/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug --via-ir --ir-optimized \ No newline at end of file diff --git a/test/cmdlineTests/ethdebug_iroptimized/input.sol b/test/cmdlineTests/ethdebug_iroptimized/input.sol deleted file mode 100644 index 25b9640ca565..000000000000 --- a/test/cmdlineTests/ethdebug_iroptimized/input.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -pragma solidity >=0.0; - -contract C { - function f() public {} -} - diff --git a/test/cmdlineTests/ethdebug_iroptimized/output b/test/cmdlineTests/ethdebug_iroptimized/output deleted file mode 100644 index 59e2579eb65a..000000000000 --- a/test/cmdlineTests/ethdebug_iroptimized/output +++ /dev/null @@ -1,77 +0,0 @@ -======= Debug Data (ethdebug/format/info/resources) ======= -{"sources":["ethdebug_iroptimized/input.sol"]} - -======= ethdebug_iroptimized/input.sol:C ======= -Optimized IR: -/// ethdebug: enabled -/// @use-src 0:"ethdebug_iroptimized/input.sol" -object "C_6" { - code { - { - /// @src 0:60:101 "contract C {..." - mstore(64, memoryguard(0x80)) - if callvalue() - { - revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - } - let _1 := allocate_unbounded() - codecopy(_1, dataoffset("C_6_deployed"), datasize("C_6_deployed")) - return(_1, datasize("C_6_deployed")) - } - function allocate_unbounded() -> memPtr - { memPtr := mload(64) } - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - { revert(0, 0) } - } - /// @use-src 0:"ethdebug_iroptimized/input.sol" - object "C_6_deployed" { - code { - { - /// @src 0:60:101 "contract C {..." - mstore(64, memoryguard(0x80)) - if iszero(lt(calldatasize(), 4)) - { - let selector := shift_right_unsigned(calldataload(0)) - switch selector - case 0x26121ff0 { external_fun_f() } - default { } - } - revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() - } - function shift_right_unsigned(value) -> newValue - { newValue := shr(224, value) } - function allocate_unbounded() -> memPtr - { memPtr := mload(64) } - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - { revert(0, 0) } - function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() - { revert(0, 0) } - function abi_decode(headStart, dataEnd) - { - if slt(sub(dataEnd, headStart), 0) - { - revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() - } - } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_f() - { - if callvalue() - { - revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - } - abi_decode(4, calldatasize()) - let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) - return(memPos, sub(memEnd, memPos)) - } - function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() - { revert(0, 0) } - } - data ".metadata" hex"" - } -} - -Debug Data (ethdebug/format/program): -{} diff --git a/test/cmdlineTests/ethdebug_no_via_ir/args b/test/cmdlineTests/ethdebug_no_via_ir/args deleted file mode 100644 index 6a019364e6b3..000000000000 --- a/test/cmdlineTests/ethdebug_no_via_ir/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug --ir --ir-optimized \ No newline at end of file diff --git a/test/cmdlineTests/ethdebug_no_via_ir/err b/test/cmdlineTests/ethdebug_no_via_ir/err deleted file mode 100644 index 2729b6d5d830..000000000000 --- a/test/cmdlineTests/ethdebug_no_via_ir/err +++ /dev/null @@ -1 +0,0 @@ -Error: --ethdebug / --ethdebug-runtime output can only be selected, if --via-ir was specified. diff --git a/test/cmdlineTests/ethdebug_no_via_ir/exit b/test/cmdlineTests/ethdebug_no_via_ir/exit deleted file mode 100644 index d00491fd7e5b..000000000000 --- a/test/cmdlineTests/ethdebug_no_via_ir/exit +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/test/cmdlineTests/ethdebug_no_via_ir/input.sol b/test/cmdlineTests/ethdebug_no_via_ir/input.sol deleted file mode 100644 index 25b9640ca565..000000000000 --- a/test/cmdlineTests/ethdebug_no_via_ir/input.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -pragma solidity >=0.0; - -contract C { - function f() public {} -} - diff --git a/test/cmdlineTests/ethdebug_runtime_ir/args b/test/cmdlineTests/ethdebug_runtime_ir/args deleted file mode 100644 index a2193034c8db..000000000000 --- a/test/cmdlineTests/ethdebug_runtime_ir/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug-runtime --via-ir --ir \ No newline at end of file diff --git a/test/cmdlineTests/ethdebug_runtime_ir/input.sol b/test/cmdlineTests/ethdebug_runtime_ir/input.sol deleted file mode 100644 index 25b9640ca565..000000000000 --- a/test/cmdlineTests/ethdebug_runtime_ir/input.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -pragma solidity >=0.0; - -contract C { - function f() public {} -} - diff --git a/test/cmdlineTests/ethdebug_runtime_ir/output b/test/cmdlineTests/ethdebug_runtime_ir/output deleted file mode 100644 index 93b7b91f13e4..000000000000 --- a/test/cmdlineTests/ethdebug_runtime_ir/output +++ /dev/null @@ -1,121 +0,0 @@ -======= Debug Data (ethdebug/format/info/resources) ======= -{"sources":["ethdebug_runtime_ir/input.sol"]} - -======= ethdebug_runtime_ir/input.sol:C ======= -IR: -/// ethdebug: enabled -/// @use-src 0:"ethdebug_runtime_ir/input.sol" -object "C_6" { - code { - /// @src 0:60:101 "contract C {..." - mstore(64, memoryguard(128)) - if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - - constructor_C_6() - - let _1 := allocate_unbounded() - codecopy(_1, dataoffset("C_6_deployed"), datasize("C_6_deployed")) - - return(_1, datasize("C_6_deployed")) - - function allocate_unbounded() -> memPtr { - memPtr := mload(64) - } - - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { - revert(0, 0) - } - - /// @src 0:60:101 "contract C {..." - function constructor_C_6() { - - /// @src 0:60:101 "contract C {..." - - } - /// @src 0:60:101 "contract C {..." - - } - /// @use-src 0:"ethdebug_runtime_ir/input.sol" - object "C_6_deployed" { - code { - /// @src 0:60:101 "contract C {..." - mstore(64, memoryguard(128)) - - if iszero(lt(calldatasize(), 4)) - { - let selector := shift_right_224_unsigned(calldataload(0)) - switch selector - - case 0x26121ff0 - { - // f() - - external_fun_f_5() - } - - default {} - } - - revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() - - function shift_right_224_unsigned(value) -> newValue { - newValue := - - shr(224, value) - - } - - function allocate_unbounded() -> memPtr { - memPtr := mload(64) - } - - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { - revert(0, 0) - } - - function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() { - revert(0, 0) - } - - function abi_decode_tuple_(headStart, dataEnd) { - if slt(sub(dataEnd, headStart), 0) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() } - - } - - function abi_encode_tuple__to__fromStack(headStart ) -> tail { - tail := add(headStart, 0) - - } - - function external_fun_f_5() { - - if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } - abi_decode_tuple_(4, calldatasize()) - fun_f_5() - let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple__to__fromStack(memPos ) - return(memPos, sub(memEnd, memPos)) - - } - - function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { - revert(0, 0) - } - - /// @ast-id 5 - /// @src 0:77:99 "function f() public {}" - function fun_f_5() { - - } - /// @src 0:60:101 "contract C {..." - - } - - data ".metadata" hex"" - } - -} - - -Debug Data of the runtime part (ethdebug/format/program): -{} diff --git a/test/cmdlineTests/ethdebug_runtime_iroptimized/args b/test/cmdlineTests/ethdebug_runtime_iroptimized/args deleted file mode 100644 index f647c52a7eed..000000000000 --- a/test/cmdlineTests/ethdebug_runtime_iroptimized/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug-runtime --via-ir --ir-optimized \ No newline at end of file diff --git a/test/cmdlineTests/ethdebug_runtime_iroptimized/input.sol b/test/cmdlineTests/ethdebug_runtime_iroptimized/input.sol deleted file mode 100644 index 25b9640ca565..000000000000 --- a/test/cmdlineTests/ethdebug_runtime_iroptimized/input.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -pragma solidity >=0.0; - -contract C { - function f() public {} -} - diff --git a/test/cmdlineTests/ethdebug_runtime_iroptimized/output b/test/cmdlineTests/ethdebug_runtime_iroptimized/output deleted file mode 100644 index 733e47a8500b..000000000000 --- a/test/cmdlineTests/ethdebug_runtime_iroptimized/output +++ /dev/null @@ -1,77 +0,0 @@ -======= Debug Data (ethdebug/format/info/resources) ======= -{"sources":["ethdebug_runtime_iroptimized/input.sol"]} - -======= ethdebug_runtime_iroptimized/input.sol:C ======= -Optimized IR: -/// ethdebug: enabled -/// @use-src 0:"ethdebug_runtime_iroptimized/input.sol" -object "C_6" { - code { - { - /// @src 0:60:101 "contract C {..." - mstore(64, memoryguard(0x80)) - if callvalue() - { - revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - } - let _1 := allocate_unbounded() - codecopy(_1, dataoffset("C_6_deployed"), datasize("C_6_deployed")) - return(_1, datasize("C_6_deployed")) - } - function allocate_unbounded() -> memPtr - { memPtr := mload(64) } - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - { revert(0, 0) } - } - /// @use-src 0:"ethdebug_runtime_iroptimized/input.sol" - object "C_6_deployed" { - code { - { - /// @src 0:60:101 "contract C {..." - mstore(64, memoryguard(0x80)) - if iszero(lt(calldatasize(), 4)) - { - let selector := shift_right_unsigned(calldataload(0)) - switch selector - case 0x26121ff0 { external_fun_f() } - default { } - } - revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() - } - function shift_right_unsigned(value) -> newValue - { newValue := shr(224, value) } - function allocate_unbounded() -> memPtr - { memPtr := mload(64) } - function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - { revert(0, 0) } - function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() - { revert(0, 0) } - function abi_decode(headStart, dataEnd) - { - if slt(sub(dataEnd, headStart), 0) - { - revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() - } - } - function abi_encode_tuple(headStart) -> tail - { tail := add(headStart, 0) } - function external_fun_f() - { - if callvalue() - { - revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() - } - abi_decode(4, calldatasize()) - let memPos := allocate_unbounded() - let memEnd := abi_encode_tuple(memPos) - return(memPos, sub(memEnd, memPos)) - } - function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() - { revert(0, 0) } - } - data ".metadata" hex"" - } -} - -Debug Data of the runtime part (ethdebug/format/program): -{} diff --git a/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/output.json b/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/output.json index 0b8a87baf622..8f198f1f3adb 100644 --- a/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/output.json +++ b/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/output.json @@ -4,10 +4,10 @@ "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" }, "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -298,10 +298,10 @@ object \"A1_14\" { "A2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" }, "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -594,10 +594,10 @@ object \"A2_27\" { "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" }, "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -888,10 +888,10 @@ object \"A1_42\" { "B2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" }, "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -1181,12 +1181,7 @@ object \"B2_55\" { } } }, - "ethdebug": { - "sources": [ - "a.sol", - "b.sol" - ] - }, + "ethdebug": "", "sources": { "a.sol": { "id": 0 diff --git a/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/strip-ethdebug b/test/cmdlineTests/standard_output_debuginfo_ethdebug_compatible/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_ir/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_ir/output.json index f8fb2ce274d0..7694acea611c 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_ir/output.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_ir/output.json @@ -4,10 +4,10 @@ "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" }, "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -184,10 +184,10 @@ object \"A1_14\" { "A2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" }, "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -366,10 +366,10 @@ object \"A2_27\" { "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" }, "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -546,10 +546,10 @@ object \"A1_42\" { "B2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" }, "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -725,12 +725,7 @@ object \"B2_55\" { } } }, - "ethdebug": { - "sources": [ - "a.sol", - "b.sol" - ] - }, + "ethdebug": "", "sources": { "a.sol": { "id": 0 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_ir/strip-ethdebug b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_ir/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/output.json index 66b9082dcc12..b129a0c91b85 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/output.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/output.json @@ -4,10 +4,10 @@ "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" }, "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -129,10 +129,10 @@ object \"A1_14\" { "A2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" }, "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -256,10 +256,10 @@ object \"A2_27\" { "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" }, "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -381,10 +381,10 @@ object \"A1_42\" { "B2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" }, "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -505,12 +505,7 @@ object \"B2_55\" { } } }, - "ethdebug": { - "sources": [ - "a.sol", - "b.sol" - ] - }, + "ethdebug": "", "sources": { "a.sol": { "id": 0 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/strip-ethdebug b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_and_deployedbytecode_iroptimized/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_ir/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_ir/output.json index fabb25ee6720..c7463f124184 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_ir/output.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_ir/output.json @@ -4,7 +4,7 @@ "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -181,7 +181,7 @@ object \"A1_14\" { "A2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -360,7 +360,7 @@ object \"A2_27\" { "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -537,7 +537,7 @@ object \"A1_42\" { "B2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -713,12 +713,7 @@ object \"B2_55\" { } } }, - "ethdebug": { - "sources": [ - "a.sol", - "b.sol" - ] - }, + "ethdebug": "", "sources": { "a.sol": { "id": 0 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_ir/strip-ethdebug b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_ir/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/output.json index d7284ab6405e..eab40879c4c5 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/output.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/output.json @@ -4,7 +4,7 @@ "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -126,7 +126,7 @@ object \"A1_14\" { "A2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -250,7 +250,7 @@ object \"A2_27\" { "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -372,7 +372,7 @@ object \"A1_42\" { "B2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -493,12 +493,7 @@ object \"B2_55\" { } } }, - "ethdebug": { - "sources": [ - "a.sol", - "b.sol" - ] - }, + "ethdebug": "", "sources": { "a.sol": { "id": 0 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/strip-ethdebug b/test/cmdlineTests/standard_output_selection_ethdebug_bytecode_iroptimized/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_ir/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_ir/output.json index 4c7b4ed67197..8a8080833cf6 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_ir/output.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_ir/output.json @@ -4,7 +4,7 @@ "A1": { "evm": { "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -181,7 +181,7 @@ object \"A1_14\" { "A2": { "evm": { "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -360,7 +360,7 @@ object \"A2_27\" { "A1": { "evm": { "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -537,7 +537,7 @@ object \"A1_42\" { "B2": { "evm": { "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -713,12 +713,7 @@ object \"B2_55\" { } } }, - "ethdebug": { - "sources": [ - "a.sol", - "b.sol" - ] - }, + "ethdebug": "", "sources": { "a.sol": { "id": 0 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_ir/strip-ethdebug b/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_ir/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/output.json index dce2a276e46f..4f3bd68eed09 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/output.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/output.json @@ -4,7 +4,7 @@ "A1": { "evm": { "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -126,7 +126,7 @@ object \"A1_14\" { "A2": { "evm": { "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -250,7 +250,7 @@ object \"A2_27\" { "A1": { "evm": { "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -372,7 +372,7 @@ object \"A1_42\" { "B2": { "evm": { "deployedBytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -493,12 +493,7 @@ object \"B2_55\" { } } }, - "ethdebug": { - "sources": [ - "a.sol", - "b.sol" - ] - }, + "ethdebug": "", "sources": { "a.sol": { "id": 0 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/strip-ethdebug b/test/cmdlineTests/standard_output_selection_ethdebug_deployedbytecode_iroptimized/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_ir/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_ir/output.json index fabb25ee6720..c7463f124184 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_ir/output.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_ir/output.json @@ -4,7 +4,7 @@ "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -181,7 +181,7 @@ object \"A1_14\" { "A2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -360,7 +360,7 @@ object \"A2_27\" { "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -537,7 +537,7 @@ object \"A1_42\" { "B2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -713,12 +713,7 @@ object \"B2_55\" { } } }, - "ethdebug": { - "sources": [ - "a.sol", - "b.sol" - ] - }, + "ethdebug": "", "sources": { "a.sol": { "id": 0 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_ir/strip-ethdebug b/test/cmdlineTests/standard_output_selection_ethdebug_ir/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/output.json b/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/output.json index d7284ab6405e..eab40879c4c5 100644 --- a/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/output.json +++ b/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/output.json @@ -4,7 +4,7 @@ "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -126,7 +126,7 @@ object \"A1_14\" { "A2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -250,7 +250,7 @@ object \"A2_27\" { "A1": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -372,7 +372,7 @@ object \"A1_42\" { "B2": { "evm": { "bytecode": { - "ethdebug": {} + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -493,12 +493,7 @@ object \"B2_55\" { } } }, - "ethdebug": { - "sources": [ - "a.sol", - "b.sol" - ] - }, + "ethdebug": "", "sources": { "a.sol": { "id": 0 diff --git a/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/strip-ethdebug b/test/cmdlineTests/standard_output_selection_ethdebug_iroptimized/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/output.json b/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/output.json index 63d48b80b255..2b2f395fadd4 100644 --- a/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/output.json +++ b/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/output.json @@ -4,9 +4,7 @@ "C_6_deployed": { "evm": { "bytecode": { - "ethdebug": { - "not yet implemented @ MachineAssemblyObject::ethdebug": true - } + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -40,9 +38,5 @@ object \"C_6_deployed\" { } } }, - "ethdebug": { - "sources": [ - "C" - ] - } + "ethdebug": "" } diff --git a/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/strip-ethdebug b/test/cmdlineTests/standard_yul_debug_info_ethdebug_compatible_output/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/args b/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/args new file mode 100644 index 000000000000..18532c5a6d3f --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/args @@ -0,0 +1 @@ +--allow-paths . diff --git a/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/in.yul b/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/in.yul new file mode 100644 index 000000000000..182cdc75ddc9 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/in.yul @@ -0,0 +1,11 @@ +{ + let x := 2 + let y := sub(x, 2) + let t := verbatim_2i_1o("abc", x, y) + sstore(t, x) + let r := verbatim_0i_1o("def") + verbatim_0i_0o("xyz") + // more than 32 bytes + verbatim_0i_0o(hex"01020304050607090001020304050607090001020304050607090001020102030405060709000102030405060709000102030405060709000102") + r := 9 +} diff --git a/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/input.json b/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/input.json new file mode 100644 index 000000000000..be4fbb64fce3 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/input.json @@ -0,0 +1,16 @@ +{ + "language": "Yul", + "sources": { + "C": { + "urls": [ + "standard_yul_debug_info_ethdebug_verbatim_unimplemented/in.yul" + ] + } + }, + "settings": { + "debug": {"debugInfo": ["ethdebug"]}, + "outputSelection": { + "*": {"*": ["evm.bytecode.ethdebug"]} + } + } +} diff --git a/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/output.json b/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/output.json new file mode 100644 index 000000000000..b645222de390 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_ethdebug_verbatim_unimplemented/output.json @@ -0,0 +1,13 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "UnimplementedFeatureError: Verbatim bytecode is currently not supported by ethdebug. + +", + "message": "Verbatim bytecode is currently not supported by ethdebug.", + "severity": "error", + "type": "UnimplementedFeatureError" + } + ] +} diff --git a/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/args b/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/args new file mode 100644 index 000000000000..18532c5a6d3f --- /dev/null +++ b/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/args @@ -0,0 +1 @@ +--allow-paths . diff --git a/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/in.yul b/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/in.yul new file mode 100644 index 000000000000..5c098cc80569 --- /dev/null +++ b/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/in.yul @@ -0,0 +1,7 @@ +object "a" { + code { + { + setimmutable(0, "long___name___that___definitely___exceeds___the___thirty___two___byte___limit", 0x1234567890123456789012345678901234567890) + } + } +} \ No newline at end of file diff --git a/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/input.json b/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/input.json new file mode 100644 index 000000000000..83acd4c42085 --- /dev/null +++ b/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/input.json @@ -0,0 +1,11 @@ +{ + "language": "Yul", + "sources": { + "C": {"urls": ["standard_yul_ethdebug_assign_immutable/in.yul"]} + }, + "settings": { + "outputSelection": { + "*": {"*": ["evm.bytecode.ethdebug"]} + } + } +} diff --git a/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/output.json b/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/output.json new file mode 100644 index 000000000000..3af82e21d392 --- /dev/null +++ b/test/cmdlineTests/standard_yul_ethdebug_assign_immutable/output.json @@ -0,0 +1,127 @@ +{ + "contracts": { + "C": { + "a": { + "evm": { + "bytecode": { + "ethdebug": { + "contract": { + "definition": { + "source": { + "id": 0 + } + }, + "name": "" + }, + "environment": "create", + "instructions": [ + { + "context": { + "code": { + "range": { + "length": 42, + "offset": 165 + }, + "source": { + "id": 0 + } + } + }, + "offset": 0, + "operation": { + "arguments": [ + "0x1234567890123456789012345678901234567890" + ], + "mnemonic": "PUSH20" + } + }, + { + "context": { + "code": { + "range": { + "length": 1, + "offset": 81 + }, + "source": { + "id": 0 + } + } + }, + "offset": 21, + "operation": { + "mnemonic": "PUSH0" + } + }, + { + "context": { + "code": { + "range": { + "length": 140, + "offset": 68 + }, + "source": { + "id": 0 + } + } + }, + "offset": 22, + "operation": { + "mnemonic": "POP" + } + }, + { + "context": { + "code": { + "range": { + "length": 140, + "offset": 68 + }, + "source": { + "id": 0 + } + } + }, + "offset": 23, + "operation": { + "mnemonic": "POP" + } + }, + { + "context": { + "code": { + "range": { + "length": 180, + "offset": 44 + }, + "source": { + "id": 0 + } + } + }, + "offset": 24, + "operation": { + "mnemonic": "STOP" + } + } + ] + } + } + } + } + } + }, + "ethdebug": { + "compilation": { + "compiler": { + "name": "solc", + "version": "" + }, + "sources": [ + { + "id": 0, + "path": "C" + } + ] + } + } +} diff --git a/test/cmdlineTests/standard_yul_ethdebug_bytecode_ir/output.json b/test/cmdlineTests/standard_yul_ethdebug_bytecode_ir/output.json index c9ab1d8f5e73..c1f6523d5388 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_bytecode_ir/output.json +++ b/test/cmdlineTests/standard_yul_ethdebug_bytecode_ir/output.json @@ -4,9 +4,7 @@ "C_6_deployed": { "evm": { "bytecode": { - "ethdebug": { - "not yet implemented @ MachineAssemblyObject::ethdebug": true - } + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -25,9 +23,5 @@ object \"C_6_deployed\" { } } }, - "ethdebug": { - "sources": [ - "C" - ] - } + "ethdebug": "" } diff --git a/test/cmdlineTests/standard_yul_ethdebug_bytecode_ir/strip-ethdebug b/test/cmdlineTests/standard_yul_ethdebug_bytecode_ir/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/output.json b/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/output.json index d7e3e6be3b40..2f1d22b4df0f 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/output.json +++ b/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/output.json @@ -4,9 +4,7 @@ "C_6_deployed": { "evm": { "bytecode": { - "ethdebug": { - "not yet implemented @ MachineAssemblyObject::ethdebug": true - } + "ethdebug": "" } }, "irOptimized": "/// ethdebug: enabled @@ -27,9 +25,5 @@ object \"C_6_deployed\" { } } }, - "ethdebug": { - "sources": [ - "C" - ] - } + "ethdebug": "" } diff --git a/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/strip-ethdebug b/test/cmdlineTests/standard_yul_ethdebug_bytecode_iroptimized/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/in.yul b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/in.yul index 920aef8e9dc2..d5adfd0c28f4 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/in.yul +++ b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/in.yul @@ -1,17 +1,19 @@ -/// @use-src 0:"input.sol" -object "C_6_deployed" { - code { - /// @src 0:60:101 "contract C {..." +object "object" { + code { mstore(64, 128) - - // f() fun_f_5() - - /// @src 0:77:99 "function f() public {}" function fun_f_5() { sstore(0, 42) } - /// @src 0:60:101 "contract C {..." } -} + object "object_deployed" { + code { + mstore(64, 128) + fun_f_5() + function fun_f_5() { + sstore(0, 42) + } + } + } +} diff --git a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/output.json b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/output.json index 1380c31d7c10..44183e45fdde 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/output.json +++ b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/output.json @@ -1,11 +1,14 @@ { - "errors": [ - { - "component": "general", - "formattedMessage": "\"evm.deployedBytecode.ethdebug\" cannot be used for Yul.", - "message": "\"evm.deployedBytecode.ethdebug\" cannot be used for Yul.", - "severity": "error", - "type": "JSONError" + "contracts": { + "C": { + "object": { + "evm": { + "deployedBytecode": { + "ethdebug": "" + } + } + } } - ] + }, + "ethdebug": "" } diff --git a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/strip-ethdebug b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/args b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/args new file mode 100644 index 000000000000..18532c5a6d3f --- /dev/null +++ b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/args @@ -0,0 +1 @@ +--allow-paths . diff --git a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/in.yul b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/in.yul new file mode 100644 index 000000000000..d5adfd0c28f4 --- /dev/null +++ b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/in.yul @@ -0,0 +1,19 @@ +object "object" { + code { + mstore(64, 128) + fun_f_5() + function fun_f_5() { + sstore(0, 42) + } + } + + object "object_deployed" { + code { + mstore(64, 128) + fun_f_5() + function fun_f_5() { + sstore(0, 42) + } + } + } +} diff --git a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/input.json b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/input.json new file mode 100644 index 000000000000..20779012030d --- /dev/null +++ b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/input.json @@ -0,0 +1,11 @@ +{ + "language": "Yul", + "sources": { + "C": {"urls": ["standard_yul_ethdebug_deployed_bytecode/in.yul"]} + }, + "settings": { + "outputSelection": { + "*": {"*": ["evm.deployedBytecode.ethdebug", "evm.bytecode.ethdebug"]} + } + } +} diff --git a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/output.json b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/output.json new file mode 100644 index 000000000000..6d8064a94f36 --- /dev/null +++ b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/output.json @@ -0,0 +1,17 @@ +{ + "contracts": { + "C": { + "object": { + "evm": { + "bytecode": { + "ethdebug": "" + }, + "deployedBytecode": { + "ethdebug": "" + } + } + } + } + }, + "ethdebug": "" +} diff --git a/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/strip-ethdebug b/test/cmdlineTests/standard_yul_ethdebug_deployed_bytecode_and_bytecode/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_yul_ethdebug_ir/output.json b/test/cmdlineTests/standard_yul_ethdebug_ir/output.json index c9ab1d8f5e73..c1f6523d5388 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_ir/output.json +++ b/test/cmdlineTests/standard_yul_ethdebug_ir/output.json @@ -4,9 +4,7 @@ "C_6_deployed": { "evm": { "bytecode": { - "ethdebug": { - "not yet implemented @ MachineAssemblyObject::ethdebug": true - } + "ethdebug": "" } }, "ir": "/// ethdebug: enabled @@ -25,9 +23,5 @@ object \"C_6_deployed\" { } } }, - "ethdebug": { - "sources": [ - "C" - ] - } + "ethdebug": "" } diff --git a/test/cmdlineTests/standard_yul_ethdebug_ir/strip-ethdebug b/test/cmdlineTests/standard_yul_ethdebug_ir/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/standard_yul_ethdebug_iroptimize/output.json b/test/cmdlineTests/standard_yul_ethdebug_iroptimize/output.json index 47d0008f1eb5..6323c1157973 100644 --- a/test/cmdlineTests/standard_yul_ethdebug_iroptimize/output.json +++ b/test/cmdlineTests/standard_yul_ethdebug_iroptimize/output.json @@ -4,17 +4,11 @@ "C_6_deployed": { "evm": { "bytecode": { - "ethdebug": { - "not yet implemented @ MachineAssemblyObject::ethdebug": true - } + "ethdebug": "" } } } } }, - "ethdebug": { - "sources": [ - "C" - ] - } + "ethdebug": "" } diff --git a/test/cmdlineTests/standard_yul_ethdebug_iroptimize/strip-ethdebug b/test/cmdlineTests/standard_yul_ethdebug_iroptimize/strip-ethdebug new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/cmdlineTests/yul_ethdebug/args b/test/cmdlineTests/yul_ethdebug/args deleted file mode 100644 index a800f5c34e34..000000000000 --- a/test/cmdlineTests/yul_ethdebug/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug --strict-assembly \ No newline at end of file diff --git a/test/cmdlineTests/yul_ethdebug/input.yul b/test/cmdlineTests/yul_ethdebug/input.yul deleted file mode 100644 index acd0b45f5335..000000000000 --- a/test/cmdlineTests/yul_ethdebug/input.yul +++ /dev/null @@ -1,18 +0,0 @@ -object "object" { - code { - let a - let b - { - function z() -> y - { y := calldataload(0) } - a := z() - } - { - function z() -> y - { y := calldataload(0x20) } - b := z() - } - sstore(a, b) - } -} - diff --git a/test/cmdlineTests/yul_ethdebug/output b/test/cmdlineTests/yul_ethdebug/output deleted file mode 100644 index 84ba9317b85b..000000000000 --- a/test/cmdlineTests/yul_ethdebug/output +++ /dev/null @@ -1,7 +0,0 @@ -======= Debug Data (ethdebug/format/info/resources) ======= -{"sources":["yul_ethdebug/input.yul"]} - -======= yul_ethdebug/input.yul (EVM) ======= - -Debug Data (ethdebug/format/program): -{"not yet implemented @ MachineAssemblyObject::ethdebug":true} diff --git a/test/cmdlineTests/yul_ethdebug_ir/args b/test/cmdlineTests/yul_ethdebug_ir/args deleted file mode 100644 index 6194b51b6942..000000000000 --- a/test/cmdlineTests/yul_ethdebug_ir/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug --strict-assembly --ir \ No newline at end of file diff --git a/test/cmdlineTests/yul_ethdebug_ir/err b/test/cmdlineTests/yul_ethdebug_ir/err deleted file mode 100644 index 645f7557ada8..000000000000 --- a/test/cmdlineTests/yul_ethdebug_ir/err +++ /dev/null @@ -1 +0,0 @@ -Error: The following outputs are not supported in assembler mode: --ir. diff --git a/test/cmdlineTests/yul_ethdebug_ir/exit b/test/cmdlineTests/yul_ethdebug_ir/exit deleted file mode 100644 index d00491fd7e5b..000000000000 --- a/test/cmdlineTests/yul_ethdebug_ir/exit +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/test/cmdlineTests/yul_ethdebug_ir/input.yul b/test/cmdlineTests/yul_ethdebug_ir/input.yul deleted file mode 100644 index acd0b45f5335..000000000000 --- a/test/cmdlineTests/yul_ethdebug_ir/input.yul +++ /dev/null @@ -1,18 +0,0 @@ -object "object" { - code { - let a - let b - { - function z() -> y - { y := calldataload(0) } - a := z() - } - { - function z() -> y - { y := calldataload(0x20) } - b := z() - } - sstore(a, b) - } -} - diff --git a/test/cmdlineTests/yul_ethdebug_iroptimized/args b/test/cmdlineTests/yul_ethdebug_iroptimized/args deleted file mode 100644 index 2063d860c504..000000000000 --- a/test/cmdlineTests/yul_ethdebug_iroptimized/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug --strict-assembly --ir-optimized \ No newline at end of file diff --git a/test/cmdlineTests/yul_ethdebug_iroptimized/input.yul b/test/cmdlineTests/yul_ethdebug_iroptimized/input.yul deleted file mode 100644 index acd0b45f5335..000000000000 --- a/test/cmdlineTests/yul_ethdebug_iroptimized/input.yul +++ /dev/null @@ -1,18 +0,0 @@ -object "object" { - code { - let a - let b - { - function z() -> y - { y := calldataload(0) } - a := z() - } - { - function z() -> y - { y := calldataload(0x20) } - b := z() - } - sstore(a, b) - } -} - diff --git a/test/cmdlineTests/yul_ethdebug_iroptimized/output b/test/cmdlineTests/yul_ethdebug_iroptimized/output deleted file mode 100644 index e2f0ed7f97f2..000000000000 --- a/test/cmdlineTests/yul_ethdebug_iroptimized/output +++ /dev/null @@ -1,26 +0,0 @@ -======= Debug Data (ethdebug/format/info/resources) ======= -{"sources":["yul_ethdebug_iroptimized/input.yul"]} - -======= yul_ethdebug_iroptimized/input.yul (EVM) ======= - -Pretty printed source: -/// ethdebug: enabled -object "object" { - code { - { - let a - let b - a := z() - b := z_1() - sstore(a, b) - } - function z() -> y - { y := calldataload(0) } - function z_1() -> y - { y := calldataload(0x20) } - } -} - - -Debug Data (ethdebug/format/program): -{"not yet implemented @ MachineAssemblyObject::ethdebug":true} diff --git a/test/cmdlineTests/yul_ethdebug_optimize/args b/test/cmdlineTests/yul_ethdebug_optimize/args deleted file mode 100644 index fd081fdaf6d3..000000000000 --- a/test/cmdlineTests/yul_ethdebug_optimize/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug --strict-assembly --optimize \ No newline at end of file diff --git a/test/cmdlineTests/yul_ethdebug_optimize/err b/test/cmdlineTests/yul_ethdebug_optimize/err deleted file mode 100644 index 7d66138755f9..000000000000 --- a/test/cmdlineTests/yul_ethdebug_optimize/err +++ /dev/null @@ -1 +0,0 @@ -Error: Optimization (using --optimize) is not yet supported with ethdebug. diff --git a/test/cmdlineTests/yul_ethdebug_optimize/exit b/test/cmdlineTests/yul_ethdebug_optimize/exit deleted file mode 100644 index d00491fd7e5b..000000000000 --- a/test/cmdlineTests/yul_ethdebug_optimize/exit +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/test/cmdlineTests/yul_ethdebug_optimize/input.yul b/test/cmdlineTests/yul_ethdebug_optimize/input.yul deleted file mode 100644 index acd0b45f5335..000000000000 --- a/test/cmdlineTests/yul_ethdebug_optimize/input.yul +++ /dev/null @@ -1,18 +0,0 @@ -object "object" { - code { - let a - let b - { - function z() -> y - { y := calldataload(0) } - a := z() - } - { - function z() -> y - { y := calldataload(0x20) } - b := z() - } - sstore(a, b) - } -} - diff --git a/test/cmdlineTests/yul_ethdebug_optimize_iroptimized/args b/test/cmdlineTests/yul_ethdebug_optimize_iroptimized/args deleted file mode 100644 index 715f3fb4848b..000000000000 --- a/test/cmdlineTests/yul_ethdebug_optimize_iroptimized/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug --strict-assembly --optimize --ir-optimized \ No newline at end of file diff --git a/test/cmdlineTests/yul_ethdebug_optimize_iroptimized/err b/test/cmdlineTests/yul_ethdebug_optimize_iroptimized/err deleted file mode 100644 index 7d66138755f9..000000000000 --- a/test/cmdlineTests/yul_ethdebug_optimize_iroptimized/err +++ /dev/null @@ -1 +0,0 @@ -Error: Optimization (using --optimize) is not yet supported with ethdebug. diff --git a/test/cmdlineTests/yul_ethdebug_optimize_iroptimized/exit b/test/cmdlineTests/yul_ethdebug_optimize_iroptimized/exit deleted file mode 100644 index d00491fd7e5b..000000000000 --- a/test/cmdlineTests/yul_ethdebug_optimize_iroptimized/exit +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/test/cmdlineTests/yul_ethdebug_optimize_iroptimized/input.yul b/test/cmdlineTests/yul_ethdebug_optimize_iroptimized/input.yul deleted file mode 100644 index acd0b45f5335..000000000000 --- a/test/cmdlineTests/yul_ethdebug_optimize_iroptimized/input.yul +++ /dev/null @@ -1,18 +0,0 @@ -object "object" { - code { - let a - let b - { - function z() -> y - { y := calldataload(0) } - a := z() - } - { - function z() -> y - { y := calldataload(0x20) } - b := z() - } - sstore(a, b) - } -} - diff --git a/test/cmdlineTests/yul_ethdebug_runtime/args b/test/cmdlineTests/yul_ethdebug_runtime/args deleted file mode 100644 index 3bedf2d9e437..000000000000 --- a/test/cmdlineTests/yul_ethdebug_runtime/args +++ /dev/null @@ -1 +0,0 @@ ---ethdebug-runtime --strict-assembly \ No newline at end of file diff --git a/test/cmdlineTests/yul_ethdebug_runtime/err b/test/cmdlineTests/yul_ethdebug_runtime/err deleted file mode 100644 index ed5894632c43..000000000000 --- a/test/cmdlineTests/yul_ethdebug_runtime/err +++ /dev/null @@ -1 +0,0 @@ -Error: The following outputs are not supported in assembler mode: --ethdebug-runtime. diff --git a/test/cmdlineTests/yul_ethdebug_runtime/exit b/test/cmdlineTests/yul_ethdebug_runtime/exit deleted file mode 100644 index d00491fd7e5b..000000000000 --- a/test/cmdlineTests/yul_ethdebug_runtime/exit +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/test/cmdlineTests/yul_ethdebug_runtime/input.yul b/test/cmdlineTests/yul_ethdebug_runtime/input.yul deleted file mode 100644 index acd0b45f5335..000000000000 --- a/test/cmdlineTests/yul_ethdebug_runtime/input.yul +++ /dev/null @@ -1,18 +0,0 @@ -object "object" { - code { - let a - let b - { - function z() -> y - { y := calldataload(0) } - a := z() - } - { - function z() -> y - { y := calldataload(0x20) } - b := z() - } - sstore(a, b) - } -} - diff --git a/test/libevmasm/Assembler.cpp b/test/libevmasm/Assembler.cpp index 3a6383002dc3..6a41f7a7394c 100644 --- a/test/libevmasm/Assembler.cpp +++ b/test/libevmasm/Assembler.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -425,6 +426,46 @@ BOOST_AUTO_TEST_CASE(subobject_encode_decode) BOOST_CHECK(assembly.decodeSubPath(assembly.encodeSubPath(subPath)) == subPath); } +BOOST_AUTO_TEST_CASE(ethdebug_program_last_instruction_with_immediate_arguments) +{ + EVMVersion evmVersion = solidity::test::CommonOptions::get().evmVersion(); + { + Assembly assembly{evmVersion, true, {}, {}}; + assembly.append(AssemblyItem{0x11223344}); + LinkerObject output = assembly.assemble(); + + Json const program = ethdebug::program("", 0, &assembly, output); + BOOST_REQUIRE(program["instructions"].size() == 1); + BOOST_REQUIRE(program["instructions"][0]["operation"]["mnemonic"] == "PUSH4"); + BOOST_REQUIRE(program["instructions"][0]["operation"]["arguments"][0] == "0x11223344"); + } + { + Assembly assembly{evmVersion, true, {}, {}}; + assembly.append(AssemblyItem{Instruction::PUSH0}); + assembly.append(AssemblyItem{0x1122334455}); + LinkerObject output = assembly.assemble(); + + Json const program = ethdebug::program("", 0, &assembly, output); + BOOST_REQUIRE(program["instructions"].size() == 2); + BOOST_REQUIRE(program["instructions"][0]["operation"]["mnemonic"] == "PUSH0"); + BOOST_REQUIRE(!program["instructions"][0]["operation"].contains("arguments")); + BOOST_REQUIRE(program["instructions"][1]["operation"]["mnemonic"] == "PUSH5"); + BOOST_REQUIRE(program["instructions"][1]["operation"]["arguments"][0] == "0x1122334455"); + } +} + +BOOST_AUTO_TEST_CASE(ethdebug_resources) +{ + Json const resources = ethdebug::resources({"sourceA", "sourceB"}, "version1"); + BOOST_REQUIRE(resources["compilation"]["compiler"]["name"] == "solc"); + BOOST_REQUIRE(resources["compilation"]["compiler"]["version"] == "version1"); + BOOST_REQUIRE(resources["compilation"]["sources"].size() == 2); + BOOST_REQUIRE(resources["compilation"]["sources"][0]["id"] == 0); + BOOST_REQUIRE(resources["compilation"]["sources"][0]["path"] == "sourceA"); + BOOST_REQUIRE(resources["compilation"]["sources"][1]["id"] == 1); + BOOST_REQUIRE(resources["compilation"]["sources"][1]["path"] == "sourceB"); +} + BOOST_AUTO_TEST_SUITE_END() } // end namespaces diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index ec3c7db1c847..b17f566613a1 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -2232,6 +2233,46 @@ BOOST_AUTO_TEST_CASE(ethdebug_ethdebug_output) } } +BOOST_DATA_TEST_CASE(ethdebug_output_instructions_smoketest, boost::unit_test::data::make({"deployedBytecode", "bytecode"}), bytecodeType) +{ + frontend::StandardCompiler compiler; + Json result = compiler.compile(generateStandardJson(true, {}, Json::array({std::string("evm.") + bytecodeType + ".ethdebug"}))); + BOOST_REQUIRE(result["contracts"]["fileA"]["C"]["evm"][bytecodeType].contains("ethdebug")); + bool creation = std::string(bytecodeType) == "bytecode"; + Json ethdebugInstructionsToCheck = result["contracts"]["fileA"]["C"]["evm"][bytecodeType]["ethdebug"]; + BOOST_REQUIRE(ethdebugInstructionsToCheck["contract"]["definition"]["source"]["id"] == 0); + BOOST_REQUIRE(ethdebugInstructionsToCheck["contract"]["name"] == "C"); + BOOST_REQUIRE(ethdebugInstructionsToCheck["environment"] == (creation ? "create" : "call")); + BOOST_REQUIRE(ethdebugInstructionsToCheck["instructions"].is_array()); + for (auto const& instruction: ethdebugInstructionsToCheck["instructions"]) + { + BOOST_REQUIRE(instruction.contains("offset")); + BOOST_REQUIRE(instruction.contains("operation")); + BOOST_REQUIRE(instruction["operation"].contains("mnemonic")); + BOOST_REQUIRE(instruction["context"]["code"]["range"].contains("length")); + BOOST_REQUIRE(instruction["context"]["code"]["range"].contains("offset")); + BOOST_REQUIRE(instruction["context"]["code"]["source"].contains("id")); + std::string mnemonic = instruction["operation"]["mnemonic"]; + if (mnemonic.find("PUSH") != std::string::npos) + { + size_t bytesToPush = boost::lexical_cast(mnemonic.substr(4)); + if (bytesToPush > 0) + { + BOOST_REQUIRE(instruction["operation"].contains("arguments")); + BOOST_REQUIRE(instruction["operation"]["arguments"].is_array()); + BOOST_REQUIRE(instruction["operation"]["arguments"].size() == 1); + std::string argument = instruction["operation"]["arguments"][0]; + BOOST_REQUIRE(argument.length() % 2 == 0); + BOOST_REQUIRE(bytesToPush == (argument.length() - 2) / 2); // remove "0x" and calculate actual byte size from hex. + } + else + BOOST_REQUIRE(!instruction["operation"].contains("arguments")); + } + else + BOOST_REQUIRE(!instruction["operation"].contains("arguments")); + } +} + BOOST_AUTO_TEST_SUITE_END() } // end namespaces