1 //===-- llvm/CodeGen/DwarfWriter.cpp - Dwarf Framework ----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by James M. Laskey and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains support for writing dwarf debug info into asm files.
12 //===----------------------------------------------------------------------===//
15 #include "llvm/CodeGen/AsmPrinter.h"
16 #include "llvm/CodeGen/DwarfWriter.h"
17 #include "llvm/Support/CommandLine.h"
23 DwarfVerbose("dwarf-verbose", cl::Hidden,
24 cl::desc("Add comments to dwarf directives."));
26 /// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
27 /// unsigned leb128 value.
29 void DwarfWriter::EmitULEB128Bytes(unsigned Value, std::string Comment) {
34 O << Asm->getData8bitsDirective();
39 << Asm->getCommentString()
48 /// EmitSLEB128Bytes - Emit an assembler byte data directive to compose a
49 /// signed leb128 value.
51 void DwarfWriter::EmitSLEB128Bytes(int Value, std::string Comment) {
56 O << Asm->getData8bitsDirective();
61 << Asm->getCommentString()
70 /// BeginModule - Emit all dwarf sections that should come prior to the content.
72 void DwarfWriter::BeginModule() {
73 EmitComment("Dwarf Begin Module");
75 // define base addresses for dwarf sections
76 Asm->SwitchSection(DwarfAbbrevSection, 0);
77 EmitLabel("abbrev", 0);
78 Asm->SwitchSection(DwarfInfoSection, 0);
80 Asm->SwitchSection(DwarfLineSection, 0);
84 /// EndModule - Emit all dwarf sections that should come after the content.
86 void DwarfWriter::EndModule() {
87 EmitComment("Dwarf End Module");
88 // Print out dwarf file info
89 std::vector<std::string> Sources = DebugInfo.getSourceFiles();
90 for (unsigned i = 0, N = Sources.size(); i < N; i++) {
91 O << "\t; .file\t" << (i + 1) << "," << "\"" << Sources[i] << "\"" << "\n";
96 /// BeginFunction - Emit pre-function debug information.
98 void DwarfWriter::BeginFunction() {
99 EmitComment("Dwarf Begin Function");
102 /// EndFunction - Emit post-function debug information.
104 void DwarfWriter::EndFunction() {
105 EmitComment("Dwarf End Function");
109 } // End llvm namespace