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