1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
//===- NativeSymbolEnumerator.cpp - info about enumerators ------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/PDB/Native/NativeSymbolEnumerator.h"
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
#include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
#include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
using namespace llvm;
using namespace llvm::codeview;
using namespace llvm::pdb;
NativeSymbolEnumerator::NativeSymbolEnumerator(
NativeSession &Session, SymIndexId Id, const NativeTypeEnum &Parent,
codeview::EnumeratorRecord Record)
: NativeRawSymbol(Session, PDB_SymType::Data, Id), Parent(Parent),
Record(std::move(Record)) {}
NativeSymbolEnumerator::~NativeSymbolEnumerator() = default;
void NativeSymbolEnumerator::dump(raw_ostream &OS, int Indent,
PdbSymbolIdField ShowIdFields,
PdbSymbolIdField RecurseIdFields) const {
NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
dumpSymbolIdField(OS, "classParentId", getClassParentId(), Indent, Session,
PdbSymbolIdField::ClassParent, ShowIdFields,
RecurseIdFields);
dumpSymbolIdField(OS, "lexicalParentId", getLexicalParentId(), Indent,
Session, PdbSymbolIdField::LexicalParent, ShowIdFields,
RecurseIdFields);
dumpSymbolField(OS, "name", getName(), Indent);
dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session,
PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
dumpSymbolField(OS, "dataKind", getDataKind(), Indent);
dumpSymbolField(OS, "locationType", getLocationType(), Indent);
dumpSymbolField(OS, "constType", isConstType(), Indent);
dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent);
dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
dumpSymbolField(OS, "value", getValue(), Indent);
}
SymIndexId NativeSymbolEnumerator::getClassParentId() const {
return Parent.getSymIndexId();
}
SymIndexId NativeSymbolEnumerator::getLexicalParentId() const { return 0; }
std::string NativeSymbolEnumerator::getName() const {
return std::string(Record.Name);
}
SymIndexId NativeSymbolEnumerator::getTypeId() const {
return Parent.getTypeId();
}
PDB_DataKind NativeSymbolEnumerator::getDataKind() const {
return PDB_DataKind::Constant;
}
PDB_LocType NativeSymbolEnumerator::getLocationType() const {
return PDB_LocType::Constant;
}
bool NativeSymbolEnumerator::isConstType() const { return false; }
bool NativeSymbolEnumerator::isVolatileType() const { return false; }
bool NativeSymbolEnumerator::isUnalignedType() const { return false; }
Variant NativeSymbolEnumerator::getValue() const {
const NativeTypeBuiltin &BT = Parent.getUnderlyingBuiltinType();
switch (BT.getBuiltinType()) {
case PDB_BuiltinType::Int:
case PDB_BuiltinType::Long:
case PDB_BuiltinType::Char: {
assert(Record.Value.isSignedIntN(BT.getLength() * 8));
int64_t N = Record.Value.getSExtValue();
switch (BT.getLength()) {
case 1:
return Variant{static_cast<int8_t>(N)};
case 2:
return Variant{static_cast<int16_t>(N)};
case 4:
return Variant{static_cast<int32_t>(N)};
case 8:
return Variant{static_cast<int64_t>(N)};
}
break;
}
case PDB_BuiltinType::UInt:
case PDB_BuiltinType::ULong: {
assert(Record.Value.isIntN(BT.getLength() * 8));
uint64_t U = Record.Value.getZExtValue();
switch (BT.getLength()) {
case 1:
return Variant{static_cast<uint8_t>(U)};
case 2:
return Variant{static_cast<uint16_t>(U)};
case 4:
return Variant{static_cast<uint32_t>(U)};
case 8:
return Variant{static_cast<uint64_t>(U)};
}
break;
}
case PDB_BuiltinType::Bool: {
assert(Record.Value.isIntN(BT.getLength() * 8));
uint64_t U = Record.Value.getZExtValue();
return Variant{static_cast<bool>(U)};
}
default:
assert(false && "Invalid enumeration type");
break;
}
return Variant{Record.Value.getSExtValue()};
}
|