Skip to main content

DecodedGsym

Struct DecodedGsym 

Source
pub struct DecodedGsym {
    pub source_version: GsymVersion,
    pub source_endian: Endian,
    pub base_address: u64,
    pub build_id: Vec<u8>,
    pub files: Vec<FileEntry>,
    pub functions: Vec<Function>,
}
Expand description

An owned, version-independent representation of a complete GSYM file.

Decode with Gsym::decode_all, edit the public semantic fields when needed, then use Self::into_builder or Self::transcode to move the model into a new encoding.

A FunctionInfo record of a type this crate does not model makes decoding fail rather than silently disappearing during re-encoding. source_version and source_endian record what the input used, and TranscodeOptions overrides either one for the output.

File indices in the model refer to Self::files, including the reserved empty entry at index zero. Re-encoding renumbers the table and keeps only the files the retained functions reference.

Fields§

§source_version: GsymVersion

Version from which this model was decoded.

§source_endian: Endian

Byte order from which this model was decoded.

§base_address: u64

Image base address.

§build_id: Vec<u8>

Opaque build identifier.

§files: Vec<FileEntry>

Complete file table, including reserved index zero.

§functions: Vec<Function>

Fully decoded semantic functions.

Implementations§

Source§

impl DecodedGsym

Source

pub fn to_builder(&self, options: TranscodeOptions) -> Result<GsymBuilder>

Builds a deterministic writer model by cloning this decoded model.

Use Self::into_builder when this model is no longer needed.

§Errors

Returns an error for invalid file references or model data.

Source

pub fn into_builder(self, options: TranscodeOptions) -> Result<GsymBuilder>

Converts this decoded model into a deterministic writer without cloning its file or function trees.

§Errors

Returns an error for invalid file references or model data.

Source

pub fn transcode(self, options: TranscodeOptions) -> Result<Vec<u8>>

Encodes the complete model using the requested output settings.

use gsym::{
    AddressRange, Endian, Function, Gsym, GsymBuilder, GsymVersion,
    TranscodeOptions,
};

let mut builder = GsymBuilder::new();
builder.add_function(Function::new(
    AddressRange::new(0x4000, 0x4010),
    b"transcoded",
))?;
let source = builder.to_bytes()?;
let decoded = Gsym::parse(source)?.decode_all()?;
let output = decoded.transcode(TranscodeOptions {
    version: Some(GsymVersion::V2),
    endian: Some(Endian::Big),
})?;

let reparsed = Gsym::parse(output)?;
assert_eq!(reparsed.header().version, GsymVersion::V2);
assert_eq!(reparsed.header().endian, Endian::Big);
§Errors

Returns an error when the model cannot be represented by the requested format version.

Source

pub fn segments( &self, target_size: usize, options: TranscodeOptions, ) -> Result<Vec<GsymSegment>>

Splits the model into independently valid GSYM files near target_size.

A single record larger than the target is emitted alone. Each shard contains only source files referenced by its functions. Boundaries are selected from exact encoded sizes, so all multi-function shards are at most the requested target.

Shards are ordered by address and their [first_address, end_address) spans tile the covered range without a gap, so GsymSegment::first_address and GsymSegment::end_address are enough to route an address to a shard: the shard whose span holds an address is the shard that resolves it, and an address below the first shard resolves nowhere, exactly as in the unsplit file. Segmentation is considerably more expensive than a single encode.

§Errors

Returns an error for a zero target, empty model, invalid references, or an encoding failure.

Trait Implementations§

Source§

impl Debug for DecodedGsym

Source§

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

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

impl Eq for DecodedGsym

Source§

impl PartialEq for DecodedGsym

Source§

fn eq(&self, other: &DecodedGsym) -> 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 DecodedGsym

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more