@@ -61,6 +61,11 @@ public MdbSourceFileInfo()
61
61
{
62
62
Methods = new List < MethodMdbInfo > ( ) ;
63
63
}
64
+
65
+ public MdbSourceFileInfo ( List < MethodMdbInfo > methods )
66
+ {
67
+ Methods = methods ;
68
+ }
64
69
}
65
70
66
71
class MethodMdbInfo
@@ -2606,20 +2611,30 @@ bool LoadMdbFile(string mdbFileName)
2606
2611
2607
2612
using ( MonoSymbolFile mdb = MonoSymbolFile . ReadSymbolFile ( mdbFileName ) )
2608
2613
{
2614
+ // Create a mapping by CompileUnitIndex.
2615
+ var methodMapping = new Dictionary < int , List < MethodMdbInfo > > ( mdb . CompileUnitCount ) ;
2616
+ foreach ( var method in mdb . Methods ) {
2617
+ List < MethodMdbInfo > list ;
2618
+ if ( ! methodMapping . TryGetValue ( method . CompileUnitIndex , out list ) )
2619
+ methodMapping [ method . CompileUnitIndex ] = list = new List < MethodMdbInfo > ( ) ;
2620
+
2621
+ list . Add ( new MethodMdbInfo { SequencePoints = method . GetLineNumberTable ( ) . LineNumbers } ) ;
2622
+ }
2623
+
2609
2624
foreach ( var cu in mdb . CompileUnits )
2610
2625
{
2611
- MdbSourceFileInfo info = new MdbSourceFileInfo ( ) ;
2626
+ // A CompileUnit may not have methods, so guard against this.
2627
+ List < MethodMdbInfo > list ;
2628
+ if ( ! methodMapping . TryGetValue ( cu . Index , out list ) )
2629
+ list = new List < MethodMdbInfo > ( ) ;
2630
+
2631
+ MdbSourceFileInfo info = new MdbSourceFileInfo ( list ) ;
2612
2632
2613
2633
var src = cu . SourceFile ;
2614
2634
info . Hash = src . Checksum ;
2615
2635
info . FileID = src . Index ;
2616
2636
info . FullFilePath = src . FileName ;
2617
2637
2618
- foreach ( var method in mdb . Methods ) {
2619
- if ( method . CompileUnitIndex == cu . Index )
2620
- info . Methods . Add ( new MethodMdbInfo { SequencePoints = method . GetLineNumberTable ( ) . LineNumbers } ) ;
2621
- }
2622
-
2623
2638
fileToSourceFileInfos [ src . FileName ] = new List < MdbSourceFileInfo > ( ) ;
2624
2639
2625
2640
if ( ! fileToSourceFileInfos . ContainsKey ( Path . GetFileName ( src . FileName ) ) )
0 commit comments