Struct

Struct Struct 

Source
pub struct Struct {
    pub location: DwarfUnit,
}
Expand description

Represents a struct type

Fields§

§location: DwarfUnit

Implementations§

Source§

impl Struct

Source

pub fn alignment_stats<D>(&self, dwarf: &D) -> Result<AlignmentStats, Error>
where D: DwarfContext + BorrowableDwarf,

Source

pub fn to_string_verbose<D>( &self, dwarf: &D, verbosity: u8, ) -> Result<String, Error>
where D: BorrowableDwarf + DwarfContext,

Examples found in repository?
examples/dump_verbose.rs (line 26)
7fn main() -> anyhow::Result<()> {
8    let mut args = std::env::args().skip(1);
9    let path = args.next().unwrap_or_else(|| {
10        eprintln!("Usage: dump_verbose <path> [verbosity-level]");
11        std::process::exit(1);
12    });
13    let verbosity = args.next().unwrap_or_else(|| {
14        "0".to_string()
15    });
16
17    let verbosity = verbosity.parse::<u8>()?;
18
19    let file = File::open(path)?;
20    let mmap = unsafe { Mmap::map(&file) }?;
21    let dwarf = Dwarf::load(&*mmap)?;
22
23    let struct_map = dwarf.get_fg_named_structs_map()?;
24
25    for (_, struc) in struct_map.into_iter() {
26        println!("{}", struc.to_string_verbose(&dwarf, verbosity)?);
27    }
28
29    Ok(())
30}
More examples
Hide additional examples
examples/lookup.rs (line 37)
7fn main() -> anyhow::Result<()> {
8    let mut args = std::env::args().skip(1);
9    let struct_name = args.next().unwrap_or_else(|| {
10        eprintln!("Usage: lookup <struct_name> <path> [verbosity]");
11        std::process::exit(1);
12    }).to_string();
13    let path = args.next().unwrap_or_else(|| {
14        eprintln!("Usage: lookup <struct_name> <path> [verbosity]");
15        std::process::exit(1);
16    });
17    let verbosity = args.next().unwrap_or_else(|| {
18        "0".to_string()
19    });
20
21    let verbosity = verbosity.parse::<u8>()?;
22
23    let file = File::open(path).unwrap();
24    let mmap = unsafe { Mmap::map(&file) }.unwrap();
25    let dwarf = Dwarf::load(&*mmap)?;
26
27    // some good test cases:
28    // compat_rusage
29    // file_system_type
30    // trace_event_raw_itimer_expire
31    // sev_config
32    // mca_config
33    // ntb_ctrl_regs
34
35    let found = dwarf.lookup_type::<dwat::Struct>(struct_name)?;
36    if let Some(found) = found {
37        println!("{}", found.to_string_verbose(&dwarf, verbosity)?);
38    }
39
40    Ok(())
41}
Source

pub fn to_string<D>(&self, dwarf: &D) -> Result<String, Error>
where D: BorrowableDwarf + DwarfContext,

Source

pub fn byte_size<D>(&self, dwarf: &D) -> Result<usize, Error>
where D: DwarfContext,

Source

pub fn alignment<D>(&self, dwarf: &D) -> Result<usize, Error>
where D: DwarfContext,

Trait Implementations§

Source§

impl Clone for Struct

Source§

fn clone(&self) -> Struct

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Struct

Source§

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

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

impl HasMembers for Struct

Source§

fn members<D>(&self, dwarf: &D) -> Result<Vec<Member>, Error>
where D: DwarfContext,

Get the members/fields of this type
Source§

impl NamedType for Struct

Source§

fn name<D>(&self, dwarf: &D) -> Result<String, Error>
where D: DwarfContext + BorrowableDwarf,

Source§

impl Tagged for Struct

Source§

fn new(location: DwarfUnit) -> Self

Source§

fn tag() -> DwTag

Source§

impl Copy for Struct

Auto Trait Implementations§

§

impl Freeze for Struct

§

impl RefUnwindSafe for Struct

§

impl Send for Struct

§

impl Sync for Struct

§

impl Unpin for Struct

§

impl UnwindSafe for Struct

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 = 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.