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