Skip to main content

Info

Struct Info 

Source
pub struct Info { /* private fields */ }
Expand description

Process metadata and parsed ELF image used by the tracer.

Info holds the auxiliary vector, an in-memory copy of the ELF file contents, parsed headers/sections, and the offsets needed to translate runtime addresses to file offsets. Construct using Info::build.

Implementations§

Source§

impl Info

Source

pub fn build(path: &str, pid: Pid) -> Result<Self>

Builds an Info struct by collecting process data.

§Arguments
  • path - The path to the file containing process data.
  • pid - The process ID.
§Errors

Returns an Err upon any failure while collecting process data.

§Returns

Returns a Result containing the Info struct upon success, or an Err upon failure.

Source

pub fn pid(&self) -> Pid

Return the PID associated with this Info.

§Returns

The Pid belonging to the traced process.

Source

pub fn endianness(&self) -> u8

Return the ELF data encoding (endianness) byte (EI_DATA).

This value matches the ELF header e_ident[EI_DATA] and can be compared against ELFDATA2LSB/ELFDATA2MSB constants.

§Returns

The ELF e_ident[EI_DATA] byte as a u8.

Source

pub fn offset(&self) -> u64

Return the offset used to translate file addresses to runtime addresses (i.e., mem_offset - load_vaddr).

§Returns

The computed offset which should be added to file addresses to obtain runtime addresses (equal to mem_offset - load_vaddr).

Source

pub fn is_addr_in_section(&self, addr: u64, name: &str) -> bool

Return true if addr lies within the named ELF section (e.g. “.text”). Addresses are compared against the section’s runtime address (section.sh_addr + mem_offset).

§Arguments
  • addr - Runtime address to test.
  • name - The section name to check (for example ".text").
§Returns

true if addr falls within the runtime range of the named section (computed as section.sh_addr + mem_offset .. + sh_size), otherwise false.

Source

pub fn entry(&self) -> Result<&u64>

Retrieves the runtime entry point address of the process from the auxiliary vector.

§Errors

Returns an Err if the entry point is not available in the auxiliary vector.

§Returns

Returns a Result containing a reference to the entry point address (u64) from the auxiliary vector (AT_ENTRY).

Source

pub fn get_section_data(&self, name: &str) -> Result<Option<&[u8]>>

Retrieves the data from the specified section.

§Arguments
  • name - The name of the section.
§Errors

Returns an Err if the conversion from u64 to usize fails when getting buffer data.

§Returns

Returns an Ok containing the data from the specified section as a slice of bytes, or Err if the section does not exist or if the conversion from u64 to usize fails.

Source

pub fn get_opcode_from_addr(&self, addr: u64) -> Result<Option<&[u8]>>

Retrieves opcode data from the loaded binary at a given runtime address.

§Arguments
  • addr - The runtime address for which to fetch opcode bytes.
§Errors

Returns an Err if the conversion from u64 to usize fails when accessing the buffer, or if required auxiliary vector data is missing.

§Returns

Returns Ok(Some(&[u8])) containing the opcode bytes at the given address, Ok(None) if the address is invalid, or Err on conversion failure or missing data.

Auto Trait Implementations§

§

impl Freeze for Info

§

impl RefUnwindSafe for Info

§

impl Send for Info

§

impl Sync for Info

§

impl Unpin for Info

§

impl UnsafeUnpin for Info

§

impl UnwindSafe for Info

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.