LLVM  10.0.0svn
DWARFDebugLoc.h
Go to the documentation of this file.
1 //===- DWARFDebugLoc.h ------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H
11 
12 #include "llvm/ADT/Optional.h"
13 #include "llvm/ADT/SmallVector.h"
17 #include <cstdint>
18 
19 namespace llvm {
20 class DWARFUnit;
21 class MCRegisterInfo;
22 class raw_ostream;
23 
25 public:
26  /// A single location within a location list.
27  struct Entry {
28  /// The beginning address of the instruction range.
29  uint64_t Begin;
30  /// The ending address of the instruction range.
31  uint64_t End;
32  /// The location of the variable within the specified range.
34  };
35 
36  /// A list of locations that contain one variable.
37  struct LocationList {
38  /// The beginning offset where this location list is stored in the debug_loc
39  /// section.
40  uint64_t Offset;
41  /// All the locations in which the variable is stored.
43  /// Dump this list on OS.
44  void dump(raw_ostream &OS, uint64_t BaseAddress, bool IsLittleEndian,
45  unsigned AddressSize, const MCRegisterInfo *MRI, DWARFUnit *U,
46  DIDumpOptions DumpOpts,
47  unsigned Indent) const;
48  };
49 
50 private:
52 
53  /// A list of all the variables in the debug_loc section, each one describing
54  /// the locations in which the variable is stored.
55  LocationLists Locations;
56 
57  unsigned AddressSize;
58 
59  bool IsLittleEndian;
60 
61 public:
62  /// Print the location lists found within the debug_loc section.
63  void dump(raw_ostream &OS, const MCRegisterInfo *RegInfo, DIDumpOptions DumpOpts,
65 
66  /// Parse the debug_loc section accessible via the 'data' parameter using the
67  /// address size also given in 'data' to interpret the address ranges.
68  void parse(const DWARFDataExtractor &data);
69 
70  /// Return the location list at the given offset or nullptr.
71  LocationList const *getLocationListAtOffset(uint64_t Offset) const;
72 
75 };
76 
78 public:
79  struct Entry {
80  uint8_t Kind;
81  uint64_t Offset;
82  uint64_t Value0;
83  uint64_t Value1;
85  void dump(raw_ostream &OS, uint64_t &BaseAddr, bool IsLittleEndian,
86  unsigned AddressSize, const MCRegisterInfo *MRI, DWARFUnit *U,
87  DIDumpOptions DumpOpts, unsigned Indent, size_t MaxEncodingStringLength) const;
88  };
89 
90  struct LocationList {
91  uint64_t Offset;
93  void dump(raw_ostream &OS, uint64_t BaseAddr, bool IsLittleEndian,
94  unsigned AddressSize, const MCRegisterInfo *RegInfo,
95  DWARFUnit *U, DIDumpOptions DumpOpts, unsigned Indent) const;
96  };
97 
98 private:
100 
101  LocationLists Locations;
102 
103  unsigned AddressSize;
104 
105  bool IsLittleEndian;
106 
107 public:
108  void parse(DataExtractor data, uint64_t Offset, uint64_t EndOffset, uint16_t Version);
109  void dump(raw_ostream &OS, uint64_t BaseAddr, const MCRegisterInfo *RegInfo,
110  DIDumpOptions DumpOpts, Optional<uint64_t> Offset) const;
111 
112  /// Return the location list at the given offset or nullptr.
113  LocationList const *getLocationListAtOffset(uint64_t Offset) const;
114 
116  uint64_t *Offset,
117  unsigned Version);
118 };
119 
120 } // end namespace llvm
121 
122 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H
A list of locations that contain one variable.
Definition: DWARFDebugLoc.h:37
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A single location within a location list.
Definition: DWARFDebugLoc.h:27
Tagged union holding either a T or a Error.
Definition: yaml2obj.h:21
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Container for dump options that control which debug information will be dumped.
Definition: DIContext.h:171
unsigned const MachineRegisterInfo * MRI
LocationList const * getLocationListAtOffset(uint64_t Offset) const
Return the location list at the given offset or nullptr.
Expected< LocationList > parseOneLocationList(const DWARFDataExtractor &Data, uint64_t *Offset)
SmallVector< uint8_t, 4 > Loc
Definition: DWARFDebugLoc.h:84
void dump(raw_ostream &OS, const MCRegisterInfo *RegInfo, DIDumpOptions DumpOpts, Optional< uint64_t > Offset) const
Print the location lists found within the debug_loc section.
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
uint64_t Begin
The beginning address of the instruction range.
Definition: DWARFDebugLoc.h:29
SmallVector< uint8_t, 4 > Loc
The location of the variable within the specified range.
Definition: DWARFDebugLoc.h:33
uint64_t Offset
The beginning offset where this location list is stored in the debug_loc section. ...
Definition: DWARFDebugLoc.h:40
uint64_t End
The ending address of the instruction range.
Definition: DWARFDebugLoc.h:31
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
SmallVector< Entry, 2 > Entries
All the locations in which the variable is stored.
Definition: DWARFDebugLoc.h:42
const uint64_t Version
Definition: InstrProf.h:980
void parse(const DWARFDataExtractor &data)
Parse the debug_loc section accessible via the &#39;data&#39; parameter using the address size also given in ...