2010-05-07 18:22:32 +02:00
|
|
|
//===-- ModuleDebugInfoPrinter.cpp - Prints module debug info metadata ----===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This pass decodes the debug info metadata in a module and prints in a
|
|
|
|
// (sufficiently-prepared-) human-readable form.
|
|
|
|
//
|
|
|
|
// For example, run this pass from opt along with the -analyze option, and
|
|
|
|
// it'll print to standard output.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Analysis/Passes.h"
|
2012-12-03 17:50:05 +01:00
|
|
|
#include "llvm/ADT/Statistic.h"
|
2014-03-06 01:46:21 +01:00
|
|
|
#include "llvm/IR/DebugInfo.h"
|
2013-01-02 12:36:10 +01:00
|
|
|
#include "llvm/IR/Function.h"
|
2012-06-28 02:05:13 +02:00
|
|
|
#include "llvm/Pass.h"
|
2010-05-07 18:22:32 +02:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
class ModuleDebugInfoPrinter : public ModulePass {
|
|
|
|
DebugInfoFinder Finder;
|
|
|
|
public:
|
|
|
|
static char ID; // Pass identification, replacement for typeid
|
2010-10-19 19:21:58 +02:00
|
|
|
ModuleDebugInfoPrinter() : ModulePass(ID) {
|
|
|
|
initializeModuleDebugInfoPrinterPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
2010-05-07 18:22:32 +02:00
|
|
|
|
2014-03-05 08:30:04 +01:00
|
|
|
bool runOnModule(Module &M) override;
|
2010-05-07 18:22:32 +02:00
|
|
|
|
2014-03-05 08:30:04 +01:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
2010-05-07 18:22:32 +02:00
|
|
|
AU.setPreservesAll();
|
|
|
|
}
|
2014-03-05 08:30:04 +01:00
|
|
|
void print(raw_ostream &O, const Module *M) const override;
|
2010-05-07 18:22:32 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
char ModuleDebugInfoPrinter::ID = 0;
|
2010-07-22 00:09:45 +02:00
|
|
|
INITIALIZE_PASS(ModuleDebugInfoPrinter, "module-debuginfo",
|
2010-10-08 00:25:06 +02:00
|
|
|
"Decodes module-level debug info", false, true)
|
2010-05-07 18:22:32 +02:00
|
|
|
|
|
|
|
ModulePass *llvm::createModuleDebugInfoPrinterPass() {
|
|
|
|
return new ModuleDebugInfoPrinter();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ModuleDebugInfoPrinter::runOnModule(Module &M) {
|
|
|
|
Finder.processModule(M);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModuleDebugInfoPrinter::print(raw_ostream &O, const Module *M) const {
|
2014-03-18 10:41:07 +01:00
|
|
|
for (DICompileUnit CU : Finder.compile_units()) {
|
2010-05-07 18:22:32 +02:00
|
|
|
O << "Compile Unit: ";
|
2014-03-18 10:41:07 +01:00
|
|
|
CU.print(O);
|
2010-05-07 18:22:32 +02:00
|
|
|
O << '\n';
|
|
|
|
}
|
|
|
|
|
2014-03-18 10:41:07 +01:00
|
|
|
for (DISubprogram S : Finder.subprograms()) {
|
2010-05-07 18:22:32 +02:00
|
|
|
O << "Subprogram: ";
|
2014-03-18 10:41:07 +01:00
|
|
|
S.print(O);
|
2010-05-07 18:22:32 +02:00
|
|
|
O << '\n';
|
|
|
|
}
|
|
|
|
|
2014-03-18 10:41:07 +01:00
|
|
|
for (DIGlobalVariable GV : Finder.global_variables()) {
|
2010-05-07 18:22:32 +02:00
|
|
|
O << "GlobalVariable: ";
|
2014-03-18 10:41:07 +01:00
|
|
|
GV.print(O);
|
2010-05-07 18:22:32 +02:00
|
|
|
O << '\n';
|
|
|
|
}
|
|
|
|
|
2014-03-18 10:41:07 +01:00
|
|
|
for (DIType T : Finder.types()) {
|
2010-05-07 18:22:32 +02:00
|
|
|
O << "Type: ";
|
2014-03-18 10:41:07 +01:00
|
|
|
T.print(O);
|
2010-05-07 18:22:32 +02:00
|
|
|
O << '\n';
|
|
|
|
}
|
|
|
|
}
|