diff options
| author | Devang Patel <dpatel@apple.com> | 2011-04-04 19:51:17 +0000 |
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2011-04-04 19:51:17 +0000 |
| commit | 0abc463f5b5d6ca72ea8ea681f9f0af83717f90d (patch) | |
| tree | 8e202d63c317828093924e3a0a6ea8b385ce86de /llvm | |
| parent | 35d800c39f238a529fcb832891f799bb32645170 (diff) | |
| download | bcm5719-llvm-0abc463f5b5d6ca72ea8ea681f9f0af83717f90d.tar.gz bcm5719-llvm-0abc463f5b5d6ca72ea8ea681f9f0af83717f90d.zip | |
Update BreakpointPrinter to emit original function names only.
llvm-svn: 128839
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/tools/opt/opt.cpp | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index e55b4b3e2af..6760b22cebf 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -26,6 +26,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetLibraryInfo.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/ADT/StringSet.h" #include "llvm/ADT/Triple.h" #include "llvm/Support/PassNameParser.h" #include "llvm/Support/Signals.h" @@ -342,28 +343,43 @@ struct BasicBlockPassPrinter : public BasicBlockPass { char BasicBlockPassPrinter::ID = 0; -struct BreakpointPrinter : public FunctionPass { +struct BreakpointPrinter : public ModulePass { raw_ostream &Out; static char ID; BreakpointPrinter(raw_ostream &out) - : FunctionPass(ID), Out(out) { + : ModulePass(ID), Out(out) { } - virtual bool runOnFunction(Function &F) { - BasicBlock &EntryBB = F.getEntryBlock(); - BasicBlock::const_iterator BI = EntryBB.end(); - --BI; - do { - const Instruction *In = BI; - const DebugLoc DL = In->getDebugLoc(); - if (!DL.isUnknown()) { - DIScope S(DL.getScope(getGlobalContext())); - Out << S.getFilename() << " " << DL.getLine() << "\n"; - break; + void getContextName(DIDescriptor Context, std::string &N) { + if (Context.isNameSpace()) { + DINameSpace NS(Context); + if (!NS.getName().empty()) { + getContextName(NS.getContext(), N); + N = N + NS.getName().str() + "::"; + } + } else if (Context.isType()) { + DIType TY(Context); + if (!TY.getName().empty()) { + 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; } |

