llvm.org GIT mirror llvm / ef0b145
Add a simple module-level debug info printer. It just sets up a DebugInfoFinder and iterates over all the contents calling print. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103262 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
4 changed file(s) with 91 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
152152
153153 // print debug info intrinsics in human readable form
154154 FunctionPass *createDbgInfoPrinterPass();
155
156 // Print module-level debug info metadata in human-readable form.
157 ModulePass *createModuleDebugInfoPrinterPass();
155158 }
156159
157160 #endif
131131 (void) llvm::createPrintModulePass(0);
132132 (void) llvm::createPrintFunctionPass("", 0);
133133 (void) llvm::createDbgInfoPrinterPass();
134 (void) llvm::createModuleDebugInfoPrinterPass();
134135 (void) llvm::createPartialInliningPass();
135136 (void) llvm::createSSIPass();
136137 (void) llvm::createSSIEverythingPass();
2727 LoopPass.cpp
2828 MemoryBuiltins.cpp
2929 MemoryDependenceAnalysis.cpp
30 ModuleDebugInfoPrinter.cpp
3031 PHITransAddr.cpp
3132 PointerTracking.cpp
3233 PostDominators.cpp
0 //===-- ModuleDebugInfoPrinter.cpp - Prints module debug info metadata ----===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This pass decodes the debug info metadata in a module and prints in a
10 // (sufficiently-prepared-) human-readable form.
11 //
12 // For example, run this pass from opt along with the -analyze option, and
13 // it'll print to standard output.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #include "llvm/Analysis/Passes.h"
18 #include "llvm/Analysis/DebugInfo.h"
19 #include "llvm/Assembly/Writer.h"
20 #include "llvm/Pass.h"
21 #include "llvm/Function.h"
22 #include "llvm/Support/ErrorHandling.h"
23 #include "llvm/Support/raw_ostream.h"
24 #include "llvm/ADT/Statistic.h"
25 using namespace llvm;
26
27 namespace {
28 class ModuleDebugInfoPrinter : public ModulePass {
29 DebugInfoFinder Finder;
30 public:
31 static char ID; // Pass identification, replacement for typeid
32 ModuleDebugInfoPrinter() : ModulePass(&ID) {}
33
34 virtual bool runOnModule(Module &M);
35
36 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
37 AU.setPreservesAll();
38 }
39 virtual void print(raw_ostream &O, const Module *M) const;
40 };
41 }
42
43 char ModuleDebugInfoPrinter::ID = 0;
44 static RegisterPass
45 X("module-debuginfo",
46 "Decodes module-level debug info", false, true);
47
48 ModulePass *llvm::createModuleDebugInfoPrinterPass() {
49 return new ModuleDebugInfoPrinter();
50 }
51
52 bool ModuleDebugInfoPrinter::runOnModule(Module &M) {
53 Finder.processModule(M);
54 return false;
55 }
56
57 void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const {
58 for (DebugInfoFinder::iterator I = Finder.compile_unit_begin(),
59 E = Finder.compile_unit_end(); I != E; ++I) {
60 O << "Compile Unit: ";
61 DICompileUnit(*I).print(O);
62 O << '\n';
63 }
64
65 for (DebugInfoFinder::iterator I = Finder.subprogram_begin(),
66 E = Finder.subprogram_end(); I != E; ++I) {
67 O << "Subprogram: ";
68 DISubprogram(*I).print(O);
69 O << '\n';
70 }
71
72 for (DebugInfoFinder::iterator I = Finder.global_variable_begin(),
73 E = Finder.global_variable_end(); I != E; ++I) {
74 O << "GlobalVariable: ";
75 DIGlobalVariable(*I).print(O);
76 O << '\n';
77 }
78
79 for (DebugInfoFinder::iterator I = Finder.type_begin(),
80 E = Finder.type_end(); I != E; ++I) {
81 O << "Type: ";
82 DIType(*I).print(O);
83 O << '\n';
84 }
85 }