| Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame^] | 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 "llvm/DebugInfo/CodeView/SymbolRecord.h" |
| 14 | #include "llvm/DebugInfo/PDB/PDBTypes.h" |
| 15 | |
| 16 | #include <tuple> |
| 17 | #include <utility> |
| 18 | |
| 19 | namespace lldb_private { |
| 20 | namespace npdb { |
| 21 | |
| 22 | struct SegmentOffset { |
| 23 | SegmentOffset() = default; |
| 24 | SegmentOffset(uint16_t s, uint32_t o) : segment(s), offset(o) {} |
| 25 | uint16_t segment = 0; |
| 26 | uint32_t offset = 0; |
| 27 | }; |
| 28 | |
| 29 | struct SegmentOffsetLength { |
| 30 | SegmentOffsetLength() = default; |
| 31 | SegmentOffsetLength(uint16_t s, uint32_t o, uint32_t l) |
| 32 | : so(s, o), length(l) {} |
| 33 | SegmentOffset so; |
| 34 | uint32_t length = 0; |
| 35 | }; |
| 36 | |
| 37 | llvm::pdb::PDB_SymType CVSymToPDBSym(llvm::codeview::SymbolKind kind); |
| 38 | |
| 39 | bool SymbolHasAddress(const llvm::codeview::CVSymbol &sym); |
| 40 | bool SymbolIsCode(const llvm::codeview::CVSymbol &sym); |
| 41 | |
| 42 | SegmentOffset GetSegmentAndOffset(const llvm::codeview::CVSymbol &sym); |
| 43 | SegmentOffsetLength |
| 44 | GetSegmentOffsetAndLength(const llvm::codeview::CVSymbol &sym); |
| 45 | |
| 46 | template <typename RecordT> bool IsValidRecord(const RecordT &sym) { |
| 47 | return true; |
| 48 | } |
| 49 | |
| 50 | inline bool IsValidRecord(const llvm::codeview::ProcRefSym &sym) { |
| 51 | // S_PROCREF symbols have 1-based module indices. |
| 52 | return sym.Module > 0; |
| 53 | } |
| 54 | |
| 55 | } // namespace npdb |
| 56 | } // namespace lldb_private |
| 57 | |
| 58 | #endif |