1 //===-- SBAddress.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 LLDB_SBAddress_h_
10 #define LLDB_SBAddress_h_
12 #include "lldb/API/SBDefines.h"
13 #include "lldb/API/SBModule.h"
17 class LLDB_API SBAddress {
21 SBAddress(const lldb::SBAddress &rhs);
23 SBAddress(lldb::SBSection section, lldb::addr_t offset);
25 // Create an address by resolving a load address using the supplied target
26 SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target);
30 const lldb::SBAddress &operator=(const lldb::SBAddress &rhs);
32 explicit operator bool() const;
34 // operator== is a free function
36 bool operator!=(const SBAddress &rhs) const;
42 addr_t GetFileAddress() const;
44 addr_t GetLoadAddress(const lldb::SBTarget &target) const;
46 void SetAddress(lldb::SBSection section, lldb::addr_t offset);
48 void SetLoadAddress(lldb::addr_t load_addr, lldb::SBTarget &target);
49 bool OffsetAddress(addr_t offset);
51 bool GetDescription(lldb::SBStream &description);
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);
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
65 // lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t
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.
72 lldb::SBSection GetSection();
74 lldb::addr_t GetOffset();
76 lldb::SBModule GetModule();
78 lldb::SBCompileUnit GetCompileUnit();
80 lldb::SBFunction GetFunction();
82 lldb::SBBlock GetBlock();
84 lldb::SBSymbol GetSymbol();
86 lldb::SBLineEntry GetLineEntry();
90 friend class SBBreakpoint;
91 friend class SBBreakpointLocation;
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;
106 lldb_private::Address *operator->();
108 const lldb_private::Address *operator->() const;
110 friend bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs);
112 lldb_private::Address *get();
114 lldb_private::Address &ref();
116 const lldb_private::Address &ref() const;
118 SBAddress(const lldb_private::Address *lldb_object_ptr);
120 void SetAddress(const lldb_private::Address *lldb_object_ptr);
123 std::unique_ptr<lldb_private::Address> m_opaque_up;
126 bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs);
130 #endif // LLDB_SBAddress_h_