2015-02-08 08:29:29 +08:00
|
|
|
//===- PDBSymbolFunc.cpp - --------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
2015-02-11 06:43:25 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
|
2015-02-08 08:29:29 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
|
|
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
|
2015-02-11 06:43:25 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
|
|
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
|
2015-02-08 08:29:29 +08:00
|
|
|
|
2015-02-11 06:43:25 +08:00
|
|
|
#include "llvm/Support/Format.h"
|
2015-02-08 08:29:29 +08:00
|
|
|
|
2015-02-11 06:43:25 +08:00
|
|
|
using namespace llvm;
|
2015-02-09 06:53:53 +08:00
|
|
|
PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession,
|
2015-02-09 04:58:09 +08:00
|
|
|
std::unique_ptr<IPDBRawSymbol> Symbol)
|
|
|
|
: PDBSymbol(PDBSession, std::move(Symbol)) {}
|
2015-02-08 08:29:29 +08:00
|
|
|
|
2015-02-11 06:43:25 +08:00
|
|
|
void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
|
|
|
|
PDB_DumpLevel Level) const {
|
|
|
|
if (Level == PDB_DumpLevel::Compact) {
|
|
|
|
uint32_t FuncStart = getRelativeVirtualAddress();
|
|
|
|
uint32_t FuncEnd = FuncStart + getLength();
|
|
|
|
auto DebugEndSymbol = findChildren(PDB_SymType::FuncDebugEnd);
|
|
|
|
OS << stream_indent(Indent);
|
|
|
|
OS << "[" << format_hex(FuncStart, 8);
|
|
|
|
if (auto DebugStartEnum = findChildren(PDB_SymType::FuncDebugStart)) {
|
|
|
|
if (auto StartSym = DebugStartEnum->getNext()) {
|
|
|
|
auto DebugStart = dyn_cast<PDBSymbolFuncDebugStart>(StartSym.get());
|
|
|
|
OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OS << " - " << format_hex(FuncEnd, 8);
|
|
|
|
if (auto DebugEndEnum = findChildren(PDB_SymType::FuncDebugEnd)) {
|
|
|
|
if (auto DebugEndSym = DebugEndEnum->getNext()) {
|
|
|
|
auto DebugEnd = dyn_cast<PDBSymbolFuncDebugEnd>(DebugEndSym.get());
|
|
|
|
OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OS << "] ";
|
|
|
|
PDB_RegisterId Reg = getLocalBasePointerRegisterId();
|
|
|
|
if (Reg == PDB_RegisterId::VFrame)
|
|
|
|
OS << "(VFrame)";
|
|
|
|
else if (hasFramePointer()) {
|
|
|
|
if (Reg == PDB_RegisterId::EBP)
|
|
|
|
OS << "(EBP)";
|
|
|
|
else
|
|
|
|
OS << "(" << (int)Reg << ")";
|
|
|
|
} else {
|
|
|
|
OS << "(FPO)";
|
|
|
|
}
|
|
|
|
OS << " " << getName() << "\n";
|
|
|
|
}
|
|
|
|
OS.flush();
|
|
|
|
}
|