Added the ability to get the target triple, byte order and address byte size

from the SBTarget and SBModule interfaces. Also added many python properties
for easier access to many things from many SB objects.

llvm-svn: 149191
This commit is contained in:
Greg Clayton
2012-01-29 06:07:39 +00:00
parent 6e1c012385
commit 13d1950ae6
22 changed files with 546 additions and 0 deletions

View File

@@ -76,6 +76,9 @@ public:
lldb::SBSection
GetSection ();
lldb::addr_t
GetOffset ();
lldb::SBModule
GetModule ();

View File

@@ -73,6 +73,15 @@ public:
bool
SetPlatformFileSpec (const lldb::SBFileSpec &platform_file);
lldb::ByteOrder
GetByteOrder ();
uint32_t
GetAddressByteSize();
const char *
GetTriple ();
#ifndef SWIG
const uint8_t *
GetUUIDBytes () const;

View File

@@ -269,6 +269,15 @@ public:
lldb::SBModule
FindModule (const lldb::SBFileSpec &file_spec);
lldb::ByteOrder
GetByteOrder ();
uint32_t
GetAddressByteSize();
const char *
GetTriple ();
//------------------------------------------------------------------
/// Set the base load address for a module section.
///

View File

@@ -82,6 +82,9 @@ public:
lldb::SBSection
GetSection ();
lldb::addr_t
SBAddress::GetOffset ();
%feature("docstring", "
//------------------------------------------------------------------
/// GetSymbolContext() and the following can lookup symbol information for a given address.
@@ -124,6 +127,37 @@ public:
lldb::SBLineEntry
GetLineEntry ();
%pythoncode %{
__swig_getmethods__["module"] = GetModule
if _newclass: x = property(GetModule, None)
__swig_getmethods__["compile_unit"] = GetCompileUnit
if _newclass: x = property(GetCompileUnit, None)
__swig_getmethods__["line_entry"] = GetLineEntry
if _newclass: x = property(GetLineEntry, None)
__swig_getmethods__["function"] = GetFunction
if _newclass: x = property(GetFunction, None)
__swig_getmethods__["block"] = GetBlock
if _newclass: x = property(GetBlock, None)
__swig_getmethods__["symbol"] = GetSymbol
if _newclass: x = property(GetSymbol, None)
__swig_getmethods__["offset"] = GetOffset
if _newclass: x = property(GetOffset, None)
__swig_getmethods__["section"] = GetSection
if _newclass: x = property(GetSection, None)
__swig_getmethods__["file_addr"] = GetFileAddress
if _newclass: x = property(GetFileAddress, None)
%}
};
} // namespace lldb

View File

@@ -79,6 +79,14 @@ public:
bool
GetDescription (lldb::SBStream &description);
%pythoncode %{
__swig_getmethods__["file"] = GetFileSpec
if _newclass: x = property(GetFileSpec, None)
__swig_getmethods__["num_line_entries"] = GetNumLineEntries
if _newclass: x = property(GetNumLineEntries, None)
%}
};
} // namespace lldb

View File

@@ -133,6 +133,16 @@ public:
bool
SetDataFromDoubleArray (double* array, size_t array_len);
%pythoncode %{
__swig_getmethods__["byte_order"] = GetByteOrder
__swig_setmethods__["byte_order"] = SetByteOrder
if _newclass: x = property(GetByteOrder, SetByteOrder)
__swig_getmethods__["size"] = GetByteSize
if _newclass: x = property(GetByteSize, None)
%}
};
} // namespace lldb

View File

@@ -102,6 +102,25 @@ public:
bool
GetDescription (lldb::SBStream &description);
%pythoncode %{
__swig_getmethods__["value"] = GetError
if _newclass: x = property(GetError, None)
__swig_getmethods__["fail"] = Fail
if _newclass: x = property(Fail, None)
__swig_getmethods__["success"] = Success
if _newclass: x = property(Success, None)
__swig_getmethods__["description"] = GetCString
if _newclass: x = property(GetCString, None)
__swig_getmethods__["type"] = GetType
if _newclass: x = property(GetType, None)
%}
};
} // namespace lldb

View File

