eac1a544d33c2940430210ff3486234a049542ab
[oota-llvm.git] / lib / DebugInfo / PDB / PDBSymbolThunk.cpp
1 //===- PDBSymbolThunk.cpp - -------------------------------------*- 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
12 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
13 #include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
14
15 #include "llvm/Support/Format.h"
16
17 using namespace llvm;
18
19 PDBSymbolThunk::PDBSymbolThunk(const IPDBSession &PDBSession,
20                                std::unique_ptr<IPDBRawSymbol> Symbol)
21     : PDBSymbol(PDBSession, std::move(Symbol)) {}
22
23 void PDBSymbolThunk::dump(raw_ostream &OS, int Indent,
24                           PDB_DumpLevel Level) const {
25   if (Level == PDB_DumpLevel::Compact) {
26     OS.indent(Indent);
27     PDB_ThunkOrdinal Ordinal = getThunkOrdinal();
28     uint32_t RVA = getRelativeVirtualAddress();
29     if (Ordinal == PDB_ThunkOrdinal::TrampIncremental) {
30       OS << format_hex(RVA, 10);
31     } else {
32       OS << "[" << format_hex(RVA, 10);
33       OS << " - " << format_hex(RVA + getLength(), 10) << "]";
34     }
35     OS << " thunk(" << Ordinal << ")";
36     if (Ordinal == PDB_ThunkOrdinal::TrampIncremental)
37       OS << " -> " << format_hex(getTargetRelativeVirtualAddress(), 10);
38     OS << " ";
39     std::string Name = getName();
40     if (!Name.empty())
41       OS << Name;
42     OS << "\n";
43   }
44 }