@@ -183,6 +183,7 @@ struct UnrelocatedFpoData {
183
183
enum : uint32_t { kSymbolStreamMagicSize = 4 };
184
184
185
185
class DebugSHandler {
186
+ COFFLinkerContext &ctx;
186
187
PDBLinker &linker;
187
188
188
189
// / The object file whose .debug$S sections we're processing.
@@ -229,8 +230,8 @@ class DebugSHandler {
229
230
const DebugSubsectionRecord &ss);
230
231
231
232
public:
232
- DebugSHandler (PDBLinker &linker, ObjFile &file)
233
- : linker(linker), file(file) {}
233
+ DebugSHandler (COFFLinkerContext &ctx, PDBLinker &linker, ObjFile &file)
234
+ : ctx(ctx), linker(linker), file(file) {}
234
235
235
236
void handleDebugS (SectionChunk *debugChunk);
236
237
@@ -384,10 +385,11 @@ void PDBLinker::translateIdSymbols(MutableArrayRef<uint8_t> &recordData,
384
385
}
385
386
}
386
387
if (newType == TypeIndex (SimpleTypeKind::NotTranslated)) {
387
- warn (formatv (" procedure symbol record for `{0}` in {1} refers to PDB "
388
- " item index {2:X} which is not a valid function ID record" ,
389
- getSymbolName (CVSymbol (recordData)),
390
- source->file ->getName (), ti->getIndex ()));
388
+ Warn (ctx) << formatv (
389
+ " procedure symbol record for `{0}` in {1} refers to PDB "
390
+ " item index {2:X} which is not a valid function ID record" ,
391
+ getSymbolName (CVSymbol (recordData)), source->file ->getName (),
392
+ ti->getIndex ());
391
393
}
392
394
*ti = newType;
393
395
}
@@ -420,11 +422,12 @@ static void scopeStackOpen(SmallVectorImpl<uint32_t> &stack,
420
422
}
421
423
422
424
// To close a scope, update the record that opened the scope.
423
- static void scopeStackClose (SmallVectorImpl<uint32_t > &stack,
425
+ static void scopeStackClose (COFFLinkerContext &ctx,
426
+ SmallVectorImpl<uint32_t > &stack,
424
427
std::vector<uint8_t > &storage,
425
428
uint32_t storageBaseOffset, ObjFile *file) {
426
429
if (stack.empty ()) {
427
- warn ( " symbol scopes are not balanced in " + file->getName () );
430
+ Warn (ctx) << " symbol scopes are not balanced in " << file->getName ();
428
431
return ;
429
432
}
430
433
@@ -594,7 +597,7 @@ void PDBLinker::analyzeSymbolSubsection(
594
597
cantFail (symData.readBytes (0 , symData.getLength (), symsBuffer));
595
598
596
599
if (symsBuffer.empty ())
597
- warn ( " empty symbols subsection in " + file->getName () );
600
+ Warn (ctx) << " empty symbols subsection in " << file->getName ();
598
601
599
602
Error ec = forEachCodeViewRecord<CVSymbol>(
600
603
symsBuffer, [&](CVSymbol sym) -> llvm::Error {
@@ -635,7 +638,7 @@ void PDBLinker::analyzeSymbolSubsection(
635
638
// any partial records, undo that. For globals, we just keep what we have and
636
639
// continue.
637
640
if (ec) {
638
- warn ( " corrupt symbol records in " + file->getName () );
641
+ Warn (ctx) << " corrupt symbol records in " << file->getName ();
639
642
moduleSymOffset = moduleSymStart;
640
643
consumeError (std::move (ec));
641
644
}
@@ -678,7 +681,7 @@ Error PDBLinker::writeAllModuleSymbolRecords(ObjFile *file,
678
681
if (symbolOpensScope (sym.kind ()))
679
682
scopeStackOpen (scopes, storage);
680
683
else if (symbolEndsScope (sym.kind ()))
681
- scopeStackClose (scopes, storage, moduleSymStart, file);
684
+ scopeStackClose (ctx, scopes, storage, moduleSymStart, file);
682
685
683
686
// Copy, relocate, and rewrite each module symbol.
684
687
if (symbolGoesInModuleStream (sym, scopes.size ())) {
@@ -740,12 +743,12 @@ static pdb::SectionContrib createSectionContrib(COFFLinkerContext &ctx,
740
743
}
741
744
742
745
static uint32_t
743
- translateStringTableIndex (uint32_t objIndex,
746
+ translateStringTableIndex (COFFLinkerContext &ctx, uint32_t objIndex,
744
747
const DebugStringTableSubsectionRef &objStrTable,
745
748
DebugStringTableSubsection &pdbStrTable) {
746
749
auto expectedString = objStrTable.getString (objIndex);
747
750
if (!expectedString) {
748
- warn ( " Invalid string table reference" ) ;
751
+ Warn (ctx) << " Invalid string table reference" ;
749
752
consumeError (expectedString.takeError ());
750
753
return 0 ;
751
754
}
@@ -820,8 +823,9 @@ void DebugSHandler::handleDebugS(SectionChunk *debugChunk) {
820
823
break ;
821
824
822
825
default :
823
- warn (" ignoring unknown debug$S subsection kind 0x" +
824
- utohexstr (uint32_t (ss.kind ())) + " in file " + toString (&file));
826
+ Warn (ctx) << " ignoring unknown debug$S subsection kind 0x"
827
+ << utohexstr (uint32_t (ss.kind ())) << " in file "
828
+ << toString (&file);
825
829
break ;
826
830
}
827
831
}
@@ -934,8 +938,9 @@ void DebugSHandler::finish() {
934
938
" string table subsection" );
935
939
936
940
if (!stringTableFixups.empty ())
937
- warn (" No StringTable subsection was encountered, but there are string "
938
- " table references" );
941
+ Warn (ctx)
942
+ << " No StringTable subsection was encountered, but there are string "
943
+ " table references" ;
939
944
return ;
940
945
}
941
946
@@ -967,17 +972,17 @@ void DebugSHandler::finish() {
967
972
exitOnErr (fds.initialize (reader));
968
973
for (codeview::FrameData fd : fds) {
969
974
fd.RvaStart += rvaStart;
970
- fd.FrameFunc =
971
- translateStringTableIndex (fd. FrameFunc , cvStrTab, linker.pdbStrTab );
975
+ fd.FrameFunc = translateStringTableIndex (ctx, fd. FrameFunc , cvStrTab,
976
+ linker.pdbStrTab );
972
977
dbiBuilder.addNewFpoData (fd);
973
978
}
974
979
}
975
980
976
981
// Translate the fixups and pass them off to the module builder so they will
977
982
// be applied during writing.
978
983
for (StringTableFixup &ref : stringTableFixups) {
979
- ref.StrTabOffset =
980
- translateStringTableIndex (ref. StrTabOffset , cvStrTab, linker.pdbStrTab );
984
+ ref.StrTabOffset = translateStringTableIndex (ctx, ref. StrTabOffset ,
985
+ cvStrTab, linker.pdbStrTab );
981
986
}
982
987
file.moduleDBI ->setStringTableFixups (std::move (stringTableFixups));
983
988
@@ -1032,7 +1037,7 @@ void PDBLinker::addDebugSymbols(TpiSource *source) {
1032
1037
ScopedTimer t (ctx.symbolMergingTimer );
1033
1038
ExitOnError exitOnErr;
1034
1039
pdb::DbiStreamBuilder &dbiBuilder = builder.getDbiBuilder ();
1035
- DebugSHandler dsh (*this , *source->file );
1040
+ DebugSHandler dsh (ctx, *this , *source->file );
1036
1041
// Now do all live .debug$S and .debug$F sections.
1037
1042
for (SectionChunk *debugChunk : source->file ->getDebugChunks ()) {
1038
1043
if (!debugChunk->live || debugChunk->getSize () == 0 )
@@ -1326,7 +1331,7 @@ void PDBLinker::addNatvisFiles() {
1326
1331
ErrorOr<std::unique_ptr<MemoryBuffer>> dataOrErr =
1327
1332
MemoryBuffer::getFile (file);
1328
1333
if (!dataOrErr) {
1329
- warn ( " Cannot open input file: " + file) ;
1334
+ Warn (ctx) << " Cannot open input file: " << file;
1330
1335
continue ;
1331
1336
}
1332
1337
std::unique_ptr<MemoryBuffer> data = std::move (*dataOrErr);
@@ -1348,7 +1353,7 @@ void PDBLinker::addNamedStreams() {
1348
1353
ErrorOr<std::unique_ptr<MemoryBuffer>> dataOrErr =
1349
1354
MemoryBuffer::getFile (file);
1350
1355
if (!dataOrErr) {
1351
- warn ( " Cannot open input file: " + file) ;
1356
+ Warn (ctx) << " Cannot open input file: " << file;
1352
1357
continue ;
1353
1358
}
1354
1359
std::unique_ptr<MemoryBuffer> data = std::move (*dataOrErr);
0 commit comments