@@ -480,12 +480,6 @@ bool ProfiledBinary::dissassembleSymbol(std::size_t SI, ArrayRef<uint8_t> Bytes,
480
480
if (ShowDisassembly)
481
481
outs () << ' <' << SymbolName << " >:\n " ;
482
482
483
- auto WarnInvalidInsts = [](uint64_t Start, uint64_t End) {
484
- WithColor::warning () << " Invalid instructions at "
485
- << format (" %8" PRIx64, Start) << " - "
486
- << format (" %8" PRIx64, End) << " \n " ;
487
- };
488
-
489
483
uint64_t Address = StartAddress;
490
484
// Size of a consecutive invalid instruction range starting from Address -1
491
485
// backwards.
@@ -578,7 +572,8 @@ bool ProfiledBinary::dissassembleSymbol(std::size_t SI, ArrayRef<uint8_t> Bytes,
578
572
}
579
573
580
574
if (InvalidInstLength) {
581
- WarnInvalidInsts (Address - InvalidInstLength, Address - 1 );
575
+ AddrsWithInvalidInstruction.insert (
576
+ {Address - InvalidInstLength, Address - 1 });
582
577
InvalidInstLength = 0 ;
583
578
}
584
579
} else {
@@ -589,7 +584,8 @@ bool ProfiledBinary::dissassembleSymbol(std::size_t SI, ArrayRef<uint8_t> Bytes,
589
584
}
590
585
591
586
if (InvalidInstLength)
592
- WarnInvalidInsts (Address - InvalidInstLength, Address - 1 );
587
+ AddrsWithInvalidInstruction.insert (
588
+ {Address - InvalidInstLength, Address - 1 });
593
589
594
590
if (ShowDisassembly)
595
591
outs () << " \n " ;
@@ -708,6 +704,19 @@ void ProfiledBinary::disassemble(const ELFObjectFileBase *Obj) {
708
704
}
709
705
}
710
706
707
+ if (!AddrsWithInvalidInstruction.empty ()) {
708
+ if (ShowDetailedWarning) {
709
+ for (auto &Addr : AddrsWithInvalidInstruction) {
710
+ WithColor::warning ()
711
+ << " Invalid instructions at " << format (" %8" PRIx64, Addr.first )
712
+ << " - " << format (" %8" PRIx64, Addr.second ) << " \n " ;
713
+ }
714
+ }
715
+ WithColor::warning () << " Found " << AddrsWithInvalidInstruction.size ()
716
+ << " invalid instructions\n " ;
717
+ AddrsWithInvalidInstruction.clear ();
718
+ }
719
+
711
720
// Dissassemble rodata section to check if FS discriminator symbol exists.
712
721
checkUseFSDiscriminator (Obj, AllSymbols);
713
722
}
@@ -792,10 +801,12 @@ void ProfiledBinary::loadSymbolsFromDWARFUnit(DWARFUnit &CompilationUnit) {
792
801
FRange.StartAddress = StartAddress;
793
802
FRange.EndAddress = EndAddress;
794
803
} else {
795
- WithColor::warning ()
796
- << " Duplicated symbol start address at "
797
- << format (" %8" PRIx64, StartAddress) << " "
798
- << R.first ->second .getFuncName () << " and " << Name << " \n " ;
804
+ AddrsWithMultipleSymbols.insert (StartAddress);
805
+ if (ShowDetailedWarning)
806
+ WithColor::warning ()
807
+ << " Duplicated symbol start address at "
808
+ << format (" %8" PRIx64, StartAddress) << " "
809
+ << R.first ->second .getFuncName () << " and " << Name << " \n " ;
799
810
}
800
811
}
801
812
}
@@ -839,14 +850,18 @@ void ProfiledBinary::loadSymbolsFromDWARF(ObjectFile &Obj) {
839
850
if (BinaryFunctions.empty ())
840
851
WithColor::warning () << " Loading of DWARF info completed, but no binary "
841
852
" functions have been retrieved.\n " ;
842
-
843
-
844
853
// Populate the hash binary function map for MD5 function name lookup. This
845
854
// is done after BinaryFunctions are finalized.
846
855
for (auto &BinaryFunction : BinaryFunctions) {
847
856
HashBinaryFunctions[MD5Hash (StringRef (BinaryFunction.first ))] =
848
857
&BinaryFunction.second ;
849
858
}
859
+
860
+ if (!AddrsWithMultipleSymbols.empty ()) {
861
+ WithColor::warning () << " Found " << AddrsWithMultipleSymbols.size ()
862
+ << " start addresses with multiple symbols\n " ;
863
+ AddrsWithMultipleSymbols.clear ();
864
+ }
850
865
}
851
866
852
867
void ProfiledBinary::populateSymbolListFromDWARF (
@@ -881,7 +896,8 @@ SampleContextFrameVector ProfiledBinary::symbolize(const InstructionPointer &IP,
881
896
SampleContextFrameVector CallStack;
882
897
for (int32_t I = InlineStack.getNumberOfFrames () - 1 ; I >= 0 ; I--) {
883
898
const auto &CallerFrame = InlineStack.getFrame (I);
884
- if (CallerFrame.FunctionName .empty () || (CallerFrame.FunctionName == " <invalid>" ))
899
+ if (CallerFrame.FunctionName .empty () ||
900
+ (CallerFrame.FunctionName == " <invalid>" ))
885
901
break ;
886
902
887
903
StringRef FunctionName (CallerFrame.FunctionName );
0 commit comments