pub struct TypeFormatter<'a, 's> { /* private fields */ }
Expand description

Allows printing function signatures, for example for use in stack traces.

Procedure symbols in PDBs usually have a name string which only includes the function name, and no function arguments. Instead, the arguments need to be obtained from the symbol’s type information. TypeFormatter handles that.

The same is true for “inlinee” functions - these are referenced by their pdb::IdIndex, and their IdData’s name string again only contains the raw function name but no arguments and also no namespace or class name. TypeFormatter handles those, too, in TypeFormatter::format_id.

Implementations§

source§

impl<'a, 's> TypeFormatter<'a, 's>

source

pub fn new_from_parts( module_provider: &'a (dyn ModuleProvider<'s> + Sync), modules: Vec<Module<'a>>, debug_info: &DebugInformation<'s>, type_info: &'a TypeInformation<'s>, id_info: &'a IdInformation<'s>, string_table: Option<&'a StringTable<'s>>, flags: TypeFormatterFlags ) -> Result<Self, Error>

Create a TypeFormatter manually. Most consumers will want to use [ContextPdbData::make_type_formatter] instead.

However, if you interact with a PDB directly and parse some of its contents for other uses, you may want to call this method in order to avoid overhead from repeatedly parsing the same streams.

source

pub fn modules(&self) -> &[Module<'a>]

A reference to the Module list that is owned by the type formatter.

source

pub fn get_type_size(&self, module_index: usize, index: TypeIndex) -> u64

Get the size, in bytes, of the type at index.

source

pub fn format_function( &self, name: &str, module_index: usize, function_type_index: TypeIndex ) -> Result<String, Error>

Return a string with the function or method signature, including return type (if requested), namespace and/or class qualifiers, and arguments. If the TypeIndex is 0, then only the raw name is emitted. In that case, the name may need to go through additional demangling / “undecorating”, but this is the responsibility of the caller. This method is used for ProcedureSymbols. The module_index is the index of the module in which this procedure was found. It is necessary in order to properly resolve cross-module references.

source

pub fn emit_function( &self, w: &mut impl Write, name: &str, module_index: usize, function_type_index: TypeIndex ) -> Result<(), Error>

Write out the function or method signature, including return type (if requested), namespace and/or class qualifiers, and arguments. If the TypeIndex is 0, then only the raw name is emitted. In that case, the name may need to go through additional demangling / “undecorating”, but this is the responsibility of the caller. This method is used for ProcedureSymbols. The module_index is the index of the module in which this procedure was found. It is necessary in order to properly resolve cross-module references.

source

pub fn format_id( &self, module_index: usize, id_index: IdIndex ) -> Result<String, Error>

Return a string with the function or method signature, including return type (if requested), namespace and/or class qualifiers, and arguments. This method is used for inlined functions. The module_index is the index of the module in which this IdIndex was found. It is necessary in order to properly resolve cross-module references.

source

pub fn emit_id( &self, w: &mut impl Write, module_index: usize, id_index: IdIndex ) -> Result<(), Error>

Write out the function or method signature, including return type (if requested), namespace and/or class qualifiers, and arguments. This method is used for inlined functions. The module_index is the index of the module in which this IdIndex was found. It is necessary in order to properly resolve cross-module references.

Auto Trait Implementations§

§

impl<'a, 's> !RefUnwindSafe for TypeFormatter<'a, 's>

§

impl<'a, 's> Send for TypeFormatter<'a, 's>

§

impl<'a, 's> Sync for TypeFormatter<'a, 's>

§

impl<'a, 's> Unpin for TypeFormatter<'a, 's>

§

impl<'a, 's> !UnwindSafe for TypeFormatter<'a, 's>

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>,

§

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>,

§

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.