@@ -66,6 +66,18 @@ public:
bool
GetDescription (lldb::SBStream &description) const;
%pythoncode %{
__swig_getmethods__["basename"] = GetFilename
if _newclass: x = property(GetFilename, None)
__swig_getmethods__["dirname"] = GetDirectory
if _newclass: x = property(GetDirectory, None)
__swig_getmethods__["exists"] = Exists
if _newclass: x = property(Exists, None)
%}
};
} // namespace lldb

View File

@@ -217,7 +217,52 @@ public:
bool
GetDescription (lldb::SBStream &description);
%pythoncode %{
__swig_getmethods__["pc"] = GetPC
__swig_setmethods__["pc"] = SetPC
if _newclass: x = property(GetPC, SetPC)
__swig_getmethods__["fp"] = GetFP
if _newclass: x = property(GetFP, None)
__swig_getmethods__["sp"] = GetSP
if _newclass: x = property(GetSP, None)
__swig_getmethods__["module"] = GetModule
if _newclass: x = property(GetModule, None)
__swig_getmethods__["compile_unit"] = GetCompileUnit
if _newclass: x = property(GetCompileUnit, None)
__swig_getmethods__["function"] = GetFunction
if _newclass: x = property(GetFunction, None)
__swig_getmethods__["symbol"] = GetSymbol
if _newclass: x = property(GetSymbol, None)
__swig_getmethods__["block"] = GetBlock
if _newclass: x = property(GetBlock, None)
__swig_getmethods__["is_inlined"] = IsInlined
if _newclass: x = property(IsInlined, None)
__swig_getmethods__["name"] = GetFunctionName
if _newclass: x = property(GetFunctionName, None)
__swig_getmethods__["line_entry"] = GetLineEntry
if _newclass: x = property(GetLineEntry, None)
__swig_getmethods__["thread"] = GetThread
if _newclass: x = property(GetThread, None)
__swig_getmethods__["disassembly"] = Disassemble
if _newclass: x = property(Disassemble, None)
__swig_getmethods__["idx"] = GetFrameID
if _newclass: x = property(GetFrameID, None)
%}
};
} // namespace lldb

View File

@@ -76,6 +76,25 @@ public:
bool
GetDescription (lldb::SBStream &description);
%pythoncode %{
__swig_getmethods__["name"] = GetName
if _newclass: x = property(GetName, None)
__swig_getmethods__["mangled"] = GetMangledName
if _newclass: x = property(GetMangledName, None)
__swig_getmethods__["start_addr"] = GetStartAddress
if _newclass: x = property(GetStartAddress, None)
__swig_getmethods__["end_addr"] = GetEndAddress
if _newclass: x = property(GetEndAddress, None)
__swig_getmethods__["prologue_size"] = GetPrologueByteSize
if _newclass: x = property(GetPrologueByteSize, None)
%}
};
} // namespace lldb

View File

@@ -62,6 +62,19 @@ public:
bool
TestEmulation (lldb::SBStream &output_stream, const char *test_file);
%pythoncode %{
__swig_getmethods__["addr"] = GetAddress
if _newclass: x = property(GetAddress, None)
__swig_getmethods__["size"] = GetByteSize
if _newclass: x = property(GetByteSize, None)
__swig_getmethods__["is_branch"] = DoesBranch
if _newclass: x = property(DoesBranch, None)
%}
};
} // namespace lldb

View File

@@ -77,6 +77,24 @@ public:
void
SetColumn (uint32_t column);
%pythoncode %{
__swig_getmethods__["file"] = GetFileSpec
if _newclass: x = property(GetFileSpec, None)
__swig_getmethods__["line"] = GetLine
if _newclass: x = property(GetLine, None)
__swig_getmethods__["column"] = GetColumn
if _newclass: x = property(GetColumn, None)
__swig_getmethods__["start_addr"] = GetStartAddress
if _newclass: x = property(GetStartAddress, None)
__swig_getmethods__["end_addr"] = GetEndAddress
if _newclass: x = property(GetEndAddress, None)
%}
};
} // namespace lldb

View File

