1 //===-- SBAddress.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_API_SBADDRESS_H 10 #define LLDB_API_SBADDRESS_H 11 12 #include "lldb/API/SBDefines.h" 13 #include "lldb/API/SBModule.h" 14 15 namespace lldb { 16 17 class LLDB_API SBAddress { 18 public: 19 SBAddress(); 20 21 SBAddress(const lldb::SBAddress &rhs); 22 23 SBAddress(lldb::SBSection section, lldb::addr_t offset); 24 25 // Create an address by resolving a load address using the supplied target 26 SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target); 27 28 ~SBAddress(); 29 30 const lldb::SBAddress &operator=(const lldb::SBAddress &rhs); 31 32 explicit operator bool() const; 33 34 // operator== is a free function 35 36 bool operator!=(const SBAddress &rhs) const; 37 38 bool IsValid() const; 39 40 void Clear(); 41 42 addr_t GetFileAddress() const; 43 44 addr_t GetLoadAddress(const lldb::SBTarget &target) const; 45 46 void SetAddress(lldb::SBSection section, lldb::addr_t offset); 47 48 void SetLoadAddress(lldb::addr_t load_addr, lldb::SBTarget &target); 49 bool OffsetAddress(addr_t offset); 50 51 bool GetDescription(lldb::SBStream &description); 52 53 // The following queries can lookup symbol information for a given address. 54 // An address might refer to code or data from an existing module, or it 55 // might refer to something on the stack or heap. The following functions 56 // will only return valid values if the address has been resolved to a code 57 // or data address using "void SBAddress::SetLoadAddress(...)" or 58 // "lldb::SBAddress SBTarget::ResolveLoadAddress (...)". 59 lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope); 60 61 // The following functions grab individual objects for a given address and 62 // are less efficient if you want more than one symbol related objects. Use 63 // one of the following when you want multiple debug symbol related objects 64 // for an address: 65 // lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t 66 // resolve_scope); 67 // lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const 68 // SBAddress &addr, uint32_t resolve_scope); 69 // One or more bits from the SymbolContextItem enumerations can be logically 70 // OR'ed together to more efficiently retrieve multiple symbol objects. 71 72 lldb::SBSection GetSection(); 73 74 lldb::addr_t GetOffset(); 75 76 lldb::SBModule GetModule(); 77 78 lldb::SBCompileUnit GetCompileUnit(); 79 80 lldb::SBFunction GetFunction(); 81 82 lldb::SBBlock GetBlock(); 83 84 lldb::SBSymbol GetSymbol(); 85 86 lldb::SBLineEntry GetLineEntry(); 87 88 protected: 89 friend class SBBlock; 90 friend class SBBreakpoint; 91 friend class SBBreakpointLocation; 92 friend class SBFrame; 93 friend class SBFunction; 94 friend class SBLineEntry; 95 friend class SBInstruction; 96 friend class SBModule; 97 friend class SBSection; 98 friend class SBSymbol; 99 friend class SBSymbolContext; 100 friend class SBTarget; 101 friend class SBThread; 102 friend class SBThreadPlan; 103 friend class SBValue; 104 friend class SBQueueItem; 105 106 lldb_private::Address *operator->(); 107 108 const lldb_private::Address *operator->() const; 109 110 #ifndef SWIG 111 friend bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs); 112 #endif 113 114 lldb_private::Address *get(); 115 116 lldb_private::Address &ref(); 117 118 const lldb_private::Address &ref() const; 119 120 SBAddress(const lldb_private::Address &address); 121 122 void SetAddress(const lldb_private::Address &address); 123 124 private: 125 std::unique_ptr<lldb_private::Address> m_opaque_up; 126 }; 127 128 #ifndef SWIG 129 bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs); 130 #endif 131 132 } // namespace lldb 133 134 #endif // LLDB_API_SBADDRESS_H 135