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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-02-11 06:43:25 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
|
2015-02-13 09:23:51 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/IPDBSession.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-13 15:40:03 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
|
2015-02-13 09:23:51 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
|
2015-02-11 06:43:25 +08:00
|
|
|
#include "llvm/Support/Format.h"
|
2015-02-13 17:09:03 +08:00
|
|
|
#include <utility>
|
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-14 01:57:09 +08:00
|
|
|
std::unique_ptr<PDBSymbolTypeFunctionSig> PDBSymbolFunc::getSignature() const {
|
|
|
|
return Session.getConcreteSymbolById<PDBSymbolTypeFunctionSig>(getTypeId());
|
|
|
|
}
|
|
|
|
|
2015-02-11 06:43:25 +08:00
|
|
|
void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
|
|
|
|
PDB_DumpLevel Level) const {
|
2015-02-13 15:40:03 +08:00
|
|
|
OS << stream_indent(Indent);
|
|
|
|
if (Level >= PDB_DumpLevel::Normal) {
|
2015-02-11 06:43:25 +08:00
|
|
|
uint32_t FuncStart = getRelativeVirtualAddress();
|
|
|
|
uint32_t FuncEnd = FuncStart + getLength();
|
2015-02-13 09:23:51 +08:00
|
|
|
if (FuncStart == 0 && FuncEnd == 0) {
|
2015-02-14 01:57:09 +08:00
|
|
|
OS << "func [???] ";
|
2015-02-13 09:23:51 +08:00
|
|
|
} else {
|
|
|
|
OS << "func ";
|
|
|
|
OS << "[" << format_hex(FuncStart, 8);
|
|
|
|
if (auto DebugStart = findOneChild<PDBSymbolFuncDebugStart>())
|
|
|
|
OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
|
|
|
|
OS << " - " << format_hex(FuncEnd, 8);
|
|
|
|
if (auto DebugEnd = findOneChild<PDBSymbolFuncDebugEnd>())
|
2015-02-11 06:43:25 +08:00
|
|
|
OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
|
2015-02-13 09:23:51 +08:00
|
|
|
OS << "] ";
|
|
|
|
}
|
|
|
|
|
2015-02-11 06:43:25 +08:00
|
|
|
PDB_RegisterId Reg = getLocalBasePointerRegisterId();
|
|
|
|
if (Reg == PDB_RegisterId::VFrame)
|
|
|
|
OS << "(VFrame)";
|
2015-02-13 05:09:24 +08:00
|
|
|
else if (hasFramePointer())
|
|
|
|
OS << "(" << Reg << ")";
|
|
|
|
else
|
2015-02-11 06:43:25 +08:00
|
|
|
OS << "(FPO)";
|
2015-02-13 09:23:51 +08:00
|
|
|
|
|
|
|
OS << " ";
|
2015-02-14 01:57:09 +08:00
|
|
|
if (auto FuncSig = getSignature()) {
|
|
|
|
// If we have a signature, dump the name with the signature.
|
|
|
|
if (auto ReturnType = FuncSig->getReturnType()) {
|
|
|
|
ReturnType->dump(OS, 0, PDB_DumpLevel::Compact);
|
|
|
|
OS << " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << FuncSig->getCallingConvention() << " ";
|
2015-02-13 15:40:03 +08:00
|
|
|
|
2015-02-14 01:57:09 +08:00
|
|
|
if (auto ClassParent = FuncSig->getClassParent()) {
|
|
|
|
ClassParent->dump(OS, 0, PDB_DumpLevel::Compact);
|
|
|
|
OS << "::";
|
2015-02-13 09:23:51 +08:00
|
|
|
}
|
2015-02-14 01:57:09 +08:00
|
|
|
|
|
|
|
OS << getName();
|
|
|
|
FuncSig->dumpArgList(OS);
|
|
|
|
} else {
|
|
|
|
uint32_t ClassId = getClassParentId();
|
|
|
|
if (ClassId != 0) {
|
|
|
|
if (auto Class = Session.getSymbolById(ClassId)) {
|
|
|
|
if (auto UDT = dyn_cast<PDBSymbolTypeUDT>(Class.get()))
|
|
|
|
OS << UDT->getName() << "::";
|
|
|
|
else
|
|
|
|
OS << "{class " << Class->getSymTag() << "}::";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OS << getName();
|
2015-02-13 09:23:51 +08:00
|
|
|
}
|
2015-02-13 15:40:03 +08:00
|
|
|
} else {
|
|
|
|
OS << getName();
|
2015-02-11 06:43:25 +08:00
|
|
|
}
|
|
|
|
}
|