xref: /freebsd/contrib/llvm-project/lldb/include/lldb/API/SBAddress.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric //===-- SBAddress.h ---------------------------------------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
95ffd83dbSDimitry Andric #ifndef LLDB_API_SBADDRESS_H
105ffd83dbSDimitry Andric #define LLDB_API_SBADDRESS_H
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric #include "lldb/API/SBDefines.h"
130b57cec5SDimitry Andric #include "lldb/API/SBModule.h"
140b57cec5SDimitry Andric 
150b57cec5SDimitry Andric namespace lldb {
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric class LLDB_API SBAddress {
180b57cec5SDimitry Andric public:
190b57cec5SDimitry Andric   SBAddress();
200b57cec5SDimitry Andric 
210b57cec5SDimitry Andric   SBAddress(const lldb::SBAddress &rhs);
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric   SBAddress(lldb::SBSection section, lldb::addr_t offset);
240b57cec5SDimitry Andric 
250b57cec5SDimitry Andric   // Create an address by resolving a load address using the supplied target
260b57cec5SDimitry Andric   SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target);
270b57cec5SDimitry Andric 
280b57cec5SDimitry Andric   ~SBAddress();
290b57cec5SDimitry Andric 
300b57cec5SDimitry Andric   const lldb::SBAddress &operator=(const lldb::SBAddress &rhs);
310b57cec5SDimitry Andric 
320b57cec5SDimitry Andric   explicit operator bool() const;
330b57cec5SDimitry Andric 
340b57cec5SDimitry Andric   // operator== is a free function
350b57cec5SDimitry Andric 
360b57cec5SDimitry Andric   bool operator!=(const SBAddress &rhs) const;
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric   bool IsValid() const;
390b57cec5SDimitry Andric 
400b57cec5SDimitry Andric   void Clear();
410b57cec5SDimitry Andric 
420b57cec5SDimitry Andric   addr_t GetFileAddress() const;
430b57cec5SDimitry Andric 
440b57cec5SDimitry Andric   addr_t GetLoadAddress(const lldb::SBTarget &target) const;
450b57cec5SDimitry Andric 
460b57cec5SDimitry Andric   void SetAddress(lldb::SBSection section, lldb::addr_t offset);
470b57cec5SDimitry Andric 
480b57cec5SDimitry Andric   void SetLoadAddress(lldb::addr_t load_addr, lldb::SBTarget &target);
490b57cec5SDimitry Andric   bool OffsetAddress(addr_t offset);
500b57cec5SDimitry Andric 
510b57cec5SDimitry Andric   bool GetDescription(lldb::SBStream &description);
520b57cec5SDimitry Andric 
530b57cec5SDimitry Andric   // The following queries can lookup symbol information for a given address.
540b57cec5SDimitry Andric   // An address might refer to code or data from an existing module, or it
550b57cec5SDimitry Andric   // might refer to something on the stack or heap. The following functions
560b57cec5SDimitry Andric   // will only return valid values if the address has been resolved to a code
570b57cec5SDimitry Andric   // or data address using "void SBAddress::SetLoadAddress(...)" or
580b57cec5SDimitry Andric   // "lldb::SBAddress SBTarget::ResolveLoadAddress (...)".
590b57cec5SDimitry Andric   lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope);
600b57cec5SDimitry Andric 
610b57cec5SDimitry Andric   // The following functions grab individual objects for a given address and
620b57cec5SDimitry Andric   // are less efficient if you want more than one symbol related objects. Use
630b57cec5SDimitry Andric   // one of the following when you want multiple debug symbol related objects
640b57cec5SDimitry Andric   // for an address:
650b57cec5SDimitry Andric   //    lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t
660b57cec5SDimitry Andric   //    resolve_scope);
670b57cec5SDimitry Andric   //    lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const
680b57cec5SDimitry Andric   //    SBAddress &addr, uint32_t resolve_scope);
690b57cec5SDimitry Andric   // One or more bits from the SymbolContextItem enumerations can be logically
700b57cec5SDimitry Andric   // OR'ed together to more efficiently retrieve multiple symbol objects.
710b57cec5SDimitry Andric 
720b57cec5SDimitry Andric   lldb::SBSection GetSection();
730b57cec5SDimitry Andric 
740b57cec5SDimitry Andric   lldb::addr_t GetOffset();
750b57cec5SDimitry Andric 
760b57cec5SDimitry Andric   lldb::SBModule GetModule();
770b57cec5SDimitry Andric 
780b57cec5SDimitry Andric   lldb::SBCompileUnit GetCompileUnit();
790b57cec5SDimitry Andric 
800b57cec5SDimitry Andric   lldb::SBFunction GetFunction();
810b57cec5SDimitry Andric 
820b57cec5SDimitry Andric   lldb::SBBlock GetBlock();
830b57cec5SDimitry Andric 
840b57cec5SDimitry Andric   lldb::SBSymbol GetSymbol();
850b57cec5SDimitry Andric 
860b57cec5SDimitry Andric   lldb::SBLineEntry GetLineEntry();
870b57cec5SDimitry Andric 
880b57cec5SDimitry Andric protected:
89*0fca6ea1SDimitry Andric   friend class SBAddressRange;
900b57cec5SDimitry Andric   friend class SBBlock;
910b57cec5SDimitry Andric   friend class SBBreakpoint;
920b57cec5SDimitry Andric   friend class SBBreakpointLocation;
930b57cec5SDimitry Andric   friend class SBFrame;
940b57cec5SDimitry Andric   friend class SBFunction;
950b57cec5SDimitry Andric   friend class SBLineEntry;
960b57cec5SDimitry Andric   friend class SBInstruction;
970b57cec5SDimitry Andric   friend class SBModule;
980b57cec5SDimitry Andric   friend class SBSection;
990b57cec5SDimitry Andric   friend class SBSymbol;
1000b57cec5SDimitry Andric   friend class SBSymbolContext;
1010b57cec5SDimitry Andric   friend class SBTarget;
1020b57cec5SDimitry Andric   friend class SBThread;
1030b57cec5SDimitry Andric   friend class SBThreadPlan;
1040b57cec5SDimitry Andric   friend class SBValue;
1050b57cec5SDimitry Andric   friend class SBQueueItem;
1060b57cec5SDimitry Andric 
1070b57cec5SDimitry Andric   lldb_private::Address *operator->();
1080b57cec5SDimitry Andric 
1090b57cec5SDimitry Andric   const lldb_private::Address *operator->() const;
1100b57cec5SDimitry Andric 
11106c3fb27SDimitry Andric #ifndef SWIG
1120b57cec5SDimitry Andric   friend bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs);
11306c3fb27SDimitry Andric #endif
1140b57cec5SDimitry Andric 
1150b57cec5SDimitry Andric   lldb_private::Address *get();
1160b57cec5SDimitry Andric 
1170b57cec5SDimitry Andric   lldb_private::Address &ref();
1180b57cec5SDimitry Andric 
1190b57cec5SDimitry Andric   const lldb_private::Address &ref() const;
1200b57cec5SDimitry Andric 
121e8d8bef9SDimitry Andric   SBAddress(const lldb_private::Address &address);
1220b57cec5SDimitry Andric 
123e8d8bef9SDimitry Andric   void SetAddress(const lldb_private::Address &address);
1240b57cec5SDimitry Andric 
1250b57cec5SDimitry Andric private:
1260b57cec5SDimitry Andric   std::unique_ptr<lldb_private::Address> m_opaque_up;
1270b57cec5SDimitry Andric };
1280b57cec5SDimitry Andric 
12906c3fb27SDimitry Andric #ifndef SWIG
1300b57cec5SDimitry Andric bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs);
13106c3fb27SDimitry Andric #endif
1320b57cec5SDimitry Andric 
1330b57cec5SDimitry Andric } // namespace lldb
1340b57cec5SDimitry Andric 
1355ffd83dbSDimitry Andric #endif // LLDB_API_SBADDRESS_H
136