blob: 7d3e36c66fd4fb8a9ac0d6f65a0c2657add0c5ea [file] [log] [blame]
Johnny Chen5de6a792011-07-18 21:30:21 +00001//===-- SWIG Interface for SBAddress ----------------------------*- 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
10namespace lldb {
11
12%feature("docstring",
13"A section + offset based address class.
14
15The SBAddress class allows addresses to be relative to a section
16that can move during runtime due to images (executables, shared
17libraries, bundles, frameworks) being loaded at different
18addresses than the addresses found in the object file that
19represents them on disk. There are currently two types of addresses
20for a section:
21 o file addresses
22 o load addresses
23
24File addresses represents the virtual addresses that are in the 'on
25disk' object files. These virtual addresses are converted to be
26relative to unique sections scoped to the object file so that
27when/if the addresses slide when the images are loaded/unloaded
28in memory, we can easily track these changes without having to
29update every object (compile unit ranges, line tables, function
30address ranges, lexical block and inlined subroutine address
31ranges, global and static variables) each time an image is loaded or
32unloaded.
33
34Load addresses represents the virtual addresses where each section
35ends up getting loaded at runtime. Before executing a program, it
36is common for all of the load addresses to be unresolved. When a
37DynamicLoader plug-in receives notification that shared libraries
38have been loaded/unloaded, the load addresses of the main executable
39and any images (shared libraries) will be resolved/unresolved. When
40this happens, breakpoints that are in one of these sections can be
41set/cleared.
42
43See docstring of SBFunction for example usage of SBAddress."
44) SBAddress;
45class SBAddress
46{
47public:
48
49 SBAddress ();
50
51 SBAddress (const lldb::SBAddress &rhs);
52
Greg Clayton819134a2012-02-04 02:58:17 +000053 SBAddress (lldb::SBSection section,
54 lldb::addr_t offset);
55
Johnny Chen33c0c772011-07-26 23:42:01 +000056 %feature("docstring", "
57 Create an address by resolving a load address using the supplied target.
58 ") SBAddress;
Greg Clayton00e6fbf2011-07-22 16:46:35 +000059 SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);
60
Johnny Chen5de6a792011-07-18 21:30:21 +000061 ~SBAddress ();
62
63 bool
64 IsValid () const;
65
66 void
67 Clear ();
68
69 addr_t
70 GetFileAddress () const;
71
72 addr_t
73 GetLoadAddress (const lldb::SBTarget &target) const;
74
Johnny Chen33c0c772011-07-26 23:42:01 +000075 void
76 SetLoadAddress (lldb::addr_t load_addr,
77 lldb::SBTarget &target);
Greg Clayton00e6fbf2011-07-22 16:46:35 +000078
Johnny Chen5de6a792011-07-18 21:30:21 +000079 bool
80 OffsetAddress (addr_t offset);
81
82 bool
83 GetDescription (lldb::SBStream &description);
84
Greg Claytoncac9c5f2011-09-24 00:52:29 +000085 lldb::SBSection
86 GetSection ();
Johnny Chen5de6a792011-07-18 21:30:21 +000087
Greg Clayton13d19502012-01-29 06:07:39 +000088 lldb::addr_t
89 SBAddress::GetOffset ();
90
Greg Clayton819134a2012-02-04 02:58:17 +000091 void
92 SetAddress (lldb::SBSection section,
93 lldb::addr_t offset);
94
95
Johnny Chen53cb46e2011-08-12 22:52:11 +000096 %feature("docstring", "
97 //------------------------------------------------------------------
98 /// GetSymbolContext() and the following can lookup symbol information for a given address.
99 /// An address might refer to code or data from an existing module, or it
100 /// might refer to something on the stack or heap. The following functions
101 /// will only return valid values if the address has been resolved to a code
102 /// or data address using 'void SBAddress::SetLoadAddress(...)' or
103 /// 'lldb::SBAddress SBTarget::ResolveLoadAddress (...)'.
104 //------------------------------------------------------------------
105 ") GetSymbolContext;
106 lldb::SBSymbolContext
107 GetSymbolContext (uint32_t resolve_scope);
108
109 %feature("docstring", "
110 //------------------------------------------------------------------
111 /// GetModule() and the following grab individual objects for a given address and
112 /// are less efficient if you want more than one symbol related objects.
113 /// Use one of the following when you want multiple debug symbol related
114 /// objects for an address:
115 /// lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t resolve_scope);
116 /// lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress &addr, uint32_t resolve_scope);
117 /// One or more bits from the SymbolContextItem enumerations can be logically
118 /// OR'ed together to more efficiently retrieve multiple symbol objects.
119 //------------------------------------------------------------------
120 ") GetModule;
Johnny Chen5de6a792011-07-18 21:30:21 +0000121 lldb::SBModule
122 GetModule ();
Johnny Chen53cb46e2011-08-12 22:52:11 +0000123
124 lldb::SBCompileUnit
125 GetCompileUnit ();
126
127 lldb::SBFunction
128 GetFunction ();
129
130 lldb::SBBlock
131 GetBlock ();
132
133 lldb::SBSymbol
134 GetSymbol ();
135
136 lldb::SBLineEntry
137 GetLineEntry ();
Greg Clayton13d19502012-01-29 06:07:39 +0000138
139 %pythoncode %{
Greg Clayton6b2bd932012-02-01 08:09:32 +0000140 def __get_load_addr_property__ (self):
141 '''Get the load address for a lldb.SBAddress using the current target.'''
142 return self.GetLoadAddress (target)
143
144 def __set_load_addr_property__ (self, load_addr):
145 '''Set the load address for a lldb.SBAddress using the current target.'''
146 return self.SetLoadAddress (load_addr, target)
147
148 def __int__(self):
149 '''Convert an address to a load address if there is a process and that
150 process is alive, or to a file address otherwise.'''
151 if process.is_alive:
152 return self.GetLoadAddress (target)
153 else:
154 return self.GetFileAddress ()
155
156 def __oct__(self):
157 return '%o' % int(self)
158
159 def __hex__(self):
160 return '0x%x' % int(self)
161
Greg Clayton13d19502012-01-29 06:07:39 +0000162 __swig_getmethods__["module"] = GetModule
163 if _newclass: x = property(GetModule, None)
164
165 __swig_getmethods__["compile_unit"] = GetCompileUnit
166 if _newclass: x = property(GetCompileUnit, None)
167
168 __swig_getmethods__["line_entry"] = GetLineEntry
169 if _newclass: x = property(GetLineEntry, None)
170
171 __swig_getmethods__["function"] = GetFunction
172 if _newclass: x = property(GetFunction, None)
173
174 __swig_getmethods__["block"] = GetBlock
175 if _newclass: x = property(GetBlock, None)
176
177 __swig_getmethods__["symbol"] = GetSymbol
178 if _newclass: x = property(GetSymbol, None)
179
180 __swig_getmethods__["offset"] = GetOffset
181 if _newclass: x = property(GetOffset, None)
182
183 __swig_getmethods__["section"] = GetSection
184 if _newclass: x = property(GetSection, None)
185
186 __swig_getmethods__["file_addr"] = GetFileAddress
187 if _newclass: x = property(GetFileAddress, None)
188
Greg Clayton6b2bd932012-02-01 08:09:32 +0000189 __swig_getmethods__["load_addr"] = __get_load_addr_property__
190 __swig_setmethods__["load_addr"] = __set_load_addr_property__
191 if _newclass: x = property(__get_load_addr_property__, __set_load_addr_property__)
192
Greg Clayton13d19502012-01-29 06:07:39 +0000193 %}
194
Johnny Chen5de6a792011-07-18 21:30:21 +0000195};
196
197} // namespace lldb