diff --git a/liblangutil/DebugInfoSelection.cpp b/liblangutil/DebugInfoSelection.cpp index ad0b615c1c1e..cd5daa66ea09 100644 --- a/liblangutil/DebugInfoSelection.cpp +++ b/liblangutil/DebugInfoSelection.cpp @@ -39,6 +39,7 @@ DebugInfoSelection const DebugInfoSelection::All(bool _value) noexcept DebugInfoSelection result; for (bool DebugInfoSelection::* member: componentMap() | ranges::views::values) result.*member = _value; + result.ethdebug = false; return result; } diff --git a/liblangutil/DebugInfoSelection.h b/liblangutil/DebugInfoSelection.h index 3a9432de6d02..e4871e0f6798 100644 --- a/liblangutil/DebugInfoSelection.h +++ b/liblangutil/DebugInfoSelection.h @@ -72,6 +72,7 @@ struct DebugInfoSelection {"location", &DebugInfoSelection::location}, {"snippet", &DebugInfoSelection::snippet}, {"ast-id", &DebugInfoSelection::astID}, + {"ethdebug", &DebugInfoSelection::ethdebug}, }; return components; } @@ -79,6 +80,7 @@ struct DebugInfoSelection bool location = false; ///< Include source location. E.g. `@src 3:50:100` bool snippet = false; ///< Include source code snippet next to location. E.g. `@src 3:50:100 "contract C {..."` bool astID = false; ///< Include ID of the Solidity AST node. E.g. `@ast-id 15` + bool ethdebug = false; ///< Include ethdebug related debug information. }; std::ostream& operator<<(std::ostream& _stream, DebugInfoSelection const& _selection); diff --git a/libsolidity/codegen/ir/IRGenerator.cpp b/libsolidity/codegen/ir/IRGenerator.cpp index bf0f6d5c0f25..55fe0f936490 100644 --- a/libsolidity/codegen/ir/IRGenerator.cpp +++ b/libsolidity/codegen/ir/IRGenerator.cpp @@ -118,7 +118,7 @@ std::string IRGenerator::generate( ); }; - Whiskers t(R"( + Whiskers t(R"(/// ethdebug: enabled /// @use-src object "" { code { @@ -155,6 +155,7 @@ std::string IRGenerator::generate( for (VariableDeclaration const* var: ContractType(_contract).immutableVariables()) m_context.registerImmutableVariable(*var); + t("isEthdebugEnabled", m_context.debugInfoSelection().ethdebug); t("CreationObject", IRNames::creationObject(_contract)); t("sourceLocationCommentCreation", dispenseLocationComment(_contract)); t("library", _contract.isLibrary()); diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 566feb21b171..f191acae1ee4 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -1486,7 +1486,8 @@ void CompilerStack::generateIR(ContractDefinition const& _contract) YulStack stack = parseYul(compiledContract.yulIR); compiledContract.yulIRAst = stack.astJson(); stack.optimize(); - compiledContract.yulIROptimized = stack.print(this); + compiledContract.yulIROptimized = m_debugInfoSelection.ethdebug ? "/// ethdebug: enabled\n" : ""; + compiledContract.yulIROptimized += stack.print(this); } { // Optimizer does not maintain correct native source locations in the AST. diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index b908ab0cc6fd..3e7ca6fe52d5 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -1324,6 +1324,13 @@ Json StandardCompiler::compileSolidity(StandardCompiler::InputsAndSettings _inpu Json errors = std::move(_inputsAndSettings.errors); + if (_inputsAndSettings.debugInfoSelection.has_value() && + _inputsAndSettings.debugInfoSelection->ethdebug && + !(isIRRequested(_inputsAndSettings.outputSelection) || _inputsAndSettings.viaIR) + ) + errors.emplace_back(formatError(Error::Type::FatalError, "general", "debug.debugInfo setting for ethdebug only valid, if 'ir', 'irAst', 'irOptimized' or 'irOptimizedAst' where requested.")); + + bool const binariesRequested = isBinaryRequested(_inputsAndSettings.outputSelection); try @@ -1429,7 +1436,7 @@ Json StandardCompiler::compileSolidity(StandardCompiler::InputsAndSettings _inpu Json output; if (errors.size() > 0) - output["errors"] = std::move(errors); + output["errors"] = std::move(errors); if (!compilerStack.unhandledSMTLib2Queries().empty()) for (std::string const& query: compilerStack.unhandledSMTLib2Queries()) @@ -1482,6 +1489,10 @@ Json StandardCompiler::compileSolidity(StandardCompiler::InputsAndSettings _inpu if (compilationSuccess && isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "irOptimizedAst", wildcardMatchesExperimental)) contractData["irOptimizedAst"] = compilerStack.yulIROptimizedAst(contractName); + // ethdebug + if (compilationSuccess && isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "ethdebug", wildcardMatchesExperimental)) + contractData["ethdebug"] = Json::object(); + // EVM Json evmData; if (compilationSuccess && isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "evm.assembly", wildcardMatchesExperimental)) diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 367434c93f2a..f7560e92acfc 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -133,6 +133,7 @@ static std::string const g_strSignatureHashes = "hashes"; static std::string const g_strSourceList = "sourceList"; static std::string const g_strSources = "sources"; static std::string const g_strSrcMap = "srcmap"; +static std::string const g_strEthdebug = "ethdebug"; static std::string const g_strSrcMapRuntime = "srcmap-runtime"; static std::string const g_strStorageLayout = "storage-layout"; static std::string const g_strVersion = "version"; @@ -995,6 +996,8 @@ void CommandLineInterface::handleCombinedJSON() contractData[g_strFunDebugRuntime] = StandardCompiler::formatFunctionDebugData( m_assemblyStack->runtimeObject(contractName).functionDebugData ); + if (m_options.compiler.combinedJsonRequests->ethdebug) + contractData[g_strEthdebug] = Json::object(); } } diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index 2697f7ebd09f..1b900d72d483 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -637,7 +637,12 @@ General Information)").c_str(), po::value()->default_value(util::toString(DebugInfoSelection::Default())), ("Debug info components to be included in the produced EVM assembly and Yul code. " "Value can be all, none or a comma-separated list containing one or more of the " - "following components: " + util::joinHumanReadable(DebugInfoSelection::componentMap() | ranges::views::keys) + ".").c_str() + "following components: " + + util::joinHumanReadable( + DebugInfoSelection::componentMap() | ranges::views::keys | + ranges::views::filter([](std::string const& key) { return key != "ethdebug"; }) | + ranges::to() + ) + ".").c_str() ) ( g_strStopAfter.c_str(), @@ -771,7 +776,13 @@ General Information)").c_str(), ) ( g_strCombinedJson.c_str(), - po::value()->value_name(util::joinHumanReadable(CombinedJsonRequests::componentMap() | ranges::views::keys, ",")), + po::value()->value_name( + util::joinHumanReadable( + CombinedJsonRequests::componentMap() | ranges::views::keys | + ranges::views::filter([](std::string const& key) { return key != "ethdebug"; }) | + ranges::to(), "," + ) + ), "Output a single json document containing the specified information." ) ; @@ -1439,6 +1450,19 @@ void CommandLineParser::processArgs() m_options.input.mode == InputMode::CompilerWithASTImport || m_options.input.mode == InputMode::EVMAssemblerJSON ); + + if (m_options.output.debugInfoSelection.has_value() && m_options.output.debugInfoSelection->ethdebug && + !(m_options.output.viaIR || m_options.compiler.outputs.ir || m_options.compiler.outputs.irOptimized) + ) + solThrow(CommandLineValidationError, + "--debug-info ethdebug can only be used with --" + g_strViaIR + ", --" + CompilerOutputs::componentName(&CompilerOutputs::ir) + + " and/or --" + CompilerOutputs::componentName(&CompilerOutputs::irOptimized) + "." + ); + + if (m_options.compiler.combinedJsonRequests.has_value() && m_options.compiler.combinedJsonRequests->ethdebug && + !(m_options.output.debugInfoSelection.has_value() && m_options.output.debugInfoSelection->ethdebug) + ) + solThrow(CommandLineValidationError, "--combined-json ethdebug can only be used together with --debug-info ethdebug."); } void CommandLineParser::parseCombinedJsonOption() diff --git a/solc/CommandLineParser.h b/solc/CommandLineParser.h index b95973562e51..c731537754fd 100644 --- a/solc/CommandLineParser.h +++ b/solc/CommandLineParser.h @@ -135,6 +135,7 @@ struct CombinedJsonRequests {"devdoc", &CombinedJsonRequests::natspecDev}, {"userdoc", &CombinedJsonRequests::natspecUser}, {"ast", &CombinedJsonRequests::ast}, + {"ethdebug", &CombinedJsonRequests::ethdebug}, }; return components; } @@ -156,6 +157,7 @@ struct CombinedJsonRequests bool natspecDev = false; bool natspecUser = false; bool ast = false; + bool ethdebug = false; }; struct CommandLineOptions diff --git a/test/cmdlineTests/combined_json_ethdebug_with_ethdebug_debug_info/args b/test/cmdlineTests/combined_json_ethdebug_with_ethdebug_debug_info/args new file mode 100644 index 000000000000..5829a7cd71c3 --- /dev/null +++ b/test/cmdlineTests/combined_json_ethdebug_with_ethdebug_debug_info/args @@ -0,0 +1 @@ +--combined-json ethdebug --pretty-json --json-indent 3 diff --git a/test/cmdlineTests/combined_json_ethdebug_with_ethdebug_debug_info/err b/test/cmdlineTests/combined_json_ethdebug_with_ethdebug_debug_info/err new file mode 100644 index 000000000000..d14cb3461102 --- /dev/null +++ b/test/cmdlineTests/combined_json_ethdebug_with_ethdebug_debug_info/err @@ -0,0 +1 @@ +Error: --combined-json ethdebug can only be used together with --debug-info ethdebug. diff --git a/test/cmdlineTests/combined_json_ethdebug_with_ethdebug_debug_info/exit b/test/cmdlineTests/combined_json_ethdebug_with_ethdebug_debug_info/exit new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/test/cmdlineTests/combined_json_ethdebug_with_ethdebug_debug_info/exit @@ -0,0 +1 @@ +1 diff --git a/test/cmdlineTests/combined_json_ethdebug_with_ethdebug_debug_info/input.sol b/test/cmdlineTests/combined_json_ethdebug_with_ethdebug_debug_info/input.sol new file mode 100644 index 000000000000..625af568280c --- /dev/null +++ b/test/cmdlineTests/combined_json_ethdebug_with_ethdebug_debug_info/input.sol @@ -0,0 +1,3 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.0; +contract C {} diff --git a/test/cmdlineTests/combined_json_ethdebug_without_ethdebug_debug_info/args b/test/cmdlineTests/combined_json_ethdebug_without_ethdebug_debug_info/args new file mode 100644 index 000000000000..d17da0440233 --- /dev/null +++ b/test/cmdlineTests/combined_json_ethdebug_without_ethdebug_debug_info/args @@ -0,0 +1 @@ +--via-ir --debug-info ethdebug --combined-json ethdebug --pretty-json --json-indent 3 diff --git a/test/cmdlineTests/combined_json_ethdebug_without_ethdebug_debug_info/input.sol b/test/cmdlineTests/combined_json_ethdebug_without_ethdebug_debug_info/input.sol new file mode 100644 index 000000000000..625af568280c --- /dev/null +++ b/test/cmdlineTests/combined_json_ethdebug_without_ethdebug_debug_info/input.sol @@ -0,0 +1,3 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.0; +contract C {} diff --git a/test/cmdlineTests/combined_json_ethdebug_without_ethdebug_debug_info/output b/test/cmdlineTests/combined_json_ethdebug_without_ethdebug_debug_info/output new file mode 100644 index 000000000000..6c534ba5467b --- /dev/null +++ b/test/cmdlineTests/combined_json_ethdebug_without_ethdebug_debug_info/output @@ -0,0 +1,8 @@ +{ + "contracts": { + "combined_json_ethdebug_without_ethdebug_debug_info/input.sol:C": { + "ethdebug": {} + } + }, + "version": "" +} diff --git a/test/cmdlineTests/debug_info_ethdebug_no_ir/args b/test/cmdlineTests/debug_info_ethdebug_no_ir/args new file mode 100644 index 000000000000..7b4e521b02b8 --- /dev/null +++ b/test/cmdlineTests/debug_info_ethdebug_no_ir/args @@ -0,0 +1 @@ +--debug-info ethdebug diff --git a/test/cmdlineTests/debug_info_ethdebug_no_ir/err b/test/cmdlineTests/debug_info_ethdebug_no_ir/err new file mode 100644 index 000000000000..369299681d07 --- /dev/null +++ b/test/cmdlineTests/debug_info_ethdebug_no_ir/err @@ -0,0 +1 @@ +Error: --debug-info ethdebug can only be used with --via-ir, --ir and/or --ir-optimized. diff --git a/test/cmdlineTests/debug_info_ethdebug_no_ir/exit b/test/cmdlineTests/debug_info_ethdebug_no_ir/exit new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/test/cmdlineTests/debug_info_ethdebug_no_ir/exit @@ -0,0 +1 @@ +1 diff --git a/test/cmdlineTests/debug_info_ethdebug_no_ir/input.sol b/test/cmdlineTests/debug_info_ethdebug_no_ir/input.sol new file mode 100644 index 000000000000..415509ef9aef --- /dev/null +++ b/test/cmdlineTests/debug_info_ethdebug_no_ir/input.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +pragma solidity >=0.0; + +contract C { + function f() public {} +} diff --git a/test/cmdlineTests/debug_info_in_yul_ethdebug/args b/test/cmdlineTests/debug_info_in_yul_ethdebug/args new file mode 100644 index 000000000000..af87a8c5aa81 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_ethdebug/args @@ -0,0 +1 @@ +--ir --debug-info ethdebug diff --git a/test/cmdlineTests/debug_info_in_yul_ethdebug/input.sol b/test/cmdlineTests/debug_info_in_yul_ethdebug/input.sol new file mode 100644 index 000000000000..415509ef9aef --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_ethdebug/input.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +pragma solidity >=0.0; + +contract C { + function f() public {} +} diff --git a/test/cmdlineTests/debug_info_in_yul_ethdebug/output b/test/cmdlineTests/debug_info_in_yul_ethdebug/output new file mode 100644 index 000000000000..601fe824288b --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_ethdebug/output @@ -0,0 +1,112 @@ +IR: +/// ethdebug: enabled +/// @use-src 0:"debug_info_in_yul_ethdebug/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_in_yul_ethdebug/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"" + } + +} diff --git a/test/cmdlineTests/debug_info_in_yul_ethdebug_optimized/args b/test/cmdlineTests/debug_info_in_yul_ethdebug_optimized/args new file mode 100644 index 000000000000..7d714eba9a13 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_ethdebug_optimized/args @@ -0,0 +1 @@ +--ir-optimized --optimize --debug-info ethdebug diff --git a/test/cmdlineTests/debug_info_in_yul_ethdebug_optimized/input.sol b/test/cmdlineTests/debug_info_in_yul_ethdebug_optimized/input.sol new file mode 100644 index 000000000000..415509ef9aef --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_ethdebug_optimized/input.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +pragma solidity >=0.0; + +contract C { + function f() public {} +} diff --git a/test/cmdlineTests/debug_info_in_yul_ethdebug_optimized/output b/test/cmdlineTests/debug_info_in_yul_ethdebug_optimized/output new file mode 100644 index 000000000000..dd7d13d0d600 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_ethdebug_optimized/output @@ -0,0 +1,35 @@ +Optimized IR: +/// ethdebug: enabled +/// @use-src 0:"debug_info_in_yul_ethdebug_optimized/input.sol" +object "C_6" { + code { + { + /// @src 0:60:101 + let _1 := memoryguard(0x80) + mstore(64, _1) + if callvalue() { revert(0, 0) } + let _2 := datasize("C_6_deployed") + codecopy(_1, dataoffset("C_6_deployed"), _2) + return(_1, _2) + } + } + /// @use-src 0:"debug_info_in_yul_ethdebug_optimized/input.sol" + object "C_6_deployed" { + code { + { + /// @src 0:60:101 + if iszero(lt(calldatasize(), 4)) + { + if eq(0x26121ff0, shr(224, calldataload(0))) + { + if callvalue() { revert(0, 0) } + if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } + return(0, 0) + } + } + revert(0, 0) + } + } + data ".metadata" hex"" + } +} diff --git a/test/cmdlineTests/standard_debug_info_ethdebug_no_ir/args b/test/cmdlineTests/standard_debug_info_ethdebug_no_ir/args new file mode 100644 index 000000000000..18532c5a6d3f --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_ethdebug_no_ir/args @@ -0,0 +1 @@ +--allow-paths . diff --git a/test/cmdlineTests/standard_debug_info_ethdebug_no_ir/in.sol b/test/cmdlineTests/standard_debug_info_ethdebug_no_ir/in.sol new file mode 100644 index 000000000000..415509ef9aef --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_ethdebug_no_ir/in.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +pragma solidity >=0.0; + +contract C { + function f() public {} +} diff --git a/test/cmdlineTests/standard_debug_info_ethdebug_no_ir/input.json b/test/cmdlineTests/standard_debug_info_ethdebug_no_ir/input.json new file mode 100644 index 000000000000..5d61d844c85f --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_ethdebug_no_ir/input.json @@ -0,0 +1,12 @@ +{ + "language": "Solidity", + "sources": { + "C": {"urls": ["standard_debug_info_in_yul_ethdebug_optimized/in.sol"]} + }, + "settings": { + "debug": {"debugInfo": ["ethdebug"]}, + "outputSelection": { + "*": {"*": ["asm"]} + } + } +} diff --git a/test/cmdlineTests/standard_debug_info_ethdebug_no_ir/output.json b/test/cmdlineTests/standard_debug_info_ethdebug_no_ir/output.json new file mode 100644 index 000000000000..9b9e13463527 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_ethdebug_no_ir/output.json @@ -0,0 +1,16 @@ +{ + "errors": [ + { + "component": "general", + "formattedMessage": "debug.debugInfo setting for ethdebug only valid, if 'ir', 'irAst', 'irOptimized' or 'irOptimizedAst' where requested.", + "message": "debug.debugInfo setting for ethdebug only valid, if 'ir', 'irAst', 'irOptimized' or 'irOptimizedAst' where requested.", + "severity": "error", + "type": "FatalError" + } + ], + "sources": { + "C": { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_ethdebug/args b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug/args new file mode 100644 index 000000000000..18532c5a6d3f --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug/args @@ -0,0 +1 @@ +--allow-paths . diff --git a/test/cmdlineTests/standard_debug_info_in_yul_ethdebug/in.sol b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug/in.sol new file mode 100644 index 000000000000..415509ef9aef --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug/in.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +pragma solidity >=0.0; + +contract C { + function f() public {} +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_ethdebug/input.json b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug/input.json new file mode 100644 index 000000000000..eca9b2d92f66 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug/input.json @@ -0,0 +1,13 @@ +{ + "language": "Solidity", + "sources": { + "C": {"urls": ["standard_debug_info_in_yul_ethdebug/in.sol"]} + }, + "settings": { + "debug": {"debugInfo": ["ethdebug"]}, + "optimizer": {"enabled": false}, + "outputSelection": { + "*": {"*": ["ir"]} + } + } +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_ethdebug/output.json b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug/output.json new file mode 100644 index 000000000000..1d46ed584a8a --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug/output.json @@ -0,0 +1,126 @@ +{ + "contracts": { + "C": { + "C": { + "ir": "/// ethdebug: enabled +/// @use-src 0:\"C\" +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:\"C\" + 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\"\" + } + +} + +" + } + } + }, + "sources": { + "C": { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_ethdebug_optimized/args b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug_optimized/args new file mode 100644 index 000000000000..18532c5a6d3f --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug_optimized/args @@ -0,0 +1 @@ +--allow-paths . diff --git a/test/cmdlineTests/standard_debug_info_in_yul_ethdebug_optimized/in.sol b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug_optimized/in.sol new file mode 100644 index 000000000000..415509ef9aef --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug_optimized/in.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +pragma solidity >=0.0; + +contract C { + function f() public {} +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_ethdebug_optimized/input.json b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug_optimized/input.json new file mode 100644 index 000000000000..410c03bd1a7e --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug_optimized/input.json @@ -0,0 +1,13 @@ +{ + "language": "Solidity", + "sources": { + "C": {"urls": ["standard_debug_info_in_yul_ethdebug_optimized/in.sol"]} + }, + "settings": { + "debug": {"debugInfo": ["ethdebug"]}, + "optimizer": {"enabled": true}, + "outputSelection": { + "*": {"*": ["irOptimized"]} + } + } +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_ethdebug_optimized/output.json b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug_optimized/output.json new file mode 100644 index 000000000000..af2fbde3dadd --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_ethdebug_optimized/output.json @@ -0,0 +1,48 @@ +{ + "contracts": { + "C": { + "C": { + "irOptimized": "/// ethdebug: enabled +/// @use-src 0:\"C\" +object \"C_6\" { + code { + { + /// @src 0:60:101 + let _1 := memoryguard(0x80) + mstore(64, _1) + if callvalue() { revert(0, 0) } + let _2 := datasize(\"C_6_deployed\") + codecopy(_1, dataoffset(\"C_6_deployed\"), _2) + return(_1, _2) + } + } + /// @use-src 0:\"C\" + object \"C_6_deployed\" { + code { + { + /// @src 0:60:101 + if iszero(lt(calldatasize(), 4)) + { + if eq(0x26121ff0, shr(224, calldataload(0))) + { + if callvalue() { revert(0, 0) } + if slt(add(calldatasize(), not(3)), 0) { revert(0, 0) } + return(0, 0) + } + } + revert(0, 0) + } + } + data \".metadata\" hex\"\" + } +} +" + } + } + }, + "sources": { + "C": { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_ethdebug_requested_with_ethdebug_debug_info/input.json b/test/cmdlineTests/standard_ethdebug_requested_with_ethdebug_debug_info/input.json new file mode 100644 index 000000000000..306ab2bd9b78 --- /dev/null +++ b/test/cmdlineTests/standard_ethdebug_requested_with_ethdebug_debug_info/input.json @@ -0,0 +1,19 @@ +{ + "language": "Solidity", + "sources": + { + "A": + { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; pragma abicoder v2; contract C { function f() public pure {} }" + } + }, + "settings": + { + "viaIR": true, + "debug": {"debugInfo": ["ethdebug"]}, + "outputSelection": + { + "*": { "*": ["ethdebug", "evm.bytecode.object"] } + } + } +} diff --git a/test/cmdlineTests/standard_ethdebug_requested_with_ethdebug_debug_info/output.json b/test/cmdlineTests/standard_ethdebug_requested_with_ethdebug_debug_info/output.json new file mode 100644 index 000000000000..5a38c22492d0 --- /dev/null +++ b/test/cmdlineTests/standard_ethdebug_requested_with_ethdebug_debug_info/output.json @@ -0,0 +1,19 @@ +{ + "contracts": { + "A": { + "C": { + "ethdebug": {}, + "evm": { + "bytecode": { + "object": "" + } + } + } + } + }, + "sources": { + "A": { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_ethdebug_requested_without_ethdebug_debug_info/input.json b/test/cmdlineTests/standard_ethdebug_requested_without_ethdebug_debug_info/input.json new file mode 100644 index 000000000000..12dd728f614b --- /dev/null +++ b/test/cmdlineTests/standard_ethdebug_requested_without_ethdebug_debug_info/input.json @@ -0,0 +1,17 @@ +{ + "language": "Solidity", + "sources": + { + "A": + { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; pragma abicoder v2; contract C { function f() public pure {} }" + } + }, + "settings": + { + "outputSelection": + { + "*": { "*": ["ethdebug", "evm.bytecode.object"] } + } + } +} diff --git a/test/cmdlineTests/standard_ethdebug_requested_without_ethdebug_debug_info/output.json b/test/cmdlineTests/standard_ethdebug_requested_without_ethdebug_debug_info/output.json new file mode 100644 index 000000000000..5a38c22492d0 --- /dev/null +++ b/test/cmdlineTests/standard_ethdebug_requested_without_ethdebug_debug_info/output.json @@ -0,0 +1,19 @@ +{ + "contracts": { + "A": { + "C": { + "ethdebug": {}, + "evm": { + "bytecode": { + "object": "" + } + } + } + } + }, + "sources": { + "A": { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_ethdebug_requested_without_requesting_binary/input.json b/test/cmdlineTests/standard_ethdebug_requested_without_requesting_binary/input.json new file mode 100644 index 000000000000..dd81ab8c40c1 --- /dev/null +++ b/test/cmdlineTests/standard_ethdebug_requested_without_requesting_binary/input.json @@ -0,0 +1,19 @@ +{ + "language": "Solidity", + "sources": + { + "A": + { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; pragma abicoder v2; contract C { function f() public pure {} }" + } + }, + "settings": + { + "viaIR": true, + "debug": {"debugInfo": ["ethdebug"]}, + "outputSelection": + { + "*": { "*": ["ethdebug"] } + } + } +} diff --git a/test/cmdlineTests/standard_ethdebug_requested_without_requesting_binary/output.json b/test/cmdlineTests/standard_ethdebug_requested_without_requesting_binary/output.json new file mode 100644 index 000000000000..f047ff70a9eb --- /dev/null +++ b/test/cmdlineTests/standard_ethdebug_requested_without_requesting_binary/output.json @@ -0,0 +1,7 @@ +{ + "sources": { + "A": { + "id": 0 + } + } +}