[llvm] r349361 - [PDB] Add some helper functions for working with scopes.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 17 08:15:36 PST 2018


Author: zturner
Date: Mon Dec 17 08:15:36 2018
New Revision: 349361

URL: http://llvm.org/viewvc/llvm-project?rev=349361&view=rev
Log:
[PDB] Add some helper functions for working with scopes.

Modified:
    llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h
    llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h?rev=349361&r1=349360&r2=349361&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h Mon Dec 17 08:15:36 2018
@@ -51,6 +51,7 @@ inline bool symbolEndsScope(SymbolKind K
 /// Given a symbol P for which symbolOpensScope(P) == true, return the
 /// corresponding end offset.
 uint32_t getScopeEndOffset(const CVSymbol &Symbol);
+uint32_t getScopeParentOffset(const CVSymbol &Symbol);
 
 CVSymbolArray limitSymbolArrayToScope(const CVSymbolArray &Symbols,
                                       uint32_t ScopeBegin);

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=349361&r1=349360&r2=349361&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h Mon Dec 17 08:15:36 2018
@@ -44,6 +44,8 @@ public:
   symbols(bool *HadError) const;
 
   const codeview::CVSymbolArray &getSymbolArray() const { return SymbolArray; }
+  const codeview::CVSymbolArray
+  getSymbolArrayForScope(uint32_t ScopeBegin) const;
 
   BinarySubstreamRef getSymbolsSubstream() const;
   BinarySubstreamRef getC11LinesSubstream() const;

Modified: llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp?rev=349361&r1=349360&r2=349361&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp Mon Dec 17 08:15:36 2018
@@ -21,8 +21,7 @@ template <typename RecordT> RecordT crea
   return record;
 }
 
-uint32_t
-llvm::codeview::getScopeEndOffset(const llvm::codeview::CVSymbol &Sym) {
+uint32_t llvm::codeview::getScopeEndOffset(const CVSymbol &Sym) {
   assert(symbolOpensScope(Sym.kind()));
   switch (Sym.kind()) {
   case SymbolKind::S_GPROC32:
@@ -48,6 +47,37 @@ llvm::codeview::getScopeEndOffset(const
   }
   default:
     assert(false && "Unknown record type");
+    return 0;
+  }
+}
+
+uint32_t
+llvm::codeview::getScopeParentOffset(const llvm::codeview::CVSymbol &Sym) {
+  assert(symbolOpensScope(Sym.kind()));
+  switch (Sym.kind()) {
+  case SymbolKind::S_GPROC32:
+  case SymbolKind::S_LPROC32:
+  case SymbolKind::S_GPROC32_ID:
+  case SymbolKind::S_LPROC32_ID:
+  case SymbolKind::S_LPROC32_DPC:
+  case SymbolKind::S_LPROC32_DPC_ID: {
+    ProcSym Proc = createRecord<ProcSym>(Sym);
+    return Proc.Parent;
+  }
+  case SymbolKind::S_BLOCK32: {
+    BlockSym Block = createRecord<BlockSym>(Sym);
+    return Block.Parent;
+  }
+  case SymbolKind::S_THUNK32: {
+    Thunk32Sym Thunk = createRecord<Thunk32Sym>(Sym);
+    return Thunk.Parent;
+  }
+  case SymbolKind::S_INLINESITE: {
+    InlineSiteSym Site = createRecord<InlineSiteSym>(Sym);
+    return Site.Parent;
+  }
+  default:
+    assert(false && "Unknown record type");
     return 0;
   }
 }

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=349361&r1=349360&r2=349361&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp Mon Dec 17 08:15:36 2018
@@ -11,7 +11,9 @@
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/DebugInfo/CodeView/CodeView.h"
 #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
+#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
+#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
 #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
 #include "llvm/DebugInfo/PDB/Native/RawError.h"
 #include "llvm/Support/BinaryStreamReader.h"
@@ -77,6 +79,11 @@ Error ModuleDebugStreamRef::reload() {
   return Error::success();
 }
 
+const codeview::CVSymbolArray
+ModuleDebugStreamRef::getSymbolArrayForScope(uint32_t ScopeBegin) const {
+  return limitSymbolArrayToScope(SymbolArray, ScopeBegin);
+}
+
 BinarySubstreamRef ModuleDebugStreamRef::getSymbolsSubstream() const {
   return SymbolsSubstream;
 }




More information about the llvm-commits mailing list