[lldb-dev] e not working when debugging llvm pass

carr27 via lldb-dev lldb-dev at lists.llvm.org
Sun Sep 13 16:26:00 PDT 2015


Hello,

I'm working on an LLVM pass that I'm trying to debug it with LLDB, but 
I'm running into a few problems.  I'm generally following this turtorial 
[1] but I run my pass with opt instead from inside clang. So I run:

$ lldb ../build/bin/opt
(lldb) break set --name MyPass::runOnModule
(lldb) run -load ../build/lib/LLVMMyPass.so -MyPass test.ll

My runOnModule is just:

bool MyPass::runOnModule(Module &M) {
  for (auto& F : M) {
     for (auto& BB : F) {
       for (auto& I : BB) {
         I.dump(); // step to here
       }
     }
   }
}

It hits the breakpoint correctly then I single step into the inner most 
loop.  Then I try the following LLDB commands:

"e I.dump()" gives me what I expect (it prints the LLVM instruction).

"e BB.dump()" gives me:
error: no member named 'dump' in 'llvm::BasicBlock'
error: 1 errors parsing expression

...but llvm::BasicBlock definitely does have a member named dump.

"e M.dump()" gives me:
lldb: 
/home/carr27/dataconf-workspace2/llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp:2883: 
const clang::ASTRecordLayout 
&clang::ASTContext::getASTRecordLayout(const clang::RecordDecl *) const: 
Assertion `D && "Cannot get layout of forward declarations!"' failed.
./lldb.sh: line 1:  6736 Aborted                 (core dumped)

I don't know exactly what is going on, but it seems like LLDB doesn't 
know about some of the LLVM classes.  Can anyone give me a pointer as to 
what might be wrong?  Having a good debug work flow would be a big help 
in writing my pass!

Thanks,
Scott Carr
PhD Student
Purdue University Computer Science

[1]http://homes.cs.washington.edu/~bholt/posts/llvm-debugging.html


More information about the lldb-dev mailing list