-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable ethdebug debug info and output selection. #15289
base: develop
Are you sure you want to change the base?
Conversation
ccbe426
to
71bf655
Compare
ec729b3
to
ee2bc12
Compare
ee2bc12
to
9772d20
Compare
09fd459
to
53e12ef
Compare
4b5c548
to
a262eef
Compare
a262eef
to
c4cb445
Compare
@@ -1091,6 +1091,14 @@ Json CompilerStack::interfaceSymbols(std::string const& _contractName) const | |||
return interfaceSymbols; | |||
} | |||
|
|||
Json CompilerStack::ethdebug(std::string const& _contractName) const | |||
{ | |||
(void)_contractName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::ignore = _contractName;
or you could even just comment out the argument name in the declaration, i.e.
Json CompilerStack::ethdebug(std::string const& /* _contractName */) const
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wow, I didn't knew about std::ignore
yet 😅
@@ -42,7 +42,9 @@ struct DebugInfoSelection | |||
static DebugInfoSelection const All(bool _value = true) noexcept; | |||
static DebugInfoSelection const None() noexcept { return All(false); } | |||
static DebugInfoSelection const Only(bool DebugInfoSelection::* _member) noexcept; | |||
static DebugInfoSelection const Default() noexcept { return All(); } | |||
static DebugInfoSelection const Default() noexcept { return ExceptExperimental(); } | |||
static DebugInfoSelection const Except(std::vector<bool DebugInfoSelection::*> const& _members) noexcept; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of this is semantically wrong, so it's really more of a stylistic thing - why are there so many of these functions, and why must we have Except(_memeber)
, which is only used in ExceptExperimental()
, which is then made equivalent to Default()
, which again, is not used everywhere, but instead omitted in lieu of the equivalent ExceptExperimental()
, even though they're the same thing.
I would simply get rid of (or rather rename) Except()
to ExceptExperimental()
, and then use Default()
everywhere (which can remain as is). Once ethdebug is promoted to non experimental, all you'll need to do is just change Default()
to return All()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For simply CLI validation, I'd suggest replacing these with test/libsolidity/interface/CommandLineParser.cpp
and test/libsolidity/interface/CommandLineInterface.cpp
. cmdlineTests
are way too verbose for stuff like this.
c4cb445
to
dfef226
Compare
test/solc/CommandLineInterface.cpp
Outdated
TemporaryDirectory tempDir(TEST_CASE_NAME); | ||
createFilesWithParentDirs({tempDir.path() / "input.sol"}); | ||
// output selection "asm-json" not working with debug-info "ethdebug" or "ethdebug" output selection. | ||
OptionsReaderAndMessages result = runCLI({"solc", "--debug-info", "ethdebug", "--asm-json", tempDir.path().string() + "/input.sol"}, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OptionsReaderAndMessages result = runCLI({"solc", "--debug-info", "ethdebug", "--asm-json", tempDir.path().string() + "/input.sol"}, ""); | |
OptionsReaderAndMessages result; |
Got a duplicate of this case on line 1430.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know, if Kamil was here, he'd say 'you should put this options into a std::vector
and iterate through them in order to make the test more readable'. :D
I will say though - it would make sense here, since we typically also assert the correctness of the error message (which you're not doing here).
BOOST_REQUIRE(!result.success); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(cli_ethdebug_incompatible_input_modes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in test/CommandLineParser.cpp
BOOST_REQUIRE(result.stdoutContent.find("ethdebug") == std::string::npos); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(cli_ethdebug_incompatible_outputs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in test/CommandLineParser.cpp
@@ -1412,6 +1412,130 @@ BOOST_AUTO_TEST_CASE(cli_include_paths_ambiguous_import) | |||
BOOST_REQUIRE(!result.success); | |||
} | |||
|
|||
BOOST_AUTO_TEST_CASE(cli_ethdebug_no_ethdebug_in_help) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in test/CommandLineParser.cpp
BOOST_REQUIRE(result.stdoutContent.find("/// ethdebug: enabled") != std::string::npos); | ||
// --ethdebug only works with --via-ir. | ||
result = runCLI({"solc", "--debug-info", "ethdebug", "--ethdebug", tempDir.path().string() + "/input.sol"}, ""); | ||
BOOST_REQUIRE(!result.success); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These negative cases are already tested covered in other tests - they don't need to be here.
BOOST_REQUIRE(result.stdoutContent.find("/// ethdebug: enabled") == std::string::npos); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(cli_ethdebug_ethdebug_output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, given that you're covering the existence of /// ethdebug: enabled
in generated output for different CLI combinations, it's definitely better that they're all here instead of in a million cmdlineTests with massive outputs - but it would none the less be good to have at least one cmdlineTest that should the full generated output (a smoke test if you will).
f1a73c3
to
93749ff
Compare
93749ff
to
0dd51e5
Compare
0dd51e5
to
55503ce
Compare
55503ce
to
f73d37b
Compare
debug-info
was set toethdebug
ir
,irOptimized
and/orethdebug
was selected as output.standard_debug_info_in_yul_ethdebug_output_ir_optimized
,standard_debug_info_in_yul_ethdebug_output_no_ir
strict-assembly
e.g.solc --strict-assembly <yul> --debug-info ethdebug
debug-info
ethdebug
is excluded from the help on clidebug-info
ethdebug
is excluded fromall
on cli and wildcard selection*
in standard-jsonethdebug
was selected as outputdebug-info
was selected, it implicitly setdebug-info
toethdebug
.solc <contract> --ethdebug
via-ir
was not specified, it will error with a message stating thatethdebug
can only be selected as output, ifvia-ir
was defined.solc <contract> --ethdebug
only works with--via-ir
debug-info
was selected and did not containethdebug
, an error will be generated stating thatethdebug
need to be set indebug-info
solc <contract> --ethdebug --debug-info location
strict-assembly
will always work e.g.solc --strict-assembly <yul> --ethdebug
ethdebug
is not shown in cli helpethdebug
output selection is excluded from wildcard selection*
in standard-jsonUPDATE
After some discussion with @gnidan and @ekpyron it turned out that we need something slightly different:
ethdebug
output will now be enabled withevm.bytecode.ethdebug
(deploytime part) andevm.deployedBytecode.ethdebug
(runtime part)evm.bytecode
andevm.deployedBytecode
behave like a wildcard, so the ethdebug stuff is excluded here.--bin
and--bin-runtime
ethdebug selection will now work similar with--ethdebug
and--ethdebug-runtime