Skip to content

Commit

Permalink
Merge pull request #93 from willglynn/fix/symbol-modi
Browse files Browse the repository at this point in the history
Parse module references in symbol data
  • Loading branch information
jan-auer authored Jun 2, 2022
2 parents 494ec12 + 6aea613 commit ad39f23
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/dbi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ pub struct DBISectionContribution {
///
/// [`IMAGE_SECTION_HEADER`]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms680341(v=vs.85).aspx
pub characteristics: u32,
/// The index of the module.
pub module: u16,
/// Index of the module in [`DebugInformation::modules`] containing the actual symbol.
pub module: usize,
/// CRC of the contribution(?)
pub data_crc: u32,
/// CRC of relocations(?)
Expand All @@ -402,7 +402,7 @@ impl DBISectionContribution {
let offset = buf.parse_u32()?;
let size = buf.parse_u32()?;
let characteristics = buf.parse_u32()?;
let module = buf.parse_u16()?;
let module = buf.parse_u16()?.into();
let _padding = buf.parse_u16()?;

Ok(DBISectionContribution {
Expand Down
27 changes: 15 additions & 12 deletions src/symbol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,9 @@ pub struct ProcedureReferenceSymbol<'t> {
///
/// Note that this symbol might be located in a different module.
pub symbol_index: SymbolIndex,
/// Index of the module containing the actual symbol.
pub module: u16,
/// Index of the module in [`DebugInformation::modules`](crate::DebugInformation::modules)
/// containing the actual symbol.
pub module: Option<usize>,
/// Name of the procedure reference.
pub name: Option<RawString<'t>>,
}
Expand All @@ -492,7 +493,7 @@ impl<'t> TryFromCtx<'t, SymbolKind> for ProcedureReferenceSymbol<'t> {
global: matches!(kind, S_PROCREF | S_PROCREF_ST),
sum_name: buf.parse()?,
symbol_index: buf.parse()?,
module: buf.parse()?,
module: buf.parse::<u16>()?.checked_sub(1).map(usize::from),
name: parse_optional_name(&mut buf, kind)?,
};

Expand All @@ -511,8 +512,9 @@ pub struct DataReferenceSymbol<'t> {
///
/// Note that this symbol might be located in a different module.
pub symbol_index: SymbolIndex,
/// Index of the module containing the actual symbol.
pub module: u16,
/// Index of the module in [`DebugInformation::modules`](crate::DebugInformation::modules)
/// containing the actual symbol.
pub module: Option<usize>,
/// Name of the data reference.
pub name: Option<RawString<'t>>,
}
Expand All @@ -526,7 +528,7 @@ impl<'t> TryFromCtx<'t, SymbolKind> for DataReferenceSymbol<'t> {
let symbol = DataReferenceSymbol {
sum_name: buf.parse()?,
symbol_index: buf.parse()?,
module: buf.parse()?,
module: buf.parse::<u16>()?.checked_sub(1).map(usize::from),
name: parse_optional_name(&mut buf, kind)?,
};

Expand All @@ -545,8 +547,9 @@ pub struct AnnotationReferenceSymbol<'t> {
///
/// Note that this symbol might be located in a different module.
pub symbol_index: SymbolIndex,
/// Index of the module containing the actual symbol.
pub module: u16,
/// Index of the module in [`DebugInformation::modules`](crate::DebugInformation::modules)
/// containing the actual symbol.
pub module: Option<usize>,
/// Name of the annotation reference.
pub name: RawString<'t>,
}
Expand All @@ -560,7 +563,7 @@ impl<'t> TryFromCtx<'t, SymbolKind> for AnnotationReferenceSymbol<'t> {
let symbol = AnnotationReferenceSymbol {
sum_name: buf.parse()?,
symbol_index: buf.parse()?,
module: buf.parse()?,
module: buf.parse::<u16>()?.checked_sub(1).map(usize::from),
name: parse_symbol_name(&mut buf, kind)?,
};

Expand Down Expand Up @@ -670,7 +673,7 @@ const CV_PFLAG_CUST_CALL: u8 = 0x20;
const CV_PFLAG_NOINLINE: u8 = 0x40;
const CV_PFLAG_OPTDBGINFO: u8 = 0x80;

/// Flags of a [`ProcedureSymbol`](struct.ProcedureSymbol).
/// Flags of a [`ProcedureSymbol`].
#[non_exhaustive]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct ProcedureFlags {
Expand Down Expand Up @@ -1764,7 +1767,7 @@ mod tests {
global: true,
sum_name: 0,
symbol_index: SymbolIndex(108),
module: 1,
module: Some(0),
name: Some("Baz::f_public".into()),
})
);
Expand Down Expand Up @@ -1878,7 +1881,7 @@ mod tests {
global: false,
sum_name: 0,
symbol_index: SymbolIndex(1152),
module: 182,
module: Some(181),
name: Some("capture_current_context".into()),
})
);
Expand Down

0 comments on commit ad39f23

Please sign in to comment.