blob: 61b164931e48b8a0c2afff08140658104fb3464b [file] [log] [blame]
Zachary Turner307f5ae2018-10-12 19:47:13 +00001//===-- 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
19namespace lldb_private {
20namespace npdb {
21
22struct 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
29struct 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
37llvm::pdb::PDB_SymType CVSymToPDBSym(llvm::codeview::SymbolKind kind);
38
39bool SymbolHasAddress(const llvm::codeview::CVSymbol &sym);
40bool SymbolIsCode(const llvm::codeview::CVSymbol &sym);
41
42SegmentOffset GetSegmentAndOffset(const llvm::codeview::CVSymbol &sym);
43SegmentOffsetLength
44GetSegmentOffsetAndLength(const llvm::codeview::CVSymbol &sym);
45
46template <typename RecordT> bool IsValidRecord(const RecordT &sym) {
47 return true;
48}
49
50inline 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