@@ -236,6 +236,43 @@ public:
FindGlobalVariables (lldb::SBTarget &target,
const char *name,
uint32_t max_matches);
lldb::ByteOrder
GetByteOrder ();
uint32_t
GetAddressByteSize();
const char *
GetTriple ();
%pythoncode %{
__swig_getmethods__["file"] = GetFileSpec
if _newclass: x = property(GetFileSpec, None)
__swig_getmethods__["platform_file"] = GetPlatformFileSpec
if _newclass: x = property(GetPlatformFileSpec, None)
__swig_getmethods__["uuid"] = GetUUIDString
if _newclass: x = property(GetUUIDString, None)
__swig_getmethods__["byte_order"] = GetByteOrder
if _newclass: x = property(GetByteOrder, None)
__swig_getmethods__["addr_size"] = GetAddressByteSize
if _newclass: x = property(GetAddressByteSize, None)
__swig_getmethods__["triple"] = GetTriple
if _newclass: x = property(GetTriple, None)
__swig_getmethods__["num_symbols"] = GetNumSymbols
if _newclass: x = property(GetNumSymbols, None)
__swig_getmethods__["num_sections"] = GetNumSections
if _newclass: x = property(GetNumSections, None)
%}
};
} // namespace lldb

View File

@@ -281,6 +281,33 @@ public:
lldb::SBError
UnloadImage (uint32_t image_token);
%pythoncode %{
__swig_getmethods__["id"] = GetProcessID
if _newclass: x = property(GetProcessID, None)
__swig_getmethods__["target"] = GetTarget
if _newclass: x = property(GetTarget, None)
__swig_getmethods__["num_threads"] = GetNumThreads
if _newclass: x = property(GetNumThreads, None)
__swig_getmethods__["selected_thread"] = GetSelectedThread
__swig_setmethods__["selected_thread"] = SetSelectedThread
if _newclass: x = property(GetSelectedThread, SetSelectedThread)
__swig_getmethods__["state"] = GetState
if _newclass: x = property(GetState, None)
__swig_getmethods__["exit_state"] = GetExitStatus
if _newclass: x = property(GetExitStatus, None)
__swig_getmethods__["exit_description"] = GetExitDescription
if _newclass: x = property(GetExitDescription, None)
__swig_getmethods__["broadcaster"] = GetBroadcaster
if _newclass: x = property(GetBroadcaster, None)
%}
};
} // namespace lldb

View File

@@ -87,6 +87,30 @@ public:
bool
GetDescription (lldb::SBStream &description);
%pythoncode %{
__swig_getmethods__["name"] = GetName
if _newclass: x = property(GetName, None)
__swig_getmethods__["file_addr"] = GetFileAddress
if _newclass: x = property(GetFileAddress, None)
__swig_getmethods__["size"] = GetByteSize
if _newclass: x = property(GetByteSize, None)
__swig_getmethods__["file_offset"] = GetFileOffset
if _newclass: x = property(GetFileOffset, None)
__swig_getmethods__["file_size"] = GetFileByteSize
if _newclass: x = property(GetFileByteSize, None)
__swig_getmethods__["data"] = GetSectionData
if _newclass: x = property(GetSectionData, None)
__swig_getmethods__["type"] = GetSectionType
if _newclass: x = property(GetSectionType, None)
%}
private:
std::auto_ptr<lldb_private::SectionImpl> m_opaque_ap;

View File

@@ -311,6 +311,15 @@ public:
lldb::SBModule
FindModule (const lldb::SBFileSpec &file_spec);
lldb::ByteOrder
GetByteOrder ();
uint32_t
GetAddressByteSize();
const char *
GetTriple ();
lldb::SBError
SetSectionLoadAddress (lldb::SBSection section,
lldb::addr_t section_base_addr);
@@ -476,6 +485,39 @@ public:
bool
GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
%pythoncode %{
__swig_getmethods__["process"] = GetProcess
if _newclass: x = property(GetProcess, None)
__swig_getmethods__["executable"] = GetExecutable
if _newclass: x = property(GetExecutable, None)
__swig_getmethods__["debugger"] = GetDebugger
if _newclass: x = property(GetDebugger, None)
__swig_getmethods__["file_offset"] = GetFileOffset
if _newclass: x = property(GetFileOffset, None)
__swig_getmethods__["num_breakpoints"] = GetNumBreakpoints
if _newclass: x = property(GetNumBreakpoints, None)
__swig_getmethods__["num_watchpoints"] = GetNumWatchpoints
if _newclass: x = property(GetNumWatchpoints, None)
__swig_getmethods__["broadcaster"] = GetBroadcaster
if _newclass: x = property(GetBroadcaster, None)
__swig_getmethods__["byte_order"] = GetByteOrder
if _newclass: x = property(GetByteOrder, None)
__swig_getmethods__["addr_size"] = GetAddressByteSize
if _newclass: x = property(GetAddressByteSize, None)
__swig_getmethods__["triple"] = GetTriple
if _newclass: x = property(GetTriple, None)
%}
};
} // namespace lldb

