Skip to content

Commit

Permalink
[ethdebug] Add output selection support for ethdebug.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarlt committed Jul 23, 2024
1 parent 71bf655 commit 5ef3239
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 1 deletion.
3 changes: 3 additions & 0 deletions solc/CommandLineInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
}
}

Expand Down
13 changes: 12 additions & 1 deletion solc/CommandLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,13 @@ General Information)").c_str(),
)
(
g_strCombinedJson.c_str(),
po::value<std::string>()->value_name(util::joinHumanReadable(CombinedJsonRequests::componentMap() | ranges::views::keys, ",")),
po::value<std::string>()->value_name(
util::joinHumanReadable(
CombinedJsonRequests::componentMap() | ranges::views::keys |
ranges::views::filter([](std::string const& key) { return key != "ethdebug"; }) |
ranges::to<std::vector>(), ","
)
),
"Output a single json document containing the specified information."
)
;
Expand Down Expand Up @@ -1452,6 +1458,11 @@ void CommandLineParser::processArgs()
"--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()
Expand Down
2 changes: 2 additions & 0 deletions solc/CommandLineParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ struct CombinedJsonRequests
{"devdoc", &CombinedJsonRequests::natspecDev},
{"userdoc", &CombinedJsonRequests::natspecUser},
{"ast", &CombinedJsonRequests::ast},
{"ethdebug", &CombinedJsonRequests::ethdebug},
};
return components;
}
Expand All @@ -156,6 +157,7 @@ struct CombinedJsonRequests
bool natspecDev = false;
bool natspecUser = false;
bool ast = false;
bool ethdebug = false;
};

struct CommandLineOptions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--combined-json ethdebug --pretty-json --json-indent 3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Error: --combined-json ethdebug can only be used together with --debug-info ethdebug.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract C {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--via-ir --debug-info ethdebug --combined-json ethdebug --pretty-json --json-indent 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract C {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"contracts": {
"combined_json_ethdebug_without_ethdebug_debug_info/input.sol:C": {
"ethdebug": {}
}
},
"version": "<VERSION REMOVED>"
}

0 comments on commit 5ef3239

Please sign in to comment.