blob: 1472c4f358895567e43555fde04e14c2faedcb28 [file] [log] [blame]
Johnny Chen3cfd5e82011-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
Johnny Chenc4f3ade2011-07-26 23:42:01 +000053 %feature("docstring", "
54 Create an address by resolving a load address using the supplied target.
55 ") SBAddress;
Greg Claytona3955062011-07-22 16:46:35 +000056 SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);
57
Johnny Chen3cfd5e82011-07-18 21:30:21 +000058 ~SBAddress ();
59
60 bool
61 IsValid () const;
62
63 void
64 Clear ();
65
66 addr_t
67 GetFileAddress () const;
68
69 addr_t
70 GetLoadAddress (const lldb::SBTarget &target) const;
71
Johnny Chenc4f3ade2011-07-26 23:42:01 +000072 void
73 SetLoadAddress (lldb::addr_t load_addr,
74 lldb::SBTarget &target);
Greg Claytona3955062011-07-22 16:46:35 +000075
Johnny Chen3cfd5e82011-07-18 21:30:21 +000076 bool
77 OffsetAddress (addr_t offset);
78
79 bool
80 GetDescription (lldb::SBStream &description);
81
Greg Clayton3e8c25f2011-09-24 00:52:29 +000082 lldb::SBSection
83 GetSection ();
Johnny Chen3cfd5e82011-07-18 21:30:21 +000084
Greg Clayton1b925202012-01-29 06:07:39 +000085 lldb::addr_t
86 SBAddress::GetOffset ();
87
Johnny Chene4fd4402011-08-12 22:52:11 +000088 %feature("docstring", "
89 //------------------------------------------------------------------
90 /// GetSymbolContext() and the following can lookup symbol information for a given address.
91 /// An address might refer to code or data from an existing module, or it
92 /// might refer to something on the stack or heap. The following functions
93 /// will only return valid values if the address has been resolved to a code
94 /// or data address using 'void SBAddress::SetLoadAddress(...)' or
95 /// 'lldb::SBAddress SBTarget::ResolveLoadAddress (...)'.
96 //------------------------------------------------------------------
97 ") GetSymbolContext;
98 lldb::SBSymbolContext
99 GetSymbolContext (uint32_t resolve_scope);
100
101 %feature("docstring", "
102 //------------------------------------------------------------------
103 /// GetModule() and the following grab individual objects for a given address and
104 /// are less efficient if you want more than one symbol related objects.
105 /// Use one of the following when you want multiple debug symbol related
106 /// objects for an address:
107 /// lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t resolve_scope);
108 /// lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress &addr, uint32_t resolve_scope);
109 /// One or more bits from the SymbolContextItem enumerations can be logically
110 /// OR'ed together to more efficiently retrieve multiple symbol objects.
111 //------------------------------------------------------------------
112 ") GetModule;
Johnny Chen3cfd5e82011-07-18 21:30:21 +0000113 lldb::SBModule
114 GetModule ();
Johnny Chene4fd4402011-08-12 22:52:11 +0000115
116 lldb::SBCompileUnit
117 GetCompileUnit ();
118
119 lldb::SBFunction
120 GetFunction ();
121
122 lldb::SBBlock
123 GetBlock ();
124
125 lldb::SBSymbol
126 GetSymbol ();
127
128 lldb::SBLineEntry
129 GetLineEntry ();
Greg Clayton1b925202012-01-29 06:07:39 +0000130
131 %pythoncode %{
Greg Claytonb302dff2012-02-01 08:09:32 +0000132 def __get_load_addr_property__ (self):
133 '''Get the load address for a lldb.SBAddress using the current target.'''
134 return self.GetLoadAddress (target)
135
136 def __set_load_addr_property__ (self, load_addr):
137 '''Set the load address for a lldb.SBAddress using the current target.'''
138 return self.SetLoadAddress (load_addr, target)
139
140 def __int__(self):
141 '''Convert an address to a load address if there is a process and that
142 process is alive, or to a file address otherwise.'''
143 if process.is_alive:
144 return self.GetLoadAddress (target)
145 else:
146 return self.GetFileAddress ()
147
148 def __oct__(self):
149 return '%o' % int(self)
150
151 def __hex__(self):
152 return '0x%x' % int(self)
153
Greg Clayton1b925202012-01-29 06:07:39 +0000154 __swig_getmethods__["module"] = GetModule
155 if _newclass: x = property(GetModule, None)
156
157 __swig_getmethods__["compile_unit"] = GetCompileUnit
158 if _newclass: x = property(GetCompileUnit, None)
159
160 __swig_getmethods__["line_entry"] = GetLineEntry
161 if _newclass: x = property(GetLineEntry, None)
162
163 __swig_getmethods__["function"] = GetFunction
164 if _newclass: x = property(GetFunction, None)
165
166 __swig_getmethods__["block"] = GetBlock
167 if _newclass: x = property(GetBlock, None)
168
169 __swig_getmethods__["symbol"] = GetSymbol
170 if _newclass: x = property(GetSymbol, None)
171
172 __swig_getmethods__["offset"] = GetOffset
173 if _newclass: x = property(GetOffset, None)
174
175 __swig_getmethods__["section"] = GetSection
176 if _newclass: x = property(GetSection, None)
177
178 __swig_getmethods__["file_addr"] = GetFileAddress
179 if _newclass: x = property(GetFileAddress, None)
180
Greg Claytonb302dff2012-02-01 08:09:32 +0000181 __swig_getmethods__["load_addr"] = __get_load_addr_property__
182 __swig_setmethods__["load_addr"] = __set_load_addr_property__
183 if _newclass: x = property(__get_load_addr_property__, __set_load_addr_property__)
184
Greg Clayton1b925202012-01-29 06:07:39 +0000185 %}
186
Johnny Chen3cfd5e82011-07-18 21:30:21 +0000187};
188
189} // namespace lldb