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
12#include "lldb/Core/Value.h"
15#include "lldb/lldb-private.h"
16
17namespace lldb_private {
18
19namespace plugin {
20namespace dwarf {
21class DWARFUnit;
22} // namespace dwarf
23} // namespace plugin
24
25/// \class DWARFExpressionList DWARFExpressionList.h
26/// "lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file
27/// address range to a single DWARF location expression.
29public:
31
33 const plugin::dwarf::DWARFUnit *dwarf_cu,
34 lldb::addr_t func_file_addr)
35 : m_module_wp(module_sp), m_dwarf_cu(dwarf_cu),
36 m_func_file_addr(func_file_addr) {}
37
39 const plugin::dwarf::DWARFUnit *dwarf_cu)
40 : m_module_wp(module_sp), m_dwarf_cu(dwarf_cu) {
42 }
43
44 /// Return true if the location expression contains data
45 bool IsValid() const { return !m_exprs.IsEmpty(); }
46
47 void Clear() { m_exprs.Clear(); }
48
49 // Return true if the location expression is always valid.
50 bool IsAlwaysValidSingleExpr() const;
51
53
54 /// Get the expression data at the file address.
56 lldb::addr_t func_load_addr = LLDB_INVALID_ADDRESS,
57 lldb::addr_t file_addr = 0) const;
58
59 /// Sort m_expressions.
60 void Sort() { m_exprs.Sort(); }
61
62 void SetFuncFileAddress(lldb::addr_t func_file_addr) {
63 m_func_file_addr = func_file_addr;
64 }
65
67
69 lldb::addr_t load_addr) const;
70
72
74 lldb::addr_t func_load_addr = LLDB_INVALID_ADDRESS,
75 lldb::addr_t load_addr = 0);
76
77 size_t GetSize() const { return m_exprs.GetSize(); }
78
79 bool ContainsThreadLocalStorage() const;
80
82 lldb::ModuleSP new_module_sp,
83 std::function<lldb::addr_t(lldb::addr_t file_addr)> const
84 &link_address_callback);
85
86 bool MatchesOperand(StackFrame &frame,
87 const Instruction::Operand &operand) const;
88
89 /// Dump locations that contains file_addr if it's valid. Otherwise. dump all
90 /// locations.
92 lldb::addr_t func_load_addr, lldb::addr_t file_addr,
93 ABI *abi) const;
94
95 /// Dump all locaitons with each separated by new line.
96 void GetDescription(Stream *s, lldb::DescriptionLevel level, ABI *abi) const;
97
98 /// Search for a load address in the dwarf location list
99 ///
100 /// \param[in] func_load_addr
101 /// The actual address of the function containing this location list.
102 ///
103 /// \param[in] addr
104 /// The address to resolve.
105 ///
106 /// \return
107 /// True if IsLocationList() is true and the address was found;
108 /// false otherwise.
109 // bool
110 // LocationListContainsLoadAddress (Process* process, const Address &addr)
111 // const;
112 //
113 bool ContainsAddress(lldb::addr_t func_load_addr, lldb::addr_t addr) const;
114
115 void SetModule(const lldb::ModuleSP &module) { m_module_wp = module; }
116
117 llvm::Expected<Value> Evaluate(ExecutionContext *exe_ctx,
118 RegisterContext *reg_ctx,
119 lldb::addr_t func_load_addr,
120 const Value *initial_value_ptr,
121 const Value *object_address_ptr) const;
122
123private:
124 // RangeDataVector requires a comparator for DWARFExpression, but it doesn't
125 // make sense to do so.
127 public:
129 const DWARFExpression &rhs) const {
130 return false;
131 }
132 };
136
137 // File address range mapping to single dwarf expression.
139
140 /// Module which defined this expression.
142
143 /// The DWARF compile unit this expression belongs to. It is used to evaluate
144 /// values indexing into the .debug_addr section (e.g. DW_OP_GNU_addr_index,
145 /// DW_OP_GNU_const_index)
147
148 // Function base file address.
150
152 const_iterator begin() const { return m_exprs.begin(); }
153 const_iterator end() const { return m_exprs.end(); }
154};
155} // namespace lldb_private
156
157#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)
DWARFExpressionList(lldb::ModuleSP module_sp, const plugin::dwarf::DWARFUnit *dwarf_cu, lldb::addr_t func_file_addr)
const DWARFExpression * GetExpressionAtAddress(lldb::addr_t func_load_addr, lldb::addr_t load_addr) const
DWARFExpressionList(lldb::ModuleSP module_sp, DWARFExpression expr, const plugin::dwarf::DWARFUnit *dwarf_cu)
void GetDescription(Stream *s, lldb::DescriptionLevel level, ABI *abi) const
Dump all locaitons with each separated by new line.
bool MatchesOperand(StackFrame &frame, const Instruction::Operand &operand) const
llvm::Expected< Value > Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::addr_t func_load_addr, const Value *initial_value_ptr, const Value *object_address_ptr) const
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)
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)
const plugin::dwarf::DWARFUnit * m_dwarf_cu
The DWARF compile unit this expression belongs to.
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
"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:43
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:82
A class that represents a running process on the host machine.
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::weak_ptr< lldb_private::Module > ModuleWP
Definition: lldb-forward.h:372
uint64_t addr_t
Definition: lldb-types.h:80
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:371
bool operator()(const DWARFExpression &lhs, const DWARFExpression &rhs) const