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