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 //===----------------------------------------------------------------------===//
11 #include "llvm/DebugInfo/PDB/IPDBSession.h"
12 #include "llvm/DebugInfo/PDB/PDBExtras.h"
13 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
14 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
16 #include "llvm/Support/Format.h"
20 PDBSymbolData::PDBSymbolData(const IPDBSession &PDBSession,
21 std::unique_ptr<IPDBRawSymbol> DataSymbol)
22 : PDBSymbol(PDBSession, std::move(DataSymbol)) {}
24 void PDBSymbolData::dump(raw_ostream &OS, int Indent,
25 PDB_DumpLevel Level) const {
26 OS << stream_indent(Indent);
27 PDB_LocType Loc = getLocationType();
28 PDB_DataKind Kind = getDataKind();
29 if (Level == PDB_DumpLevel::Compact) {
31 case PDB_LocType::Static: {
32 uint32_t RVA = getRelativeVirtualAddress();
33 OS << Kind << " data[";
35 OS << format_hex(RVA, 10);
40 case PDB_LocType::TLS:
41 OS << "threadlocal " << Kind << " data[";
42 OS << getAddressSection() << ":" << format_hex(getAddressOffset(), 10);
44 case PDB_LocType::RegRel:
45 OS << "regrel " << Kind << " data[";
46 OS << getRegisterId() << " + " << getOffset();
48 case PDB_LocType::ThisRel: {
49 uint32_t Offset = getOffset();
50 OS << Kind << " data[this + " << format_hex(Offset, 4);
53 case PDB_LocType::Enregistered:
54 OS << "register " << Kind << " data[" << getRegisterId();
56 case PDB_LocType::BitField: {
57 OS << "bitfield data[this + ";
58 uint32_t Offset = getOffset();
59 uint32_t BitPos = getBitPosition();
60 uint32_t Length = getLength();
61 OS << format_hex(Offset, 4) << ":" << BitPos << "," << Length;
64 case PDB_LocType::Slot:
67 case PDB_LocType::Constant: {
68 OS << "constant data[";
72 case PDB_LocType::IlRel:
73 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() << "}";
89 OS << getName() << "\n";