From 302dc8bccffe6a047f22fac456cf2bb4871beedc Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Mon, 14 Aug 2017 18:44:58 +0000 Subject: [PATCH] [PDB] Ignore all S_UDT symbols when writing PDBs. We don't have the right algorithm for copying S_UDT symbols from object files to the globals stream, and having it wrong is worse than not having it at all, since it breaks display of local variables of UDT types (for example, "dv Foo" fails in our current implementation, but succeeds if the S_UDT records are omitted). Omit them until we fix the algorithm. llvm-svn: 310867 --- lld/COFF/PDB.cpp | 8 +++++++- lld/test/COFF/pdb-globals.test | 6 +----- lld/test/COFF/pdb-symbol-types.yaml | 4 ---- lld/test/COFF/pdb-type-server-simple.test | 6 +----- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp index 8e891cfe2419..29cf7b521a38 100644 --- a/lld/COFF/PDB.cpp +++ b/lld/COFF/PDB.cpp @@ -483,7 +483,6 @@ static bool symbolGoesInModuleStream(const CVSymbol &Sym) { static bool symbolGoesInGlobalsStream(const CVSymbol &Sym) { switch (Sym.kind()) { case SymbolKind::S_CONSTANT: - case SymbolKind::S_UDT: case SymbolKind::S_GDATA32: // S_LDATA32 goes in both the module stream and the globals stream. case SymbolKind::S_LDATA32: @@ -495,6 +494,13 @@ static bool symbolGoesInGlobalsStream(const CVSymbol &Sym) { case SymbolKind::S_PROCREF: case SymbolKind::S_LPROCREF: return true; + // FIXME: For now, we drop all S_UDT symbols (i.e. they don't go in the + // globals stream or the modules stream). These have special handling which + // needs more investigation before we can get right, but by putting them all + // into the globals stream WinDbg fails to display local variables of class + // types saying that it cannot find the type Foo *. So as a stopgap just to + // keep things working, we drop them. + case SymbolKind::S_UDT: default: return false; } diff --git a/lld/test/COFF/pdb-globals.test b/lld/test/COFF/pdb-globals.test index b3b0f63d0dc6..b5e4f49cb458 100644 --- a/lld/test/COFF/pdb-globals.test +++ b/lld/test/COFF/pdb-globals.test @@ -15,22 +15,18 @@ RUN: llvm-pdbutil dump -symbols -globals %t.pdb | FileCheck %s CHECK-LABEL: Global Symbols CHECK-NEXT: ============================================================ CHECK-NEXT: Records -CHECK-NEXT: 340 | S_UDT [size = 20] `HelloPoint` -CHECK-NEXT: original type = 0x1007 CHECK-NEXT: 160 | S_PROCREF [size = 28] `GlobalFunc` CHECK-NEXT: module = 1, sum name = 0, offset = 52 CHECK-NEXT: 188 | S_PROCREF [size = 20] `main` CHECK-NEXT: module = 1, sum name = 0, offset = 108 CHECK-NEXT: 208 | S_LPROCREF [size = 24] `LocalFunc` CHECK-NEXT: module = 1, sum name = 0, offset = 292 -CHECK-NEXT: 360 | S_PROCREF [size = 40] `HelloPoint::HelloPoint` +CHECK-NEXT: 312 | S_PROCREF [size = 40] `HelloPoint::HelloPoint` CHECK-NEXT: module = 1, sum name = 0, offset = 376 CHECK-NEXT: 232 | S_GDATA32 [size = 28] `__purecall` CHECK-NEXT: type = 0x0403 (void*), addr = 0000:0000 CHECK-NEXT: 260 | S_GDATA32 [size = 24] `GlobalVar` CHECK-NEXT: type = 0x100B (const int*), addr = 0001:0000 -CHECK-NEXT: 312 | S_UDT [size = 28] `HelloPointTypedef` -CHECK-NEXT: original type = 0x1005 CHECK-NEXT: 284 | S_LDATA32 [size = 28] `ConstantVar` CHECK-NEXT: type = 0x100A (const int), addr = 0002:0000 diff --git a/lld/test/COFF/pdb-symbol-types.yaml b/lld/test/COFF/pdb-symbol-types.yaml index 34ac92fb7def..9dad72d3cc2f 100644 --- a/lld/test/COFF/pdb-symbol-types.yaml +++ b/lld/test/COFF/pdb-symbol-types.yaml @@ -18,10 +18,6 @@ # CHECK-NEXT: Records # CHECK-NEXT: 48 | S_PROCREF [size = 20] `main` # CHECK-NEXT: module = 1, sum name = 0, offset = 116 -# CHECK-NEXT: 96 | S_UDT [size = 16] `UDT_Foo` -# CHECK-NEXT: original type = 0x1004 -# CHECK-NEXT: 112 | S_UDT [size = 12] `Foo` -# CHECK-NEXT: original type = 0x1004 # CHECK-NEXT: 68 | S_GDATA32 [size = 28] `global_foo` # CHECK-NEXT: type = 0x1004 (Foo), addr = 0001:0000 diff --git a/lld/test/COFF/pdb-type-server-simple.test b/lld/test/COFF/pdb-type-server-simple.test index dcefef552234..238b483a3d7c 100644 --- a/lld/test/COFF/pdb-type-server-simple.test +++ b/lld/test/COFF/pdb-type-server-simple.test @@ -64,12 +64,8 @@ CHECK: ============================================================ CHECK-NEXT: Records CHECK-NEXT: 36 | S_PROCREF [size = 20] `main` CHECK-NEXT: module = 1, sum name = 0, offset = 104 -CHECK-NEXT: 68 | S_PROCREF [size = 16] `g` +CHECK-NEXT: 56 | S_PROCREF [size = 16] `g` CHECK-NEXT: module = 2, sum name = 0, offset = 104 -CHECK-NEXT: 56 | S_UDT [size = 12] `Foo` -CHECK-NEXT: original type = 0x1006 -CHECK-NEXT: 84 | S_UDT [size = 12] `Foo` -CHECK-NEXT: original type = 0x1006 CHECK-LABEL: Symbols CHECK: ============================================================