2009-05-11 07:14:38 +08:00
|
|
|
//===-- llvm/CodeGen/DwarfWriter.cpp - Dwarf Framework --------------------===//
|
2005-12-22 03:48:16 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-12-22 03:48:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2007-01-30 02:51:14 +08:00
|
|
|
// This file contains support for writing dwarf info into asm files.
|
2005-12-22 03:48:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2006-01-28 02:32:41 +08:00
|
|
|
|
2006-01-05 06:28:25 +08:00
|
|
|
#include "llvm/CodeGen/DwarfWriter.h"
|
2009-05-15 17:23:25 +08:00
|
|
|
#include "DwarfDebug.h"
|
2009-05-15 09:12:28 +08:00
|
|
|
#include "DwarfException.h"
|
2007-01-27 05:22:28 +08:00
|
|
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2006-01-05 06:28:25 +08:00
|
|
|
using namespace llvm;
|
2006-01-04 21:52:30 +08:00
|
|
|
|
2009-01-09 07:40:34 +08:00
|
|
|
static RegisterPass<DwarfWriter>
|
|
|
|
X("dwarfwriter", "DWARF Information Writer");
|
|
|
|
char DwarfWriter::ID = 0;
|
|
|
|
|
2006-10-30 21:35:07 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// DwarfWriter Implementation
|
2006-11-03 04:12:39 +08:00
|
|
|
///
|
2006-10-30 21:35:07 +08:00
|
|
|
|
2009-03-11 04:41:52 +08:00
|
|
|
DwarfWriter::DwarfWriter()
|
2009-03-11 05:23:25 +08:00
|
|
|
: ImmutablePass(&ID), DD(0), DE(0) {}
|
2006-10-30 21:35:07 +08:00
|
|
|
|
|
|
|
DwarfWriter::~DwarfWriter() {
|
2007-01-30 02:51:14 +08:00
|
|
|
delete DE;
|
|
|
|
delete DD;
|
2006-10-30 21:35:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// BeginModule - Emit all Dwarf sections that should come prior to the
|
|
|
|
/// content.
|
2010-04-04 15:48:20 +08:00
|
|
|
void DwarfWriter::BeginModule(Module *M, AsmPrinter *A) {
|
|
|
|
DE = new DwarfException(A);
|
|
|
|
DD = new DwarfDebug(A);
|
|
|
|
DE->BeginModule(M);
|
|
|
|
DD->beginModule(M);
|
2006-10-30 21:35:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// EndModule - Emit all Dwarf sections that should come after the content.
|
|
|
|
///
|
|
|
|
void DwarfWriter::EndModule() {
|
2007-01-30 02:51:14 +08:00
|
|
|
DE->EndModule();
|
2009-11-21 10:48:08 +08:00
|
|
|
DD->endModule();
|
2009-09-12 01:24:29 +08:00
|
|
|
delete DD; DD = 0;
|
|
|
|
delete DE; DE = 0;
|
2006-10-30 21:35:07 +08:00
|
|
|
}
|
|
|
|
|
2008-08-16 20:57:46 +08:00
|
|
|
/// BeginFunction - Gather pre-function debug information. Assumes being
|
2006-10-30 21:35:07 +08:00
|
|
|
/// emitted immediately after the function entry point.
|
2010-01-27 07:18:02 +08:00
|
|
|
void DwarfWriter::BeginFunction(const MachineFunction *MF) {
|
2007-01-30 02:51:14 +08:00
|
|
|
DE->BeginFunction(MF);
|
2009-11-21 10:48:08 +08:00
|
|
|
DD->beginFunction(MF);
|
2006-10-30 21:35:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// EndFunction - Gather and emit post-function debug information.
|
|
|
|
///
|
2010-01-27 07:18:02 +08:00
|
|
|
void DwarfWriter::EndFunction(const MachineFunction *MF) {
|
2009-11-21 10:48:08 +08:00
|
|
|
DD->endFunction(MF);
|
2007-02-02 00:31:34 +08:00
|
|
|
DE->EndFunction();
|
2008-08-16 20:57:46 +08:00
|
|
|
|
2008-07-22 08:53:37 +08:00
|
|
|
if (MachineModuleInfo *MMI = DD->getMMI() ? DD->getMMI() : DE->getMMI())
|
2007-02-02 00:31:34 +08:00
|
|
|
// Clear function debug information.
|
|
|
|
MMI->EndFunction();
|
2006-10-30 21:35:07 +08:00
|
|
|
}
|
2009-01-13 03:17:34 +08:00
|
|
|
|
2009-02-20 08:44:43 +08:00
|
|
|
/// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
|
|
|
|
/// be emitted.
|
|
|
|
bool DwarfWriter::ShouldEmitDwarfDebug() const {
|
2009-05-03 16:50:41 +08:00
|
|
|
return DD && DD->ShouldEmitDwarfDebug();
|
2009-02-20 08:44:43 +08:00
|
|
|
}
|
2009-04-14 01:02:03 +08:00
|
|
|
|
2010-03-30 01:20:31 +08:00
|
|
|
void DwarfWriter::BeginScope(const MachineInstr *MI) {
|
|
|
|
DD->beginScope(MI);
|
2009-04-15 08:10:26 +08:00
|
|
|
}
|
2009-11-11 07:06:00 +08:00
|
|
|
void DwarfWriter::EndScope(const MachineInstr *MI) {
|
2009-11-21 10:48:08 +08:00
|
|
|
DD->endScope(MI);
|
2009-10-07 02:37:31 +08:00
|
|
|
}
|