Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 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 | |
Zachary Turner | bae16b3 | 2015-02-08 20:58:09 +0000 | [diff] [blame] | 10 | #include <utility> |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 11 | #include "llvm/DebugInfo/PDB/PDBExtras.h" |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 12 | #include "llvm/DebugInfo/PDB/PDBSymbolData.h" |
| 13 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 14 | #include "llvm/Support/Format.h" |
| 15 | |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 16 | using namespace llvm; |
| 17 | |
Zachary Turner | 98571ed | 2015-02-08 22:53:53 +0000 | [diff] [blame] | 18 | PDBSymbolData::PDBSymbolData(const IPDBSession &PDBSession, |
Zachary Turner | bae16b3 | 2015-02-08 20:58:09 +0000 | [diff] [blame] | 19 | std::unique_ptr<IPDBRawSymbol> DataSymbol) |
| 20 | : PDBSymbol(PDBSession, std::move(DataSymbol)) {} |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 21 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 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 ["; |
Zachary Turner | c074de0 | 2015-02-12 21:09:24 +0000 | [diff] [blame] | 28 | int Length; |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 29 | switch (Loc) { |
| 30 | case PDB_LocType::Static: |
| 31 | OS << format_hex(getRelativeVirtualAddress(), 10); |
Zachary Turner | c074de0 | 2015-02-12 21:09:24 +0000 | [diff] [blame] | 32 | Length = getLength(); |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 33 | break; |
| 34 | case PDB_LocType::TLS: |
| 35 | OS << getAddressSection() << ":" << format_hex(getAddressOffset(), 10); |
| 36 | break; |
| 37 | case PDB_LocType::RegRel: |
| 38 | OS << getRegisterId() << " + " << getOffset() << "]"; |
| 39 | break; |
| 40 | case PDB_LocType::ThisRel: |
| 41 | OS << "this + " << getOffset() << "]"; |
| 42 | break; |
| 43 | case PDB_LocType::Enregistered: |
| 44 | OS << getRegisterId() << "]"; |
| 45 | break; |
| 46 | case PDB_LocType::BitField: { |
| 47 | uint32_t Offset = getOffset(); |
| 48 | uint32_t BitPos = getBitPosition(); |
| 49 | uint32_t Length = getLength(); |
| 50 | uint32_t StartBits = 8 - BitPos; |
| 51 | uint32_t MiddleBytes = (Length - StartBits) / 8; |
| 52 | uint32_t EndBits = Length - StartBits - MiddleBytes * 8; |
| 53 | OS << format_hex(Offset, 10) << ":" << BitPos; |
| 54 | OS << " - " << format_hex(Offset + MiddleBytes, 10) << ":" << EndBits; |
| 55 | break; |
| 56 | } |
| 57 | case PDB_LocType::Slot: |
| 58 | OS << getSlot(); |
| 59 | case PDB_LocType::IlRel: |
| 60 | case PDB_LocType::MetaData: |
| 61 | case PDB_LocType::Constant: |
| 62 | default: |
| 63 | OS << "???"; |
| 64 | } |
| 65 | OS << "] "; |
| 66 | } |
| 67 | OS << getName() << "\n"; |
| 68 | } |