llvm-6502/include/llvm/CodeGen/DwarfWriter.h
Bill Wendling d751c64a67 If we have a function with an unreachable statement such that the ending debug
information is in an unreachable block, then it's possible that the high/low pc
values won't be set for the dwarf information. E.g., this function:

void abort(void) __attribute__((__noreturn__));
void dead_beef(void) __attribute__ ((noreturn));

int *b;

void dead_beef(void) {
  *b=0xdeadbeef;
  abort();
}

has a call to "@llvm.dbg.region.end" only in the unreachable block:

define void @dead_beef() noreturn nounwind  {
entry:
	call void @llvm.dbg.func.start(...)
	call void @llvm.dbg.stoppoint(...)
...
	call void @abort( ) noreturn nounwind 
	unreachable

return:		; No predecessors!
	call void @llvm.dbg.stoppoint(...)
	call void @llvm.dbg.region.end(...)
	ret void
}

The dwarf information emitted is something like:

0x00000084:     TAG_subprogram [5]  
                 AT_name( "dead_beef" )
                 AT_external( 0x01 )
                 AT_prototyped( 0x01 )
                 AT_decl_file( 0x01 )
                 AT_decl_line( 0x08 )

Note that this is *not* the best fix for this problem, but a band-aid for an
gaping wound. This code needs to be changed when we revamp our debugging
information.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56628 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 00:28:12 +00:00

84 lines
2.4 KiB
C++

//===-- llvm/CodeGen/DwarfWriter.h - Dwarf Framework ------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains support for writing Dwarf debug and exception info into
// asm files. For Details on the Dwarf 3 specfication see DWARF Debugging
// Information Format V.3 reference manual http://dwarf.freestandards.org ,
//
// The role of the Dwarf Writer class is to extract information from the
// MachineModuleInfo object, organize it in Dwarf form and then emit it into asm
// the current asm file using data and high level Dwarf directives.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CODEGEN_DWARFWRITER_H
#define LLVM_CODEGEN_DWARFWRITER_H
#include <iosfwd>
namespace llvm {
class AsmPrinter;
class DwarfDebug;
class DwarfException;
class MachineModuleInfo;
class MachineFunction;
class Module;
class TargetAsmInfo;
class raw_ostream;
//===----------------------------------------------------------------------===//
// DwarfWriter - Emits Dwarf debug and exception handling directives.
//
class DwarfWriter {
private:
/// DD - Provides the DwarfWriter debug implementation.
///
DwarfDebug *DD;
/// DE - Provides the DwarfWriter exception implementation.
///
DwarfException *DE;
public:
DwarfWriter(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T);
virtual ~DwarfWriter();
/// SetModuleInfo - Set machine module info when it's known that pass manager
/// has created it. Set by the target AsmPrinter.
void SetModuleInfo(MachineModuleInfo *MMI);
//===--------------------------------------------------------------------===//
// Main entry points.
//
/// BeginModule - Emit all Dwarf sections that should come prior to the
/// content.
void BeginModule(Module *M);
/// EndModule - Emit all Dwarf sections that should come after the content.
///
void EndModule();
/// BeginFunction - Gather pre-function debug information. Assumes being
/// emitted immediately after the function entry point.
void BeginFunction(MachineFunction *MF);
/// EndFunction - Gather and emit post-function debug information.
///
void EndFunction(MachineFunction *MF);
};
} // end llvm namespace
#endif