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.
Decoding is all-or-nothing: a record type this crate cannot represent is an
error rather than a silent drop. 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: GsymVersionVersion from which this model was decoded.
source_endian: EndianByte order from which this model was decoded.
base_address: u64Image 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
impl DecodedGsym
Sourcepub fn to_builder(&self, options: TranscodeOptions) -> Result<GsymBuilder>
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.
Sourcepub fn into_builder(self, options: TranscodeOptions) -> Result<GsymBuilder>
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.
Sourcepub fn transcode(self, options: TranscodeOptions) -> Result<Vec<u8>>
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.
Sourcepub fn segments(
&self,
target_size: usize,
options: TranscodeOptions,
) -> Result<Vec<GsymSegment>>
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.
Each shard covers a contiguous address span, so
GsymSegment::first_address and GsymSegment::end_address are
enough to route an address to a shard. 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.