[llvm] r343951 - [PDB] Add the ability to lookup global symbols by name.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 8 07:35:24 PDT 2018


Ugh, I guess it’s the back quote? Because it works on Windows. I’ll just
remove that particular argument
On Mon, Oct 8, 2018 at 4:19 AM Kristina Brooks via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Er, sorry, what I meant is, I fixed that particular warning in
> https://reviews.llvm.org/rL343957. Just
> wanted to disambiguate it from Zachary's earlier fix for a different
> warning.
>
> On 08/10/2018 12:10, Kristina Brooks via llvm-commits wrote:
> > I already fixed the warning in https://reviews.llvm.org/rL343951. The
> test file
> > seems to be malformed though so all buildbots have been failing on it (I
> think
> > there's a syntax error in the RUN directive in the test you added).
> >
> > Thanks.
> >
> > On 08/10/2018 11:42, Zachary Turner via llvm-commits wrote:
> >> I’ll have to fix this in a couple hours as I don’t have computer access
> at the moment, if you want to unblock you can
> >> just cast to a uint32. Sorry!
> >> On Sun, Oct 7, 2018 at 11:24 PM Mikael Holmén <
> mikael.holmen at ericsson.com <mailto:mikael.holmen at ericsson.com>> wrote:
> >>
> >>     Hi Zachary,
> >>
> >>     I get the following with clang 3.6:
> >>
> >>     ../lib/DebugInfo/PDB/Native/GlobalsStream.cpp:61:33: error:
> comparison
> >>     of integers of different signs: 'int' and 'uint32_t' (aka 'unsigned
> >>     int') [-Werror,-Wsign-compare]
> >>        if (CompressedBucketIndex + 1 < GlobalsTable.HashBuckets.size())
> >>            ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >>     1 error generated.
> >>
> >>     I saw that you fixed something in r343952 and r343953 but now I get
> this
> >>     warnign.
> >>
> >>     Regards,
> >>     Mikael
> >>
> >>     On 10/08/2018 06:19 AM, Zachary Turner via llvm-commits wrote:
> >>     > Author: zturner
> >>     > Date: Sun Oct  7 21:19:16 2018
> >>     > New Revision: 343951
> >>     >
> >>     > URL: http://llvm.org/viewvc/llvm-project?rev=343951&view=rev
> >>     > Log:
> >>     > [PDB] Add the ability to lookup global symbols by name.
> >>     >
> >>     > The Globals table is a hash table keyed on symbol name, so
> >>     > it's possible to lookup symbols by name in O(1) time.  Add
> >>     > a function to the globals stream to do this, and add an option
> >>     > to llvm-pdbutil to exercise this, then use it to write some
> >>     > tests to verify correctness.
> >>     >
> >>     > Added:
> >>     >      llvm/trunk/test/DebugInfo/PDB/pdbdump-global-lookup.test
> >>     > Modified:
> >>     >      llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h
> >>     >      llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h
> >>     >      llvm/trunk/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h
> >>     >
> llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h
> >>     >      llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp
> >>     >      llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp
> >>     >      llvm/trunk/lib/DebugInfo/PDB/Native/GlobalsStream.cpp
> >>     >      llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
> >>     >      llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp
> >>     >      llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
> >>     >      llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h
> >>     >
> >>     > Modified:
> llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h
> >>     > URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h?rev=343951&r1=343950&r2=343951&view=diff
> >>     >
> ==============================================================================
> >>     > --- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h
> (original)
> >>     > +++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h Sun
> Oct  7 21:19:16 2018
> >>     > @@ -358,6 +358,7 @@ public:
> >>     >   // S_PUB32
> >>     >   class PublicSym32 : public SymbolRecord {
> >>     >   public:
> >>     > +  PublicSym32() : SymbolRecord(SymbolRecordKind::PublicSym32) {}
> >>     >     explicit PublicSym32(SymbolRecordKind Kind) :
> SymbolRecord(Kind) {}
> >>     >     explicit PublicSym32(uint32_t RecordOffset)
> >>     >         : SymbolRecord(SymbolRecordKind::PublicSym32),
> >>     > @@ -636,6 +637,7 @@ public:
> >>     >   // S_OBJNAME
> >>     >   class ObjNameSym : public SymbolRecord {
> >>     >   public:
> >>     > +  explicit ObjNameSym() :
> SymbolRecord(SymbolRecordKind::ObjNameSym) {}
> >>     >     explicit ObjNameSym(SymbolRecordKind Kind) :
> SymbolRecord(Kind) {}
> >>     >     ObjNameSym(uint32_t RecordOffset)
> >>     >         : SymbolRecord(SymbolRecordKind::ObjNameSym),
> RecordOffset(RecordOffset) {
> >>     > @@ -718,6 +720,7 @@ public:
> >>     >   // S_COMPILE3
> >>     >   class Compile3Sym : public SymbolRecord {
> >>     >   public:
> >>     > +  Compile3Sym() : SymbolRecord(SymbolRecordKind::Compile3Sym) {}
> >>     >     explicit Compile3Sym(SymbolRecordKind Kind) :
> SymbolRecord(Kind) {}
> >>     >     Compile3Sym(uint32_t RecordOffset)
> >>     >         : SymbolRecord(SymbolRecordKind::Compile3Sym),
> >>     > @@ -739,8 +742,17 @@ public:
> >>     >       Flags = CompileSym3Flags((uint32_t(Flags) & 0xFFFFFF00) |
> uint32_t(Lang));
> >>     >     }
> >>     >
> >>     > -  uint8_t getLanguage() const { return
> static_cast<uint32_t>(Flags) & 0xFF; }
> >>     > -  uint32_t getFlags() const { return
> static_cast<uint32_t>(Flags) & ~0xFF; }
> >>     > +  SourceLanguage getLanguage() const {
> >>     > +    return
> static_cast<SourceLanguage>(static_cast<uint32_t>(Flags) & 0xFF);
> >>     > +  }
> >>     > +  CompileSym3Flags getFlags() const {
> >>     > +    return
> static_cast<CompileSym3Flags>(static_cast<uint32_t>(Flags) & ~0xFF);
> >>     > +  }
> >>     > +
> >>     > +  bool hasOptimizations() const {
> >>     > +    return CompileSym3Flags::None !=
> >>     > +           (getFlags() & (CompileSym3Flags::PGO |
> CompileSym3Flags::LTCG));
> >>     > +  }
> >>     >
> >>     >     uint32_t RecordOffset;
> >>     >   };
> >>     >
> >>     > Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h
> >>     > URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h?rev=343951&r1=343950&r2=343951&view=diff
> >>     >
> ==============================================================================
> >>     > --- llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h
> (original)
> >>     > +++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/DbiStream.h Sun
> Oct  7 21:19:16 2018
> >>     > @@ -78,7 +78,7 @@ public:
> >>     >
> >>     >     const DbiModuleList &modules() const;
> >>     >
> >>     > -  FixedStreamArray<object::coff_section> getSectionHeaders();
> >>     > +  FixedStreamArray<object::coff_section> getSectionHeaders()
> const;
> >>     >
> >>     >     FixedStreamArray<object::FpoData> getFpoRecords();
> >>     >
> >>     >
> >>     > Modified:
> llvm/trunk/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h
> >>     > URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h?rev=343951&r1=343950&r2=343951&view=diff
> >>     >
> ==============================================================================
> >>     > --- llvm/trunk/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h
> (original)
> >>     > +++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h
> Sun Oct  7 21:19:16 2018
> >>     > @@ -10,18 +10,20 @@
> >>     >   #ifndef LLVM_DEBUGINFO_PDB_RAW_GLOBALS_STREAM_H
> >>     >   #define LLVM_DEBUGINFO_PDB_RAW_GLOBALS_STREAM_H
> >>     >
> >>     > +#include "llvm/ADT/iterator.h"
> >>     > +#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
> >>     >   #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
> >>     >   #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
> >>     >   #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
> >>     >   #include "llvm/DebugInfo/PDB/PDBTypes.h"
> >>     >   #include "llvm/Support/BinaryStreamArray.h"
> >>     >   #include "llvm/Support/Error.h"
> >>     > -#include "llvm/ADT/iterator.h"
> >>     >
> >>     >   namespace llvm {
> >>     >   namespace pdb {
> >>     >   class DbiStream;
> >>     >   class PDBFile;
> >>     > +class SymbolStream;
> >>     >
> >>     >   /// Iterator over hash records producing symbol record offsets.
> Abstracts away
> >>     >   /// the fact that symbol record offsets on disk are off-by-one.
> >>     > @@ -50,8 +52,9 @@ class GSIHashTable {
> >>     >   public:
> >>     >     const GSIHashHeader *HashHdr;
> >>     >     FixedStreamArray<PSHashRecord> HashRecords;
> >>     > -  ArrayRef<uint8_t> HashBitmap;
> >>     > +  ArrayRef<uint32_t> HashBitmap;
> >>     >     FixedStreamArray<support::ulittle32_t> HashBuckets;
> >>     > +  std::array<int32_t, IPHR_HASH + 1> BucketMap;
> >>     >
> >>     >     Error read(BinaryStreamReader &Reader);
> >>     >
> >>     > @@ -72,6 +75,9 @@ public:
> >>     >     const GSIHashTable &getGlobalsTable() const { return
> GlobalsTable; }
> >>     >     Error reload();
> >>     >
> >>     > +  std::vector<std::pair<uint32_t, codeview::CVSymbol>>
> >>     > +  findRecordsByName(StringRef Name, const SymbolStream &Symbols)
> const;
> >>     > +
> >>     >   private:
> >>     >     GSIHashTable GlobalsTable;
> >>     >     std::unique_ptr<msf::MappedBlockStream> Stream;
> >>     >
> >>     > Modified:
> llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h
> >>     > URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h?rev=343951&r1=343950&r2=343951&view=diff
> >>     >
> ==============================================================================
> >>     > ---
> llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h (original)
> >>     > +++
> llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h Sun Oct  7
> 21:19:16 2018
> >>     > @@ -15,6 +15,7 @@
> >>     >   #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
> >>     >   #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
> >>     >   #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
> >>     > +#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
> >>     >   #include "llvm/Support/BinaryStreamRef.h"
> >>     >   #include "llvm/Support/Error.h"
> >>     >   #include <cstdint>
> >>     > @@ -51,6 +52,8 @@ public:
> >>     >
> >>     >     ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other)
> = delete;
> >>     >
> >>     > +  codeview::CVSymbol readSymbolAtOffset(uint32_t Offset) const;
> >>     > +
> >>     >     iterator_range<DebugSubsectionIterator> subsections() const;
> >>     >     codeview::DebugSubsectionArray getSubsectionsArray() const {
> >>     >       return Subsections;
> >>     > @@ -64,7 +67,7 @@ public:
> >>     >     findChecksumsSubsection() const;
> >>     >
> >>     >   private:
> >>     > -  const DbiModuleDescriptor &Mod;
> >>     > +  DbiModuleDescriptor Mod;
> >>     >
> >>     >     uint32_t Signature;
> >>     >
> >>     >
> >>     > Modified: llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp
> >>     > URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp?rev=343951&r1=343950&r2=343951&view=diff
> >>     >
> ==============================================================================
> >>     > --- llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp (original)
> >>     > +++ llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp Sun Oct  7
> 21:19:16 2018
> >>     > @@ -262,7 +262,8 @@ Error CVSymbolDumperImpl::visitKnownReco
> >>     >   Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
> >>     >                                              Compile3Sym
> &Compile3) {
> >>     >     W.printEnum("Language", Compile3.getLanguage(),
> getSourceLanguageNames());
> >>     > -  W.printFlags("Flags", Compile3.getFlags(),
> getCompileSym3FlagNames());
> >>     > +  W.printFlags("Flags", uint32_t(Compile3.getFlags()),
> >>     > +               getCompileSym3FlagNames());
> >>     >     W.printEnum("Machine", unsigned(Compile3.Machine),
> getCPUTypeNames());
> >>     >     CompilationCPUType = Compile3.Machine;
> >>     >     std::string FrontendVersion;
> >>     >
> >>     > Modified: llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp
> >>     > URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp?rev=343951&r1=343950&r2=343951&view=diff
> >>     >
> ==============================================================================
> >>     > --- llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp (original)
> >>     > +++ llvm/trunk/lib/DebugInfo/PDB/Native/DbiStream.cpp Sun Oct  7
> 21:19:16 2018
> >>     > @@ -197,7 +197,7 @@ PDB_Machine DbiStream::getMachineType()
> >>     >     return static_cast<PDB_Machine>(Machine);
> >>     >   }
> >>     >
> >>     > -FixedStreamArray<object::coff_section>
> DbiStream::getSectionHeaders() {
> >>     > +FixedStreamArray<object::coff_section>
> DbiStream::getSectionHeaders() const {
> >>     >     return SectionHeaders;
> >>     >   }
> >>     >
> >>     >
> >>     > Modified: llvm/trunk/lib/DebugInfo/PDB/Native/GlobalsStream.cpp
> >>     > URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/GlobalsStream.cpp?rev=343951&r1=343950&r2=343951&view=diff
> >>     >
> ==============================================================================
> >>     > --- llvm/trunk/lib/DebugInfo/PDB/Native/GlobalsStream.cpp
> (original)
> >>     > +++ llvm/trunk/lib/DebugInfo/PDB/Native/GlobalsStream.cpp Sun
> Oct  7 21:19:16 2018
> >>     > @@ -20,7 +20,11 @@
> >>     >
>  //===----------------------------------------------------------------------===//
> >>     >
> >>     >   #include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
> >>     > +
> >>     > +#include "llvm/DebugInfo/CodeView/RecordName.h"
> >>     > +#include "llvm/DebugInfo/PDB/Native/Hash.h"
> >>     >   #include "llvm/DebugInfo/PDB/Native/RawError.h"
> >>     > +#include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
> >>     >   #include "llvm/Support/BinaryStreamReader.h"
> >>     >   #include "llvm/Support/Error.h"
> >>     >   #include <algorithm>
> >>     > @@ -41,6 +45,35 @@ Error GlobalsStream::reload() {
> >>     >     return Error::success();
> >>     >   }
> >>     >
> >>     > +std::vector<std::pair<uint32_t, codeview::CVSymbol>>
> >>     > +GlobalsStream::findRecordsByName(StringRef Name,
> >>     > +                                 const SymbolStream &Symbols)
> const {
> >>     > +  std::vector<std::pair<uint32_t, codeview::CVSymbol>> Result;
> >>     > +
> >>     > +  // Hash the name to figure out which bucket this goes into.
> >>     > +  size_t ExpandedBucketIndex = hashStringV1(Name) % IPHR_HASH;
> >>     > +  uint32_t CompressedBucketIndex =
> GlobalsTable.BucketMap[ExpandedBucketIndex];
> >>     > +  if (CompressedBucketIndex == -1)
> >>     > +    return Result;
> >>     > +
> >>     > +  uint32_t ChainStartOffset =
> GlobalsTable.HashBuckets[CompressedBucketIndex];
> >>     > +  uint32_t NextChainStart = GlobalsTable.HashBuckets.size();
> >>     > +  if (CompressedBucketIndex + 1 <
> GlobalsTable.HashBuckets.size())
> >>     > +    NextChainStart =
> GlobalsTable.HashBuckets[CompressedBucketIndex + 1];
> >>     > +  ChainStartOffset /= 12;
> >>     > +  NextChainStart /= 12;
> >>     > +
> >>     > +  while (ChainStartOffset < NextChainStart) {
> >>     > +    PSHashRecord PSH =
> GlobalsTable.HashRecords[ChainStartOffset];
> >>     > +    uint32_t Off = PSH.Off - 1;
> >>     > +    codeview::CVSymbol Record = Symbols.readRecord(Off);
> >>     > +    if (codeview::getSymbolName(Record) == Name)
> >>     > +      Result.push_back(std::make_pair(Off, std::move(Record)));
> >>     > +    ++ChainStartOffset;
> >>     > +  }
> >>     > +  return Result;
> >>     > +}
> >>     > +
> >>     >   static Error checkHashHdrVersion(const GSIHashHeader *HashHdr) {
> >>     >     if (HashHdr->VerHdr != GSIHashHeader::HdrVersion)
> >>     >       return make_error<RawError>(
> >>     > @@ -86,7 +119,8 @@ static Error readGSIHashRecords(FixedStr
> >>     >
> >>     >   static Error
> >>     >   readGSIHashBuckets(FixedStreamArray<support::ulittle32_t>
> &HashBuckets,
> >>     > -                   ArrayRef<uint8_t> &HashBitmap, const
> GSIHashHeader *HashHdr,
> >>     > +                   ArrayRef<uint32_t> &HashBitmap, const
> GSIHashHeader *HashHdr,
> >>     > +                   MutableArrayRef<int32_t> BucketMap,
> >>     >                      BinaryStreamReader &Reader) {
> >>     >     if (auto EC = checkHashHdrVersion(HashHdr))
> >>     >       return EC;
> >>     > @@ -94,13 +128,27 @@ readGSIHashBuckets(FixedStreamArray<supp
> >>     >     // Before the actual hash buckets, there is a bitmap of
> length determined by
> >>     >     // IPHR_HASH.
> >>     >     size_t BitmapSizeInBits = alignTo(IPHR_HASH + 1, 32);
> >>     > -  uint32_t NumBitmapEntries = BitmapSizeInBits / 8;
> >>     > -  if (auto EC = Reader.readBytes(HashBitmap, NumBitmapEntries))
> >>     > +  uint32_t NumBitmapEntries = BitmapSizeInBits / 32;
> >>     > +  if (auto EC = Reader.readArray(HashBitmap, NumBitmapEntries))
> >>     >       return joinErrors(std::move(EC),
> >>     >
>  make_error<RawError>(raw_error_code::corrupt_file,
> >>     >                                              "Could not read a
> bitmap."));
> >>     > +  uint32_t NumBuckets1 = 0;
> >>     > +  uint32_t CompressedBucketIdx = 0;
> >>     > +  for (uint32_t I = 0; I <= IPHR_HASH; ++I) {
> >>     > +    uint8_t WordIdx = I / 32;
> >>     > +    uint8_t BitIdx = I % 32;
> >>     > +    bool IsSet = HashBitmap[WordIdx] & (1U << BitIdx);
> >>     > +    if (IsSet) {
> >>     > +      ++NumBuckets1;
> >>     > +      BucketMap[I] = CompressedBucketIdx++;
> >>     > +    } else {
> >>     > +      BucketMap[I] = -1;
> >>     > +    }
> >>     > +  }
> >>     > +
> >>     >     uint32_t NumBuckets = 0;
> >>     > -  for (uint8_t B : HashBitmap)
> >>     > +  for (uint32_t B : HashBitmap)
> >>     >       NumBuckets += countPopulation(B);
> >>     >
> >>     >     // Hash buckets follow.
> >>     > @@ -118,7 +166,8 @@ Error GSIHashTable::read(BinaryStreamRea
> >>     >     if (auto EC = readGSIHashRecords(HashRecords, HashHdr,
> Reader))
> >>     >       return EC;
> >>     >     if (HashHdr->HrSize > 0)
> >>     > -    if (auto EC = readGSIHashBuckets(HashBuckets, HashBitmap,
> HashHdr, Reader))
> >>     > +    if (auto EC = readGSIHashBuckets(HashBuckets, HashBitmap,
> HashHdr,
> >>     > +                                     BucketMap, Reader))
> >>     >         return EC;
> >>     >     return Error::success();
> >>     >   }
> >>     >
> >>     > Modified:
> llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
> >>     > URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp?rev=343951&r1=343950&r2=343951&view=diff
> >>     >
> ==============================================================================
> >>     > --- llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
> (original)
> >>     > +++ llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp Sun
> Oct  7 21:19:16 2018
> >>     > @@ -97,6 +97,14 @@ ModuleDebugStreamRef::symbols(bool *HadE
> >>     >     return make_range(SymbolArray.begin(HadError),
> SymbolArray.end());
> >>     >   }
> >>     >
> >>     > +CVSymbol ModuleDebugStreamRef::readSymbolAtOffset(uint32_t
> Offset) const {
> >>     > +  // Offsets include the size of the 4-byte magic at the
> beginning, but lookup
> >>     > +  // doesn't take that into account, so subtract it here.
> >>     > +  auto Iter = SymbolArray.at(Offset - 4);
> >>     > +  assert(Iter != SymbolArray.end());
> >>     > +  return *Iter;
> >>     > +}
> >>     > +
> >>     >   iterator_range<ModuleDebugStreamRef::DebugSubsectionIterator>
> >>     >   ModuleDebugStreamRef::subsections() const {
> >>     >     return make_range(Subsections.begin(), Subsections.end());
> >>     >
> >>     > Added: llvm/trunk/test/DebugInfo/PDB/pdbdump-global-lookup.test
> >>     > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/pdbdump-global-lookup.test?rev=343951&view=auto
> >>     >
> ==============================================================================
> >>     > --- llvm/trunk/test/DebugInfo/PDB/pdbdump-global-lookup.test
> (added)
> >>     > +++ llvm/trunk/test/DebugInfo/PDB/pdbdump-global-lookup.test Sun
> Oct  7 21:19:16 2018
> >>     > @@ -0,0 +1,22 @@
> >>     > +; RUN: llvm-pdbutil dump -globals \
> >>     > +; RUN:    -global-name="operator delete" \
> >>     > +; RUN:    -global-name=main \
> >>     > +; RUN:    -global-name=abcdefg \
> >>     > +; RUN:    -global-name="Base2::`vbase destructor'" \
> >>     > +; RUN:    %p/Inputs/every-function.pdb | FileCheck %s
> >>     > +
> >>     > +CHECK:                        Global Symbols
> >>     > +CHECK-NEXT:
> ============================================================
> >>     > +CHECK-NEXT:     Global Name `operator delete`
> >>     > +CHECK-NEXT:       1516 | S_PROCREF [size = 32] `operator delete`
> >>     > +CHECK-NEXT:              module = 1, sum name = 0, offset = 324
> >>     > +CHECK-NEXT:       1484 | S_PROCREF [size = 32] `operator delete`
> >>     > +CHECK-NEXT:              module = 1, sum name = 0, offset = 184
> >>     > +CHECK-NEXT:     Global Name `main`
> >>     > +CHECK-NEXT:       2016 | S_PROCREF [size = 20] `main`
> >>     > +CHECK-NEXT:              module = 1, sum name = 0, offset = 1952
> >>     > +CHECK-NEXT:     Global Name `abcdefg`
> >>     > +CHECK-NEXT:       (no matching records found)
> >>     > +CHECK-NEXT:     Global Name `Base2::`vbase destructor'`
> >>     > +CHECK-NEXT:       2288 | S_PROCREF [size = 40] `Base2::`vbase
> destructor'`
> >>     > +CHECK-NEXT:              module = 1, sum name = 0, offset = 2852
> >>     >
> >>     > Modified: llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp
> >>     > URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp?rev=343951&r1=343950&r2=343951&view=diff
> >>     >
> ==============================================================================
> >>     > --- llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp (original)
> >>     > +++ llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp Sun Oct  7
> 21:19:16 2018
> >>     > @@ -1572,8 +1572,40 @@ Error DumpOutputStyle::dumpGlobals() {
> >>     >     ExitOnError Err("Error dumping globals stream: ");
> >>     >     auto &Globals = Err(getPdb().getPDBGlobalsStream());
> >>     >
> >>     > -  const GSIHashTable &Table = Globals.getGlobalsTable();
> >>     > -  Err(dumpSymbolsFromGSI(Table, opts::dump::DumpGlobalExtras));
> >>     > +  if (opts::dump::DumpGlobalNames.empty()) {
> >>     > +    const GSIHashTable &Table = Globals.getGlobalsTable();
> >>     > +    Err(dumpSymbolsFromGSI(Table, opts::dump::DumpGlobalExtras));
> >>     > +  } else {
> >>     > +    SymbolStream &SymRecords =
> cantFail(getPdb().getPDBSymbolStream());
> >>     > +    auto &Types = File.types();
> >>     > +    auto &Ids = File.ids();
> >>     > +
> >>     > +    SymbolVisitorCallbackPipeline Pipeline;
> >>     > +    SymbolDeserializer Deserializer(nullptr,
> CodeViewContainer::Pdb);
> >>     > +    MinimalSymbolDumper Dumper(P,
> opts::dump::DumpSymRecordBytes, Ids, Types);
> >>     > +
> >>     > +    Pipeline.addCallbackToPipeline(Deserializer);
> >>     > +    Pipeline.addCallbackToPipeline(Dumper);
> >>     > +    CVSymbolVisitor Visitor(Pipeline);
> >>     > +
> >>     > +    using ResultEntryType = std::pair<uint32_t, CVSymbol>;
> >>     > +    for (StringRef Name : opts::dump::DumpGlobalNames) {
> >>     > +      AutoIndent Indent(P);
> >>     > +      P.formatLine("Global Name `{0}`", Name);
> >>     > +      std::vector<ResultEntryType> Results =
> >>     > +          Globals.findRecordsByName(Name, SymRecords);
> >>     > +      if (Results.empty()) {
> >>     > +        AutoIndent Indent(P);
> >>     > +        P.printLine("(no matching records found)");
> >>     > +        continue;
> >>     > +      }
> >>     > +
> >>     > +      for (ResultEntryType Result : Results) {
> >>     > +        if (auto E = Visitor.visitSymbolRecord(Result.second,
> Result.first))
> >>     > +          return E;
> >>     > +      }
> >>     > +    }
> >>     > +  }
> >>     >     return Error::success();
> >>     >   }
> >>     >
> >>     > @@ -1676,7 +1708,10 @@ Error DumpOutputStyle::dumpSymbolsFromGS
> >>     >
> >>     >     // Return early if we aren't dumping public hash table and
> address map info.
> >>     >     if (HashExtras) {
> >>     > -    P.formatBinary("Hash Bitmap", Table.HashBitmap, 0);
> >>     > +    ArrayRef<uint8_t> BitmapBytes(
> >>     > +        reinterpret_cast<const uint8_t
> *>(Table.HashBitmap.data()),
> >>     > +        Table.HashBitmap.size() * sizeof(uint32_t));
> >>     > +    P.formatBinary("Hash Bitmap", BitmapBytes, 0);
> >>     >
> >>     >       P.formatLine("Hash Entries");
> >>     >       {
> >>     >
> >>     > Modified: llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
> >>     > URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp?rev=343951&r1=343950&r2=343951&view=diff
> >>     >
> ==============================================================================
> >>     > --- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp (original)
> >>     > +++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp Sun Oct  7
> 21:19:16 2018
> >>     > @@ -526,6 +526,11 @@ cl::opt<bool> DumpGlobals("globals", cl:
> >>     >                             cl::cat(SymbolOptions),
> cl::sub(DumpSubcommand));
> >>     >   cl::opt<bool> DumpGlobalExtras("global-extras", cl::desc("dump
> Globals hashes"),
> >>     >                                  cl::cat(SymbolOptions),
> cl::sub(DumpSubcommand));
> >>     > +cl::list<std::string> DumpGlobalNames(
> >>     > +    "global-name",
> >>     > +    cl::desc(
> >>     > +        "With -globals, only dump globals whose name matches the
> given value"),
> >>     > +    cl::cat(SymbolOptions), cl::sub(DumpSubcommand),
> cl::ZeroOrMore);
> >>     >   cl::opt<bool> DumpPublics("publics", cl::desc("dump Publics
> stream data"),
> >>     >                             cl::cat(SymbolOptions),
> cl::sub(DumpSubcommand));
> >>     >   cl::opt<bool> DumpPublicExtras("public-extras",
> >>     >
> >>     > Modified: llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h
> >>     > URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h?rev=343951&r1=343950&r2=343951&view=diff
> >>     >
> ==============================================================================
> >>     > --- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h (original)
> >>     > +++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h Sun Oct  7
> 21:19:16 2018
> >>     > @@ -169,6 +169,7 @@ extern llvm::cl::opt<bool> DumpSymbols;
> >>     >   extern llvm::cl::opt<bool> DumpSymRecordBytes;
> >>     >   extern llvm::cl::opt<bool> DumpGSIRecords;
> >>     >   extern llvm::cl::opt<bool> DumpGlobals;
> >>     > +extern llvm::cl::list<std::string> DumpGlobalNames;
> >>     >   extern llvm::cl::opt<bool> DumpGlobalExtras;
> >>     >   extern llvm::cl::opt<bool> DumpPublics;
> >>     >   extern llvm::cl::opt<bool> DumpPublicExtras;
> >>     >
> >>     >
> >>     > _______________________________________________
> >>     > llvm-commits mailing list
> >>     > llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
> >>     > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> >>     >
> >>
> >>
> >> _______________________________________________
> >> llvm-commits mailing list
> >> llvm-commits at lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> >>
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> >
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181008/106a7fb6/attachment-0001.html>


More information about the llvm-commits mailing list