pub struct Cached { /* private fields */ }Expand description
Coverage collector that maintains an in-memory mapping from source locations to execution counts.
Cached keeps a small cache mapping instruction addresses to source
LineInfo (if available) and a coverage map counting visits per file
and line. It also tracks the set of files seen.
Implementations§
Source§impl Cached
impl Cached
Sourcepub fn files(&self) -> &HashSet<String>
pub fn files(&self) -> &HashSet<String>
Return the set of files observed by the collector.
§Returns
A reference to the HashSet of file paths that have been observed.
Sourcepub fn print_source(
&mut self,
instruction: &Instruction,
dwarf: &Dwarf<'_>,
record: bool,
) -> Result<Option<String>>
pub fn print_source( &mut self, instruction: &Instruction, dwarf: &Dwarf<'_>, record: bool, ) -> Result<Option<String>>
Print the source line corresponding to instruction when available.
This looks up the DWARF line info for the instruction address and
prints the source line if the file exists on disk. When record is
true the collector updates its internal coverage counts and file set.
§Arguments
instruction- The disassembled instruction whose source line to print.dwarf- DWARF helper used to resolve addresses to source lines.record- When true the collector records coverage counts for the located source line.
§Errors
Returns an error if DWARF lookup fails.
Sourcepub fn trace_with_source_print(
&mut self,
context: &Tracer,
process: &Info,
) -> Result<i32>
pub fn trace_with_source_print( &mut self, context: &Tracer, process: &Info, ) -> Result<i32>
Run the tracer and print source lines when available.
This convenience wraps trace_with using the collector’s
print_source formatter so each executed instruction prints a
source line when the DWARF information is present.
§Arguments
context- The tracer implementation used to run the program.process- Process metadata for the target binary.
§Errors
Returns an error if DWARF construction fails or if tracing fails.
Sourcepub fn trace_with_custom_progress(
&mut self,
context: &Tracer,
process: &Info,
dwarf: Option<&Dwarf<'_>>,
record: bool,
progress: impl ProgressFn,
) -> Result<i32>
pub fn trace_with_custom_progress( &mut self, context: &Tracer, process: &Info, dwarf: Option<&Dwarf<'_>>, record: bool, progress: impl ProgressFn, ) -> Result<i32>
Run the tracer using a custom progress function and optionally print source lines.
If dwarf is Some, the tracer will attempt to print source lines
(when the layout indicates source); otherwise it falls back to the
default printer. When record is true coverage counts are collected.
The provided progress function is used for user interaction between
instructions.
§Arguments
context- The tracer implementation used to run the program.process- Process metadata for the target binary.dwarf- Optional DWARF helper; whenSomesource printing is enabled.record- If true, coverage counts are recorded.progress- Custom progress function called between instructions.
§Errors
Returns an error if tracing or DWARF operations fail.
Sourcepub fn trace_with_default_progress(
&mut self,
context: &Tracer,
process: &Info,
) -> Result<i32>
pub fn trace_with_default_progress( &mut self, context: &Tracer, process: &Info, ) -> Result<i32>
Run the tracer with the default progress function and recording enabled.
This is the standard entry point for coverage collection: it tries
to build DWARF info and then calls trace_with_custom_progress.
§Arguments
context- The tracer implementation used to run the program.process- Process metadata for the target binary.
§Errors
Returns an error if DWARF construction or tracing fails.