Skip to content

Commit e11b929

Browse files
trutstellar
authored andcommitted
[LLD][COFF] Fix TypeServerSource matcher with more than one collision
Follow-up from 98bc304 - while that commit fixed when you had two PDBs colliding on the same Guid it didn't fix the case where you had more than two PDBs using the same Guid. This commit fixes that and also tests much more carefully that all the types are correct no matter the order. Reviewed By: aganea, saudi Differential Revision: https://reviews.llvm.org/D123185 (cherry picked from commit 0dfa8a0)
1 parent d800180 commit e11b929

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

lld/COFF/DebugTypes.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ class TypeServerSource : public TpiSource {
6060
// If we hit here we have collision on Guid's in two PDB files.
6161
// This can happen if the PDB Guid is invalid or if we are really
6262
// unlucky. This should fall back on stright file-system lookup.
63-
TypeServerSource *tSrc = (TypeServerSource *)it.first->second;
64-
log("GUID collision between " + file.getFilePath() + " and " +
65-
tSrc->pdbInputFile->session->getPDBFile().getFilePath());
66-
ctx.typeServerSourceMappings.erase(Guid);
63+
it.first->second = nullptr;
6764
}
6865
}
6966

@@ -405,11 +402,12 @@ Expected<TypeServerSource *> UseTypeServerSource::getTypeServerSource() {
405402
const codeview::GUID &tsId = typeServerDependency.getGuid();
406403
StringRef tsPath = typeServerDependency.getName();
407404

408-
TypeServerSource *tsSrc;
405+
TypeServerSource *tsSrc = nullptr;
409406
auto it = ctx.typeServerSourceMappings.find(tsId);
410407
if (it != ctx.typeServerSourceMappings.end()) {
411408
tsSrc = (TypeServerSource *)it->second;
412-
} else {
409+
}
410+
if (tsSrc == nullptr) {
413411
// The file failed to load, lookup by name
414412
PDBInputFile *pdb = PDBInputFile::findFromRecordPath(ctx, tsPath, file);
415413
if (!pdb)

lld/test/COFF/pdb-type-server-guid-collision-invalid.test

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ that was set to FFFFFF...
66
RUN: rm -rf %t && mkdir -p %t && cd %t
77
RUN: yaml2obj %p/Inputs/pdb-type-server-guid-collision-a.yaml -o a.obj
88
RUN: yaml2obj %p/Inputs/pdb-type-server-guid-collision-b.yaml -o b.obj
9+
RUN: sed s/b.pdb/c.pdb/ %S/Inputs/pdb-type-server-guid-collision-b.yaml | sed s/b.obj/c.obj/ | sed s/bar_gv/rab_gv/ | sed s/Bar/Rab/ | yaml2obj > c.obj
910
RUN: llvm-pdbutil yaml2pdb %S/Inputs/pdb-type-server-guid-collision-a-pdb.yaml -pdb a.pdb
1011
RUN: llvm-pdbutil yaml2pdb %S/Inputs/pdb-type-server-guid-collision-b-pdb.yaml -pdb b.pdb
11-
RUN: lld-link a.obj b.obj -out:collision.dll /debug:ghash -pdb:collision.pdb -nodefaultlib /noentry /dll
12-
RUN: lld-link a.obj b.obj -out:collision.dll /debug:noghash -pdb:collision_noghash.pdb -nodefaultlib /noentry /dll
12+
RUN: sed s/b.pdb/c.pdb/ %S/Inputs/pdb-type-server-guid-collision-b-pdb.yaml | sed s/bar_gv/rab_gv/ | sed s/Bar/Rab/ | llvm-pdbutil yaml2pdb - -pdb c.pdb
13+
RUN: lld-link b.obj a.obj c.obj -out:collision.dll /debug:ghash -pdb:collision.pdb -nodefaultlib /noentry /dll
14+
RUN: lld-link a.obj b.obj c.obj -out:collision.dll /debug:noghash -pdb:collision_noghash.pdb -nodefaultlib /noentry /dll
1315
RUN: llvm-pdbutil dump -globals collision.pdb | FileCheck %s
1416
RUN: llvm-pdbutil dump -globals collision_noghash.pdb | FileCheck %s
1517

1618
CHECK-LABEL: Global Symbols
1719
CHECK: ============================================================
1820

19-
CHECK: 100 | S_GDATA32 [size = 24] `bar_gv`
20-
CHECK-NEXT: type = 0x104E (Bar), addr = 0002:0004
21+
CHECK-DAG: {{[0-9]+}} | S_GDATA32 [size = 24] `rab_gv`
22+
CHECK-NEXT: type = {{[^\s]+}} (Rab), addr = 0002:{{[0-9]+}}
23+
CHECK-DAG: {{[0-9]+}} | S_GDATA32 [size = 24] `bar_gv`
24+
CHECK-NEXT: type = {{[^\s]+}} (Bar), addr = 0002:{{[0-9]+}}
25+
CHECK-DAG: {{[0-9]+}} | S_GDATA32 [size = 24] `foo_gv`
26+
CHECK-NEXT: type = {{[^\s]+}} (Foo), addr = 0002:{{[0-9]+}}

lld/test/COFF/pdb-type-server-guid-collision-valid.test

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ RUN: sed s/{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}/{6C633EB7-46FE-4609-BA83-EB820
77
RUN: sed s/{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}/{6C633EB7-46FE-4609-BA83-EB820E6F5683}/ %S/Inputs/pdb-type-server-guid-collision-b.yaml | yaml2obj > b.obj
88
RUN: sed s/{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}/{6C633EB7-46FE-4609-BA83-EB820E6F5683}/ %S/Inputs/pdb-type-server-guid-collision-a-pdb.yaml | llvm-pdbutil yaml2pdb - -pdb a.pdb
99
RUN: sed s/{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF}/{6C633EB7-46FE-4609-BA83-EB820E6F5683}/ %S/Inputs/pdb-type-server-guid-collision-b-pdb.yaml | llvm-pdbutil yaml2pdb - -pdb b.pdb
10-
RUN: lld-link a.obj b.obj -out:collision.dll -debug -pdb:collision.pdb -nodefaultlib /noentry /dll -verbose 2>&1 | FileCheck %s -check-prefix LOG
10+
RUN: lld-link a.obj b.obj -out:collision.dll -debug -pdb:collision.pdb -nodefaultlib /noentry /dll
1111
RUN: llvm-pdbutil dump -globals collision.pdb | FileCheck %s -check-prefix DUMP
1212

13-
LOG: lld-link: GUID collision between b.pdb and a.pdb
14-
1513
DUMP-LABEL: Global Symbols
1614
DUMP: ============================================================
1715

0 commit comments

Comments
 (0)