LLDB mainline
DWARFExpressionList.h
Go to the documentation of this file.
1//===-- DWARFExpressionList.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 LLDB_EXPRESSION_DWARFEXPRESSIONLIST_H
10#define LLDB_EXPRESSION_DWARFEXPRESSIONLIST_H
11
14#include "lldb/lldb-private.h"
15
16class DWARFUnit;
17
18namespace lldb_private {
19
20/// \class DWARFExpressionList DWARFExpressionList.h
21/// "lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file
22/// address range to a single DWARF location expression.
24public:
26
27 DWARFExpressionList(lldb::ModuleSP module_sp, const DWARFUnit *dwarf_cu,
28 lldb::addr_t func_file_addr)
29 : m_module_wp(module_sp), m_dwarf_cu(dwarf_cu),
30 m_func_file_addr(func_file_addr) {}
31
32 DWARFExpressionList(lldb::ModuleSP module_sp, DWARFExpression expr,
33 const DWARFUnit *dwarf_cu)
34 : m_module_wp(module_sp), m_dwarf_cu(dwarf_cu) {
36 }
37
38 /// Return true if the location expression contains data
39 bool IsValid() const { return !m_exprs.IsEmpty(); }
40
41 void Clear() { m_exprs.Clear(); }
42
43 // Return true if the location expression is always valid.
44 bool IsAlwaysValidSingleExpr() const;
45
47
48 /// Get the expression data at the file address.
50 lldb::addr_t func_load_addr = LLDB_INVALID_ADDRESS,
51 lldb::addr_t file_addr = 0) const;
52
53 /// Sort m_expressions.
54 void Sort() { m_exprs.Sort(); }
55
56 void SetFuncFileAddress(lldb::addr_t func_file_addr) {
57 m_func_file_addr = func_file_addr;
58 }
59
61
63 lldb::addr_t load_addr) const;
64
66
68 lldb::addr_t func_load_addr = LLDB_INVALID_ADDRESS,
69 lldb::addr_t load_addr = 0);
70
71 size_t GetSize() const { return m_exprs.GetSize(); }
72
73 bool ContainsThreadLocalStorage() const;
74
76 lldb::ModuleSP new_module_sp,
77 std::function<lldb::addr_t(lldb::addr_t file_addr)> const
78 &link_address_callback);
79
80 bool MatchesOperand(StackFrame &frame,
81 const Instruction::Operand &operand) const;
82
83 /// Dump locations that contains file_addr if it's valid. Otherwise. dump all
84 /// locations.
86 lldb::addr_t func_load_addr, lldb::addr_t file_addr,
87 ABI *abi) const;
88
89 /// Dump all locaitons with each seperated by new line.
90 void GetDescription(Stream *s, lldb::DescriptionLevel level, ABI *abi) const;
91
92 /// Search for a load address in the dwarf location list
93 ///
94 /// \param[in] func_load_addr
95 /// The actual address of the function containing this location list.
96 ///
97 /// \param[in] addr
98 /// The address to resolve.
99 ///
100 /// \return
101 /// True if IsLocationList() is true and the address was found;
102 /// false otherwise.
103 // bool
104 // LocationListContainsLoadAddress (Process* process, const Address &addr)
105 // const;
106 //
107 bool ContainsAddress(lldb::addr_t func_load_addr, lldb::addr_t addr) const;
108
109 void SetModule(const lldb::ModuleSP &module) { m_module_wp = module; }
110
111 bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
112 lldb::addr_t func_load_addr, const Value *initial_value_ptr,
113 const Value *object_address_ptr, Value &result,
114 Status *error_ptr) const;
115
116private:
117 // RangeDataVector requires a comparator for DWARFExpression, but it doesn't
118 // make sense to do so.
120 public:
122 const DWARFExpression &rhs) const {
123 return false;
124 }
125 };
129
130 // File address range mapping to single dwarf expression.
132
133 /// Module which defined this expression.
134 lldb::ModuleWP m_module_wp;
135
136 /// The DWARF compile unit this expression belongs to. It is used to evaluate
137 /// values indexing into the .debug_addr section (e.g. DW_OP_GNU_addr_index,
138 /// DW_OP_GNU_const_index)
139 const DWARFUnit *m_dwarf_cu = nullptr;
140
141 // Function base file address.
143
145 const_iterator begin() const { return m_exprs.begin(); }
146 const_iterator end() const { return m_exprs.end(); }
147};
148} // namespace lldb_private
149
150#endif // LLDB_EXPRESSION_DWARFEXPRESSIONLIST_H
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
bool AddExpression(lldb::addr_t base, lldb::addr_t end, DWARFExpression expr)
const DWARFExpression * GetExpressionAtAddress(lldb::addr_t func_load_addr, lldb::addr_t load_addr) const
bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::addr_t func_load_addr, const Value *initial_value_ptr, const Value *object_address_ptr, Value &result, Status *error_ptr) const
void GetDescription(Stream *s, lldb::DescriptionLevel level, ABI *abi) const
Dump all locaitons with each seperated by new line.
bool MatchesOperand(StackFrame &frame, const Instruction::Operand &operand) const
DWARFExpressionList(lldb::ModuleSP module_sp, DWARFExpression expr, const DWARFUnit *dwarf_cu)
const DWARFExpression * GetAlwaysValidExpr() const
lldb::ModuleWP m_module_wp
Module which defined this expression.
void Sort()
Sort m_expressions.
bool GetExpressionData(DataExtractor &data, lldb::addr_t func_load_addr=LLDB_INVALID_ADDRESS, lldb::addr_t file_addr=0) const
Get the expression data at the file address.
void SetModule(const lldb::ModuleSP &module)
bool IsValid() const
Return true if the location expression contains data.
void SetFuncFileAddress(lldb::addr_t func_file_addr)
const DWARFUnit * m_dwarf_cu
The DWARF compile unit this expression belongs to.
bool DumpLocations(Stream *s, lldb::DescriptionLevel level, lldb::addr_t func_load_addr, lldb::addr_t file_addr, ABI *abi) const
Dump locations that contains file_addr if it's valid.
bool LinkThreadLocalStorage(lldb::ModuleSP new_module_sp, std::function< lldb::addr_t(lldb::addr_t file_addr)> const &link_address_callback)
bool ContainsAddress(lldb::addr_t func_load_addr, lldb::addr_t addr) const
Search for a load address in the dwarf location list.
DWARFExpression * GetMutableExpressionAtAddress(lldb::addr_t func_load_addr=LLDB_INVALID_ADDRESS, lldb::addr_t load_addr=0)
ExprVec::Collection::const_iterator const_iterator
DWARFExpressionList(lldb::ModuleSP module_sp, const DWARFUnit *dwarf_cu, lldb::addr_t func_file_addr)
"lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location expression and interprets it.
An data extractor class.
Definition: DataExtractor.h:48
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const_iterator end() const
Definition: RangeMap.h:654
const_iterator begin() const
Definition: RangeMap.h:653
This base class provides an interface to stack frames.
Definition: StackFrame.h:41
An error handling class.
Definition: Status.h:44
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
uint64_t addr_t
Definition: lldb-types.h:79
bool operator()(const DWARFExpression &lhs, const DWARFExpression &rhs) const