Allow a SBAddress to be created from a SBSection and an offset.

Changed the lldb.SBModule.section[<str>] property to return a single section.

Added a lldb.SBSection.addr property which returns an lldb.SBAddress object.

llvm-svn: 149755
This commit is contained in:
Greg Clayton 2012-02-04 02:58:17 +00:00
parent f8ea108c05
commit 819134a7c4
5 changed files with 35 additions and 3 deletions

View File

@ -23,6 +23,8 @@ public:
SBAddress (const lldb::SBAddress &rhs);
SBAddress (lldb::SBSection section, lldb::addr_t offset);
// Create an address by resolving a load address using the supplied target
SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);
@ -45,6 +47,9 @@ public:
addr_t
GetLoadAddress (const lldb::SBTarget &target) const;
void
SetAddress (lldb::SBSection section, lldb::addr_t offset);
void
SetLoadAddress (lldb::addr_t load_addr,
lldb::SBTarget &target);

View File

@ -50,6 +50,9 @@ public:
SBAddress (const lldb::SBAddress &rhs);
SBAddress (lldb::SBSection section,
lldb::addr_t offset);
%feature("docstring", "
Create an address by resolving a load address using the supplied target.
") SBAddress;
@ -85,6 +88,11 @@ public:
lldb::addr_t
SBAddress::GetOffset ();
void
SetAddress (lldb::SBSection section,
lldb::addr_t offset);
%feature("docstring", "
//------------------------------------------------------------------
/// GetSymbolContext() and the following can lookup symbol information for a given address.

View File

@ -320,12 +320,10 @@ public:
if key < count:
return self.sbmodule.GetSectionAtIndex(key)
elif type(key) is str:
matches = []
for idx in range(count):
section = self.sbmodule.GetSectionAtIndex(idx)
if section.name == key:
matches.append(section)
return matches
return section
elif isinstance(key, self.re_compile_type):
matches = []
for idx in range(count):

View File

@ -88,9 +88,15 @@ public:
GetDescription (lldb::SBStream &description);
%pythoncode %{
def get_addr(self):
return SBAddress(self, 0)
__swig_getmethods__["name"] = GetName
if _newclass: x = property(GetName, None)
__swig_getmethods__["addr"] = get_addr
if _newclass: x = property(get_addr, None)
__swig_getmethods__["file_addr"] = GetFileAddress
if _newclass: x = property(GetFileAddress, None)

View File

@ -103,6 +103,12 @@ SBAddress::SBAddress (const SBAddress &rhs) :
m_opaque_ap.reset (new AddressImpl(*rhs.m_opaque_ap.get()));
}
SBAddress::SBAddress (lldb::SBSection section, lldb::addr_t offset) :
m_opaque_ap(new AddressImpl (Address(section.GetSection(), offset)))
{
}
// Create an address by resolving a load address using the supplied target
SBAddress::SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target) :
m_opaque_ap()
@ -141,6 +147,15 @@ SBAddress::Clear ()
m_opaque_ap.reset();
}
void
SBAddress::SetAddress (lldb::SBSection section, lldb::addr_t offset)
{
Address &addr = ref();
addr.SetSection (section.GetSection());
addr.SetOffset (offset);
}
void
SBAddress::SetAddress (const Address *lldb_object_ptr)
{