pub struct ContractDebugInfo {
pub address: Option<String>,
pub code_hash: Option<String>,
pub name: String,
pub info: EthdebugInfo,
pub source_contents: BTreeMap<u64, String>,
pub functions: Vec<SourceFunction>,
pub types: SourceTypes,
pub storage_layout: Option<StorageLayout>,
pub transient_storage_layout: Option<StorageLayout>,
pub code_generator: Option<CodeGenerator>,
/* private fields */
}Expand description
One contract’s debug information, prepared for stepping: the ETHDebug metadata, the source text, the functions parsed from it, and the indexes that make per-step lookups constant time.
Fields§
§address: Option<String>The deployed address this info describes, lowercase, when known.
code_hash: Option<String>The keccak-256 hash of the code this info describes, lowercase, when known. A frame that records the hash of the code it runs only takes info with the same hash, so two programs run at one address map to their own sources.
name: String§info: EthdebugInfo§source_contents: BTreeMap<u64, String>§functions: Vec<SourceFunction>§types: SourceTypesThe struct, enum, and user-defined value type declarations of the sources, which say how a variable of such a type is shown.
storage_layout: Option<StorageLayout>Where the contract’s state variables live, when it was compiled with
--storage-layout.
transient_storage_layout: Option<StorageLayout>Where its transient state variables live, from --transient-storage-layout.
code_generator: Option<CodeGenerator>Which code generator produced the program, when the artifact or the host says.
Decides whether local variables can be inferred from the stack; see
StepMap::locals_at.
Implementations§
Source§impl ContractDebugInfo
impl ContractDebugInfo
Sourcepub fn new(
address: Option<&str>,
name: &str,
info: EthdebugInfo,
source_contents: BTreeMap<u64, String>,
) -> Self
pub fn new( address: Option<&str>, name: &str, info: EthdebugInfo, source_contents: BTreeMap<u64, String>, ) -> Self
Prepares one contract’s debug info. Functions are parsed from the source text, which serves ETHDebug and legacy source maps alike: both attach byte ranges of the same sources to instructions.
Sourcepub fn with_source_cache(
address: Option<&str>,
name: &str,
info: EthdebugInfo,
source_contents: BTreeMap<u64, String>,
cache: &mut SourceCache,
) -> Self
pub fn with_source_cache( address: Option<&str>, name: &str, info: EthdebugInfo, source_contents: BTreeMap<u64, String>, cache: &mut SourceCache, ) -> Self
Prepares one contract’s debug info as ContractDebugInfo::new does, reading
each source through cache so that the contracts sharing it read it once.
Sourcepub const fn with_code_generator(
self,
code_generator: Option<CodeGenerator>,
) -> Self
pub const fn with_code_generator( self, code_generator: Option<CodeGenerator>, ) -> Self
Records which code generator produced the program.
Sourcepub fn with_code_hash(self, code_hash: Option<&str>) -> Self
pub fn with_code_hash(self, code_hash: Option<&str>) -> Self
Records the hash of the code this info describes, so frames that record the hash of the code they run only map through matching info.
Sourcepub fn with_storage_layout(self, storage_layout: Option<StorageLayout>) -> Self
pub fn with_storage_layout(self, storage_layout: Option<StorageLayout>) -> Self
Attaches the contract’s storage layout, so state variables can be read by name.
Sourcepub fn with_transient_storage_layout(
self,
layout: Option<StorageLayout>,
) -> Self
pub fn with_transient_storage_layout( self, layout: Option<StorageLayout>, ) -> Self
Attaches the layout of the contract’s transient state variables.
Sourcepub fn function_entry_at_pc(&self, pc: u64) -> Option<usize>
pub fn function_entry_at_pc(&self, pc: u64) -> Option<usize>
The function whose entry point pc is, when it is one.
Sourcepub fn is_jumpdest(&self, pc: u64) -> bool
pub fn is_jumpdest(&self, pc: u64) -> bool
Whether the instruction at pc is a JUMPDEST.
Sourcepub fn jump_marker_at_pc(&self, pc: u64) -> JumpMarker
pub fn jump_marker_at_pc(&self, pc: u64) -> JumpMarker
What the artifact says about the jump the instruction at pc makes.
pub fn source_path(&self, source_id: u64) -> Option<&str>
Sourcepub fn line_of(&self, source_id: u64, offset: u64) -> Option<u64>
pub fn line_of(&self, source_id: u64, offset: u64) -> Option<u64>
The one-based line a byte offset falls on, when the source text is available.
pub fn column_of(&self, source_id: u64, offset: u64) -> Option<u64>
pub fn line_count(&self, source_id: u64) -> Option<u64>
Sourcepub fn line_text(&self, source_id: u64, line: u64) -> Option<&str>
pub fn line_text(&self, source_id: u64, line: u64) -> Option<&str>
The text of one line, without its line ending.
Sourcepub fn location_at_pc(&self, pc: u64) -> Option<SourceLocation>
pub fn location_at_pc(&self, pc: u64) -> Option<SourceLocation>
The source span the compiler attached to the instruction at pc.
Sourcepub fn instruction_at_pc(&self, pc: u64) -> Option<&Instruction>
pub fn instruction_at_pc(&self, pc: u64) -> Option<&Instruction>
The compiler’s instruction at pc, using the prepared index.
Sourcepub fn modifier_depth_at_pc(&self, pc: u64) -> Option<i64>
pub fn modifier_depth_at_pc(&self, pc: u64) -> Option<i64>
Legacy source-map modifier depth at pc, when the artifact carries it.
Sourcepub fn function_for_location(&self, location: &SourceLocation) -> Option<usize>
pub fn function_for_location(&self, location: &SourceLocation) -> Option<usize>
The narrowest parsed function whose declaration contains the span.
pub fn function_at_pc(&self, pc: u64) -> Option<&SourceFunction>
Sourcepub fn effective_line(&self, source_id: u64, line: u64) -> Option<u64>
pub fn effective_line(&self, source_id: u64, line: u64) -> Option<u64>
The line a breakpoint on line of source_id resolves to: the line itself when
the compiler generated code that begins there, otherwise the first line of the
narrowest statement that contains it, or nothing when no code maps to the line.
Ranking matters because solc attaches the whole-contract span to the dispatcher, and that span intersects every line in the file.