Skip to main content

ContractDebugInfo

Struct ContractDebugInfo 

Source
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: SourceTypes

The 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

Source

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.

Source

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.

Source

pub const fn with_code_generator( self, code_generator: Option<CodeGenerator>, ) -> Self

Records which code generator produced the program.

Source

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.

Source

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.

Source

pub fn with_transient_storage_layout( self, layout: Option<StorageLayout>, ) -> Self

Attaches the layout of the contract’s transient state variables.

Source

pub fn function_entry_at_pc(&self, pc: u64) -> Option<usize>

The function whose entry point pc is, when it is one.

Source

pub fn is_jumpdest(&self, pc: u64) -> bool

Whether the instruction at pc is a JUMPDEST.

Source

pub fn jump_marker_at_pc(&self, pc: u64) -> JumpMarker

What the artifact says about the jump the instruction at pc makes.

Source

pub fn source_path(&self, source_id: u64) -> Option<&str>

Source

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.

Source

pub fn column_of(&self, source_id: u64, offset: u64) -> Option<u64>

Source

pub fn line_count(&self, source_id: u64) -> Option<u64>

Source

pub fn line_text(&self, source_id: u64, line: u64) -> Option<&str>

The text of one line, without its line ending.

Source

pub fn location_at_pc(&self, pc: u64) -> Option<SourceLocation>

The source span the compiler attached to the instruction at pc.

Source

pub fn instruction_at_pc(&self, pc: u64) -> Option<&Instruction>

The compiler’s instruction at pc, using the prepared index.

Source

pub fn modifier_depth_at_pc(&self, pc: u64) -> Option<i64>

Legacy source-map modifier depth at pc, when the artifact carries it.

Source

pub fn function_for_location(&self, location: &SourceLocation) -> Option<usize>

The narrowest parsed function whose declaration contains the span.

Source

pub fn function_at_pc(&self, pc: u64) -> Option<&SourceFunction>

Source

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.

Trait Implementations§

Source§

impl Clone for ContractDebugInfo

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContractDebugInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ContractDebugInfo

Source§

impl PartialEq for ContractDebugInfo

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ContractDebugInfo

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.