diff options
author | Torok Edwin <edwintorok@gmail.com> | 2009-03-10 13:41:26 +0000 |
---|---|---|
committer | Torok Edwin <edwintorok@gmail.com> | 2009-03-10 13:41:26 +0000 |
commit | ff7d0e9509cf8f359fe14c05dc29a05a293ce88f (patch) | |
tree | c14372a112c7b3779e087c48e9279ef31afe068f /lib/Analysis/DbgInfoPrinter.cpp | |
parent | c29f0c7ddea5a7d5e4f01b47735cb9acdc9ec4df (diff) |
Global variables don't have a corresponding llvm.dbg.declare, yet it is possible
to obtain debug info about them.
Introduce helpers to access debug info for global variables. Also introduce a
helper that works for both local and global variables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66541 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DbgInfoPrinter.cpp')
-rw-r--r-- | lib/Analysis/DbgInfoPrinter.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/Analysis/DbgInfoPrinter.cpp b/lib/Analysis/DbgInfoPrinter.cpp index 127f931b6e..e43bc81ffa 100644 --- a/lib/Analysis/DbgInfoPrinter.cpp +++ b/lib/Analysis/DbgInfoPrinter.cpp @@ -19,6 +19,7 @@ #include "llvm/Module.h" #include "llvm/Value.h" #include "llvm/IntrinsicInst.h" +#include "llvm/Assembly/Writer.h" #include "llvm/Analysis/DebugInfo.h" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/ValueTracking.h" @@ -57,12 +58,17 @@ FunctionPass *llvm::createDbgInfoPrinterPass() { return new PrintDbgInfo(); } void PrintDbgInfo::printVariableDeclaration(const Value *V) { - if(const DbgDeclareInst* DDI = findDbgDeclare(V)) { - DIVariable Var(cast<GlobalVariable>(DDI->getVariable())); - std::string Res1, Res2; - Out << "; variable " << Var.getName(Res1) - << " of type " << Var.getType().getName(Res2) - << " at line " << Var.getLineNumber() << "\n"; + std::string DisplayName, File, Directory, Type; + unsigned LineNo; + if (getLocationInfo(V, DisplayName, Type, LineNo, File, Directory)) { + Out << "; "; + WriteAsOperand(Out, V, false, 0); + Out << " is variable " << DisplayName + << " of type " << Type << " declared at "; + if (PrintDirectory) { + Out << Directory << "/"; + } + Out << File << ":" << LineNo << "\n"; } } @@ -140,6 +146,11 @@ bool PrintDbgInfo::runOnFunction(Function &F) } Out << *i; printVariableDeclaration(i); + if (const User *U = dyn_cast<User>(i)) { + for(unsigned i=0;i<U->getNumOperands();i++) { + printVariableDeclaration(U->getOperand(i)); + } + } } } } |