Skip to content

Commit e9b3119

Browse files
committed
Parse module references in symbol data
1 parent 98e2529 commit e9b3119

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/symbol/mod.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,10 @@ pub struct ProcedureReferenceSymbol<'t> {
476476
///
477477
/// Note that this symbol might be located in a different module.
478478
pub symbol_index: SymbolIndex,
479-
/// Index of the module containing the actual symbol.
480-
pub module: u16,
479+
/// Index of the module in [`DebugInformation::modules`] containing the actual symbol.
480+
///
481+
/// [`DebugInformation::modules`]: struct.DebugInformation.html#method.modules
482+
pub module: Option<usize>,
481483
/// Name of the procedure reference.
482484
pub name: Option<RawString<'t>>,
483485
}
@@ -492,7 +494,7 @@ impl<'t> TryFromCtx<'t, SymbolKind> for ProcedureReferenceSymbol<'t> {
492494
global: matches!(kind, S_PROCREF | S_PROCREF_ST),
493495
sum_name: buf.parse()?,
494496
symbol_index: buf.parse()?,
495-
module: buf.parse()?,
497+
module: buf.parse::<u16>()?.checked_sub(1).map(usize::from),
496498
name: parse_optional_name(&mut buf, kind)?,
497499
};
498500

@@ -511,8 +513,10 @@ pub struct DataReferenceSymbol<'t> {
511513
///
512514
/// Note that this symbol might be located in a different module.
513515
pub symbol_index: SymbolIndex,
514-
/// Index of the module containing the actual symbol.
515-
pub module: u16,
516+
/// Index of the module in [`DebugInformation::modules`] containing the actual symbol.
517+
///
518+
/// [`DebugInformation::modules`]: struct.DebugInformation.html#method.modules
519+
pub module: Option<usize>,
516520
/// Name of the data reference.
517521
pub name: Option<RawString<'t>>,
518522
}
@@ -526,7 +530,7 @@ impl<'t> TryFromCtx<'t, SymbolKind> for DataReferenceSymbol<'t> {
526530
let symbol = DataReferenceSymbol {
527531
sum_name: buf.parse()?,
528532
symbol_index: buf.parse()?,
529-
module: buf.parse()?,
533+
module: buf.parse::<u16>()?.checked_sub(1).map(usize::from),
530534
name: parse_optional_name(&mut buf, kind)?,
531535
};
532536

@@ -545,8 +549,10 @@ pub struct AnnotationReferenceSymbol<'t> {
545549
///
546550
/// Note that this symbol might be located in a different module.
547551
pub symbol_index: SymbolIndex,
548-
/// Index of the module containing the actual symbol.
549-
pub module: u16,
552+
/// Index of the module in [`DebugInformation::modules`] containing the actual symbol.
553+
///
554+
/// [`DebugInformation::modules`]: struct.DebugInformation.html#method.modules
555+
pub module: Option<usize>,
550556
/// Name of the annotation reference.
551557
pub name: RawString<'t>,
552558
}
@@ -560,7 +566,7 @@ impl<'t> TryFromCtx<'t, SymbolKind> for AnnotationReferenceSymbol<'t> {
560566
let symbol = AnnotationReferenceSymbol {
561567
sum_name: buf.parse()?,
562568
symbol_index: buf.parse()?,
563-
module: buf.parse()?,
569+
module: buf.parse::<u16>()?.checked_sub(1).map(usize::from),
564570
name: parse_symbol_name(&mut buf, kind)?,
565571
};
566572

@@ -1764,7 +1770,7 @@ mod tests {
17641770
global: true,
17651771
sum_name: 0,
17661772
symbol_index: SymbolIndex(108),
1767-
module: 1,
1773+
module: Some(0),
17681774
name: Some("Baz::f_public".into()),
17691775
})
17701776
);
@@ -1878,7 +1884,7 @@ mod tests {
18781884
global: false,
18791885
sum_name: 0,
18801886
symbol_index: SymbolIndex(1152),
1881-
module: 182,
1887+
module: Some(181),
18821888
name: Some("capture_current_context".into()),
18831889
})
18841890
);

0 commit comments

Comments
 (0)