Skip to content

Commit

Permalink
Merge pull request #2431 from crytic/fix/evm-printer
Browse files Browse the repository at this point in the history
Fix #2430
  • Loading branch information
0xalpharush authored Apr 18, 2024
2 parents ae0cb5b + 9413e1e commit 0fad849
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions slither/printers/summary/evm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Module printing evm mapping of the contract
"""
import logging

from slither.printers.abstract_printer import AbstractPrinter
from slither.analyses.evm import (
generate_source_to_evm_ins_mapping,
Expand All @@ -9,6 +11,9 @@
from slither.utils.colors import blue, green, magenta, red


logger: logging.Logger = logging.getLogger("EVMPrinter")


def _extract_evm_info(slither):
"""
Extract evm information for all derived contracts using evm_cfg_builder
Expand All @@ -24,6 +29,16 @@ def _extract_evm_info(slither):
contract_bytecode_runtime = contract.file_scope.bytecode_runtime(
contract.compilation_unit.crytic_compile_compilation_unit, contract.name
)

if not contract_bytecode_runtime:
logger.info(
"Contract %s (abstract: %r) has no bytecode runtime, skipping. ",
contract.name,
contract.is_abstract,
)
evm_info["empty", contract.name] = True
continue

contract_srcmap_runtime = contract.file_scope.srcmap_runtime(
contract.compilation_unit.crytic_compile_compilation_unit, contract.name
)
Expand Down Expand Up @@ -80,6 +95,10 @@ def output(self, _filename):
for contract in self.slither.contracts_derived:
txt += blue(f"Contract {contract.name}\n")

if evm_info.get(("empty", contract.name), False):
txt += "\tempty contract\n"
continue

contract_file = self.slither.source_code[
contract.source_mapping.filename.absolute
].encode("utf-8")
Expand Down

0 comments on commit 0fad849

Please sign in to comment.