1 //===- DWARFDebugLoc.h ------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H
12 #include "llvm/ADT/Optional.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/DebugInfo/DIContext.h"
15 #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
16 #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
26 /// A single location within a location list.
28 /// The beginning address of the instruction range.
30 /// The ending address of the instruction range.
32 /// The location of the variable within the specified range.
33 SmallVector
<uint8_t, 4> Loc
;
36 /// A list of locations that contain one variable.
38 /// The beginning offset where this location list is stored in the debug_loc
41 /// All the locations in which the variable is stored.
42 SmallVector
<Entry
, 2> Entries
;
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;
51 using LocationLists
= SmallVector
<LocationList
, 4>;
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
;
62 /// Print the location lists found within the debug_loc section.
63 void dump(raw_ostream
&OS
, const MCRegisterInfo
*RegInfo
, DIDumpOptions DumpOpts
,
64 Optional
<uint64_t> Offset
) const;
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
);
70 /// Return the location list at the given offset or nullptr.
71 LocationList
const *getLocationListAtOffset(uint64_t Offset
) const;
73 Expected
<LocationList
>
74 parseOneLocationList(const DWARFDataExtractor
&Data
, uint64_t *Offset
);
77 class DWARFDebugLoclists
{
84 SmallVector
<uint8_t, 4> Loc
;
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;
92 SmallVector
<Entry
, 2> Entries
;
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;
99 using LocationLists
= SmallVector
<LocationList
, 4>;
101 LocationLists Locations
;
103 unsigned AddressSize
;
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;
112 /// Return the location list at the given offset or nullptr.
113 LocationList
const *getLocationListAtOffset(uint64_t Offset
) const;
115 static Expected
<LocationList
> parseOneLocationList(const DataExtractor
&Data
,
120 } // end namespace llvm
122 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H