Skip to main content

soldb_ethdebug/
lib.rs

1//! Loading and interpreting compiler-generated Solidity debug information.
2//!
3//! This is the metadata half of an ETHDebug-first debugger: it turns `solc` artifacts
4//! into the program-counter, source-location, variable, and ABI lookups the rest of the
5//! workspace needs. Nothing here touches the network.
6//!
7//! - [`metadata`] models ETHDebug artifacts: instructions, their source spans, live
8//!   variable locations, and the `address:name:dir` contract specs used on the command
9//!   line.
10//! - [`source_map`] reads the legacy `srcmap` format for compiler and tooling
11//!   interoperability when ETHDebug programs are unavailable, naming its instructions
12//!   through [`opcodes`].
13//! - [`abi`] encodes calldata and parses function signatures, including tuples and
14//!   arrays, and carries the keccak-256 implementation used to derive selectors.
15//! - [`events`] decodes logs against event ABIs.
16//!
17//! Everything decoded here comes from files or from chain data, so it is untrusted:
18//! offsets and lengths read out of an artifact or a log payload are validated rather
19//! than trusted to be in range.
20
21pub mod abi;
22pub mod artifacts;
23pub mod events;
24pub mod metadata;
25pub mod opcodes;
26pub mod source_map;
27pub mod storage_layout;
28
29pub use abi::{
30    canonical_abi_input_type, encode_abi_arguments, encode_function_call, function_selector,
31    keccak256, match_abi_types, match_single_type, parse_signature, parse_tuple_arg, AbiInput,
32    FunctionSignature,
33};
34pub use artifacts::{
35    contract_name_from_program_path, ethdebug_resources_from_metadata, find_ethdebug_metadata,
36    find_program_ethdebug, load_contract_mapping, load_debug_program,
37    load_debug_program_with_sources, load_storage_layout, load_transient_storage_layout,
38    parse_contract_mapping, read_debug_source, read_json_file, source_candidates, CodeGenerator,
39    ContractMapping, DebugProgram,
40};
41pub use events::{
42    event_signature, event_topic, parse_event_abis, DecodedEvent, DecodedEventArg, EventAbi,
43    EventParam, EventRegistry, EventRegistryEntry,
44};
45pub use metadata::{
46    parse_compilation_sources, parse_ethdebug_spec, parse_multi_contract_spec,
47    parse_single_contract_spec, parse_variable_locations, read_compilation_source, EthdebugInfo,
48    EthdebugSpec, FunctionExit, FunctionIdentity, Instruction, SourceLocation, VariableLocation,
49};
50pub use source_map::{
51    build_pc_to_instruction_map, is_legacy_compiler, load_source_map_program,
52    load_source_map_program_with_sources, parse_srcmap, SourceMapEntry, SourceMapEnvironment,
53    SourceMapInfo, SourceMapProgram,
54};
55pub use storage_layout::{
56    add_word, decode_value, element_place, mapping_slot, parse_path, parse_word, word_hex,
57    word_to_decimal, DecodedStorage, PathSegment, StorageEncoding, StorageLayout, StorageMember,
58    StorageRef, StorageType, StorageVariable, Word,
59};