[llvm-bugs] [Bug 32243] New: llvm-pdbdump analyze doesn't quite work for clang.pdb

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 11 19:47:41 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=32243

            Bug ID: 32243
           Summary: llvm-pdbdump analyze doesn't quite work for clang.pdb
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org

Repro:

1. Download clang.pdb from
http://commondatastorage.googleapis.com/chromium-browser-symsrv/index.html?path=clang.pdb/EA4564EA6D47405AB6EE56969E08EE0F1/
(it's a cab archive, uncompress it). It was written by link.exe in a bootstrap
build of clang -- i.e. clang wrote the CodeView data that link.exe linked
together.

2. Run `llvm-pdbdump analyze clang.pdb`


Expected: Works.

Actual: "llvm-pdbdump: Native PDB Error: The Type record has an invalid hash
value.  Type index is 0x24EB6"

If I add this debug printf:

Index: lib/DebugInfo/PDB/Native/TpiHashing.cpp
===================================================================
--- lib/DebugInfo/PDB/Native/TpiHashing.cpp     (revision 297571)
+++ lib/DebugInfo/PDB/Native/TpiHashing.cpp     (working copy)
@@ -32,8 +32,12 @@
       Opts & static_cast<uint16_t>(ClassOptions::ForwardReference);
   bool Scoped = Opts & static_cast<uint16_t>(ClassOptions::Scoped);
   bool UniqueName = Opts & static_cast<uint16_t>(ClassOptions::HasUniqueName);
   bool IsAnon = UniqueName && isAnonymous(Rec);

+fprintf(stderr, "opts %x %d %s\n", Opts, IsAnon, Rec.getName().str().c_str());


Then the last output before things fail is 

opts 8 0 `anonymous namespace'::AArch64FastISel::Address::<unnamed-tag>

So that's an anonymous enum, but UniqueName isn't set -- and hence IsAnon is
false. With this change, things work fine:


Index: lib/DebugInfo/PDB/Native/TpiHashing.cpp
===================================================================
--- lib/DebugInfo/PDB/Native/TpiHashing.cpp     (revision 297571)
+++ lib/DebugInfo/PDB/Native/TpiHashing.cpp     (working copy)
@@ -32,7 +32,7 @@
       Opts & static_cast<uint16_t>(ClassOptions::ForwardReference);
   bool Scoped = Opts & static_cast<uint16_t>(ClassOptions::Scoped);
   bool UniqueName = Opts & static_cast<uint16_t>(ClassOptions::HasUniqueName);
-  bool IsAnon = UniqueName && isAnonymous(Rec);
+  bool IsAnon = isAnonymous(Rec);

   if (!ForwardRef && !Scoped && !IsAnon)
     return hashStringV1(Rec.getName());
@@ -79,18 +79,24 @@
 }




However, I'm not sure if this is a bug in pdbdump, or if clang writes bad
codeview and the input is in fact bad. (dbghelp.dll seems to load the file fine
though, so I suppose even if there's also a clang bug here, llvm-pdbdump should
accept it too.)


I tried writing a test for this, but I didn't see where to put it -- looks like
this code doesn't have a lot of tests now.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170312/b6e658be/attachment.html>


More information about the llvm-bugs mailing list