LLVM  4.0.0
DebugHandlerBase.h
Go to the documentation of this file.
1 //===-- llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h --------*- C++ -*--===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Common functionality for different debug information format backends.
11 // LLVM currently supports DWARF and CodeView.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DEBUGHANDLERBASE_H
16 #define LLVM_LIB_CODEGEN_ASMPRINTER_DEBUGHANDLERBASE_H
17 
18 #include "AsmPrinterHandler.h"
22 
23 namespace llvm {
24 
25 class AsmPrinter;
26 class MachineModuleInfo;
27 
28 /// Base class for debug information backends. Common functionality related to
29 /// tracking which variables and scopes are alive at a given PC live here.
31 protected:
33 
34  /// Target of debug info emission.
36 
37  /// Collected machine module information.
39 
40  /// Previous instruction's location information. This is used to
41  /// determine label location to indicate scope boundaries in debug info.
42  /// We track the previous instruction's source location (if not line 0),
43  /// whether it was a label, and its parent BB.
45  MCSymbol *PrevLabel = nullptr;
46  const MachineBasicBlock *PrevInstBB = nullptr;
47 
48  /// This location indicates end of function prologue and beginning of
49  /// function body.
51 
52  /// If nonnull, stores the current machine instruction we're processing.
53  const MachineInstr *CurMI = nullptr;
54 
56 
57  /// History of DBG_VALUE and clobber instructions for each user
58  /// variable. Variables are listed in order of appearance.
60 
61  /// Maps instruction with label emitted before instruction.
62  /// FIXME: Make this private from DwarfDebug, we have the necessary accessors
63  /// for it.
65 
66  /// Maps instruction with label emitted after instruction.
68 
69  /// Indentify instructions that are marking the beginning of or
70  /// ending of a scope.
71  void identifyScopeMarkers();
72 
73  /// Ensure that a label will be emitted before MI.
75  LabelsBeforeInsn.insert(std::make_pair(MI, nullptr));
76  }
77 
78  /// Ensure that a label will be emitted after MI.
80  LabelsAfterInsn.insert(std::make_pair(MI, nullptr));
81  }
82 
83  // AsmPrinterHandler overrides.
84 public:
85  void beginInstruction(const MachineInstr *MI) override;
86  void endInstruction() override;
87 
88  void beginFunction(const MachineFunction *MF) override;
89  void endFunction(const MachineFunction *MF) override;
90 
91  /// Return Label preceding the instruction.
93 
94  /// Return Label immediately following the instruction.
96 
97  /// Determine the relative position of the fragments described by P1 and P2.
98  /// Returns -1 if P1 is entirely before P2, 0 if P1 and P2 overlap, 1 if P1 is
99  /// entirely after P2.
100  static int fragmentCmp(const DIExpression *P1, const DIExpression *P2);
101 
102  /// Determine whether two variable fragments overlap.
103  static bool fragmentsOverlap(const DIExpression *P1, const DIExpression *P2);
104 
105  /// If this type is derived from a base type then return base type size.
106  static uint64_t getBaseTypeSize(const DITypeRef TyRef);
107 };
108 
109 }
110 
111 #endif
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
Collects and handles AsmPrinter objects required to build debug or EH information.
A debug info location.
Definition: DebugLoc.h:34
const MachineInstr * CurMI
If nonnull, stores the current machine instruction we're processing.
DebugLoc PrevInstLoc
Previous instruction's location information.
DbgValueHistoryMap DbgValues
History of DBG_VALUE and clobber instructions for each user variable.
void beginFunction(const MachineFunction *MF) override
Gather pre-function debug information.
Holds a subclass of DINode.
DebugHandlerBase(AsmPrinter *A)
void identifyScopeMarkers()
Indentify instructions that are marking the beginning of or ending of a scope.
DenseMap< const MachineInstr *, MCSymbol * > LabelsAfterInsn
Maps instruction with label emitted after instruction.
void requestLabelBeforeInsn(const MachineInstr *MI)
Ensure that a label will be emitted before MI.
static bool fragmentsOverlap(const DIExpression *P1, const DIExpression *P2)
Determine whether two variable fragments overlap.
const MachineBasicBlock * PrevInstBB
AsmPrinter * Asm
Target of debug info emission.
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:67
DenseMap< const MachineInstr *, MCSymbol * > LabelsBeforeInsn
Maps instruction with label emitted before instruction.
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
void endFunction(const MachineFunction *MF) override
Gather post-function debug information.
MCSymbol * getLabelAfterInsn(const MachineInstr *MI)
Return Label immediately following the instruction.
DWARF expression.
DebugLoc PrologEndLoc
This location indicates end of function prologue and beginning of function body.
void requestLabelAfterInsn(const MachineInstr *MI)
Ensure that a label will be emitted after MI.
Representation of each machine instruction.
Definition: MachineInstr.h:52
LexicalScopes - This class provides interface to collect and use lexical scoping information from mac...
Base class for debug information backends.
void endInstruction() override
Process end of an instruction.
MCSymbol * getLabelBeforeInsn(const MachineInstr *MI)
Return Label preceding the instruction.
static int fragmentCmp(const DIExpression *P1, const DIExpression *P2)
Determine the relative position of the fragments described by P1 and P2.
MachineModuleInfo * MMI
Collected machine module information.
static uint64_t getBaseTypeSize(const DITypeRef TyRef)
If this type is derived from a base type then return base type size.
IRTranslator LLVM IR MI
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
This class contains meta information specific to a module.