106c3fb27SDimitry Andric STRING_EXTENSION_OUTSIDE(SBAddress) 206c3fb27SDimitry Andric 306c3fb27SDimitry Andric %extend lldb::SBAddress { 406c3fb27SDimitry Andric #ifdef SWIGPYTHON 506c3fb27SDimitry Andric %pythoncode%{ 6*5f757f3fSDimitry Andric # operator== is a free function, which swig does not handle, so we inject 7*5f757f3fSDimitry Andric # our own equality operator here 806c3fb27SDimitry Andric def __eq__(self, other): 906c3fb27SDimitry Andric return not self.__ne__(other) 1006c3fb27SDimitry Andric %} 1106c3fb27SDimitry Andric 1206c3fb27SDimitry Andric %pythoncode %{ 1306c3fb27SDimitry Andric __runtime_error_str = 'This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.' 1406c3fb27SDimitry Andric 1506c3fb27SDimitry Andric def __get_load_addr_property__ (self): 1606c3fb27SDimitry Andric '''Get the load address for a lldb.SBAddress using the current target. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.''' 1706c3fb27SDimitry Andric if not target: 1806c3fb27SDimitry Andric raise RuntimeError(self.__runtime_error_str) 1906c3fb27SDimitry Andric return self.GetLoadAddress (target) 2006c3fb27SDimitry Andric 2106c3fb27SDimitry Andric def __set_load_addr_property__ (self, load_addr): 2206c3fb27SDimitry Andric '''Set the load address for a lldb.SBAddress using the current target. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.''' 2306c3fb27SDimitry Andric if not target: 2406c3fb27SDimitry Andric raise RuntimeError(self.__runtime_error_str) 2506c3fb27SDimitry Andric return self.SetLoadAddress (load_addr, target) 2606c3fb27SDimitry Andric 2706c3fb27SDimitry Andric def __int__(self): 2806c3fb27SDimitry Andric '''Convert an address to a load address if there is a process and that process is alive, or to a file address otherwise. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.''' 2906c3fb27SDimitry Andric if not process or not target: 3006c3fb27SDimitry Andric raise RuntimeError(self.__runtime_error_str) 3106c3fb27SDimitry Andric if process.is_alive: 3206c3fb27SDimitry Andric return self.GetLoadAddress (target) 3306c3fb27SDimitry Andric return self.GetFileAddress () 3406c3fb27SDimitry Andric 3506c3fb27SDimitry Andric def __oct__(self): 3606c3fb27SDimitry Andric '''Convert the address to an octal string. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.''' 3706c3fb27SDimitry Andric return '%o' % int(self) 3806c3fb27SDimitry Andric 3906c3fb27SDimitry Andric def __hex__(self): 4006c3fb27SDimitry Andric '''Convert the address to an hex string. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.''' 4106c3fb27SDimitry Andric return '0x%x' % int(self) 4206c3fb27SDimitry Andric 4306c3fb27SDimitry Andric module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''') 4406c3fb27SDimitry Andric compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) that this address resides within.''') 4506c3fb27SDimitry Andric line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line entry (lldb.SBLineEntry) that this address resides within.''') 4606c3fb27SDimitry Andric function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) that this address resides within.''') 4706c3fb27SDimitry Andric block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) that this address resides within.''') 4806c3fb27SDimitry Andric symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) that this address resides within.''') 4906c3fb27SDimitry Andric offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''') 5006c3fb27SDimitry Andric section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''') 5106c3fb27SDimitry Andric file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''') 5206c3fb27SDimitry Andric load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.''') 5306c3fb27SDimitry Andric %} 5406c3fb27SDimitry Andric #endif 5506c3fb27SDimitry Andric } 56