1 //===- PDBSymbolData.cpp - PDB data (e.g. variable) accessors ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/DebugInfo/PDB/IPDBSession.h"
11 #include "llvm/DebugInfo/PDB/PDBExtras.h"
12 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
13 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
14 #include "llvm/Support/Format.h"
19 PDBSymbolData::PDBSymbolData(const IPDBSession &PDBSession,
20 std::unique_ptr<IPDBRawSymbol> DataSymbol)
21 : PDBSymbol(PDBSession, std::move(DataSymbol)) {}
23 void PDBSymbolData::dump(raw_ostream &OS, int Indent,
24 PDB_DumpLevel Level) const {
25 OS << stream_indent(Indent);
26 PDB_LocType Loc = getLocationType();
27 PDB_DataKind Kind = getDataKind();
28 if (Level >= PDB_DumpLevel::Normal) {
30 case PDB_LocType::Static: {
31 uint32_t RVA = getRelativeVirtualAddress();
32 OS << Kind << " data[";
34 OS << format_hex(RVA, 10);
39 case PDB_LocType::TLS:
40 OS << "threadlocal " << Kind << " data[";
41 OS << getAddressSection() << ":" << format_hex(getAddressOffset(), 10);
43 case PDB_LocType::RegRel:
44 OS << "regrel " << Kind << " data[";
45 OS << getRegisterId() << " + " << getOffset();
47 case PDB_LocType::ThisRel: {
48 uint32_t Offset = getOffset();
49 OS << Kind << " data[this + " << format_hex(Offset, 4);
52 case PDB_LocType::Enregistered:
53 OS << "register " << Kind << " data[" << getRegisterId();
55 case PDB_LocType::BitField: {
56 OS << "bitfield data[this + ";
57 uint32_t Offset = getOffset();
58 uint32_t BitPos = getBitPosition();
59 uint32_t Length = getLength();
60 OS << format_hex(Offset, 4) << ":" << BitPos << "," << Length;
63 case PDB_LocType::Slot:
66 case PDB_LocType::Constant: {
67 OS << "constant data[";
71 case PDB_LocType::IlRel:
72 case PDB_LocType::MetaData:
79 if (Kind == PDB_DataKind::Member || Kind == PDB_DataKind::StaticMember) {
80 uint32_t ClassId = getClassParentId();
81 if (auto Class = Session.getSymbolById(ClassId)) {
82 if (auto UDT = dyn_cast<PDBSymbolTypeUDT>(Class.get()))
85 OS << "{class " << Class->getSymTag() << "}";