diff --git a/docs/WritingAnLLVMPass.html b/docs/WritingAnLLVMPass.html index 3e2f167ccbb..d1cf63cae8f 100644 --- a/docs/WritingAnLLVMPass.html +++ b/docs/WritingAnLLVMPass.html @@ -1,34 +1,6 @@
+Using GDB with dynamically loaded passes + |
+ +For sake of discussion, I'm going to assume that you are debugging a +transformation invoked by opt, although nothing described here depends +on that.
+ + +
+ +
+$ gdb opt +GNU gdb 5.0 +Copyright 2000 Free Software Foundation, Inc. +GDB is free software, covered by the GNU General Public License, and you are +welcome to change it and/or distribute copies of it under certain conditions. +Type "show copying" to see the conditions. +There is absolutely no warranty for GDB. Type "show warranty" for details. +This GDB was configured as "sparc-sun-solaris2.6"... +(gdb) +
+ +Note that opt has a lot of debugging information in it, so it takes +time to load. Be patient. Since we cannot set a breakpoint in our pass yet +(the shared object isn't loaded until runtime), we must execute the process, and +have it stop before it invokes our pass, but after it has loaded the shared +object. The most foolproof way of doing this is to set a breakpoint in +PassManager::run and then run the process with the arguments you +want:
+ +
+(gdb) break PassManager::run +Breakpoint 1 at 0x2413bc: file Pass.cpp, line 70. +(gdb) run test.bc -load /shared/lattner/cvs/llvm/lib/Debug/[libname].so -[passoption] +Starting program: /shared/lattner/cvs/llvm/tools/Debug/opt test.bc + -load /shared/lattner/cvs/llvm/lib/Debug/[libname].so -[passoption] +Breakpoint 1, PassManager::run (this=0xffbef174, M=@0x70b298) at Pass.cpp:70 +70 bool PassManager::run(Module &M) { return PM->run(M); } +(gdb) ++ +Once the opt stops in the PassManager::run method you are now +free to set breakpoints in your pass so that you can trace through execution or +do other standard debugging stuff.
+ + + +
+ +
+ +
+ +
+ +
@@ -1098,9 +1161,9 @@ href="#Pass">Pass, only the other way around.
-Christopher Lattner +Chris Lattner -Last modified: Thu Aug 22 14:19:43 CDT 2002 +Last modified: Thu Sep 5 15:06:01 CDT 2002 |