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/DWARF/DWARFDataExtractor.h"
15 #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
25 /// A single location within a location list.
27 /// The beginning address of the instruction range.
29 /// The ending address of the instruction range.
31 /// The location of the variable within the specified range.
32 SmallVector
<uint8_t, 4> Loc
;
35 /// A list of locations that contain one variable.
37 /// The beginning offset where this location list is stored in the debug_loc
40 /// All the locations in which the variable is stored.
41 SmallVector
<Entry
, 2> Entries
;
42 /// Dump this list on OS.
43 void dump(raw_ostream
&OS
, uint64_t BaseAddress
, bool IsLittleEndian
,
44 unsigned AddressSize
, const MCRegisterInfo
*MRI
, DWARFUnit
*U
,
45 unsigned Indent
) const;
49 using LocationLists
= SmallVector
<LocationList
, 4>;
51 /// A list of all the variables in the debug_loc section, each one describing
52 /// the locations in which the variable is stored.
53 LocationLists Locations
;
60 /// Print the location lists found within the debug_loc section.
61 void dump(raw_ostream
&OS
, const MCRegisterInfo
*RegInfo
,
62 Optional
<uint64_t> Offset
) const;
64 /// Parse the debug_loc section accessible via the 'data' parameter using the
65 /// address size also given in 'data' to interpret the address ranges.
66 void parse(const DWARFDataExtractor
&data
);
68 /// Return the location list at the given offset or nullptr.
69 LocationList
const *getLocationListAtOffset(uint64_t Offset
) const;
71 static Expected
<LocationList
>
72 parseOneLocationList(const DWARFDataExtractor
&Data
, uint64_t *Offset
);
75 class DWARFDebugLoclists
{
81 SmallVector
<uint8_t, 4> Loc
;
86 SmallVector
<Entry
, 2> Entries
;
87 void dump(raw_ostream
&OS
, uint64_t BaseAddr
, bool IsLittleEndian
,
88 unsigned AddressSize
, const MCRegisterInfo
*RegInfo
,
89 DWARFUnit
*U
, unsigned Indent
) const;
93 using LocationLists
= SmallVector
<LocationList
, 4>;
95 LocationLists Locations
;
102 void parse(DataExtractor data
, unsigned Version
);
103 void dump(raw_ostream
&OS
, uint64_t BaseAddr
, const MCRegisterInfo
*RegInfo
,
104 Optional
<uint64_t> Offset
) const;
106 /// Return the location list at the given offset or nullptr.
107 LocationList
const *getLocationListAtOffset(uint64_t Offset
) const;
109 static Expected
<LocationList
> parseOneLocationList(const DataExtractor
&Data
,
114 } // end namespace llvm
116 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H