diff --git a/Changelog.md b/Changelog.md index 9dd650599..24b326a12 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,8 +6,10 @@ Language Features: Compiler Features: * Commandline Interface: Accept nested brackets in step sequences passed to ``--yul-optimizations``. + * Commandline Interface: Add ``--debug-info`` option for selecting how much extra debug information should be included in the produced EVM assembly and Yul code. * SMTChecker: Output values for ``block.*``, ``msg.*`` and ``tx.*`` variables that are present in the called functions. * Standard JSON: Accept nested brackets in step sequences passed to ``settings.optimizer.details.yulDetails.optimizerSteps``. + * Standard JSON: Add ``settings.debug.debugInfo`` option for selecting how much extra debug information should be included in the produced EVM assembly and Yul code. Bugfixes: diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index 1b14187ca..88da5d5e6 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -308,7 +308,18 @@ Input Description // "strip" removes all revert strings (if possible, i.e. if literals are used) keeping side-effects // "debug" injects strings for compiler-generated internal reverts, implemented for ABI encoders V1 and V2 for now. // "verboseDebug" even appends further information to user-supplied revert strings (not yet implemented) - "revertStrings": "default" + "revertStrings": "default", + // Optional: How much extra debug information to include in comments in the produced EVM + // assembly and Yul code. Available components are: + // - `location`: Annotations of the form `@src ::` indicating the + // location of the corresponding element in the original Solidity file, where: + // - `` is the file index matching the `@use-src` annotation, + // - `` is the index of the first byte at that location, + // - `` is the index of the first byte after that location. + // - `snippet`: A single-line code snippet from the location indicated by `@src`. + // The snippet is quoted and follows the corresponding `@src` annotation. + // - `*`: Wildcard value that can be used to request everything. + "debugInfo": ["location", "snippet"] }, // Metadata settings (optional) "metadata": { diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 240ad4f9c..66f5dc4e5 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -33,7 +33,6 @@ #include -#include #include #include @@ -798,7 +797,7 @@ std::variant StandardCompiler: if (settings.isMember("debug")) { - if (auto result = checkKeys(settings["debug"], {"revertStrings"}, "settings.debug")) + if (auto result = checkKeys(settings["debug"], {"revertStrings", "debugInfo"}, "settings.debug")) return *result; if (settings["debug"].isMember("revertStrings")) @@ -815,6 +814,31 @@ std::variant StandardCompiler: ); ret.revertStrings = *revertStrings; } + + if (settings["debug"].isMember("debugInfo")) + { + if (!settings["debug"]["debugInfo"].isArray()) + return formatFatalError("JSONError", "settings.debug.debugInfo must be an array."); + + vector components; + for (Json::Value const& arrayValue: settings["debug"]["debugInfo"]) + components.push_back(arrayValue.asString()); + + optional debugInfoSelection = DebugInfoSelection::fromComponents( + components, + true /* _acceptWildcards */ + ); + if (!debugInfoSelection.has_value()) + return formatFatalError("JSONError", "Invalid value in settings.debug.debugInfo."); + + if (debugInfoSelection->snippet && !debugInfoSelection->location) + return formatFatalError( + "JSONError", + "To use 'snippet' with settings.debug.debugInfo you must select also 'location'." + ); + + ret.debugInfoSelection = debugInfoSelection.value(); + } } if (settings.isMember("remappings") && !settings["remappings"].isArray()) @@ -1034,6 +1058,8 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting compilerStack.setRemappings(move(_inputsAndSettings.remappings)); compilerStack.setOptimiserSettings(std::move(_inputsAndSettings.optimiserSettings)); compilerStack.setRevertStringBehaviour(_inputsAndSettings.revertStrings); + if (_inputsAndSettings.debugInfoSelection.has_value()) + compilerStack.selectDebugInfo(_inputsAndSettings.debugInfoSelection.value()); compilerStack.setLibraries(_inputsAndSettings.libraries); compilerStack.useMetadataLiteralSources(_inputsAndSettings.metadataLiteralSources); compilerStack.setMetadataHash(_inputsAndSettings.metadataHash); @@ -1364,7 +1390,9 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) _inputsAndSettings.evmVersion, AssemblyStack::Language::StrictAssembly, _inputsAndSettings.optimiserSettings, - DebugInfoSelection::Default() + _inputsAndSettings.debugInfoSelection.has_value() ? + _inputsAndSettings.debugInfoSelection.value() : + DebugInfoSelection::Default() ); string const& sourceName = _inputsAndSettings.sources.begin()->first; string const& sourceContents = _inputsAndSettings.sources.begin()->second; diff --git a/libsolidity/interface/StandardCompiler.h b/libsolidity/interface/StandardCompiler.h index 4d43fdfec..679e731a2 100644 --- a/libsolidity/interface/StandardCompiler.h +++ b/libsolidity/interface/StandardCompiler.h @@ -26,6 +26,8 @@ #include #include +#include + #include #include #include @@ -78,6 +80,7 @@ private: std::vector remappings; RevertStrings revertStrings = RevertStrings::Default; OptimiserSettings optimiserSettings = OptimiserSettings::minimal(); + std::optional debugInfoSelection; std::map libraries; bool metadataLiteralSources = false; CompilerStack::MetadataHash metadataHash = CompilerStack::MetadataHash::IPFS; diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index e1a0b3dbe..3b26b6c83 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -631,6 +631,8 @@ bool CommandLineInterface::compile() m_compiler->setViaIR(m_options.output.experimentalViaIR); m_compiler->setEVMVersion(m_options.output.evmVersion); m_compiler->setRevertStringBehaviour(m_options.output.revertStrings); + if (m_options.output.debugInfoSelection.has_value()) + m_compiler->selectDebugInfo(m_options.output.debugInfoSelection.value()); // TODO: Perhaps we should not compile unless requested m_compiler->enableIRGeneration(m_options.compiler.outputs.ir || m_options.compiler.outputs.irOptimized); @@ -973,7 +975,9 @@ bool CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul: m_options.output.evmVersion, _language, m_options.optimiserSettings(), - DebugInfoSelection::Default() + m_options.output.debugInfoSelection.has_value() ? + m_options.output.debugInfoSelection.value() : + DebugInfoSelection::Default() ); if (!stack.parseAndAnalyze(src.first, src.second)) diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index 6c673c311..89304ef3c 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -67,6 +67,7 @@ static string const g_strImportAst = "import-ast"; static string const g_strInputFile = "input-file"; static string const g_strYul = "yul"; static string const g_strYulDialect = "yul-dialect"; +static string const g_strDebugInfo = "debug-info"; static string const g_strIPFS = "ipfs"; static string const g_strLicense = "license"; static string const g_strLibraries = "libraries"; @@ -252,6 +253,7 @@ bool CommandLineOptions::operator==(CommandLineOptions const& _other) const noex output.evmVersion == _other.output.evmVersion && output.experimentalViaIR == _other.output.experimentalViaIR && output.revertStrings == _other.output.revertStrings && + output.debugInfoSelection == _other.output.debugInfoSelection && output.stopAfter == _other.output.stopAfter && input.mode == _other.input.mode && assembly.targetMachine == _other.assembly.targetMachine && @@ -595,6 +597,13 @@ General Information)").c_str(), po::value()->value_name(joinHumanReadable(g_revertStringsArgs, ",")), "Strip revert (and require) reason strings or add additional debugging information." ) + ( + g_strDebugInfo.c_str(), + po::value()->default_value(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: " + joinHumanReadable(DebugInfoSelection::componentMap() | ranges::views::keys) + ".").c_str() + ) ( g_strStopAfter.c_str(), po::value()->value_name("stage"), @@ -935,6 +944,12 @@ bool CommandLineParser::processArgs() serr() << "Option --" << option << " is only valid in compiler and assembler modes." << endl; return false; } + + if (!m_args[g_strDebugInfo].defaulted()) + { + serr() << "Option --" << g_strDebugInfo << " is only valid in compiler and assembler modes." << endl; + return false; + } } if (m_args.count(g_strColor) > 0) @@ -961,6 +976,23 @@ bool CommandLineParser::processArgs() m_options.output.revertStrings = *revertStrings; } + if (!m_args[g_strDebugInfo].defaulted()) + { + string optionValue = m_args[g_strDebugInfo].as(); + m_options.output.debugInfoSelection = DebugInfoSelection::fromString(optionValue); + if (!m_options.output.debugInfoSelection.has_value()) + { + serr() << "Invalid value for --" << g_strDebugInfo << " option: " << optionValue << endl; + return false; + } + + if (m_options.output.debugInfoSelection->snippet && !m_options.output.debugInfoSelection->location) + { + serr() << "To use 'snippet' with --" << g_strDebugInfo << " you must select also 'location'." << endl; + return false; + } + } + if (!parseCombinedJsonOption()) return false; diff --git a/solc/CommandLineParser.h b/solc/CommandLineParser.h index 1f09ea993..ad525ea3b 100644 --- a/solc/CommandLineParser.h +++ b/solc/CommandLineParser.h @@ -24,8 +24,12 @@ #include #include #include + #include + +#include #include + #include #include @@ -174,6 +178,7 @@ struct CommandLineOptions langutil::EVMVersion evmVersion; bool experimentalViaIR = false; RevertStrings revertStrings = RevertStrings::Default; + std::optional debugInfoSelection; CompilerStack::State stopAfter = CompilerStack::State::CompilationSuccessful; } output; diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/args b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/args new file mode 100644 index 000000000..77f60c746 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/args @@ -0,0 +1 @@ +--ir --ir-optimized --asm --optimize --debug-info all diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/input.sol b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/input.sol new file mode 100644 index 000000000..415509ef9 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/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_and_evm_asm_print_all/output b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output new file mode 100644 index 000000000..157594b2b --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output @@ -0,0 +1,213 @@ + +======= debug_info_in_yul_and_evm_asm_print_all/input.sol:C ======= +EVM assembly: + /* "debug_info_in_yul_and_evm_asm_print_all/input.sol":60:101 contract C {... */ + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert +tag_1: + pop + dataSize(sub_0) + dup1 + dataOffset(sub_0) + 0x00 + codecopy + 0x00 + return +stop + +sub_0: assembly { + /* "debug_info_in_yul_and_evm_asm_print_all/input.sol":60:101 contract C {... */ + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert + tag_1: + pop + jumpi(tag_2, lt(calldatasize, 0x04)) + shr(0xe0, calldataload(0x00)) + dup1 + 0x26121ff0 + eq + tag_3 + jumpi + tag_2: + 0x00 + dup1 + revert + /* "debug_info_in_yul_and_evm_asm_print_all/input.sol":77:99 function f() public {} */ + tag_3: + stop + + auxdata: +} + +IR: +/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + + +/// @use-src 0:"debug_info_in_yul_and_evm_asm_print_all/input.sol" +object "C_6" { + code { + /// @src 0:60:101 "contract C {..." + mstore(64, 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:"debug_info_in_yul_and_evm_asm_print_all/input.sol" + object "C_6_deployed" { + code { + /// @src 0:60:101 "contract C {..." + mstore(64, 128) + + if iszero(lt(calldatasize(), 4)) + { + let selector := shift_right_224_unsigned(calldataload(0)) + switch selector + + case 0x26121ff0 + { + // f() + + 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)) + } + + default {} + } + if iszero(calldatasize()) { } + 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 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"" + } + +} + + +Optimized IR: +/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + +/// @use-src 0:"debug_info_in_yul_and_evm_asm_print_all/input.sol" +object "C_6" { + code { + { + /// @src 0:60:101 "contract C {..." + mstore(64, 128) + if callvalue() { revert(0, 0) } + let _1 := datasize("C_6_deployed") + codecopy(128, dataoffset("C_6_deployed"), _1) + return(128, _1) + } + } + /// @use-src 0:"debug_info_in_yul_and_evm_asm_print_all/input.sol" + object "C_6_deployed" { + code { + { + /// @src 0:60:101 "contract C {..." + mstore(64, 128) + if iszero(lt(calldatasize(), 4)) + { + let _1 := 0 + if eq(0x26121ff0, shr(224, calldataload(_1))) + { + if callvalue() { revert(_1, _1) } + if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } + return(128, _1) + } + } + revert(0, 0) + } + } + data ".metadata" hex"" + } +} diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all_and_none/args b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all_and_none/args new file mode 100644 index 000000000..e0c752a3a --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all_and_none/args @@ -0,0 +1 @@ +--ir --ir-optimized --asm --optimize --debug-info location,all,none diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all_and_none/err b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all_and_none/err new file mode 100644 index 000000000..99ed59cc0 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all_and_none/err @@ -0,0 +1 @@ +Invalid value for --debug-info option: location,all,none diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all_and_none/exit b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all_and_none/exit new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all_and_none/exit @@ -0,0 +1 @@ +1 diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all_and_none/input.sol b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all_and_none/input.sol new file mode 100644 index 000000000..e69de29bb diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/args b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/args new file mode 100644 index 000000000..6b47cc2c3 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/args @@ -0,0 +1 @@ +--ir --ir-optimized --asm --optimize --debug-info location diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/input.sol b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/input.sol new file mode 100644 index 000000000..415509ef9 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/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_and_evm_asm_print_location_only/output b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output new file mode 100644 index 000000000..505e734b9 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output @@ -0,0 +1,212 @@ + +======= debug_info_in_yul_and_evm_asm_print_location_only/input.sol:C ======= +EVM assembly: + /* "debug_info_in_yul_and_evm_asm_print_location_only/input.sol":60:101 */ + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert +tag_1: + pop + dataSize(sub_0) + dup1 + dataOffset(sub_0) + 0x00 + codecopy + 0x00 + return +stop + +sub_0: assembly { + /* "debug_info_in_yul_and_evm_asm_print_location_only/input.sol":60:101 */ + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert + tag_1: + pop + jumpi(tag_2, lt(calldatasize, 0x04)) + shr(0xe0, calldataload(0x00)) + dup1 + 0x26121ff0 + eq + tag_3 + jumpi + tag_2: + 0x00 + dup1 + revert + /* "debug_info_in_yul_and_evm_asm_print_location_only/input.sol":77:99 */ + tag_3: + stop + + auxdata: +} + +IR: +/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + + +/// @use-src 0:"debug_info_in_yul_and_evm_asm_print_location_only/input.sol" +object "C_6" { + code { + /// @src 0:60:101 + mstore(64, 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_and_evm_asm_print_location_only/input.sol" + object "C_6_deployed" { + code { + /// @src 0:60:101 + mstore(64, 128) + + if iszero(lt(calldatasize(), 4)) + { + let selector := shift_right_224_unsigned(calldataload(0)) + switch selector + + case 0x26121ff0 + { + // f() + + 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)) + } + + default {} + } + if iszero(calldatasize()) { } + 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 revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { + revert(0, 0) + } + + /// @src 0:77:99 + function fun_f_5() { + + } + /// @src 0:60:101 + + } + + data ".metadata" hex"" + } + +} + + +Optimized IR: +/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + +/// @use-src 0:"debug_info_in_yul_and_evm_asm_print_location_only/input.sol" +object "C_6" { + code { + { + /// @src 0:60:101 + mstore(64, 128) + if callvalue() { revert(0, 0) } + let _1 := datasize("C_6_deployed") + codecopy(128, dataoffset("C_6_deployed"), _1) + return(128, _1) + } + } + /// @use-src 0:"debug_info_in_yul_and_evm_asm_print_location_only/input.sol" + object "C_6_deployed" { + code { + { + /// @src 0:60:101 + mstore(64, 128) + if iszero(lt(calldatasize(), 4)) + { + let _1 := 0 + if eq(0x26121ff0, shr(224, calldataload(_1))) + { + if callvalue() { revert(_1, _1) } + if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } + return(128, _1) + } + } + revert(0, 0) + } + } + data ".metadata" hex"" + } +} diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/args b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/args new file mode 100644 index 000000000..89896f68a --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/args @@ -0,0 +1 @@ +--ir --ir-optimized --asm --optimize --debug-info none diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/input.sol b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/input.sol new file mode 100644 index 000000000..415509ef9 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/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_and_evm_asm_print_none/output b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output new file mode 100644 index 000000000..c8f76f990 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output @@ -0,0 +1,201 @@ + +======= debug_info_in_yul_and_evm_asm_print_none/input.sol:C ======= +EVM assembly: + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert +tag_1: + pop + dataSize(sub_0) + dup1 + dataOffset(sub_0) + 0x00 + codecopy + 0x00 + return +stop + +sub_0: assembly { + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert + tag_1: + pop + jumpi(tag_2, lt(calldatasize, 0x04)) + shr(0xe0, calldataload(0x00)) + dup1 + 0x26121ff0 + eq + tag_3 + jumpi + tag_2: + 0x00 + dup1 + revert + tag_3: + stop + + auxdata: +} + +IR: +/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + + +/// @use-src 0:"debug_info_in_yul_and_evm_asm_print_none/input.sol" +object "C_6" { + code { + + mstore(64, 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) + } + + function constructor_C_6() { + + } + + } + /// @use-src 0:"debug_info_in_yul_and_evm_asm_print_none/input.sol" + object "C_6_deployed" { + code { + + mstore(64, 128) + + if iszero(lt(calldatasize(), 4)) + { + let selector := shift_right_224_unsigned(calldataload(0)) + switch selector + + case 0x26121ff0 + { + // f() + + 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)) + } + + default {} + } + if iszero(calldatasize()) { } + 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 revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { + revert(0, 0) + } + + function fun_f_5() { + + } + + } + + data ".metadata" hex"" + } + +} + + +Optimized IR: +/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + +/// @use-src 0:"debug_info_in_yul_and_evm_asm_print_none/input.sol" +object "C_6" { + code { + { + mstore(64, 128) + if callvalue() { revert(0, 0) } + let _1 := datasize("C_6_deployed") + codecopy(128, dataoffset("C_6_deployed"), _1) + return(128, _1) + } + } + /// @use-src 0:"debug_info_in_yul_and_evm_asm_print_none/input.sol" + object "C_6_deployed" { + code { + { + mstore(64, 128) + if iszero(lt(calldatasize(), 4)) + { + let _1 := 0 + if eq(0x26121ff0, shr(224, calldataload(_1))) + { + if callvalue() { revert(_1, _1) } + if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } + return(128, _1) + } + } + revert(0, 0) + } + } + data ".metadata" hex"" + } +} diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_snippet_only/args b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_snippet_only/args new file mode 100644 index 000000000..9f1e80de2 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_snippet_only/args @@ -0,0 +1 @@ +--ir --ir-optimized --asm --optimize --debug-info snippet diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_snippet_only/err b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_snippet_only/err new file mode 100644 index 000000000..4cd94075a --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_snippet_only/err @@ -0,0 +1 @@ +To use 'snippet' with --debug-info you must select also 'location'. diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_snippet_only/exit b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_snippet_only/exit new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_snippet_only/exit @@ -0,0 +1 @@ +1 diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_snippet_only/input.sol b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_snippet_only/input.sol new file mode 100644 index 000000000..415509ef9 --- /dev/null +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_snippet_only/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/standard_debug_info_in_yul_and_evm_asm_print_all/args b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/args new file mode 100644 index 000000000..24d48faf2 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/args @@ -0,0 +1 @@ +--pretty-json --json-indent 4 --allow-paths . diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/in.sol b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/in.sol new file mode 100644 index 000000000..415509ef9 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/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_and_evm_asm_print_all/input.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/input.json new file mode 100644 index 000000000..3059e1ecd --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/input.json @@ -0,0 +1,13 @@ +{ + "language": "Solidity", + "sources": { + "C": {"urls": ["standard_debug_info_in_yul_and_evm_asm_print_all/in.sol"]} + }, + "settings": { + "debug": {"debugInfo": ["*"]}, + "optimizer": {"enabled": true}, + "outputSelection": { + "*": {"*": ["ir", "irOptimized", "evm.assembly"]} + } + } +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json new file mode 100644 index 000000000..4ef790de3 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json @@ -0,0 +1,230 @@ +{ + "contracts": + { + "C": + { + "C": + { + "evm": + { + "assembly": " /* \"C\":60:101 contract C {... */ + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert +tag_1: + pop + dataSize(sub_0) + dup1 + dataOffset(sub_0) + 0x00 + codecopy + 0x00 + return +stop + +sub_0: assembly { + /* \"C\":60:101 contract C {... */ + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert + tag_1: + pop + jumpi(tag_2, lt(calldatasize, 0x04)) + shr(0xe0, calldataload(0x00)) + dup1 + 0x26121ff0 + eq + tag_3 + jumpi + tag_2: + 0x00 + dup1 + revert + /* \"C\":77:99 function f() public {} */ + tag_3: + stop + + auxdata: +} +" + }, + "ir": "/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + + +/// @use-src 0:\"C\" +object \"C_6\" { + code { + /// @src 0:60:101 \"contract C {...\" + mstore(64, 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:\"C\" + object \"C_6_deployed\" { + code { + /// @src 0:60:101 \"contract C {...\" + mstore(64, 128) + + if iszero(lt(calldatasize(), 4)) + { + let selector := shift_right_224_unsigned(calldataload(0)) + switch selector + + case 0x26121ff0 + { + // f() + + 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)) + } + + default {} + } + if iszero(calldatasize()) { } + 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 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\"\" + } + +} + +", + "irOptimized": "/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + +/// @use-src 0:\"C\" +object \"C_6\" { + code { + { + /// @src 0:60:101 \"contract C {...\" + mstore(64, 128) + if callvalue() { revert(0, 0) } + let _1 := datasize(\"C_6_deployed\") + codecopy(128, dataoffset(\"C_6_deployed\"), _1) + return(128, _1) + } + } + /// @use-src 0:\"C\" + object \"C_6_deployed\" { + code { + { + /// @src 0:60:101 \"contract C {...\" + mstore(64, 128) + if iszero(lt(calldatasize(), 4)) + { + let _1 := 0 + if eq(0x26121ff0, shr(224, calldataload(_1))) + { + if callvalue() { revert(_1, _1) } + if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } + return(128, _1) + } + } + revert(0, 0) + } + } + data \".metadata\" hex\"\" + } +} +" + } + } + }, + "sources": + { + "C": + { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/args b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/args new file mode 100644 index 000000000..24d48faf2 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/args @@ -0,0 +1 @@ +--pretty-json --json-indent 4 --allow-paths . diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/in.sol b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/in.sol new file mode 100644 index 000000000..415509ef9 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/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_and_evm_asm_print_location_only/input.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/input.json new file mode 100644 index 000000000..8e338322b --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/input.json @@ -0,0 +1,13 @@ +{ + "language": "Solidity", + "sources": { + "C": {"urls": ["standard_debug_info_in_yul_and_evm_asm_print_location_only/in.sol"]} + }, + "settings": { + "debug": {"debugInfo": ["location"]}, + "optimizer": {"enabled": true}, + "outputSelection": { + "*": {"*": ["ir", "irOptimized", "evm.assembly"]} + } + } +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json new file mode 100644 index 000000000..2aebdc0f2 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json @@ -0,0 +1,229 @@ +{ + "contracts": + { + "C": + { + "C": + { + "evm": + { + "assembly": " /* \"C\":60:101 */ + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert +tag_1: + pop + dataSize(sub_0) + dup1 + dataOffset(sub_0) + 0x00 + codecopy + 0x00 + return +stop + +sub_0: assembly { + /* \"C\":60:101 */ + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert + tag_1: + pop + jumpi(tag_2, lt(calldatasize, 0x04)) + shr(0xe0, calldataload(0x00)) + dup1 + 0x26121ff0 + eq + tag_3 + jumpi + tag_2: + 0x00 + dup1 + revert + /* \"C\":77:99 */ + tag_3: + stop + + auxdata: +} +" + }, + "ir": "/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + + +/// @use-src 0:\"C\" +object \"C_6\" { + code { + /// @src 0:60:101 + mstore(64, 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, 128) + + if iszero(lt(calldatasize(), 4)) + { + let selector := shift_right_224_unsigned(calldataload(0)) + switch selector + + case 0x26121ff0 + { + // f() + + 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)) + } + + default {} + } + if iszero(calldatasize()) { } + 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 revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { + revert(0, 0) + } + + /// @src 0:77:99 + function fun_f_5() { + + } + /// @src 0:60:101 + + } + + data \".metadata\" hex\"\" + } + +} + +", + "irOptimized": "/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + +/// @use-src 0:\"C\" +object \"C_6\" { + code { + { + /// @src 0:60:101 + mstore(64, 128) + if callvalue() { revert(0, 0) } + let _1 := datasize(\"C_6_deployed\") + codecopy(128, dataoffset(\"C_6_deployed\"), _1) + return(128, _1) + } + } + /// @use-src 0:\"C\" + object \"C_6_deployed\" { + code { + { + /// @src 0:60:101 + mstore(64, 128) + if iszero(lt(calldatasize(), 4)) + { + let _1 := 0 + if eq(0x26121ff0, shr(224, calldataload(_1))) + { + if callvalue() { revert(_1, _1) } + if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } + return(128, _1) + } + } + revert(0, 0) + } + } + data \".metadata\" hex\"\" + } +} +" + } + } + }, + "sources": + { + "C": + { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/args b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/args new file mode 100644 index 000000000..24d48faf2 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/args @@ -0,0 +1 @@ +--pretty-json --json-indent 4 --allow-paths . diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/in.sol b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/in.sol new file mode 100644 index 000000000..415509ef9 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/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_and_evm_asm_print_none/input.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/input.json new file mode 100644 index 000000000..c9184d944 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/input.json @@ -0,0 +1,13 @@ +{ + "language": "Solidity", + "sources": { + "C": {"urls": ["standard_debug_info_in_yul_and_evm_asm_print_none/in.sol"]} + }, + "settings": { + "debug": {"debugInfo": []}, + "optimizer": {"enabled": true}, + "outputSelection": { + "*": {"*": ["ir", "irOptimized", "evm.assembly"]} + } + } +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json new file mode 100644 index 000000000..be369ef1a --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json @@ -0,0 +1,218 @@ +{ + "contracts": + { + "C": + { + "C": + { + "evm": + { + "assembly": " mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert +tag_1: + pop + dataSize(sub_0) + dup1 + dataOffset(sub_0) + 0x00 + codecopy + 0x00 + return +stop + +sub_0: assembly { + mstore(0x40, 0x80) + callvalue + dup1 + iszero + tag_1 + jumpi + 0x00 + dup1 + revert + tag_1: + pop + jumpi(tag_2, lt(calldatasize, 0x04)) + shr(0xe0, calldataload(0x00)) + dup1 + 0x26121ff0 + eq + tag_3 + jumpi + tag_2: + 0x00 + dup1 + revert + tag_3: + stop + + auxdata: +} +" + }, + "ir": "/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + + +/// @use-src 0:\"C\" +object \"C_6\" { + code { + + mstore(64, 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) + } + + function constructor_C_6() { + + } + + } + /// @use-src 0:\"C\" + object \"C_6_deployed\" { + code { + + mstore(64, 128) + + if iszero(lt(calldatasize(), 4)) + { + let selector := shift_right_224_unsigned(calldataload(0)) + switch selector + + case 0x26121ff0 + { + // f() + + 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)) + } + + default {} + } + if iszero(calldatasize()) { } + 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 revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { + revert(0, 0) + } + + function fun_f_5() { + + } + + } + + data \".metadata\" hex\"\" + } + +} + +", + "irOptimized": "/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + +/// @use-src 0:\"C\" +object \"C_6\" { + code { + { + mstore(64, 128) + if callvalue() { revert(0, 0) } + let _1 := datasize(\"C_6_deployed\") + codecopy(128, dataoffset(\"C_6_deployed\"), _1) + return(128, _1) + } + } + /// @use-src 0:\"C\" + object \"C_6_deployed\" { + code { + { + mstore(64, 128) + if iszero(lt(calldatasize(), 4)) + { + let _1 := 0 + if eq(0x26121ff0, shr(224, calldataload(_1))) + { + if callvalue() { revert(_1, _1) } + if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } + return(128, _1) + } + } + revert(0, 0) + } + } + data \".metadata\" hex\"\" + } +} +" + } + } + }, + "sources": + { + "C": + { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/args b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/args new file mode 100644 index 000000000..24d48faf2 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/args @@ -0,0 +1 @@ +--pretty-json --json-indent 4 --allow-paths . diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/in.sol b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/in.sol new file mode 100644 index 000000000..415509ef9 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/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_and_evm_asm_print_snippet_only/input.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/input.json new file mode 100644 index 000000000..962688913 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/input.json @@ -0,0 +1,13 @@ +{ + "language": "Solidity", + "sources": { + "C": {"urls": ["standard_debug_info_in_yul_and_evm_asm_print_snippet_only/in.sol"]} + }, + "settings": { + "debug": {"debugInfo": ["snippet"]}, + "optimizer": {"enabled": true}, + "outputSelection": { + "*": {"*": ["ir", "irOptimized", "evm.assembly"]} + } + } +} diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/output.json new file mode 100644 index 000000000..fb7f199a7 --- /dev/null +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_snippet_only/output.json @@ -0,0 +1,12 @@ +{ + "errors": + [ + { + "component": "general", + "formattedMessage": "To use 'snippet' with settings.debug.debugInfo you must select also 'location'.", + "message": "To use 'snippet' with settings.debug.debugInfo you must select also 'location'.", + "severity": "error", + "type": "JSONError" + } + ] +} diff --git a/test/cmdlineTests/standard_yul_debug_info_print_all/args b/test/cmdlineTests/standard_yul_debug_info_print_all/args new file mode 100644 index 000000000..24d48faf2 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_all/args @@ -0,0 +1 @@ +--pretty-json --json-indent 4 --allow-paths . diff --git a/test/cmdlineTests/standard_yul_debug_info_print_all/in.yul b/test/cmdlineTests/standard_yul_debug_info_print_all/in.yul new file mode 100644 index 000000000..6d1ebe21b --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_all/in.yul @@ -0,0 +1,15 @@ +/// @use-src 0:"input.sol" +object "C_6_deployed" { + code { + /// @src 0:60:101 "contract C {..." + mstore(64, 128) + + // f() + fun_f_5() + + /// @src 0:77:99 "function f() public {}" + function fun_f_5() { + } + /// @src 0:60:101 "contract C {..." + } +} diff --git a/test/cmdlineTests/standard_yul_debug_info_print_all/input.json b/test/cmdlineTests/standard_yul_debug_info_print_all/input.json new file mode 100644 index 000000000..1e6ed81a4 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_all/input.json @@ -0,0 +1,12 @@ +{ + "language": "Yul", + "sources": { + "C": {"urls": ["standard_yul_debug_info_print_all/in.yul"]} + }, + "settings": { + "debug": {"debugInfo": ["*"]}, + "outputSelection": { + "*": {"*": ["evm.assembly"]} + } + } +} diff --git a/test/cmdlineTests/standard_yul_debug_info_print_all/output.json b/test/cmdlineTests/standard_yul_debug_info_print_all/output.json new file mode 100644 index 000000000..b57bc9188 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_all/output.json @@ -0,0 +1,36 @@ +{ + "contracts": + { + "C": + { + "C_6_deployed": + { + "evm": + { + "assembly": " /* \"input.sol\":60:101 */ + mstore(0x40, 0x80) + tag_2 + tag_1 + jump\t// in +tag_2: + /* \"input.sol\":77:99 */ + jump(tag_3) +tag_1: + jump\t// out +tag_3: +" + } + } + } + }, + "errors": + [ + { + "component": "general", + "formattedMessage": "Yul is still experimental. Please use the output with care.", + "message": "Yul is still experimental. Please use the output with care.", + "severity": "warning", + "type": "Warning" + } + ] +} diff --git a/test/cmdlineTests/standard_yul_debug_info_print_location_only/args b/test/cmdlineTests/standard_yul_debug_info_print_location_only/args new file mode 100644 index 000000000..24d48faf2 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_location_only/args @@ -0,0 +1 @@ +--pretty-json --json-indent 4 --allow-paths . diff --git a/test/cmdlineTests/standard_yul_debug_info_print_location_only/in.yul b/test/cmdlineTests/standard_yul_debug_info_print_location_only/in.yul new file mode 100644 index 000000000..6d1ebe21b --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_location_only/in.yul @@ -0,0 +1,15 @@ +/// @use-src 0:"input.sol" +object "C_6_deployed" { + code { + /// @src 0:60:101 "contract C {..." + mstore(64, 128) + + // f() + fun_f_5() + + /// @src 0:77:99 "function f() public {}" + function fun_f_5() { + } + /// @src 0:60:101 "contract C {..." + } +} diff --git a/test/cmdlineTests/standard_yul_debug_info_print_location_only/input.json b/test/cmdlineTests/standard_yul_debug_info_print_location_only/input.json new file mode 100644 index 000000000..867bc6e70 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_location_only/input.json @@ -0,0 +1,12 @@ +{ + "language": "Yul", + "sources": { + "C": {"urls": ["standard_yul_debug_info_print_location_only/in.yul"]} + }, + "settings": { + "debug": {"debugInfo": ["location"]}, + "outputSelection": { + "*": {"*": ["evm.assembly"]} + } + } +} diff --git a/test/cmdlineTests/standard_yul_debug_info_print_location_only/output.json b/test/cmdlineTests/standard_yul_debug_info_print_location_only/output.json new file mode 100644 index 000000000..0ce9fd2de --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_location_only/output.json @@ -0,0 +1,36 @@ +{ + "contracts": + { + "C": + { + "C_6_deployed": + { + "evm": + { + "assembly": " /* \"input.sol\":60:101 */ + mstore(0x40, 0x80) + tag_2 + tag_1 + jump\t// in +tag_2: + /* \"input.sol\":77:99 */ + jump(tag_3) +tag_1: + jump\t// out +tag_3: +" + } + } + } + }, + "errors": + [ + { + "component": "general", + "formattedMessage": "Yul is still experimental. Please use the output with care.", + "message": "Yul is still experimental. Please use the output with care.", + "severity": "warning", + "type": "Warning" + } + ] +} diff --git a/test/cmdlineTests/standard_yul_debug_info_print_none/args b/test/cmdlineTests/standard_yul_debug_info_print_none/args new file mode 100644 index 000000000..24d48faf2 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_none/args @@ -0,0 +1 @@ +--pretty-json --json-indent 4 --allow-paths . diff --git a/test/cmdlineTests/standard_yul_debug_info_print_none/in.yul b/test/cmdlineTests/standard_yul_debug_info_print_none/in.yul new file mode 100644 index 000000000..6d1ebe21b --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_none/in.yul @@ -0,0 +1,15 @@ +/// @use-src 0:"input.sol" +object "C_6_deployed" { + code { + /// @src 0:60:101 "contract C {..." + mstore(64, 128) + + // f() + fun_f_5() + + /// @src 0:77:99 "function f() public {}" + function fun_f_5() { + } + /// @src 0:60:101 "contract C {..." + } +} diff --git a/test/cmdlineTests/standard_yul_debug_info_print_none/input.json b/test/cmdlineTests/standard_yul_debug_info_print_none/input.json new file mode 100644 index 000000000..705cf3879 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_none/input.json @@ -0,0 +1,12 @@ +{ + "language": "Yul", + "sources": { + "C": {"urls": ["standard_yul_debug_info_print_none/in.yul"]} + }, + "settings": { + "debug": {"debugInfo": []}, + "outputSelection": { + "*": {"*": ["evm.assembly"]} + } + } +} diff --git a/test/cmdlineTests/standard_yul_debug_info_print_none/output.json b/test/cmdlineTests/standard_yul_debug_info_print_none/output.json new file mode 100644 index 000000000..8203ee0a2 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_none/output.json @@ -0,0 +1,34 @@ +{ + "contracts": + { + "C": + { + "C_6_deployed": + { + "evm": + { + "assembly": " mstore(0x40, 0x80) + tag_2 + tag_1 + jump\t// in +tag_2: + jump(tag_3) +tag_1: + jump\t// out +tag_3: +" + } + } + } + }, + "errors": + [ + { + "component": "general", + "formattedMessage": "Yul is still experimental. Please use the output with care.", + "message": "Yul is still experimental. Please use the output with care.", + "severity": "warning", + "type": "Warning" + } + ] +} diff --git a/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/args b/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/args new file mode 100644 index 000000000..24d48faf2 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/args @@ -0,0 +1 @@ +--pretty-json --json-indent 4 --allow-paths . diff --git a/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/in.yul b/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/in.yul new file mode 100644 index 000000000..6d1ebe21b --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/in.yul @@ -0,0 +1,15 @@ +/// @use-src 0:"input.sol" +object "C_6_deployed" { + code { + /// @src 0:60:101 "contract C {..." + mstore(64, 128) + + // f() + fun_f_5() + + /// @src 0:77:99 "function f() public {}" + function fun_f_5() { + } + /// @src 0:60:101 "contract C {..." + } +} diff --git a/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/input.json b/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/input.json new file mode 100644 index 000000000..ee247218f --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/input.json @@ -0,0 +1,12 @@ +{ + "language": "Yul", + "sources": { + "C": {"urls": ["standard_yul_debug_info_print_snippet_only/in.yul"]} + }, + "settings": { + "debug": {"debugInfo": ["snippet"]}, + "outputSelection": { + "*": {"*": ["evm.assembly"]} + } + } +} diff --git a/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/output.json b/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/output.json new file mode 100644 index 000000000..fb7f199a7 --- /dev/null +++ b/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/output.json @@ -0,0 +1,12 @@ +{ + "errors": + [ + { + "component": "general", + "formattedMessage": "To use 'snippet' with settings.debug.debugInfo you must select also 'location'.", + "message": "To use 'snippet' with settings.debug.debugInfo you must select also 'location'.", + "severity": "error", + "type": "JSONError" + } + ] +} diff --git a/test/cmdlineTests/strict_asm_debug_info_print_all/args b/test/cmdlineTests/strict_asm_debug_info_print_all/args new file mode 100644 index 000000000..cfe8a15a2 --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_all/args @@ -0,0 +1 @@ +--strict-assembly --debug-info all diff --git a/test/cmdlineTests/strict_asm_debug_info_print_all/err b/test/cmdlineTests/strict_asm_debug_info_print_all/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_all/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/strict_asm_debug_info_print_all/input.yul b/test/cmdlineTests/strict_asm_debug_info_print_all/input.yul new file mode 100644 index 000000000..6d1ebe21b --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_all/input.yul @@ -0,0 +1,15 @@ +/// @use-src 0:"input.sol" +object "C_6_deployed" { + code { + /// @src 0:60:101 "contract C {..." + mstore(64, 128) + + // f() + fun_f_5() + + /// @src 0:77:99 "function f() public {}" + function fun_f_5() { + } + /// @src 0:60:101 "contract C {..." + } +} diff --git a/test/cmdlineTests/strict_asm_debug_info_print_all/output b/test/cmdlineTests/strict_asm_debug_info_print_all/output new file mode 100644 index 000000000..e83614b62 --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_all/output @@ -0,0 +1,32 @@ + +======= strict_asm_debug_info_print_all/input.yul (EVM) ======= + +Pretty printed source: +/// @use-src 0:"input.sol" +object "C_6_deployed" { + code { + /// @src 0:60:101 + mstore(64, 128) + fun_f_5() + /// @src 0:77:99 + function fun_f_5() + { } + } +} + + +Binary representation: +6080604052600a600e565b6010565b565b + +Text representation: + /* "input.sol":60:101 */ + mstore(0x40, 0x80) + tag_2 + tag_1 + jump // in +tag_2: + /* "input.sol":77:99 */ + jump(tag_3) +tag_1: + jump // out +tag_3: diff --git a/test/cmdlineTests/strict_asm_debug_info_print_location_only/args b/test/cmdlineTests/strict_asm_debug_info_print_location_only/args new file mode 100644 index 000000000..0d6ad325b --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_location_only/args @@ -0,0 +1 @@ +--strict-assembly --debug-info location diff --git a/test/cmdlineTests/strict_asm_debug_info_print_location_only/err b/test/cmdlineTests/strict_asm_debug_info_print_location_only/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_location_only/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/strict_asm_debug_info_print_location_only/input.yul b/test/cmdlineTests/strict_asm_debug_info_print_location_only/input.yul new file mode 100644 index 000000000..6d1ebe21b --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_location_only/input.yul @@ -0,0 +1,15 @@ +/// @use-src 0:"input.sol" +object "C_6_deployed" { + code { + /// @src 0:60:101 "contract C {..." + mstore(64, 128) + + // f() + fun_f_5() + + /// @src 0:77:99 "function f() public {}" + function fun_f_5() { + } + /// @src 0:60:101 "contract C {..." + } +} diff --git a/test/cmdlineTests/strict_asm_debug_info_print_location_only/output b/test/cmdlineTests/strict_asm_debug_info_print_location_only/output new file mode 100644 index 000000000..a4fd0e494 --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_location_only/output @@ -0,0 +1,32 @@ + +======= strict_asm_debug_info_print_location_only/input.yul (EVM) ======= + +Pretty printed source: +/// @use-src 0:"input.sol" +object "C_6_deployed" { + code { + /// @src 0:60:101 + mstore(64, 128) + fun_f_5() + /// @src 0:77:99 + function fun_f_5() + { } + } +} + + +Binary representation: +6080604052600a600e565b6010565b565b + +Text representation: + /* "input.sol":60:101 */ + mstore(0x40, 0x80) + tag_2 + tag_1 + jump // in +tag_2: + /* "input.sol":77:99 */ + jump(tag_3) +tag_1: + jump // out +tag_3: diff --git a/test/cmdlineTests/strict_asm_debug_info_print_none/args b/test/cmdlineTests/strict_asm_debug_info_print_none/args new file mode 100644 index 000000000..7e891dd86 --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_none/args @@ -0,0 +1 @@ +--strict-assembly --debug-info none diff --git a/test/cmdlineTests/strict_asm_debug_info_print_none/err b/test/cmdlineTests/strict_asm_debug_info_print_none/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_none/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/strict_asm_debug_info_print_none/input.yul b/test/cmdlineTests/strict_asm_debug_info_print_none/input.yul new file mode 100644 index 000000000..6d1ebe21b --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_none/input.yul @@ -0,0 +1,15 @@ +/// @use-src 0:"input.sol" +object "C_6_deployed" { + code { + /// @src 0:60:101 "contract C {..." + mstore(64, 128) + + // f() + fun_f_5() + + /// @src 0:77:99 "function f() public {}" + function fun_f_5() { + } + /// @src 0:60:101 "contract C {..." + } +} diff --git a/test/cmdlineTests/strict_asm_debug_info_print_none/output b/test/cmdlineTests/strict_asm_debug_info_print_none/output new file mode 100644 index 000000000..fc8841c9a --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_none/output @@ -0,0 +1,28 @@ + +======= strict_asm_debug_info_print_none/input.yul (EVM) ======= + +Pretty printed source: +/// @use-src 0:"input.sol" +object "C_6_deployed" { + code { + mstore(64, 128) + fun_f_5() + function fun_f_5() + { } + } +} + + +Binary representation: +6080604052600a600e565b6010565b565b + +Text representation: + mstore(0x40, 0x80) + tag_2 + tag_1 + jump // in +tag_2: + jump(tag_3) +tag_1: + jump // out +tag_3: diff --git a/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/args b/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/args new file mode 100644 index 000000000..362fd6515 --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/args @@ -0,0 +1 @@ +--strict-assembly --debug-info snippet diff --git a/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/err b/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/err new file mode 100644 index 000000000..4cd94075a --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/err @@ -0,0 +1 @@ +To use 'snippet' with --debug-info you must select also 'location'. diff --git a/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/exit b/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/exit new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/exit @@ -0,0 +1 @@ +1 diff --git a/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/input.yul b/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/input.yul new file mode 100644 index 000000000..6d1ebe21b --- /dev/null +++ b/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/input.yul @@ -0,0 +1,15 @@ +/// @use-src 0:"input.sol" +object "C_6_deployed" { + code { + /// @src 0:60:101 "contract C {..." + mstore(64, 128) + + // f() + fun_f_5() + + /// @src 0:77:99 "function f() public {}" + function fun_f_5() { + } + /// @src 0:60:101 "contract C {..." + } +} diff --git a/test/solc/CommandLineParser.cpp b/test/solc/CommandLineParser.cpp index 939850304..f2e4ea387 100644 --- a/test/solc/CommandLineParser.cpp +++ b/test/solc/CommandLineParser.cpp @@ -127,6 +127,7 @@ BOOST_AUTO_TEST_CASE(cli_mode_options) "--evm-version=spuriousDragon", "--experimental-via-ir", "--revert-strings=strip", + "--debug-info=location", "--pretty-json", "--json-indent=7", "--no-color", @@ -180,6 +181,7 @@ BOOST_AUTO_TEST_CASE(cli_mode_options) expectedOptions.output.evmVersion = EVMVersion::spuriousDragon(); expectedOptions.output.experimentalViaIR = true; expectedOptions.output.revertStrings = RevertStrings::Strip; + expectedOptions.output.debugInfoSelection = DebugInfoSelection::fromString("location"); expectedOptions.formatting.json = JsonFormat{JsonFormat::Pretty, 7}; expectedOptions.linker.libraries = { {"dir1/file1.sol:L", h160("1234567890123456789012345678901234567890")}, @@ -269,6 +271,7 @@ BOOST_AUTO_TEST_CASE(assembly_mode_options) "--overwrite", "--evm-version=spuriousDragon", "--revert-strings=strip", // Accepted but has no effect in assembly mode + "--debug-info=location", "--pretty-json", "--json-indent=1", "--no-color", @@ -315,6 +318,7 @@ BOOST_AUTO_TEST_CASE(assembly_mode_options) expectedOptions.output.overwriteFiles = true; expectedOptions.output.evmVersion = EVMVersion::spuriousDragon(); expectedOptions.output.revertStrings = RevertStrings::Strip; + expectedOptions.output.debugInfoSelection = DebugInfoSelection::fromString("location"); expectedOptions.formatting.json = JsonFormat {JsonFormat::Pretty, 1}; expectedOptions.assembly.targetMachine = expectedMachine; expectedOptions.assembly.inputLanguage = expectedLanguage;