File indexing completed on 2026-05-10 08:42:47
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_EXPRESSION_DWARFEXPRESSIONLIST_H
0010 #define LLDB_EXPRESSION_DWARFEXPRESSIONLIST_H
0011
0012 #include "lldb/Core/Value.h"
0013 #include "lldb/Expression/DWARFExpression.h"
0014 #include "lldb/Utility/RangeMap.h"
0015 #include "lldb/lldb-private.h"
0016
0017 namespace lldb_private {
0018
0019 namespace plugin {
0020 namespace dwarf {
0021 class DWARFUnit;
0022 }
0023 }
0024
0025
0026
0027
0028 class DWARFExpressionList {
0029 public:
0030 DWARFExpressionList() = default;
0031
0032 DWARFExpressionList(lldb::ModuleSP module_sp,
0033 const plugin::dwarf::DWARFUnit *dwarf_cu,
0034 lldb::addr_t func_file_addr)
0035 : m_module_wp(module_sp), m_dwarf_cu(dwarf_cu),
0036 m_func_file_addr(func_file_addr) {}
0037
0038 DWARFExpressionList(lldb::ModuleSP module_sp, DWARFExpression expr,
0039 const plugin::dwarf::DWARFUnit *dwarf_cu)
0040 : m_module_wp(module_sp), m_dwarf_cu(dwarf_cu) {
0041 AddExpression(0, LLDB_INVALID_ADDRESS, expr);
0042 }
0043
0044
0045 bool IsValid() const { return !m_exprs.IsEmpty(); }
0046
0047 void Clear() { m_exprs.Clear(); }
0048
0049
0050 bool IsAlwaysValidSingleExpr() const;
0051
0052 bool AddExpression(lldb::addr_t base, lldb::addr_t end, DWARFExpression expr);
0053
0054
0055 bool GetExpressionData(DataExtractor &data,
0056 lldb::addr_t func_load_addr = LLDB_INVALID_ADDRESS,
0057 lldb::addr_t file_addr = 0) const;
0058
0059
0060 void Sort() { m_exprs.Sort(); }
0061
0062 void SetFuncFileAddress(lldb::addr_t func_file_addr) {
0063 m_func_file_addr = func_file_addr;
0064 }
0065
0066 lldb::addr_t GetFuncFileAddress() { return m_func_file_addr; }
0067
0068 const DWARFExpression *GetExpressionAtAddress(lldb::addr_t func_load_addr,
0069 lldb::addr_t load_addr) const;
0070
0071 const DWARFExpression *GetAlwaysValidExpr() const;
0072
0073 DWARFExpression *GetMutableExpressionAtAddress(
0074 lldb::addr_t func_load_addr = LLDB_INVALID_ADDRESS,
0075 lldb::addr_t load_addr = 0);
0076
0077 size_t GetSize() const { return m_exprs.GetSize(); }
0078
0079 bool ContainsThreadLocalStorage() const;
0080
0081 bool LinkThreadLocalStorage(
0082 lldb::ModuleSP new_module_sp,
0083 std::function<lldb::addr_t(lldb::addr_t file_addr)> const
0084 &link_address_callback);
0085
0086 bool MatchesOperand(StackFrame &frame,
0087 const Instruction::Operand &operand) const;
0088
0089
0090
0091 bool DumpLocations(Stream *s, lldb::DescriptionLevel level,
0092 lldb::addr_t func_load_addr, lldb::addr_t file_addr,
0093 ABI *abi) const;
0094
0095
0096 void GetDescription(Stream *s, lldb::DescriptionLevel level, ABI *abi) const;
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113 bool ContainsAddress(lldb::addr_t func_load_addr, lldb::addr_t addr) const;
0114
0115 void SetModule(const lldb::ModuleSP &module) { m_module_wp = module; }
0116
0117 llvm::Expected<Value> Evaluate(ExecutionContext *exe_ctx,
0118 RegisterContext *reg_ctx,
0119 lldb::addr_t func_load_addr,
0120 const Value *initial_value_ptr,
0121 const Value *object_address_ptr) const;
0122
0123 private:
0124
0125
0126 struct DWARFExpressionCompare {
0127 public:
0128 bool operator()(const DWARFExpression &lhs,
0129 const DWARFExpression &rhs) const {
0130 return false;
0131 }
0132 };
0133 using ExprVec = RangeDataVector<lldb::addr_t, lldb::addr_t, DWARFExpression,
0134 0, DWARFExpressionCompare>;
0135 using Entry = ExprVec::Entry;
0136
0137
0138 ExprVec m_exprs;
0139
0140
0141 lldb::ModuleWP m_module_wp;
0142
0143
0144
0145
0146 const plugin::dwarf::DWARFUnit *m_dwarf_cu = nullptr;
0147
0148
0149 lldb::addr_t m_func_file_addr = LLDB_INVALID_ADDRESS;
0150
0151 using const_iterator = ExprVec::Collection::const_iterator;
0152 const_iterator begin() const { return m_exprs.begin(); }
0153 const_iterator end() const { return m_exprs.end(); }
0154 };
0155 }
0156
0157 #endif