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