1 //===-- PdbUtil.h -----------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBUTIL_H
11 #define LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBUTIL_H
12 
13 #include "lldb/lldb-enumerations.h"
14 
15 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
16 #include "llvm/DebugInfo/PDB/PDBTypes.h"
17 
18 #include <tuple>
19 #include <utility>
20 
21 namespace lldb_private {
22 namespace npdb {
23 
24 struct SegmentOffset {
25   SegmentOffset() = default;
26   SegmentOffset(uint16_t s, uint32_t o) : segment(s), offset(o) {}
27   uint16_t segment = 0;
28   uint32_t offset = 0;
29 };
30 
31 struct SegmentOffsetLength {
32   SegmentOffsetLength() = default;
33   SegmentOffsetLength(uint16_t s, uint32_t o, uint32_t l)
34       : so(s, o), length(l) {}
35   SegmentOffset so;
36   uint32_t length = 0;
37 };
38 
39 llvm::pdb::PDB_SymType CVSymToPDBSym(llvm::codeview::SymbolKind kind);
40 llvm::pdb::PDB_SymType CVTypeToPDBType(llvm::codeview::TypeLeafKind kind);
41 
42 bool SymbolHasAddress(const llvm::codeview::CVSymbol &sym);
43 bool SymbolIsCode(const llvm::codeview::CVSymbol &sym);
44 
45 SegmentOffset GetSegmentAndOffset(const llvm::codeview::CVSymbol &sym);
46 SegmentOffsetLength
47 GetSegmentOffsetAndLength(const llvm::codeview::CVSymbol &sym);
48 
49 template <typename RecordT> bool IsValidRecord(const RecordT &sym) {
50   return true;
51 }
52 
53 inline bool IsValidRecord(const llvm::codeview::ProcRefSym &sym) {
54   // S_PROCREF symbols have 1-based module indices.
55   return sym.Module > 0;
56 }
57 
58 bool IsForwardRefUdt(llvm::codeview::CVType cvt);
59 
60 lldb::AccessType TranslateMemberAccess(llvm::codeview::MemberAccess access);
61 llvm::codeview::TypeIndex GetFieldListIndex(llvm::codeview::CVType cvt);
62 
63 llvm::StringRef DropNameScope(llvm::StringRef name);
64 
65 } // namespace npdb
66 } // namespace lldb_private
67 
68 #endif
69