View File

@@ -173,6 +173,36 @@ public:
bool
GetDescription (lldb::SBStream &description) const;
%pythoncode %{
__swig_getmethods__["id"] = GetThreadID
if _newclass: x = property(GetThreadID, None)
__swig_getmethods__["idx"] = GetIndexID
if _newclass: x = property(GetIndexID, None)
__swig_getmethods__["return_value"] = GetStopReturnValue
if _newclass: x = property(GetStopReturnValue, None)
__swig_getmethods__["process"] = GetProcess
if _newclass: x = property(GetProcess, None)
__swig_getmethods__["num_frames"] = GetNumFrames
if _newclass: x = property(GetNumFrames, None)
__swig_getmethods__["name"] = GetName
if _newclass: x = property(GetName, None)
__swig_getmethods__["queue"] = GetQueueName
if _newclass: x = property(GetQueueName, None)
__swig_getmethods__["stop_reason"] = GetStopReason
if _newclass: x = property(GetStopReason, None)
__swig_getmethods__["is_suspended"] = IsSuspended
if _newclass: x = property(IsSuspended, None)
%}
};
} // namespace lldb

View File

@@ -37,6 +37,20 @@ public:
uint64_t
GetOffsetInBits();
%pythoncode %{
__swig_getmethods__["name"] = GetName
if _newclass: x = property(GetName, None)
__swig_getmethods__["type"] = GetType
if _newclass: x = property(GetType, None)
__swig_getmethods__["byte_offset"] = GetOffsetInBytes
if _newclass: x = property(GetOffsetInBytes, None)
__swig_getmethods__["bit_offset"] = GetOffsetInBits
if _newclass: x = property(GetOffsetInBits, None)
%}
protected:
std::auto_ptr<lldb_private::TypeMemberImpl> m_opaque_ap;
};
@@ -174,6 +188,33 @@ public:
lldb::TypeClass
GetTypeClass ();
%pythoncode %{
__swig_getmethods__["name"] = GetName
if _newclass: x = property(GetName, None)
__swig_getmethods__["size"] = GetByteSize
if _newclass: x = property(GetByteSize, None)
__swig_getmethods__["is_pointer"] = IsPointerType
if _newclass: x = property(IsPointerType, None)
__swig_getmethods__["is_reference"] = IsReferenceType
if _newclass: x = property(IsReferenceType, None)
__swig_getmethods__["num_fields"] = GetNumberOfFields
if _newclass: x = property(GetNumberOfFields, None)
__swig_getmethods__["num_bases"] = GetNumberOfDirectBaseClasses
if _newclass: x = property(GetNumberOfDirectBaseClasses, None)
__swig_getmethods__["num_vbases"] = GetNumberOfVirtualBaseClasses
if _newclass: x = property(GetNumberOfVirtualBaseClasses, None)
__swig_getmethods__["class"] = GetTypeClass
if _newclass: x = property(GetTypeClass, None)
%}
};
%feature("docstring",

View File

@@ -362,6 +362,82 @@ public:
) GetExpressionPath;
bool
GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes);
%pythoncode %{
__swig_getmethods__["name"] = GetName
if _newclass: x = property(GetName, None)
__swig_getmethods__["type"] = GetType
if _newclass: x = property(GetType, None)
__swig_getmethods__["size"] = GetByteSize
if _newclass: x = property(GetByteSize, None)
__swig_getmethods__["name"] = GetName
if _newclass: x = property(GetName, None)
__swig_getmethods__["is_in_scope"] = IsInScope
if _newclass: x = property(IsInScope, None)
__swig_getmethods__["format"] = GetFormat
__swig_setmethods__["format"] = SetFormat
if _newclass: x = property(GetName, SetFormat)
__swig_getmethods__["value"] = GetValue
__swig_setmethods__["value"] = SetValueFromCString
if _newclass: x = property(GetValue, SetValueFromCString)
__swig_getmethods__["value_type"] = GetValueType
if _newclass: x = property(GetValueType, None)
__swig_getmethods__["changed"] = GetValueDidChange
if _newclass: x = property(GetValueDidChange, None)
__swig_getmethods__["data"] = GetData
if _newclass: x = property(GetData, None)
__swig_getmethods__["load_addr"] = GetLoadAddress
if _newclass: x = property(GetLoadAddress, None)
__swig_getmethods__["addr"] = GetAddress
if _newclass: x = property(GetAddress, None)
__swig_getmethods__["deref"] = Dereference
if _newclass: x = property(Dereference, None)
__swig_getmethods__["address_of"] = AddressOf
if _newclass: x = property(AddressOf, None)
__swig_getmethods__["error"] = GetError
if _newclass: x = property(GetError, None)
__swig_getmethods__["summary"] = GetSummary
if _newclass: x = property(GetSummary, None)
__swig_getmethods__["description"] = GetObjectDescription
if _newclass: x = property(GetObjectDescription, None)
__swig_getmethods__["location"] = GetLocation
if _newclass: x = property(GetLocation, None)
__swig_getmethods__["target"] = GetTarget
if _newclass: x = property(GetTarget, None)
__swig_getmethods__["process"] = GetProcess
if _newclass: x = property(GetProcess, None)
__swig_getmethods__["thread"] = GetThread
if _newclass: x = property(GetThread, None)
__swig_getmethods__["frame"] = GetFrame
if _newclass: x = property(GetFrame, None)
__swig_getmethods__["num_children"] = GetNumChildren
if _newclass: x = property(GetNumChildren, None)
%}
};
} // namespace lldb

