1 //===- PDBSymbolData.cpp - PDB data (e.g. variable) accessors ---*- 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 #include <utility> 11 #include "llvm/DebugInfo/PDB/PDBExtras.h" 12 #include "llvm/DebugInfo/PDB/PDBSymbolData.h" 13 14 #include "llvm/Support/Format.h" 15 16 using namespace llvm; 17 18 PDBSymbolData::PDBSymbolData(const IPDBSession &PDBSession, 19 std::unique_ptr<IPDBRawSymbol> DataSymbol) 20 : PDBSymbol(PDBSession, std::move(DataSymbol)) {} 21 22 void PDBSymbolData::dump(raw_ostream &OS, int Indent, 23 PDB_DumpLevel Level) const { 24 OS.indent(Indent); 25 if (Level == PDB_DumpLevel::Compact) { 26 PDB_LocType Loc = getLocationType(); 27 OS << Loc << " data ["; 28 switch (Loc) { 29 case PDB_LocType::Static: 30 OS << format_hex(getRelativeVirtualAddress(), 10); 31 break; 32 case PDB_LocType::TLS: 33 OS << getAddressSection() << ":" << format_hex(getAddressOffset(), 10); 34 break; 35 case PDB_LocType::RegRel: 36 OS << getRegisterId() << " + " << getOffset() << "]"; 37 break; 38 case PDB_LocType::ThisRel: 39 OS << "this + " << getOffset() << "]"; 40 break; 41 case PDB_LocType::Enregistered: 42 OS << getRegisterId() << "]"; 43 break; 44 case PDB_LocType::BitField: { 45 uint32_t Offset = getOffset(); 46 uint32_t BitPos = getBitPosition(); 47 uint32_t Length = getLength(); 48 uint32_t StartBits = 8 - BitPos; 49 uint32_t MiddleBytes = (Length - StartBits) / 8; 50 uint32_t EndBits = Length - StartBits - MiddleBytes * 8; 51 OS << format_hex(Offset, 10) << ":" << BitPos; 52 OS << " - " << format_hex(Offset + MiddleBytes, 10) << ":" << EndBits; 53 break; 54 } 55 case PDB_LocType::Slot: 56 OS << getSlot(); 57 case PDB_LocType::IlRel: 58 case PDB_LocType::MetaData: 59 case PDB_LocType::Constant: 60 default: 61 OS << "???"; 62 } 63 OS << "] "; 64 } 65 OS << getName() << "\n"; 66 }