-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Support ethdebug source locations under EOF #15994
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d75bd39
Ethdebug requires assembly instance
clonker 43b0f06
Ethdebug instructions output over multiple code sections
clonker 4ea1d47
Add ethdebug schema
clonker 3b924e6
Ethdebug uses schema for serialization
clonker 89a0f91
Update test expectations with eof-enabled ethdebug
clonker 482f64b
Test ethdebug output when requested in standard json under EOF
clonker 059bd8e
Add tests for ethdebug output on abstract contracts and interfaces
clonker dd25b24
Changelog uses single blank line between headlines
clonker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/* | ||
This file is part of solidity. | ||
|
||
solidity is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
solidity is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with solidity. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
#include <libevmasm/EthdebugSchema.h> | ||
|
||
#include <libsolutil/Numeric.h> | ||
#include <libsolutil/Visitor.h> | ||
|
||
using namespace solidity; | ||
using namespace solidity::evmasm::ethdebug; | ||
|
||
void schema::data::to_json(Json& _json, HexValue const& _hexValue) | ||
{ | ||
_json = util::toHex(_hexValue.value, util::HexPrefix::Add); | ||
} | ||
|
||
void schema::data::to_json(Json& _json, Unsigned const& _unsigned) | ||
{ | ||
std::visit(util::GenericVisitor{ | ||
[&](HexValue const& _hexValue) { _json = _hexValue; }, | ||
[&](std::uint64_t const _value) { _json = _value; } | ||
}, _unsigned.value); | ||
} | ||
|
||
void schema::materials::to_json(Json& _json, ID const& _id) | ||
{ | ||
std::visit(util::GenericVisitor{ | ||
[&](std::string const& _hexValue) { _json = _hexValue; }, | ||
[&](std::uint64_t const _value) { _json = _value; } | ||
}, _id.value); | ||
} | ||
|
||
void schema::materials::to_json(Json& _json, Reference const& _source) | ||
{ | ||
_json["id"] = _source.id; | ||
if (_source.type) | ||
_json["type"] = *_source.type == Reference::Type::Compilation ? "compilation" : "source"; | ||
} | ||
|
||
void schema::materials::to_json(Json& _json, SourceRange::Range const& _range) | ||
{ | ||
_json["length"] = _range.length; | ||
_json["offset"] = _range.offset; | ||
} | ||
|
||
|
||
void schema::materials::to_json(Json& _json, SourceRange const& _sourceRange) | ||
{ | ||
_json["source"] = _sourceRange.source; | ||
if (_sourceRange.range) | ||
_json["range"] = *_sourceRange.range; | ||
} | ||
|
||
void schema::to_json(Json& _json, Program::Contract const& _contract) | ||
{ | ||
if (_contract.name) | ||
_json["name"] = *_contract.name; | ||
_json["definition"] = _contract.definition; | ||
} | ||
|
||
void schema::program::to_json(Json& _json, Context::Variable const& _contextVariable) | ||
{ | ||
auto const numProperties = | ||
_contextVariable.identifier.has_value() + | ||
_contextVariable.declaration.has_value(); | ||
solRequire(numProperties >= 1, EthdebugException, "Context variable has no properties."); | ||
if (_contextVariable.identifier) | ||
{ | ||
solRequire(!_contextVariable.identifier->empty(), EthdebugException, "Variable identifier must not be empty."); | ||
_json["identifier"] = *_contextVariable.identifier; | ||
} | ||
if (_contextVariable.declaration) | ||
_json["declaration"] = *_contextVariable.declaration; | ||
} | ||
|
||
void schema::program::to_json(Json& _json, Context const& _context) | ||
{ | ||
solRequire(_context.code.has_value() + _context.remark.has_value() + _context.variables.has_value() >= 1, EthdebugException, "Context needs >=1 properties."); | ||
clonker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (_context.code) | ||
_json["code"] = *_context.code; | ||
if (_context.variables) | ||
{ | ||
solRequire(!_context.variables->empty(), EthdebugException, "Context variables must not be empty if provided."); | ||
_json["variables"] = *_context.variables; | ||
} | ||
if (_context.remark) | ||
_json["remark"] = *_context.remark; | ||
} | ||
|
||
void schema::program::to_json(Json& _json, Instruction::Operation const& _operation) | ||
{ | ||
_json = { {"mnemonic", _operation.mnemonic} }; | ||
if (!_operation.arguments.empty()) | ||
_json["arguments"] = _operation.arguments; | ||
} | ||
|
||
void schema::program::to_json(Json& _json, Instruction const& _instruction) | ||
{ | ||
_json["offset"] = _instruction.offset; | ||
if (_instruction.operation) | ||
_json["operation"] = *_instruction.operation; | ||
if (_instruction.context) | ||
_json["context"] = *_instruction.context; | ||
} | ||
|
||
void schema::to_json(Json& _json, Program const& _program) | ||
{ | ||
if (_program.compilation) | ||
_json["compilation"] = *_program.compilation; | ||
_json["contract"] = _program.contract; | ||
_json["environment"] = _program.environment; | ||
if (_program.context) | ||
_json["context"] = *_program.context; | ||
_json["instructions"] = _program.instructions; | ||
} | ||
|
||
void schema::to_json(Json& _json, Program::Environment const& _environment) | ||
{ | ||
switch (_environment) | ||
{ | ||
case Program::Environment::CALL: | ||
_json = "call"; | ||
break; | ||
case Program::Environment::CREATE: | ||
_json = "create"; | ||
break; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Uhh. Happy to fix this - but why? It's not like there's a blank line between bullet point list and headline anywhere else.
Uh oh!
There was an error while loading. Please reload this page.
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.
Ah, my bad, should have been the other way around - an extra empty line below :)
Two empty lines between sections.
Maybe we should just change the convention to a single line? No one seems to be able to keep it straight or see it in the diff and it gets changed by PRs back and forth. I usually ignore it but I got annoyed enough seeing it again to suggest a correction :)
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.
Haha yeah, that explains it. Might've also been my pre-coffee confusion that I didn't realize you meant the blank line below. I am absolutely fine with changing it to one line in any case! :)