View File

@@ -229,6 +229,13 @@ SBAddress::GetSection ()
return sb_section;
}
lldb::addr_t
SBAddress::GetOffset ()
{
if (m_opaque_ap.get())
m_opaque_ap->GetAddress().GetOffset();
return 0;
}
Address *
SBAddress::operator->()

View File

@@ -475,3 +475,34 @@ SBModule::FindSection (const char *sect_name)
return sb_section;
}
lldb::ByteOrder
SBModule::GetByteOrder ()
{
if (m_opaque_sp)
return m_opaque_sp->GetArchitecture().GetByteOrder();
return eByteOrderInvalid;
}
const char *
SBModule::GetTriple ()
{
if (m_opaque_sp)
{
std::string triple (m_opaque_sp->GetArchitecture().GetTriple().str());
// Unique the string so we don't run into ownership issues since
// the const strings put the string into the string pool once and
// the strings never comes out
ConstString const_triple (triple.c_str());
return const_triple.GetCString();
}
return NULL;
}
uint32_t
SBModule::GetAddressByteSize()
{
if (m_opaque_sp)
return m_opaque_sp->GetArchitecture().GetAddressByteSize();
return sizeof(void*);
}

View File

@@ -1113,6 +1113,38 @@ SBTarget::FindModule (const SBFileSpec &sb_file_spec)
return sb_module;
}
lldb::ByteOrder
SBTarget::GetByteOrder ()
{
if (m_opaque_sp)
return m_opaque_sp->GetArchitecture().GetByteOrder();
return eByteOrderInvalid;
}
const char *
SBTarget::GetTriple ()
{
if (m_opaque_sp)
{
std::string triple (m_opaque_sp->GetArchitecture().GetTriple().str());
// Unique the string so we don't run into ownership issues since
// the const strings put the string into the string pool once and
// the strings never comes out
ConstString const_triple (triple.c_str());
return const_triple.GetCString();
}
return NULL;
}
uint32_t
SBTarget::GetAddressByteSize()
{
if (m_opaque_sp)
return m_opaque_sp->GetArchitecture().GetAddressByteSize();
return sizeof(void*);
}
SBModule
SBTarget::GetModuleAtIndex (uint32_t idx)
{