Update BreakpointPrinter to emit original function names only.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128839 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2011-04-04 19:51:17 +00:00
parent 5fcb81dace
commit 1be9980d06

View File

@ -26,6 +26,7 @@
#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLibraryInfo.h" #include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Triple.h" #include "llvm/ADT/Triple.h"
#include "llvm/Support/PassNameParser.h" #include "llvm/Support/PassNameParser.h"
#include "llvm/Support/Signals.h" #include "llvm/Support/Signals.h"
@ -342,28 +343,43 @@ struct BasicBlockPassPrinter : public BasicBlockPass {
char BasicBlockPassPrinter::ID = 0; char BasicBlockPassPrinter::ID = 0;
struct BreakpointPrinter : public FunctionPass { struct BreakpointPrinter : public ModulePass {
raw_ostream &Out; raw_ostream &Out;
static char ID; static char ID;
BreakpointPrinter(raw_ostream &out) BreakpointPrinter(raw_ostream &out)
: FunctionPass(ID), Out(out) { : ModulePass(ID), Out(out) {
} }
virtual bool runOnFunction(Function &F) { void getContextName(DIDescriptor Context, std::string &N) {
BasicBlock &EntryBB = F.getEntryBlock(); if (Context.isNameSpace()) {
BasicBlock::const_iterator BI = EntryBB.end(); DINameSpace NS(Context);
--BI; if (!NS.getName().empty()) {
do { getContextName(NS.getContext(), N);
const Instruction *In = BI; N = N + NS.getName().str() + "::";
const DebugLoc DL = In->getDebugLoc(); }
if (!DL.isUnknown()) { } else if (Context.isType()) {
DIScope S(DL.getScope(getGlobalContext())); DIType TY(Context);
Out << S.getFilename() << " " << DL.getLine() << "\n"; if (!TY.getName().empty()) {
break; getContextName(TY.getContext(), N);
N = N + TY.getName().str() + "::";
}
}
}
virtual bool runOnModule(Module &M) {
StringSet<> Processed;
if (NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.sp"))
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
std::string Name;
DISubprogram SP(NMD->getOperand(i));
if (SP.Verify())
getContextName(SP.getContext(), Name);
Name = Name + SP.getDisplayName().str();
if (!Name.empty() && Processed.insert(Name)) {
Out << Name << "\n";
}
} }
--BI;
} while (BI != EntryBB.begin());
return false; return false;
} }