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.
12//! - [`abi`] encodes calldata and parses function signatures, including tuples and
13//!   arrays, and carries the keccak-256 implementation used to derive selectors.
14//! - [`events`] decodes logs against event ABIs.
15//!
16//! Everything decoded here comes from files or from chain data, so it is untrusted:
17//! offsets and lengths read out of an artifact or a log payload are validated rather
18//! than trusted to be in range.
19
20pub mod abi;
21pub mod artifacts;
22pub mod events;
23pub mod metadata;
24pub mod source_map;
25pub mod storage_layout;
26
27pub use abi::{
28    canonical_abi_input_type, encode_abi_arguments, encode_function_call, function_selector,
29    keccak256, match_abi_types, match_single_type, parse_signature, parse_tuple_arg, AbiInput,
30    FunctionSignature,
31};
32pub use artifacts::{
33    contract_name_from_program_path, ethdebug_resources_from_metadata, find_ethdebug_metadata,
34    find_program_ethdebug, load_debug_program, load_debug_program_with_sources,
35    load_storage_layout, read_debug_source, read_debug_source_from, read_json_file,
36    source_candidates, DebugProgram,
37};
38pub use events::{
39    event_signature, event_topic, parse_event_abis, DecodedEvent, DecodedEventArg, EventAbi,
40    EventParam, EventRegistry, EventRegistryEntry,
41};
42pub use metadata::{
43    parse_compilation_sources, parse_ethdebug_spec, parse_multi_contract_spec,
44    parse_single_contract_spec, parse_variable_locations, read_compilation_source, EthdebugInfo,
45    EthdebugSpec, FunctionExit, FunctionIdentity, Instruction, SourceLocation, VariableLocation,
46};
47pub use source_map::{
48    build_pc_to_instruction_map, is_legacy_compiler, load_source_map_program,
49    load_source_map_program_with_sources, parse_srcmap, SourceMapEntry, SourceMapEnvironment,
50    SourceMapInfo, SourceMapProgram,
51};
52pub use storage_layout::{
53    add_word, decode_value, element_place, mapping_slot, parse_word, word_hex, word_to_decimal,
54    DecodedStorage, StorageEncoding, StorageLayout, StorageMember, StorageRef, StorageType,
55    StorageVariable, Word,
56};