Hi, Dear all I am debuging my frontend and I want to print the debug information. Like when using opt -debug -loop-vectorize xxx.ll the -debug prints the detailed logs of the loop vectorize pass and that is what I want to do in my code. Could anyone provide some "how-to" information to me? Thanks. -- Fan Zhang Department of Computer Science University of South Carolina, Columbia -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140507/4f606ca3/attachment.html>
Hi, Maybe this page will answer your questions: http://llvm.org/docs/ProgrammersManual.html#the-debug-macro-and-debug-option Michael On May 7, 2014, at 9:04 AM, Fan Zhang <zhangfan0726 at gmail.com> wrote:> Hi, Dear all > > I am debuging my frontend and I want to print the debug information. Like when using > opt -debug -loop-vectorize xxx.ll > > the -debug prints the detailed logs of the loop vectorize pass and that is what I want to do in my code. > > Could anyone provide some "how-to" information to me? > > Thanks. > > -- > Fan Zhang > Department of Computer Science > University of South Carolina, Columbia > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> I am debuging my frontend and I want to print the debug information. Like > when using > opt -debug -loop-vectorize xxx.ll > > the -debug prints the detailed logs of the loop vectorize pass and that is > what I want to do in my code.If you're using LLVM's Command line parser then this is incredibly easy. Simply #include <llvm/Support/Debug.h> and then use the facilities that this header file provides. For example you can use the following macro DEBUG( dbgs() << "This is a message for debugging\n"); This will cause the message to printed to stderr only if you pass the -debug command line flag and do a debug build. An even more useful feature is the following macro DEBUG_WITH_TYPE("mypass", dbgs() << "This is a message for mypass\n"); If you pass the command line flag -debug-only=mypass then you will only see messages that choose "mypass" as their type. This is useful if you are running many passes because the output of -debug can be quite noisy if you are only interested in a particular pass. The header Debug.h header file does expose a few other features so I recommend you have a read so that you are aware of what features are available to you so you can pick what is most suitable to you. Hope that helps. Thanks, -- Dan Liew PhD Student - Imperial College London