-
Notifications
You must be signed in to change notification settings - Fork 970
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
Slither printer and API for getting evm instructions for contract source #281
Conversation
…s of Contract, Function or Node.
- Removes duplicate generate_source_to_evm_ins_mapping() in evm printer (reuse from SourceToEVM module) - Adds more comments for readability - Adds expected output for convert_to_evm_ins - Uses get_function_id from slither.utils.function
Note: Travis CI fails many checks because of missing
|
slither/printers/summary/evm.py
Outdated
evm_info = self._extract_evm_info(self.slither) | ||
|
||
for contract in self.slither.contracts_derived: | ||
print('Contract {}'.format(contract.name)) |
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.
Do not use print, create a string and call self.info
at the end.
See the other printers architecture
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, will do. I adopted this style from slithir
printer which has print
s (with empty self.info(txt)
) but looks like that is a bug. Will fix that too.
- Replaces sys.exit with SlitherError - Replaces prints with self.info - Moves slither.evm to slither.analyses.evm - Replaces class SourceToEVM static methods with functions - Makes KEY_EVM_INS into a constant - Adds wiki entry for evm printer
This PR addresses #209 to add a printer
evm
and an APIget_evm_instructions (obj)
whereobj
can be a contract, function or a node. It usesevm-cfg-builder
(https://github.com/crytic/evm_cfg_builder) to disassemble the bytecode and access evm instructions for the appropriate contract CFGs or functions as necessary.The
evm
printer outputs evm assembly instructions at corresponding source lines for all the nodes in the functions of the contracts. For example:The API
get_evm_instructions(obj)
returns a list ofpyevmasm
(https://github.com/crytic/pyevmasm) Instructions associated with theobj
. A sample script is shown below: