Index: lldb/trunk/docs/doxygen.cfg.in =================================================================== --- lldb/trunk/docs/doxygen.cfg.in +++ lldb/trunk/docs/doxygen.cfg.in @@ -1349,7 +1349,7 @@ # contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = ../scripts/Python/interface +INCLUDE_PATH = ../scripts/interface # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the Index: lldb/trunk/lldb.xcodeproj/project.pbxproj =================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj +++ lldb/trunk/lldb.xcodeproj/project.pbxproj @@ -3230,7 +3230,7 @@ B2A5872514313B480092BFBA /* SBWatchpoint.i */, ); name = interface; - path = scripts/Python/interface; + path = scripts/interface; sourceTree = SOURCE_ROOT; }; 26274FA414030F79006BA130 /* Darwin-Kernel */ = { Index: lldb/trunk/scripts/CMakeLists.txt =================================================================== --- lldb/trunk/scripts/CMakeLists.txt +++ lldb/trunk/scripts/CMakeLists.txt @@ -1,6 +1,6 @@ set(LLVM_NO_RTTI 1) -file(GLOB SWIG_INTERFACES Python/interface/*.i) +file(GLOB SWIG_INTERFACES interface/*.i) file(GLOB_RECURSE SWIG_SOURCES *.swig) if ( LLDB_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION ) Index: lldb/trunk/scripts/Python/build-swig-Python.sh =================================================================== --- lldb/trunk/scripts/Python/build-swig-Python.sh +++ lldb/trunk/scripts/Python/build-swig-Python.sh @@ -131,59 +131,59 @@ " ${SRC_ROOT}/include/lldb/API/SBWatchpoint.h"\ " ${SRC_ROOT}/include/lldb/API/SBUnixSignals.h" -INTERFACE_FILES="${SRC_ROOT}/scripts/Python/interface/SBAddress.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBAttachInfo.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBBlock.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBBreakpoint.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBBreakpointLocation.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBBroadcaster.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBCommandInterpreter.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBCommandReturnObject.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBCommunication.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBCompileUnit.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBData.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBDebugger.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBDeclaration.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBError.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBEvent.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBExecutionContext.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBExpressionOptions.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBFileSpec.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBFrame.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBFunction.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBHostOS.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBInstruction.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBInstructionList.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBLaunchInfo.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBLineEntry.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBListener.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBModule.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBModuleSpec.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBPlatform.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBProcess.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBQueue.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBQueueItem.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBSourceManager.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBStream.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBStringList.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBSymbol.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBSymbolContext.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTarget.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBThread.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBThreadCollection.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBThreadPlan.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBType.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTypeCategory.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTypeFilter.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTypeFormat.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTypeNameSpecifier.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTypeSummary.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBTypeSynthetic.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBValue.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBValueList.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBVariablesOptions.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBWatchpoint.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBUnixSignals.i" +INTERFACE_FILES="${SRC_ROOT}/scripts/interface/SBAddress.i"\ +" ${SRC_ROOT}/scripts/interface/SBAttachInfo.i"\ +" ${SRC_ROOT}/scripts/interface/SBBlock.i"\ +" ${SRC_ROOT}/scripts/interface/SBBreakpoint.i"\ +" ${SRC_ROOT}/scripts/interface/SBBreakpointLocation.i"\ +" ${SRC_ROOT}/scripts/interface/SBBroadcaster.i"\ +" ${SRC_ROOT}/scripts/interface/SBCommandInterpreter.i"\ +" ${SRC_ROOT}/scripts/interface/SBCommandReturnObject.i"\ +" ${SRC_ROOT}/scripts/interface/SBCommunication.i"\ +" ${SRC_ROOT}/scripts/interface/SBCompileUnit.i"\ +" ${SRC_ROOT}/scripts/interface/SBData.i"\ +" ${SRC_ROOT}/scripts/interface/SBDebugger.i"\ +" ${SRC_ROOT}/scripts/interface/SBDeclaration.i"\ +" ${SRC_ROOT}/scripts/interface/SBError.i"\ +" ${SRC_ROOT}/scripts/interface/SBEvent.i"\ +" ${SRC_ROOT}/scripts/interface/SBExecutionContext.i"\ +" ${SRC_ROOT}/scripts/interface/SBExpressionOptions.i"\ +" ${SRC_ROOT}/scripts/interface/SBFileSpec.i"\ +" ${SRC_ROOT}/scripts/interface/SBFrame.i"\ +" ${SRC_ROOT}/scripts/interface/SBFunction.i"\ +" ${SRC_ROOT}/scripts/interface/SBHostOS.i"\ +" ${SRC_ROOT}/scripts/interface/SBInstruction.i"\ +" ${SRC_ROOT}/scripts/interface/SBInstructionList.i"\ +" ${SRC_ROOT}/scripts/interface/SBLaunchInfo.i"\ +" ${SRC_ROOT}/scripts/interface/SBLineEntry.i"\ +" ${SRC_ROOT}/scripts/interface/SBListener.i"\ +" ${SRC_ROOT}/scripts/interface/SBModule.i"\ +" ${SRC_ROOT}/scripts/interface/SBModuleSpec.i"\ +" ${SRC_ROOT}/scripts/interface/SBPlatform.i"\ +" ${SRC_ROOT}/scripts/interface/SBProcess.i"\ +" ${SRC_ROOT}/scripts/interface/SBQueue.i"\ +" ${SRC_ROOT}/scripts/interface/SBQueueItem.i"\ +" ${SRC_ROOT}/scripts/interface/SBSourceManager.i"\ +" ${SRC_ROOT}/scripts/interface/SBStream.i"\ +" ${SRC_ROOT}/scripts/interface/SBStringList.i"\ +" ${SRC_ROOT}/scripts/interface/SBSymbol.i"\ +" ${SRC_ROOT}/scripts/interface/SBSymbolContext.i"\ +" ${SRC_ROOT}/scripts/interface/SBTarget.i"\ +" ${SRC_ROOT}/scripts/interface/SBThread.i"\ +" ${SRC_ROOT}/scripts/interface/SBThreadCollection.i"\ +" ${SRC_ROOT}/scripts/interface/SBThreadPlan.i"\ +" ${SRC_ROOT}/scripts/interface/SBType.i"\ +" ${SRC_ROOT}/scripts/interface/SBTypeCategory.i"\ +" ${SRC_ROOT}/scripts/interface/SBTypeFilter.i"\ +" ${SRC_ROOT}/scripts/interface/SBTypeFormat.i"\ +" ${SRC_ROOT}/scripts/interface/SBTypeNameSpecifier.i"\ +" ${SRC_ROOT}/scripts/interface/SBTypeSummary.i"\ +" ${SRC_ROOT}/scripts/interface/SBTypeSynthetic.i"\ +" ${SRC_ROOT}/scripts/interface/SBValue.i"\ +" ${SRC_ROOT}/scripts/interface/SBValueList.i"\ +" ${SRC_ROOT}/scripts/interface/SBVariablesOptions.i"\ +" ${SRC_ROOT}/scripts/interface/SBWatchpoint.i"\ +" ${SRC_ROOT}/scripts/interface/SBUnixSignals.i" if [ $Debug -eq 1 ] then Index: lldb/trunk/scripts/Python/buildSwigPython.py =================================================================== --- lldb/trunk/scripts/Python/buildSwigPython.py +++ lldb/trunk/scripts/Python/buildSwigPython.py @@ -152,53 +152,53 @@ #-- def get_interface_files( vDictArgs ): dbg = utilsDebug.CDebugFnVerbose( "Python script get_interface_files()" ); - listIFaceFiles = [ "/scripts/Python/interface/SBAddress.i", - "/scripts/Python/interface/SBAttachInfo.i", - "/scripts/Python/interface/SBBlock.i", - "/scripts/Python/interface/SBBreakpoint.i", - "/scripts/Python/interface/SBBreakpointLocation.i", - "/scripts/Python/interface/SBBroadcaster.i", - "/scripts/Python/interface/SBCommandInterpreter.i", - "/scripts/Python/interface/SBCommandReturnObject.i", - "/scripts/Python/interface/SBCommunication.i", - "/scripts/Python/interface/SBCompileUnit.i", - "/scripts/Python/interface/SBData.i", - "/scripts/Python/interface/SBDebugger.i", - "/scripts/Python/interface/SBDeclaration.i", - "/scripts/Python/interface/SBError.i", - "/scripts/Python/interface/SBEvent.i", - "/scripts/Python/interface/SBExpressionOptions.i", - "/scripts/Python/interface/SBFileSpec.i", - "/scripts/Python/interface/SBFrame.i", - "/scripts/Python/interface/SBFunction.i", - "/scripts/Python/interface/SBHostOS.i", - "/scripts/Python/interface/SBInputReader.i", - "/scripts/Python/interface/SBInstruction.i", - "/scripts/Python/interface/SBInstructionList.i", - "/scripts/Python/interface/SBLaunchInfo.i", - "/scripts/Python/interface/SBLineEntry.i", - "/scripts/Python/interface/SBListener.i", - "/scripts/Python/interface/SBModule.i", - "/scripts/Python/interface/SBModuleSpec.i", - "/scripts/Python/interface/SBProcess.i", - "/scripts/Python/interface/SBSourceManager.i", - "/scripts/Python/interface/SBStream.i", - "/scripts/Python/interface/SBStringList.i", - "/scripts/Python/interface/SBSymbol.i", - "/scripts/Python/interface/SBSymbolContext.i", - "/scripts/Python/interface/SBTarget.i", - "/scripts/Python/interface/SBThread.i", - "/scripts/Python/interface/SBThreadCollection.i", - "/scripts/Python/interface/SBType.i", - "/scripts/Python/interface/SBTypeCategory.i", - "/scripts/Python/interface/SBTypeFilter.i", - "/scripts/Python/interface/SBTypeFormat.i", - "/scripts/Python/interface/SBTypeNameSpecifier.i", - "/scripts/Python/interface/SBTypeSummary.i", - "/scripts/Python/interface/SBTypeSynthetic.i", - "/scripts/Python/interface/SBValue.i", - "/scripts/Python/interface/SBValueList.i", - "/scripts/Python/interface/SBWatchpoint.i" ]; + listIFaceFiles = [ "/scripts/interface/SBAddress.i", + "/scripts/interface/SBAttachInfo.i", + "/scripts/interface/SBBlock.i", + "/scripts/interface/SBBreakpoint.i", + "/scripts/interface/SBBreakpointLocation.i", + "/scripts/interface/SBBroadcaster.i", + "/scripts/interface/SBCommandInterpreter.i", + "/scripts/interface/SBCommandReturnObject.i", + "/scripts/interface/SBCommunication.i", + "/scripts/interface/SBCompileUnit.i", + "/scripts/interface/SBData.i", + "/scripts/interface/SBDebugger.i", + "/scripts/interface/SBDeclaration.i", + "/scripts/interface/SBError.i", + "/scripts/interface/SBEvent.i", + "/scripts/interface/SBExpressionOptions.i", + "/scripts/interface/SBFileSpec.i", + "/scripts/interface/SBFrame.i", + "/scripts/interface/SBFunction.i", + "/scripts/interface/SBHostOS.i", + "/scripts/interface/SBInputReader.i", + "/scripts/interface/SBInstruction.i", + "/scripts/interface/SBInstructionList.i", + "/scripts/interface/SBLaunchInfo.i", + "/scripts/interface/SBLineEntry.i", + "/scripts/interface/SBListener.i", + "/scripts/interface/SBModule.i", + "/scripts/interface/SBModuleSpec.i", + "/scripts/interface/SBProcess.i", + "/scripts/interface/SBSourceManager.i", + "/scripts/interface/SBStream.i", + "/scripts/interface/SBStringList.i", + "/scripts/interface/SBSymbol.i", + "/scripts/interface/SBSymbolContext.i", + "/scripts/interface/SBTarget.i", + "/scripts/interface/SBThread.i", + "/scripts/interface/SBThreadCollection.i", + "/scripts/interface/SBType.i", + "/scripts/interface/SBTypeCategory.i", + "/scripts/interface/SBTypeFilter.i", + "/scripts/interface/SBTypeFormat.i", + "/scripts/interface/SBTypeNameSpecifier.i", + "/scripts/interface/SBTypeSummary.i", + "/scripts/interface/SBTypeSynthetic.i", + "/scripts/interface/SBValue.i", + "/scripts/interface/SBValueList.i", + "/scripts/interface/SBWatchpoint.i" ]; bDebug = vDictArgs.has_key( "-d" ); strRt = vDictArgs[ "--srcRoot" ]; strRt = os.path.normcase( strRt ); Index: lldb/trunk/scripts/Python/interface/SBAddress.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBAddress.i +++ lldb/trunk/scripts/Python/interface/SBAddress.i @@ -1,201 +0,0 @@ -//===-- SWIG Interface for SBAddress ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"A section + offset based address class. - -The SBAddress class allows addresses to be relative to a section -that can move during runtime due to images (executables, shared -libraries, bundles, frameworks) being loaded at different -addresses than the addresses found in the object file that -represents them on disk. There are currently two types of addresses -for a section: - o file addresses - o load addresses - -File addresses represents the virtual addresses that are in the 'on -disk' object files. These virtual addresses are converted to be -relative to unique sections scoped to the object file so that -when/if the addresses slide when the images are loaded/unloaded -in memory, we can easily track these changes without having to -update every object (compile unit ranges, line tables, function -address ranges, lexical block and inlined subroutine address -ranges, global and static variables) each time an image is loaded or -unloaded. - -Load addresses represents the virtual addresses where each section -ends up getting loaded at runtime. Before executing a program, it -is common for all of the load addresses to be unresolved. When a -DynamicLoader plug-in receives notification that shared libraries -have been loaded/unloaded, the load addresses of the main executable -and any images (shared libraries) will be resolved/unresolved. When -this happens, breakpoints that are in one of these sections can be -set/cleared. - -See docstring of SBFunction for example usage of SBAddress." -) SBAddress; -class SBAddress -{ -public: - - SBAddress (); - - 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; - SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target); - - ~SBAddress (); - - bool - IsValid () const; - - void - Clear (); - - addr_t - GetFileAddress () const; - - addr_t - GetLoadAddress (const lldb::SBTarget &target) const; - - void - SetLoadAddress (lldb::addr_t load_addr, - lldb::SBTarget &target); - - bool - OffsetAddress (addr_t offset); - - bool - GetDescription (lldb::SBStream &description); - - lldb::SBSection - GetSection (); - - lldb::addr_t - SBAddress::GetOffset (); - - void - SetAddress (lldb::SBSection section, - lldb::addr_t offset); - - - lldb::AddressClass - GetAddressClass (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// GetSymbolContext() and the following can lookup symbol information for a given address. - /// An address might refer to code or data from an existing module, or it - /// might refer to something on the stack or heap. The following functions - /// will only return valid values if the address has been resolved to a code - /// or data address using 'void SBAddress::SetLoadAddress(...)' or - /// 'lldb::SBAddress SBTarget::ResolveLoadAddress (...)'. - //------------------------------------------------------------------ - ") GetSymbolContext; - lldb::SBSymbolContext - GetSymbolContext (uint32_t resolve_scope); - - %feature("docstring", " - //------------------------------------------------------------------ - /// GetModule() and the following grab individual objects for a given address and - /// are less efficient if you want more than one symbol related objects. - /// Use one of the following when you want multiple debug symbol related - /// objects for an address: - /// lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t resolve_scope); - /// lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress &addr, uint32_t resolve_scope); - /// One or more bits from the SymbolContextItem enumerations can be logically - /// OR'ed together to more efficiently retrieve multiple symbol objects. - //------------------------------------------------------------------ - ") GetModule; - lldb::SBModule - GetModule (); - - lldb::SBCompileUnit - GetCompileUnit (); - - lldb::SBFunction - GetFunction (); - - lldb::SBBlock - GetBlock (); - - lldb::SBSymbol - GetSymbol (); - - lldb::SBLineEntry - GetLineEntry (); - - %pythoncode %{ - def __get_load_addr_property__ (self): - '''Get the load address for a lldb.SBAddress using the current target.''' - return self.GetLoadAddress (target) - - def __set_load_addr_property__ (self, load_addr): - '''Set the load address for a lldb.SBAddress using the current target.''' - return self.SetLoadAddress (load_addr, target) - - def __int__(self): - '''Convert an address to a load address if there is a process and that process is alive, or to a file address otherwise.''' - if process.is_alive: - return self.GetLoadAddress (target) - else: - return self.GetFileAddress () - - def __oct__(self): - '''Convert the address to an octal string''' - return '%o' % int(self) - - def __hex__(self): - '''Convert the address to an hex string''' - return '0x%x' % int(self) - - __swig_getmethods__["module"] = GetModule - if _newclass: 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.''') - - __swig_getmethods__["compile_unit"] = GetCompileUnit - if _newclass: 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.''') - - __swig_getmethods__["line_entry"] = GetLineEntry - if _newclass: 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.''') - - __swig_getmethods__["function"] = GetFunction - if _newclass: 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.''') - - __swig_getmethods__["block"] = GetBlock - if _newclass: 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.''') - - __swig_getmethods__["symbol"] = GetSymbol - if _newclass: 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.''') - - __swig_getmethods__["offset"] = GetOffset - if _newclass: offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''') - - __swig_getmethods__["section"] = GetSection - if _newclass: 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.''') - - __swig_getmethods__["file_addr"] = GetFileAddress - if _newclass: 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.''') - - __swig_getmethods__["load_addr"] = __get_load_addr_property__ - __swig_setmethods__["load_addr"] = __set_load_addr_property__ - if _newclass: load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves 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) and not in Python based commands, or breakpoint commands.''') - - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBAttachInfo.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBAttachInfo.i +++ lldb/trunk/scripts/Python/interface/SBAttachInfo.i @@ -1,111 +0,0 @@ -//===-- SWIG Interface for SBAttachInfo--------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBAttachInfo -{ -public: - SBAttachInfo (); - - SBAttachInfo (lldb::pid_t pid); - - SBAttachInfo (const char *path, bool wait_for); - - SBAttachInfo (const lldb::SBAttachInfo &rhs); - - lldb::pid_t - GetProcessID (); - - void - SetProcessID (lldb::pid_t pid); - - void - SetExecutable (const char *path); - - void - SetExecutable (lldb::SBFileSpec exe_file); - - bool - GetWaitForLaunch (); - - void - SetWaitForLaunch (bool b); - - bool - GetIgnoreExisting (); - - void - SetIgnoreExisting (bool b); - - uint32_t - GetResumeCount (); - - void - SetResumeCount (uint32_t c); - - const char * - GetProcessPluginName (); - - void - SetProcessPluginName (const char *plugin_name); - - uint32_t - GetUserID(); - - uint32_t - GetGroupID(); - - bool - UserIDIsValid (); - - bool - GroupIDIsValid (); - - void - SetUserID (uint32_t uid); - - void - SetGroupID (uint32_t gid); - - uint32_t - GetEffectiveUserID(); - - uint32_t - GetEffectiveGroupID(); - - bool - EffectiveUserIDIsValid (); - - bool - EffectiveGroupIDIsValid (); - - void - SetEffectiveUserID (uint32_t uid); - - void - SetEffectiveGroupID (uint32_t gid); - - lldb::pid_t - GetParentProcessID (); - - void - SetParentProcessID (lldb::pid_t pid); - - bool - ParentProcessIDIsValid(); - - lldb::SBListener - GetListener (); - - void - SetListener (lldb::SBListener &listener); -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBBlock.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBBlock.i +++ lldb/trunk/scripts/Python/interface/SBBlock.i @@ -1,179 +0,0 @@ -//===-- SWIG Interface for SBBlock ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a lexical block. SBFunction contains SBBlock(s)." -) SBBlock; -class SBBlock -{ -public: - - SBBlock (); - - SBBlock (const lldb::SBBlock &rhs); - - ~SBBlock (); - - %feature("docstring", - "Does this block represent an inlined function?" - ) IsInlined; - bool - IsInlined () const; - - bool - IsValid () const; - - %feature("docstring", " - Get the function name if this block represents an inlined function; - otherwise, return None. - ") GetInlinedName; - const char * - GetInlinedName () const; - - %feature("docstring", " - Get the call site file if this block represents an inlined function; - otherwise, return an invalid file spec. - ") GetInlinedCallSiteFile; - lldb::SBFileSpec - GetInlinedCallSiteFile () const; - - %feature("docstring", " - Get the call site line if this block represents an inlined function; - otherwise, return 0. - ") GetInlinedCallSiteLine; - uint32_t - GetInlinedCallSiteLine () const; - - %feature("docstring", " - Get the call site column if this block represents an inlined function; - otherwise, return 0. - ") GetInlinedCallSiteColumn; - uint32_t - GetInlinedCallSiteColumn () const; - - %feature("docstring", "Get the parent block.") GetParent; - lldb::SBBlock - GetParent (); - - %feature("docstring", "Get the inlined block that is or contains this block.") GetContainingInlinedBlock; - lldb::SBBlock - GetContainingInlinedBlock (); - - %feature("docstring", "Get the sibling block for this block.") GetSibling; - lldb::SBBlock - GetSibling (); - - %feature("docstring", "Get the first child block.") GetFirstChild; - lldb::SBBlock - GetFirstChild (); - - uint32_t - GetNumRanges (); - - lldb::SBAddress - GetRangeStartAddress (uint32_t idx); - - lldb::SBAddress - GetRangeEndAddress (uint32_t idx); - - uint32_t - GetRangeIndexForBlockAddress (lldb::SBAddress block_addr); - - bool - GetDescription (lldb::SBStream &description); - - lldb::SBValueList - GetVariables (lldb::SBFrame& frame, - bool arguments, - bool locals, - bool statics, - lldb::DynamicValueType use_dynamic); - - lldb::SBValueList - GetVariables (lldb::SBTarget& target, - bool arguments, - bool locals, - bool statics); - - %pythoncode %{ - def get_range_at_index(self, idx): - if idx < self.GetNumRanges(): - return [self.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)] - return [] - - class ranges_access(object): - '''A helper object that will lazily hand out an array of lldb.SBAddress that represent address ranges for a block.''' - def __init__(self, sbblock): - self.sbblock = sbblock - - def __len__(self): - if self.sbblock: - return int(self.sbblock.GetNumRanges()) - return 0 - - def __getitem__(self, key): - count = len(self) - if type(key) is int: - return self.sbblock.get_range_at_index (key); - if isinstance(key, SBAddress): - range_idx = self.sbblock.GetRangeIndexForBlockAddress(key); - if range_idx < len(self): - return [self.sbblock.GetRangeStartAddress(range_idx), self.sbblock.GetRangeEndAddress(range_idx)] - else: - print "error: unsupported item type: %s" % type(key) - return None - - def get_ranges_access_object(self): - '''An accessor function that returns a ranges_access() object which allows lazy block address ranges access.''' - return self.ranges_access (self) - - def get_ranges_array(self): - '''An accessor function that returns an array object that contains all ranges in this block object.''' - if not hasattr(self, 'ranges_array'): - self.ranges_array = [] - for idx in range(self.num_ranges): - self.ranges_array.append ([self.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)]) - return self.ranges_array - - def get_call_site(self): - return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn()) - - __swig_getmethods__["parent"] = GetParent - if _newclass: parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''') - - __swig_getmethods__["first_child"] = GetFirstChild - if _newclass: first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''') - - __swig_getmethods__["call_site"] = get_call_site - if _newclass: call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''') - - __swig_getmethods__["sibling"] = GetSibling - if _newclass: sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''') - - __swig_getmethods__["name"] = GetInlinedName - if _newclass: name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''') - - __swig_getmethods__["inlined_block"] = GetContainingInlinedBlock - if _newclass: inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''') - - __swig_getmethods__["range"] = get_ranges_access_object - if _newclass: range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''') - - __swig_getmethods__["ranges"] = get_ranges_array - if _newclass: ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''') - - __swig_getmethods__["num_ranges"] = GetNumRanges - if _newclass: num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''') - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBBreakpoint.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBBreakpoint.i +++ lldb/trunk/scripts/Python/interface/SBBreakpoint.i @@ -1,266 +0,0 @@ -//===-- SWIG Interface for SBBreakpoint -------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a logical breakpoint and its associated settings. - -For example (from test/functionalities/breakpoint/breakpoint_ignore_count/ -TestBreakpointIgnoreCount.py), - - def breakpoint_ignore_count_python(self): - '''Use Python APIs to set breakpoint ignore count.''' - exe = os.path.join(os.getcwd(), 'a.out') - - # Create a target by the debugger. - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - # Now create a breakpoint on main.c by name 'c'. - breakpoint = target.BreakpointCreateByName('c', 'a.out') - self.assertTrue(breakpoint and - breakpoint.GetNumLocations() == 1, - VALID_BREAKPOINT) - - # Get the breakpoint location from breakpoint after we verified that, - # indeed, it has one location. - location = breakpoint.GetLocationAtIndex(0) - self.assertTrue(location and - location.IsEnabled(), - VALID_BREAKPOINT_LOCATION) - - # Set the ignore count on the breakpoint location. - location.SetIgnoreCount(2) - self.assertTrue(location.GetIgnoreCount() == 2, - 'SetIgnoreCount() works correctly') - - # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(process, PROCESS_IS_VALID) - - # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and - # frame#2 should be on main.c:48. - #lldbutil.print_stacktraces(process) - from lldbutil import get_stopped_thread - thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) - self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint') - frame0 = thread.GetFrameAtIndex(0) - frame1 = thread.GetFrameAtIndex(1) - frame2 = thread.GetFrameAtIndex(2) - self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and - frame1.GetLineEntry().GetLine() == self.line3 and - frame2.GetLineEntry().GetLine() == self.line4, - STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT) - - # The hit count for the breakpoint should be 3. - self.assertTrue(breakpoint.GetHitCount() == 3) - - process.Continue() - -SBBreakpoint supports breakpoint location iteration, for example, - - for bl in breakpoint: - print 'breakpoint location load addr: %s' % hex(bl.GetLoadAddress()) - print 'breakpoint location condition: %s' % hex(bl.GetCondition()) - -and rich comparion methods which allow the API program to use, - - if aBreakpoint == bBreakpoint: - ... - -to compare two breakpoints for equality." -) SBBreakpoint; -class SBBreakpoint -{ -public: - - typedef bool (*BreakpointHitCallback) (void *baton, - SBProcess &process, - SBThread &thread, - lldb::SBBreakpointLocation &location); - - SBBreakpoint (); - - SBBreakpoint (const lldb::SBBreakpoint& rhs); - - ~SBBreakpoint(); - - break_id_t - GetID () const; - - bool - IsValid() const; - - void - ClearAllBreakpointSites (); - - lldb::SBBreakpointLocation - FindLocationByAddress (lldb::addr_t vm_addr); - - lldb::break_id_t - FindLocationIDByAddress (lldb::addr_t vm_addr); - - lldb::SBBreakpointLocation - FindLocationByID (lldb::break_id_t bp_loc_id); - - lldb::SBBreakpointLocation - GetLocationAtIndex (uint32_t index); - - void - SetEnabled (bool enable); - - bool - IsEnabled (); - - void - SetOneShot (bool one_shot); - - bool - IsOneShot (); - - bool - IsInternal (); - - uint32_t - GetHitCount () const; - - void - SetIgnoreCount (uint32_t count); - - uint32_t - GetIgnoreCount () const; - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// The breakpoint stops only if the condition expression evaluates to true. - //-------------------------------------------------------------------------- - ") SetCondition; - void - SetCondition (const char *condition); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get the condition expression for the breakpoint. - //------------------------------------------------------------------ - ") GetCondition; - const char * - GetCondition (); - - void - SetThreadID (lldb::tid_t sb_thread_id); - - lldb::tid_t - GetThreadID (); - - void - SetThreadIndex (uint32_t index); - - uint32_t - GetThreadIndex() const; - - void - SetThreadName (const char *thread_name); - - const char * - GetThreadName () const; - - void - SetQueueName (const char *queue_name); - - const char * - GetQueueName () const; - - %feature("docstring", " - //------------------------------------------------------------------ - /// Set the name of the script function to be called when the breakpoint is hit. - //------------------------------------------------------------------ - ") SetScriptCallbackFunction; - void - SetScriptCallbackFunction (const char *callback_function_name); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Provide the body for the script function to be called when the breakpoint is hit. - /// The body will be wrapped in a function, which be passed two arguments: - /// 'frame' - which holds the bottom-most SBFrame of the thread that hit the breakpoint - /// 'bpno' - which is the SBBreakpointLocation to which the callback was attached. - /// - /// The error parameter is currently ignored, but will at some point hold the Python - /// compilation diagnostics. - /// Returns true if the body compiles successfully, false if not. - //------------------------------------------------------------------ - ") SetScriptCallbackBody; - SBError - SetScriptCallbackBody (const char *script_body_text); - - bool - AddName (const char *new_name); - - void - RemoveName (const char *name_to_remove); - - bool - MatchesName (const char *name); - - void - GetNames (SBStringList &names); - - size_t - GetNumResolvedLocations() const; - - size_t - GetNumLocations() const; - - bool - GetDescription (lldb::SBStream &description); - - bool - operator == (const lldb::SBBreakpoint& rhs); - - bool - operator != (const lldb::SBBreakpoint& rhs); - - static bool - EventIsBreakpointEvent (const lldb::SBEvent &event); - - static lldb::BreakpointEventType - GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event); - - static lldb::SBBreakpoint - GetBreakpointFromEvent (const lldb::SBEvent& event); - - static lldb::SBBreakpointLocation - GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx); - - static uint32_t - GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event_sp); - - %pythoncode %{ - - __swig_getmethods__["id"] = GetID - if _newclass: id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''') - - __swig_getmethods__["enabled"] = IsEnabled - __swig_setmethods__["enabled"] = SetEnabled - if _newclass: enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''') - - __swig_getmethods__["one_shot"] = IsOneShot - __swig_setmethods__["one_shot"] = SetOneShot - if _newclass: one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''') - - __swig_getmethods__["num_locations"] = GetNumLocations - if _newclass: num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''') - - %} - - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i +++ lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i @@ -1,130 +0,0 @@ -//===-- SWIG Interface for SBBreakpointLocation -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents one unique instance (by address) of a logical breakpoint. - -A breakpoint location is defined by the breakpoint that produces it, -and the address that resulted in this particular instantiation. -Each breakpoint location has its settable options. - -SBBreakpoint contains SBBreakpointLocation(s). See docstring of SBBreakpoint -for retrieval of an SBBreakpointLocation from an SBBreakpoint." -) SBBreakpointLocation; -class SBBreakpointLocation -{ -public: - - SBBreakpointLocation (); - - SBBreakpointLocation (const lldb::SBBreakpointLocation &rhs); - - ~SBBreakpointLocation (); - - break_id_t - GetID (); - - bool - IsValid() const; - - lldb::SBAddress - GetAddress(); - - lldb::addr_t - GetLoadAddress (); - - void - SetEnabled(bool enabled); - - bool - IsEnabled (); - - uint32_t - GetIgnoreCount (); - - void - SetIgnoreCount (uint32_t n); - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// The breakpoint location stops only if the condition expression evaluates - /// to true. - //-------------------------------------------------------------------------- - ") SetCondition; - void - SetCondition (const char *condition); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get the condition expression for the breakpoint location. - //------------------------------------------------------------------ - ") GetCondition; - const char * - GetCondition (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Set the callback to the given Python function name. - //------------------------------------------------------------------ - ") SetScriptCallbackFunction; - void - SetScriptCallbackFunction (const char *callback_function_name); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Provide the body for the script function to be called when the breakpoint location is hit. - /// The body will be wrapped in a function, which be passed two arguments: - /// 'frame' - which holds the bottom-most SBFrame of the thread that hit the breakpoint - /// 'bpno' - which is the SBBreakpointLocation to which the callback was attached. - /// - /// The error parameter is currently ignored, but will at some point hold the Python - /// compilation diagnostics. - /// Returns true if the body compiles successfully, false if not. - //------------------------------------------------------------------ - ") SetScriptCallbackBody; - SBError - SetScriptCallbackBody (const char *script_body_text); - - void - SetThreadID (lldb::tid_t sb_thread_id); - - lldb::tid_t - GetThreadID (); - - void - SetThreadIndex (uint32_t index); - - uint32_t - GetThreadIndex() const; - - void - SetThreadName (const char *thread_name); - - const char * - GetThreadName () const; - - void - SetQueueName (const char *queue_name); - - const char * - GetQueueName () const; - - bool - IsResolved (); - - bool - GetDescription (lldb::SBStream &description, DescriptionLevel level); - - SBBreakpoint - GetBreakpoint (); -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBBroadcaster.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBBroadcaster.i +++ lldb/trunk/scripts/Python/interface/SBBroadcaster.i @@ -1,68 +0,0 @@ -//===-- SWIG Interface for SBBroadcaster ------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents an entity which can broadcast events. A default broadcaster is -associated with an SBCommandInterpreter, SBProcess, and SBTarget. For -example, use - - broadcaster = process.GetBroadcaster() - -to retrieve the process's broadcaster. - -See also SBEvent for example usage of interacting with a broadcaster." -) SBBroadcaster; -class SBBroadcaster -{ -public: - SBBroadcaster (); - - SBBroadcaster (const char *name); - - SBBroadcaster (const SBBroadcaster &rhs); - - ~SBBroadcaster(); - - bool - IsValid () const; - - void - Clear (); - - void - BroadcastEventByType (uint32_t event_type, bool unique = false); - - void - BroadcastEvent (const lldb::SBEvent &event, bool unique = false); - - void - AddInitialEventsToListener (const lldb::SBListener &listener, uint32_t requested_events); - - uint32_t - AddListener (const lldb::SBListener &listener, uint32_t event_mask); - - const char * - GetName () const; - - bool - EventTypeHasListeners (uint32_t event_type); - - bool - RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX); - - bool - operator == (const lldb::SBBroadcaster &rhs) const; - - bool - operator != (const lldb::SBBroadcaster &rhs) const; -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i +++ lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i @@ -1,218 +0,0 @@ -//===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"SBCommandInterpreterRunOptions controls how the RunCommandInterpreter runs the code it is fed. -A default SBCommandInterpreterRunOptions object has: - StopOnContinue: false - StopOnError: false - StopOnCrash: false - EchoCommands: true - PrintResults: true - AddToHistory: true - - -") SBCommandInterpreterRunOptions; -class SBCommandInterpreterRunOptions -{ -friend class SBDebugger; -public: - SBCommandInterpreterRunOptions(); - ~SBCommandInterpreterRunOptions(); - - bool - GetStopOnContinue () const; - - void - SetStopOnContinue (bool); - - bool - GetStopOnError () const; - - void - SetStopOnError (bool); - - bool - GetStopOnCrash () const; - - void - SetStopOnCrash (bool); - - bool - GetEchoCommands () const; - - void - SetEchoCommands (bool); - - bool - GetPrintResults () const; - - void - SetPrintResults (bool); - - bool - GetAddToHistory () const; - - void - SetAddToHistory (bool); -private: - lldb_private::CommandInterpreterRunOptions * - get () const; - - lldb_private::CommandInterpreterRunOptions & - ref () const; - - // This is set in the constructor and will always be valid. - mutable std::unique_ptr m_opaque_up; -}; - -%feature("docstring", -"SBCommandInterpreter handles/interprets commands for lldb. You get the -command interpreter from the SBDebugger instance. For example (from test/ -python_api/interpreter/TestCommandInterpreterAPI.py), - - def command_interpreter_api(self): - '''Test the SBCommandInterpreter APIs.''' - exe = os.path.join(os.getcwd(), 'a.out') - - # Create a target by the debugger. - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - # Retrieve the associated command interpreter from our debugger. - ci = self.dbg.GetCommandInterpreter() - self.assertTrue(ci, VALID_COMMAND_INTERPRETER) - - # Exercise some APIs.... - - self.assertTrue(ci.HasCommands()) - self.assertTrue(ci.HasAliases()) - self.assertTrue(ci.HasAliasOptions()) - self.assertTrue(ci.CommandExists('breakpoint')) - self.assertTrue(ci.CommandExists('target')) - self.assertTrue(ci.CommandExists('platform')) - self.assertTrue(ci.AliasExists('file')) - self.assertTrue(ci.AliasExists('run')) - self.assertTrue(ci.AliasExists('bt')) - - res = lldb.SBCommandReturnObject() - ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res) - self.assertTrue(res.Succeeded()) - ci.HandleCommand('process launch', res) - self.assertTrue(res.Succeeded()) - - process = ci.GetProcess() - self.assertTrue(process) - - ... - -The HandleCommand() instance method takes two args: the command string and -an SBCommandReturnObject instance which encapsulates the result of command -execution. -") SBCommandInterpreter; -class SBCommandInterpreter -{ -public: - enum - { - eBroadcastBitThreadShouldExit = (1 << 0), - eBroadcastBitResetPrompt = (1 << 1), - eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit - eBroadcastBitAsynchronousOutputData = (1 << 3), - eBroadcastBitAsynchronousErrorData = (1 << 4) - }; - - SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs); - - ~SBCommandInterpreter (); - - static const char * - GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); - - static const char * - GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type); - - static bool - EventIsCommandInterpreterEvent (const lldb::SBEvent &event); - - bool - IsValid() const; - - const char * - GetIOHandlerControlSequence(char ch); - - bool - GetPromptOnQuit(); - - void - SetPromptOnQuit(bool b); - - void - ResolveCommand(const char *command_line, SBCommandReturnObject &result); - - bool - CommandExists (const char *cmd); - - bool - AliasExists (const char *cmd); - - lldb::SBBroadcaster - GetBroadcaster (); - - static const char * - GetBroadcasterClass (); - - bool - HasCommands (); - - bool - HasAliases (); - - bool - HasAliasOptions (); - - lldb::SBProcess - GetProcess (); - - lldb::SBDebugger - GetDebugger (); - - void - SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result); - - void - SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result); - - lldb::ReturnStatus - HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false); - - lldb::ReturnStatus - HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history = false); - - void - HandleCommandsFromFile (lldb::SBFileSpec &file, - lldb::SBExecutionContext &override_context, - lldb::SBCommandInterpreterRunOptions &options, - lldb::SBCommandReturnObject result); - - int - HandleCompletion (const char *current_line, - uint32_t cursor_pos, - int match_start_point, - int max_return_elements, - lldb::SBStringList &matches); - - bool - IsActive (); - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i +++ lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i @@ -1,107 +0,0 @@ -//===-- SWIG Interface for SBCommandReturnObject ----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a container which holds the result from command execution. -It works with SBCommandInterpreter.HandleCommand() to encapsulate the result -of command execution. - -See SBCommandInterpreter for example usage of SBCommandReturnObject." -) SBCommandReturnObject; -class SBCommandReturnObject -{ -public: - - SBCommandReturnObject (); - - SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs); - - ~SBCommandReturnObject (); - - bool - IsValid() const; - - const char * - GetOutput (); - - const char * - GetError (); - - size_t - GetOutputSize (); - - size_t - GetErrorSize (); - - const char * - GetOutput (bool only_if_no_immediate); - - const char * - GetError (bool if_no_immediate); - - size_t - PutOutput (FILE *fh); - - size_t - PutError (FILE *fh); - - void - Clear(); - - void - SetStatus (lldb::ReturnStatus status); - - void - SetError (lldb::SBError &error, - const char *fallback_error_cstr = NULL); - - void - SetError (const char *error_cstr); - - lldb::ReturnStatus - GetStatus(); - - bool - Succeeded (); - - bool - HasResult (); - - void - AppendMessage (const char *message); - - void - AppendWarning (const char *message); - - bool - GetDescription (lldb::SBStream &description); - - void - SetImmediateOutputFile (FILE *fh); - - void - SetImmediateErrorFile (FILE *fh); - - void - PutCString(const char* string, int len); - - // wrapping the variadic Printf() with a plain Print() - // because it is hard to support varargs in SWIG bridgings - %extend { - void Print (const char* str) - { - self->Printf("%s", str); - } - } - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBCommunication.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBCommunication.i +++ lldb/trunk/scripts/Python/interface/SBCommunication.i @@ -1,82 +0,0 @@ -//===-- SWIG Interface for SBCommunication ----------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBCommunication -{ -public: - enum { - eBroadcastBitDisconnected = (1 << 0), ///< Sent when the communications connection is lost. - eBroadcastBitReadThreadGotBytes = (1 << 1), ///< Sent by the read thread when bytes become available. - eBroadcastBitReadThreadDidExit = (1 << 2), ///< Sent by the read thread when it exits to inform clients. - eBroadcastBitReadThreadShouldExit = (1 << 3), ///< Sent by clients that need to cancel the read thread. - eBroadcastBitPacketAvailable = (1 << 4), ///< Sent when data received makes a complete packet. - eAllEventBits = 0xffffffff - }; - - typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len); - - SBCommunication (); - SBCommunication (const char * broadcaster_name); - ~SBCommunication (); - - - bool - IsValid () const; - - lldb::SBBroadcaster - GetBroadcaster (); - - static const char *GetBroadcasterClass(); - - lldb::ConnectionStatus - AdoptFileDesriptor (int fd, bool owns_fd); - - lldb::ConnectionStatus - Connect (const char *url); - - lldb::ConnectionStatus - Disconnect (); - - bool - IsConnected () const; - - bool - GetCloseOnEOF (); - - void - SetCloseOnEOF (bool b); - - size_t - Read (void *dst, - size_t dst_len, - uint32_t timeout_usec, - lldb::ConnectionStatus &status); - - size_t - Write (const void *src, - size_t src_len, - lldb::ConnectionStatus &status); - - bool - ReadThreadStart (); - - bool - ReadThreadStop (); - - bool - ReadThreadIsRunning (); - - bool - SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback, - void *callback_baton); -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBCompileUnit.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBCompileUnit.i +++ lldb/trunk/scripts/Python/interface/SBCompileUnit.i @@ -1,130 +0,0 @@ -//===-- SWIG Interface for SBCompileUnit ------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a compilation unit, or compiled source file. - -SBCompileUnit supports line entry iteration. For example, - - # Now get the SBSymbolContext from this frame. We want everything. :-) - context = frame0.GetSymbolContext(lldb.eSymbolContextEverything) - ... - - compileUnit = context.GetCompileUnit() - - for lineEntry in compileUnit: - print 'line entry: %s:%d' % (str(lineEntry.GetFileSpec()), - lineEntry.GetLine()) - print 'start addr: %s' % str(lineEntry.GetStartAddress()) - print 'end addr: %s' % str(lineEntry.GetEndAddress()) - -produces: - -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:20 -start addr: a.out[0x100000d98] -end addr: a.out[0x100000da3] -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:21 -start addr: a.out[0x100000da3] -end addr: a.out[0x100000da9] -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:22 -start addr: a.out[0x100000da9] -end addr: a.out[0x100000db6] -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:23 -start addr: a.out[0x100000db6] -end addr: a.out[0x100000dbc] -... - -See also SBSymbolContext and SBLineEntry" -) SBCompileUnit; -class SBCompileUnit -{ -public: - - SBCompileUnit (); - - SBCompileUnit (const lldb::SBCompileUnit &rhs); - - ~SBCompileUnit (); - - bool - IsValid () const; - - lldb::SBFileSpec - GetFileSpec () const; - - uint32_t - GetNumLineEntries () const; - - lldb::SBLineEntry - GetLineEntryAtIndex (uint32_t idx) const; - - uint32_t - FindLineEntryIndex (uint32_t start_idx, - uint32_t line, - lldb::SBFileSpec *inline_file_spec) const; - - uint32_t - FindLineEntryIndex (uint32_t start_idx, - uint32_t line, - lldb::SBFileSpec *inline_file_spec, - bool exact) const; - - SBFileSpec - GetSupportFileAtIndex (uint32_t idx) const; - - uint32_t - GetNumSupportFiles () const; - - uint32_t - FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get all types matching \a type_mask from debug info in this - /// compile unit. - /// - /// @param[in] type_mask - /// A bitfield that consists of one or more bits logically OR'ed - /// together from the lldb::TypeClass enumeration. This allows - /// you to request only structure types, or only class, struct - /// and union types. Passing in lldb::eTypeClassAny will return - /// all types found in the debug information for this compile - /// unit. - /// - /// @return - /// A list of types in this compile unit that match \a type_mask - //------------------------------------------------------------------ - ") GetTypes; - lldb::SBTypeList - GetTypes (uint32_t type_mask = lldb::eTypeClassAny); - - lldb::LanguageType - GetLanguage (); - - bool - GetDescription (lldb::SBStream &description); - - bool - operator == (const lldb::SBCompileUnit &rhs) const; - - bool - operator != (const lldb::SBCompileUnit &rhs) const; - - %pythoncode %{ - __swig_getmethods__["file"] = GetFileSpec - if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns the same result an lldb object that represents the source file (lldb.SBFileSpec) for the compile unit.''') - - __swig_getmethods__["num_line_entries"] = GetNumLineEntries - if _newclass: num_line_entries = property(GetNumLineEntries, None, doc='''A read only property that returns the number of line entries in a compile unit as an integer.''') - %} -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBData.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBData.i +++ lldb/trunk/scripts/Python/interface/SBData.i @@ -1,340 +0,0 @@ -//===-- SWIG Interface for SBData -------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - - -namespace lldb { - -class SBData -{ -public: - - SBData (); - - SBData (const SBData &rhs); - - ~SBData (); - - uint8_t - GetAddressByteSize (); - - void - SetAddressByteSize (uint8_t addr_byte_size); - - void - Clear (); - - bool - IsValid(); - - size_t - GetByteSize (); - - lldb::ByteOrder - GetByteOrder(); - - void - SetByteOrder (lldb::ByteOrder endian); - - float - GetFloat (lldb::SBError& error, lldb::offset_t offset); - - double - GetDouble (lldb::SBError& error, lldb::offset_t offset); - - long double - GetLongDouble (lldb::SBError& error, lldb::offset_t offset); - - lldb::addr_t - GetAddress (lldb::SBError& error, lldb::offset_t offset); - - uint8_t - GetUnsignedInt8 (lldb::SBError& error, lldb::offset_t offset); - - uint16_t - GetUnsignedInt16 (lldb::SBError& error, lldb::offset_t offset); - - uint32_t - GetUnsignedInt32 (lldb::SBError& error, lldb::offset_t offset); - - uint64_t - GetUnsignedInt64 (lldb::SBError& error, lldb::offset_t offset); - - int8_t - GetSignedInt8 (lldb::SBError& error, lldb::offset_t offset); - - int16_t - GetSignedInt16 (lldb::SBError& error, lldb::offset_t offset); - - int32_t - GetSignedInt32 (lldb::SBError& error, lldb::offset_t offset); - - int64_t - GetSignedInt64 (lldb::SBError& error, lldb::offset_t offset); - - const char* - GetString (lldb::SBError& error, lldb::offset_t offset); - - bool - GetDescription (lldb::SBStream &description, lldb::addr_t base_addr); - - size_t - ReadRawData (lldb::SBError& error, - lldb::offset_t offset, - void *buf, - size_t size); - - void - SetData (lldb::SBError& error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size); - - bool - Append (const SBData& rhs); - - static lldb::SBData - CreateDataFromCString (lldb::ByteOrder endian, uint32_t addr_byte_size, const char* data); - - // in the following CreateData*() and SetData*() prototypes, the two parameters array and array_len - // should not be renamed or rearranged, because doing so will break the SWIG typemap - static lldb::SBData - CreateDataFromUInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t* array, size_t array_len); - - static lldb::SBData - CreateDataFromUInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint32_t* array, size_t array_len); - - static lldb::SBData - CreateDataFromSInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int64_t* array, size_t array_len); - - static lldb::SBData - CreateDataFromSInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int32_t* array, size_t array_len); - - static lldb::SBData - CreateDataFromDoubleArray (lldb::ByteOrder endian, uint32_t addr_byte_size, double* array, size_t array_len); - - bool - SetDataFromCString (const char* data); - - bool - SetDataFromUInt64Array (uint64_t* array, size_t array_len); - - bool - SetDataFromUInt32Array (uint32_t* array, size_t array_len); - - bool - SetDataFromSInt64Array (int64_t* array, size_t array_len); - - bool - SetDataFromSInt32Array (int32_t* array, size_t array_len); - - bool - SetDataFromDoubleArray (double* array, size_t array_len); - - %pythoncode %{ - - class read_data_helper: - def __init__(self, sbdata, readerfunc, item_size): - self.sbdata = sbdata - self.readerfunc = readerfunc - self.item_size = item_size - def __getitem__(self,key): - if isinstance(key,slice): - list = [] - for x in range(*key.indices(self.__len__())): - list.append(self.__getitem__(x)) - return list - if not (isinstance(key,(int,long))): - raise TypeError('must be int') - key = key * self.item_size # SBData uses byte-based indexes, but we want to use itemsize-based indexes here - error = SBError() - my_data = self.readerfunc(self.sbdata,error,key) - if error.Fail(): - raise IndexError(error.GetCString()) - else: - return my_data - def __len__(self): - return int(self.sbdata.GetByteSize()/self.item_size) - def all(self): - return self[0:len(self)] - - @classmethod - def CreateDataFromInt (cls, value, size = None, target = None, ptr_size = None, endian = None): - import sys - lldbmodule = sys.modules[cls.__module__] - lldbdict = lldbmodule.__dict__ - if 'target' in lldbdict: - lldbtarget = lldbdict['target'] - else: - lldbtarget = None - if target == None and lldbtarget != None and lldbtarget.IsValid(): - target = lldbtarget - if ptr_size == None: - if target and target.IsValid(): - ptr_size = target.addr_size - else: - ptr_size = 8 - if endian == None: - if target and target.IsValid(): - endian = target.byte_order - else: - endian = lldbdict['eByteOrderLittle'] - if size == None: - if value > 2147483647: - size = 8 - elif value < -2147483648: - size = 8 - elif value > 4294967295: - size = 8 - else: - size = 4 - if size == 4: - if value < 0: - return SBData().CreateDataFromSInt32Array(endian, ptr_size, [value]) - return SBData().CreateDataFromUInt32Array(endian, ptr_size, [value]) - if size == 8: - if value < 0: - return SBData().CreateDataFromSInt64Array(endian, ptr_size, [value]) - return SBData().CreateDataFromUInt64Array(endian, ptr_size, [value]) - return None - - def _make_helper(self, sbdata, getfunc, itemsize): - return self.read_data_helper(sbdata, getfunc, itemsize) - - def _make_helper_uint8(self): - return self._make_helper(self, SBData.GetUnsignedInt8, 1) - - def _make_helper_uint16(self): - return self._make_helper(self, SBData.GetUnsignedInt16, 2) - - def _make_helper_uint32(self): - return self._make_helper(self, SBData.GetUnsignedInt32, 4) - - def _make_helper_uint64(self): - return self._make_helper(self, SBData.GetUnsignedInt64, 8) - - def _make_helper_sint8(self): - return self._make_helper(self, SBData.GetSignedInt8, 1) - - def _make_helper_sint16(self): - return self._make_helper(self, SBData.GetSignedInt16, 2) - - def _make_helper_sint32(self): - return self._make_helper(self, SBData.GetSignedInt32, 4) - - def _make_helper_sint64(self): - return self._make_helper(self, SBData.GetSignedInt64, 8) - - def _make_helper_float(self): - return self._make_helper(self, SBData.GetFloat, 4) - - def _make_helper_double(self): - return self._make_helper(self, SBData.GetDouble, 8) - - def _read_all_uint8(self): - return self._make_helper_uint8().all() - - def _read_all_uint16(self): - return self._make_helper_uint16().all() - - def _read_all_uint32(self): - return self._make_helper_uint32().all() - - def _read_all_uint64(self): - return self._make_helper_uint64().all() - - def _read_all_sint8(self): - return self._make_helper_sint8().all() - - def _read_all_sint16(self): - return self._make_helper_sint16().all() - - def _read_all_sint32(self): - return self._make_helper_sint32().all() - - def _read_all_sint64(self): - return self._make_helper_sint64().all() - - def _read_all_float(self): - return self._make_helper_float().all() - - def _read_all_double(self): - return self._make_helper_double().all() - - __swig_getmethods__["uint8"] = _make_helper_uint8 - if _newclass: uint8 = property(_make_helper_uint8, None, doc='''A read only property that returns an array-like object out of which you can read uint8 values.''') - - __swig_getmethods__["uint16"] = _make_helper_uint16 - if _newclass: uint16 = property(_make_helper_uint16, None, doc='''A read only property that returns an array-like object out of which you can read uint16 values.''') - - __swig_getmethods__["uint32"] = _make_helper_uint32 - if _newclass: uint32 = property(_make_helper_uint32, None, doc='''A read only property that returns an array-like object out of which you can read uint32 values.''') - - __swig_getmethods__["uint64"] = _make_helper_uint64 - if _newclass: uint64 = property(_make_helper_uint64, None, doc='''A read only property that returns an array-like object out of which you can read uint64 values.''') - - __swig_getmethods__["sint8"] = _make_helper_sint8 - if _newclass: sint8 = property(_make_helper_sint8, None, doc='''A read only property that returns an array-like object out of which you can read sint8 values.''') - - __swig_getmethods__["sint16"] = _make_helper_sint16 - if _newclass: sint16 = property(_make_helper_sint16, None, doc='''A read only property that returns an array-like object out of which you can read sint16 values.''') - - __swig_getmethods__["sint32"] = _make_helper_sint32 - if _newclass: sint32 = property(_make_helper_sint32, None, doc='''A read only property that returns an array-like object out of which you can read sint32 values.''') - - __swig_getmethods__["sint64"] = _make_helper_sint64 - if _newclass: sint64 = property(_make_helper_sint64, None, doc='''A read only property that returns an array-like object out of which you can read sint64 values.''') - - __swig_getmethods__["float"] = _make_helper_float - if _newclass: float = property(_make_helper_float, None, doc='''A read only property that returns an array-like object out of which you can read float values.''') - - __swig_getmethods__["double"] = _make_helper_double - if _newclass: double = property(_make_helper_double, None, doc='''A read only property that returns an array-like object out of which you can read double values.''') - - __swig_getmethods__["uint8s"] = _read_all_uint8 - if _newclass: uint8s = property(_read_all_uint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint8 values.''') - - __swig_getmethods__["uint16s"] = _read_all_uint16 - if _newclass: uint16s = property(_read_all_uint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint16 values.''') - - __swig_getmethods__["uint32s"] = _read_all_uint32 - if _newclass: uint32s = property(_read_all_uint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint32 values.''') - - __swig_getmethods__["uint64s"] = _read_all_uint64 - if _newclass: uint64s = property(_read_all_uint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint64 values.''') - - __swig_getmethods__["sint8s"] = _read_all_sint8 - if _newclass: sint8s = property(_read_all_sint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint8 values.''') - - __swig_getmethods__["sint16s"] = _read_all_sint16 - if _newclass: sint16s = property(_read_all_sint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint16 values.''') - - __swig_getmethods__["sint32s"] = _read_all_sint32 - if _newclass: sint32s = property(_read_all_sint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint32 values.''') - - __swig_getmethods__["sint64s"] = _read_all_sint64 - if _newclass: sint64s = property(_read_all_sint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint64 values.''') - - __swig_getmethods__["floats"] = _read_all_float - if _newclass: floats = property(_read_all_float, None, doc='''A read only property that returns an array with all the contents of this SBData represented as float values.''') - - __swig_getmethods__["doubles"] = _read_all_double - if _newclass: doubles = property(_read_all_double, None, doc='''A read only property that returns an array with all the contents of this SBData represented as double values.''') - - %} - - %pythoncode %{ - __swig_getmethods__["byte_order"] = GetByteOrder - __swig_setmethods__["byte_order"] = SetByteOrder - if _newclass: byte_order = property(GetByteOrder, SetByteOrder, doc='''A read/write property getting and setting the endianness of this SBData (data.byte_order = lldb.eByteOrderLittle).''') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size the same result as GetByteSize().''') - - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBDebugger.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBDebugger.i +++ lldb/trunk/scripts/Python/interface/SBDebugger.i @@ -1,382 +0,0 @@ -//===-- SWIG Interface for SBDebugger ---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"SBDebugger is the primordial object that creates SBTargets and provides -access to them. It also manages the overall debugging experiences. - -For example (from example/disasm.py), - -import lldb -import os -import sys - -def disassemble_instructions (insts): - for i in insts: - print i - -... - -# Create a new debugger instance -debugger = lldb.SBDebugger.Create() - -# When we step or continue, don't return from the function until the process -# stops. We do this by setting the async mode to false. -debugger.SetAsync (False) - -# Create a target from a file and arch -print 'Creating a target for \'%s\'' % exe - -target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT) - -if target: - # If the target is valid set a breakpoint at main - main_bp = target.BreakpointCreateByName (fname, target.GetExecutable().GetFilename()); - - print main_bp - - # Launch the process. Since we specified synchronous mode, we won't return - # from this function until we hit the breakpoint at main - process = target.LaunchSimple (None, None, os.getcwd()) - - # Make sure the launch went ok - if process: - # Print some simple process info - state = process.GetState () - print process - if state == lldb.eStateStopped: - # Get the first thread - thread = process.GetThreadAtIndex (0) - if thread: - # Print some simple thread info - print thread - # Get the first frame - frame = thread.GetFrameAtIndex (0) - if frame: - # Print some simple frame info - print frame - function = frame.GetFunction() - # See if we have debug info (a function) - if function: - # We do have a function, print some info for the function - print function - # Now get all instructions for this function and print them - insts = function.GetInstructions(target) - disassemble_instructions (insts) - else: - # See if we have a symbol in the symbol table for where we stopped - symbol = frame.GetSymbol(); - if symbol: - # We do have a symbol, print some info for the symbol - print symbol - # Now get all instructions for this symbol and print them - insts = symbol.GetInstructions(target) - disassemble_instructions (insts) - - registerList = frame.GetRegisters() - print 'Frame registers (size of register set = %d):' % registerList.GetSize() - for value in registerList: - #print value - print '%s (number of children = %d):' % (value.GetName(), value.GetNumChildren()) - for child in value: - print 'Name: ', child.GetName(), ' Value: ', child.GetValue() - - print 'Hit the breakpoint at main, enter to continue and wait for program to exit or \'Ctrl-D\'/\'quit\' to terminate the program' - next = sys.stdin.readline() - if not next or next.rstrip('\n') == 'quit': - print 'Terminating the inferior process...' - process.Kill() - else: - # Now continue to the program exit - process.Continue() - # When we return from the above function we will hopefully be at the - # program exit. Print out some process info - print process - elif state == lldb.eStateExited: - print 'Didn\'t hit the breakpoint at main, program has exited...' - else: - print 'Unexpected process state: %s, killing process...' % debugger.StateAsCString (state) - process.Kill() -") SBDebugger; -class SBDebugger -{ -public: - - static void - Initialize(); - - static void - Terminate(); - - static lldb::SBDebugger - Create(); - - static lldb::SBDebugger - Create(bool source_init_files); - - static lldb::SBDebugger - Create(bool source_init_files, lldb::LogOutputCallback log_callback, void *baton); - - static void - Destroy (lldb::SBDebugger &debugger); - - static void - MemoryPressureDetected(); - - SBDebugger(); - - SBDebugger(const lldb::SBDebugger &rhs); - - ~SBDebugger(); - - bool - IsValid() const; - - void - Clear (); - - void - SetAsync (bool b); - - bool - GetAsync (); - - void - SkipLLDBInitFiles (bool b); - - void - SetInputFileHandle (FILE *f, bool transfer_ownership); - - void - SetOutputFileHandle (FILE *f, bool transfer_ownership); - - void - SetErrorFileHandle (FILE *f, bool transfer_ownership); - - FILE * - GetInputFileHandle (); - - FILE * - GetOutputFileHandle (); - - FILE * - GetErrorFileHandle (); - - lldb::SBCommandInterpreter - GetCommandInterpreter (); - - void - HandleCommand (const char *command); - - lldb::SBListener - GetListener (); - - void - HandleProcessEvent (const lldb::SBProcess &process, - const lldb::SBEvent &event, - FILE *out, - FILE *err); - - lldb::SBTarget - CreateTarget (const char *filename, - const char *target_triple, - const char *platform_name, - bool add_dependent_modules, - lldb::SBError& sb_error); - - lldb::SBTarget - CreateTargetWithFileAndTargetTriple (const char *filename, - const char *target_triple); - - lldb::SBTarget - CreateTargetWithFileAndArch (const char *filename, - const char *archname); - - lldb::SBTarget - CreateTarget (const char *filename); - - %feature("docstring", - "Return true if target is deleted from the target list of the debugger." - ) DeleteTarget; - bool - DeleteTarget (lldb::SBTarget &target); - - lldb::SBTarget - GetTargetAtIndex (uint32_t idx); - - uint32_t - GetIndexOfTarget (lldb::SBTarget target); - - lldb::SBTarget - FindTargetWithProcessID (pid_t pid); - - lldb::SBTarget - FindTargetWithFileAndArch (const char *filename, - const char *arch); - - uint32_t - GetNumTargets (); - - lldb::SBTarget - GetSelectedTarget (); - - void - SetSelectedTarget (lldb::SBTarget &target); - - lldb::SBPlatform - GetSelectedPlatform(); - - void - SetSelectedPlatform(lldb::SBPlatform &platform); - - lldb::SBSourceManager - GetSourceManager (); - - // REMOVE: just for a quick fix, need to expose platforms through - // SBPlatform from this class. - lldb::SBError - SetCurrentPlatform (const char *platform_name); - - bool - SetCurrentPlatformSDKRoot (const char *sysroot); - - // FIXME: Once we get the set show stuff in place, the driver won't need - // an interface to the Set/Get UseExternalEditor. - bool - SetUseExternalEditor (bool input); - - bool - GetUseExternalEditor (); - - bool - SetUseColor (bool use_color); - - bool - GetUseColor () const; - - static bool - GetDefaultArchitecture (char *arch_name, size_t arch_name_len); - - static bool - SetDefaultArchitecture (const char *arch_name); - - lldb::ScriptLanguage - GetScriptingLanguage (const char *script_language_name); - - static const char * - GetVersionString (); - - static const char * - StateAsCString (lldb::StateType state); - - static bool - StateIsRunningState (lldb::StateType state); - - static bool - StateIsStoppedState (lldb::StateType state); - - bool - EnableLog (const char *channel, const char ** types); - - void - SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton); - - void - DispatchInput (const void *data, size_t data_len); - - void - DispatchInputInterrupt (); - - void - DispatchInputEndOfFile (); - - const char * - GetInstanceName (); - - static SBDebugger - FindDebuggerWithID (int id); - - static lldb::SBError - SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name); - - static lldb::SBStringList - GetInternalVariableValue (const char *var_name, const char *debugger_instance_name); - - bool - GetDescription (lldb::SBStream &description); - - uint32_t - GetTerminalWidth () const; - - void - SetTerminalWidth (uint32_t term_width); - - lldb::user_id_t - GetID (); - - const char * - GetPrompt() const; - - void - SetPrompt (const char *prompt); - - lldb::ScriptLanguage - GetScriptLanguage() const; - - void - SetScriptLanguage (lldb::ScriptLanguage script_lang); - - bool - GetCloseInputOnEOF () const; - - void - SetCloseInputOnEOF (bool b); - - lldb::SBTypeCategory - GetCategory (const char* category_name); - - lldb::SBTypeCategory - CreateCategory (const char* category_name); - - bool - DeleteCategory (const char* category_name); - - uint32_t - GetNumCategories (); - - lldb::SBTypeCategory - GetCategoryAtIndex (uint32_t); - - lldb::SBTypeCategory - GetDefaultCategory(); - - lldb::SBTypeFormat - GetFormatForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeSummary - GetSummaryForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeFilter - GetFilterForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeSynthetic - GetSyntheticForType (lldb::SBTypeNameSpecifier); - - void - RunCommandInterpreter (bool auto_handle_events, - bool spawn_thread, - SBCommandInterpreterRunOptions &options, - int &num_errors, - bool &quit_requested, - bool &stopped_for_crash); -}; // class SBDebugger - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBDeclaration.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBDeclaration.i +++ lldb/trunk/scripts/Python/interface/SBDeclaration.i @@ -1,68 +0,0 @@ -//===-- SWIG Interface for SBDeclaration --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", - "Specifies an association with a line and column for a variable." - ) SBDeclaration; - class SBDeclaration - { - public: - - SBDeclaration (); - - SBDeclaration (const lldb::SBDeclaration &rhs); - - ~SBDeclaration (); - - bool - IsValid () const; - - lldb::SBFileSpec - GetFileSpec () const; - - uint32_t - GetLine () const; - - uint32_t - GetColumn () const; - - bool - GetDescription (lldb::SBStream &description); - - void - SetFileSpec (lldb::SBFileSpec filespec); - - void - SetLine (uint32_t line); - - void - SetColumn (uint32_t column); - - bool - operator == (const lldb::SBDeclaration &rhs) const; - - bool - operator != (const lldb::SBDeclaration &rhs) const; - - %pythoncode %{ - __swig_getmethods__["file"] = GetFileSpec - if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''') - - __swig_getmethods__["line"] = GetLine - if _newclass: line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''') - - __swig_getmethods__["column"] = GetColumn - if _newclass: column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''') - %} - - }; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBError.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBError.i +++ lldb/trunk/scripts/Python/interface/SBError.i @@ -1,126 +0,0 @@ -//===-- SWIG Interface for SBError ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a container for holding any error code. - -For example (from test/python_api/hello_world/TestHelloWorld.py), - - def hello_world_attach_with_id_api(self): - '''Create target, spawn a process, and attach to it by id.''' - - target = self.dbg.CreateTarget(self.exe) - - # Spawn a new process and don't display the stdout if not in TraceOn() mode. - import subprocess - popen = subprocess.Popen([self.exe, 'abc', 'xyz'], - stdout = open(os.devnull, 'w') if not self.TraceOn() else None) - - listener = lldb.SBListener('my.attach.listener') - error = lldb.SBError() - process = target.AttachToProcessWithID(listener, popen.pid, error) - - self.assertTrue(error.Success() and process, PROCESS_IS_VALID) - - # Let's check the stack traces of the attached process. - import lldbutil - stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) - self.expect(stacktraces, exe=False, - substrs = ['main.c:%d' % self.line2, - '(int)argc=3']) - - listener = lldb.SBListener('my.attach.listener') - error = lldb.SBError() - process = target.AttachToProcessWithID(listener, popen.pid, error) - - self.assertTrue(error.Success() and process, PROCESS_IS_VALID) - -checks that after the attach, there is no error condition by asserting -that error.Success() is True and we get back a valid process object. - -And (from test/python_api/event/TestEvent.py), - - # Now launch the process, and do not stop at entry point. - error = lldb.SBError() - process = target.Launch(listener, None, None, None, None, None, None, 0, False, error) - self.assertTrue(error.Success() and process, PROCESS_IS_VALID) - -checks that after calling the target.Launch() method there's no error -condition and we get back a void process object. -") SBError; -class SBError { -public: - SBError (); - - SBError (const lldb::SBError &rhs); - - ~SBError(); - - const char * - GetCString () const; - - void - Clear (); - - bool - Fail () const; - - bool - Success () const; - - uint32_t - GetError () const; - - lldb::ErrorType - GetType () const; - - void - SetError (uint32_t err, lldb::ErrorType type); - - void - SetErrorToErrno (); - - void - SetErrorToGenericError (); - - void - SetErrorString (const char *err_str); - - int - SetErrorStringWithFormat (const char *format, ...); - - bool - IsValid () const; - - bool - GetDescription (lldb::SBStream &description); - - %pythoncode %{ - __swig_getmethods__["value"] = GetError - if _newclass: value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''') - - __swig_getmethods__["fail"] = Fail - if _newclass: fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''') - - __swig_getmethods__["success"] = Success - if _newclass: success = property(Success, None, doc='''A read only property that returns the same result as Success().''') - - __swig_getmethods__["description"] = GetCString - if _newclass: description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''') - - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBEvent.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBEvent.i +++ lldb/trunk/scripts/Python/interface/SBEvent.i @@ -1,153 +0,0 @@ -//===-- SWIG Interface for SBEvent ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBBroadcaster; - -%feature("docstring", -"API clients can register to receive events. - -For example, check out the following output: - -Try wait for event... -Event description: 0x103d0bb70 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = running} -Event data flavor: Process::ProcessEventData -Process state: running - -Try wait for event... -Event description: 0x103a700a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = stopped} -Event data flavor: Process::ProcessEventData -Process state: stopped - -Try wait for event... -Event description: 0x103d0d4a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = exited} -Event data flavor: Process::ProcessEventData -Process state: exited - -Try wait for event... -timeout occurred waiting for event... - -from test/python_api/event/TestEventspy: - - def do_listen_for_and_print_event(self): - '''Create a listener and use SBEvent API to print the events received.''' - exe = os.path.join(os.getcwd(), 'a.out') - - # Create a target by the debugger. - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - # Now create a breakpoint on main.c by name 'c'. - breakpoint = target.BreakpointCreateByName('c', 'a.out') - - # Now launch the process, and do not stop at the entry point. - process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(process.GetState() == lldb.eStateStopped, - PROCESS_STOPPED) - - # Get a handle on the process's broadcaster. - broadcaster = process.GetBroadcaster() - - # Create an empty event object. - event = lldb.SBEvent() - - # Create a listener object and register with the broadcaster. - listener = lldb.SBListener('my listener') - rc = broadcaster.AddListener(listener, lldb.SBProcess.eBroadcastBitStateChanged) - self.assertTrue(rc, 'AddListener successfully retruns') - - traceOn = self.TraceOn() - if traceOn: - lldbutil.print_stacktraces(process) - - # Create MyListeningThread class to wait for any kind of event. - import threading - class MyListeningThread(threading.Thread): - def run(self): - count = 0 - # Let's only try at most 4 times to retrieve any kind of event. - # After that, the thread exits. - while not count > 3: - if traceOn: - print 'Try wait for event...' - if listener.WaitForEventForBroadcasterWithType(5, - broadcaster, - lldb.SBProcess.eBroadcastBitStateChanged, - event): - if traceOn: - desc = lldbutil.get_description(event) - print 'Event description:', desc - print 'Event data flavor:', event.GetDataFlavor() - print 'Process state:', lldbutil.state_type_to_str(process.GetState()) - print - else: - if traceOn: - print 'timeout occurred waiting for event...' - count = count + 1 - return - - # Let's start the listening thread to retrieve the events. - my_thread = MyListeningThread() - my_thread.start() - - # Use Python API to continue the process. The listening thread should be - # able to receive the state changed events. - process.Continue() - - # Use Python API to kill the process. The listening thread should be - # able to receive the state changed event, too. - process.Kill() - - # Wait until the 'MyListeningThread' terminates. - my_thread.join() -") SBEvent; -class SBEvent -{ -public: - SBEvent(); - - SBEvent (const lldb::SBEvent &rhs); - - %feature("autodoc", - "__init__(self, int type, str data) -> SBEvent (make an event that contains a C string)" - ) SBEvent; - SBEvent (uint32_t event, const char *cstr, uint32_t cstr_len); - - ~SBEvent(); - - bool - IsValid() const; - - const char * - GetDataFlavor (); - - uint32_t - GetType () const; - - lldb::SBBroadcaster - GetBroadcaster () const; - - const char * - GetBroadcasterClass () const; - - bool - BroadcasterMatchesRef (const lldb::SBBroadcaster &broadcaster); - - void - Clear(); - - static const char * - GetCStringFromEvent (const lldb::SBEvent &event); - - bool - GetDescription (lldb::SBStream &description) const; -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBExecutionContext.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBExecutionContext.i +++ lldb/trunk/scripts/Python/interface/SBExecutionContext.i @@ -1,57 +0,0 @@ -//===-- SWIG Interface for SBExecutionContext ---------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBExecutionContext -{ -public: - SBExecutionContext(); - - SBExecutionContext (const lldb::SBExecutionContext &rhs); - - SBExecutionContext (const lldb::SBTarget &target); - - SBExecutionContext (const lldb::SBProcess &process); - - SBExecutionContext (lldb::SBThread thread); // can't be a const& because SBThread::get() isn't itself a const function - - SBExecutionContext (const lldb::SBFrame &frame); - - ~SBExecutionContext(); - - SBTarget - GetTarget () const; - - SBProcess - GetProcess () const; - - SBThread - GetThread () const; - - SBFrame - GetFrame () const; - - %pythoncode %{ - __swig_getmethods__["target"] = GetTarget - if _newclass: target = property(GetTarget, None, doc='''A read only property that returns the same result as GetTarget().''') - - __swig_getmethods__["process"] = GetProcess - if _newclass: process = property(GetProcess, None, doc='''A read only property that returns the same result as GetProcess().''') - - __swig_getmethods__["thread"] = GetThread - if _newclass: thread = property(GetThread, None, doc='''A read only property that returns the same result as GetThread().''') - - __swig_getmethods__["frame"] = GetFrame - if _newclass: frame = property(GetFrame, None, doc='''A read only property that returns the same result as GetFrame().''') - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBExpressionOptions.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBExpressionOptions.i +++ lldb/trunk/scripts/Python/interface/SBExpressionOptions.i @@ -1,130 +0,0 @@ -//===-- SWIG interface for SBExpressionOptions -----------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"A container for options to use when evaluating expressions." -) SBExpressionOptions; - -class SBExpressionOptions -{ -friend class SBFrame; -friend class SBValue; - -public: - SBExpressionOptions(); - - SBExpressionOptions (const lldb::SBExpressionOptions &rhs); - - ~SBExpressionOptions(); - - bool - GetCoerceResultToId () const; - - %feature("docstring", "Sets whether to coerce the expression result to ObjC id type after evaluation.") SetCoerceResultToId; - - void - SetCoerceResultToId (bool coerce = true); - - bool - GetUnwindOnError () const; - - %feature("docstring", "Sets whether to unwind the expression stack on error.") SetUnwindOnError; - - void - SetUnwindOnError (bool unwind = true); - - bool - GetIgnoreBreakpoints () const; - - %feature("docstring", "Sets whether to ignore breakpoint hits while running expressions.") SetUnwindOnError; - - void - SetIgnoreBreakpoints (bool ignore = true); - - lldb::DynamicValueType - GetFetchDynamicValue () const; - - %feature("docstring", "Sets whether to cast the expression result to its dynamic type.") SetFetchDynamicValue; - - void - SetFetchDynamicValue (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget); - - uint32_t - GetTimeoutInMicroSeconds () const; - - %feature("docstring", "Sets the timeout in microseconds to run the expression for. If try all threads is set to true and the expression doesn't complete within the specified timeout, all threads will be resumed for the same timeout to see if the expresson will finish.") SetTimeoutInMicroSeconds; - void - SetTimeoutInMicroSeconds (uint32_t timeout = 0); - - uint32_t - GetOneThreadTimeoutInMicroSeconds () const; - - %feature("docstring", "Sets the timeout in microseconds to run the expression on one thread before either timing out or trying all threads.") SetTimeoutInMicroSeconds; - void - SetOneThreadTimeoutInMicroSeconds (uint32_t timeout = 0); - - bool - GetTryAllThreads () const; - - %feature("docstring", "Sets whether to run all threads if the expression does not complete on one thread.") SetTryAllThreads; - void - SetTryAllThreads (bool run_others = true); - - bool - GetStopOthers () const; - - %feature("docstring", "Sets whether to stop other threads at all while running expressins. If false, TryAllThreads does nothing.") SetTryAllThreads; - void - SetStopOthers (bool stop_others = true); - - bool - GetTrapExceptions () const; - - %feature("docstring", "Sets whether to abort expression evaluation if an exception is thrown while executing. Don't set this to false unless you know the function you are calling traps all exceptions itself.") SetTryAllThreads; - void - SetTrapExceptions (bool trap_exceptions = true); - - %feature ("docstring", "Sets the language that LLDB should assume the expression is written in") SetLanguage; - void - SetLanguage (lldb::LanguageType language); - - bool - GetGenerateDebugInfo (); - - %feature("docstring", "Sets whether to generate debug information for the expression and also controls if a SBModule is generated.") SetGenerateDebugInfo; - void - SetGenerateDebugInfo (bool b = true); - - bool - GetSuppressPersistentResult (); - - %feature("docstring", "Sets whether to produce a persistent result that can be used in future expressions.") SetSuppressPersistentResult; - void - SetSuppressPersistentResult (bool b = false); - - - -protected: - - SBExpressionOptions (lldb_private::EvaluateExpressionOptions &expression_options); - - lldb_private::EvaluateExpressionOptions * - get () const; - - lldb_private::EvaluateExpressionOptions & - ref () const; - -private: - // This auto_pointer is made in the constructor and is always valid. - mutable std::unique_ptr m_opaque_ap; -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBFileSpec.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBFileSpec.i +++ lldb/trunk/scripts/Python/interface/SBFileSpec.i @@ -1,103 +0,0 @@ -//===-- SWIG Interface for SBFileSpec ---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a file specification that divides the path into a directory and -basename. The string values of the paths are put into uniqued string pools -for fast comparisons and efficient memory usage. - -For example, the following code - - lineEntry = context.GetLineEntry() - self.expect(lineEntry.GetFileSpec().GetDirectory(), 'The line entry should have the correct directory', - exe=False, - substrs = [self.mydir]) - self.expect(lineEntry.GetFileSpec().GetFilename(), 'The line entry should have the correct filename', - exe=False, - substrs = ['main.c']) - self.assertTrue(lineEntry.GetLine() == self.line, - 'The line entry's line number should match ') - -gets the line entry from the symbol context when a thread is stopped. -It gets the file spec corresponding to the line entry and checks that -the filename and the directory matches what we expect. -") SBFileSpec; -class SBFileSpec -{ -public: - SBFileSpec (); - - SBFileSpec (const lldb::SBFileSpec &rhs); - - SBFileSpec (const char *path);// Deprecated, use SBFileSpec (const char *path, bool resolve) - - SBFileSpec (const char *path, bool resolve); - - ~SBFileSpec (); - - bool - IsValid() const; - - bool - Exists () const; - - bool - ResolveExecutableLocation (); - - const char * - GetFilename() const; - - const char * - GetDirectory() const; - - void - SetFilename(const char *filename); - - void - SetDirectory(const char *directory); - - uint32_t - GetPath (char *dst_path, size_t dst_len) const; - - static int - ResolvePath (const char *src_path, char *dst_path, size_t dst_len); - - bool - GetDescription (lldb::SBStream &description) const; - - %pythoncode %{ - def __get_fullpath__(self): - spec_dir = self.GetDirectory() - spec_file = self.GetFilename() - if spec_dir and spec_file: - return '%s/%s' % (spec_dir, spec_file) - elif spec_dir: - return spec_dir - elif spec_file: - return spec_file - return None - - __swig_getmethods__["fullpath"] = __get_fullpath__ - if _newclass: fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''') - - __swig_getmethods__["basename"] = GetFilename - if _newclass: basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''') - - __swig_getmethods__["dirname"] = GetDirectory - if _newclass: dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''') - - __swig_getmethods__["exists"] = Exists - if _newclass: exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''') - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBFileSpecList.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBFileSpecList.i +++ lldb/trunk/scripts/Python/interface/SBFileSpecList.i @@ -1,45 +0,0 @@ -//===-- SWIG Interface for SBFileSpecList -----------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBFileSpecList -{ -public: - SBFileSpecList (); - - SBFileSpecList (const lldb::SBFileSpecList &rhs); - - ~SBFileSpecList (); - - uint32_t - GetSize () const; - - bool - GetDescription (SBStream &description) const; - - void - Append (const SBFileSpec &sb_file); - - bool - AppendIfUnique (const SBFileSpec &sb_file); - - void - Clear(); - - uint32_t - FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full); - - const SBFileSpec - GetFileSpecAtIndex (uint32_t idx) const; - -}; - - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBFrame.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBFrame.i +++ lldb/trunk/scripts/Python/interface/SBFrame.i @@ -1,379 +0,0 @@ -//===-- SWIG Interface for SBFrame ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents one of the stack frames associated with a thread. -SBThread contains SBFrame(s). For example (from test/lldbutil.py), - -def print_stacktrace(thread, string_buffer = False): - '''Prints a simple stack trace of this thread.''' - - ... - - for i in range(depth): - frame = thread.GetFrameAtIndex(i) - function = frame.GetFunction() - - load_addr = addrs[i].GetLoadAddress(target) - if not function: - file_addr = addrs[i].GetFileAddress() - start_addr = frame.GetSymbol().GetStartAddress().GetFileAddress() - symbol_offset = file_addr - start_addr - print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format( - num=i, addr=load_addr, mod=mods[i], symbol=symbols[i], offset=symbol_offset) - else: - print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format( - num=i, addr=load_addr, mod=mods[i], - func='%s [inlined]' % funcs[i] if frame.IsInlined() else funcs[i], - file=files[i], line=lines[i], - args=get_args_as_string(frame, showFuncName=False) if not frame.IsInlined() else '()') - - ... - -And, - - for frame in thread: - print frame - -See also SBThread." -) SBFrame; -class SBFrame -{ -public: - SBFrame (); - - SBFrame (const lldb::SBFrame &rhs); - - ~SBFrame(); - - bool - IsEqual (const lldb::SBFrame &rhs) const; - - bool - IsValid() const; - - uint32_t - GetFrameID () const; - - lldb::addr_t - GetPC () const; - - bool - SetPC (lldb::addr_t new_pc); - - lldb::addr_t - GetSP () const; - - lldb::addr_t - GetFP () const; - - lldb::SBAddress - GetPCAddress () const; - - lldb::SBSymbolContext - GetSymbolContext (uint32_t resolve_scope) const; - - lldb::SBModule - GetModule () const; - - lldb::SBCompileUnit - GetCompileUnit () const; - - lldb::SBFunction - GetFunction () const; - - lldb::SBSymbol - GetSymbol () const; - - %feature("docstring", " - /// Gets the deepest block that contains the frame PC. - /// - /// See also GetFrameBlock(). - ") GetBlock; - lldb::SBBlock - GetBlock () const; - - %feature("docstring", " - /// Get the appropriate function name for this frame. Inlined functions in - /// LLDB are represented by Blocks that have inlined function information, so - /// just looking at the SBFunction or SBSymbol for a frame isn't enough. - /// This function will return the appropriate function, symbol or inlined - /// function name for the frame. - /// - /// This function returns: - /// - the name of the inlined function (if there is one) - /// - the name of the concrete function (if there is one) - /// - the name of the symbol (if there is one) - /// - NULL - /// - /// See also IsInlined(). - ") GetFunctionName; - const char * - GetFunctionName(); - - %feature("docstring", " - /// Return true if this frame represents an inlined function. - /// - /// See also GetFunctionName(). - ") IsInlined; - bool - IsInlined(); - - %feature("docstring", " - /// The version that doesn't supply a 'use_dynamic' value will use the - /// target's default. - ") EvaluateExpression; - lldb::SBValue - EvaluateExpression (const char *expr); - - lldb::SBValue - EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic); - - lldb::SBValue - EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic, bool unwind_on_error); - - lldb::SBValue - EvaluateExpression (const char *expr, SBExpressionOptions &options); - - %feature("docstring", " - /// Gets the lexical block that defines the stack frame. Another way to think - /// of this is it will return the block that contains all of the variables - /// for a stack frame. Inlined functions are represented as SBBlock objects - /// that have inlined function information: the name of the inlined function, - /// where it was called from. The block that is returned will be the first - /// block at or above the block for the PC (SBFrame::GetBlock()) that defines - /// the scope of the frame. When a function contains no inlined functions, - /// this will be the top most lexical block that defines the function. - /// When a function has inlined functions and the PC is currently - /// in one of those inlined functions, this method will return the inlined - /// block that defines this frame. If the PC isn't currently in an inlined - /// function, the lexical block that defines the function is returned. - ") GetFrameBlock; - lldb::SBBlock - GetFrameBlock () const; - - lldb::SBLineEntry - GetLineEntry () const; - - lldb::SBThread - GetThread () const; - - const char * - Disassemble () const; - - void - Clear(); - -#ifndef SWIG - bool - operator == (const lldb::SBFrame &rhs) const; - - bool - operator != (const lldb::SBFrame &rhs) const; - -#endif - - %feature("docstring", " - /// The version that doesn't supply a 'use_dynamic' value will use the - /// target's default. - ") GetVariables; - lldb::SBValueList - GetVariables (bool arguments, - bool locals, - bool statics, - bool in_scope_only); - - lldb::SBValueList - GetVariables (bool arguments, - bool locals, - bool statics, - bool in_scope_only, - lldb::DynamicValueType use_dynamic); - - lldb::SBValueList - GetVariables (const lldb::SBVariablesOptions& options); - - lldb::SBValueList - GetRegisters (); - - %feature("docstring", " - /// The version that doesn't supply a 'use_dynamic' value will use the - /// target's default. - ") FindVariable; - lldb::SBValue - FindVariable (const char *var_name); - - lldb::SBValue - FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic); - - lldb::SBValue - FindRegister (const char *name); - - %feature("docstring", " - /// Get a lldb.SBValue for a variable path. - /// - /// Variable paths can include access to pointer or instance members: - /// rect_ptr->origin.y - /// pt.x - /// Pointer dereferences: - /// *this->foo_ptr - /// **argv - /// Address of: - /// &pt - /// &my_array[3].x - /// Array accesses and treating pointers as arrays: - /// int_array[1] - /// pt_ptr[22].x - /// - /// Unlike EvaluateExpression() which returns lldb.SBValue objects - /// with constant copies of the values at the time of evaluation, - /// the result of this function is a value that will continue to - /// track the current value of the value as execution progresses - /// in the current frame. - ") GetValueForVariablePath; - lldb::SBValue - GetValueForVariablePath (const char *var_path); - - lldb::SBValue - GetValueForVariablePath (const char *var_path, lldb::DynamicValueType use_dynamic); - - %feature("docstring", " - /// Find variables, register sets, registers, or persistent variables using - /// the frame as the scope. - /// - /// The version that doesn't supply a 'use_dynamic' value will use the - /// target's default. - ") FindValue; - lldb::SBValue - FindValue (const char *name, ValueType value_type); - - lldb::SBValue - FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic); - - bool - GetDescription (lldb::SBStream &description); - - %pythoncode %{ - def get_all_variables(self): - return self.GetVariables(True,True,True,True) - - def get_arguments(self): - return self.GetVariables(True,False,False,False) - - def get_locals(self): - return self.GetVariables(False,True,False,False) - - def get_statics(self): - return self.GetVariables(False,False,True,False) - - def var(self, var_expr_path): - '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns - a value that represents the variable expression path''' - return self.GetValueForVariablePath(var_expr_path) - - def get_registers_access(self): - class registers_access(object): - '''A helper object that exposes a flattened view of registers, masking away the notion of register sets for easy scripting.''' - def __init__(self, regs): - self.regs = regs - - def __getitem__(self, key): - if type(key) is str: - for i in range(0,len(self.regs)): - rs = self.regs[i] - for j in range (0,rs.num_children): - reg = rs.GetChildAtIndex(j) - if reg.name == key: return reg - else: - return lldb.SBValue() - - return registers_access(self.registers) - - __swig_getmethods__["pc"] = GetPC - __swig_setmethods__["pc"] = SetPC - if _newclass: pc = property(GetPC, SetPC) - - __swig_getmethods__["addr"] = GetPCAddress - if _newclass: addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''') - - __swig_getmethods__["fp"] = GetFP - if _newclass: fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''') - - __swig_getmethods__["sp"] = GetSP - if _newclass: sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''') - - __swig_getmethods__["module"] = GetModule - if _newclass: module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''') - - __swig_getmethods__["compile_unit"] = GetCompileUnit - if _newclass: compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) for this stack frame.''') - - __swig_getmethods__["function"] = GetFunction - if _newclass: function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''') - - __swig_getmethods__["symbol"] = GetSymbol - if _newclass: symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''') - - __swig_getmethods__["block"] = GetBlock - if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''') - - __swig_getmethods__["is_inlined"] = IsInlined - if _newclass: is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''') - - __swig_getmethods__["name"] = GetFunctionName - if _newclass: name = property(GetFunctionName, None, doc='''A read only property that retuns the name for the function that this frame represents. Inlined stack frame might have a concrete function that differs from the name of the inlined function (a named lldb.SBBlock).''') - - __swig_getmethods__["line_entry"] = GetLineEntry - if _newclass: line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line table entry (lldb.SBLineEntry) for this stack frame.''') - - __swig_getmethods__["thread"] = GetThread - if _newclass: thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''') - - __swig_getmethods__["disassembly"] = Disassemble - if _newclass: disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''') - - __swig_getmethods__["idx"] = GetFrameID - if _newclass: idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''') - - __swig_getmethods__["variables"] = get_all_variables - if _newclass: variables = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') - - __swig_getmethods__["vars"] = get_all_variables - if _newclass: vars = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') - - __swig_getmethods__["locals"] = get_locals - if _newclass: locals = property(get_locals, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the local variables in this stack frame.''') - - __swig_getmethods__["args"] = get_arguments - if _newclass: args = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') - - __swig_getmethods__["arguments"] = get_arguments - if _newclass: arguments = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') - - __swig_getmethods__["statics"] = get_statics - if _newclass: statics = property(get_statics, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the static variables in this stack frame.''') - - __swig_getmethods__["registers"] = GetRegisters - if _newclass: registers = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') - - __swig_getmethods__["regs"] = GetRegisters - if _newclass: regs = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') - - __swig_getmethods__["register"] = get_registers_access - if _newclass: register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''') - - __swig_getmethods__["reg"] = get_registers_access - if _newclass: reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''') - - %} -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBFunction.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBFunction.i +++ lldb/trunk/scripts/Python/interface/SBFunction.i @@ -1,129 +0,0 @@ -//===-- SWIG Interface for SBFunction ---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a generic function, which can be inlined or not. - -For example (from test/lldbutil.py, but slightly modified for doc purpose), - - ... - - frame = thread.GetFrameAtIndex(i) - addr = frame.GetPCAddress() - load_addr = addr.GetLoadAddress(target) - function = frame.GetFunction() - mod_name = frame.GetModule().GetFileSpec().GetFilename() - - if not function: - # No debug info for 'function'. - symbol = frame.GetSymbol() - file_addr = addr.GetFileAddress() - start_addr = symbol.GetStartAddress().GetFileAddress() - symbol_name = symbol.GetName() - symbol_offset = file_addr - start_addr - print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format( - num=i, addr=load_addr, mod=mod_name, symbol=symbol_name, offset=symbol_offset) - else: - # Debug info is available for 'function'. - func_name = frame.GetFunctionName() - file_name = frame.GetLineEntry().GetFileSpec().GetFilename() - line_num = frame.GetLineEntry().GetLine() - print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format( - num=i, addr=load_addr, mod=mod_name, - func='%s [inlined]' % func_name] if frame.IsInlined() else func_name, - file=file_name, line=line_num, args=get_args_as_string(frame, showFuncName=False)) - - ... -") SBFunction; -class SBFunction -{ -public: - - SBFunction (); - - SBFunction (const lldb::SBFunction &rhs); - - ~SBFunction (); - - bool - IsValid () const; - - const char * - GetName() const; - - const char * - GetMangledName () const; - - lldb::SBInstructionList - GetInstructions (lldb::SBTarget target); - - lldb::SBInstructionList - GetInstructions (lldb::SBTarget target, const char *flavor); - - lldb::SBAddress - GetStartAddress (); - - lldb::SBAddress - GetEndAddress (); - - uint32_t - GetPrologueByteSize (); - - lldb::SBType - GetType (); - - lldb::SBBlock - GetBlock (); - - lldb::LanguageType - GetLanguage (); - - bool - GetDescription (lldb::SBStream &description); - - bool - operator == (const lldb::SBFunction &rhs) const; - - bool - operator != (const lldb::SBFunction &rhs) const; - - %pythoncode %{ - def get_instructions_from_current_target (self): - return self.GetInstructions (target) - - __swig_getmethods__["addr"] = GetStartAddress - if _newclass: addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this function.''') - - __swig_getmethods__["end_addr"] = GetEndAddress - if _newclass: end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this function.''') - - __swig_getmethods__["block"] = GetBlock - if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the top level lexical block (lldb.SBBlock) for this function.''') - - __swig_getmethods__["instructions"] = get_instructions_from_current_target - if _newclass: instructions = property(get_instructions_from_current_target, None, doc='''A read only property that returns an lldb object that represents the instructions (lldb.SBInstructionList) for this function.''') - - __swig_getmethods__["mangled"] = GetMangledName - if _newclass: mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this function as a string.''') - - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this function as a string.''') - - __swig_getmethods__["prologue_size"] = GetPrologueByteSize - if _newclass: prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the return type (lldb.SBType) for this function.''') - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBHostOS.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBHostOS.i +++ lldb/trunk/scripts/Python/interface/SBHostOS.i @@ -1,47 +0,0 @@ -//===-- SWIG Interface for SBHostOS -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBHostOS -{ -public: - - static lldb::SBFileSpec - GetProgramFileSpec (); - - static lldb::SBFileSpec - GetLLDBPythonPath (); - - static lldb::SBFileSpec - GetLLDBPath (lldb::PathType path_type); - - static void - ThreadCreated (const char *name); - - static lldb::thread_t - ThreadCreate (const char *name, - lldb::thread_func_t, - void *thread_arg, - lldb::SBError *err); - - static bool - ThreadCancel (lldb::thread_t thread, - lldb::SBError *err); - - static bool - ThreadDetach (lldb::thread_t thread, - lldb::SBError *err); - static bool - ThreadJoin (lldb::thread_t thread, - lldb::thread_result_t *result, - lldb::SBError *err); -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBInstruction.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBInstruction.i +++ lldb/trunk/scripts/Python/interface/SBInstruction.i @@ -1,103 +0,0 @@ -//===-- SWIG Interface for SBInstruction ------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include - -// There's a lot to be fixed here, but need to wait for underlying insn implementation -// to be revised & settle down first. - -namespace lldb { - -class SBInstruction -{ -public: - - SBInstruction (); - - SBInstruction (const SBInstruction &rhs); - - ~SBInstruction (); - - bool - IsValid(); - - lldb::SBAddress - GetAddress(); - - lldb::AddressClass - GetAddressClass (); - - const char * - GetMnemonic (lldb::SBTarget target); - - const char * - GetOperands (lldb::SBTarget target); - - const char * - GetComment (lldb::SBTarget target); - - lldb::SBData - GetData (lldb::SBTarget target); - - size_t - GetByteSize (); - - bool - DoesBranch (); - - void - Print (FILE *out); - - bool - GetDescription (lldb::SBStream &description); - - bool - EmulateWithFrame (lldb::SBFrame &frame, uint32_t evaluate_options); - - bool - DumpEmulation (const char * triple); // triple is to specify the architecture, e.g. 'armv6' or 'armv7-apple-ios' - - bool - TestEmulation (lldb::SBStream &output_stream, const char *test_file); - - %pythoncode %{ - def __mnemonic_property__ (self): - return self.GetMnemonic (target) - def __operands_property__ (self): - return self.GetOperands (target) - def __comment_property__ (self): - return self.GetComment (target) - def __file_addr_property__ (self): - return self.GetAddress ().GetFileAddress() - def __load_adrr_property__ (self): - return self.GetComment (target) - - __swig_getmethods__["mnemonic"] = __mnemonic_property__ - if _newclass: mnemonic = property(__mnemonic_property__, None, doc='''A read only property that returns the mnemonic for this instruction as a string.''') - - __swig_getmethods__["operands"] = __operands_property__ - if _newclass: operands = property(__operands_property__, None, doc='''A read only property that returns the operands for this instruction as a string.''') - - __swig_getmethods__["comment"] = __comment_property__ - if _newclass: comment = property(__comment_property__, None, doc='''A read only property that returns the comment for this instruction as a string.''') - - __swig_getmethods__["addr"] = GetAddress - if _newclass: addr = property(GetAddress, None, doc='''A read only property that returns an lldb object that represents the address (lldb.SBAddress) for this instruction.''') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes for this instruction as an integer.''') - - __swig_getmethods__["is_branch"] = DoesBranch - if _newclass: is_branch = property(DoesBranch, None, doc='''A read only property that returns a boolean value that indicates if this instruction is a branch instruction.''') - %} - - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBInstructionList.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBInstructionList.i +++ lldb/trunk/scripts/Python/interface/SBInstructionList.i @@ -1,91 +0,0 @@ -//===-- SWIG Interface for SBInstructionList --------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include - -namespace lldb { - -%feature("docstring", -"Represents a list of machine instructions. SBFunction and SBSymbol have -GetInstructions() methods which return SBInstructionList instances. - -SBInstructionList supports instruction (SBInstruction instance) iteration. -For example (see also SBDebugger for a more complete example), - -def disassemble_instructions (insts): - for i in insts: - print i - -defines a function which takes an SBInstructionList instance and prints out -the machine instructions in assembly format." -) SBInstructionList; -class SBInstructionList -{ -public: - - SBInstructionList (); - - SBInstructionList (const SBInstructionList &rhs); - - ~SBInstructionList (); - - bool - IsValid () const; - - size_t - GetSize (); - - lldb::SBInstruction - GetInstructionAtIndex (uint32_t idx); - - void - Clear (); - - void - AppendInstruction (lldb::SBInstruction inst); - - void - Print (FILE *out); - - bool - GetDescription (lldb::SBStream &description); - - bool - DumpEmulationForAllInstructions (const char *triple); - - %pythoncode %{ - def __len__(self): - '''Access len of the instruction list.''' - return int(self.GetSize()) - - def __getitem__(self, key): - '''Access instructions by integer index for array access or by lldb.SBAddress to find an instruction that matches a section offset address object.''' - if type(key) is int: - # Find an instruction by index - if key < len(self): - return self.GetInstructionAtIndex(key) - elif type(key) is SBAddress: - # Find an instruction using a lldb.SBAddress object - lookup_file_addr = key.file_addr - closest_inst = None - for idx in range(self.GetSize()): - inst = self.GetInstructionAtIndex(idx) - inst_file_addr = inst.addr.file_addr - if inst_file_addr == lookup_file_addr: - return inst - elif inst_file_addr > lookup_file_addr: - return closest_inst - else: - closest_inst = inst - return None - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBLaunchInfo.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBLaunchInfo.i +++ lldb/trunk/scripts/Python/interface/SBLaunchInfo.i @@ -1,132 +0,0 @@ -//===-- SWIG Interface for SBLaunchInfo--------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBLaunchInfo -{ -public: - SBLaunchInfo (const char **argv); - - pid_t - GetProcessID(); - - uint32_t - GetUserID(); - - uint32_t - GetGroupID(); - - bool - UserIDIsValid (); - - bool - GroupIDIsValid (); - - void - SetUserID (uint32_t uid); - - void - SetGroupID (uint32_t gid); - - lldb::SBFileSpec - GetExecutableFile (); - - void - SetExecutableFile (lldb::SBFileSpec exe_file, bool add_as_first_arg); - - lldb::SBListener - GetListener (); - - void - SetListener (lldb::SBListener &listener); - - uint32_t - GetNumArguments (); - - const char * - GetArgumentAtIndex (uint32_t idx); - - void - SetArguments (const char **argv, bool append); - - uint32_t - GetNumEnvironmentEntries (); - - const char * - GetEnvironmentEntryAtIndex (uint32_t idx); - - void - SetEnvironmentEntries (const char **envp, bool append); - - void - Clear (); - - const char * - GetWorkingDirectory () const; - - void - SetWorkingDirectory (const char *working_dir); - - uint32_t - GetLaunchFlags (); - - void - SetLaunchFlags (uint32_t flags); - - const char * - GetProcessPluginName (); - - void - SetProcessPluginName (const char *plugin_name); - - const char * - GetShell (); - - void - SetShell (const char * path); - - bool - GetShellExpandArguments (); - - void - SetShellExpandArguments (bool expand); - - uint32_t - GetResumeCount (); - - void - SetResumeCount (uint32_t c); - - bool - AddCloseFileAction (int fd); - - bool - AddDuplicateFileAction (int fd, int dup_fd); - - bool - AddOpenFileAction (int fd, const char *path, bool read, bool write); - - bool - AddSuppressFileAction (int fd, bool read, bool write); - - void - SetLaunchEventData (const char *data); - - const char * - GetLaunchEventData () const; - - bool - GetDetachOnError() const; - - void - SetDetachOnError(bool enable); -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBLineEntry.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBLineEntry.i +++ lldb/trunk/scripts/Python/interface/SBLineEntry.i @@ -1,106 +0,0 @@ -//===-- SWIG Interface for SBLineEntry --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Specifies an association with a contiguous range of instructions and -a source file location. SBCompileUnit contains SBLineEntry(s). For example, - - for lineEntry in compileUnit: - print 'line entry: %s:%d' % (str(lineEntry.GetFileSpec()), - lineEntry.GetLine()) - print 'start addr: %s' % str(lineEntry.GetStartAddress()) - print 'end addr: %s' % str(lineEntry.GetEndAddress()) - -produces: - -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:20 -start addr: a.out[0x100000d98] -end addr: a.out[0x100000da3] -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:21 -start addr: a.out[0x100000da3] -end addr: a.out[0x100000da9] -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:22 -start addr: a.out[0x100000da9] -end addr: a.out[0x100000db6] -line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:23 -start addr: a.out[0x100000db6] -end addr: a.out[0x100000dbc] -... - -See also SBCompileUnit." -) SBLineEntry; -class SBLineEntry -{ -public: - - SBLineEntry (); - - SBLineEntry (const lldb::SBLineEntry &rhs); - - ~SBLineEntry (); - - lldb::SBAddress - GetStartAddress () const; - - lldb::SBAddress - GetEndAddress () const; - - bool - IsValid () const; - - lldb::SBFileSpec - GetFileSpec () const; - - uint32_t - GetLine () const; - - uint32_t - GetColumn () const; - - bool - GetDescription (lldb::SBStream &description); - - void - SetFileSpec (lldb::SBFileSpec filespec); - - void - SetLine (uint32_t line); - - void - SetColumn (uint32_t column); - - bool - operator == (const lldb::SBLineEntry &rhs) const; - - bool - operator != (const lldb::SBLineEntry &rhs) const; - - %pythoncode %{ - __swig_getmethods__["file"] = GetFileSpec - if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''') - - __swig_getmethods__["line"] = GetLine - if _newclass: line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''') - - __swig_getmethods__["column"] = GetColumn - if _newclass: column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''') - - __swig_getmethods__["addr"] = GetStartAddress - if _newclass: addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this line entry.''') - - __swig_getmethods__["end_addr"] = GetEndAddress - if _newclass: end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this line entry.''') - - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBListener.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBListener.i +++ lldb/trunk/scripts/Python/interface/SBListener.i @@ -1,99 +0,0 @@ -//===-- SWIG Interface for SBListener ---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"API clients can register its own listener to debugger events. - -See aslo SBEvent for example usage of creating and adding a listener." -) SBListener; -class SBListener -{ -public: - SBListener (); - - SBListener (const char *name); - - SBListener (const SBListener &rhs); - - ~SBListener (); - - void - AddEvent (const lldb::SBEvent &event); - - void - Clear (); - - bool - IsValid () const; - - uint32_t - StartListeningForEventClass (SBDebugger &debugger, - const char *broadcaster_class, - uint32_t event_mask); - - uint32_t - StopListeningForEventClass (SBDebugger &debugger, - const char *broadcaster_class, - uint32_t event_mask); - - uint32_t - StartListeningForEvents (const lldb::SBBroadcaster& broadcaster, - uint32_t event_mask); - - bool - StopListeningForEvents (const lldb::SBBroadcaster& broadcaster, - uint32_t event_mask); - - // Returns true if an event was received, false if we timed out. - bool - WaitForEvent (uint32_t num_seconds, - lldb::SBEvent &event); - - bool - WaitForEventForBroadcaster (uint32_t num_seconds, - const lldb::SBBroadcaster &broadcaster, - lldb::SBEvent &sb_event); - - bool - WaitForEventForBroadcasterWithType (uint32_t num_seconds, - const lldb::SBBroadcaster &broadcaster, - uint32_t event_type_mask, - lldb::SBEvent &sb_event); - - bool - PeekAtNextEvent (lldb::SBEvent &sb_event); - - bool - PeekAtNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster, - lldb::SBEvent &sb_event); - - bool - PeekAtNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster, - uint32_t event_type_mask, - lldb::SBEvent &sb_event); - - bool - GetNextEvent (lldb::SBEvent &sb_event); - - bool - GetNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster, - lldb::SBEvent &sb_event); - - bool - GetNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster, - uint32_t event_type_mask, - lldb::SBEvent &sb_event); - - bool - HandleBroadcastEvent (const lldb::SBEvent &event); -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBModule.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBModule.i +++ lldb/trunk/scripts/Python/interface/SBModule.i @@ -1,530 +0,0 @@ -//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents an executable image and its associated object and symbol files. - -The module is designed to be able to select a single slice of an -executable image as it would appear on disk and during program -execution. - -You can retrieve SBModule from SBSymbolContext, which in turn is available -from SBFrame. - -SBModule supports symbol iteration, for example, - - for symbol in module: - name = symbol.GetName() - saddr = symbol.GetStartAddress() - eaddr = symbol.GetEndAddress() - -and rich comparion methods which allow the API program to use, - - if thisModule == thatModule: - print 'This module is the same as that module' - -to test module equality. A module also contains object file sections, namely -SBSection. SBModule supports section iteration through section_iter(), for -example, - - print 'Number of sections: %d' % module.GetNumSections() - for sec in module.section_iter(): - print sec - -And to iterate the symbols within a SBSection, use symbol_in_section_iter(), - - # Iterates the text section and prints each symbols within each sub-section. - for subsec in text_sec: - print INDENT + repr(subsec) - for sym in exe_module.symbol_in_section_iter(subsec): - print INDENT2 + repr(sym) - print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType()) - -produces this following output: - - [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text - id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870) - symbol type: code - id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0) - symbol type: code - id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c) - symbol type: code - id = {0x00000023}, name = 'start', address = 0x0000000100001780 - symbol type: code - [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs - id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62) - symbol type: trampoline - id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68) - symbol type: trampoline - id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e) - symbol type: trampoline - id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74) - symbol type: trampoline - id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a) - symbol type: trampoline - id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80) - symbol type: trampoline - id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86) - symbol type: trampoline - id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c) - symbol type: trampoline - id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92) - symbol type: trampoline - id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98) - symbol type: trampoline - id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e) - symbol type: trampoline - id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4) - symbol type: trampoline - [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper - [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring - [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info - [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame -" -) SBModule; -class SBModule -{ -public: - - SBModule (); - - SBModule (const lldb::SBModule &rhs); - - SBModule (const lldb::SBModuleSpec &module_spec); - - SBModule (lldb::SBProcess &process, - lldb::addr_t header_addr); - - ~SBModule (); - - bool - IsValid () const; - - void - Clear(); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get const accessor for the module file specification. - /// - /// This function returns the file for the module on the host system - /// that is running LLDB. This can differ from the path on the - /// platform since we might be doing remote debugging. - /// - /// @return - /// A const reference to the file specification object. - //------------------------------------------------------------------ - ") GetFileSpec; - lldb::SBFileSpec - GetFileSpec () const; - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get accessor for the module platform file specification. - /// - /// Platform file refers to the path of the module as it is known on - /// the remote system on which it is being debugged. For local - /// debugging this is always the same as Module::GetFileSpec(). But - /// remote debugging might mention a file '/usr/lib/liba.dylib' - /// which might be locally downloaded and cached. In this case the - /// platform file could be something like: - /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib' - /// The file could also be cached in a local developer kit directory. - /// - /// @return - /// A const reference to the file specification object. - //------------------------------------------------------------------ - ") GetPlatformFileSpec; - lldb::SBFileSpec - GetPlatformFileSpec () const; - - bool - SetPlatformFileSpec (const lldb::SBFileSpec &platform_file); - - lldb::SBFileSpec - GetRemoteInstallFileSpec (); - - bool - SetRemoteInstallFileSpec (lldb::SBFileSpec &file); - - %feature("docstring", "Returns the UUID of the module as a Python string." - ) GetUUIDString; - const char * - GetUUIDString () const; - - lldb::SBSection - FindSection (const char *sect_name); - - lldb::SBAddress - ResolveFileAddress (lldb::addr_t vm_addr); - - lldb::SBSymbolContext - ResolveSymbolContextForAddress (const lldb::SBAddress& addr, - uint32_t resolve_scope); - - bool - GetDescription (lldb::SBStream &description); - - uint32_t - GetNumCompileUnits(); - - lldb::SBCompileUnit - GetCompileUnitAtIndex (uint32_t); - - size_t - GetNumSymbols (); - - lldb::SBSymbol - GetSymbolAtIndex (size_t idx); - - lldb::SBSymbol - FindSymbol (const char *name, - lldb::SymbolType type = eSymbolTypeAny); - - lldb::SBSymbolContextList - FindSymbols (const char *name, - lldb::SymbolType type = eSymbolTypeAny); - - - size_t - GetNumSections (); - - lldb::SBSection - GetSectionAtIndex (size_t idx); - - - %feature("docstring", " - //------------------------------------------------------------------ - /// Find functions by name. - /// - /// @param[in] name - /// The name of the function we are looking for. - /// - /// @param[in] name_type_mask - /// A logical OR of one or more FunctionNameType enum bits that - /// indicate what kind of names should be used when doing the - /// lookup. Bits include fully qualified names, base names, - /// C++ methods, or ObjC selectors. - /// See FunctionNameType for more details. - /// - /// @return - /// A symbol context list that gets filled in with all of the - /// matches. - //------------------------------------------------------------------ - ") FindFunctions; - lldb::SBSymbolContextList - FindFunctions (const char *name, - uint32_t name_type_mask = lldb::eFunctionNameTypeAny); - - lldb::SBType - FindFirstType (const char* name); - - lldb::SBTypeList - FindTypes (const char* type); - - lldb::SBType - GetTypeByID (lldb::user_id_t uid); - - lldb::SBType - GetBasicType(lldb::BasicType type); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get all types matching \a type_mask from debug info in this - /// module. - /// - /// @param[in] type_mask - /// A bitfield that consists of one or more bits logically OR'ed - /// together from the lldb::TypeClass enumeration. This allows - /// you to request only structure types, or only class, struct - /// and union types. Passing in lldb::eTypeClassAny will return - /// all types found in the debug information for this module. - /// - /// @return - /// A list of types in this module that match \a type_mask - //------------------------------------------------------------------ - ") GetTypes; - lldb::SBTypeList - GetTypes (uint32_t type_mask = lldb::eTypeClassAny); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Find global and static variables by name. - /// - /// @param[in] target - /// A valid SBTarget instance representing the debuggee. - /// - /// @param[in] name - /// The name of the global or static variable we are looking - /// for. - /// - /// @param[in] max_matches - /// Allow the number of matches to be limited to \a max_matches. - /// - /// @return - /// A list of matched variables in an SBValueList. - //------------------------------------------------------------------ - ") FindGlobalVariables; - lldb::SBValueList - FindGlobalVariables (lldb::SBTarget &target, - const char *name, - uint32_t max_matches); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Find the first global (or static) variable by name. - /// - /// @param[in] target - /// A valid SBTarget instance representing the debuggee. - /// - /// @param[in] name - /// The name of the global or static variable we are looking - /// for. - /// - /// @return - /// An SBValue that gets filled in with the found variable (if any). - //------------------------------------------------------------------ - ") FindFirstGlobalVariable; - lldb::SBValue - FindFirstGlobalVariable (lldb::SBTarget &target, const char *name); - - lldb::ByteOrder - GetByteOrder (); - - uint32_t - GetAddressByteSize(); - - const char * - GetTriple (); - - uint32_t - GetVersion (uint32_t *versions, - uint32_t num_versions); - - lldb::SBFileSpec - GetSymbolFileSpec() const; - - lldb::SBAddress - GetObjectFileHeaderAddress() const; - - bool - operator == (const lldb::SBModule &rhs) const; - - bool - operator != (const lldb::SBModule &rhs) const; - - %pythoncode %{ - class symbols_access(object): - re_compile_type = type(re.compile('.')) - '''A helper object that will lazily hand out lldb.SBSymbol objects for a module when supplied an index, name, or regular expression.''' - def __init__(self, sbmodule): - self.sbmodule = sbmodule - - def __len__(self): - if self.sbmodule: - return int(self.sbmodule.GetNumSymbols()) - return 0 - - def __getitem__(self, key): - count = len(self) - if type(key) is int: - if key < count: - return self.sbmodule.GetSymbolAtIndex(key) - elif type(key) is str: - matches = [] - sc_list = self.sbmodule.FindSymbols(key) - for sc in sc_list: - symbol = sc.symbol - if symbol: - matches.append(symbol) - return matches - elif isinstance(key, self.re_compile_type): - matches = [] - for idx in range(count): - symbol = self.sbmodule.GetSymbolAtIndex(idx) - added = False - name = symbol.name - if name: - re_match = key.search(name) - if re_match: - matches.append(symbol) - added = True - if not added: - mangled = symbol.mangled - if mangled: - re_match = key.search(mangled) - if re_match: - matches.append(symbol) - return matches - else: - print "error: unsupported item type: %s" % type(key) - return None - - def get_symbols_access_object(self): - '''An accessor function that returns a symbols_access() object which allows lazy symbol access from a lldb.SBModule object.''' - return self.symbols_access (self) - - def get_compile_units_access_object (self): - '''An accessor function that returns a compile_units_access() object which allows lazy compile unit access from a lldb.SBModule object.''' - return self.compile_units_access (self) - - def get_symbols_array(self): - '''An accessor function that returns a list() that contains all symbols in a lldb.SBModule object.''' - symbols = [] - for idx in range(self.num_symbols): - symbols.append(self.GetSymbolAtIndex(idx)) - return symbols - - class sections_access(object): - re_compile_type = type(re.compile('.')) - '''A helper object that will lazily hand out lldb.SBSection objects for a module when supplied an index, name, or regular expression.''' - def __init__(self, sbmodule): - self.sbmodule = sbmodule - - def __len__(self): - if self.sbmodule: - return int(self.sbmodule.GetNumSections()) - return 0 - - def __getitem__(self, key): - count = len(self) - if type(key) is int: - if key < count: - return self.sbmodule.GetSectionAtIndex(key) - elif type(key) is str: - for idx in range(count): - section = self.sbmodule.GetSectionAtIndex(idx) - if section.name == key: - return section - elif isinstance(key, self.re_compile_type): - matches = [] - for idx in range(count): - section = self.sbmodule.GetSectionAtIndex(idx) - name = section.name - if name: - re_match = key.search(name) - if re_match: - matches.append(section) - return matches - else: - print "error: unsupported item type: %s" % type(key) - return None - - class compile_units_access(object): - re_compile_type = type(re.compile('.')) - '''A helper object that will lazily hand out lldb.SBCompileUnit objects for a module when supplied an index, full or partial path, or regular expression.''' - def __init__(self, sbmodule): - self.sbmodule = sbmodule - - def __len__(self): - if self.sbmodule: - return int(self.sbmodule.GetNumCompileUnits()) - return 0 - - def __getitem__(self, key): - count = len(self) - if type(key) is int: - if key < count: - return self.sbmodule.GetCompileUnitAtIndex(key) - elif type(key) is str: - is_full_path = key[0] == '/' - for idx in range(count): - comp_unit = self.sbmodule.GetCompileUnitAtIndex(idx) - if is_full_path: - if comp_unit.file.fullpath == key: - return comp_unit - else: - if comp_unit.file.basename == key: - return comp_unit - elif isinstance(key, self.re_compile_type): - matches = [] - for idx in range(count): - comp_unit = self.sbmodule.GetCompileUnitAtIndex(idx) - fullpath = comp_unit.file.fullpath - if fullpath: - re_match = key.search(fullpath) - if re_match: - matches.append(comp_unit) - return matches - else: - print "error: unsupported item type: %s" % type(key) - return None - - def get_sections_access_object(self): - '''An accessor function that returns a sections_access() object which allows lazy section array access.''' - return self.sections_access (self) - - def get_sections_array(self): - '''An accessor function that returns an array object that contains all sections in this module object.''' - if not hasattr(self, 'sections_array'): - self.sections_array = [] - for idx in range(self.num_sections): - self.sections_array.append(self.GetSectionAtIndex(idx)) - return self.sections_array - - def get_compile_units_array(self): - '''An accessor function that returns an array object that contains all compile_units in this module object.''' - if not hasattr(self, 'compile_units_array'): - self.compile_units_array = [] - for idx in range(self.GetNumCompileUnits()): - self.compile_units_array.append(self.GetCompileUnitAtIndex(idx)) - return self.compile_units_array - - __swig_getmethods__["symbols"] = get_symbols_array - if _newclass: symbols = property(get_symbols_array, None, doc='''A read only property that returns a list() of lldb.SBSymbol objects contained in this module.''') - - __swig_getmethods__["symbol"] = get_symbols_access_object - if _newclass: symbol = property(get_symbols_access_object, None, doc='''A read only property that can be used to access symbols by index ("symbol = module.symbol[0]"), name ("symbols = module.symbol['main']"), or using a regular expression ("symbols = module.symbol[re.compile(...)]"). The return value is a single lldb.SBSymbol object for array access, and a list() of lldb.SBSymbol objects for name and regular expression access''') - - __swig_getmethods__["sections"] = get_sections_array - if _newclass: sections = property(get_sections_array, None, doc='''A read only property that returns a list() of lldb.SBSection objects contained in this module.''') - - __swig_getmethods__["compile_units"] = get_compile_units_array - if _newclass: compile_units = property(get_compile_units_array, None, doc='''A read only property that returns a list() of lldb.SBCompileUnit objects contained in this module.''') - - __swig_getmethods__["section"] = get_sections_access_object - if _newclass: section = property(get_sections_access_object, None, doc='''A read only property that can be used to access symbols by index ("section = module.section[0]"), name ("sections = module.section[\'main\']"), or using a regular expression ("sections = module.section[re.compile(...)]"). The return value is a single lldb.SBSection object for array access, and a list() of lldb.SBSection objects for name and regular expression access''') - - __swig_getmethods__["compile_unit"] = get_compile_units_access_object - if _newclass: section = property(get_sections_access_object, None, doc='''A read only property that can be used to access compile units by index ("compile_unit = module.compile_unit[0]"), name ("compile_unit = module.compile_unit[\'main.cpp\']"), or using a regular expression ("compile_unit = module.compile_unit[re.compile(...)]"). The return value is a single lldb.SBCompileUnit object for array access or by full or partial path, and a list() of lldb.SBCompileUnit objects regular expressions.''') - - def get_uuid(self): - return uuid.UUID (self.GetUUIDString()) - - __swig_getmethods__["uuid"] = get_uuid - if _newclass: uuid = property(get_uuid, None, doc='''A read only property that returns a standard python uuid.UUID object that represents the UUID of this module.''') - - __swig_getmethods__["file"] = GetFileSpec - if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented where it is being debugged.''') - - __swig_getmethods__["platform_file"] = GetPlatformFileSpec - if _newclass: platform_file = property(GetPlatformFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented on the current host system.''') - - __swig_getmethods__["byte_order"] = GetByteOrder - if _newclass: byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this module.''') - - __swig_getmethods__["addr_size"] = GetAddressByteSize - if _newclass: addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this module.''') - - __swig_getmethods__["triple"] = GetTriple - if _newclass: triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this module.''') - - __swig_getmethods__["num_symbols"] = GetNumSymbols - if _newclass: num_symbols = property(GetNumSymbols, None, doc='''A read only property that returns number of symbols in the module symbol table as an integer.''') - - __swig_getmethods__["num_sections"] = GetNumSections - if _newclass: num_sections = property(GetNumSections, None, doc='''A read only property that returns number of sections in the module as an integer.''') - - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBModuleSpec.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBModuleSpec.i +++ lldb/trunk/scripts/Python/interface/SBModuleSpec.i @@ -1,133 +0,0 @@ -//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBModuleSpec -{ -public: - - SBModuleSpec (); - - SBModuleSpec (const lldb::SBModuleSpec &rhs); - - ~SBModuleSpec (); - - bool - IsValid () const; - - void - Clear(); - - //------------------------------------------------------------------ - /// Get const accessor for the module file. - /// - /// This function returns the file for the module on the host system - /// that is running LLDB. This can differ from the path on the - /// platform since we might be doing remote debugging. - /// - /// @return - /// A const reference to the file specification object. - //------------------------------------------------------------------ - lldb::SBFileSpec - GetFileSpec (); - - void - SetFileSpec (const lldb::SBFileSpec &fspec); - - //------------------------------------------------------------------ - /// Get accessor for the module platform file. - /// - /// Platform file refers to the path of the module as it is known on - /// the remote system on which it is being debugged. For local - /// debugging this is always the same as Module::GetFileSpec(). But - /// remote debugging might mention a file '/usr/lib/liba.dylib' - /// which might be locally downloaded and cached. In this case the - /// platform file could be something like: - /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib' - /// The file could also be cached in a local developer kit directory. - /// - /// @return - /// A const reference to the file specification object. - //------------------------------------------------------------------ - lldb::SBFileSpec - GetPlatformFileSpec (); - - void - SetPlatformFileSpec (const lldb::SBFileSpec &fspec); - - lldb::SBFileSpec - GetSymbolFileSpec (); - - void - SetSymbolFileSpec (const lldb::SBFileSpec &fspec); - - const char * - GetObjectName (); - - void - SetObjectName (const char *name); - - const char * - GetTriple (); - - void - SetTriple (const char *triple); - - const uint8_t * - GetUUIDBytes (); - - size_t - GetUUIDLength (); - - bool - SetUUIDBytes (const uint8_t *uuid, size_t uuid_len); - - bool - GetDescription (lldb::SBStream &description); - -}; - - -class SBModuleSpecList -{ -public: - SBModuleSpecList(); - - SBModuleSpecList (const SBModuleSpecList &rhs); - - ~SBModuleSpecList(); - - static SBModuleSpecList - GetModuleSpecifications (const char *path); - - void - Append (const lldb::SBModuleSpec &spec); - - void - Append (const lldb::SBModuleSpecList &spec_list); - - lldb::SBModuleSpec - FindFirstMatchingSpec (const lldb::SBModuleSpec &match_spec); - - lldb::SBModuleSpecList - FindMatchingSpecs (const lldb::SBModuleSpec &match_spec); - - size_t - GetSize(); - - lldb::SBModuleSpec - GetSpecAtIndex (size_t i); - - bool - GetDescription (lldb::SBStream &description); - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBPlatform.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBPlatform.i +++ lldb/trunk/scripts/Python/interface/SBPlatform.i @@ -1,193 +0,0 @@ -//===-- SWIG Interface for SBPlatform ---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - -class SBPlatformConnectOptions -{ -public: - SBPlatformConnectOptions (const char *url); - - SBPlatformConnectOptions (const SBPlatformConnectOptions &rhs); - - ~SBPlatformConnectOptions (); - - const char * - GetURL(); - - void - SetURL(const char *url); - - bool - GetRsyncEnabled(); - - void - EnableRsync (const char *options, - const char *remote_path_prefix, - bool omit_remote_hostname); - - void - DisableRsync (); - - const char * - GetLocalCacheDirectory(); - - void - SetLocalCacheDirectory(const char *path); -}; - -class SBPlatformShellCommand -{ -public: - SBPlatformShellCommand (const char *shell_command); - - SBPlatformShellCommand (const SBPlatformShellCommand &rhs); - - ~SBPlatformShellCommand(); - - void - Clear(); - - const char * - GetCommand(); - - void - SetCommand(const char *shell_command); - - const char * - GetWorkingDirectory (); - - void - SetWorkingDirectory (const char *path); - - uint32_t - GetTimeoutSeconds (); - - void - SetTimeoutSeconds (uint32_t sec); - - int - GetSignal (); - - int - GetStatus (); - - const char * - GetOutput (); -}; - -%feature("docstring", -"A class that represents the a platform that can represent the current host or a remote host debug platform. - -The SBPlatform class represents the current host, or a remote host. -It can be connected to a remote platform in order to provide ways -to remotely launch and attach to processes, upload/download files, -create directories, run remote shell commands, find locally cached -versions of files from the remote system, and much more. - -SBPlatform objects can be created and then used to connect to a remote -platform which allows the SBPlatform to be used to get a list of the -current processes on the remote host, attach to one of those processes, -install programs on the remote system, attach and launch processes, -and much more. - -Every SBTarget has a corresponding SBPlatform. The platform can be -specified upon target creation, or the currently selected platform -will attempt to be used when creating the target automatically as long -as the currently selected platform matches the target architecture -and executable type. If the architecture or executable type do not match, -a suitable platform will be found automatically." - -) SBPlatform; -class SBPlatform -{ -public: - - SBPlatform (); - - SBPlatform (const char *); - - ~SBPlatform(); - - bool - IsValid () const; - - void - Clear (); - - const char * - GetWorkingDirectory(); - - bool - SetWorkingDirectory(const char *); - - const char * - GetName (); - - SBError - ConnectRemote (lldb::SBPlatformConnectOptions &connect_options); - - void - DisconnectRemote (); - - bool - IsConnected(); - - const char * - GetTriple(); - - const char * - GetHostname (); - - const char * - GetOSBuild (); - - const char * - GetOSDescription (); - - uint32_t - GetOSMajorVersion (); - - uint32_t - GetOSMinorVersion (); - - uint32_t - GetOSUpdateVersion (); - - lldb::SBError - Get (lldb::SBFileSpec &src, lldb::SBFileSpec &dst); - - lldb::SBError - Put (lldb::SBFileSpec &src, lldb::SBFileSpec &dst); - - lldb::SBError - Install (lldb::SBFileSpec &src, lldb::SBFileSpec &dst); - - lldb::SBError - Run (lldb::SBPlatformShellCommand &shell_command); - - lldb::SBError - Launch (lldb::SBLaunchInfo &launch_info); - - lldb::SBError - Kill (const lldb::pid_t pid); - - lldb::SBError - MakeDirectory (const char *path, uint32_t file_permissions = lldb::eFilePermissionsDirectoryDefault); - - uint32_t - GetFilePermissions (const char *path); - - lldb::SBError - SetFilePermissions (const char *path, uint32_t file_permissions); - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBProcess.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBProcess.i +++ lldb/trunk/scripts/Python/interface/SBProcess.i @@ -1,496 +0,0 @@ -//===-- SWIG Interface for SBProcess ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents the process associated with the target program. - -SBProcess supports thread iteration. For example (from test/lldbutil.py), - -# ================================================== -# Utility functions related to Threads and Processes -# ================================================== - -def get_stopped_threads(process, reason): - '''Returns the thread(s) with the specified stop reason in a list. - - The list can be empty if no such thread exists. - ''' - threads = [] - for t in process: - if t.GetStopReason() == reason: - threads.append(t) - return threads - -... -" -) SBProcess; -class SBProcess -{ -public: - //------------------------------------------------------------------ - /// Broadcaster event bits definitions. - //------------------------------------------------------------------ - enum - { - eBroadcastBitStateChanged = (1 << 0), - eBroadcastBitInterrupt = (1 << 1), - eBroadcastBitSTDOUT = (1 << 2), - eBroadcastBitSTDERR = (1 << 3), - eBroadcastBitProfileData = (1 << 4) - }; - - SBProcess (); - - SBProcess (const lldb::SBProcess& rhs); - - ~SBProcess(); - - static const char * - GetBroadcasterClassName (); - - const char * - GetPluginName (); - - const char * - GetShortPluginName (); - - void - Clear (); - - bool - IsValid() const; - - lldb::SBTarget - GetTarget() const; - - lldb::ByteOrder - GetByteOrder() const; - - %feature("autodoc", " - Writes data into the current process's stdin. API client specifies a Python - string as the only argument. - ") PutSTDIN; - size_t - PutSTDIN (const char *src, size_t src_len); - - %feature("autodoc", " - Reads data from the current process's stdout stream. API client specifies - the size of the buffer to read data into. It returns the byte buffer in a - Python string. - ") GetSTDOUT; - size_t - GetSTDOUT (char *dst, size_t dst_len) const; - - %feature("autodoc", " - Reads data from the current process's stderr stream. API client specifies - the size of the buffer to read data into. It returns the byte buffer in a - Python string. - ") GetSTDERR; - size_t - GetSTDERR (char *dst, size_t dst_len) const; - - size_t - GetAsyncProfileData(char *dst, size_t dst_len) const; - - void - ReportEventState (const lldb::SBEvent &event, FILE *out) const; - - void - AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Remote connection related functions. These will fail if the - /// process is not in eStateConnected. They are intended for use - /// when connecting to an externally managed debugserver instance. - //------------------------------------------------------------------ - ") RemoteAttachToProcessWithID; - bool - RemoteAttachToProcessWithID (lldb::pid_t pid, - lldb::SBError& error); - - %feature("docstring", - "See SBTarget.Launch for argument description and usage." - ) RemoteLaunch; - bool - RemoteLaunch (char const **argv, - char const **envp, - const char *stdin_path, - const char *stdout_path, - const char *stderr_path, - const char *working_directory, - uint32_t launch_flags, - bool stop_at_entry, - lldb::SBError& error); - - //------------------------------------------------------------------ - // Thread related functions - //------------------------------------------------------------------ - uint32_t - GetNumThreads (); - - %feature("autodoc", " - Returns the INDEX'th thread from the list of current threads. The index - of a thread is only valid for the current stop. For a persistent thread - identifier use either the thread ID or the IndexID. See help on SBThread - for more details. - ") GetThreadAtIndex; - lldb::SBThread - GetThreadAtIndex (size_t index); - - %feature("autodoc", " - Returns the thread with the given thread ID. - ") GetThreadByID; - lldb::SBThread - GetThreadByID (lldb::tid_t sb_thread_id); - - %feature("autodoc", " - Returns the thread with the given thread IndexID. - ") GetThreadByIndexID; - lldb::SBThread - GetThreadByIndexID (uint32_t index_id); - - %feature("autodoc", " - Returns the currently selected thread. - ") GetSelectedThread; - lldb::SBThread - GetSelectedThread () const; - - %feature("autodoc", " - Lazily create a thread on demand through the current OperatingSystem plug-in, if the current OperatingSystem plug-in supports it. - ") CreateOSPluginThread; - lldb::SBThread - CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context); - - bool - SetSelectedThread (const lldb::SBThread &thread); - - bool - SetSelectedThreadByID (lldb::tid_t tid); - - bool - SetSelectedThreadByIndexID (uint32_t index_id); - - //------------------------------------------------------------------ - // Queue related functions - //------------------------------------------------------------------ - uint32_t - GetNumQueues (); - - lldb::SBQueue - GetQueueAtIndex (uint32_t index); - - //------------------------------------------------------------------ - // Stepping related functions - //------------------------------------------------------------------ - - lldb::StateType - GetState (); - - int - GetExitStatus (); - - const char * - GetExitDescription (); - - %feature("autodoc", " - Returns the process ID of the process. - ") GetProcessID; - lldb::pid_t - GetProcessID (); - - %feature("autodoc", " - Returns an integer ID that is guaranteed to be unique across all process instances. This is not the process ID, just a unique integer for comparison and caching purposes. - ") GetUniqueID; - uint32_t - GetUniqueID(); - - uint32_t - GetAddressByteSize() const; - - %feature("docstring", " - Kills the process and shuts down all threads that were spawned to - track and monitor process. - ") Destroy; - lldb::SBError - Destroy (); - - lldb::SBError - Continue (); - - lldb::SBError - Stop (); - - %feature("docstring", "Same as Destroy(self).") Destroy; - lldb::SBError - Kill (); - - lldb::SBError - Detach (); - - %feature("docstring", "Sends the process a unix signal.") Signal; - lldb::SBError - Signal (int signal); - - lldb::SBUnixSignals - GetUnixSignals(); - - %feature("docstring", " - Returns a stop id that will increase every time the process executes. If - include_expression_stops is true, then stops caused by expression evaluation - will cause the returned value to increase, otherwise the counter returned will - only increase when execution is continued explicitly by the user. Note, the value - will always increase, but may increase by more than one per stop. - ") GetStopID; - uint32_t - GetStopID(bool include_expression_stops = false); - - void - SendAsyncInterrupt(); - - %feature("autodoc", " - Reads memory from the current process's address space and removes any - traps that may have been inserted into the memory. It returns the byte - buffer in a Python string. Example: - - # Read 4 bytes from address 'addr' and assume error.Success() is True. - content = process.ReadMemory(addr, 4, error) - new_bytes = bytearray(content) - ") ReadMemory; - size_t - ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); - - %feature("autodoc", " - Writes memory to the current process's address space and maintains any - traps that might be present due to software breakpoints. Example: - - # Create a Python string from the byte array. - new_value = str(bytes) - result = process.WriteMemory(addr, new_value, error) - if not error.Success() or result != len(bytes): - print 'SBProcess.WriteMemory() failed!' - ") WriteMemory; - size_t - WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error); - - %feature("autodoc", " - Reads a NULL terminated C string from the current process's address space. - It returns a python string of the exact length, or truncates the string if - the maximum character limit is reached. Example: - - # Read a C string of at most 256 bytes from address '0x1000' - error = lldb.SBError() - cstring = process.ReadCStringFromMemory(0x1000, 256, error) - if error.Success(): - print 'cstring: ', cstring - else - print 'error: ', error - ") ReadCStringFromMemory; - - size_t - ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); - - %feature("autodoc", " - Reads an unsigned integer from memory given a byte size and an address. - Returns the unsigned integer that was read. Example: - - # Read a 4 byte unsigned integer from address 0x1000 - error = lldb.SBError() - uint = ReadUnsignedFromMemory(0x1000, 4, error) - if error.Success(): - print 'integer: %u' % uint - else - print 'error: ', error - - ") ReadUnsignedFromMemory; - - uint64_t - ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error); - - %feature("autodoc", " - Reads a pointer from memory from an address and returns the value. Example: - - # Read a pointer from address 0x1000 - error = lldb.SBError() - ptr = ReadPointerFromMemory(0x1000, error) - if error.Success(): - print 'pointer: 0x%x' % ptr - else - print 'error: ', error - - ") ReadPointerFromMemory; - - lldb::addr_t - ReadPointerFromMemory (addr_t addr, lldb::SBError &error); - - - // Events - static lldb::StateType - GetStateFromEvent (const lldb::SBEvent &event); - - static bool - GetRestartedFromEvent (const lldb::SBEvent &event); - - static size_t - GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event); - - static const char * - GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx); - - static lldb::SBProcess - GetProcessFromEvent (const lldb::SBEvent &event); - - static bool - EventIsProcessEvent (const lldb::SBEvent &event); - - lldb::SBBroadcaster - GetBroadcaster () const; - - bool - GetDescription (lldb::SBStream &description); - - uint32_t - GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const; - - uint32_t - LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error); - - lldb::SBError - UnloadImage (uint32_t image_token); - - lldb::SBError - SendEventData (const char *event_data); - - %feature("autodoc", " - Return the number of different thread-origin extended backtraces - this process can support as a uint32_t. - When the process is stopped and you have an SBThread, lldb may be - able to show a backtrace of when that thread was originally created, - or the work item was enqueued to it (in the case of a libdispatch - queue). - ") GetNumExtendedBacktraceTypes; - - uint32_t - GetNumExtendedBacktraceTypes (); - - %feature("autodoc", " - Takes an index argument, returns the name of one of the thread-origin - extended backtrace methods as a str. - ") GetExtendedBacktraceTypeAtIndex; - - const char * - GetExtendedBacktraceTypeAtIndex (uint32_t idx); - - lldb::SBThreadCollection - GetHistoryThreads (addr_t addr); - - bool - IsInstrumentationRuntimePresent(lldb::InstrumentationRuntimeType type); - - %pythoncode %{ - def __get_is_alive__(self): - '''Returns "True" if the process is currently alive, "False" otherwise''' - s = self.GetState() - if (s == eStateAttaching or - s == eStateLaunching or - s == eStateStopped or - s == eStateRunning or - s == eStateStepping or - s == eStateCrashed or - s == eStateSuspended): - return True - return False - - def __get_is_running__(self): - '''Returns "True" if the process is currently running, "False" otherwise''' - state = self.GetState() - if state == eStateRunning or state == eStateStepping: - return True - return False - - def __get_is_running__(self): - '''Returns "True" if the process is currently stopped, "False" otherwise''' - state = self.GetState() - if state == eStateStopped or state == eStateCrashed or state == eStateSuspended: - return True - return False - - class threads_access(object): - '''A helper object that will lazily hand out thread for a process when supplied an index.''' - def __init__(self, sbprocess): - self.sbprocess = sbprocess - - def __len__(self): - if self.sbprocess: - return int(self.sbprocess.GetNumThreads()) - return 0 - - def __getitem__(self, key): - if type(key) is int and key < len(self): - return self.sbprocess.GetThreadAtIndex(key) - return None - - def get_threads_access_object(self): - '''An accessor function that returns a modules_access() object which allows lazy thread access from a lldb.SBProcess object.''' - return self.threads_access (self) - - def get_process_thread_list(self): - '''An accessor function that returns a list() that contains all threads in a lldb.SBProcess object.''' - threads = [] - accessor = self.get_threads_access_object() - for idx in range(len(accessor)): - threads.append(accessor[idx]) - return threads - - __swig_getmethods__["threads"] = get_process_thread_list - if _newclass: threads = property(get_process_thread_list, None, doc='''A read only property that returns a list() of lldb.SBThread objects for this process.''') - - __swig_getmethods__["thread"] = get_threads_access_object - if _newclass: thread = property(get_threads_access_object, None, doc='''A read only property that returns an object that can access threads by thread index (thread = lldb.process.thread[12]).''') - - __swig_getmethods__["is_alive"] = __get_is_alive__ - if _newclass: is_alive = property(__get_is_alive__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently alive.''') - - __swig_getmethods__["is_running"] = __get_is_running__ - if _newclass: is_running = property(__get_is_running__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently running.''') - - __swig_getmethods__["is_stopped"] = __get_is_running__ - if _newclass: is_stopped = property(__get_is_running__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently stopped.''') - - __swig_getmethods__["id"] = GetProcessID - if _newclass: id = property(GetProcessID, None, doc='''A read only property that returns the process ID as an integer.''') - - __swig_getmethods__["target"] = GetTarget - if _newclass: target = property(GetTarget, None, doc='''A read only property that an lldb object that represents the target (lldb.SBTarget) that owns this process.''') - - __swig_getmethods__["num_threads"] = GetNumThreads - if _newclass: num_threads = property(GetNumThreads, None, doc='''A read only property that returns the number of threads in this process as an integer.''') - - __swig_getmethods__["selected_thread"] = GetSelectedThread - __swig_setmethods__["selected_thread"] = SetSelectedThread - if _newclass: selected_thread = property(GetSelectedThread, SetSelectedThread, doc='''A read/write property that gets/sets the currently selected thread in this process. The getter returns a lldb.SBThread object and the setter takes an lldb.SBThread object.''') - - __swig_getmethods__["state"] = GetState - if _newclass: state = property(GetState, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eState") that represents the current state of this process (running, stopped, exited, etc.).''') - - __swig_getmethods__["exit_state"] = GetExitStatus - if _newclass: exit_state = property(GetExitStatus, None, doc='''A read only property that returns an exit status as an integer of this process when the process state is lldb.eStateExited.''') - - __swig_getmethods__["exit_description"] = GetExitDescription - if _newclass: exit_description = property(GetExitDescription, None, doc='''A read only property that returns an exit description as a string of this process when the process state is lldb.eStateExited.''') - - __swig_getmethods__["broadcaster"] = GetBroadcaster - if _newclass: broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.''') - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBQueue.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBQueue.i +++ lldb/trunk/scripts/Python/interface/SBQueue.i @@ -1,75 +0,0 @@ -//===-- SWIG Interface for SBQueue.h -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBQueue -{ -public: - SBQueue (); - - SBQueue (const lldb::QueueSP& queue_sp); - - ~SBQueue(); - - bool - IsValid() const; - - void - Clear (); - - lldb::SBProcess - GetProcess (); - - %feature("autodoc", " - Returns an lldb::queue_id_t type unique identifier number for this - queue that will not be used by any other queue during this process' - execution. These ID numbers often start at 1 with the first - system-created queues and increment from there. - ") - GetQueueID; - - lldb::queue_id_t - GetQueueID () const; - - const char * - GetName () const; - - %feature("autodoc", " - Returns an lldb::QueueKind enumerated value (e.g. eQueueKindUnknown, - eQueueKindSerial, eQueueKindConcurrent) describing the type of this - queue. - ") - GetKind(); - - lldb::QueueKind - GetKind(); - - uint32_t - GetIndexID () const; - - uint32_t - GetNumThreads (); - - lldb::SBThread - GetThreadAtIndex (uint32_t); - - uint32_t - GetNumPendingItems (); - - lldb::SBQueueItem - GetPendingItemAtIndex (uint32_t); - - uint32_t - GetNumRunningItems (); - -}; - -} // namespace lldb - Index: lldb/trunk/scripts/Python/interface/SBQueueItem.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBQueueItem.i +++ lldb/trunk/scripts/Python/interface/SBQueueItem.i @@ -1,46 +0,0 @@ -//===-- SWIG Interface for SBQueueItem.h ------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBQueueItem -{ -public: - SBQueueItem (); - - SBQueueItem (const lldb::QueueItemSP& queue_item_sp); - - ~SBQueueItem(); - - bool - IsValid() const; - - void - Clear (); - - lldb::QueueItemKind - GetKind () const; - - void - SetKind (lldb::QueueItemKind kind); - - lldb::SBAddress - GetAddress () const; - - void - SetAddress (lldb::SBAddress addr); - - void - SetQueueItem (const lldb::QueueItemSP& queue_item_sp); - - lldb::SBThread - GetExtendedBacktraceThread (const char *type); -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBSection.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBSection.i +++ lldb/trunk/scripts/Python/interface/SBSection.i @@ -1,154 +0,0 @@ -//===-- SWIG Interface for SBSection ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents an executable image section. - -SBSection supports iteration through its subsection, represented as SBSection -as well. For example, - - for sec in exe_module: - if sec.GetName() == '__TEXT': - print sec - break - print INDENT + 'Number of subsections: %d' % sec.GetNumSubSections() - for subsec in sec: - print INDENT + repr(subsec) - -produces: - -[0x0000000100000000-0x0000000100002000) a.out.__TEXT - Number of subsections: 6 - [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text - [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs - [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper - [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring - [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info - [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame - -See also SBModule." -) SBSection; - -class SBSection -{ -public: - - SBSection (); - - SBSection (const lldb::SBSection &rhs); - - ~SBSection (); - - bool - IsValid () const; - - const char * - GetName (); - - lldb::SBSection - GetParent(); - - lldb::SBSection - FindSubSection (const char *sect_name); - - size_t - GetNumSubSections (); - - lldb::SBSection - GetSubSectionAtIndex (size_t idx); - - lldb::addr_t - GetFileAddress (); - - lldb::addr_t - GetLoadAddress (lldb::SBTarget &target); - - lldb::addr_t - GetByteSize (); - - uint64_t - GetFileOffset (); - - uint64_t - GetFileByteSize (); - - lldb::SBData - GetSectionData (); - - lldb::SBData - GetSectionData (uint64_t offset, - uint64_t size); - - SectionType - GetSectionType (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Return the size of a target's byte represented by this section - /// in numbers of host bytes. Note that certain architectures have - /// varying minimum addressable unit (i.e. byte) size for their - /// CODE or DATA buses. - /// - /// @return - /// The number of host (8-bit) bytes needed to hold a target byte - //------------------------------------------------------------------ - ") GetTargetByteSize; - uint32_t - GetTargetByteSize (); - - bool - GetDescription (lldb::SBStream &description); - - bool - operator == (const lldb::SBSection &rhs); - - bool - operator != (const lldb::SBSection &rhs); - - %pythoncode %{ - def get_addr(self): - return SBAddress(self, 0) - - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name of this section as a string.''') - - __swig_getmethods__["addr"] = get_addr - if _newclass: addr = property(get_addr, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this section.''') - - __swig_getmethods__["file_addr"] = GetFileAddress - if _newclass: file_addr = property(GetFileAddress, None, doc='''A read only property that returns an integer that represents the starting "file" address for this section, or the address of the section in the object file in which it is defined.''') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this section as an integer.''') - - __swig_getmethods__["file_offset"] = GetFileOffset - if _newclass: file_offset = property(GetFileOffset, None, doc='''A read only property that returns the file offset in bytes of this section as an integer.''') - - __swig_getmethods__["file_size"] = GetFileByteSize - if _newclass: file_size = property(GetFileByteSize, None, doc='''A read only property that returns the file size in bytes of this section as an integer.''') - - __swig_getmethods__["data"] = GetSectionData - if _newclass: data = property(GetSectionData, None, doc='''A read only property that returns an lldb object that represents the bytes for this section (lldb.SBData) for this section.''') - - __swig_getmethods__["type"] = GetSectionType - if _newclass: type = property(GetSectionType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSectionType") that represents the type of this section (code, data, etc.).''') - - __swig_getmethods__["target_byte_size"] = GetTargetByteSize - if _newclass: target_byte_size = property(GetTargetByteSize, None, doc='''A read only property that returns the size of a target byte represented by this section as a number of host bytes.''') - - %} - -private: - - std::unique_ptr m_opaque_ap; -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBSourceManager.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBSourceManager.i +++ lldb/trunk/scripts/Python/interface/SBSourceManager.i @@ -1,54 +0,0 @@ -//===-- SWIG Interface for SBSourceManager ----------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a central authority for displaying source code. - -For example (from test/source-manager/TestSourceManager.py), - - # Create the filespec for 'main.c'. - filespec = lldb.SBFileSpec('main.c', False) - source_mgr = self.dbg.GetSourceManager() - # Use a string stream as the destination. - stream = lldb.SBStream() - source_mgr.DisplaySourceLinesWithLineNumbers(filespec, - self.line, - 2, # context before - 2, # context after - '=>', # prefix for current line - stream) - - # 2 - # 3 int main(int argc, char const *argv[]) { - # => 4 printf('Hello world.\\n'); // Set break point at this line. - # 5 return 0; - # 6 } - self.expect(stream.GetData(), 'Source code displayed correctly', - exe=False, - patterns = ['=> %d.*Hello world' % self.line]) -") SBSourceManager; -class SBSourceManager -{ -public: - SBSourceManager (const lldb::SBSourceManager &rhs); - - ~SBSourceManager(); - - size_t - DisplaySourceLinesWithLineNumbers (const lldb::SBFileSpec &file, - uint32_t line, - uint32_t context_before, - uint32_t context_after, - const char* current_line_cstr, - lldb::SBStream &s); -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBStream.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBStream.i +++ lldb/trunk/scripts/Python/interface/SBStream.i @@ -1,100 +0,0 @@ -//===-- SWIG Interface for SBStream -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include - -namespace lldb { - -%feature("docstring", -"Represents a destination for streaming data output to. By default, a string -stream is created. - -For example (from test/source-manager/TestSourceManager.py), - - # Create the filespec for 'main.c'. - filespec = lldb.SBFileSpec('main.c', False) - source_mgr = self.dbg.GetSourceManager() - # Use a string stream as the destination. - stream = lldb.SBStream() - source_mgr.DisplaySourceLinesWithLineNumbers(filespec, - self.line, - 2, # context before - 2, # context after - '=>', # prefix for current line - stream) - - # 2 - # 3 int main(int argc, char const *argv[]) { - # => 4 printf('Hello world.\\n'); // Set break point at this line. - # 5 return 0; - # 6 } - self.expect(stream.GetData(), 'Source code displayed correctly', - exe=False, - patterns = ['=> %d.*Hello world' % self.line]) -") SBStream; -class SBStream -{ -public: - - SBStream (); - - ~SBStream (); - - bool - IsValid() const; - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// If this stream is not redirected to a file, it will maintain a local - /// cache for the stream data which can be accessed using this accessor. - //-------------------------------------------------------------------------- - ") GetData; - const char * - GetData (); - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// If this stream is not redirected to a file, it will maintain a local - /// cache for the stream output whose length can be accessed using this - /// accessor. - //-------------------------------------------------------------------------- - ") GetSize; - size_t - GetSize(); - - // wrapping the variadic Printf() with a plain Print() - // because it is hard to support varargs in SWIG bridgings - %extend { - void Print (const char* str) - { - self->Printf("%s", str); - } - } - - void - RedirectToFile (const char *path, bool append); - - void - RedirectToFileHandle (FILE *fh, bool transfer_fh_ownership); - - void - RedirectToFileDescriptor (int fd, bool transfer_fh_ownership); - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// If the stream is redirected to a file, forget about the file and if - /// ownership of the file was transferred to this object, close the file. - /// If the stream is backed by a local cache, clear this cache. - //-------------------------------------------------------------------------- - ") Clear; - void - Clear (); -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBStringList.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBStringList.i +++ lldb/trunk/scripts/Python/interface/SBStringList.i @@ -1,44 +0,0 @@ -//===-- SWIG Interface for SBStringList -------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBStringList -{ -public: - - SBStringList (); - - SBStringList (const lldb::SBStringList &rhs); - - ~SBStringList (); - - bool - IsValid() const; - - void - AppendString (const char *str); - - void - AppendList (const char **strv, int strc); - - void - AppendList (const lldb::SBStringList &strings); - - uint32_t - GetSize () const; - - const char * - GetStringAtIndex (size_t idx); - - void - Clear (); -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBSymbol.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBSymbol.i +++ lldb/trunk/scripts/Python/interface/SBSymbol.i @@ -1,107 +0,0 @@ -//===-- SWIG Interface for SBSymbol -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents the symbol possibly associated with a stack frame. -SBModule contains SBSymbol(s). SBSymbol can also be retrived from SBFrame. - -See also SBModule and SBFrame." -) SBSymbol; -class SBSymbol -{ -public: - - SBSymbol (); - - ~SBSymbol (); - - SBSymbol (const lldb::SBSymbol &rhs); - - bool - IsValid () const; - - - const char * - GetName() const; - - const char * - GetMangledName () const; - - lldb::SBInstructionList - GetInstructions (lldb::SBTarget target); - - lldb::SBInstructionList - GetInstructions (lldb::SBTarget target, const char *flavor_string); - - SBAddress - GetStartAddress (); - - SBAddress - GetEndAddress (); - - uint32_t - GetPrologueByteSize (); - - SymbolType - GetType (); - - bool - GetDescription (lldb::SBStream &description); - - bool - IsExternal(); - - bool - IsSynthetic(); - - bool - operator == (const lldb::SBSymbol &rhs) const; - - bool - operator != (const lldb::SBSymbol &rhs) const; - - %pythoncode %{ - def get_instructions_from_current_target (self): - return self.GetInstructions (target) - - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this symbol as a string.''') - - __swig_getmethods__["mangled"] = GetMangledName - if _newclass: mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this symbol as a string.''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSymbolType") that represents the type of this symbol.''') - - __swig_getmethods__["addr"] = GetStartAddress - if _newclass: addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this symbol.''') - - __swig_getmethods__["end_addr"] = GetEndAddress - if _newclass: end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this symbol.''') - - __swig_getmethods__["prologue_size"] = GetPrologueByteSize - if _newclass: prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''') - - __swig_getmethods__["instructions"] = get_instructions_from_current_target - if _newclass: instructions = property(get_instructions_from_current_target, None, doc='''A read only property that returns an lldb object that represents the instructions (lldb.SBInstructionList) for this symbol.''') - - __swig_getmethods__["external"] = IsExternal - if _newclass: external = property(IsExternal, None, doc='''A read only property that returns a boolean value that indicates if this symbol is externally visiable (exported) from the module that contains it.''') - - __swig_getmethods__["synthetic"] = IsSynthetic - if _newclass: synthetic = property(IsSynthetic, None, doc='''A read only property that returns a boolean value that indicates if this symbol was synthetically created from information in module that contains it.''') - - - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBSymbolContext.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBSymbolContext.i +++ lldb/trunk/scripts/Python/interface/SBSymbolContext.i @@ -1,112 +0,0 @@ -//===-- SWIG Interface for SBSymbolContext ----------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"A context object that provides access to core debugger entities. - -Manay debugger functions require a context when doing lookups. This class -provides a common structure that can be used as the result of a query that -can contain a single result. - -For example, - - exe = os.path.join(os.getcwd(), 'a.out') - - # Create a target for the debugger. - target = self.dbg.CreateTarget(exe) - - # Now create a breakpoint on main.c by name 'c'. - breakpoint = target.BreakpointCreateByName('c', 'a.out') - - # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple(None, None, os.getcwd()) - - # The inferior should stop on 'c'. - from lldbutil import get_stopped_thread - thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) - frame0 = thread.GetFrameAtIndex(0) - - # Now get the SBSymbolContext from this frame. We want everything. :-) - context = frame0.GetSymbolContext(lldb.eSymbolContextEverything) - - # Get the module. - module = context.GetModule() - ... - - # And the compile unit associated with the frame. - compileUnit = context.GetCompileUnit() - ... -" -) SBSymbolContext; -class SBSymbolContext -{ -public: - SBSymbolContext (); - - SBSymbolContext (const lldb::SBSymbolContext& rhs); - - ~SBSymbolContext (); - - bool - IsValid () const; - - lldb::SBModule GetModule (); - lldb::SBCompileUnit GetCompileUnit (); - lldb::SBFunction GetFunction (); - lldb::SBBlock GetBlock (); - lldb::SBLineEntry GetLineEntry (); - lldb::SBSymbol GetSymbol (); - - void SetModule (lldb::SBModule module); - void SetCompileUnit (lldb::SBCompileUnit compile_unit); - void SetFunction (lldb::SBFunction function); - void SetBlock (lldb::SBBlock block); - void SetLineEntry (lldb::SBLineEntry line_entry); - void SetSymbol (lldb::SBSymbol symbol); - - lldb::SBSymbolContext - GetParentOfInlinedScope (const lldb::SBAddress &curr_frame_pc, - lldb::SBAddress &parent_frame_addr) const; - - - bool - GetDescription (lldb::SBStream &description); - - - %pythoncode %{ - __swig_getmethods__["module"] = GetModule - __swig_setmethods__["module"] = SetModule - if _newclass: module = property(GetModule, SetModule, doc='''A read/write property that allows the getting/setting of the module (lldb.SBModule) in this symbol context.''') - - __swig_getmethods__["compile_unit"] = GetCompileUnit - __swig_setmethods__["compile_unit"] = SetCompileUnit - if _newclass: compile_unit = property(GetCompileUnit, SetCompileUnit, doc='''A read/write property that allows the getting/setting of the compile unit (lldb.SBCompileUnit) in this symbol context.''') - - __swig_getmethods__["function"] = GetFunction - __swig_setmethods__["function"] = SetFunction - if _newclass: function = property(GetFunction, SetFunction, doc='''A read/write property that allows the getting/setting of the function (lldb.SBFunction) in this symbol context.''') - - __swig_getmethods__["block"] = GetBlock - __swig_setmethods__["block"] = SetBlock - if _newclass: block = property(GetBlock, SetBlock, doc='''A read/write property that allows the getting/setting of the block (lldb.SBBlock) in this symbol context.''') - - __swig_getmethods__["symbol"] = GetSymbol - __swig_setmethods__["symbol"] = SetSymbol - if _newclass: symbol = property(GetSymbol, SetSymbol, doc='''A read/write property that allows the getting/setting of the symbol (lldb.SBSymbol) in this symbol context.''') - - __swig_getmethods__["line_entry"] = GetLineEntry - __swig_setmethods__["line_entry"] = SetLineEntry - if _newclass: line_entry = property(GetLineEntry, SetLineEntry, doc='''A read/write property that allows the getting/setting of the line entry (lldb.SBLineEntry) in this symbol context.''') - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBSymbolContextList.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBSymbolContextList.i +++ lldb/trunk/scripts/Python/interface/SBSymbolContextList.i @@ -1,140 +0,0 @@ -//===-- SWIG Interface for SBSymbolContextList ------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a list of symbol context object. See also SBSymbolContext. - -For example (from test/python_api/target/TestTargetAPI.py), - - def find_functions(self, exe_name): - '''Exercise SBTaget.FindFunctions() API.''' - exe = os.path.join(os.getcwd(), exe_name) - - # Create a target by the debugger. - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - list = lldb.SBSymbolContextList() - num = target.FindFunctions('c', lldb.eFunctionNameTypeAuto, False, list) - self.assertTrue(num == 1 and list.GetSize() == 1) - - for sc in list: - self.assertTrue(sc.GetModule().GetFileSpec().GetFilename() == exe_name) - self.assertTrue(sc.GetSymbol().GetName() == 'c') -") SBSymbolContextList; -class SBSymbolContextList -{ -public: - SBSymbolContextList (); - - SBSymbolContextList (const lldb::SBSymbolContextList& rhs); - - ~SBSymbolContextList (); - - bool - IsValid () const; - - uint32_t - GetSize() const; - - SBSymbolContext - GetContextAtIndex (uint32_t idx); - - void - Append (lldb::SBSymbolContext &sc); - - void - Append (lldb::SBSymbolContextList &sc_list); - - bool - GetDescription (lldb::SBStream &description); - - void - Clear(); - - %pythoncode %{ - def __len__(self): - return int(self.GetSize()) - - def __getitem__(self, key): - count = len(self) - if type(key) is int: - if key < count: - return self.GetContextAtIndex(key) - else: - raise IndexError - raise TypeError - - def get_module_array(self): - a = [] - for i in range(len(self)): - obj = self.GetContextAtIndex(i).module - if obj: - a.append(obj) - return a - - def get_compile_unit_array(self): - a = [] - for i in range(len(self)): - obj = self.GetContextAtIndex(i).compile_unit - if obj: - a.append(obj) - return a - def get_function_array(self): - a = [] - for i in range(len(self)): - obj = self.GetContextAtIndex(i).function - if obj: - a.append(obj) - return a - def get_block_array(self): - a = [] - for i in range(len(self)): - obj = self.GetContextAtIndex(i).block - if obj: - a.append(obj) - return a - def get_symbol_array(self): - a = [] - for i in range(len(self)): - obj = self.GetContextAtIndex(i).symbol - if obj: - a.append(obj) - return a - def get_line_entry_array(self): - a = [] - for i in range(len(self)): - obj = self.GetContextAtIndex(i).line_entry - if obj: - a.append(obj) - return a - __swig_getmethods__["modules"] = get_module_array - if _newclass: modules = property(get_module_array, None, doc='''Returns a list() of lldb.SBModule objects, one for each module in each SBSymbolContext object in this list.''') - - __swig_getmethods__["compile_units"] = get_compile_unit_array - if _newclass: compile_units = property(get_compile_unit_array, None, doc='''Returns a list() of lldb.SBCompileUnit objects, one for each compile unit in each SBSymbolContext object in this list.''') - - __swig_getmethods__["functions"] = get_function_array - if _newclass: functions = property(get_function_array, None, doc='''Returns a list() of lldb.SBFunction objects, one for each function in each SBSymbolContext object in this list.''') - - __swig_getmethods__["blocks"] = get_block_array - if _newclass: blocks = property(get_block_array, None, doc='''Returns a list() of lldb.SBBlock objects, one for each block in each SBSymbolContext object in this list.''') - - __swig_getmethods__["line_entries"] = get_line_entry_array - if _newclass: line_entries = property(get_line_entry_array, None, doc='''Returns a list() of lldb.SBLineEntry objects, one for each line entry in each SBSymbolContext object in this list.''') - - __swig_getmethods__["symbols"] = get_symbol_array - if _newclass: symbols = property(get_symbol_array, None, doc='''Returns a list() of lldb.SBSymbol objects, one for each symbol in each SBSymbolContext object in this list.''') - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBTarget.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBTarget.i +++ lldb/trunk/scripts/Python/interface/SBTarget.i @@ -1,853 +0,0 @@ -//===-- SWIG Interface for SBTarget -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - -%feature("docstring", -"Represents the target program running under the debugger. - -SBTarget supports module, breakpoint, and watchpoint iterations. For example, - - for m in target.module_iter(): - print m - -produces: - -(x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out -(x86_64) /usr/lib/dyld -(x86_64) /usr/lib/libstdc++.6.dylib -(x86_64) /usr/lib/libSystem.B.dylib -(x86_64) /usr/lib/system/libmathCommon.A.dylib -(x86_64) /usr/lib/libSystem.B.dylib(__commpage) - -and, - - for b in target.breakpoint_iter(): - print b - -produces: - -SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1 -SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1 - -and, - - for wp_loc in target.watchpoint_iter(): - print wp_loc - -produces: - -Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw - declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12' - hw_index = 0 hit_count = 2 ignore_count = 0" -) SBTarget; -class SBTarget -{ -public: - //------------------------------------------------------------------ - // Broadcaster bits. - //------------------------------------------------------------------ - enum - { - eBroadcastBitBreakpointChanged = (1 << 0), - eBroadcastBitModulesLoaded = (1 << 1), - eBroadcastBitModulesUnloaded = (1 << 2), - eBroadcastBitWatchpointChanged = (1 << 3), - eBroadcastBitSymbolsLoaded = (1 << 4) - }; - - //------------------------------------------------------------------ - // Constructors - //------------------------------------------------------------------ - SBTarget (); - - SBTarget (const lldb::SBTarget& rhs); - - //------------------------------------------------------------------ - // Destructor - //------------------------------------------------------------------ - ~SBTarget(); - - static const char * - GetBroadcasterClassName (); - - bool - IsValid() const; - - static bool - EventIsTargetEvent (const lldb::SBEvent &event); - - static lldb::SBTarget - GetTargetFromEvent (const lldb::SBEvent &event); - - static uint32_t - GetNumModulesFromEvent (const lldb::SBEvent &event); - - static lldb::SBModule - GetModuleAtIndexFromEvent (const uint32_t idx, const lldb::SBEvent &event); - - lldb::SBProcess - GetProcess (); - - - %feature("docstring", " - //------------------------------------------------------------------ - /// Return the platform object associated with the target. - /// - /// After return, the platform object should be checked for - /// validity. - /// - /// @return - /// A platform object. - //------------------------------------------------------------------ - ") GetPlatform; - lldb::SBPlatform - GetPlatform (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Install any binaries that need to be installed. - /// - /// This function does nothing when debugging on the host system. - /// When connected to remote platforms, the target's main executable - /// and any modules that have their install path set will be - /// installed on the remote platform. If the main executable doesn't - /// have an install location set, it will be installed in the remote - /// platform's working directory. - /// - /// @return - /// An error describing anything that went wrong during - /// installation. - //------------------------------------------------------------------ - ") Install; - lldb::SBError - Install(); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Launch a new process. - /// - /// Launch a new process by spawning a new process using the - /// target object's executable module's file as the file to launch. - /// Arguments are given in \a argv, and the environment variables - /// are in \a envp. Standard input and output files can be - /// optionally re-directed to \a stdin_path, \a stdout_path, and - /// \a stderr_path. - /// - /// @param[in] listener - /// An optional listener that will receive all process events. - /// If \a listener is valid then \a listener will listen to all - /// process events. If not valid, then this target's debugger - /// (SBTarget::GetDebugger()) will listen to all process events. - /// - /// @param[in] argv - /// The argument array. - /// - /// @param[in] envp - /// The environment array. - /// - /// @param[in] launch_flags - /// Flags to modify the launch (@see lldb::LaunchFlags) - /// - /// @param[in] stdin_path - /// The path to use when re-directing the STDIN of the new - /// process. If all stdXX_path arguments are NULL, a pseudo - /// terminal will be used. - /// - /// @param[in] stdout_path - /// The path to use when re-directing the STDOUT of the new - /// process. If all stdXX_path arguments are NULL, a pseudo - /// terminal will be used. - /// - /// @param[in] stderr_path - /// The path to use when re-directing the STDERR of the new - /// process. If all stdXX_path arguments are NULL, a pseudo - /// terminal will be used. - /// - /// @param[in] working_directory - /// The working directory to have the child process run in - /// - /// @param[in] launch_flags - /// Some launch options specified by logical OR'ing - /// lldb::LaunchFlags enumeration values together. - /// - /// @param[in] stop_at_endtry - /// If false do not stop the inferior at the entry point. - /// - /// @param[out] - /// An error object. Contains the reason if there is some failure. - /// - /// @return - /// A process object for the newly created process. - //------------------------------------------------------------------ - - For example, - - process = target.Launch(self.dbg.GetListener(), None, None, - None, '/tmp/stdout.txt', None, - None, 0, False, error) - - launches a new process by passing nothing for both the args and the envs - and redirect the standard output of the inferior to the /tmp/stdout.txt - file. It does not specify a working directory so that the debug server - will use its idea of what the current working directory is for the - inferior. Also, we ask the debugger not to stop the inferior at the - entry point. If no breakpoint is specified for the inferior, it should - run to completion if no user interaction is required. - ") Launch; - lldb::SBProcess - Launch (SBListener &listener, - char const **argv, - char const **envp, - const char *stdin_path, - const char *stdout_path, - const char *stderr_path, - const char *working_directory, - uint32_t launch_flags, // See LaunchFlags - bool stop_at_entry, - lldb::SBError& error); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Launch a new process with sensible defaults. - /// - /// @param[in] argv - /// The argument array. - /// - /// @param[in] envp - /// The environment array. - /// - /// @param[in] working_directory - /// The working directory to have the child process run in - /// - /// Default: listener - /// Set to the target's debugger (SBTarget::GetDebugger()) - /// - /// Default: launch_flags - /// Empty launch flags - /// - /// Default: stdin_path - /// Default: stdout_path - /// Default: stderr_path - /// A pseudo terminal will be used. - /// - /// @return - /// A process object for the newly created process. - //------------------------------------------------------------------ - - For example, - - process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd()) - - launches a new process by passing 'X', 'Y', 'Z' as the args to the - executable. - ") LaunchSimple; - lldb::SBProcess - LaunchSimple (const char **argv, - const char **envp, - const char *working_directory); - - lldb::SBProcess - Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Load a core file - /// - /// @param[in] core_file - /// File path of the core dump. - /// - /// @return - /// A process object for the newly created core file. - //------------------------------------------------------------------ - - For example, - - process = target.LoadCore('./a.out.core') - - loads a new core file and returns the process object. - ") LoadCore; - lldb::SBProcess - LoadCore(const char *core_file); - - lldb::SBProcess - Attach (lldb::SBAttachInfo &attach_info, lldb::SBError& error); - - - %feature("docstring", " - //------------------------------------------------------------------ - /// Attach to process with pid. - /// - /// @param[in] listener - /// An optional listener that will receive all process events. - /// If \a listener is valid then \a listener will listen to all - /// process events. If not valid, then this target's debugger - /// (SBTarget::GetDebugger()) will listen to all process events. - /// - /// @param[in] pid - /// The process ID to attach to. - /// - /// @param[out] - /// An error explaining what went wrong if attach fails. - /// - /// @return - /// A process object for the attached process. - //------------------------------------------------------------------ - ") AttachToProcessWithID; - lldb::SBProcess - AttachToProcessWithID (SBListener &listener, - lldb::pid_t pid, - lldb::SBError& error); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Attach to process with name. - /// - /// @param[in] listener - /// An optional listener that will receive all process events. - /// If \a listener is valid then \a listener will listen to all - /// process events. If not valid, then this target's debugger - /// (SBTarget::GetDebugger()) will listen to all process events. - /// - /// @param[in] name - /// Basename of process to attach to. - /// - /// @param[in] wait_for - /// If true wait for a new instance of 'name' to be launched. - /// - /// @param[out] - /// An error explaining what went wrong if attach fails. - /// - /// @return - /// A process object for the attached process. - //------------------------------------------------------------------ - ") AttachToProcessWithName; - lldb::SBProcess - AttachToProcessWithName (SBListener &listener, - const char *name, - bool wait_for, - lldb::SBError& error); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Connect to a remote debug server with url. - /// - /// @param[in] listener - /// An optional listener that will receive all process events. - /// If \a listener is valid then \a listener will listen to all - /// process events. If not valid, then this target's debugger - /// (SBTarget::GetDebugger()) will listen to all process events. - /// - /// @param[in] url - /// The url to connect to, e.g., 'connect://localhost:12345'. - /// - /// @param[in] plugin_name - /// The plugin name to be used; can be NULL. - /// - /// @param[out] - /// An error explaining what went wrong if the connect fails. - /// - /// @return - /// A process object for the connected process. - //------------------------------------------------------------------ - ") ConnectRemote; - lldb::SBProcess - ConnectRemote (SBListener &listener, - const char *url, - const char *plugin_name, - SBError& error); - - lldb::SBFileSpec - GetExecutable (); - - bool - AddModule (lldb::SBModule &module); - - lldb::SBModule - AddModule (const char *path, - const char *triple, - const char *uuid); - - lldb::SBModule - AddModule (const char *path, - const char *triple, - const char *uuid_cstr, - const char *symfile); - - lldb::SBModule - AddModule (const SBModuleSpec &module_spec); - - uint32_t - GetNumModules () const; - - lldb::SBModule - GetModuleAtIndex (uint32_t idx); - - bool - RemoveModule (lldb::SBModule module); - - lldb::SBDebugger - GetDebugger() const; - - lldb::SBModule - FindModule (const lldb::SBFileSpec &file_spec); - - lldb::ByteOrder - GetByteOrder (); - - uint32_t - GetAddressByteSize(); - - const char * - GetTriple (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Architecture data byte width accessor - /// - /// @return - /// The size in 8-bit (host) bytes of a minimum addressable - /// unit from the Architecture's data bus - //------------------------------------------------------------------ - ") GetDataByteSize; - uint32_t - GetDataByteSize (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Architecture code byte width accessor - /// - /// @return - /// The size in 8-bit (host) bytes of a minimum addressable - /// unit from the Architecture's code bus - //------------------------------------------------------------------ - ") GetCodeByteSize; - uint32_t - GetCodeByteSize (); - - lldb::SBError - SetSectionLoadAddress (lldb::SBSection section, - lldb::addr_t section_base_addr); - - lldb::SBError - ClearSectionLoadAddress (lldb::SBSection section); - - lldb::SBError - SetModuleLoadAddress (lldb::SBModule module, - int64_t sections_offset); - - lldb::SBError - ClearModuleLoadAddress (lldb::SBModule module); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Find functions by name. - /// - /// @param[in] name - /// The name of the function we are looking for. - /// - /// @param[in] name_type_mask - /// A logical OR of one or more FunctionNameType enum bits that - /// indicate what kind of names should be used when doing the - /// lookup. Bits include fully qualified names, base names, - /// C++ methods, or ObjC selectors. - /// See FunctionNameType for more details. - /// - /// @return - /// A lldb::SBSymbolContextList that gets filled in with all of - /// the symbol contexts for all the matches. - //------------------------------------------------------------------ - ") FindFunctions; - lldb::SBSymbolContextList - FindFunctions (const char *name, - uint32_t name_type_mask = lldb::eFunctionNameTypeAny); - - lldb::SBType - FindFirstType (const char* type); - - lldb::SBTypeList - FindTypes (const char* type); - - lldb::SBType - GetBasicType(lldb::BasicType type); - - lldb::SBSourceManager - GetSourceManager (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Find global and static variables by name. - /// - /// @param[in] name - /// The name of the global or static variable we are looking - /// for. - /// - /// @param[in] max_matches - /// Allow the number of matches to be limited to \a max_matches. - /// - /// @return - /// A list of matched variables in an SBValueList. - //------------------------------------------------------------------ - ") FindGlobalVariables; - lldb::SBValueList - FindGlobalVariables (const char *name, - uint32_t max_matches); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Find the first global (or static) variable by name. - /// - /// @param[in] name - /// The name of the global or static variable we are looking - /// for. - /// - /// @return - /// An SBValue that gets filled in with the found variable (if any). - //------------------------------------------------------------------ - ") FindFirstGlobalVariable; - lldb::SBValue - FindFirstGlobalVariable (const char* name); - - - lldb::SBValueList - FindGlobalVariables(const char *name, - uint32_t max_matches, - MatchType matchtype); - - lldb::SBSymbolContextList - FindGlobalFunctions(const char *name, - uint32_t max_matches, - MatchType matchtype); - - void - Clear (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Resolve a current file address into a section offset address. - /// - /// @param[in] file_addr - /// - /// @return - /// An SBAddress which will be valid if... - //------------------------------------------------------------------ - ") ResolveFileAddress; - lldb::SBAddress - ResolveFileAddress (lldb::addr_t file_addr); - - lldb::SBAddress - ResolveLoadAddress (lldb::addr_t vm_addr); - - lldb::SBAddress - ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr); - - SBSymbolContext - ResolveSymbolContextForAddress (const SBAddress& addr, - uint32_t resolve_scope); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Read target memory. If a target process is running then memory - /// is read from here. Otherwise the memory is read from the object - /// files. For a target whose bytes are sized as a multiple of host - /// bytes, the data read back will preserve the target's byte order. - /// - /// @param[in] addr - /// A target address to read from. - /// - /// @param[out] buf - /// The buffer to read memory into. - /// - /// @param[in] size - /// The maximum number of host bytes to read in the buffer passed - /// into this call - /// - /// @param[out] error - /// Error information is written here if the memory read fails. - /// - /// @return - /// The amount of data read in host bytes. - //------------------------------------------------------------------ - ") ReadMemory; - size_t - ReadMemory (const SBAddress addr, void *buf, size_t size, lldb::SBError &error); - - lldb::SBBreakpoint - BreakpointCreateByLocation (const char *file, uint32_t line); - - lldb::SBBreakpoint - BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); - - lldb::SBBreakpoint - BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); - - lldb::SBBreakpoint - BreakpointCreateByName (const char *symbol_name, - uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits - const SBFileSpecList &module_list, - const SBFileSpecList &comp_unit_list); - - lldb::SBBreakpoint - BreakpointCreateByNames (const char *symbol_name[], - uint32_t num_names, - uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits - const SBFileSpecList &module_list, - const SBFileSpecList &comp_unit_list); - - lldb::SBBreakpoint - BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); - - lldb::SBBreakpoint - BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL); - - lldb::SBBreakpoint - BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpecList &module_list, const lldb::SBFileSpecList &file_list); - - lldb::SBBreakpoint - BreakpointCreateForException (lldb::LanguageType language, - bool catch_bp, - bool throw_bp); - - lldb::SBBreakpoint - BreakpointCreateByAddress (addr_t address); - - uint32_t - GetNumBreakpoints () const; - - lldb::SBBreakpoint - GetBreakpointAtIndex (uint32_t idx) const; - - bool - BreakpointDelete (break_id_t break_id); - - lldb::SBBreakpoint - FindBreakpointByID (break_id_t break_id); - - bool - EnableAllBreakpoints (); - - bool - DisableAllBreakpoints (); - - bool - DeleteAllBreakpoints (); - - uint32_t - GetNumWatchpoints () const; - - lldb::SBWatchpoint - GetWatchpointAtIndex (uint32_t idx) const; - - bool - DeleteWatchpoint (lldb::watch_id_t watch_id); - - lldb::SBWatchpoint - FindWatchpointByID (lldb::watch_id_t watch_id); - - bool - EnableAllWatchpoints (); - - bool - DisableAllWatchpoints (); - - bool - DeleteAllWatchpoints (); - - lldb::SBWatchpoint - WatchAddress (lldb::addr_t addr, - size_t size, - bool read, - bool write, - SBError &error); - - - lldb::SBBroadcaster - GetBroadcaster () const; - - lldb::SBValue - CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type); - - lldb::SBValue - CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type); - - lldb::SBValue - CreateValueFromExpression (const char *name, const char* expr); - - %feature("docstring", " - Disassemble a specified number of instructions starting at an address. - Parameters: - base_addr -- the address to start disassembly from - count -- the number of instructions to disassemble - flavor_string -- may be 'intel' or 'att' on x86 targets to specify that style of disassembly - Returns an SBInstructionList.") - ReadInstructions; - lldb::SBInstructionList - ReadInstructions (lldb::SBAddress base_addr, uint32_t count); - - lldb::SBInstructionList - ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string); - - %feature("docstring", " - Disassemble the bytes in a buffer and return them in an SBInstructionList. - Parameters: - base_addr -- used for symbolicating the offsets in the byte stream when disassembling - buf -- bytes to be disassembled - size -- (C++) size of the buffer - Returns an SBInstructionList.") - GetInstructions; - lldb::SBInstructionList - GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size); - - %feature("docstring", " - Disassemble the bytes in a buffer and return them in an SBInstructionList, with a supplied flavor. - Parameters: - base_addr -- used for symbolicating the offsets in the byte stream when disassembling - flavor -- may be 'intel' or 'att' on x86 targets to specify that style of disassembly - buf -- bytes to be disassembled - size -- (C++) size of the buffer - Returns an SBInstructionList.") - GetInstructionsWithFlavor; - lldb::SBInstructionList - GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size); - - lldb::SBSymbolContextList - FindSymbols (const char *name, lldb::SymbolType type = eSymbolTypeAny); - - bool - GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); - - lldb::addr_t - GetStackRedZoneSize(); - - lldb::SBLaunchInfo - GetLaunchInfo () const; - - void - SetLaunchInfo (const lldb::SBLaunchInfo &launch_info); - - bool - operator == (const lldb::SBTarget &rhs) const; - - bool - operator != (const lldb::SBTarget &rhs) const; - - lldb::SBValue - EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options); - %pythoncode %{ - class modules_access(object): - '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.''' - def __init__(self, sbtarget): - self.sbtarget = sbtarget - - def __len__(self): - if self.sbtarget: - return int(self.sbtarget.GetNumModules()) - return 0 - - def __getitem__(self, key): - num_modules = self.sbtarget.GetNumModules() - if type(key) is int: - if key < num_modules: - return self.sbtarget.GetModuleAtIndex(key) - elif type(key) is str: - if key.find('/') == -1: - for idx in range(num_modules): - module = self.sbtarget.GetModuleAtIndex(idx) - if module.file.basename == key: - return module - else: - for idx in range(num_modules): - module = self.sbtarget.GetModuleAtIndex(idx) - if module.file.fullpath == key: - return module - # See if the string is a UUID - try: - the_uuid = uuid.UUID(key) - if the_uuid: - for idx in range(num_modules): - module = self.sbtarget.GetModuleAtIndex(idx) - if module.uuid == the_uuid: - return module - except: - return None - elif type(key) is uuid.UUID: - for idx in range(num_modules): - module = self.sbtarget.GetModuleAtIndex(idx) - if module.uuid == key: - return module - elif type(key) is re.SRE_Pattern: - matching_modules = [] - for idx in range(num_modules): - module = self.sbtarget.GetModuleAtIndex(idx) - re_match = key.search(module.path.fullpath) - if re_match: - matching_modules.append(module) - return matching_modules - else: - print "error: unsupported item type: %s" % type(key) - return None - - def get_modules_access_object(self): - '''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.''' - return self.modules_access (self) - - def get_modules_array(self): - '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.''' - modules = [] - for idx in range(self.GetNumModules()): - modules.append(self.GetModuleAtIndex(idx)) - return modules - - __swig_getmethods__["modules"] = get_modules_array - if _newclass: modules = property(get_modules_array, None, doc='''A read only property that returns a list() of lldb.SBModule objects contained in this target. This list is a list all modules that the target currently is tracking (the main executable and all dependent shared libraries).''') - - __swig_getmethods__["module"] = get_modules_access_object - if _newclass: module = property(get_modules_access_object, None, doc=r'''A read only property that returns an object that implements python operator overloading with the square brackets().\n target.module[] allows array access to any modules.\n target.module[] allows access to modules by basename, full path, or uuid string value.\n target.module[uuid.UUID()] allows module access by UUID.\n target.module[re] allows module access using a regular expression that matches the module full path.''') - - __swig_getmethods__["process"] = GetProcess - if _newclass: process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that this target owns.''') - - __swig_getmethods__["executable"] = GetExecutable - if _newclass: executable = property(GetExecutable, None, doc='''A read only property that returns an lldb object that represents the main executable module (lldb.SBModule) for this target.''') - - __swig_getmethods__["debugger"] = GetDebugger - if _newclass: debugger = property(GetDebugger, None, doc='''A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.''') - - __swig_getmethods__["num_breakpoints"] = GetNumBreakpoints - if _newclass: num_breakpoints = property(GetNumBreakpoints, None, doc='''A read only property that returns the number of breakpoints that this target has as an integer.''') - - __swig_getmethods__["num_watchpoints"] = GetNumWatchpoints - if _newclass: num_watchpoints = property(GetNumWatchpoints, None, doc='''A read only property that returns the number of watchpoints that this target has as an integer.''') - - __swig_getmethods__["broadcaster"] = GetBroadcaster - if _newclass: broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this target.''') - - __swig_getmethods__["byte_order"] = GetByteOrder - if _newclass: byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this target.''') - - __swig_getmethods__["addr_size"] = GetAddressByteSize - if _newclass: addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this target.''') - - __swig_getmethods__["triple"] = GetTriple - if _newclass: triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''') - - __swig_getmethods__["data_byte_size"] = GetDataByteSize - if _newclass: data_byte_size = property(GetDataByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the data address space for this target.''') - - __swig_getmethods__["code_byte_size"] = GetCodeByteSize - if _newclass: code_byte_size = property(GetCodeByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the code address space for this target.''') - - __swig_getmethods__["platform"] = GetPlatform - if _newclass: platform = property(GetPlatform, None, doc='''A read only property that returns the platform associated with with this target.''') - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBThread.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBThread.i +++ lldb/trunk/scripts/Python/interface/SBThread.i @@ -1,401 +0,0 @@ -//===-- SWIG Interface for SBThread -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a thread of execution. SBProcess contains SBThread(s). - -SBThreads can be referred to by their ID, which maps to the system specific thread -identifier, or by IndexID. The ID may or may not be unique depending on whether the -system reuses its thread identifiers. The IndexID is a monotonically increasing identifier -that will always uniquely reference a particular thread, and when that thread goes -away it will not be reused. - -SBThread supports frame iteration. For example (from test/python_api/ -lldbutil/iter/TestLLDBIterator.py), - - from lldbutil import print_stacktrace - stopped_due_to_breakpoint = False - for thread in process: - if self.TraceOn(): - print_stacktrace(thread) - ID = thread.GetThreadID() - if thread.GetStopReason() == lldb.eStopReasonBreakpoint: - stopped_due_to_breakpoint = True - for frame in thread: - self.assertTrue(frame.GetThread().GetThreadID() == ID) - if self.TraceOn(): - print frame - - self.assertTrue(stopped_due_to_breakpoint) - -See also SBProcess and SBFrame." -) SBThread; -class SBThread -{ -public: - //------------------------------------------------------------------ - // Broadcaster bits. - //------------------------------------------------------------------ - enum - { - eBroadcastBitStackChanged = (1 << 0), - eBroadcastBitThreadSuspended = (1 << 1), - eBroadcastBitThreadResumed = (1 << 2), - eBroadcastBitSelectedFrameChanged = (1 << 3), - eBroadcastBitThreadSelected = (1 << 4) - }; - - - SBThread (); - - SBThread (const lldb::SBThread &thread); - - ~SBThread(); - - static const char * - GetBroadcasterClassName (); - - static bool - EventIsThreadEvent (const SBEvent &event); - - static SBFrame - GetStackFrameFromEvent (const SBEvent &event); - - static SBThread - GetThreadFromEvent (const SBEvent &event); - - bool - IsValid() const; - - void - Clear (); - - lldb::StopReason - GetStopReason(); - - %feature("docstring", " - /// Get the number of words associated with the stop reason. - /// See also GetStopReasonDataAtIndex(). - ") GetStopReasonDataCount; - size_t - GetStopReasonDataCount(); - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// Get information associated with a stop reason. - /// - /// Breakpoint stop reasons will have data that consists of pairs of - /// breakpoint IDs followed by the breakpoint location IDs (they always come - /// in pairs). - /// - /// Stop Reason Count Data Type - /// ======================== ===== ========================================= - /// eStopReasonNone 0 - /// eStopReasonTrace 0 - /// eStopReasonBreakpoint N duple: {breakpoint id, location id} - /// eStopReasonWatchpoint 1 watchpoint id - /// eStopReasonSignal 1 unix signal number - /// eStopReasonException N exception data - /// eStopReasonExec 0 - /// eStopReasonPlanComplete 0 - //-------------------------------------------------------------------------- - ") GetStopReasonDataAtIndex; - uint64_t - GetStopReasonDataAtIndex(uint32_t idx); - - %feature("autodoc", " - Collects a thread's stop reason extended information dictionary and prints it - into the SBStream in a JSON format. The format of this JSON dictionary depends - on the stop reason and is currently used only for instrumentation plugins. - ") GetStopReasonExtendedInfoAsJSON; - bool - GetStopReasonExtendedInfoAsJSON (lldb::SBStream &stream); - - %feature("autodoc", " - Pass only an (int)length and expect to get a Python string describing the - stop reason. - ") GetStopDescription; - size_t - GetStopDescription (char *dst, size_t dst_len); - - SBValue - GetStopReturnValue (); - - %feature("autodoc", " - Returns a unique thread identifier (type lldb::tid_t, typically a 64-bit type) - for the current SBThread that will remain constant throughout the thread's - lifetime in this process and will not be reused by another thread during this - process lifetime. On Mac OS X systems, this is a system-wide unique thread - identifier; this identifier is also used by other tools like sample which helps - to associate data from those tools with lldb. See related GetIndexID. - ") - GetThreadID; - lldb::tid_t - GetThreadID () const; - - %feature("autodoc", " - Return the index number for this SBThread. The index number is the same thing - that a user gives as an argument to 'thread select' in the command line lldb. - These numbers start at 1 (for the first thread lldb sees in a debug session) - and increments up throughout the process lifetime. An index number will not be - reused for a different thread later in a process - thread 1 will always be - associated with the same thread. See related GetThreadID. - This method returns a uint32_t index number, takes no arguments. - ") - GetIndexID; - uint32_t - GetIndexID () const; - - const char * - GetName () const; - - %feature("autodoc", " - Return the queue name associated with this thread, if any, as a str. - For example, with a libdispatch (aka Grand Central Dispatch) queue. - ") GetQueueName; - - const char * - GetQueueName() const; - - %feature("autodoc", " - Return the dispatch_queue_id for this thread, if any, as a lldb::queue_id_t. - For example, with a libdispatch (aka Grand Central Dispatch) queue. - ") GetQueueID; - - lldb::queue_id_t - GetQueueID() const; - - %feature("autodoc", " - Takes a path string and a SBStream reference as parameters, returns a bool. - Collects the thread's 'info' dictionary from the remote system, uses the path - argument to descend into the dictionary to an item of interest, and prints - it into the SBStream in a natural format. Return bool is to indicate if - anything was printed into the stream (true) or not (false). - ") GetInfoItemByPathAsString; - - bool - GetInfoItemByPathAsString (const char *path, lldb::SBStream &strm); - - %feature("autodoc", " - Return the SBQueue for this thread. If this thread is not currently associated - with a libdispatch queue, the SBQueue object's IsValid() method will return false. - If this SBThread is actually a HistoryThread, we may be able to provide QueueID - and QueueName, but not provide an SBQueue. Those individual attributes may have - been saved for the HistoryThread without enough information to reconstitute the - entire SBQueue at that time. - This method takes no arguments, returns an SBQueue. - ") GetQueue; - - lldb::SBQueue - GetQueue () const; - - void - StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); - - void - StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); - - void - StepInto (const char *target_name, lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); - - void - StepOut (); - - void - StepOutOfFrame (lldb::SBFrame &frame); - - void - StepInstruction(bool step_over); - - SBError - StepOverUntil (lldb::SBFrame &frame, - lldb::SBFileSpec &file_spec, - uint32_t line); - - SBError - StepUsingScriptedThreadPlan (const char *script_class_name); - - SBError - JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line); - - void - RunToAddress (lldb::addr_t addr); - - SBError - ReturnFromFrame (SBFrame &frame, SBValue &return_value); - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// LLDB currently supports process centric debugging which means when any - /// thread in a process stops, all other threads are stopped. The Suspend() - /// call here tells our process to suspend a thread and not let it run when - /// the other threads in a process are allowed to run. So when - /// SBProcess::Continue() is called, any threads that aren't suspended will - /// be allowed to run. If any of the SBThread functions for stepping are - /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the - /// thread will now be allowed to run and these functions will simply return. - /// - /// Eventually we plan to add support for thread centric debugging where - /// each thread is controlled individually and each thread would broadcast - /// its state, but we haven't implemented this yet. - /// - /// Likewise the SBThread::Resume() call will again allow the thread to run - /// when the process is continued. - /// - /// Suspend() and Resume() functions are not currently reference counted, if - /// anyone has the need for them to be reference counted, please let us - /// know. - //-------------------------------------------------------------------------- - ") Suspend; - bool - Suspend(); - - bool - Resume (); - - bool - IsSuspended(); - - bool - IsStopped(); - - uint32_t - GetNumFrames (); - - lldb::SBFrame - GetFrameAtIndex (uint32_t idx); - - lldb::SBFrame - GetSelectedFrame (); - - lldb::SBFrame - SetSelectedFrame (uint32_t frame_idx); - - lldb::SBProcess - GetProcess (); - - bool - GetDescription (lldb::SBStream &description) const; - - bool - GetStatus (lldb::SBStream &status) const; - - bool - operator == (const lldb::SBThread &rhs) const; - - bool - operator != (const lldb::SBThread &rhs) const; - - %feature("autodoc"," - Given an argument of str to specify the type of thread-origin extended - backtrace to retrieve, query whether the origin of this thread is - available. An SBThread is retured; SBThread.IsValid will return true - if an extended backtrace was available. The returned SBThread is not - a part of the SBProcess' thread list and it cannot be manipulated like - normal threads -- you cannot step or resume it, for instance -- it is - intended to used primarily for generating a backtrace. You may request - the returned thread's own thread origin in turn. - ") GetExtendedBacktraceThread; - lldb::SBThread - GetExtendedBacktraceThread (const char *type); - - %feature("autodoc"," - Takes no arguments, returns a uint32_t. - If this SBThread is an ExtendedBacktrace thread, get the IndexID of the - original thread that this ExtendedBacktrace thread represents, if - available. The thread that was running this backtrace in the past may - not have been registered with lldb's thread index (if it was created, - did its work, and was destroyed without lldb ever stopping execution). - In that case, this ExtendedBacktrace thread's IndexID will be returned. - ") GetExtendedBacktraceOriginatingIndexID; - uint32_t - GetExtendedBacktraceOriginatingIndexID(); - - %feature("autodoc"," - Takes no arguments, returns a bool. - lldb may be able to detect that function calls should not be executed - on a given thread at a particular point in time. It is recommended that - this is checked before performing an inferior function call on a given - thread. - ") SafeToCallFunctions; - bool - SafeToCallFunctions (); - - %pythoncode %{ - class frames_access(object): - '''A helper object that will lazily hand out frames for a thread when supplied an index.''' - def __init__(self, sbthread): - self.sbthread = sbthread - - def __len__(self): - if self.sbthread: - return int(self.sbthread.GetNumFrames()) - return 0 - - def __getitem__(self, key): - if type(key) is int and key < self.sbthread.GetNumFrames(): - return self.sbthread.GetFrameAtIndex(key) - return None - - def get_frames_access_object(self): - '''An accessor function that returns a frames_access() object which allows lazy frame access from a lldb.SBThread object.''' - return self.frames_access (self) - - def get_thread_frames(self): - '''An accessor function that returns a list() that contains all frames in a lldb.SBThread object.''' - frames = [] - for frame in self: - frames.append(frame) - return frames - - __swig_getmethods__["id"] = GetThreadID - if _newclass: id = property(GetThreadID, None, doc='''A read only property that returns the thread ID as an integer.''') - - __swig_getmethods__["idx"] = GetIndexID - if _newclass: idx = property(GetIndexID, None, doc='''A read only property that returns the thread index ID as an integer. Thread index ID values start at 1 and increment as threads come and go and can be used to uniquely identify threads.''') - - __swig_getmethods__["return_value"] = GetStopReturnValue - if _newclass: return_value = property(GetStopReturnValue, None, doc='''A read only property that returns an lldb object that represents the return value from the last stop (lldb.SBValue) if we just stopped due to stepping out of a function.''') - - __swig_getmethods__["process"] = GetProcess - if _newclass: process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that owns this thread.''') - - __swig_getmethods__["num_frames"] = GetNumFrames - if _newclass: num_frames = property(GetNumFrames, None, doc='''A read only property that returns the number of stack frames in this thread as an integer.''') - - __swig_getmethods__["frames"] = get_thread_frames - if _newclass: frames = property(get_thread_frames, None, doc='''A read only property that returns a list() of lldb.SBFrame objects for all frames in this thread.''') - - __swig_getmethods__["frame"] = get_frames_access_object - if _newclass: frame = property(get_frames_access_object, None, doc='''A read only property that returns an object that can be used to access frames as an array ("frame_12 = lldb.thread.frame[12]").''') - - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name of this thread as a string.''') - - __swig_getmethods__["queue"] = GetQueueName - if _newclass: queue = property(GetQueueName, None, doc='''A read only property that returns the dispatch queue name of this thread as a string.''') - - __swig_getmethods__["queue_id"] = GetQueueID - if _newclass: queue_id = property(GetQueueID, None, doc='''A read only property that returns the dispatch queue id of this thread as an integer.''') - - __swig_getmethods__["stop_reason"] = GetStopReason - if _newclass: stop_reason = property(GetStopReason, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eStopReason") that represents the reason this thread stopped.''') - - __swig_getmethods__["is_suspended"] = IsSuspended - if _newclass: is_suspended = property(IsSuspended, None, doc='''A read only property that returns a boolean value that indicates if this thread is suspended.''') - - __swig_getmethods__["is_stopped"] = IsStopped - if _newclass: is_stopped = property(IsStopped, None, doc='''A read only property that returns a boolean value that indicates if this thread is stopped but not exited.''') - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBThreadCollection.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBThreadCollection.i +++ lldb/trunk/scripts/Python/interface/SBThreadCollection.i @@ -1,38 +0,0 @@ -//===-- SWIG Interface for SBThreadCollection -------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include - -namespace lldb { - -%feature("docstring", -"Represents a collection of SBThread objects." -) SBThreadCollection; -class SBThreadCollection -{ -public: - - SBThreadCollection (); - - SBThreadCollection (const SBThreadCollection &rhs); - - ~SBThreadCollection (); - - bool - IsValid () const; - - size_t - GetSize (); - - lldb::SBThread - GetThreadAtIndex (size_t idx); - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBThreadPlan.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBThreadPlan.i +++ lldb/trunk/scripts/Python/interface/SBThreadPlan.i @@ -1,123 +0,0 @@ -//===-- SBThread.h ----------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLDB_SBThreadPlan_h_ -#define LLDB_SBThreadPlan_h_ - -#include "lldb/API/SBDefines.h" - -#include - -namespace lldb { - -%feature("docstring", -"Represents a plan for the execution control of a given thread. - -See also SBThread and SBFrame." -) SBThread; - -class SBThreadPlan -{ - -friend class lldb_private::ThreadPlan; - -public: - SBThreadPlan (); - - SBThreadPlan (const lldb::SBThreadPlan &threadPlan); - - SBThreadPlan (const lldb::ThreadPlanSP& lldb_object_sp); - - SBThreadPlan (lldb::SBThread &thread, const char *class_name); - - ~SBThreadPlan (); - - bool - IsValid() const; - - void - Clear (); - - lldb::StopReason - GetStopReason(); - - /// Get the number of words associated with the stop reason. - /// See also GetStopReasonDataAtIndex(). - size_t - GetStopReasonDataCount(); - - //-------------------------------------------------------------------------- - /// Get information associated with a stop reason. - /// - /// Breakpoint stop reasons will have data that consists of pairs of - /// breakpoint IDs followed by the breakpoint location IDs (they always come - /// in pairs). - /// - /// Stop Reason Count Data Type - /// ======================== ===== ========================================= - /// eStopReasonNone 0 - /// eStopReasonTrace 0 - /// eStopReasonBreakpoint N duple: {breakpoint id, location id} - /// eStopReasonWatchpoint 1 watchpoint id - /// eStopReasonSignal 1 unix signal number - /// eStopReasonException N exception data - /// eStopReasonExec 0 - /// eStopReasonPlanComplete 0 - //-------------------------------------------------------------------------- - uint64_t - GetStopReasonDataAtIndex(uint32_t idx); - - SBThread - GetThread () const; - - bool - GetDescription (lldb::SBStream &description) const; - - void - SetPlanComplete (bool success); - - bool - IsPlanComplete(); - - bool - IsValid(); - - // This section allows an SBThreadPlan to push another of the common types of plans... - SBThreadPlan - QueueThreadPlanForStepOverRange (SBAddress &start_address, - lldb::addr_t range_size); - - SBThreadPlan - QueueThreadPlanForStepInRange (SBAddress &start_address, - lldb::addr_t range_size); - - SBThreadPlan - QueueThreadPlanForStepOut (uint32_t frame_idx_to_step_to, bool first_insn = false); - - SBThreadPlan - QueueThreadPlanForRunToAddress (SBAddress address); - - -protected: - friend class SBBreakpoint; - friend class SBBreakpointLocation; - friend class SBFrame; - friend class SBProcess; - friend class SBDebugger; - friend class SBValue; - friend class lldb_private::QueueImpl; - friend class SBQueueItem; - -private: - lldb::ThreadPlanSP m_opaque_sp; -}; - -} // namespace lldb - -#endif // LLDB_SBThreadPlan_h_ Index: lldb/trunk/scripts/Python/interface/SBType.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBType.i +++ lldb/trunk/scripts/Python/interface/SBType.i @@ -1,491 +0,0 @@ -//===-- SWIG Interface for SBType -------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", -"Represents a member of a type in lldb. -") SBTypeMember; - -class SBTypeMember -{ -public: - SBTypeMember (); - - SBTypeMember (const lldb::SBTypeMember& rhs); - - ~SBTypeMember(); - - bool - IsValid() const; - - const char * - GetName (); - - lldb::SBType - GetType (); - - uint64_t - GetOffsetInBytes(); - - uint64_t - GetOffsetInBits(); - - bool - IsBitfield(); - - uint32_t - GetBitfieldSizeInBits(); - - %pythoncode %{ - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this member as a string.''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this member.''') - - __swig_getmethods__["byte_offset"] = GetOffsetInBytes - if _newclass: byte_offset = property(GetOffsetInBytes, None, doc='''A read only property that returns offset in bytes for this member as an integer.''') - - __swig_getmethods__["bit_offset"] = GetOffsetInBits - if _newclass: bit_offset = property(GetOffsetInBits, None, doc='''A read only property that returns offset in bits for this member as an integer.''') - - __swig_getmethods__["is_bitfield"] = IsBitfield - if _newclass: is_bitfield = property(IsBitfield, None, doc='''A read only property that returns true if this member is a bitfield.''') - - __swig_getmethods__["bitfield_bit_size"] = GetBitfieldSizeInBits - if _newclass: bitfield_bit_size = property(GetBitfieldSizeInBits, None, doc='''A read only property that returns the bitfield size in bits for this member as an integer, or zero if this member is not a bitfield.''') - - %} - -protected: - std::unique_ptr m_opaque_ap; -}; - -class SBTypeMemberFunction -{ -public: - SBTypeMemberFunction (); - - SBTypeMemberFunction (const lldb::SBTypeMemberFunction& rhs); - - ~SBTypeMemberFunction(); - - bool - IsValid() const; - - const char * - GetName (); - - lldb::SBType - GetType (); - - lldb::SBType - GetReturnType (); - - uint32_t - GetNumberOfArguments (); - - lldb::SBType - GetArgumentTypeAtIndex (uint32_t); - - lldb::MemberFunctionKind - GetKind(); - - bool - GetDescription (lldb::SBStream &description, - lldb::DescriptionLevel description_level); - -protected: - lldb::TypeMemberFunctionImplSP m_opaque_sp; -}; - -%feature("docstring", -"Represents a data type in lldb. The FindFirstType() method of SBTarget/SBModule -returns a SBType. - -SBType supports the eq/ne operator. For example, - -main.cpp: - -class Task { -public: - int id; - Task *next; - Task(int i, Task *n): - id(i), - next(n) - {} -}; - -int main (int argc, char const *argv[]) -{ - Task *task_head = new Task(-1, NULL); - Task *task1 = new Task(1, NULL); - Task *task2 = new Task(2, NULL); - Task *task3 = new Task(3, NULL); // Orphaned. - Task *task4 = new Task(4, NULL); - Task *task5 = new Task(5, NULL); - - task_head->next = task1; - task1->next = task2; - task2->next = task4; - task4->next = task5; - - int total = 0; - Task *t = task_head; - while (t != NULL) { - if (t->id >= 0) - ++total; - t = t->next; - } - printf('We have a total number of %d tasks\\n', total); - - // This corresponds to an empty task list. - Task *empty_task_head = new Task(-1, NULL); - - return 0; // Break at this line -} - -find_type.py: - - # Get the type 'Task'. - task_type = target.FindFirstType('Task') - self.assertTrue(task_type) - - # Get the variable 'task_head'. - frame0.FindVariable('task_head') - task_head_type = task_head.GetType() - self.assertTrue(task_head_type.IsPointerType()) - - # task_head_type is 'Task *'. - task_pointer_type = task_type.GetPointerType() - self.assertTrue(task_head_type == task_pointer_type) - - # Get the child mmember 'id' from 'task_head'. - id = task_head.GetChildMemberWithName('id') - id_type = id.GetType() - - # SBType.GetBasicType() takes an enum 'BasicType' (lldb-enumerations.h). - int_type = id_type.GetBasicType(lldb.eBasicTypeInt) - # id_type and int_type should be the same type! - self.assertTrue(id_type == int_type) - -... -") SBType; -class SBType -{ -public: - SBType (); - - SBType (const lldb::SBType &rhs); - - ~SBType (); - - bool - IsValid(); - - uint64_t - GetByteSize(); - - bool - IsPointerType(); - - bool - IsReferenceType(); - - bool - IsFunctionType (); - - bool - IsPolymorphicClass (); - - bool - IsArrayType (); - - bool - IsVectorType (); - - bool - IsTypedefType (); - - lldb::SBType - GetPointerType(); - - lldb::SBType - GetPointeeType(); - - lldb::SBType - GetReferenceType(); - - lldb::SBType - SBType::GetTypedefedType(); - - lldb::SBType - GetDereferencedType(); - - lldb::SBType - GetUnqualifiedType(); - - lldb::SBType - GetCanonicalType(); - - lldb::SBType - GetArrayElementType (); - - lldb::SBType - GetVectorElementType (); - - lldb::BasicType - GetBasicType(); - - lldb::SBType - GetBasicType (lldb::BasicType type); - - uint32_t - GetNumberOfFields (); - - uint32_t - GetNumberOfDirectBaseClasses (); - - uint32_t - GetNumberOfVirtualBaseClasses (); - - lldb::SBTypeMember - GetFieldAtIndex (uint32_t idx); - - lldb::SBTypeMember - GetDirectBaseClassAtIndex (uint32_t idx); - - lldb::SBTypeMember - GetVirtualBaseClassAtIndex (uint32_t idx); - - lldb::SBTypeEnumMemberList - GetEnumMembers(); - - const char* - GetName(); - - const char * - GetDisplayTypeName (); - - lldb::TypeClass - GetTypeClass (); - - uint32_t - GetNumberOfTemplateArguments (); - - lldb::SBType - GetTemplateArgumentType (uint32_t idx); - - lldb::TemplateArgumentKind - GetTemplateArgumentKind (uint32_t idx); - - lldb::SBType - GetFunctionReturnType (); - - lldb::SBTypeList - GetFunctionArgumentTypes (); - - uint32_t - GetNumberOfMemberFunctions (); - - lldb::SBTypeMemberFunction - GetMemberFunctionAtIndex (uint32_t idx); - - bool - IsTypeComplete (); - - uint32_t - GetTypeFlags (); - - %pythoncode %{ - def template_arg_array(self): - num_args = self.num_template_args - if num_args: - template_args = [] - for i in range(num_args): - template_args.append(self.GetTemplateArgumentType(i)) - return template_args - return None - - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this type as a string.''') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns size in bytes for this type as an integer.''') - - __swig_getmethods__["is_pointer"] = IsPointerType - if _newclass: is_pointer = property(IsPointerType, None, doc='''A read only property that returns a boolean value that indicates if this type is a pointer type.''') - - __swig_getmethods__["is_reference"] = IsReferenceType - if _newclass: is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a reference type.''') - - __swig_getmethods__["is_function"] = IsFunctionType - if _newclass: is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a function type.''') - - __swig_getmethods__["num_fields"] = GetNumberOfFields - if _newclass: num_fields = property(GetNumberOfFields, None, doc='''A read only property that returns number of fields in this type as an integer.''') - - __swig_getmethods__["num_bases"] = GetNumberOfDirectBaseClasses - if _newclass: num_bases = property(GetNumberOfDirectBaseClasses, None, doc='''A read only property that returns number of direct base classes in this type as an integer.''') - - __swig_getmethods__["num_vbases"] = GetNumberOfVirtualBaseClasses - if _newclass: num_vbases = property(GetNumberOfVirtualBaseClasses, None, doc='''A read only property that returns number of virtual base classes in this type as an integer.''') - - __swig_getmethods__["num_template_args"] = GetNumberOfTemplateArguments - if _newclass: num_template_args = property(GetNumberOfTemplateArguments, None, doc='''A read only property that returns number of template arguments in this type as an integer.''') - - __swig_getmethods__["template_args"] = template_arg_array - if _newclass: template_args = property(template_arg_array, None, doc='''A read only property that returns a list() of lldb.SBType objects that represent all template arguments in this type.''') - - __swig_getmethods__["type"] = GetTypeClass - if _newclass: type = property(GetTypeClass, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eTypeClass") that represents a classification for this type.''') - - __swig_getmethods__["is_complete"] = IsTypeComplete - if _newclass: is_complete = property(IsTypeComplete, None, doc='''A read only property that returns a boolean value that indicates if this type is a complete type (True) or a forward declaration (False).''') - - def get_bases_array(self): - '''An accessor function that returns a list() that contains all direct base classes in a lldb.SBType object.''' - bases = [] - for idx in range(self.GetNumberOfDirectBaseClasses()): - bases.append(self.GetDirectBaseClassAtIndex(idx)) - return bases - - def get_vbases_array(self): - '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.''' - vbases = [] - for idx in range(self.GetNumberOfVirtualBaseClasses()): - vbases.append(self.GetVirtualBaseClassAtIndex(idx)) - return vbases - - def get_fields_array(self): - '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.''' - fields = [] - for idx in range(self.GetNumberOfFields()): - fields.append(self.GetFieldAtIndex(idx)) - return fields - - def get_members_array(self): - '''An accessor function that returns a list() that contains all members (base classes and fields) in a lldb.SBType object in ascending bit offset order.''' - members = [] - bases = self.get_bases_array() - fields = self.get_fields_array() - vbases = self.get_vbases_array() - for base in bases: - bit_offset = base.bit_offset - added = False - for idx, member in enumerate(members): - if member.bit_offset > bit_offset: - members.insert(idx, base) - added = True - break - if not added: - members.append(base) - for vbase in vbases: - bit_offset = vbase.bit_offset - added = False - for idx, member in enumerate(members): - if member.bit_offset > bit_offset: - members.insert(idx, vbase) - added = True - break - if not added: - members.append(vbase) - for field in fields: - bit_offset = field.bit_offset - added = False - for idx, member in enumerate(members): - if member.bit_offset > bit_offset: - members.insert(idx, field) - added = True - break - if not added: - members.append(field) - return members - - def get_enum_members_array(self): - '''An accessor function that returns a list() that contains all enum members in an lldb.SBType object.''' - enum_members_list = [] - sb_enum_members = self.GetEnumMembers() - for idx in range(sb_enum_members.GetSize()): - enum_members_list.append(sb_enum_members.GetTypeEnumMemberAtIndex(idx)) - return enum_members_list - - __swig_getmethods__["bases"] = get_bases_array - if _newclass: bases = property(get_bases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the direct base classes for this type.''') - - __swig_getmethods__["vbases"] = get_vbases_array - if _newclass: vbases = property(get_vbases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the virtual base classes for this type.''') - - __swig_getmethods__["fields"] = get_fields_array - if _newclass: fields = property(get_fields_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the fields for this type.''') - - __swig_getmethods__["members"] = get_members_array - if _newclass: members = property(get_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeMember objects that represent all of the base classes, virtual base classes and fields for this type in ascending bit offset order.''') - - __swig_getmethods__["enum_members"] = get_enum_members_array - if _newclass: enum_members = property(get_enum_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeEnumMember objects that represent the enum members for this type.''') - - %} - -}; - -%feature("docstring", -"Represents a list of SBTypes. The FindTypes() method of SBTarget/SBModule -returns a SBTypeList. - -SBTypeList supports SBType iteration. For example, - -main.cpp: - -class Task { -public: - int id; - Task *next; - Task(int i, Task *n): - id(i), - next(n) - {} -}; - -... - -find_type.py: - - # Get the type 'Task'. - type_list = target.FindTypes('Task') - self.assertTrue(len(type_list) == 1) - # To illustrate the SBType iteration. - for type in type_list: - # do something with type - -... -") SBTypeList; -class SBTypeList -{ -public: - SBTypeList(); - - bool - IsValid(); - - void - Append (lldb::SBType type); - - lldb::SBType - GetTypeAtIndex (uint32_t index); - - uint32_t - GetSize(); - - ~SBTypeList(); -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBTypeCategory.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBTypeCategory.i +++ lldb/trunk/scripts/Python/interface/SBTypeCategory.i @@ -1,237 +0,0 @@ -//===-- SWIG Interface for SBTypeCategory---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", - "Represents a category that can contain formatters for types. - ") SBTypeCategory; - - class SBTypeCategory - { - public: - - SBTypeCategory(); - - SBTypeCategory (const lldb::SBTypeCategory &rhs); - - ~SBTypeCategory (); - - bool - IsValid() const; - - bool - GetEnabled (); - - void - SetEnabled (bool); - - const char* - GetName(); - - bool - GetDescription (lldb::SBStream &description, - lldb::DescriptionLevel description_level); - - uint32_t - GetNumFormats (); - - uint32_t - GetNumSummaries (); - - uint32_t - GetNumFilters (); - - uint32_t - GetNumSynthetics (); - - lldb::SBTypeNameSpecifier - GetTypeNameSpecifierForFilterAtIndex (uint32_t); - - lldb::SBTypeNameSpecifier - GetTypeNameSpecifierForFormatAtIndex (uint32_t); - - lldb::SBTypeNameSpecifier - GetTypeNameSpecifierForSummaryAtIndex (uint32_t); - - lldb::SBTypeNameSpecifier - GetTypeNameSpecifierForSyntheticAtIndex (uint32_t); - - lldb::SBTypeFilter - GetFilterForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeFormat - GetFormatForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeSummary - GetSummaryForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeSynthetic - GetSyntheticForType (lldb::SBTypeNameSpecifier); - - lldb::SBTypeFilter - GetFilterAtIndex (uint32_t); - - lldb::SBTypeFormat - GetFormatAtIndex (uint32_t); - - lldb::SBTypeSummary - GetSummaryAtIndex (uint32_t); - - lldb::SBTypeSynthetic - GetSyntheticAtIndex (uint32_t); - - bool - AddTypeFormat (lldb::SBTypeNameSpecifier, - lldb::SBTypeFormat); - - bool - DeleteTypeFormat (lldb::SBTypeNameSpecifier); - - bool - AddTypeSummary (lldb::SBTypeNameSpecifier, - lldb::SBTypeSummary); - - bool - DeleteTypeSummary (lldb::SBTypeNameSpecifier); - - bool - AddTypeFilter (lldb::SBTypeNameSpecifier, - lldb::SBTypeFilter); - - bool - DeleteTypeFilter (lldb::SBTypeNameSpecifier); - - bool - AddTypeSynthetic (lldb::SBTypeNameSpecifier, - lldb::SBTypeSynthetic); - - bool - DeleteTypeSynthetic (lldb::SBTypeNameSpecifier); - - %pythoncode %{ - - class formatters_access_class(object): - '''A helper object that will lazily hand out formatters for a specific category.''' - def __init__(self, sbcategory, get_count_function, get_at_index_function, get_by_name_function): - self.sbcategory = sbcategory - self.get_count_function = get_count_function - self.get_at_index_function = get_at_index_function - self.get_by_name_function = get_by_name_function - self.regex_type = type(re.compile('.')) - - - def __len__(self): - if self.sbcategory and self.get_count_function: - return int(self.get_count_function(self.sbcategory)) - return 0 - - def __getitem__(self, key): - num_items = len(self) - if type(key) is int: - if key < num_items: - return self.get_at_index_function(self.sbcategory,key) - elif type(key) is str: - return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key)) - elif isinstance(key,self.regex_type): - return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key.pattern,True)) - else: - print "error: unsupported item type: %s" % type(key) - return None - - def get_formats_access_object(self): - '''An accessor function that returns an accessor object which allows lazy format access from a lldb.SBTypeCategory object.''' - return self.formatters_access_class (self,self.__class__.GetNumFormats,self.__class__.GetFormatAtIndex,self.__class__.GetFormatForType) - - def get_formats_array(self): - '''An accessor function that returns a list() that contains all formats in a lldb.SBCategory object.''' - formats = [] - for idx in range(self.GetNumFormats()): - formats.append(self.GetFormatAtIndex(idx)) - return formats - - def get_summaries_access_object(self): - '''An accessor function that returns an accessor object which allows lazy summary access from a lldb.SBTypeCategory object.''' - return self.formatters_access_class (self,self.__class__.GetNumSummaries,self.__class__.GetSummaryAtIndex,self.__class__.GetSummaryForType) - - def get_summaries_array(self): - '''An accessor function that returns a list() that contains all summaries in a lldb.SBCategory object.''' - summaries = [] - for idx in range(self.GetNumSummaries()): - summaries.append(self.GetSummaryAtIndex(idx)) - return summaries - - def get_synthetics_access_object(self): - '''An accessor function that returns an accessor object which allows lazy synthetic children provider access from a lldb.SBTypeCategory object.''' - return self.formatters_access_class (self,self.__class__.GetNumSynthetics,self.__class__.GetSyntheticAtIndex,self.__class__.GetSyntheticForType) - - def get_synthetics_array(self): - '''An accessor function that returns a list() that contains all synthetic children providers in a lldb.SBCategory object.''' - synthetics = [] - for idx in range(self.GetNumSynthetics()): - synthetics.append(self.GetSyntheticAtIndex(idx)) - return synthetics - - def get_filters_access_object(self): - '''An accessor function that returns an accessor object which allows lazy filter access from a lldb.SBTypeCategory object.''' - return self.formatters_access_class (self,self.__class__.GetNumFilters,self.__class__.GetFilterAtIndex,self.__class__.GetFilterForType) - - def get_filters_array(self): - '''An accessor function that returns a list() that contains all filters in a lldb.SBCategory object.''' - filters = [] - for idx in range(self.GetNumFilters()): - filters.append(self.GetFilterAtIndex(idx)) - return filters - - __swig_getmethods__["formats"] = get_formats_array - if _newclass: formats = property(get_formats_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFormat objects contained in this category''') - - __swig_getmethods__["format"] = get_formats_access_object - if _newclass: format = property(get_formats_access_object, None, doc=r'''A read only property that returns an object that you can use to look for formats by index or type name.''') - - __swig_getmethods__["summaries"] = get_summaries_array - if _newclass: summaries = property(get_summaries_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSummary objects contained in this category''') - - __swig_getmethods__["summary"] = get_summaries_access_object - if _newclass: summary = property(get_summaries_access_object, None, doc=r'''A read only property that returns an object that you can use to look for summaries by index or type name or regular expression.''') - - __swig_getmethods__["filters"] = get_filters_array - if _newclass: filters = property(get_filters_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFilter objects contained in this category''') - - __swig_getmethods__["filter"] = get_filters_access_object - if _newclass: filter = property(get_filters_access_object, None, doc=r'''A read only property that returns an object that you can use to look for filters by index or type name or regular expression.''') - - __swig_getmethods__["synthetics"] = get_synthetics_array - if _newclass: synthetics = property(get_synthetics_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSynthetic objects contained in this category''') - - __swig_getmethods__["synthetic"] = get_synthetics_access_object - if _newclass: synthetic = property(get_synthetics_access_object, None, doc=r'''A read only property that returns an object that you can use to look for synthetic children provider by index or type name or regular expression.''') - - __swig_getmethods__["num_formats"] = GetNumFormats - if _newclass: num_formats = property(GetNumFormats, None) - __swig_getmethods__["num_summaries"] = GetNumSummaries - if _newclass: num_summaries = property(GetNumSummaries, None) - __swig_getmethods__["num_filters"] = GetNumFilters - if _newclass: num_filters = property(GetNumFilters, None) - __swig_getmethods__["num_synthetics"] = GetNumSynthetics - if _newclass: num_synthetics = property(GetNumSynthetics, None) - - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None) - - __swig_getmethods__["enabled"] = GetEnabled - __swig_setmethods__["enabled"] = SetEnabled - if _newclass: enabled = property(GetEnabled, SetEnabled) - %} - - }; - - -} // namespace lldb - Index: lldb/trunk/scripts/Python/interface/SBTypeEnumMember.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBTypeEnumMember.i +++ lldb/trunk/scripts/Python/interface/SBTypeEnumMember.i @@ -1,108 +0,0 @@ -//===-- SWIG Interface for SBTypeEnumMember ---------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature( - "docstring", - "Represents a member of an enum in lldb." -) SBTypeEnumMember; - -class SBTypeEnumMember -{ -public: - SBTypeEnumMember (); - - SBTypeEnumMember (const SBTypeEnumMember& rhs); - - ~SBTypeEnumMember(); - - bool - IsValid() const; - - int64_t - GetValueAsSigned(); - - uint64_t - GetValueAsUnsigned(); - - const char * - GetName (); - - lldb::SBType - GetType (); - - bool - GetDescription (lldb::SBStream &description, - lldb::DescriptionLevel description_level); - - %pythoncode %{ - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this enum member as a string.''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this enum member.''') - - __swig_getmethods__["signed"] = GetValueAsSigned - if _newclass: signed = property(GetValueAsSigned, None, doc='''A read only property that returns the value of this enum member as a signed integer.''') - - __swig_getmethods__["unsigned"] = GetValueAsUnsigned - if _newclass: unsigned = property(GetValueAsUnsigned, None, doc='''A read only property that returns the value of this enum member as a unsigned integer.''') - %} - -protected: - friend class SBType; - friend class SBTypeEnumMemberList; - - void - reset (lldb_private::TypeEnumMemberImpl *); - - lldb_private::TypeEnumMemberImpl & - ref (); - - const lldb_private::TypeEnumMemberImpl & - ref () const; - - lldb::TypeEnumMemberImplSP m_opaque_sp; - - SBTypeEnumMember (const lldb::TypeEnumMemberImplSP &); -}; - -%feature( - "docstring", - "Represents a list of SBTypeEnumMembers." -) SBTypeEnumMemberList; - -class SBTypeEnumMemberList -{ -public: - SBTypeEnumMemberList(); - - SBTypeEnumMemberList(const SBTypeEnumMemberList& rhs); - - ~SBTypeEnumMemberList(); - - bool - IsValid(); - - void - Append (SBTypeEnumMember entry); - - SBTypeEnumMember - GetTypeEnumMemberAtIndex (uint32_t index); - - uint32_t - GetSize(); - - -private: - std::unique_ptr m_opaque_ap; -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBTypeFilter.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBTypeFilter.i +++ lldb/trunk/scripts/Python/interface/SBTypeFilter.i @@ -1,75 +0,0 @@ -//===-- SWIG Interface for SBTypeFilter----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", - "Represents a filter that can be associated to one or more types. - ") SBTypeFilter; - - class SBTypeFilter - { - public: - - SBTypeFilter(); - - SBTypeFilter (uint32_t options); - - SBTypeFilter (const lldb::SBTypeFilter &rhs); - - ~SBTypeFilter (); - - bool - IsValid() const; - - bool - IsEqualTo (lldb::SBTypeFilter &rhs); - - uint32_t - GetNumberOfExpressionPaths (); - - const char* - GetExpressionPathAtIndex (uint32_t i); - - bool - ReplaceExpressionPathAtIndex (uint32_t i, const char* item); - - void - AppendExpressionPath (const char* item); - - void - Clear(); - - uint32_t - GetOptions(); - - void - SetOptions (uint32_t); - - bool - GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); - - bool - operator == (lldb::SBTypeFilter &rhs); - - bool - operator != (lldb::SBTypeFilter &rhs); - - %pythoncode %{ - __swig_getmethods__["options"] = GetOptions - __swig_setmethods__["options"] = SetOptions - if _newclass: options = property(GetOptions, SetOptions) - - __swig_getmethods__["count"] = GetNumberOfExpressionPaths - if _newclass: count = property(GetNumberOfExpressionPaths, None) - %} - - }; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBTypeFormat.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBTypeFormat.i +++ lldb/trunk/scripts/Python/interface/SBTypeFormat.i @@ -1,78 +0,0 @@ -//===-- SWIG Interface for SBTypeFormat----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", - "Represents a format that can be associated to one or more types. - ") SBTypeFormat; - - class SBTypeFormat - { - public: - - SBTypeFormat(); - - SBTypeFormat (lldb::Format format, uint32_t options = 0); - - SBTypeFormat (const char* type, uint32_t options = 0); - - SBTypeFormat (const lldb::SBTypeFormat &rhs); - - ~SBTypeFormat (); - - bool - IsValid() const; - - bool - IsEqualTo (lldb::SBTypeFormat &rhs); - - lldb::Format - GetFormat (); - - const char* - GetTypeName (); - - uint32_t - GetOptions(); - - void - SetFormat (lldb::Format); - - void - SetTypeName (const char*); - - void - SetOptions (uint32_t); - - bool - GetDescription (lldb::SBStream &description, - lldb::DescriptionLevel description_level); - - bool - operator == (lldb::SBTypeFormat &rhs); - - bool - operator != (lldb::SBTypeFormat &rhs); - - %pythoncode %{ - __swig_getmethods__["format"] = GetFormat - __swig_setmethods__["format"] = SetFormat - if _newclass: format = property(GetFormat, SetFormat) - - __swig_getmethods__["options"] = GetOptions - __swig_setmethods__["options"] = SetOptions - if _newclass: options = property(GetOptions, SetOptions) - %} - - }; - - -} // namespace lldb - Index: lldb/trunk/scripts/Python/interface/SBTypeNameSpecifier.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBTypeNameSpecifier.i +++ lldb/trunk/scripts/Python/interface/SBTypeNameSpecifier.i @@ -1,68 +0,0 @@ -//===-- SWIG Interface for SBTypeNameSpecifier---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", - "Represents a general way to provide a type name to LLDB APIs. - ") SBTypeNameSpecifier; - - class SBTypeNameSpecifier - { - public: - - SBTypeNameSpecifier(); - - SBTypeNameSpecifier (const char* name, - bool is_regex = false); - - SBTypeNameSpecifier (SBType type); - - SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs); - - ~SBTypeNameSpecifier (); - - bool - IsValid() const; - - bool - IsEqualTo (lldb::SBTypeNameSpecifier &rhs); - - const char* - GetName(); - - lldb::SBType - GetType (); - - bool - IsRegex(); - - bool - GetDescription (lldb::SBStream &description, - lldb::DescriptionLevel description_level); - - bool - operator == (lldb::SBTypeNameSpecifier &rhs); - - bool - operator != (lldb::SBTypeNameSpecifier &rhs); - - %pythoncode %{ - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None) - - __swig_getmethods__["is_regex"] = IsRegex - if _newclass: is_regex = property(IsRegex, None) - %} - - - }; - -} // namespace lldb - Index: lldb/trunk/scripts/Python/interface/SBTypeSummary.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBTypeSummary.i +++ lldb/trunk/scripts/Python/interface/SBTypeSummary.i @@ -1,123 +0,0 @@ -//===-- SWIG Interface for SBTypeSummary---------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - class SBTypeSummaryOptions - { - public: - SBTypeSummaryOptions(); - - SBTypeSummaryOptions (const lldb::SBTypeSummaryOptions &rhs); - - ~SBTypeSummaryOptions (); - - bool - IsValid (); - - lldb::LanguageType - GetLanguage (); - - lldb::TypeSummaryCapping - GetCapping (); - - void - SetLanguage (lldb::LanguageType); - - void - SetCapping (lldb::TypeSummaryCapping); - }; - - %feature("docstring", - "Represents a summary that can be associated to one or more types. - ") SBTypeSummary; - - class SBTypeSummary - { - public: - - SBTypeSummary(); - - static SBTypeSummary - CreateWithSummaryString (const char* data, uint32_t options = 0); - - static SBTypeSummary - CreateWithFunctionName (const char* data, uint32_t options = 0); - - static SBTypeSummary - CreateWithScriptCode (const char* data, uint32_t options = 0); - - SBTypeSummary (const lldb::SBTypeSummary &rhs); - - ~SBTypeSummary (); - - bool - IsValid() const; - - bool - IsEqualTo (lldb::SBTypeSummary &rhs); - - bool - IsFunctionCode(); - - bool - IsFunctionName(); - - bool - IsSummaryString(); - - const char* - GetData (); - - void - SetSummaryString (const char* data); - - void - SetFunctionName (const char* data); - - void - SetFunctionCode (const char* data); - - uint32_t - GetOptions (); - - void - SetOptions (uint32_t); - - bool - GetDescription (lldb::SBStream &description, - lldb::DescriptionLevel description_level); - - bool - operator == (lldb::SBTypeSummary &rhs); - - bool - operator != (lldb::SBTypeSummary &rhs); - - %pythoncode %{ - __swig_getmethods__["options"] = GetOptions - __swig_setmethods__["options"] = SetOptions - if _newclass: options = property(GetOptions, SetOptions) - - __swig_getmethods__["is_summary_string"] = IsSummaryString - if _newclass: is_summary_string = property(IsSummaryString, None) - - __swig_getmethods__["is_function_name"] = IsFunctionName - if _newclass: is_function_name = property(IsFunctionName, None) - - __swig_getmethods__["is_function_name"] = IsFunctionCode - if _newclass: is_function_name = property(IsFunctionCode, None) - - __swig_getmethods__["summary_data"] = GetData - if _newclass: summary_data = property(GetData, None) - %} - - }; - -} // namespace lldb - Index: lldb/trunk/scripts/Python/interface/SBTypeSynthetic.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBTypeSynthetic.i +++ lldb/trunk/scripts/Python/interface/SBTypeSynthetic.i @@ -1,80 +0,0 @@ -//===-- SWIG Interface for SBTypeSynthetic-------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - - %feature("docstring", - "Represents a summary that can be associated to one or more types. - ") SBTypeSynthetic; - - class SBTypeSynthetic - { - public: - - SBTypeSynthetic(); - - static lldb::SBTypeSynthetic - CreateWithClassName (const char* data, uint32_t options = 0); - - static lldb::SBTypeSynthetic - CreateWithScriptCode (const char* data, uint32_t options = 0); - - SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs); - - ~SBTypeSynthetic (); - - bool - IsValid() const; - - bool - IsEqualTo (lldb::SBTypeSynthetic &rhs); - - bool - IsClassCode(); - - const char* - GetData (); - - void - SetClassName (const char* data); - - void - SetClassCode (const char* data); - - uint32_t - GetOptions (); - - void - SetOptions (uint32_t); - - bool - GetDescription (lldb::SBStream &description, - lldb::DescriptionLevel description_level); - - bool - operator == (lldb::SBTypeSynthetic &rhs); - - bool - operator != (lldb::SBTypeSynthetic &rhs); - - %pythoncode %{ - __swig_getmethods__["options"] = GetOptions - __swig_setmethods__["options"] = SetOptions - if _newclass: options = property(GetOptions, SetOptions) - - __swig_getmethods__["contains_code"] = IsClassCode - if _newclass: contains_code = property(IsClassCode, None) - - __swig_getmethods__["synthetic_data"] = GetData - if _newclass: synthetic_data = property(GetData, None) - %} - - }; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBUnixSignals.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBUnixSignals.i +++ lldb/trunk/scripts/Python/interface/SBUnixSignals.i @@ -1,74 +0,0 @@ -//===-- SWIG Interface for SBUnixSignals ------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Allows you to manipulate LLDB's signal disposition" -) SBUnixSignals; -class SBUnixSignals -{ -public: - SBUnixSignals (); - - SBUnixSignals (const lldb::SBUnixSignals &rhs); - - ~SBUnixSignals(); - - void - Clear (); - - bool - IsValid () const; - - const char * - GetSignalAsCString (int32_t signo) const; - - int32_t - GetSignalNumberFromName (const char *name) const; - - bool - GetShouldSuppress (int32_t signo) const; - - bool - SetShouldSuppress (int32_t signo, - bool value); - - bool - GetShouldStop (int32_t signo) const; - - bool - SetShouldStop (int32_t signo, - bool value); - - bool - GetShouldNotify (int32_t signo) const; - - bool - SetShouldNotify (int32_t signo, bool value); - - int32_t - GetNumSignals () const; - - int32_t - GetSignalAtIndex (int32_t index) const; - - %pythoncode %{ - def get_unix_signals_list(self): - signals = [] - for idx in range(0, self.GetNumSignals()): - signals.append(self.GetSignalAtIndex(sig)) - return signals - - __swig_getmethods__["signals"] = get_unix_signals_list - if _newclass: threads = property(get_unix_signals_list, None, doc='''A read only property that returns a list() of valid signal numbers for this platform.''') - %} -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBValue.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBValue.i +++ lldb/trunk/scripts/Python/interface/SBValue.i @@ -1,520 +0,0 @@ -//===-- SWIG Interface for SBValue ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents the value of a variable, a register, or an expression. - -SBValue supports iteration through its child, which in turn is represented -as an SBValue. For example, we can get the general purpose registers of a -frame as an SBValue, and iterate through all the registers, - - registerSet = frame.GetRegisters() # Returns an SBValueList. - for regs in registerSet: - if 'general purpose registers' in regs.getName().lower(): - GPRs = regs - break - - print '%s (number of children = %d):' % (GPRs.GetName(), GPRs.GetNumChildren()) - for reg in GPRs: - print 'Name: ', reg.GetName(), ' Value: ', reg.GetValue() - -produces the output: - -General Purpose Registers (number of children = 21): -Name: rax Value: 0x0000000100000c5c -Name: rbx Value: 0x0000000000000000 -Name: rcx Value: 0x00007fff5fbffec0 -Name: rdx Value: 0x00007fff5fbffeb8 -Name: rdi Value: 0x0000000000000001 -Name: rsi Value: 0x00007fff5fbffea8 -Name: rbp Value: 0x00007fff5fbffe80 -Name: rsp Value: 0x00007fff5fbffe60 -Name: r8 Value: 0x0000000008668682 -Name: r9 Value: 0x0000000000000000 -Name: r10 Value: 0x0000000000001200 -Name: r11 Value: 0x0000000000000206 -Name: r12 Value: 0x0000000000000000 -Name: r13 Value: 0x0000000000000000 -Name: r14 Value: 0x0000000000000000 -Name: r15 Value: 0x0000000000000000 -Name: rip Value: 0x0000000100000dae -Name: rflags Value: 0x0000000000000206 -Name: cs Value: 0x0000000000000027 -Name: fs Value: 0x0000000000000010 -Name: gs Value: 0x0000000000000048 - -See also linked_list_iter() for another perspective on how to iterate through an -SBValue instance which interprets the value object as representing the head of a -linked list." -) SBValue; -class SBValue -{ -public: - SBValue (); - - SBValue (const SBValue &rhs); - - ~SBValue (); - - bool - IsValid(); - - void - Clear(); - - SBError - GetError(); - - lldb::user_id_t - GetID (); - - const char * - GetName(); - - const char * - GetTypeName (); - - const char * - GetDisplayTypeName (); - - size_t - GetByteSize (); - - bool - IsInScope (); - - lldb::Format - GetFormat (); - - void - SetFormat (lldb::Format format); - - const char * - GetValue (); - - int64_t - GetValueAsSigned(SBError& error, int64_t fail_value=0); - - uint64_t - GetValueAsUnsigned(SBError& error, uint64_t fail_value=0); - - int64_t - GetValueAsSigned(int64_t fail_value=0); - - uint64_t - GetValueAsUnsigned(uint64_t fail_value=0); - - ValueType - GetValueType (); - - bool - GetValueDidChange (); - - const char * - GetSummary (); - - const char * - GetSummary (lldb::SBStream& stream, - lldb::SBTypeSummaryOptions& options); - - const char * - GetObjectDescription (); - - const char * - GetTypeValidatorResult (); - - lldb::SBValue - GetDynamicValue (lldb::DynamicValueType use_dynamic); - - lldb::SBValue - GetStaticValue (); - - lldb::SBValue - GetNonSyntheticValue (); - - lldb::DynamicValueType - GetPreferDynamicValue (); - - void - SetPreferDynamicValue (lldb::DynamicValueType use_dynamic); - - bool - GetPreferSyntheticValue (); - - void - SetPreferSyntheticValue (bool use_synthetic); - - bool - IsDynamic(); - - bool - IsSynthetic (); - - const char * - GetLocation (); - - bool - SetValueFromCString (const char *value_str); - - bool - SetValueFromCString (const char *value_str, lldb::SBError& error); - - lldb::SBTypeFormat - GetTypeFormat (); - - lldb::SBTypeSummary - GetTypeSummary (); - - lldb::SBTypeFilter - GetTypeFilter (); - - lldb::SBTypeSynthetic - GetTypeSynthetic (); - - lldb::SBValue - GetChildAtIndex (uint32_t idx); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get a child value by index from a value. - /// - /// Structs, unions, classes, arrays and pointers have child - /// values that can be access by index. - /// - /// Structs and unions access child members using a zero based index - /// for each child member. For - /// - /// Classes reserve the first indexes for base classes that have - /// members (empty base classes are omitted), and all members of the - /// current class will then follow the base classes. - /// - /// Pointers differ depending on what they point to. If the pointer - /// points to a simple type, the child at index zero - /// is the only child value available, unless \a synthetic_allowed - /// is \b true, in which case the pointer will be used as an array - /// and can create 'synthetic' child values using positive or - /// negative indexes. If the pointer points to an aggregate type - /// (an array, class, union, struct), then the pointee is - /// transparently skipped and any children are going to be the indexes - /// of the child values within the aggregate type. For example if - /// we have a 'Point' type and we have a SBValue that contains a - /// pointer to a 'Point' type, then the child at index zero will be - /// the 'x' member, and the child at index 1 will be the 'y' member - /// (the child at index zero won't be a 'Point' instance). - /// - /// Arrays have a preset number of children that can be accessed by - /// index and will returns invalid child values for indexes that are - /// out of bounds unless the \a synthetic_allowed is \b true. In this - /// case the array can create 'synthetic' child values for indexes - /// that aren't in the array bounds using positive or negative - /// indexes. - /// - /// @param[in] idx - /// The index of the child value to get - /// - /// @param[in] use_dynamic - /// An enumeration that specifies whether to get dynamic values, - /// and also if the target can be run to figure out the dynamic - /// type of the child value. - /// - /// @param[in] synthetic_allowed - /// If \b true, then allow child values to be created by index - /// for pointers and arrays for indexes that normally wouldn't - /// be allowed. - /// - /// @return - /// A new SBValue object that represents the child member value. - //------------------------------------------------------------------ - ") GetChildAtIndex; - lldb::SBValue - GetChildAtIndex (uint32_t idx, - lldb::DynamicValueType use_dynamic, - bool can_create_synthetic); - - lldb::SBValue - CreateChildAtOffset (const char *name, uint32_t offset, lldb::SBType type); - - lldb::SBValue - SBValue::Cast (lldb::SBType type); - - lldb::SBValue - CreateValueFromExpression (const char *name, const char* expression); - - lldb::SBValue - CreateValueFromExpression (const char *name, const char* expression, SBExpressionOptions &options); - - lldb::SBValue - CreateValueFromAddress(const char* name, lldb::addr_t address, lldb::SBType type); - - lldb::SBValue - CreateValueFromData (const char* name, - lldb::SBData data, - lldb::SBType type); - - lldb::SBType - GetType(); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Returns the child member index. - /// - /// Matches children of this object only and will match base classes and - /// member names if this is a clang typed object. - /// - /// @param[in] name - /// The name of the child value to get - /// - /// @return - /// An index to the child member value. - //------------------------------------------------------------------ - ") GetIndexOfChildWithName; - uint32_t - GetIndexOfChildWithName (const char *name); - - lldb::SBValue - GetChildMemberWithName (const char *name); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Returns the child member value. - /// - /// Matches child members of this object and child members of any base - /// classes. - /// - /// @param[in] name - /// The name of the child value to get - /// - /// @param[in] use_dynamic - /// An enumeration that specifies whether to get dynamic values, - /// and also if the target can be run to figure out the dynamic - /// type of the child value. - /// - /// @return - /// A new SBValue object that represents the child member value. - //------------------------------------------------------------------ - ") GetChildMemberWithName; - lldb::SBValue - GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic); - - %feature("docstring", "Expands nested expressions like .a->b[0].c[1]->d." - ) GetValueForExpressionPath; - lldb::SBValue - GetValueForExpressionPath(const char* expr_path); - - lldb::SBDeclaration - GetDeclaration (); - - bool - MightHaveChildren (); - - bool - IsRuntimeSupportValue (); - - uint32_t - GetNumChildren (); - - void * - GetOpaqueType(); - - lldb::SBValue - Dereference (); - - lldb::SBValue - AddressOf(); - - bool - TypeIsPointerType (); - - lldb::SBTarget - GetTarget(); - - lldb::SBProcess - GetProcess(); - - lldb::SBThread - GetThread(); - - lldb::SBFrame - GetFrame(); - - %feature("docstring", " - /// Find and watch a variable. - /// It returns an SBWatchpoint, which may be invalid. - ") Watch; - lldb::SBWatchpoint - Watch (bool resolve_location, bool read, bool write, SBError &error); - - %feature("docstring", " - /// Find and watch the location pointed to by a variable. - /// It returns an SBWatchpoint, which may be invalid. - ") WatchPointee; - lldb::SBWatchpoint - WatchPointee (bool resolve_location, bool read, bool write, SBError &error); - - bool - GetDescription (lldb::SBStream &description); - - bool - GetExpressionPath (lldb::SBStream &description); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get an SBData wrapping what this SBValue points to. - /// - /// This method will dereference the current SBValue, if its - /// data type is a T* or T[], and extract item_count elements - /// of type T from it, copying their contents in an SBData. - /// - /// @param[in] item_idx - /// The index of the first item to retrieve. For an array - /// this is equivalent to array[item_idx], for a pointer - /// to *(pointer + item_idx). In either case, the measurement - /// unit for item_idx is the sizeof(T) rather than the byte - /// - /// @param[in] item_count - /// How many items should be copied into the output. By default - /// only one item is copied, but more can be asked for. - /// - /// @return - /// An SBData with the contents of the copied items, on success. - /// An empty SBData otherwise. - //------------------------------------------------------------------ - ") GetPointeeData; - lldb::SBData - GetPointeeData (uint32_t item_idx = 0, - uint32_t item_count = 1); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get an SBData wrapping the contents of this SBValue. - /// - /// This method will read the contents of this object in memory - /// and copy them into an SBData for future use. - /// - /// @return - /// An SBData with the contents of this SBValue, on success. - /// An empty SBData otherwise. - //------------------------------------------------------------------ - ") GetData; - lldb::SBData - GetData (); - - bool - SetData (lldb::SBData &data, lldb::SBError& error); - - lldb::addr_t - GetLoadAddress(); - - lldb::SBAddress - GetAddress(); - - lldb::SBValue - Persist (); - - %feature("docstring", "Returns an expression path for this value." - ) GetExpressionPath; - bool - GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes); - - %pythoncode %{ - def __get_dynamic__ (self): - '''Helper function for the "SBValue.dynamic" property.''' - return self.GetDynamicValue (eDynamicCanRunTarget) - - __swig_getmethods__["name"] = GetName - if _newclass: name = property(GetName, None, doc='''A read only property that returns the name of this value as a string.''') - - __swig_getmethods__["type"] = GetType - if _newclass: type = property(GetType, None, doc='''A read only property that returns a lldb.SBType object that represents the type for this value.''') - - __swig_getmethods__["size"] = GetByteSize - if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this value.''') - - __swig_getmethods__["is_in_scope"] = IsInScope - if _newclass: is_in_scope = property(IsInScope, None, doc='''A read only property that returns a boolean value that indicates whether this value is currently lexically in scope.''') - - __swig_getmethods__["format"] = GetFormat - __swig_setmethods__["format"] = SetFormat - if _newclass: format = property(GetName, SetFormat, doc='''A read/write property that gets/sets the format used for lldb.SBValue().GetValue() for this value. See enumerations that start with "lldb.eFormat".''') - - __swig_getmethods__["value"] = GetValue - __swig_setmethods__["value"] = SetValueFromCString - if _newclass: value = property(GetValue, SetValueFromCString, doc='''A read/write property that gets/sets value from a string.''') - - __swig_getmethods__["value_type"] = GetValueType - if _newclass: value_type = property(GetValueType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eValueType") that represents the type of this value (local, argument, global, register, etc.).''') - - __swig_getmethods__["changed"] = GetValueDidChange - if _newclass: changed = property(GetValueDidChange, None, doc='''A read only property that returns a boolean value that indicates if this value has changed since it was last updated.''') - - __swig_getmethods__["data"] = GetData - if _newclass: data = property(GetData, None, doc='''A read only property that returns an lldb object (lldb.SBData) that represents the bytes that make up the value for this object.''') - - __swig_getmethods__["load_addr"] = GetLoadAddress - if _newclass: load_addr = property(GetLoadAddress, None, doc='''A read only property that returns the load address of this value as an integer.''') - - __swig_getmethods__["addr"] = GetAddress - if _newclass: addr = property(GetAddress, None, doc='''A read only property that returns an lldb.SBAddress that represents the address of this value if it is in memory.''') - - __swig_getmethods__["deref"] = Dereference - if _newclass: deref = property(Dereference, None, doc='''A read only property that returns an lldb.SBValue that is created by dereferencing this value.''') - - __swig_getmethods__["address_of"] = AddressOf - if _newclass: address_of = property(AddressOf, None, doc='''A read only property that returns an lldb.SBValue that represents the address-of this value.''') - - __swig_getmethods__["error"] = GetError - if _newclass: error = property(GetError, None, doc='''A read only property that returns the lldb.SBError that represents the error from the last time the variable value was calculated.''') - - __swig_getmethods__["summary"] = GetSummary - if _newclass: summary = property(GetSummary, None, doc='''A read only property that returns the summary for this value as a string''') - - __swig_getmethods__["description"] = GetObjectDescription - if _newclass: description = property(GetObjectDescription, None, doc='''A read only property that returns the language-specific description of this value as a string''') - - __swig_getmethods__["dynamic"] = __get_dynamic__ - if _newclass: dynamic = property(__get_dynamic__, None, doc='''A read only property that returns an lldb.SBValue that is created by finding the dynamic type of this value.''') - - __swig_getmethods__["location"] = GetLocation - if _newclass: location = property(GetLocation, None, doc='''A read only property that returns the location of this value as a string.''') - - __swig_getmethods__["target"] = GetTarget - if _newclass: target = property(GetTarget, None, doc='''A read only property that returns the lldb.SBTarget that this value is associated with.''') - - __swig_getmethods__["process"] = GetProcess - if _newclass: process = property(GetProcess, None, doc='''A read only property that returns the lldb.SBProcess that this value is associated with, the returned value might be invalid and should be tested.''') - - __swig_getmethods__["thread"] = GetThread - if _newclass: thread = property(GetThread, None, doc='''A read only property that returns the lldb.SBThread that this value is associated with, the returned value might be invalid and should be tested.''') - - __swig_getmethods__["frame"] = GetFrame - if _newclass: frame = property(GetFrame, None, doc='''A read only property that returns the lldb.SBFrame that this value is associated with, the returned value might be invalid and should be tested.''') - - __swig_getmethods__["num_children"] = GetNumChildren - if _newclass: num_children = property(GetNumChildren, None, doc='''A read only property that returns the number of child lldb.SBValues that this value has.''') - - __swig_getmethods__["unsigned"] = GetValueAsUnsigned - if _newclass: unsigned = property(GetValueAsUnsigned, None, doc='''A read only property that returns the value of this SBValue as an usigned integer.''') - - __swig_getmethods__["signed"] = GetValueAsSigned - if _newclass: signed = property(GetValueAsSigned, None, doc='''A read only property that returns the value of this SBValue as a signed integer.''') - - def get_expr_path(self): - s = SBStream() - self.GetExpressionPath (s) - return s.GetData() - - __swig_getmethods__["path"] = get_expr_path - if _newclass: path = property(get_expr_path, None, doc='''A read only property that returns the expression path that one can use to reach this value in an expression.''') - %} - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBValueList.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBValueList.i +++ lldb/trunk/scripts/Python/interface/SBValueList.i @@ -1,142 +0,0 @@ -//===-- SWIG Interface for SBValueList --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents a collection of SBValues. Both SBFrame's GetVariables() and -GetRegisters() return a SBValueList. - -SBValueList supports SBValue iteration. For example (from test/lldbutil.py), - -def get_registers(frame, kind): - '''Returns the registers given the frame and the kind of registers desired. - - Returns None if there's no such kind. - ''' - registerSet = frame.GetRegisters() # Return type of SBValueList. - for value in registerSet: - if kind.lower() in value.GetName().lower(): - return value - - return None - -def get_GPRs(frame): - '''Returns the general purpose registers of the frame as an SBValue. - - The returned SBValue object is iterable. An example: - ... - from lldbutil import get_GPRs - regs = get_GPRs(frame) - for reg in regs: - print '%s => %s' % (reg.GetName(), reg.GetValue()) - ... - ''' - return get_registers(frame, 'general purpose') - -def get_FPRs(frame): - '''Returns the floating point registers of the frame as an SBValue. - - The returned SBValue object is iterable. An example: - ... - from lldbutil import get_FPRs - regs = get_FPRs(frame) - for reg in regs: - print '%s => %s' % (reg.GetName(), reg.GetValue()) - ... - ''' - return get_registers(frame, 'floating point') - -def get_ESRs(frame): - '''Returns the exception state registers of the frame as an SBValue. - - The returned SBValue object is iterable. An example: - ... - from lldbutil import get_ESRs - regs = get_ESRs(frame) - for reg in regs: - print '%s => %s' % (reg.GetName(), reg.GetValue()) - ... - ''' - return get_registers(frame, 'exception state')" -) SBValueList; -class SBValueList -{ -public: - - SBValueList (); - - SBValueList (const lldb::SBValueList &rhs); - - ~SBValueList(); - - bool - IsValid() const; - - void - Clear(); - - void - Append (const lldb::SBValue &val_obj); - - void - Append (const lldb::SBValueList& value_list); - - uint32_t - GetSize() const; - - lldb::SBValue - GetValueAtIndex (uint32_t idx) const; - - lldb::SBValue - FindValueObjectByUID (lldb::user_id_t uid); - - lldb::SBValue - GetFirstValueByName (const char* name) const; - - %pythoncode %{ - def __len__(self): - return int(self.GetSize()) - - def __getitem__(self, key): - count = len(self) - #------------------------------------------------------------ - # Access with "int" to get Nth item in the list - #------------------------------------------------------------ - if type(key) is int: - if key < count: - return self.GetValueAtIndex(key) - #------------------------------------------------------------ - # Access with "str" to get values by name - #------------------------------------------------------------ - elif type(key) is str: - matches = [] - for idx in range(count): - value = self.GetValueAtIndex(idx) - if value.name == key: - matches.append(value) - return matches - #------------------------------------------------------------ - # Match with regex - #------------------------------------------------------------ - elif isinstance(key, type(re.compile('.'))): - matches = [] - for idx in range(count): - value = self.GetValueAtIndex(idx) - re_match = key.search(value.name) - if re_match: - matches.append(value) - return matches - - %} - - -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBVariablesOptions.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBVariablesOptions.i +++ lldb/trunk/scripts/Python/interface/SBVariablesOptions.i @@ -1,61 +0,0 @@ -//===-- SWIG Interface for SBVariablesOptions ----------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -class SBVariablesOptions -{ -public: - SBVariablesOptions (); - - SBVariablesOptions (const SBVariablesOptions& options); - - ~SBVariablesOptions (); - - bool - IsValid () const; - - bool - GetIncludeArguments () const; - - void - SetIncludeArguments (bool); - - bool - GetIncludeLocals () const; - - void - SetIncludeLocals (bool); - - bool - GetIncludeStatics () const; - - void - SetIncludeStatics (bool); - - bool - GetInScopeOnly () const; - - void - SetInScopeOnly (bool); - - bool - GetIncludeRuntimeSupportValues () const; - - void - SetIncludeRuntimeSupportValues (bool); - - lldb::DynamicValueType - GetUseDynamic () const; - - void - SetUseDynamic (lldb::DynamicValueType); -}; - -} // namespace lldb Index: lldb/trunk/scripts/Python/interface/SBWatchpoint.i =================================================================== --- lldb/trunk/scripts/Python/interface/SBWatchpoint.i +++ lldb/trunk/scripts/Python/interface/SBWatchpoint.i @@ -1,99 +0,0 @@ -//===-- SWIG Interface for SBWatchpoint -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace lldb { - -%feature("docstring", -"Represents an instance of watchpoint for a specific target program. - -A watchpoint is determined by the address and the byte size that resulted in -this particular instantiation. Each watchpoint has its settable options. - -See also SBTarget.watchpoint_iter() for example usage of iterating through the -watchpoints of the target." -) SBWatchpoint; -class SBWatchpoint -{ -public: - - SBWatchpoint (); - - SBWatchpoint (const lldb::SBWatchpoint &rhs); - - ~SBWatchpoint (); - - bool - IsValid(); - - SBError - GetError(); - - watch_id_t - GetID (); - - %feature("docstring", " - //------------------------------------------------------------------ - /// With -1 representing an invalid hardware index. - //------------------------------------------------------------------ - ") GetHardwareIndex; - int32_t - GetHardwareIndex (); - - lldb::addr_t - GetWatchAddress (); - - size_t - GetWatchSize(); - - void - SetEnabled(bool enabled); - - bool - IsEnabled (); - - uint32_t - GetHitCount (); - - uint32_t - GetIgnoreCount (); - - void - SetIgnoreCount (uint32_t n); - - %feature("docstring", " - //------------------------------------------------------------------ - /// Get the condition expression for the watchpoint. - //------------------------------------------------------------------ - ") GetCondition; - const char * - GetCondition (); - - %feature("docstring", " - //-------------------------------------------------------------------------- - /// The watchpoint stops only if the condition expression evaluates to true. - //-------------------------------------------------------------------------- - ") SetCondition; - void - SetCondition (const char *condition); - - bool - GetDescription (lldb::SBStream &description, DescriptionLevel level); - - static bool - EventIsWatchpointEvent (const lldb::SBEvent &event); - - static lldb::WatchpointEventType - GetWatchpointEventTypeFromEvent (const lldb::SBEvent& event); - - static lldb::SBWatchpoint - GetWatchpointFromEvent (const lldb::SBEvent& event); - -}; - -} // namespace lldb Index: lldb/trunk/scripts/buildSwigWrapperClasses.py =================================================================== --- lldb/trunk/scripts/buildSwigWrapperClasses.py +++ lldb/trunk/scripts/buildSwigWrapperClasses.py @@ -280,6 +280,9 @@ if nDepth == 0: break; + # Skip the directory that contains the interface files. + listDirs.remove('interface') + if gbDbgFlag: print strSwigScriptLangsFound, for dir in listDirs: Index: lldb/trunk/scripts/finishSwigWrapperClasses.py =================================================================== --- lldb/trunk/scripts/finishSwigWrapperClasses.py +++ lldb/trunk/scripts/finishSwigWrapperClasses.py @@ -260,6 +260,9 @@ if nDepth == 0: break; + # Skip the directory that contains the interface files. + listDirs.remove('interface') + if gbDbgFlag: print strScriptLangsFound, for dir in listDirs: Index: lldb/trunk/scripts/interface/SBAddress.i =================================================================== --- lldb/trunk/scripts/interface/SBAddress.i +++ lldb/trunk/scripts/interface/SBAddress.i @@ -0,0 +1,201 @@ +//===-- SWIG Interface for SBAddress ----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"A section + offset based address class. + +The SBAddress class allows addresses to be relative to a section +that can move during runtime due to images (executables, shared +libraries, bundles, frameworks) being loaded at different +addresses than the addresses found in the object file that +represents them on disk. There are currently two types of addresses +for a section: + o file addresses + o load addresses + +File addresses represents the virtual addresses that are in the 'on +disk' object files. These virtual addresses are converted to be +relative to unique sections scoped to the object file so that +when/if the addresses slide when the images are loaded/unloaded +in memory, we can easily track these changes without having to +update every object (compile unit ranges, line tables, function +address ranges, lexical block and inlined subroutine address +ranges, global and static variables) each time an image is loaded or +unloaded. + +Load addresses represents the virtual addresses where each section +ends up getting loaded at runtime. Before executing a program, it +is common for all of the load addresses to be unresolved. When a +DynamicLoader plug-in receives notification that shared libraries +have been loaded/unloaded, the load addresses of the main executable +and any images (shared libraries) will be resolved/unresolved. When +this happens, breakpoints that are in one of these sections can be +set/cleared. + +See docstring of SBFunction for example usage of SBAddress." +) SBAddress; +class SBAddress +{ +public: + + SBAddress (); + + 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; + SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target); + + ~SBAddress (); + + bool + IsValid () const; + + void + Clear (); + + addr_t + GetFileAddress () const; + + addr_t + GetLoadAddress (const lldb::SBTarget &target) const; + + void + SetLoadAddress (lldb::addr_t load_addr, + lldb::SBTarget &target); + + bool + OffsetAddress (addr_t offset); + + bool + GetDescription (lldb::SBStream &description); + + lldb::SBSection + GetSection (); + + lldb::addr_t + SBAddress::GetOffset (); + + void + SetAddress (lldb::SBSection section, + lldb::addr_t offset); + + + lldb::AddressClass + GetAddressClass (); + + %feature("docstring", " + //------------------------------------------------------------------ + /// GetSymbolContext() and the following can lookup symbol information for a given address. + /// An address might refer to code or data from an existing module, or it + /// might refer to something on the stack or heap. The following functions + /// will only return valid values if the address has been resolved to a code + /// or data address using 'void SBAddress::SetLoadAddress(...)' or + /// 'lldb::SBAddress SBTarget::ResolveLoadAddress (...)'. + //------------------------------------------------------------------ + ") GetSymbolContext; + lldb::SBSymbolContext + GetSymbolContext (uint32_t resolve_scope); + + %feature("docstring", " + //------------------------------------------------------------------ + /// GetModule() and the following grab individual objects for a given address and + /// are less efficient if you want more than one symbol related objects. + /// Use one of the following when you want multiple debug symbol related + /// objects for an address: + /// lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t resolve_scope); + /// lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress &addr, uint32_t resolve_scope); + /// One or more bits from the SymbolContextItem enumerations can be logically + /// OR'ed together to more efficiently retrieve multiple symbol objects. + //------------------------------------------------------------------ + ") GetModule; + lldb::SBModule + GetModule (); + + lldb::SBCompileUnit + GetCompileUnit (); + + lldb::SBFunction + GetFunction (); + + lldb::SBBlock + GetBlock (); + + lldb::SBSymbol + GetSymbol (); + + lldb::SBLineEntry + GetLineEntry (); + + %pythoncode %{ + def __get_load_addr_property__ (self): + '''Get the load address for a lldb.SBAddress using the current target.''' + return self.GetLoadAddress (target) + + def __set_load_addr_property__ (self, load_addr): + '''Set the load address for a lldb.SBAddress using the current target.''' + return self.SetLoadAddress (load_addr, target) + + def __int__(self): + '''Convert an address to a load address if there is a process and that process is alive, or to a file address otherwise.''' + if process.is_alive: + return self.GetLoadAddress (target) + else: + return self.GetFileAddress () + + def __oct__(self): + '''Convert the address to an octal string''' + return '%o' % int(self) + + def __hex__(self): + '''Convert the address to an hex string''' + return '0x%x' % int(self) + + __swig_getmethods__["module"] = GetModule + if _newclass: 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.''') + + __swig_getmethods__["compile_unit"] = GetCompileUnit + if _newclass: 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.''') + + __swig_getmethods__["line_entry"] = GetLineEntry + if _newclass: 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.''') + + __swig_getmethods__["function"] = GetFunction + if _newclass: 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.''') + + __swig_getmethods__["block"] = GetBlock + if _newclass: 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.''') + + __swig_getmethods__["symbol"] = GetSymbol + if _newclass: 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.''') + + __swig_getmethods__["offset"] = GetOffset + if _newclass: offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''') + + __swig_getmethods__["section"] = GetSection + if _newclass: 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.''') + + __swig_getmethods__["file_addr"] = GetFileAddress + if _newclass: 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.''') + + __swig_getmethods__["load_addr"] = __get_load_addr_property__ + __swig_setmethods__["load_addr"] = __set_load_addr_property__ + if _newclass: load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves 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) and not in Python based commands, or breakpoint commands.''') + + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBAttachInfo.i =================================================================== --- lldb/trunk/scripts/interface/SBAttachInfo.i +++ lldb/trunk/scripts/interface/SBAttachInfo.i @@ -0,0 +1,111 @@ +//===-- SWIG Interface for SBAttachInfo--------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBAttachInfo +{ +public: + SBAttachInfo (); + + SBAttachInfo (lldb::pid_t pid); + + SBAttachInfo (const char *path, bool wait_for); + + SBAttachInfo (const lldb::SBAttachInfo &rhs); + + lldb::pid_t + GetProcessID (); + + void + SetProcessID (lldb::pid_t pid); + + void + SetExecutable (const char *path); + + void + SetExecutable (lldb::SBFileSpec exe_file); + + bool + GetWaitForLaunch (); + + void + SetWaitForLaunch (bool b); + + bool + GetIgnoreExisting (); + + void + SetIgnoreExisting (bool b); + + uint32_t + GetResumeCount (); + + void + SetResumeCount (uint32_t c); + + const char * + GetProcessPluginName (); + + void + SetProcessPluginName (const char *plugin_name); + + uint32_t + GetUserID(); + + uint32_t + GetGroupID(); + + bool + UserIDIsValid (); + + bool + GroupIDIsValid (); + + void + SetUserID (uint32_t uid); + + void + SetGroupID (uint32_t gid); + + uint32_t + GetEffectiveUserID(); + + uint32_t + GetEffectiveGroupID(); + + bool + EffectiveUserIDIsValid (); + + bool + EffectiveGroupIDIsValid (); + + void + SetEffectiveUserID (uint32_t uid); + + void + SetEffectiveGroupID (uint32_t gid); + + lldb::pid_t + GetParentProcessID (); + + void + SetParentProcessID (lldb::pid_t pid); + + bool + ParentProcessIDIsValid(); + + lldb::SBListener + GetListener (); + + void + SetListener (lldb::SBListener &listener); +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBBlock.i =================================================================== --- lldb/trunk/scripts/interface/SBBlock.i +++ lldb/trunk/scripts/interface/SBBlock.i @@ -0,0 +1,179 @@ +//===-- SWIG Interface for SBBlock ------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents a lexical block. SBFunction contains SBBlock(s)." +) SBBlock; +class SBBlock +{ +public: + + SBBlock (); + + SBBlock (const lldb::SBBlock &rhs); + + ~SBBlock (); + + %feature("docstring", + "Does this block represent an inlined function?" + ) IsInlined; + bool + IsInlined () const; + + bool + IsValid () const; + + %feature("docstring", " + Get the function name if this block represents an inlined function; + otherwise, return None. + ") GetInlinedName; + const char * + GetInlinedName () const; + + %feature("docstring", " + Get the call site file if this block represents an inlined function; + otherwise, return an invalid file spec. + ") GetInlinedCallSiteFile; + lldb::SBFileSpec + GetInlinedCallSiteFile () const; + + %feature("docstring", " + Get the call site line if this block represents an inlined function; + otherwise, return 0. + ") GetInlinedCallSiteLine; + uint32_t + GetInlinedCallSiteLine () const; + + %feature("docstring", " + Get the call site column if this block represents an inlined function; + otherwise, return 0. + ") GetInlinedCallSiteColumn; + uint32_t + GetInlinedCallSiteColumn () const; + + %feature("docstring", "Get the parent block.") GetParent; + lldb::SBBlock + GetParent (); + + %feature("docstring", "Get the inlined block that is or contains this block.") GetContainingInlinedBlock; + lldb::SBBlock + GetContainingInlinedBlock (); + + %feature("docstring", "Get the sibling block for this block.") GetSibling; + lldb::SBBlock + GetSibling (); + + %feature("docstring", "Get the first child block.") GetFirstChild; + lldb::SBBlock + GetFirstChild (); + + uint32_t + GetNumRanges (); + + lldb::SBAddress + GetRangeStartAddress (uint32_t idx); + + lldb::SBAddress + GetRangeEndAddress (uint32_t idx); + + uint32_t + GetRangeIndexForBlockAddress (lldb::SBAddress block_addr); + + bool + GetDescription (lldb::SBStream &description); + + lldb::SBValueList + GetVariables (lldb::SBFrame& frame, + bool arguments, + bool locals, + bool statics, + lldb::DynamicValueType use_dynamic); + + lldb::SBValueList + GetVariables (lldb::SBTarget& target, + bool arguments, + bool locals, + bool statics); + + %pythoncode %{ + def get_range_at_index(self, idx): + if idx < self.GetNumRanges(): + return [self.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)] + return [] + + class ranges_access(object): + '''A helper object that will lazily hand out an array of lldb.SBAddress that represent address ranges for a block.''' + def __init__(self, sbblock): + self.sbblock = sbblock + + def __len__(self): + if self.sbblock: + return int(self.sbblock.GetNumRanges()) + return 0 + + def __getitem__(self, key): + count = len(self) + if type(key) is int: + return self.sbblock.get_range_at_index (key); + if isinstance(key, SBAddress): + range_idx = self.sbblock.GetRangeIndexForBlockAddress(key); + if range_idx < len(self): + return [self.sbblock.GetRangeStartAddress(range_idx), self.sbblock.GetRangeEndAddress(range_idx)] + else: + print "error: unsupported item type: %s" % type(key) + return None + + def get_ranges_access_object(self): + '''An accessor function that returns a ranges_access() object which allows lazy block address ranges access.''' + return self.ranges_access (self) + + def get_ranges_array(self): + '''An accessor function that returns an array object that contains all ranges in this block object.''' + if not hasattr(self, 'ranges_array'): + self.ranges_array = [] + for idx in range(self.num_ranges): + self.ranges_array.append ([self.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)]) + return self.ranges_array + + def get_call_site(self): + return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn()) + + __swig_getmethods__["parent"] = GetParent + if _newclass: parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''') + + __swig_getmethods__["first_child"] = GetFirstChild + if _newclass: first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''') + + __swig_getmethods__["call_site"] = get_call_site + if _newclass: call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''') + + __swig_getmethods__["sibling"] = GetSibling + if _newclass: sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''') + + __swig_getmethods__["name"] = GetInlinedName + if _newclass: name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''') + + __swig_getmethods__["inlined_block"] = GetContainingInlinedBlock + if _newclass: inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''') + + __swig_getmethods__["range"] = get_ranges_access_object + if _newclass: range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''') + + __swig_getmethods__["ranges"] = get_ranges_array + if _newclass: ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''') + + __swig_getmethods__["num_ranges"] = GetNumRanges + if _newclass: num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''') + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBBreakpoint.i =================================================================== --- lldb/trunk/scripts/interface/SBBreakpoint.i +++ lldb/trunk/scripts/interface/SBBreakpoint.i @@ -0,0 +1,266 @@ +//===-- SWIG Interface for SBBreakpoint -------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents a logical breakpoint and its associated settings. + +For example (from test/functionalities/breakpoint/breakpoint_ignore_count/ +TestBreakpointIgnoreCount.py), + + def breakpoint_ignore_count_python(self): + '''Use Python APIs to set breakpoint ignore count.''' + exe = os.path.join(os.getcwd(), 'a.out') + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Now create a breakpoint on main.c by name 'c'. + breakpoint = target.BreakpointCreateByName('c', 'a.out') + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Get the breakpoint location from breakpoint after we verified that, + # indeed, it has one location. + location = breakpoint.GetLocationAtIndex(0) + self.assertTrue(location and + location.IsEnabled(), + VALID_BREAKPOINT_LOCATION) + + # Set the ignore count on the breakpoint location. + location.SetIgnoreCount(2) + self.assertTrue(location.GetIgnoreCount() == 2, + 'SetIgnoreCount() works correctly') + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) + + # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and + # frame#2 should be on main.c:48. + #lldbutil.print_stacktraces(process) + from lldbutil import get_stopped_thread + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint') + frame0 = thread.GetFrameAtIndex(0) + frame1 = thread.GetFrameAtIndex(1) + frame2 = thread.GetFrameAtIndex(2) + self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and + frame1.GetLineEntry().GetLine() == self.line3 and + frame2.GetLineEntry().GetLine() == self.line4, + STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT) + + # The hit count for the breakpoint should be 3. + self.assertTrue(breakpoint.GetHitCount() == 3) + + process.Continue() + +SBBreakpoint supports breakpoint location iteration, for example, + + for bl in breakpoint: + print 'breakpoint location load addr: %s' % hex(bl.GetLoadAddress()) + print 'breakpoint location condition: %s' % hex(bl.GetCondition()) + +and rich comparion methods which allow the API program to use, + + if aBreakpoint == bBreakpoint: + ... + +to compare two breakpoints for equality." +) SBBreakpoint; +class SBBreakpoint +{ +public: + + typedef bool (*BreakpointHitCallback) (void *baton, + SBProcess &process, + SBThread &thread, + lldb::SBBreakpointLocation &location); + + SBBreakpoint (); + + SBBreakpoint (const lldb::SBBreakpoint& rhs); + + ~SBBreakpoint(); + + break_id_t + GetID () const; + + bool + IsValid() const; + + void + ClearAllBreakpointSites (); + + lldb::SBBreakpointLocation + FindLocationByAddress (lldb::addr_t vm_addr); + + lldb::break_id_t + FindLocationIDByAddress (lldb::addr_t vm_addr); + + lldb::SBBreakpointLocation + FindLocationByID (lldb::break_id_t bp_loc_id); + + lldb::SBBreakpointLocation + GetLocationAtIndex (uint32_t index); + + void + SetEnabled (bool enable); + + bool + IsEnabled (); + + void + SetOneShot (bool one_shot); + + bool + IsOneShot (); + + bool + IsInternal (); + + uint32_t + GetHitCount () const; + + void + SetIgnoreCount (uint32_t count); + + uint32_t + GetIgnoreCount () const; + + %feature("docstring", " + //-------------------------------------------------------------------------- + /// The breakpoint stops only if the condition expression evaluates to true. + //-------------------------------------------------------------------------- + ") SetCondition; + void + SetCondition (const char *condition); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Get the condition expression for the breakpoint. + //------------------------------------------------------------------ + ") GetCondition; + const char * + GetCondition (); + + void + SetThreadID (lldb::tid_t sb_thread_id); + + lldb::tid_t + GetThreadID (); + + void + SetThreadIndex (uint32_t index); + + uint32_t + GetThreadIndex() const; + + void + SetThreadName (const char *thread_name); + + const char * + GetThreadName () const; + + void + SetQueueName (const char *queue_name); + + const char * + GetQueueName () const; + + %feature("docstring", " + //------------------------------------------------------------------ + /// Set the name of the script function to be called when the breakpoint is hit. + //------------------------------------------------------------------ + ") SetScriptCallbackFunction; + void + SetScriptCallbackFunction (const char *callback_function_name); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Provide the body for the script function to be called when the breakpoint is hit. + /// The body will be wrapped in a function, which be passed two arguments: + /// 'frame' - which holds the bottom-most SBFrame of the thread that hit the breakpoint + /// 'bpno' - which is the SBBreakpointLocation to which the callback was attached. + /// + /// The error parameter is currently ignored, but will at some point hold the Python + /// compilation diagnostics. + /// Returns true if the body compiles successfully, false if not. + //------------------------------------------------------------------ + ") SetScriptCallbackBody; + SBError + SetScriptCallbackBody (const char *script_body_text); + + bool + AddName (const char *new_name); + + void + RemoveName (const char *name_to_remove); + + bool + MatchesName (const char *name); + + void + GetNames (SBStringList &names); + + size_t + GetNumResolvedLocations() const; + + size_t + GetNumLocations() const; + + bool + GetDescription (lldb::SBStream &description); + + bool + operator == (const lldb::SBBreakpoint& rhs); + + bool + operator != (const lldb::SBBreakpoint& rhs); + + static bool + EventIsBreakpointEvent (const lldb::SBEvent &event); + + static lldb::BreakpointEventType + GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event); + + static lldb::SBBreakpoint + GetBreakpointFromEvent (const lldb::SBEvent& event); + + static lldb::SBBreakpointLocation + GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx); + + static uint32_t + GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event_sp); + + %pythoncode %{ + + __swig_getmethods__["id"] = GetID + if _newclass: id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''') + + __swig_getmethods__["enabled"] = IsEnabled + __swig_setmethods__["enabled"] = SetEnabled + if _newclass: enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''') + + __swig_getmethods__["one_shot"] = IsOneShot + __swig_setmethods__["one_shot"] = SetOneShot + if _newclass: one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''') + + __swig_getmethods__["num_locations"] = GetNumLocations + if _newclass: num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''') + + %} + + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBBreakpointLocation.i =================================================================== --- lldb/trunk/scripts/interface/SBBreakpointLocation.i +++ lldb/trunk/scripts/interface/SBBreakpointLocation.i @@ -0,0 +1,130 @@ +//===-- SWIG Interface for SBBreakpointLocation -----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents one unique instance (by address) of a logical breakpoint. + +A breakpoint location is defined by the breakpoint that produces it, +and the address that resulted in this particular instantiation. +Each breakpoint location has its settable options. + +SBBreakpoint contains SBBreakpointLocation(s). See docstring of SBBreakpoint +for retrieval of an SBBreakpointLocation from an SBBreakpoint." +) SBBreakpointLocation; +class SBBreakpointLocation +{ +public: + + SBBreakpointLocation (); + + SBBreakpointLocation (const lldb::SBBreakpointLocation &rhs); + + ~SBBreakpointLocation (); + + break_id_t + GetID (); + + bool + IsValid() const; + + lldb::SBAddress + GetAddress(); + + lldb::addr_t + GetLoadAddress (); + + void + SetEnabled(bool enabled); + + bool + IsEnabled (); + + uint32_t + GetIgnoreCount (); + + void + SetIgnoreCount (uint32_t n); + + %feature("docstring", " + //-------------------------------------------------------------------------- + /// The breakpoint location stops only if the condition expression evaluates + /// to true. + //-------------------------------------------------------------------------- + ") SetCondition; + void + SetCondition (const char *condition); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Get the condition expression for the breakpoint location. + //------------------------------------------------------------------ + ") GetCondition; + const char * + GetCondition (); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Set the callback to the given Python function name. + //------------------------------------------------------------------ + ") SetScriptCallbackFunction; + void + SetScriptCallbackFunction (const char *callback_function_name); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Provide the body for the script function to be called when the breakpoint location is hit. + /// The body will be wrapped in a function, which be passed two arguments: + /// 'frame' - which holds the bottom-most SBFrame of the thread that hit the breakpoint + /// 'bpno' - which is the SBBreakpointLocation to which the callback was attached. + /// + /// The error parameter is currently ignored, but will at some point hold the Python + /// compilation diagnostics. + /// Returns true if the body compiles successfully, false if not. + //------------------------------------------------------------------ + ") SetScriptCallbackBody; + SBError + SetScriptCallbackBody (const char *script_body_text); + + void + SetThreadID (lldb::tid_t sb_thread_id); + + lldb::tid_t + GetThreadID (); + + void + SetThreadIndex (uint32_t index); + + uint32_t + GetThreadIndex() const; + + void + SetThreadName (const char *thread_name); + + const char * + GetThreadName () const; + + void + SetQueueName (const char *queue_name); + + const char * + GetQueueName () const; + + bool + IsResolved (); + + bool + GetDescription (lldb::SBStream &description, DescriptionLevel level); + + SBBreakpoint + GetBreakpoint (); +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBBroadcaster.i =================================================================== --- lldb/trunk/scripts/interface/SBBroadcaster.i +++ lldb/trunk/scripts/interface/SBBroadcaster.i @@ -0,0 +1,68 @@ +//===-- SWIG Interface for SBBroadcaster ------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents an entity which can broadcast events. A default broadcaster is +associated with an SBCommandInterpreter, SBProcess, and SBTarget. For +example, use + + broadcaster = process.GetBroadcaster() + +to retrieve the process's broadcaster. + +See also SBEvent for example usage of interacting with a broadcaster." +) SBBroadcaster; +class SBBroadcaster +{ +public: + SBBroadcaster (); + + SBBroadcaster (const char *name); + + SBBroadcaster (const SBBroadcaster &rhs); + + ~SBBroadcaster(); + + bool + IsValid () const; + + void + Clear (); + + void + BroadcastEventByType (uint32_t event_type, bool unique = false); + + void + BroadcastEvent (const lldb::SBEvent &event, bool unique = false); + + void + AddInitialEventsToListener (const lldb::SBListener &listener, uint32_t requested_events); + + uint32_t + AddListener (const lldb::SBListener &listener, uint32_t event_mask); + + const char * + GetName () const; + + bool + EventTypeHasListeners (uint32_t event_type); + + bool + RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX); + + bool + operator == (const lldb::SBBroadcaster &rhs) const; + + bool + operator != (const lldb::SBBroadcaster &rhs) const; +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBCommandInterpreter.i =================================================================== --- lldb/trunk/scripts/interface/SBCommandInterpreter.i +++ lldb/trunk/scripts/interface/SBCommandInterpreter.i @@ -0,0 +1,218 @@ +//===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"SBCommandInterpreterRunOptions controls how the RunCommandInterpreter runs the code it is fed. +A default SBCommandInterpreterRunOptions object has: + StopOnContinue: false + StopOnError: false + StopOnCrash: false + EchoCommands: true + PrintResults: true + AddToHistory: true + + +") SBCommandInterpreterRunOptions; +class SBCommandInterpreterRunOptions +{ +friend class SBDebugger; +public: + SBCommandInterpreterRunOptions(); + ~SBCommandInterpreterRunOptions(); + + bool + GetStopOnContinue () const; + + void + SetStopOnContinue (bool); + + bool + GetStopOnError () const; + + void + SetStopOnError (bool); + + bool + GetStopOnCrash () const; + + void + SetStopOnCrash (bool); + + bool + GetEchoCommands () const; + + void + SetEchoCommands (bool); + + bool + GetPrintResults () const; + + void + SetPrintResults (bool); + + bool + GetAddToHistory () const; + + void + SetAddToHistory (bool); +private: + lldb_private::CommandInterpreterRunOptions * + get () const; + + lldb_private::CommandInterpreterRunOptions & + ref () const; + + // This is set in the constructor and will always be valid. + mutable std::unique_ptr m_opaque_up; +}; + +%feature("docstring", +"SBCommandInterpreter handles/interprets commands for lldb. You get the +command interpreter from the SBDebugger instance. For example (from test/ +python_api/interpreter/TestCommandInterpreterAPI.py), + + def command_interpreter_api(self): + '''Test the SBCommandInterpreter APIs.''' + exe = os.path.join(os.getcwd(), 'a.out') + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Retrieve the associated command interpreter from our debugger. + ci = self.dbg.GetCommandInterpreter() + self.assertTrue(ci, VALID_COMMAND_INTERPRETER) + + # Exercise some APIs.... + + self.assertTrue(ci.HasCommands()) + self.assertTrue(ci.HasAliases()) + self.assertTrue(ci.HasAliasOptions()) + self.assertTrue(ci.CommandExists('breakpoint')) + self.assertTrue(ci.CommandExists('target')) + self.assertTrue(ci.CommandExists('platform')) + self.assertTrue(ci.AliasExists('file')) + self.assertTrue(ci.AliasExists('run')) + self.assertTrue(ci.AliasExists('bt')) + + res = lldb.SBCommandReturnObject() + ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res) + self.assertTrue(res.Succeeded()) + ci.HandleCommand('process launch', res) + self.assertTrue(res.Succeeded()) + + process = ci.GetProcess() + self.assertTrue(process) + + ... + +The HandleCommand() instance method takes two args: the command string and +an SBCommandReturnObject instance which encapsulates the result of command +execution. +") SBCommandInterpreter; +class SBCommandInterpreter +{ +public: + enum + { + eBroadcastBitThreadShouldExit = (1 << 0), + eBroadcastBitResetPrompt = (1 << 1), + eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit + eBroadcastBitAsynchronousOutputData = (1 << 3), + eBroadcastBitAsynchronousErrorData = (1 << 4) + }; + + SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs); + + ~SBCommandInterpreter (); + + static const char * + GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); + + static const char * + GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type); + + static bool + EventIsCommandInterpreterEvent (const lldb::SBEvent &event); + + bool + IsValid() const; + + const char * + GetIOHandlerControlSequence(char ch); + + bool + GetPromptOnQuit(); + + void + SetPromptOnQuit(bool b); + + void + ResolveCommand(const char *command_line, SBCommandReturnObject &result); + + bool + CommandExists (const char *cmd); + + bool + AliasExists (const char *cmd); + + lldb::SBBroadcaster + GetBroadcaster (); + + static const char * + GetBroadcasterClass (); + + bool + HasCommands (); + + bool + HasAliases (); + + bool + HasAliasOptions (); + + lldb::SBProcess + GetProcess (); + + lldb::SBDebugger + GetDebugger (); + + void + SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result); + + void + SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result); + + lldb::ReturnStatus + HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false); + + lldb::ReturnStatus + HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history = false); + + void + HandleCommandsFromFile (lldb::SBFileSpec &file, + lldb::SBExecutionContext &override_context, + lldb::SBCommandInterpreterRunOptions &options, + lldb::SBCommandReturnObject result); + + int + HandleCompletion (const char *current_line, + uint32_t cursor_pos, + int match_start_point, + int max_return_elements, + lldb::SBStringList &matches); + + bool + IsActive (); + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBCommandReturnObject.i =================================================================== --- lldb/trunk/scripts/interface/SBCommandReturnObject.i +++ lldb/trunk/scripts/interface/SBCommandReturnObject.i @@ -0,0 +1,107 @@ +//===-- SWIG Interface for SBCommandReturnObject ----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents a container which holds the result from command execution. +It works with SBCommandInterpreter.HandleCommand() to encapsulate the result +of command execution. + +See SBCommandInterpreter for example usage of SBCommandReturnObject." +) SBCommandReturnObject; +class SBCommandReturnObject +{ +public: + + SBCommandReturnObject (); + + SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs); + + ~SBCommandReturnObject (); + + bool + IsValid() const; + + const char * + GetOutput (); + + const char * + GetError (); + + size_t + GetOutputSize (); + + size_t + GetErrorSize (); + + const char * + GetOutput (bool only_if_no_immediate); + + const char * + GetError (bool if_no_immediate); + + size_t + PutOutput (FILE *fh); + + size_t + PutError (FILE *fh); + + void + Clear(); + + void + SetStatus (lldb::ReturnStatus status); + + void + SetError (lldb::SBError &error, + const char *fallback_error_cstr = NULL); + + void + SetError (const char *error_cstr); + + lldb::ReturnStatus + GetStatus(); + + bool + Succeeded (); + + bool + HasResult (); + + void + AppendMessage (const char *message); + + void + AppendWarning (const char *message); + + bool + GetDescription (lldb::SBStream &description); + + void + SetImmediateOutputFile (FILE *fh); + + void + SetImmediateErrorFile (FILE *fh); + + void + PutCString(const char* string, int len); + + // wrapping the variadic Printf() with a plain Print() + // because it is hard to support varargs in SWIG bridgings + %extend { + void Print (const char* str) + { + self->Printf("%s", str); + } + } + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBCommunication.i =================================================================== --- lldb/trunk/scripts/interface/SBCommunication.i +++ lldb/trunk/scripts/interface/SBCommunication.i @@ -0,0 +1,82 @@ +//===-- SWIG Interface for SBCommunication ----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBCommunication +{ +public: + enum { + eBroadcastBitDisconnected = (1 << 0), ///< Sent when the communications connection is lost. + eBroadcastBitReadThreadGotBytes = (1 << 1), ///< Sent by the read thread when bytes become available. + eBroadcastBitReadThreadDidExit = (1 << 2), ///< Sent by the read thread when it exits to inform clients. + eBroadcastBitReadThreadShouldExit = (1 << 3), ///< Sent by clients that need to cancel the read thread. + eBroadcastBitPacketAvailable = (1 << 4), ///< Sent when data received makes a complete packet. + eAllEventBits = 0xffffffff + }; + + typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len); + + SBCommunication (); + SBCommunication (const char * broadcaster_name); + ~SBCommunication (); + + + bool + IsValid () const; + + lldb::SBBroadcaster + GetBroadcaster (); + + static const char *GetBroadcasterClass(); + + lldb::ConnectionStatus + AdoptFileDesriptor (int fd, bool owns_fd); + + lldb::ConnectionStatus + Connect (const char *url); + + lldb::ConnectionStatus + Disconnect (); + + bool + IsConnected () const; + + bool + GetCloseOnEOF (); + + void + SetCloseOnEOF (bool b); + + size_t + Read (void *dst, + size_t dst_len, + uint32_t timeout_usec, + lldb::ConnectionStatus &status); + + size_t + Write (const void *src, + size_t src_len, + lldb::ConnectionStatus &status); + + bool + ReadThreadStart (); + + bool + ReadThreadStop (); + + bool + ReadThreadIsRunning (); + + bool + SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback, + void *callback_baton); +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBCompileUnit.i =================================================================== --- lldb/trunk/scripts/interface/SBCompileUnit.i +++ lldb/trunk/scripts/interface/SBCompileUnit.i @@ -0,0 +1,130 @@ +//===-- SWIG Interface for SBCompileUnit ------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents a compilation unit, or compiled source file. + +SBCompileUnit supports line entry iteration. For example, + + # Now get the SBSymbolContext from this frame. We want everything. :-) + context = frame0.GetSymbolContext(lldb.eSymbolContextEverything) + ... + + compileUnit = context.GetCompileUnit() + + for lineEntry in compileUnit: + print 'line entry: %s:%d' % (str(lineEntry.GetFileSpec()), + lineEntry.GetLine()) + print 'start addr: %s' % str(lineEntry.GetStartAddress()) + print 'end addr: %s' % str(lineEntry.GetEndAddress()) + +produces: + +line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:20 +start addr: a.out[0x100000d98] +end addr: a.out[0x100000da3] +line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:21 +start addr: a.out[0x100000da3] +end addr: a.out[0x100000da9] +line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:22 +start addr: a.out[0x100000da9] +end addr: a.out[0x100000db6] +line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:23 +start addr: a.out[0x100000db6] +end addr: a.out[0x100000dbc] +... + +See also SBSymbolContext and SBLineEntry" +) SBCompileUnit; +class SBCompileUnit +{ +public: + + SBCompileUnit (); + + SBCompileUnit (const lldb::SBCompileUnit &rhs); + + ~SBCompileUnit (); + + bool + IsValid () const; + + lldb::SBFileSpec + GetFileSpec () const; + + uint32_t + GetNumLineEntries () const; + + lldb::SBLineEntry + GetLineEntryAtIndex (uint32_t idx) const; + + uint32_t + FindLineEntryIndex (uint32_t start_idx, + uint32_t line, + lldb::SBFileSpec *inline_file_spec) const; + + uint32_t + FindLineEntryIndex (uint32_t start_idx, + uint32_t line, + lldb::SBFileSpec *inline_file_spec, + bool exact) const; + + SBFileSpec + GetSupportFileAtIndex (uint32_t idx) const; + + uint32_t + GetNumSupportFiles () const; + + uint32_t + FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Get all types matching \a type_mask from debug info in this + /// compile unit. + /// + /// @param[in] type_mask + /// A bitfield that consists of one or more bits logically OR'ed + /// together from the lldb::TypeClass enumeration. This allows + /// you to request only structure types, or only class, struct + /// and union types. Passing in lldb::eTypeClassAny will return + /// all types found in the debug information for this compile + /// unit. + /// + /// @return + /// A list of types in this compile unit that match \a type_mask + //------------------------------------------------------------------ + ") GetTypes; + lldb::SBTypeList + GetTypes (uint32_t type_mask = lldb::eTypeClassAny); + + lldb::LanguageType + GetLanguage (); + + bool + GetDescription (lldb::SBStream &description); + + bool + operator == (const lldb::SBCompileUnit &rhs) const; + + bool + operator != (const lldb::SBCompileUnit &rhs) const; + + %pythoncode %{ + __swig_getmethods__["file"] = GetFileSpec + if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns the same result an lldb object that represents the source file (lldb.SBFileSpec) for the compile unit.''') + + __swig_getmethods__["num_line_entries"] = GetNumLineEntries + if _newclass: num_line_entries = property(GetNumLineEntries, None, doc='''A read only property that returns the number of line entries in a compile unit as an integer.''') + %} +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBData.i =================================================================== --- lldb/trunk/scripts/interface/SBData.i +++ lldb/trunk/scripts/interface/SBData.i @@ -0,0 +1,340 @@ +//===-- SWIG Interface for SBData -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +namespace lldb { + +class SBData +{ +public: + + SBData (); + + SBData (const SBData &rhs); + + ~SBData (); + + uint8_t + GetAddressByteSize (); + + void + SetAddressByteSize (uint8_t addr_byte_size); + + void + Clear (); + + bool + IsValid(); + + size_t + GetByteSize (); + + lldb::ByteOrder + GetByteOrder(); + + void + SetByteOrder (lldb::ByteOrder endian); + + float + GetFloat (lldb::SBError& error, lldb::offset_t offset); + + double + GetDouble (lldb::SBError& error, lldb::offset_t offset); + + long double + GetLongDouble (lldb::SBError& error, lldb::offset_t offset); + + lldb::addr_t + GetAddress (lldb::SBError& error, lldb::offset_t offset); + + uint8_t + GetUnsignedInt8 (lldb::SBError& error, lldb::offset_t offset); + + uint16_t + GetUnsignedInt16 (lldb::SBError& error, lldb::offset_t offset); + + uint32_t + GetUnsignedInt32 (lldb::SBError& error, lldb::offset_t offset); + + uint64_t + GetUnsignedInt64 (lldb::SBError& error, lldb::offset_t offset); + + int8_t + GetSignedInt8 (lldb::SBError& error, lldb::offset_t offset); + + int16_t + GetSignedInt16 (lldb::SBError& error, lldb::offset_t offset); + + int32_t + GetSignedInt32 (lldb::SBError& error, lldb::offset_t offset); + + int64_t + GetSignedInt64 (lldb::SBError& error, lldb::offset_t offset); + + const char* + GetString (lldb::SBError& error, lldb::offset_t offset); + + bool + GetDescription (lldb::SBStream &description, lldb::addr_t base_addr); + + size_t + ReadRawData (lldb::SBError& error, + lldb::offset_t offset, + void *buf, + size_t size); + + void + SetData (lldb::SBError& error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size); + + bool + Append (const SBData& rhs); + + static lldb::SBData + CreateDataFromCString (lldb::ByteOrder endian, uint32_t addr_byte_size, const char* data); + + // in the following CreateData*() and SetData*() prototypes, the two parameters array and array_len + // should not be renamed or rearranged, because doing so will break the SWIG typemap + static lldb::SBData + CreateDataFromUInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t* array, size_t array_len); + + static lldb::SBData + CreateDataFromUInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint32_t* array, size_t array_len); + + static lldb::SBData + CreateDataFromSInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int64_t* array, size_t array_len); + + static lldb::SBData + CreateDataFromSInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int32_t* array, size_t array_len); + + static lldb::SBData + CreateDataFromDoubleArray (lldb::ByteOrder endian, uint32_t addr_byte_size, double* array, size_t array_len); + + bool + SetDataFromCString (const char* data); + + bool + SetDataFromUInt64Array (uint64_t* array, size_t array_len); + + bool + SetDataFromUInt32Array (uint32_t* array, size_t array_len); + + bool + SetDataFromSInt64Array (int64_t* array, size_t array_len); + + bool + SetDataFromSInt32Array (int32_t* array, size_t array_len); + + bool + SetDataFromDoubleArray (double* array, size_t array_len); + + %pythoncode %{ + + class read_data_helper: + def __init__(self, sbdata, readerfunc, item_size): + self.sbdata = sbdata + self.readerfunc = readerfunc + self.item_size = item_size + def __getitem__(self,key): + if isinstance(key,slice): + list = [] + for x in range(*key.indices(self.__len__())): + list.append(self.__getitem__(x)) + return list + if not (isinstance(key,(int,long))): + raise TypeError('must be int') + key = key * self.item_size # SBData uses byte-based indexes, but we want to use itemsize-based indexes here + error = SBError() + my_data = self.readerfunc(self.sbdata,error,key) + if error.Fail(): + raise IndexError(error.GetCString()) + else: + return my_data + def __len__(self): + return int(self.sbdata.GetByteSize()/self.item_size) + def all(self): + return self[0:len(self)] + + @classmethod + def CreateDataFromInt (cls, value, size = None, target = None, ptr_size = None, endian = None): + import sys + lldbmodule = sys.modules[cls.__module__] + lldbdict = lldbmodule.__dict__ + if 'target' in lldbdict: + lldbtarget = lldbdict['target'] + else: + lldbtarget = None + if target == None and lldbtarget != None and lldbtarget.IsValid(): + target = lldbtarget + if ptr_size == None: + if target and target.IsValid(): + ptr_size = target.addr_size + else: + ptr_size = 8 + if endian == None: + if target and target.IsValid(): + endian = target.byte_order + else: + endian = lldbdict['eByteOrderLittle'] + if size == None: + if value > 2147483647: + size = 8 + elif value < -2147483648: + size = 8 + elif value > 4294967295: + size = 8 + else: + size = 4 + if size == 4: + if value < 0: + return SBData().CreateDataFromSInt32Array(endian, ptr_size, [value]) + return SBData().CreateDataFromUInt32Array(endian, ptr_size, [value]) + if size == 8: + if value < 0: + return SBData().CreateDataFromSInt64Array(endian, ptr_size, [value]) + return SBData().CreateDataFromUInt64Array(endian, ptr_size, [value]) + return None + + def _make_helper(self, sbdata, getfunc, itemsize): + return self.read_data_helper(sbdata, getfunc, itemsize) + + def _make_helper_uint8(self): + return self._make_helper(self, SBData.GetUnsignedInt8, 1) + + def _make_helper_uint16(self): + return self._make_helper(self, SBData.GetUnsignedInt16, 2) + + def _make_helper_uint32(self): + return self._make_helper(self, SBData.GetUnsignedInt32, 4) + + def _make_helper_uint64(self): + return self._make_helper(self, SBData.GetUnsignedInt64, 8) + + def _make_helper_sint8(self): + return self._make_helper(self, SBData.GetSignedInt8, 1) + + def _make_helper_sint16(self): + return self._make_helper(self, SBData.GetSignedInt16, 2) + + def _make_helper_sint32(self): + return self._make_helper(self, SBData.GetSignedInt32, 4) + + def _make_helper_sint64(self): + return self._make_helper(self, SBData.GetSignedInt64, 8) + + def _make_helper_float(self): + return self._make_helper(self, SBData.GetFloat, 4) + + def _make_helper_double(self): + return self._make_helper(self, SBData.GetDouble, 8) + + def _read_all_uint8(self): + return self._make_helper_uint8().all() + + def _read_all_uint16(self): + return self._make_helper_uint16().all() + + def _read_all_uint32(self): + return self._make_helper_uint32().all() + + def _read_all_uint64(self): + return self._make_helper_uint64().all() + + def _read_all_sint8(self): + return self._make_helper_sint8().all() + + def _read_all_sint16(self): + return self._make_helper_sint16().all() + + def _read_all_sint32(self): + return self._make_helper_sint32().all() + + def _read_all_sint64(self): + return self._make_helper_sint64().all() + + def _read_all_float(self): + return self._make_helper_float().all() + + def _read_all_double(self): + return self._make_helper_double().all() + + __swig_getmethods__["uint8"] = _make_helper_uint8 + if _newclass: uint8 = property(_make_helper_uint8, None, doc='''A read only property that returns an array-like object out of which you can read uint8 values.''') + + __swig_getmethods__["uint16"] = _make_helper_uint16 + if _newclass: uint16 = property(_make_helper_uint16, None, doc='''A read only property that returns an array-like object out of which you can read uint16 values.''') + + __swig_getmethods__["uint32"] = _make_helper_uint32 + if _newclass: uint32 = property(_make_helper_uint32, None, doc='''A read only property that returns an array-like object out of which you can read uint32 values.''') + + __swig_getmethods__["uint64"] = _make_helper_uint64 + if _newclass: uint64 = property(_make_helper_uint64, None, doc='''A read only property that returns an array-like object out of which you can read uint64 values.''') + + __swig_getmethods__["sint8"] = _make_helper_sint8 + if _newclass: sint8 = property(_make_helper_sint8, None, doc='''A read only property that returns an array-like object out of which you can read sint8 values.''') + + __swig_getmethods__["sint16"] = _make_helper_sint16 + if _newclass: sint16 = property(_make_helper_sint16, None, doc='''A read only property that returns an array-like object out of which you can read sint16 values.''') + + __swig_getmethods__["sint32"] = _make_helper_sint32 + if _newclass: sint32 = property(_make_helper_sint32, None, doc='''A read only property that returns an array-like object out of which you can read sint32 values.''') + + __swig_getmethods__["sint64"] = _make_helper_sint64 + if _newclass: sint64 = property(_make_helper_sint64, None, doc='''A read only property that returns an array-like object out of which you can read sint64 values.''') + + __swig_getmethods__["float"] = _make_helper_float + if _newclass: float = property(_make_helper_float, None, doc='''A read only property that returns an array-like object out of which you can read float values.''') + + __swig_getmethods__["double"] = _make_helper_double + if _newclass: double = property(_make_helper_double, None, doc='''A read only property that returns an array-like object out of which you can read double values.''') + + __swig_getmethods__["uint8s"] = _read_all_uint8 + if _newclass: uint8s = property(_read_all_uint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint8 values.''') + + __swig_getmethods__["uint16s"] = _read_all_uint16 + if _newclass: uint16s = property(_read_all_uint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint16 values.''') + + __swig_getmethods__["uint32s"] = _read_all_uint32 + if _newclass: uint32s = property(_read_all_uint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint32 values.''') + + __swig_getmethods__["uint64s"] = _read_all_uint64 + if _newclass: uint64s = property(_read_all_uint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint64 values.''') + + __swig_getmethods__["sint8s"] = _read_all_sint8 + if _newclass: sint8s = property(_read_all_sint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint8 values.''') + + __swig_getmethods__["sint16s"] = _read_all_sint16 + if _newclass: sint16s = property(_read_all_sint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint16 values.''') + + __swig_getmethods__["sint32s"] = _read_all_sint32 + if _newclass: sint32s = property(_read_all_sint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint32 values.''') + + __swig_getmethods__["sint64s"] = _read_all_sint64 + if _newclass: sint64s = property(_read_all_sint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint64 values.''') + + __swig_getmethods__["floats"] = _read_all_float + if _newclass: floats = property(_read_all_float, None, doc='''A read only property that returns an array with all the contents of this SBData represented as float values.''') + + __swig_getmethods__["doubles"] = _read_all_double + if _newclass: doubles = property(_read_all_double, None, doc='''A read only property that returns an array with all the contents of this SBData represented as double values.''') + + %} + + %pythoncode %{ + __swig_getmethods__["byte_order"] = GetByteOrder + __swig_setmethods__["byte_order"] = SetByteOrder + if _newclass: byte_order = property(GetByteOrder, SetByteOrder, doc='''A read/write property getting and setting the endianness of this SBData (data.byte_order = lldb.eByteOrderLittle).''') + + __swig_getmethods__["size"] = GetByteSize + if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size the same result as GetByteSize().''') + + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBDebugger.i =================================================================== --- lldb/trunk/scripts/interface/SBDebugger.i +++ lldb/trunk/scripts/interface/SBDebugger.i @@ -0,0 +1,382 @@ +//===-- SWIG Interface for SBDebugger ---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"SBDebugger is the primordial object that creates SBTargets and provides +access to them. It also manages the overall debugging experiences. + +For example (from example/disasm.py), + +import lldb +import os +import sys + +def disassemble_instructions (insts): + for i in insts: + print i + +... + +# Create a new debugger instance +debugger = lldb.SBDebugger.Create() + +# When we step or continue, don't return from the function until the process +# stops. We do this by setting the async mode to false. +debugger.SetAsync (False) + +# Create a target from a file and arch +print 'Creating a target for \'%s\'' % exe + +target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT) + +if target: + # If the target is valid set a breakpoint at main + main_bp = target.BreakpointCreateByName (fname, target.GetExecutable().GetFilename()); + + print main_bp + + # Launch the process. Since we specified synchronous mode, we won't return + # from this function until we hit the breakpoint at main + process = target.LaunchSimple (None, None, os.getcwd()) + + # Make sure the launch went ok + if process: + # Print some simple process info + state = process.GetState () + print process + if state == lldb.eStateStopped: + # Get the first thread + thread = process.GetThreadAtIndex (0) + if thread: + # Print some simple thread info + print thread + # Get the first frame + frame = thread.GetFrameAtIndex (0) + if frame: + # Print some simple frame info + print frame + function = frame.GetFunction() + # See if we have debug info (a function) + if function: + # We do have a function, print some info for the function + print function + # Now get all instructions for this function and print them + insts = function.GetInstructions(target) + disassemble_instructions (insts) + else: + # See if we have a symbol in the symbol table for where we stopped + symbol = frame.GetSymbol(); + if symbol: + # We do have a symbol, print some info for the symbol + print symbol + # Now get all instructions for this symbol and print them + insts = symbol.GetInstructions(target) + disassemble_instructions (insts) + + registerList = frame.GetRegisters() + print 'Frame registers (size of register set = %d):' % registerList.GetSize() + for value in registerList: + #print value + print '%s (number of children = %d):' % (value.GetName(), value.GetNumChildren()) + for child in value: + print 'Name: ', child.GetName(), ' Value: ', child.GetValue() + + print 'Hit the breakpoint at main, enter to continue and wait for program to exit or \'Ctrl-D\'/\'quit\' to terminate the program' + next = sys.stdin.readline() + if not next or next.rstrip('\n') == 'quit': + print 'Terminating the inferior process...' + process.Kill() + else: + # Now continue to the program exit + process.Continue() + # When we return from the above function we will hopefully be at the + # program exit. Print out some process info + print process + elif state == lldb.eStateExited: + print 'Didn\'t hit the breakpoint at main, program has exited...' + else: + print 'Unexpected process state: %s, killing process...' % debugger.StateAsCString (state) + process.Kill() +") SBDebugger; +class SBDebugger +{ +public: + + static void + Initialize(); + + static void + Terminate(); + + static lldb::SBDebugger + Create(); + + static lldb::SBDebugger + Create(bool source_init_files); + + static lldb::SBDebugger + Create(bool source_init_files, lldb::LogOutputCallback log_callback, void *baton); + + static void + Destroy (lldb::SBDebugger &debugger); + + static void + MemoryPressureDetected(); + + SBDebugger(); + + SBDebugger(const lldb::SBDebugger &rhs); + + ~SBDebugger(); + + bool + IsValid() const; + + void + Clear (); + + void + SetAsync (bool b); + + bool + GetAsync (); + + void + SkipLLDBInitFiles (bool b); + + void + SetInputFileHandle (FILE *f, bool transfer_ownership); + + void + SetOutputFileHandle (FILE *f, bool transfer_ownership); + + void + SetErrorFileHandle (FILE *f, bool transfer_ownership); + + FILE * + GetInputFileHandle (); + + FILE * + GetOutputFileHandle (); + + FILE * + GetErrorFileHandle (); + + lldb::SBCommandInterpreter + GetCommandInterpreter (); + + void + HandleCommand (const char *command); + + lldb::SBListener + GetListener (); + + void + HandleProcessEvent (const lldb::SBProcess &process, + const lldb::SBEvent &event, + FILE *out, + FILE *err); + + lldb::SBTarget + CreateTarget (const char *filename, + const char *target_triple, + const char *platform_name, + bool add_dependent_modules, + lldb::SBError& sb_error); + + lldb::SBTarget + CreateTargetWithFileAndTargetTriple (const char *filename, + const char *target_triple); + + lldb::SBTarget + CreateTargetWithFileAndArch (const char *filename, + const char *archname); + + lldb::SBTarget + CreateTarget (const char *filename); + + %feature("docstring", + "Return true if target is deleted from the target list of the debugger." + ) DeleteTarget; + bool + DeleteTarget (lldb::SBTarget &target); + + lldb::SBTarget + GetTargetAtIndex (uint32_t idx); + + uint32_t + GetIndexOfTarget (lldb::SBTarget target); + + lldb::SBTarget + FindTargetWithProcessID (pid_t pid); + + lldb::SBTarget + FindTargetWithFileAndArch (const char *filename, + const char *arch); + + uint32_t + GetNumTargets (); + + lldb::SBTarget + GetSelectedTarget (); + + void + SetSelectedTarget (lldb::SBTarget &target); + + lldb::SBPlatform + GetSelectedPlatform(); + + void + SetSelectedPlatform(lldb::SBPlatform &platform); + + lldb::SBSourceManager + GetSourceManager (); + + // REMOVE: just for a quick fix, need to expose platforms through + // SBPlatform from this class. + lldb::SBError + SetCurrentPlatform (const char *platform_name); + + bool + SetCurrentPlatformSDKRoot (const char *sysroot); + + // FIXME: Once we get the set show stuff in place, the driver won't need + // an interface to the Set/Get UseExternalEditor. + bool + SetUseExternalEditor (bool input); + + bool + GetUseExternalEditor (); + + bool + SetUseColor (bool use_color); + + bool + GetUseColor () const; + + static bool + GetDefaultArchitecture (char *arch_name, size_t arch_name_len); + + static bool + SetDefaultArchitecture (const char *arch_name); + + lldb::ScriptLanguage + GetScriptingLanguage (const char *script_language_name); + + static const char * + GetVersionString (); + + static const char * + StateAsCString (lldb::StateType state); + + static bool + StateIsRunningState (lldb::StateType state); + + static bool + StateIsStoppedState (lldb::StateType state); + + bool + EnableLog (const char *channel, const char ** types); + + void + SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton); + + void + DispatchInput (const void *data, size_t data_len); + + void + DispatchInputInterrupt (); + + void + DispatchInputEndOfFile (); + + const char * + GetInstanceName (); + + static SBDebugger + FindDebuggerWithID (int id); + + static lldb::SBError + SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name); + + static lldb::SBStringList + GetInternalVariableValue (const char *var_name, const char *debugger_instance_name); + + bool + GetDescription (lldb::SBStream &description); + + uint32_t + GetTerminalWidth () const; + + void + SetTerminalWidth (uint32_t term_width); + + lldb::user_id_t + GetID (); + + const char * + GetPrompt() const; + + void + SetPrompt (const char *prompt); + + lldb::ScriptLanguage + GetScriptLanguage() const; + + void + SetScriptLanguage (lldb::ScriptLanguage script_lang); + + bool + GetCloseInputOnEOF () const; + + void + SetCloseInputOnEOF (bool b); + + lldb::SBTypeCategory + GetCategory (const char* category_name); + + lldb::SBTypeCategory + CreateCategory (const char* category_name); + + bool + DeleteCategory (const char* category_name); + + uint32_t + GetNumCategories (); + + lldb::SBTypeCategory + GetCategoryAtIndex (uint32_t); + + lldb::SBTypeCategory + GetDefaultCategory(); + + lldb::SBTypeFormat + GetFormatForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeSummary + GetSummaryForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeFilter + GetFilterForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeSynthetic + GetSyntheticForType (lldb::SBTypeNameSpecifier); + + void + RunCommandInterpreter (bool auto_handle_events, + bool spawn_thread, + SBCommandInterpreterRunOptions &options, + int &num_errors, + bool &quit_requested, + bool &stopped_for_crash); +}; // class SBDebugger + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBDeclaration.i =================================================================== --- lldb/trunk/scripts/interface/SBDeclaration.i +++ lldb/trunk/scripts/interface/SBDeclaration.i @@ -0,0 +1,68 @@ +//===-- SWIG Interface for SBDeclaration --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", + "Specifies an association with a line and column for a variable." + ) SBDeclaration; + class SBDeclaration + { + public: + + SBDeclaration (); + + SBDeclaration (const lldb::SBDeclaration &rhs); + + ~SBDeclaration (); + + bool + IsValid () const; + + lldb::SBFileSpec + GetFileSpec () const; + + uint32_t + GetLine () const; + + uint32_t + GetColumn () const; + + bool + GetDescription (lldb::SBStream &description); + + void + SetFileSpec (lldb::SBFileSpec filespec); + + void + SetLine (uint32_t line); + + void + SetColumn (uint32_t column); + + bool + operator == (const lldb::SBDeclaration &rhs) const; + + bool + operator != (const lldb::SBDeclaration &rhs) const; + + %pythoncode %{ + __swig_getmethods__["file"] = GetFileSpec + if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''') + + __swig_getmethods__["line"] = GetLine + if _newclass: line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''') + + __swig_getmethods__["column"] = GetColumn + if _newclass: column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''') + %} + + }; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBError.i =================================================================== --- lldb/trunk/scripts/interface/SBError.i +++ lldb/trunk/scripts/interface/SBError.i @@ -0,0 +1,126 @@ +//===-- SWIG Interface for SBError ------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents a container for holding any error code. + +For example (from test/python_api/hello_world/TestHelloWorld.py), + + def hello_world_attach_with_id_api(self): + '''Create target, spawn a process, and attach to it by id.''' + + target = self.dbg.CreateTarget(self.exe) + + # Spawn a new process and don't display the stdout if not in TraceOn() mode. + import subprocess + popen = subprocess.Popen([self.exe, 'abc', 'xyz'], + stdout = open(os.devnull, 'w') if not self.TraceOn() else None) + + listener = lldb.SBListener('my.attach.listener') + error = lldb.SBError() + process = target.AttachToProcessWithID(listener, popen.pid, error) + + self.assertTrue(error.Success() and process, PROCESS_IS_VALID) + + # Let's check the stack traces of the attached process. + import lldbutil + stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) + self.expect(stacktraces, exe=False, + substrs = ['main.c:%d' % self.line2, + '(int)argc=3']) + + listener = lldb.SBListener('my.attach.listener') + error = lldb.SBError() + process = target.AttachToProcessWithID(listener, popen.pid, error) + + self.assertTrue(error.Success() and process, PROCESS_IS_VALID) + +checks that after the attach, there is no error condition by asserting +that error.Success() is True and we get back a valid process object. + +And (from test/python_api/event/TestEvent.py), + + # Now launch the process, and do not stop at entry point. + error = lldb.SBError() + process = target.Launch(listener, None, None, None, None, None, None, 0, False, error) + self.assertTrue(error.Success() and process, PROCESS_IS_VALID) + +checks that after calling the target.Launch() method there's no error +condition and we get back a void process object. +") SBError; +class SBError { +public: + SBError (); + + SBError (const lldb::SBError &rhs); + + ~SBError(); + + const char * + GetCString () const; + + void + Clear (); + + bool + Fail () const; + + bool + Success () const; + + uint32_t + GetError () const; + + lldb::ErrorType + GetType () const; + + void + SetError (uint32_t err, lldb::ErrorType type); + + void + SetErrorToErrno (); + + void + SetErrorToGenericError (); + + void + SetErrorString (const char *err_str); + + int + SetErrorStringWithFormat (const char *format, ...); + + bool + IsValid () const; + + bool + GetDescription (lldb::SBStream &description); + + %pythoncode %{ + __swig_getmethods__["value"] = GetError + if _newclass: value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''') + + __swig_getmethods__["fail"] = Fail + if _newclass: fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''') + + __swig_getmethods__["success"] = Success + if _newclass: success = property(Success, None, doc='''A read only property that returns the same result as Success().''') + + __swig_getmethods__["description"] = GetCString + if _newclass: description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''') + + __swig_getmethods__["type"] = GetType + if _newclass: type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''') + + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBEvent.i =================================================================== --- lldb/trunk/scripts/interface/SBEvent.i +++ lldb/trunk/scripts/interface/SBEvent.i @@ -0,0 +1,153 @@ +//===-- SWIG Interface for SBEvent ------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBBroadcaster; + +%feature("docstring", +"API clients can register to receive events. + +For example, check out the following output: + +Try wait for event... +Event description: 0x103d0bb70 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = running} +Event data flavor: Process::ProcessEventData +Process state: running + +Try wait for event... +Event description: 0x103a700a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = stopped} +Event data flavor: Process::ProcessEventData +Process state: stopped + +Try wait for event... +Event description: 0x103d0d4a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = exited} +Event data flavor: Process::ProcessEventData +Process state: exited + +Try wait for event... +timeout occurred waiting for event... + +from test/python_api/event/TestEventspy: + + def do_listen_for_and_print_event(self): + '''Create a listener and use SBEvent API to print the events received.''' + exe = os.path.join(os.getcwd(), 'a.out') + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Now create a breakpoint on main.c by name 'c'. + breakpoint = target.BreakpointCreateByName('c', 'a.out') + + # Now launch the process, and do not stop at the entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + + # Get a handle on the process's broadcaster. + broadcaster = process.GetBroadcaster() + + # Create an empty event object. + event = lldb.SBEvent() + + # Create a listener object and register with the broadcaster. + listener = lldb.SBListener('my listener') + rc = broadcaster.AddListener(listener, lldb.SBProcess.eBroadcastBitStateChanged) + self.assertTrue(rc, 'AddListener successfully retruns') + + traceOn = self.TraceOn() + if traceOn: + lldbutil.print_stacktraces(process) + + # Create MyListeningThread class to wait for any kind of event. + import threading + class MyListeningThread(threading.Thread): + def run(self): + count = 0 + # Let's only try at most 4 times to retrieve any kind of event. + # After that, the thread exits. + while not count > 3: + if traceOn: + print 'Try wait for event...' + if listener.WaitForEventForBroadcasterWithType(5, + broadcaster, + lldb.SBProcess.eBroadcastBitStateChanged, + event): + if traceOn: + desc = lldbutil.get_description(event) + print 'Event description:', desc + print 'Event data flavor:', event.GetDataFlavor() + print 'Process state:', lldbutil.state_type_to_str(process.GetState()) + print + else: + if traceOn: + print 'timeout occurred waiting for event...' + count = count + 1 + return + + # Let's start the listening thread to retrieve the events. + my_thread = MyListeningThread() + my_thread.start() + + # Use Python API to continue the process. The listening thread should be + # able to receive the state changed events. + process.Continue() + + # Use Python API to kill the process. The listening thread should be + # able to receive the state changed event, too. + process.Kill() + + # Wait until the 'MyListeningThread' terminates. + my_thread.join() +") SBEvent; +class SBEvent +{ +public: + SBEvent(); + + SBEvent (const lldb::SBEvent &rhs); + + %feature("autodoc", + "__init__(self, int type, str data) -> SBEvent (make an event that contains a C string)" + ) SBEvent; + SBEvent (uint32_t event, const char *cstr, uint32_t cstr_len); + + ~SBEvent(); + + bool + IsValid() const; + + const char * + GetDataFlavor (); + + uint32_t + GetType () const; + + lldb::SBBroadcaster + GetBroadcaster () const; + + const char * + GetBroadcasterClass () const; + + bool + BroadcasterMatchesRef (const lldb::SBBroadcaster &broadcaster); + + void + Clear(); + + static const char * + GetCStringFromEvent (const lldb::SBEvent &event); + + bool + GetDescription (lldb::SBStream &description) const; +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBExecutionContext.i =================================================================== --- lldb/trunk/scripts/interface/SBExecutionContext.i +++ lldb/trunk/scripts/interface/SBExecutionContext.i @@ -0,0 +1,57 @@ +//===-- SWIG Interface for SBExecutionContext ---------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBExecutionContext +{ +public: + SBExecutionContext(); + + SBExecutionContext (const lldb::SBExecutionContext &rhs); + + SBExecutionContext (const lldb::SBTarget &target); + + SBExecutionContext (const lldb::SBProcess &process); + + SBExecutionContext (lldb::SBThread thread); // can't be a const& because SBThread::get() isn't itself a const function + + SBExecutionContext (const lldb::SBFrame &frame); + + ~SBExecutionContext(); + + SBTarget + GetTarget () const; + + SBProcess + GetProcess () const; + + SBThread + GetThread () const; + + SBFrame + GetFrame () const; + + %pythoncode %{ + __swig_getmethods__["target"] = GetTarget + if _newclass: target = property(GetTarget, None, doc='''A read only property that returns the same result as GetTarget().''') + + __swig_getmethods__["process"] = GetProcess + if _newclass: process = property(GetProcess, None, doc='''A read only property that returns the same result as GetProcess().''') + + __swig_getmethods__["thread"] = GetThread + if _newclass: thread = property(GetThread, None, doc='''A read only property that returns the same result as GetThread().''') + + __swig_getmethods__["frame"] = GetFrame + if _newclass: frame = property(GetFrame, None, doc='''A read only property that returns the same result as GetFrame().''') + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBExpressionOptions.i =================================================================== --- lldb/trunk/scripts/interface/SBExpressionOptions.i +++ lldb/trunk/scripts/interface/SBExpressionOptions.i @@ -0,0 +1,130 @@ +//===-- SWIG interface for SBExpressionOptions -----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"A container for options to use when evaluating expressions." +) SBExpressionOptions; + +class SBExpressionOptions +{ +friend class SBFrame; +friend class SBValue; + +public: + SBExpressionOptions(); + + SBExpressionOptions (const lldb::SBExpressionOptions &rhs); + + ~SBExpressionOptions(); + + bool + GetCoerceResultToId () const; + + %feature("docstring", "Sets whether to coerce the expression result to ObjC id type after evaluation.") SetCoerceResultToId; + + void + SetCoerceResultToId (bool coerce = true); + + bool + GetUnwindOnError () const; + + %feature("docstring", "Sets whether to unwind the expression stack on error.") SetUnwindOnError; + + void + SetUnwindOnError (bool unwind = true); + + bool + GetIgnoreBreakpoints () const; + + %feature("docstring", "Sets whether to ignore breakpoint hits while running expressions.") SetUnwindOnError; + + void + SetIgnoreBreakpoints (bool ignore = true); + + lldb::DynamicValueType + GetFetchDynamicValue () const; + + %feature("docstring", "Sets whether to cast the expression result to its dynamic type.") SetFetchDynamicValue; + + void + SetFetchDynamicValue (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget); + + uint32_t + GetTimeoutInMicroSeconds () const; + + %feature("docstring", "Sets the timeout in microseconds to run the expression for. If try all threads is set to true and the expression doesn't complete within the specified timeout, all threads will be resumed for the same timeout to see if the expresson will finish.") SetTimeoutInMicroSeconds; + void + SetTimeoutInMicroSeconds (uint32_t timeout = 0); + + uint32_t + GetOneThreadTimeoutInMicroSeconds () const; + + %feature("docstring", "Sets the timeout in microseconds to run the expression on one thread before either timing out or trying all threads.") SetTimeoutInMicroSeconds; + void + SetOneThreadTimeoutInMicroSeconds (uint32_t timeout = 0); + + bool + GetTryAllThreads () const; + + %feature("docstring", "Sets whether to run all threads if the expression does not complete on one thread.") SetTryAllThreads; + void + SetTryAllThreads (bool run_others = true); + + bool + GetStopOthers () const; + + %feature("docstring", "Sets whether to stop other threads at all while running expressins. If false, TryAllThreads does nothing.") SetTryAllThreads; + void + SetStopOthers (bool stop_others = true); + + bool + GetTrapExceptions () const; + + %feature("docstring", "Sets whether to abort expression evaluation if an exception is thrown while executing. Don't set this to false unless you know the function you are calling traps all exceptions itself.") SetTryAllThreads; + void + SetTrapExceptions (bool trap_exceptions = true); + + %feature ("docstring", "Sets the language that LLDB should assume the expression is written in") SetLanguage; + void + SetLanguage (lldb::LanguageType language); + + bool + GetGenerateDebugInfo (); + + %feature("docstring", "Sets whether to generate debug information for the expression and also controls if a SBModule is generated.") SetGenerateDebugInfo; + void + SetGenerateDebugInfo (bool b = true); + + bool + GetSuppressPersistentResult (); + + %feature("docstring", "Sets whether to produce a persistent result that can be used in future expressions.") SetSuppressPersistentResult; + void + SetSuppressPersistentResult (bool b = false); + + + +protected: + + SBExpressionOptions (lldb_private::EvaluateExpressionOptions &expression_options); + + lldb_private::EvaluateExpressionOptions * + get () const; + + lldb_private::EvaluateExpressionOptions & + ref () const; + +private: + // This auto_pointer is made in the constructor and is always valid. + mutable std::unique_ptr m_opaque_ap; +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBFileSpec.i =================================================================== --- lldb/trunk/scripts/interface/SBFileSpec.i +++ lldb/trunk/scripts/interface/SBFileSpec.i @@ -0,0 +1,103 @@ +//===-- SWIG Interface for SBFileSpec ---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents a file specification that divides the path into a directory and +basename. The string values of the paths are put into uniqued string pools +for fast comparisons and efficient memory usage. + +For example, the following code + + lineEntry = context.GetLineEntry() + self.expect(lineEntry.GetFileSpec().GetDirectory(), 'The line entry should have the correct directory', + exe=False, + substrs = [self.mydir]) + self.expect(lineEntry.GetFileSpec().GetFilename(), 'The line entry should have the correct filename', + exe=False, + substrs = ['main.c']) + self.assertTrue(lineEntry.GetLine() == self.line, + 'The line entry's line number should match ') + +gets the line entry from the symbol context when a thread is stopped. +It gets the file spec corresponding to the line entry and checks that +the filename and the directory matches what we expect. +") SBFileSpec; +class SBFileSpec +{ +public: + SBFileSpec (); + + SBFileSpec (const lldb::SBFileSpec &rhs); + + SBFileSpec (const char *path);// Deprecated, use SBFileSpec (const char *path, bool resolve) + + SBFileSpec (const char *path, bool resolve); + + ~SBFileSpec (); + + bool + IsValid() const; + + bool + Exists () const; + + bool + ResolveExecutableLocation (); + + const char * + GetFilename() const; + + const char * + GetDirectory() const; + + void + SetFilename(const char *filename); + + void + SetDirectory(const char *directory); + + uint32_t + GetPath (char *dst_path, size_t dst_len) const; + + static int + ResolvePath (const char *src_path, char *dst_path, size_t dst_len); + + bool + GetDescription (lldb::SBStream &description) const; + + %pythoncode %{ + def __get_fullpath__(self): + spec_dir = self.GetDirectory() + spec_file = self.GetFilename() + if spec_dir and spec_file: + return '%s/%s' % (spec_dir, spec_file) + elif spec_dir: + return spec_dir + elif spec_file: + return spec_file + return None + + __swig_getmethods__["fullpath"] = __get_fullpath__ + if _newclass: fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''') + + __swig_getmethods__["basename"] = GetFilename + if _newclass: basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''') + + __swig_getmethods__["dirname"] = GetDirectory + if _newclass: dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''') + + __swig_getmethods__["exists"] = Exists + if _newclass: exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''') + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBFileSpecList.i =================================================================== --- lldb/trunk/scripts/interface/SBFileSpecList.i +++ lldb/trunk/scripts/interface/SBFileSpecList.i @@ -0,0 +1,45 @@ +//===-- SWIG Interface for SBFileSpecList -----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBFileSpecList +{ +public: + SBFileSpecList (); + + SBFileSpecList (const lldb::SBFileSpecList &rhs); + + ~SBFileSpecList (); + + uint32_t + GetSize () const; + + bool + GetDescription (SBStream &description) const; + + void + Append (const SBFileSpec &sb_file); + + bool + AppendIfUnique (const SBFileSpec &sb_file); + + void + Clear(); + + uint32_t + FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full); + + const SBFileSpec + GetFileSpecAtIndex (uint32_t idx) const; + +}; + + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBFrame.i =================================================================== --- lldb/trunk/scripts/interface/SBFrame.i +++ lldb/trunk/scripts/interface/SBFrame.i @@ -0,0 +1,379 @@ +//===-- SWIG Interface for SBFrame ------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents one of the stack frames associated with a thread. +SBThread contains SBFrame(s). For example (from test/lldbutil.py), + +def print_stacktrace(thread, string_buffer = False): + '''Prints a simple stack trace of this thread.''' + + ... + + for i in range(depth): + frame = thread.GetFrameAtIndex(i) + function = frame.GetFunction() + + load_addr = addrs[i].GetLoadAddress(target) + if not function: + file_addr = addrs[i].GetFileAddress() + start_addr = frame.GetSymbol().GetStartAddress().GetFileAddress() + symbol_offset = file_addr - start_addr + print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format( + num=i, addr=load_addr, mod=mods[i], symbol=symbols[i], offset=symbol_offset) + else: + print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format( + num=i, addr=load_addr, mod=mods[i], + func='%s [inlined]' % funcs[i] if frame.IsInlined() else funcs[i], + file=files[i], line=lines[i], + args=get_args_as_string(frame, showFuncName=False) if not frame.IsInlined() else '()') + + ... + +And, + + for frame in thread: + print frame + +See also SBThread." +) SBFrame; +class SBFrame +{ +public: + SBFrame (); + + SBFrame (const lldb::SBFrame &rhs); + + ~SBFrame(); + + bool + IsEqual (const lldb::SBFrame &rhs) const; + + bool + IsValid() const; + + uint32_t + GetFrameID () const; + + lldb::addr_t + GetPC () const; + + bool + SetPC (lldb::addr_t new_pc); + + lldb::addr_t + GetSP () const; + + lldb::addr_t + GetFP () const; + + lldb::SBAddress + GetPCAddress () const; + + lldb::SBSymbolContext + GetSymbolContext (uint32_t resolve_scope) const; + + lldb::SBModule + GetModule () const; + + lldb::SBCompileUnit + GetCompileUnit () const; + + lldb::SBFunction + GetFunction () const; + + lldb::SBSymbol + GetSymbol () const; + + %feature("docstring", " + /// Gets the deepest block that contains the frame PC. + /// + /// See also GetFrameBlock(). + ") GetBlock; + lldb::SBBlock + GetBlock () const; + + %feature("docstring", " + /// Get the appropriate function name for this frame. Inlined functions in + /// LLDB are represented by Blocks that have inlined function information, so + /// just looking at the SBFunction or SBSymbol for a frame isn't enough. + /// This function will return the appropriate function, symbol or inlined + /// function name for the frame. + /// + /// This function returns: + /// - the name of the inlined function (if there is one) + /// - the name of the concrete function (if there is one) + /// - the name of the symbol (if there is one) + /// - NULL + /// + /// See also IsInlined(). + ") GetFunctionName; + const char * + GetFunctionName(); + + %feature("docstring", " + /// Return true if this frame represents an inlined function. + /// + /// See also GetFunctionName(). + ") IsInlined; + bool + IsInlined(); + + %feature("docstring", " + /// The version that doesn't supply a 'use_dynamic' value will use the + /// target's default. + ") EvaluateExpression; + lldb::SBValue + EvaluateExpression (const char *expr); + + lldb::SBValue + EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic); + + lldb::SBValue + EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic, bool unwind_on_error); + + lldb::SBValue + EvaluateExpression (const char *expr, SBExpressionOptions &options); + + %feature("docstring", " + /// Gets the lexical block that defines the stack frame. Another way to think + /// of this is it will return the block that contains all of the variables + /// for a stack frame. Inlined functions are represented as SBBlock objects + /// that have inlined function information: the name of the inlined function, + /// where it was called from. The block that is returned will be the first + /// block at or above the block for the PC (SBFrame::GetBlock()) that defines + /// the scope of the frame. When a function contains no inlined functions, + /// this will be the top most lexical block that defines the function. + /// When a function has inlined functions and the PC is currently + /// in one of those inlined functions, this method will return the inlined + /// block that defines this frame. If the PC isn't currently in an inlined + /// function, the lexical block that defines the function is returned. + ") GetFrameBlock; + lldb::SBBlock + GetFrameBlock () const; + + lldb::SBLineEntry + GetLineEntry () const; + + lldb::SBThread + GetThread () const; + + const char * + Disassemble () const; + + void + Clear(); + +#ifndef SWIG + bool + operator == (const lldb::SBFrame &rhs) const; + + bool + operator != (const lldb::SBFrame &rhs) const; + +#endif + + %feature("docstring", " + /// The version that doesn't supply a 'use_dynamic' value will use the + /// target's default. + ") GetVariables; + lldb::SBValueList + GetVariables (bool arguments, + bool locals, + bool statics, + bool in_scope_only); + + lldb::SBValueList + GetVariables (bool arguments, + bool locals, + bool statics, + bool in_scope_only, + lldb::DynamicValueType use_dynamic); + + lldb::SBValueList + GetVariables (const lldb::SBVariablesOptions& options); + + lldb::SBValueList + GetRegisters (); + + %feature("docstring", " + /// The version that doesn't supply a 'use_dynamic' value will use the + /// target's default. + ") FindVariable; + lldb::SBValue + FindVariable (const char *var_name); + + lldb::SBValue + FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic); + + lldb::SBValue + FindRegister (const char *name); + + %feature("docstring", " + /// Get a lldb.SBValue for a variable path. + /// + /// Variable paths can include access to pointer or instance members: + /// rect_ptr->origin.y + /// pt.x + /// Pointer dereferences: + /// *this->foo_ptr + /// **argv + /// Address of: + /// &pt + /// &my_array[3].x + /// Array accesses and treating pointers as arrays: + /// int_array[1] + /// pt_ptr[22].x + /// + /// Unlike EvaluateExpression() which returns lldb.SBValue objects + /// with constant copies of the values at the time of evaluation, + /// the result of this function is a value that will continue to + /// track the current value of the value as execution progresses + /// in the current frame. + ") GetValueForVariablePath; + lldb::SBValue + GetValueForVariablePath (const char *var_path); + + lldb::SBValue + GetValueForVariablePath (const char *var_path, lldb::DynamicValueType use_dynamic); + + %feature("docstring", " + /// Find variables, register sets, registers, or persistent variables using + /// the frame as the scope. + /// + /// The version that doesn't supply a 'use_dynamic' value will use the + /// target's default. + ") FindValue; + lldb::SBValue + FindValue (const char *name, ValueType value_type); + + lldb::SBValue + FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic); + + bool + GetDescription (lldb::SBStream &description); + + %pythoncode %{ + def get_all_variables(self): + return self.GetVariables(True,True,True,True) + + def get_arguments(self): + return self.GetVariables(True,False,False,False) + + def get_locals(self): + return self.GetVariables(False,True,False,False) + + def get_statics(self): + return self.GetVariables(False,False,True,False) + + def var(self, var_expr_path): + '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns + a value that represents the variable expression path''' + return self.GetValueForVariablePath(var_expr_path) + + def get_registers_access(self): + class registers_access(object): + '''A helper object that exposes a flattened view of registers, masking away the notion of register sets for easy scripting.''' + def __init__(self, regs): + self.regs = regs + + def __getitem__(self, key): + if type(key) is str: + for i in range(0,len(self.regs)): + rs = self.regs[i] + for j in range (0,rs.num_children): + reg = rs.GetChildAtIndex(j) + if reg.name == key: return reg + else: + return lldb.SBValue() + + return registers_access(self.registers) + + __swig_getmethods__["pc"] = GetPC + __swig_setmethods__["pc"] = SetPC + if _newclass: pc = property(GetPC, SetPC) + + __swig_getmethods__["addr"] = GetPCAddress + if _newclass: addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''') + + __swig_getmethods__["fp"] = GetFP + if _newclass: fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''') + + __swig_getmethods__["sp"] = GetSP + if _newclass: sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''') + + __swig_getmethods__["module"] = GetModule + if _newclass: module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''') + + __swig_getmethods__["compile_unit"] = GetCompileUnit + if _newclass: compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) for this stack frame.''') + + __swig_getmethods__["function"] = GetFunction + if _newclass: function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''') + + __swig_getmethods__["symbol"] = GetSymbol + if _newclass: symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''') + + __swig_getmethods__["block"] = GetBlock + if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''') + + __swig_getmethods__["is_inlined"] = IsInlined + if _newclass: is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''') + + __swig_getmethods__["name"] = GetFunctionName + if _newclass: name = property(GetFunctionName, None, doc='''A read only property that retuns the name for the function that this frame represents. Inlined stack frame might have a concrete function that differs from the name of the inlined function (a named lldb.SBBlock).''') + + __swig_getmethods__["line_entry"] = GetLineEntry + if _newclass: line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line table entry (lldb.SBLineEntry) for this stack frame.''') + + __swig_getmethods__["thread"] = GetThread + if _newclass: thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''') + + __swig_getmethods__["disassembly"] = Disassemble + if _newclass: disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''') + + __swig_getmethods__["idx"] = GetFrameID + if _newclass: idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''') + + __swig_getmethods__["variables"] = get_all_variables + if _newclass: variables = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') + + __swig_getmethods__["vars"] = get_all_variables + if _newclass: vars = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''') + + __swig_getmethods__["locals"] = get_locals + if _newclass: locals = property(get_locals, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the local variables in this stack frame.''') + + __swig_getmethods__["args"] = get_arguments + if _newclass: args = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') + + __swig_getmethods__["arguments"] = get_arguments + if _newclass: arguments = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''') + + __swig_getmethods__["statics"] = get_statics + if _newclass: statics = property(get_statics, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the static variables in this stack frame.''') + + __swig_getmethods__["registers"] = GetRegisters + if _newclass: registers = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') + + __swig_getmethods__["regs"] = GetRegisters + if _newclass: regs = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') + + __swig_getmethods__["register"] = get_registers_access + if _newclass: register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''') + + __swig_getmethods__["reg"] = get_registers_access + if _newclass: reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''') + + %} +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBFunction.i =================================================================== --- lldb/trunk/scripts/interface/SBFunction.i +++ lldb/trunk/scripts/interface/SBFunction.i @@ -0,0 +1,129 @@ +//===-- SWIG Interface for SBFunction ---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents a generic function, which can be inlined or not. + +For example (from test/lldbutil.py, but slightly modified for doc purpose), + + ... + + frame = thread.GetFrameAtIndex(i) + addr = frame.GetPCAddress() + load_addr = addr.GetLoadAddress(target) + function = frame.GetFunction() + mod_name = frame.GetModule().GetFileSpec().GetFilename() + + if not function: + # No debug info for 'function'. + symbol = frame.GetSymbol() + file_addr = addr.GetFileAddress() + start_addr = symbol.GetStartAddress().GetFileAddress() + symbol_name = symbol.GetName() + symbol_offset = file_addr - start_addr + print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format( + num=i, addr=load_addr, mod=mod_name, symbol=symbol_name, offset=symbol_offset) + else: + # Debug info is available for 'function'. + func_name = frame.GetFunctionName() + file_name = frame.GetLineEntry().GetFileSpec().GetFilename() + line_num = frame.GetLineEntry().GetLine() + print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format( + num=i, addr=load_addr, mod=mod_name, + func='%s [inlined]' % func_name] if frame.IsInlined() else func_name, + file=file_name, line=line_num, args=get_args_as_string(frame, showFuncName=False)) + + ... +") SBFunction; +class SBFunction +{ +public: + + SBFunction (); + + SBFunction (const lldb::SBFunction &rhs); + + ~SBFunction (); + + bool + IsValid () const; + + const char * + GetName() const; + + const char * + GetMangledName () const; + + lldb::SBInstructionList + GetInstructions (lldb::SBTarget target); + + lldb::SBInstructionList + GetInstructions (lldb::SBTarget target, const char *flavor); + + lldb::SBAddress + GetStartAddress (); + + lldb::SBAddress + GetEndAddress (); + + uint32_t + GetPrologueByteSize (); + + lldb::SBType + GetType (); + + lldb::SBBlock + GetBlock (); + + lldb::LanguageType + GetLanguage (); + + bool + GetDescription (lldb::SBStream &description); + + bool + operator == (const lldb::SBFunction &rhs) const; + + bool + operator != (const lldb::SBFunction &rhs) const; + + %pythoncode %{ + def get_instructions_from_current_target (self): + return self.GetInstructions (target) + + __swig_getmethods__["addr"] = GetStartAddress + if _newclass: addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this function.''') + + __swig_getmethods__["end_addr"] = GetEndAddress + if _newclass: end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this function.''') + + __swig_getmethods__["block"] = GetBlock + if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the top level lexical block (lldb.SBBlock) for this function.''') + + __swig_getmethods__["instructions"] = get_instructions_from_current_target + if _newclass: instructions = property(get_instructions_from_current_target, None, doc='''A read only property that returns an lldb object that represents the instructions (lldb.SBInstructionList) for this function.''') + + __swig_getmethods__["mangled"] = GetMangledName + if _newclass: mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this function as a string.''') + + __swig_getmethods__["name"] = GetName + if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this function as a string.''') + + __swig_getmethods__["prologue_size"] = GetPrologueByteSize + if _newclass: prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''') + + __swig_getmethods__["type"] = GetType + if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the return type (lldb.SBType) for this function.''') + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBHostOS.i =================================================================== --- lldb/trunk/scripts/interface/SBHostOS.i +++ lldb/trunk/scripts/interface/SBHostOS.i @@ -0,0 +1,47 @@ +//===-- SWIG Interface for SBHostOS -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBHostOS +{ +public: + + static lldb::SBFileSpec + GetProgramFileSpec (); + + static lldb::SBFileSpec + GetLLDBPythonPath (); + + static lldb::SBFileSpec + GetLLDBPath (lldb::PathType path_type); + + static void + ThreadCreated (const char *name); + + static lldb::thread_t + ThreadCreate (const char *name, + lldb::thread_func_t, + void *thread_arg, + lldb::SBError *err); + + static bool + ThreadCancel (lldb::thread_t thread, + lldb::SBError *err); + + static bool + ThreadDetach (lldb::thread_t thread, + lldb::SBError *err); + static bool + ThreadJoin (lldb::thread_t thread, + lldb::thread_result_t *result, + lldb::SBError *err); +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBInstruction.i =================================================================== --- lldb/trunk/scripts/interface/SBInstruction.i +++ lldb/trunk/scripts/interface/SBInstruction.i @@ -0,0 +1,103 @@ +//===-- SWIG Interface for SBInstruction ------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +// There's a lot to be fixed here, but need to wait for underlying insn implementation +// to be revised & settle down first. + +namespace lldb { + +class SBInstruction +{ +public: + + SBInstruction (); + + SBInstruction (const SBInstruction &rhs); + + ~SBInstruction (); + + bool + IsValid(); + + lldb::SBAddress + GetAddress(); + + lldb::AddressClass + GetAddressClass (); + + const char * + GetMnemonic (lldb::SBTarget target); + + const char * + GetOperands (lldb::SBTarget target); + + const char * + GetComment (lldb::SBTarget target); + + lldb::SBData + GetData (lldb::SBTarget target); + + size_t + GetByteSize (); + + bool + DoesBranch (); + + void + Print (FILE *out); + + bool + GetDescription (lldb::SBStream &description); + + bool + EmulateWithFrame (lldb::SBFrame &frame, uint32_t evaluate_options); + + bool + DumpEmulation (const char * triple); // triple is to specify the architecture, e.g. 'armv6' or 'armv7-apple-ios' + + bool + TestEmulation (lldb::SBStream &output_stream, const char *test_file); + + %pythoncode %{ + def __mnemonic_property__ (self): + return self.GetMnemonic (target) + def __operands_property__ (self): + return self.GetOperands (target) + def __comment_property__ (self): + return self.GetComment (target) + def __file_addr_property__ (self): + return self.GetAddress ().GetFileAddress() + def __load_adrr_property__ (self): + return self.GetComment (target) + + __swig_getmethods__["mnemonic"] = __mnemonic_property__ + if _newclass: mnemonic = property(__mnemonic_property__, None, doc='''A read only property that returns the mnemonic for this instruction as a string.''') + + __swig_getmethods__["operands"] = __operands_property__ + if _newclass: operands = property(__operands_property__, None, doc='''A read only property that returns the operands for this instruction as a string.''') + + __swig_getmethods__["comment"] = __comment_property__ + if _newclass: comment = property(__comment_property__, None, doc='''A read only property that returns the comment for this instruction as a string.''') + + __swig_getmethods__["addr"] = GetAddress + if _newclass: addr = property(GetAddress, None, doc='''A read only property that returns an lldb object that represents the address (lldb.SBAddress) for this instruction.''') + + __swig_getmethods__["size"] = GetByteSize + if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes for this instruction as an integer.''') + + __swig_getmethods__["is_branch"] = DoesBranch + if _newclass: is_branch = property(DoesBranch, None, doc='''A read only property that returns a boolean value that indicates if this instruction is a branch instruction.''') + %} + + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBInstructionList.i =================================================================== --- lldb/trunk/scripts/interface/SBInstructionList.i +++ lldb/trunk/scripts/interface/SBInstructionList.i @@ -0,0 +1,91 @@ +//===-- SWIG Interface for SBInstructionList --------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +namespace lldb { + +%feature("docstring", +"Represents a list of machine instructions. SBFunction and SBSymbol have +GetInstructions() methods which return SBInstructionList instances. + +SBInstructionList supports instruction (SBInstruction instance) iteration. +For example (see also SBDebugger for a more complete example), + +def disassemble_instructions (insts): + for i in insts: + print i + +defines a function which takes an SBInstructionList instance and prints out +the machine instructions in assembly format." +) SBInstructionList; +class SBInstructionList +{ +public: + + SBInstructionList (); + + SBInstructionList (const SBInstructionList &rhs); + + ~SBInstructionList (); + + bool + IsValid () const; + + size_t + GetSize (); + + lldb::SBInstruction + GetInstructionAtIndex (uint32_t idx); + + void + Clear (); + + void + AppendInstruction (lldb::SBInstruction inst); + + void + Print (FILE *out); + + bool + GetDescription (lldb::SBStream &description); + + bool + DumpEmulationForAllInstructions (const char *triple); + + %pythoncode %{ + def __len__(self): + '''Access len of the instruction list.''' + return int(self.GetSize()) + + def __getitem__(self, key): + '''Access instructions by integer index for array access or by lldb.SBAddress to find an instruction that matches a section offset address object.''' + if type(key) is int: + # Find an instruction by index + if key < len(self): + return self.GetInstructionAtIndex(key) + elif type(key) is SBAddress: + # Find an instruction using a lldb.SBAddress object + lookup_file_addr = key.file_addr + closest_inst = None + for idx in range(self.GetSize()): + inst = self.GetInstructionAtIndex(idx) + inst_file_addr = inst.addr.file_addr + if inst_file_addr == lookup_file_addr: + return inst + elif inst_file_addr > lookup_file_addr: + return closest_inst + else: + closest_inst = inst + return None + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBLaunchInfo.i =================================================================== --- lldb/trunk/scripts/interface/SBLaunchInfo.i +++ lldb/trunk/scripts/interface/SBLaunchInfo.i @@ -0,0 +1,132 @@ +//===-- SWIG Interface for SBLaunchInfo--------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBLaunchInfo +{ +public: + SBLaunchInfo (const char **argv); + + pid_t + GetProcessID(); + + uint32_t + GetUserID(); + + uint32_t + GetGroupID(); + + bool + UserIDIsValid (); + + bool + GroupIDIsValid (); + + void + SetUserID (uint32_t uid); + + void + SetGroupID (uint32_t gid); + + lldb::SBFileSpec + GetExecutableFile (); + + void + SetExecutableFile (lldb::SBFileSpec exe_file, bool add_as_first_arg); + + lldb::SBListener + GetListener (); + + void + SetListener (lldb::SBListener &listener); + + uint32_t + GetNumArguments (); + + const char * + GetArgumentAtIndex (uint32_t idx); + + void + SetArguments (const char **argv, bool append); + + uint32_t + GetNumEnvironmentEntries (); + + const char * + GetEnvironmentEntryAtIndex (uint32_t idx); + + void + SetEnvironmentEntries (const char **envp, bool append); + + void + Clear (); + + const char * + GetWorkingDirectory () const; + + void + SetWorkingDirectory (const char *working_dir); + + uint32_t + GetLaunchFlags (); + + void + SetLaunchFlags (uint32_t flags); + + const char * + GetProcessPluginName (); + + void + SetProcessPluginName (const char *plugin_name); + + const char * + GetShell (); + + void + SetShell (const char * path); + + bool + GetShellExpandArguments (); + + void + SetShellExpandArguments (bool expand); + + uint32_t + GetResumeCount (); + + void + SetResumeCount (uint32_t c); + + bool + AddCloseFileAction (int fd); + + bool + AddDuplicateFileAction (int fd, int dup_fd); + + bool + AddOpenFileAction (int fd, const char *path, bool read, bool write); + + bool + AddSuppressFileAction (int fd, bool read, bool write); + + void + SetLaunchEventData (const char *data); + + const char * + GetLaunchEventData () const; + + bool + GetDetachOnError() const; + + void + SetDetachOnError(bool enable); +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBLineEntry.i =================================================================== --- lldb/trunk/scripts/interface/SBLineEntry.i +++ lldb/trunk/scripts/interface/SBLineEntry.i @@ -0,0 +1,106 @@ +//===-- SWIG Interface for SBLineEntry --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Specifies an association with a contiguous range of instructions and +a source file location. SBCompileUnit contains SBLineEntry(s). For example, + + for lineEntry in compileUnit: + print 'line entry: %s:%d' % (str(lineEntry.GetFileSpec()), + lineEntry.GetLine()) + print 'start addr: %s' % str(lineEntry.GetStartAddress()) + print 'end addr: %s' % str(lineEntry.GetEndAddress()) + +produces: + +line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:20 +start addr: a.out[0x100000d98] +end addr: a.out[0x100000da3] +line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:21 +start addr: a.out[0x100000da3] +end addr: a.out[0x100000da9] +line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:22 +start addr: a.out[0x100000da9] +end addr: a.out[0x100000db6] +line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:23 +start addr: a.out[0x100000db6] +end addr: a.out[0x100000dbc] +... + +See also SBCompileUnit." +) SBLineEntry; +class SBLineEntry +{ +public: + + SBLineEntry (); + + SBLineEntry (const lldb::SBLineEntry &rhs); + + ~SBLineEntry (); + + lldb::SBAddress + GetStartAddress () const; + + lldb::SBAddress + GetEndAddress () const; + + bool + IsValid () const; + + lldb::SBFileSpec + GetFileSpec () const; + + uint32_t + GetLine () const; + + uint32_t + GetColumn () const; + + bool + GetDescription (lldb::SBStream &description); + + void + SetFileSpec (lldb::SBFileSpec filespec); + + void + SetLine (uint32_t line); + + void + SetColumn (uint32_t column); + + bool + operator == (const lldb::SBLineEntry &rhs) const; + + bool + operator != (const lldb::SBLineEntry &rhs) const; + + %pythoncode %{ + __swig_getmethods__["file"] = GetFileSpec + if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''') + + __swig_getmethods__["line"] = GetLine + if _newclass: line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''') + + __swig_getmethods__["column"] = GetColumn + if _newclass: column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''') + + __swig_getmethods__["addr"] = GetStartAddress + if _newclass: addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this line entry.''') + + __swig_getmethods__["end_addr"] = GetEndAddress + if _newclass: end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this line entry.''') + + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBListener.i =================================================================== --- lldb/trunk/scripts/interface/SBListener.i +++ lldb/trunk/scripts/interface/SBListener.i @@ -0,0 +1,99 @@ +//===-- SWIG Interface for SBListener ---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"API clients can register its own listener to debugger events. + +See aslo SBEvent for example usage of creating and adding a listener." +) SBListener; +class SBListener +{ +public: + SBListener (); + + SBListener (const char *name); + + SBListener (const SBListener &rhs); + + ~SBListener (); + + void + AddEvent (const lldb::SBEvent &event); + + void + Clear (); + + bool + IsValid () const; + + uint32_t + StartListeningForEventClass (SBDebugger &debugger, + const char *broadcaster_class, + uint32_t event_mask); + + uint32_t + StopListeningForEventClass (SBDebugger &debugger, + const char *broadcaster_class, + uint32_t event_mask); + + uint32_t + StartListeningForEvents (const lldb::SBBroadcaster& broadcaster, + uint32_t event_mask); + + bool + StopListeningForEvents (const lldb::SBBroadcaster& broadcaster, + uint32_t event_mask); + + // Returns true if an event was received, false if we timed out. + bool + WaitForEvent (uint32_t num_seconds, + lldb::SBEvent &event); + + bool + WaitForEventForBroadcaster (uint32_t num_seconds, + const lldb::SBBroadcaster &broadcaster, + lldb::SBEvent &sb_event); + + bool + WaitForEventForBroadcasterWithType (uint32_t num_seconds, + const lldb::SBBroadcaster &broadcaster, + uint32_t event_type_mask, + lldb::SBEvent &sb_event); + + bool + PeekAtNextEvent (lldb::SBEvent &sb_event); + + bool + PeekAtNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster, + lldb::SBEvent &sb_event); + + bool + PeekAtNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster, + uint32_t event_type_mask, + lldb::SBEvent &sb_event); + + bool + GetNextEvent (lldb::SBEvent &sb_event); + + bool + GetNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster, + lldb::SBEvent &sb_event); + + bool + GetNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster, + uint32_t event_type_mask, + lldb::SBEvent &sb_event); + + bool + HandleBroadcastEvent (const lldb::SBEvent &event); +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBModule.i =================================================================== --- lldb/trunk/scripts/interface/SBModule.i +++ lldb/trunk/scripts/interface/SBModule.i @@ -0,0 +1,530 @@ +//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents an executable image and its associated object and symbol files. + +The module is designed to be able to select a single slice of an +executable image as it would appear on disk and during program +execution. + +You can retrieve SBModule from SBSymbolContext, which in turn is available +from SBFrame. + +SBModule supports symbol iteration, for example, + + for symbol in module: + name = symbol.GetName() + saddr = symbol.GetStartAddress() + eaddr = symbol.GetEndAddress() + +and rich comparion methods which allow the API program to use, + + if thisModule == thatModule: + print 'This module is the same as that module' + +to test module equality. A module also contains object file sections, namely +SBSection. SBModule supports section iteration through section_iter(), for +example, + + print 'Number of sections: %d' % module.GetNumSections() + for sec in module.section_iter(): + print sec + +And to iterate the symbols within a SBSection, use symbol_in_section_iter(), + + # Iterates the text section and prints each symbols within each sub-section. + for subsec in text_sec: + print INDENT + repr(subsec) + for sym in exe_module.symbol_in_section_iter(subsec): + print INDENT2 + repr(sym) + print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType()) + +produces this following output: + + [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text + id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870) + symbol type: code + id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0) + symbol type: code + id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c) + symbol type: code + id = {0x00000023}, name = 'start', address = 0x0000000100001780 + symbol type: code + [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs + id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62) + symbol type: trampoline + id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68) + symbol type: trampoline + id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e) + symbol type: trampoline + id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74) + symbol type: trampoline + id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a) + symbol type: trampoline + id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80) + symbol type: trampoline + id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86) + symbol type: trampoline + id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c) + symbol type: trampoline + id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92) + symbol type: trampoline + id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98) + symbol type: trampoline + id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e) + symbol type: trampoline + id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4) + symbol type: trampoline + [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper + [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring + [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info + [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame +" +) SBModule; +class SBModule +{ +public: + + SBModule (); + + SBModule (const lldb::SBModule &rhs); + + SBModule (const lldb::SBModuleSpec &module_spec); + + SBModule (lldb::SBProcess &process, + lldb::addr_t header_addr); + + ~SBModule (); + + bool + IsValid () const; + + void + Clear(); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Get const accessor for the module file specification. + /// + /// This function returns the file for the module on the host system + /// that is running LLDB. This can differ from the path on the + /// platform since we might be doing remote debugging. + /// + /// @return + /// A const reference to the file specification object. + //------------------------------------------------------------------ + ") GetFileSpec; + lldb::SBFileSpec + GetFileSpec () const; + + %feature("docstring", " + //------------------------------------------------------------------ + /// Get accessor for the module platform file specification. + /// + /// Platform file refers to the path of the module as it is known on + /// the remote system on which it is being debugged. For local + /// debugging this is always the same as Module::GetFileSpec(). But + /// remote debugging might mention a file '/usr/lib/liba.dylib' + /// which might be locally downloaded and cached. In this case the + /// platform file could be something like: + /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib' + /// The file could also be cached in a local developer kit directory. + /// + /// @return + /// A const reference to the file specification object. + //------------------------------------------------------------------ + ") GetPlatformFileSpec; + lldb::SBFileSpec + GetPlatformFileSpec () const; + + bool + SetPlatformFileSpec (const lldb::SBFileSpec &platform_file); + + lldb::SBFileSpec + GetRemoteInstallFileSpec (); + + bool + SetRemoteInstallFileSpec (lldb::SBFileSpec &file); + + %feature("docstring", "Returns the UUID of the module as a Python string." + ) GetUUIDString; + const char * + GetUUIDString () const; + + lldb::SBSection + FindSection (const char *sect_name); + + lldb::SBAddress + ResolveFileAddress (lldb::addr_t vm_addr); + + lldb::SBSymbolContext + ResolveSymbolContextForAddress (const lldb::SBAddress& addr, + uint32_t resolve_scope); + + bool + GetDescription (lldb::SBStream &description); + + uint32_t + GetNumCompileUnits(); + + lldb::SBCompileUnit + GetCompileUnitAtIndex (uint32_t); + + size_t + GetNumSymbols (); + + lldb::SBSymbol + GetSymbolAtIndex (size_t idx); + + lldb::SBSymbol + FindSymbol (const char *name, + lldb::SymbolType type = eSymbolTypeAny); + + lldb::SBSymbolContextList + FindSymbols (const char *name, + lldb::SymbolType type = eSymbolTypeAny); + + + size_t + GetNumSections (); + + lldb::SBSection + GetSectionAtIndex (size_t idx); + + + %feature("docstring", " + //------------------------------------------------------------------ + /// Find functions by name. + /// + /// @param[in] name + /// The name of the function we are looking for. + /// + /// @param[in] name_type_mask + /// A logical OR of one or more FunctionNameType enum bits that + /// indicate what kind of names should be used when doing the + /// lookup. Bits include fully qualified names, base names, + /// C++ methods, or ObjC selectors. + /// See FunctionNameType for more details. + /// + /// @return + /// A symbol context list that gets filled in with all of the + /// matches. + //------------------------------------------------------------------ + ") FindFunctions; + lldb::SBSymbolContextList + FindFunctions (const char *name, + uint32_t name_type_mask = lldb::eFunctionNameTypeAny); + + lldb::SBType + FindFirstType (const char* name); + + lldb::SBTypeList + FindTypes (const char* type); + + lldb::SBType + GetTypeByID (lldb::user_id_t uid); + + lldb::SBType + GetBasicType(lldb::BasicType type); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Get all types matching \a type_mask from debug info in this + /// module. + /// + /// @param[in] type_mask + /// A bitfield that consists of one or more bits logically OR'ed + /// together from the lldb::TypeClass enumeration. This allows + /// you to request only structure types, or only class, struct + /// and union types. Passing in lldb::eTypeClassAny will return + /// all types found in the debug information for this module. + /// + /// @return + /// A list of types in this module that match \a type_mask + //------------------------------------------------------------------ + ") GetTypes; + lldb::SBTypeList + GetTypes (uint32_t type_mask = lldb::eTypeClassAny); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Find global and static variables by name. + /// + /// @param[in] target + /// A valid SBTarget instance representing the debuggee. + /// + /// @param[in] name + /// The name of the global or static variable we are looking + /// for. + /// + /// @param[in] max_matches + /// Allow the number of matches to be limited to \a max_matches. + /// + /// @return + /// A list of matched variables in an SBValueList. + //------------------------------------------------------------------ + ") FindGlobalVariables; + lldb::SBValueList + FindGlobalVariables (lldb::SBTarget &target, + const char *name, + uint32_t max_matches); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Find the first global (or static) variable by name. + /// + /// @param[in] target + /// A valid SBTarget instance representing the debuggee. + /// + /// @param[in] name + /// The name of the global or static variable we are looking + /// for. + /// + /// @return + /// An SBValue that gets filled in with the found variable (if any). + //------------------------------------------------------------------ + ") FindFirstGlobalVariable; + lldb::SBValue + FindFirstGlobalVariable (lldb::SBTarget &target, const char *name); + + lldb::ByteOrder + GetByteOrder (); + + uint32_t + GetAddressByteSize(); + + const char * + GetTriple (); + + uint32_t + GetVersion (uint32_t *versions, + uint32_t num_versions); + + lldb::SBFileSpec + GetSymbolFileSpec() const; + + lldb::SBAddress + GetObjectFileHeaderAddress() const; + + bool + operator == (const lldb::SBModule &rhs) const; + + bool + operator != (const lldb::SBModule &rhs) const; + + %pythoncode %{ + class symbols_access(object): + re_compile_type = type(re.compile('.')) + '''A helper object that will lazily hand out lldb.SBSymbol objects for a module when supplied an index, name, or regular expression.''' + def __init__(self, sbmodule): + self.sbmodule = sbmodule + + def __len__(self): + if self.sbmodule: + return int(self.sbmodule.GetNumSymbols()) + return 0 + + def __getitem__(self, key): + count = len(self) + if type(key) is int: + if key < count: + return self.sbmodule.GetSymbolAtIndex(key) + elif type(key) is str: + matches = [] + sc_list = self.sbmodule.FindSymbols(key) + for sc in sc_list: + symbol = sc.symbol + if symbol: + matches.append(symbol) + return matches + elif isinstance(key, self.re_compile_type): + matches = [] + for idx in range(count): + symbol = self.sbmodule.GetSymbolAtIndex(idx) + added = False + name = symbol.name + if name: + re_match = key.search(name) + if re_match: + matches.append(symbol) + added = True + if not added: + mangled = symbol.mangled + if mangled: + re_match = key.search(mangled) + if re_match: + matches.append(symbol) + return matches + else: + print "error: unsupported item type: %s" % type(key) + return None + + def get_symbols_access_object(self): + '''An accessor function that returns a symbols_access() object which allows lazy symbol access from a lldb.SBModule object.''' + return self.symbols_access (self) + + def get_compile_units_access_object (self): + '''An accessor function that returns a compile_units_access() object which allows lazy compile unit access from a lldb.SBModule object.''' + return self.compile_units_access (self) + + def get_symbols_array(self): + '''An accessor function that returns a list() that contains all symbols in a lldb.SBModule object.''' + symbols = [] + for idx in range(self.num_symbols): + symbols.append(self.GetSymbolAtIndex(idx)) + return symbols + + class sections_access(object): + re_compile_type = type(re.compile('.')) + '''A helper object that will lazily hand out lldb.SBSection objects for a module when supplied an index, name, or regular expression.''' + def __init__(self, sbmodule): + self.sbmodule = sbmodule + + def __len__(self): + if self.sbmodule: + return int(self.sbmodule.GetNumSections()) + return 0 + + def __getitem__(self, key): + count = len(self) + if type(key) is int: + if key < count: + return self.sbmodule.GetSectionAtIndex(key) + elif type(key) is str: + for idx in range(count): + section = self.sbmodule.GetSectionAtIndex(idx) + if section.name == key: + return section + elif isinstance(key, self.re_compile_type): + matches = [] + for idx in range(count): + section = self.sbmodule.GetSectionAtIndex(idx) + name = section.name + if name: + re_match = key.search(name) + if re_match: + matches.append(section) + return matches + else: + print "error: unsupported item type: %s" % type(key) + return None + + class compile_units_access(object): + re_compile_type = type(re.compile('.')) + '''A helper object that will lazily hand out lldb.SBCompileUnit objects for a module when supplied an index, full or partial path, or regular expression.''' + def __init__(self, sbmodule): + self.sbmodule = sbmodule + + def __len__(self): + if self.sbmodule: + return int(self.sbmodule.GetNumCompileUnits()) + return 0 + + def __getitem__(self, key): + count = len(self) + if type(key) is int: + if key < count: + return self.sbmodule.GetCompileUnitAtIndex(key) + elif type(key) is str: + is_full_path = key[0] == '/' + for idx in range(count): + comp_unit = self.sbmodule.GetCompileUnitAtIndex(idx) + if is_full_path: + if comp_unit.file.fullpath == key: + return comp_unit + else: + if comp_unit.file.basename == key: + return comp_unit + elif isinstance(key, self.re_compile_type): + matches = [] + for idx in range(count): + comp_unit = self.sbmodule.GetCompileUnitAtIndex(idx) + fullpath = comp_unit.file.fullpath + if fullpath: + re_match = key.search(fullpath) + if re_match: + matches.append(comp_unit) + return matches + else: + print "error: unsupported item type: %s" % type(key) + return None + + def get_sections_access_object(self): + '''An accessor function that returns a sections_access() object which allows lazy section array access.''' + return self.sections_access (self) + + def get_sections_array(self): + '''An accessor function that returns an array object that contains all sections in this module object.''' + if not hasattr(self, 'sections_array'): + self.sections_array = [] + for idx in range(self.num_sections): + self.sections_array.append(self.GetSectionAtIndex(idx)) + return self.sections_array + + def get_compile_units_array(self): + '''An accessor function that returns an array object that contains all compile_units in this module object.''' + if not hasattr(self, 'compile_units_array'): + self.compile_units_array = [] + for idx in range(self.GetNumCompileUnits()): + self.compile_units_array.append(self.GetCompileUnitAtIndex(idx)) + return self.compile_units_array + + __swig_getmethods__["symbols"] = get_symbols_array + if _newclass: symbols = property(get_symbols_array, None, doc='''A read only property that returns a list() of lldb.SBSymbol objects contained in this module.''') + + __swig_getmethods__["symbol"] = get_symbols_access_object + if _newclass: symbol = property(get_symbols_access_object, None, doc='''A read only property that can be used to access symbols by index ("symbol = module.symbol[0]"), name ("symbols = module.symbol['main']"), or using a regular expression ("symbols = module.symbol[re.compile(...)]"). The return value is a single lldb.SBSymbol object for array access, and a list() of lldb.SBSymbol objects for name and regular expression access''') + + __swig_getmethods__["sections"] = get_sections_array + if _newclass: sections = property(get_sections_array, None, doc='''A read only property that returns a list() of lldb.SBSection objects contained in this module.''') + + __swig_getmethods__["compile_units"] = get_compile_units_array + if _newclass: compile_units = property(get_compile_units_array, None, doc='''A read only property that returns a list() of lldb.SBCompileUnit objects contained in this module.''') + + __swig_getmethods__["section"] = get_sections_access_object + if _newclass: section = property(get_sections_access_object, None, doc='''A read only property that can be used to access symbols by index ("section = module.section[0]"), name ("sections = module.section[\'main\']"), or using a regular expression ("sections = module.section[re.compile(...)]"). The return value is a single lldb.SBSection object for array access, and a list() of lldb.SBSection objects for name and regular expression access''') + + __swig_getmethods__["compile_unit"] = get_compile_units_access_object + if _newclass: section = property(get_sections_access_object, None, doc='''A read only property that can be used to access compile units by index ("compile_unit = module.compile_unit[0]"), name ("compile_unit = module.compile_unit[\'main.cpp\']"), or using a regular expression ("compile_unit = module.compile_unit[re.compile(...)]"). The return value is a single lldb.SBCompileUnit object for array access or by full or partial path, and a list() of lldb.SBCompileUnit objects regular expressions.''') + + def get_uuid(self): + return uuid.UUID (self.GetUUIDString()) + + __swig_getmethods__["uuid"] = get_uuid + if _newclass: uuid = property(get_uuid, None, doc='''A read only property that returns a standard python uuid.UUID object that represents the UUID of this module.''') + + __swig_getmethods__["file"] = GetFileSpec + if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented where it is being debugged.''') + + __swig_getmethods__["platform_file"] = GetPlatformFileSpec + if _newclass: platform_file = property(GetPlatformFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented on the current host system.''') + + __swig_getmethods__["byte_order"] = GetByteOrder + if _newclass: byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this module.''') + + __swig_getmethods__["addr_size"] = GetAddressByteSize + if _newclass: addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this module.''') + + __swig_getmethods__["triple"] = GetTriple + if _newclass: triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this module.''') + + __swig_getmethods__["num_symbols"] = GetNumSymbols + if _newclass: num_symbols = property(GetNumSymbols, None, doc='''A read only property that returns number of symbols in the module symbol table as an integer.''') + + __swig_getmethods__["num_sections"] = GetNumSections + if _newclass: num_sections = property(GetNumSections, None, doc='''A read only property that returns number of sections in the module as an integer.''') + + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBModuleSpec.i =================================================================== --- lldb/trunk/scripts/interface/SBModuleSpec.i +++ lldb/trunk/scripts/interface/SBModuleSpec.i @@ -0,0 +1,133 @@ +//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBModuleSpec +{ +public: + + SBModuleSpec (); + + SBModuleSpec (const lldb::SBModuleSpec &rhs); + + ~SBModuleSpec (); + + bool + IsValid () const; + + void + Clear(); + + //------------------------------------------------------------------ + /// Get const accessor for the module file. + /// + /// This function returns the file for the module on the host system + /// that is running LLDB. This can differ from the path on the + /// platform since we might be doing remote debugging. + /// + /// @return + /// A const reference to the file specification object. + //------------------------------------------------------------------ + lldb::SBFileSpec + GetFileSpec (); + + void + SetFileSpec (const lldb::SBFileSpec &fspec); + + //------------------------------------------------------------------ + /// Get accessor for the module platform file. + /// + /// Platform file refers to the path of the module as it is known on + /// the remote system on which it is being debugged. For local + /// debugging this is always the same as Module::GetFileSpec(). But + /// remote debugging might mention a file '/usr/lib/liba.dylib' + /// which might be locally downloaded and cached. In this case the + /// platform file could be something like: + /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib' + /// The file could also be cached in a local developer kit directory. + /// + /// @return + /// A const reference to the file specification object. + //------------------------------------------------------------------ + lldb::SBFileSpec + GetPlatformFileSpec (); + + void + SetPlatformFileSpec (const lldb::SBFileSpec &fspec); + + lldb::SBFileSpec + GetSymbolFileSpec (); + + void + SetSymbolFileSpec (const lldb::SBFileSpec &fspec); + + const char * + GetObjectName (); + + void + SetObjectName (const char *name); + + const char * + GetTriple (); + + void + SetTriple (const char *triple); + + const uint8_t * + GetUUIDBytes (); + + size_t + GetUUIDLength (); + + bool + SetUUIDBytes (const uint8_t *uuid, size_t uuid_len); + + bool + GetDescription (lldb::SBStream &description); + +}; + + +class SBModuleSpecList +{ +public: + SBModuleSpecList(); + + SBModuleSpecList (const SBModuleSpecList &rhs); + + ~SBModuleSpecList(); + + static SBModuleSpecList + GetModuleSpecifications (const char *path); + + void + Append (const lldb::SBModuleSpec &spec); + + void + Append (const lldb::SBModuleSpecList &spec_list); + + lldb::SBModuleSpec + FindFirstMatchingSpec (const lldb::SBModuleSpec &match_spec); + + lldb::SBModuleSpecList + FindMatchingSpecs (const lldb::SBModuleSpec &match_spec); + + size_t + GetSize(); + + lldb::SBModuleSpec + GetSpecAtIndex (size_t i); + + bool + GetDescription (lldb::SBStream &description); + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBPlatform.i =================================================================== --- lldb/trunk/scripts/interface/SBPlatform.i +++ lldb/trunk/scripts/interface/SBPlatform.i @@ -0,0 +1,193 @@ +//===-- SWIG Interface for SBPlatform ---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + +class SBPlatformConnectOptions +{ +public: + SBPlatformConnectOptions (const char *url); + + SBPlatformConnectOptions (const SBPlatformConnectOptions &rhs); + + ~SBPlatformConnectOptions (); + + const char * + GetURL(); + + void + SetURL(const char *url); + + bool + GetRsyncEnabled(); + + void + EnableRsync (const char *options, + const char *remote_path_prefix, + bool omit_remote_hostname); + + void + DisableRsync (); + + const char * + GetLocalCacheDirectory(); + + void + SetLocalCacheDirectory(const char *path); +}; + +class SBPlatformShellCommand +{ +public: + SBPlatformShellCommand (const char *shell_command); + + SBPlatformShellCommand (const SBPlatformShellCommand &rhs); + + ~SBPlatformShellCommand(); + + void + Clear(); + + const char * + GetCommand(); + + void + SetCommand(const char *shell_command); + + const char * + GetWorkingDirectory (); + + void + SetWorkingDirectory (const char *path); + + uint32_t + GetTimeoutSeconds (); + + void + SetTimeoutSeconds (uint32_t sec); + + int + GetSignal (); + + int + GetStatus (); + + const char * + GetOutput (); +}; + +%feature("docstring", +"A class that represents the a platform that can represent the current host or a remote host debug platform. + +The SBPlatform class represents the current host, or a remote host. +It can be connected to a remote platform in order to provide ways +to remotely launch and attach to processes, upload/download files, +create directories, run remote shell commands, find locally cached +versions of files from the remote system, and much more. + +SBPlatform objects can be created and then used to connect to a remote +platform which allows the SBPlatform to be used to get a list of the +current processes on the remote host, attach to one of those processes, +install programs on the remote system, attach and launch processes, +and much more. + +Every SBTarget has a corresponding SBPlatform. The platform can be +specified upon target creation, or the currently selected platform +will attempt to be used when creating the target automatically as long +as the currently selected platform matches the target architecture +and executable type. If the architecture or executable type do not match, +a suitable platform will be found automatically." + +) SBPlatform; +class SBPlatform +{ +public: + + SBPlatform (); + + SBPlatform (const char *); + + ~SBPlatform(); + + bool + IsValid () const; + + void + Clear (); + + const char * + GetWorkingDirectory(); + + bool + SetWorkingDirectory(const char *); + + const char * + GetName (); + + SBError + ConnectRemote (lldb::SBPlatformConnectOptions &connect_options); + + void + DisconnectRemote (); + + bool + IsConnected(); + + const char * + GetTriple(); + + const char * + GetHostname (); + + const char * + GetOSBuild (); + + const char * + GetOSDescription (); + + uint32_t + GetOSMajorVersion (); + + uint32_t + GetOSMinorVersion (); + + uint32_t + GetOSUpdateVersion (); + + lldb::SBError + Get (lldb::SBFileSpec &src, lldb::SBFileSpec &dst); + + lldb::SBError + Put (lldb::SBFileSpec &src, lldb::SBFileSpec &dst); + + lldb::SBError + Install (lldb::SBFileSpec &src, lldb::SBFileSpec &dst); + + lldb::SBError + Run (lldb::SBPlatformShellCommand &shell_command); + + lldb::SBError + Launch (lldb::SBLaunchInfo &launch_info); + + lldb::SBError + Kill (const lldb::pid_t pid); + + lldb::SBError + MakeDirectory (const char *path, uint32_t file_permissions = lldb::eFilePermissionsDirectoryDefault); + + uint32_t + GetFilePermissions (const char *path); + + lldb::SBError + SetFilePermissions (const char *path, uint32_t file_permissions); + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBProcess.i =================================================================== --- lldb/trunk/scripts/interface/SBProcess.i +++ lldb/trunk/scripts/interface/SBProcess.i @@ -0,0 +1,496 @@ +//===-- SWIG Interface for SBProcess ----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents the process associated with the target program. + +SBProcess supports thread iteration. For example (from test/lldbutil.py), + +# ================================================== +# Utility functions related to Threads and Processes +# ================================================== + +def get_stopped_threads(process, reason): + '''Returns the thread(s) with the specified stop reason in a list. + + The list can be empty if no such thread exists. + ''' + threads = [] + for t in process: + if t.GetStopReason() == reason: + threads.append(t) + return threads + +... +" +) SBProcess; +class SBProcess +{ +public: + //------------------------------------------------------------------ + /// Broadcaster event bits definitions. + //------------------------------------------------------------------ + enum + { + eBroadcastBitStateChanged = (1 << 0), + eBroadcastBitInterrupt = (1 << 1), + eBroadcastBitSTDOUT = (1 << 2), + eBroadcastBitSTDERR = (1 << 3), + eBroadcastBitProfileData = (1 << 4) + }; + + SBProcess (); + + SBProcess (const lldb::SBProcess& rhs); + + ~SBProcess(); + + static const char * + GetBroadcasterClassName (); + + const char * + GetPluginName (); + + const char * + GetShortPluginName (); + + void + Clear (); + + bool + IsValid() const; + + lldb::SBTarget + GetTarget() const; + + lldb::ByteOrder + GetByteOrder() const; + + %feature("autodoc", " + Writes data into the current process's stdin. API client specifies a Python + string as the only argument. + ") PutSTDIN; + size_t + PutSTDIN (const char *src, size_t src_len); + + %feature("autodoc", " + Reads data from the current process's stdout stream. API client specifies + the size of the buffer to read data into. It returns the byte buffer in a + Python string. + ") GetSTDOUT; + size_t + GetSTDOUT (char *dst, size_t dst_len) const; + + %feature("autodoc", " + Reads data from the current process's stderr stream. API client specifies + the size of the buffer to read data into. It returns the byte buffer in a + Python string. + ") GetSTDERR; + size_t + GetSTDERR (char *dst, size_t dst_len) const; + + size_t + GetAsyncProfileData(char *dst, size_t dst_len) const; + + void + ReportEventState (const lldb::SBEvent &event, FILE *out) const; + + void + AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Remote connection related functions. These will fail if the + /// process is not in eStateConnected. They are intended for use + /// when connecting to an externally managed debugserver instance. + //------------------------------------------------------------------ + ") RemoteAttachToProcessWithID; + bool + RemoteAttachToProcessWithID (lldb::pid_t pid, + lldb::SBError& error); + + %feature("docstring", + "See SBTarget.Launch for argument description and usage." + ) RemoteLaunch; + bool + RemoteLaunch (char const **argv, + char const **envp, + const char *stdin_path, + const char *stdout_path, + const char *stderr_path, + const char *working_directory, + uint32_t launch_flags, + bool stop_at_entry, + lldb::SBError& error); + + //------------------------------------------------------------------ + // Thread related functions + //------------------------------------------------------------------ + uint32_t + GetNumThreads (); + + %feature("autodoc", " + Returns the INDEX'th thread from the list of current threads. The index + of a thread is only valid for the current stop. For a persistent thread + identifier use either the thread ID or the IndexID. See help on SBThread + for more details. + ") GetThreadAtIndex; + lldb::SBThread + GetThreadAtIndex (size_t index); + + %feature("autodoc", " + Returns the thread with the given thread ID. + ") GetThreadByID; + lldb::SBThread + GetThreadByID (lldb::tid_t sb_thread_id); + + %feature("autodoc", " + Returns the thread with the given thread IndexID. + ") GetThreadByIndexID; + lldb::SBThread + GetThreadByIndexID (uint32_t index_id); + + %feature("autodoc", " + Returns the currently selected thread. + ") GetSelectedThread; + lldb::SBThread + GetSelectedThread () const; + + %feature("autodoc", " + Lazily create a thread on demand through the current OperatingSystem plug-in, if the current OperatingSystem plug-in supports it. + ") CreateOSPluginThread; + lldb::SBThread + CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context); + + bool + SetSelectedThread (const lldb::SBThread &thread); + + bool + SetSelectedThreadByID (lldb::tid_t tid); + + bool + SetSelectedThreadByIndexID (uint32_t index_id); + + //------------------------------------------------------------------ + // Queue related functions + //------------------------------------------------------------------ + uint32_t + GetNumQueues (); + + lldb::SBQueue + GetQueueAtIndex (uint32_t index); + + //------------------------------------------------------------------ + // Stepping related functions + //------------------------------------------------------------------ + + lldb::StateType + GetState (); + + int + GetExitStatus (); + + const char * + GetExitDescription (); + + %feature("autodoc", " + Returns the process ID of the process. + ") GetProcessID; + lldb::pid_t + GetProcessID (); + + %feature("autodoc", " + Returns an integer ID that is guaranteed to be unique across all process instances. This is not the process ID, just a unique integer for comparison and caching purposes. + ") GetUniqueID; + uint32_t + GetUniqueID(); + + uint32_t + GetAddressByteSize() const; + + %feature("docstring", " + Kills the process and shuts down all threads that were spawned to + track and monitor process. + ") Destroy; + lldb::SBError + Destroy (); + + lldb::SBError + Continue (); + + lldb::SBError + Stop (); + + %feature("docstring", "Same as Destroy(self).") Destroy; + lldb::SBError + Kill (); + + lldb::SBError + Detach (); + + %feature("docstring", "Sends the process a unix signal.") Signal; + lldb::SBError + Signal (int signal); + + lldb::SBUnixSignals + GetUnixSignals(); + + %feature("docstring", " + Returns a stop id that will increase every time the process executes. If + include_expression_stops is true, then stops caused by expression evaluation + will cause the returned value to increase, otherwise the counter returned will + only increase when execution is continued explicitly by the user. Note, the value + will always increase, but may increase by more than one per stop. + ") GetStopID; + uint32_t + GetStopID(bool include_expression_stops = false); + + void + SendAsyncInterrupt(); + + %feature("autodoc", " + Reads memory from the current process's address space and removes any + traps that may have been inserted into the memory. It returns the byte + buffer in a Python string. Example: + + # Read 4 bytes from address 'addr' and assume error.Success() is True. + content = process.ReadMemory(addr, 4, error) + new_bytes = bytearray(content) + ") ReadMemory; + size_t + ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); + + %feature("autodoc", " + Writes memory to the current process's address space and maintains any + traps that might be present due to software breakpoints. Example: + + # Create a Python string from the byte array. + new_value = str(bytes) + result = process.WriteMemory(addr, new_value, error) + if not error.Success() or result != len(bytes): + print 'SBProcess.WriteMemory() failed!' + ") WriteMemory; + size_t + WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error); + + %feature("autodoc", " + Reads a NULL terminated C string from the current process's address space. + It returns a python string of the exact length, or truncates the string if + the maximum character limit is reached. Example: + + # Read a C string of at most 256 bytes from address '0x1000' + error = lldb.SBError() + cstring = process.ReadCStringFromMemory(0x1000, 256, error) + if error.Success(): + print 'cstring: ', cstring + else + print 'error: ', error + ") ReadCStringFromMemory; + + size_t + ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); + + %feature("autodoc", " + Reads an unsigned integer from memory given a byte size and an address. + Returns the unsigned integer that was read. Example: + + # Read a 4 byte unsigned integer from address 0x1000 + error = lldb.SBError() + uint = ReadUnsignedFromMemory(0x1000, 4, error) + if error.Success(): + print 'integer: %u' % uint + else + print 'error: ', error + + ") ReadUnsignedFromMemory; + + uint64_t + ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error); + + %feature("autodoc", " + Reads a pointer from memory from an address and returns the value. Example: + + # Read a pointer from address 0x1000 + error = lldb.SBError() + ptr = ReadPointerFromMemory(0x1000, error) + if error.Success(): + print 'pointer: 0x%x' % ptr + else + print 'error: ', error + + ") ReadPointerFromMemory; + + lldb::addr_t + ReadPointerFromMemory (addr_t addr, lldb::SBError &error); + + + // Events + static lldb::StateType + GetStateFromEvent (const lldb::SBEvent &event); + + static bool + GetRestartedFromEvent (const lldb::SBEvent &event); + + static size_t + GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event); + + static const char * + GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx); + + static lldb::SBProcess + GetProcessFromEvent (const lldb::SBEvent &event); + + static bool + EventIsProcessEvent (const lldb::SBEvent &event); + + lldb::SBBroadcaster + GetBroadcaster () const; + + bool + GetDescription (lldb::SBStream &description); + + uint32_t + GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const; + + uint32_t + LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error); + + lldb::SBError + UnloadImage (uint32_t image_token); + + lldb::SBError + SendEventData (const char *event_data); + + %feature("autodoc", " + Return the number of different thread-origin extended backtraces + this process can support as a uint32_t. + When the process is stopped and you have an SBThread, lldb may be + able to show a backtrace of when that thread was originally created, + or the work item was enqueued to it (in the case of a libdispatch + queue). + ") GetNumExtendedBacktraceTypes; + + uint32_t + GetNumExtendedBacktraceTypes (); + + %feature("autodoc", " + Takes an index argument, returns the name of one of the thread-origin + extended backtrace methods as a str. + ") GetExtendedBacktraceTypeAtIndex; + + const char * + GetExtendedBacktraceTypeAtIndex (uint32_t idx); + + lldb::SBThreadCollection + GetHistoryThreads (addr_t addr); + + bool + IsInstrumentationRuntimePresent(lldb::InstrumentationRuntimeType type); + + %pythoncode %{ + def __get_is_alive__(self): + '''Returns "True" if the process is currently alive, "False" otherwise''' + s = self.GetState() + if (s == eStateAttaching or + s == eStateLaunching or + s == eStateStopped or + s == eStateRunning or + s == eStateStepping or + s == eStateCrashed or + s == eStateSuspended): + return True + return False + + def __get_is_running__(self): + '''Returns "True" if the process is currently running, "False" otherwise''' + state = self.GetState() + if state == eStateRunning or state == eStateStepping: + return True + return False + + def __get_is_running__(self): + '''Returns "True" if the process is currently stopped, "False" otherwise''' + state = self.GetState() + if state == eStateStopped or state == eStateCrashed or state == eStateSuspended: + return True + return False + + class threads_access(object): + '''A helper object that will lazily hand out thread for a process when supplied an index.''' + def __init__(self, sbprocess): + self.sbprocess = sbprocess + + def __len__(self): + if self.sbprocess: + return int(self.sbprocess.GetNumThreads()) + return 0 + + def __getitem__(self, key): + if type(key) is int and key < len(self): + return self.sbprocess.GetThreadAtIndex(key) + return None + + def get_threads_access_object(self): + '''An accessor function that returns a modules_access() object which allows lazy thread access from a lldb.SBProcess object.''' + return self.threads_access (self) + + def get_process_thread_list(self): + '''An accessor function that returns a list() that contains all threads in a lldb.SBProcess object.''' + threads = [] + accessor = self.get_threads_access_object() + for idx in range(len(accessor)): + threads.append(accessor[idx]) + return threads + + __swig_getmethods__["threads"] = get_process_thread_list + if _newclass: threads = property(get_process_thread_list, None, doc='''A read only property that returns a list() of lldb.SBThread objects for this process.''') + + __swig_getmethods__["thread"] = get_threads_access_object + if _newclass: thread = property(get_threads_access_object, None, doc='''A read only property that returns an object that can access threads by thread index (thread = lldb.process.thread[12]).''') + + __swig_getmethods__["is_alive"] = __get_is_alive__ + if _newclass: is_alive = property(__get_is_alive__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently alive.''') + + __swig_getmethods__["is_running"] = __get_is_running__ + if _newclass: is_running = property(__get_is_running__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently running.''') + + __swig_getmethods__["is_stopped"] = __get_is_running__ + if _newclass: is_stopped = property(__get_is_running__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently stopped.''') + + __swig_getmethods__["id"] = GetProcessID + if _newclass: id = property(GetProcessID, None, doc='''A read only property that returns the process ID as an integer.''') + + __swig_getmethods__["target"] = GetTarget + if _newclass: target = property(GetTarget, None, doc='''A read only property that an lldb object that represents the target (lldb.SBTarget) that owns this process.''') + + __swig_getmethods__["num_threads"] = GetNumThreads + if _newclass: num_threads = property(GetNumThreads, None, doc='''A read only property that returns the number of threads in this process as an integer.''') + + __swig_getmethods__["selected_thread"] = GetSelectedThread + __swig_setmethods__["selected_thread"] = SetSelectedThread + if _newclass: selected_thread = property(GetSelectedThread, SetSelectedThread, doc='''A read/write property that gets/sets the currently selected thread in this process. The getter returns a lldb.SBThread object and the setter takes an lldb.SBThread object.''') + + __swig_getmethods__["state"] = GetState + if _newclass: state = property(GetState, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eState") that represents the current state of this process (running, stopped, exited, etc.).''') + + __swig_getmethods__["exit_state"] = GetExitStatus + if _newclass: exit_state = property(GetExitStatus, None, doc='''A read only property that returns an exit status as an integer of this process when the process state is lldb.eStateExited.''') + + __swig_getmethods__["exit_description"] = GetExitDescription + if _newclass: exit_description = property(GetExitDescription, None, doc='''A read only property that returns an exit description as a string of this process when the process state is lldb.eStateExited.''') + + __swig_getmethods__["broadcaster"] = GetBroadcaster + if _newclass: broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.''') + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBQueue.i =================================================================== --- lldb/trunk/scripts/interface/SBQueue.i +++ lldb/trunk/scripts/interface/SBQueue.i @@ -0,0 +1,75 @@ +//===-- SWIG Interface for SBQueue.h -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBQueue +{ +public: + SBQueue (); + + SBQueue (const lldb::QueueSP& queue_sp); + + ~SBQueue(); + + bool + IsValid() const; + + void + Clear (); + + lldb::SBProcess + GetProcess (); + + %feature("autodoc", " + Returns an lldb::queue_id_t type unique identifier number for this + queue that will not be used by any other queue during this process' + execution. These ID numbers often start at 1 with the first + system-created queues and increment from there. + ") + GetQueueID; + + lldb::queue_id_t + GetQueueID () const; + + const char * + GetName () const; + + %feature("autodoc", " + Returns an lldb::QueueKind enumerated value (e.g. eQueueKindUnknown, + eQueueKindSerial, eQueueKindConcurrent) describing the type of this + queue. + ") + GetKind(); + + lldb::QueueKind + GetKind(); + + uint32_t + GetIndexID () const; + + uint32_t + GetNumThreads (); + + lldb::SBThread + GetThreadAtIndex (uint32_t); + + uint32_t + GetNumPendingItems (); + + lldb::SBQueueItem + GetPendingItemAtIndex (uint32_t); + + uint32_t + GetNumRunningItems (); + +}; + +} // namespace lldb + Index: lldb/trunk/scripts/interface/SBQueueItem.i =================================================================== --- lldb/trunk/scripts/interface/SBQueueItem.i +++ lldb/trunk/scripts/interface/SBQueueItem.i @@ -0,0 +1,46 @@ +//===-- SWIG Interface for SBQueueItem.h ------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBQueueItem +{ +public: + SBQueueItem (); + + SBQueueItem (const lldb::QueueItemSP& queue_item_sp); + + ~SBQueueItem(); + + bool + IsValid() const; + + void + Clear (); + + lldb::QueueItemKind + GetKind () const; + + void + SetKind (lldb::QueueItemKind kind); + + lldb::SBAddress + GetAddress () const; + + void + SetAddress (lldb::SBAddress addr); + + void + SetQueueItem (const lldb::QueueItemSP& queue_item_sp); + + lldb::SBThread + GetExtendedBacktraceThread (const char *type); +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBSection.i =================================================================== --- lldb/trunk/scripts/interface/SBSection.i +++ lldb/trunk/scripts/interface/SBSection.i @@ -0,0 +1,154 @@ +//===-- SWIG Interface for SBSection ----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents an executable image section. + +SBSection supports iteration through its subsection, represented as SBSection +as well. For example, + + for sec in exe_module: + if sec.GetName() == '__TEXT': + print sec + break + print INDENT + 'Number of subsections: %d' % sec.GetNumSubSections() + for subsec in sec: + print INDENT + repr(subsec) + +produces: + +[0x0000000100000000-0x0000000100002000) a.out.__TEXT + Number of subsections: 6 + [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text + [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs + [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper + [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring + [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info + [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame + +See also SBModule." +) SBSection; + +class SBSection +{ +public: + + SBSection (); + + SBSection (const lldb::SBSection &rhs); + + ~SBSection (); + + bool + IsValid () const; + + const char * + GetName (); + + lldb::SBSection + GetParent(); + + lldb::SBSection + FindSubSection (const char *sect_name); + + size_t + GetNumSubSections (); + + lldb::SBSection + GetSubSectionAtIndex (size_t idx); + + lldb::addr_t + GetFileAddress (); + + lldb::addr_t + GetLoadAddress (lldb::SBTarget &target); + + lldb::addr_t + GetByteSize (); + + uint64_t + GetFileOffset (); + + uint64_t + GetFileByteSize (); + + lldb::SBData + GetSectionData (); + + lldb::SBData + GetSectionData (uint64_t offset, + uint64_t size); + + SectionType + GetSectionType (); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Return the size of a target's byte represented by this section + /// in numbers of host bytes. Note that certain architectures have + /// varying minimum addressable unit (i.e. byte) size for their + /// CODE or DATA buses. + /// + /// @return + /// The number of host (8-bit) bytes needed to hold a target byte + //------------------------------------------------------------------ + ") GetTargetByteSize; + uint32_t + GetTargetByteSize (); + + bool + GetDescription (lldb::SBStream &description); + + bool + operator == (const lldb::SBSection &rhs); + + bool + operator != (const lldb::SBSection &rhs); + + %pythoncode %{ + def get_addr(self): + return SBAddress(self, 0) + + __swig_getmethods__["name"] = GetName + if _newclass: name = property(GetName, None, doc='''A read only property that returns the name of this section as a string.''') + + __swig_getmethods__["addr"] = get_addr + if _newclass: addr = property(get_addr, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this section.''') + + __swig_getmethods__["file_addr"] = GetFileAddress + if _newclass: file_addr = property(GetFileAddress, None, doc='''A read only property that returns an integer that represents the starting "file" address for this section, or the address of the section in the object file in which it is defined.''') + + __swig_getmethods__["size"] = GetByteSize + if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this section as an integer.''') + + __swig_getmethods__["file_offset"] = GetFileOffset + if _newclass: file_offset = property(GetFileOffset, None, doc='''A read only property that returns the file offset in bytes of this section as an integer.''') + + __swig_getmethods__["file_size"] = GetFileByteSize + if _newclass: file_size = property(GetFileByteSize, None, doc='''A read only property that returns the file size in bytes of this section as an integer.''') + + __swig_getmethods__["data"] = GetSectionData + if _newclass: data = property(GetSectionData, None, doc='''A read only property that returns an lldb object that represents the bytes for this section (lldb.SBData) for this section.''') + + __swig_getmethods__["type"] = GetSectionType + if _newclass: type = property(GetSectionType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSectionType") that represents the type of this section (code, data, etc.).''') + + __swig_getmethods__["target_byte_size"] = GetTargetByteSize + if _newclass: target_byte_size = property(GetTargetByteSize, None, doc='''A read only property that returns the size of a target byte represented by this section as a number of host bytes.''') + + %} + +private: + + std::unique_ptr m_opaque_ap; +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBSourceManager.i =================================================================== --- lldb/trunk/scripts/interface/SBSourceManager.i +++ lldb/trunk/scripts/interface/SBSourceManager.i @@ -0,0 +1,54 @@ +//===-- SWIG Interface for SBSourceManager ----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents a central authority for displaying source code. + +For example (from test/source-manager/TestSourceManager.py), + + # Create the filespec for 'main.c'. + filespec = lldb.SBFileSpec('main.c', False) + source_mgr = self.dbg.GetSourceManager() + # Use a string stream as the destination. + stream = lldb.SBStream() + source_mgr.DisplaySourceLinesWithLineNumbers(filespec, + self.line, + 2, # context before + 2, # context after + '=>', # prefix for current line + stream) + + # 2 + # 3 int main(int argc, char const *argv[]) { + # => 4 printf('Hello world.\\n'); // Set break point at this line. + # 5 return 0; + # 6 } + self.expect(stream.GetData(), 'Source code displayed correctly', + exe=False, + patterns = ['=> %d.*Hello world' % self.line]) +") SBSourceManager; +class SBSourceManager +{ +public: + SBSourceManager (const lldb::SBSourceManager &rhs); + + ~SBSourceManager(); + + size_t + DisplaySourceLinesWithLineNumbers (const lldb::SBFileSpec &file, + uint32_t line, + uint32_t context_before, + uint32_t context_after, + const char* current_line_cstr, + lldb::SBStream &s); +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBStream.i =================================================================== --- lldb/trunk/scripts/interface/SBStream.i +++ lldb/trunk/scripts/interface/SBStream.i @@ -0,0 +1,100 @@ +//===-- SWIG Interface for SBStream -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +namespace lldb { + +%feature("docstring", +"Represents a destination for streaming data output to. By default, a string +stream is created. + +For example (from test/source-manager/TestSourceManager.py), + + # Create the filespec for 'main.c'. + filespec = lldb.SBFileSpec('main.c', False) + source_mgr = self.dbg.GetSourceManager() + # Use a string stream as the destination. + stream = lldb.SBStream() + source_mgr.DisplaySourceLinesWithLineNumbers(filespec, + self.line, + 2, # context before + 2, # context after + '=>', # prefix for current line + stream) + + # 2 + # 3 int main(int argc, char const *argv[]) { + # => 4 printf('Hello world.\\n'); // Set break point at this line. + # 5 return 0; + # 6 } + self.expect(stream.GetData(), 'Source code displayed correctly', + exe=False, + patterns = ['=> %d.*Hello world' % self.line]) +") SBStream; +class SBStream +{ +public: + + SBStream (); + + ~SBStream (); + + bool + IsValid() const; + + %feature("docstring", " + //-------------------------------------------------------------------------- + /// If this stream is not redirected to a file, it will maintain a local + /// cache for the stream data which can be accessed using this accessor. + //-------------------------------------------------------------------------- + ") GetData; + const char * + GetData (); + + %feature("docstring", " + //-------------------------------------------------------------------------- + /// If this stream is not redirected to a file, it will maintain a local + /// cache for the stream output whose length can be accessed using this + /// accessor. + //-------------------------------------------------------------------------- + ") GetSize; + size_t + GetSize(); + + // wrapping the variadic Printf() with a plain Print() + // because it is hard to support varargs in SWIG bridgings + %extend { + void Print (const char* str) + { + self->Printf("%s", str); + } + } + + void + RedirectToFile (const char *path, bool append); + + void + RedirectToFileHandle (FILE *fh, bool transfer_fh_ownership); + + void + RedirectToFileDescriptor (int fd, bool transfer_fh_ownership); + + %feature("docstring", " + //-------------------------------------------------------------------------- + /// If the stream is redirected to a file, forget about the file and if + /// ownership of the file was transferred to this object, close the file. + /// If the stream is backed by a local cache, clear this cache. + //-------------------------------------------------------------------------- + ") Clear; + void + Clear (); +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBStringList.i =================================================================== --- lldb/trunk/scripts/interface/SBStringList.i +++ lldb/trunk/scripts/interface/SBStringList.i @@ -0,0 +1,44 @@ +//===-- SWIG Interface for SBStringList -------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBStringList +{ +public: + + SBStringList (); + + SBStringList (const lldb::SBStringList &rhs); + + ~SBStringList (); + + bool + IsValid() const; + + void + AppendString (const char *str); + + void + AppendList (const char **strv, int strc); + + void + AppendList (const lldb::SBStringList &strings); + + uint32_t + GetSize () const; + + const char * + GetStringAtIndex (size_t idx); + + void + Clear (); +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBSymbol.i =================================================================== --- lldb/trunk/scripts/interface/SBSymbol.i +++ lldb/trunk/scripts/interface/SBSymbol.i @@ -0,0 +1,107 @@ +//===-- SWIG Interface for SBSymbol -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents the symbol possibly associated with a stack frame. +SBModule contains SBSymbol(s). SBSymbol can also be retrived from SBFrame. + +See also SBModule and SBFrame." +) SBSymbol; +class SBSymbol +{ +public: + + SBSymbol (); + + ~SBSymbol (); + + SBSymbol (const lldb::SBSymbol &rhs); + + bool + IsValid () const; + + + const char * + GetName() const; + + const char * + GetMangledName () const; + + lldb::SBInstructionList + GetInstructions (lldb::SBTarget target); + + lldb::SBInstructionList + GetInstructions (lldb::SBTarget target, const char *flavor_string); + + SBAddress + GetStartAddress (); + + SBAddress + GetEndAddress (); + + uint32_t + GetPrologueByteSize (); + + SymbolType + GetType (); + + bool + GetDescription (lldb::SBStream &description); + + bool + IsExternal(); + + bool + IsSynthetic(); + + bool + operator == (const lldb::SBSymbol &rhs) const; + + bool + operator != (const lldb::SBSymbol &rhs) const; + + %pythoncode %{ + def get_instructions_from_current_target (self): + return self.GetInstructions (target) + + __swig_getmethods__["name"] = GetName + if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this symbol as a string.''') + + __swig_getmethods__["mangled"] = GetMangledName + if _newclass: mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this symbol as a string.''') + + __swig_getmethods__["type"] = GetType + if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSymbolType") that represents the type of this symbol.''') + + __swig_getmethods__["addr"] = GetStartAddress + if _newclass: addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this symbol.''') + + __swig_getmethods__["end_addr"] = GetEndAddress + if _newclass: end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this symbol.''') + + __swig_getmethods__["prologue_size"] = GetPrologueByteSize + if _newclass: prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''') + + __swig_getmethods__["instructions"] = get_instructions_from_current_target + if _newclass: instructions = property(get_instructions_from_current_target, None, doc='''A read only property that returns an lldb object that represents the instructions (lldb.SBInstructionList) for this symbol.''') + + __swig_getmethods__["external"] = IsExternal + if _newclass: external = property(IsExternal, None, doc='''A read only property that returns a boolean value that indicates if this symbol is externally visiable (exported) from the module that contains it.''') + + __swig_getmethods__["synthetic"] = IsSynthetic + if _newclass: synthetic = property(IsSynthetic, None, doc='''A read only property that returns a boolean value that indicates if this symbol was synthetically created from information in module that contains it.''') + + + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBSymbolContext.i =================================================================== --- lldb/trunk/scripts/interface/SBSymbolContext.i +++ lldb/trunk/scripts/interface/SBSymbolContext.i @@ -0,0 +1,112 @@ +//===-- SWIG Interface for SBSymbolContext ----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"A context object that provides access to core debugger entities. + +Manay debugger functions require a context when doing lookups. This class +provides a common structure that can be used as the result of a query that +can contain a single result. + +For example, + + exe = os.path.join(os.getcwd(), 'a.out') + + # Create a target for the debugger. + target = self.dbg.CreateTarget(exe) + + # Now create a breakpoint on main.c by name 'c'. + breakpoint = target.BreakpointCreateByName('c', 'a.out') + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + + # The inferior should stop on 'c'. + from lldbutil import get_stopped_thread + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) + frame0 = thread.GetFrameAtIndex(0) + + # Now get the SBSymbolContext from this frame. We want everything. :-) + context = frame0.GetSymbolContext(lldb.eSymbolContextEverything) + + # Get the module. + module = context.GetModule() + ... + + # And the compile unit associated with the frame. + compileUnit = context.GetCompileUnit() + ... +" +) SBSymbolContext; +class SBSymbolContext +{ +public: + SBSymbolContext (); + + SBSymbolContext (const lldb::SBSymbolContext& rhs); + + ~SBSymbolContext (); + + bool + IsValid () const; + + lldb::SBModule GetModule (); + lldb::SBCompileUnit GetCompileUnit (); + lldb::SBFunction GetFunction (); + lldb::SBBlock GetBlock (); + lldb::SBLineEntry GetLineEntry (); + lldb::SBSymbol GetSymbol (); + + void SetModule (lldb::SBModule module); + void SetCompileUnit (lldb::SBCompileUnit compile_unit); + void SetFunction (lldb::SBFunction function); + void SetBlock (lldb::SBBlock block); + void SetLineEntry (lldb::SBLineEntry line_entry); + void SetSymbol (lldb::SBSymbol symbol); + + lldb::SBSymbolContext + GetParentOfInlinedScope (const lldb::SBAddress &curr_frame_pc, + lldb::SBAddress &parent_frame_addr) const; + + + bool + GetDescription (lldb::SBStream &description); + + + %pythoncode %{ + __swig_getmethods__["module"] = GetModule + __swig_setmethods__["module"] = SetModule + if _newclass: module = property(GetModule, SetModule, doc='''A read/write property that allows the getting/setting of the module (lldb.SBModule) in this symbol context.''') + + __swig_getmethods__["compile_unit"] = GetCompileUnit + __swig_setmethods__["compile_unit"] = SetCompileUnit + if _newclass: compile_unit = property(GetCompileUnit, SetCompileUnit, doc='''A read/write property that allows the getting/setting of the compile unit (lldb.SBCompileUnit) in this symbol context.''') + + __swig_getmethods__["function"] = GetFunction + __swig_setmethods__["function"] = SetFunction + if _newclass: function = property(GetFunction, SetFunction, doc='''A read/write property that allows the getting/setting of the function (lldb.SBFunction) in this symbol context.''') + + __swig_getmethods__["block"] = GetBlock + __swig_setmethods__["block"] = SetBlock + if _newclass: block = property(GetBlock, SetBlock, doc='''A read/write property that allows the getting/setting of the block (lldb.SBBlock) in this symbol context.''') + + __swig_getmethods__["symbol"] = GetSymbol + __swig_setmethods__["symbol"] = SetSymbol + if _newclass: symbol = property(GetSymbol, SetSymbol, doc='''A read/write property that allows the getting/setting of the symbol (lldb.SBSymbol) in this symbol context.''') + + __swig_getmethods__["line_entry"] = GetLineEntry + __swig_setmethods__["line_entry"] = SetLineEntry + if _newclass: line_entry = property(GetLineEntry, SetLineEntry, doc='''A read/write property that allows the getting/setting of the line entry (lldb.SBLineEntry) in this symbol context.''') + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBSymbolContextList.i =================================================================== --- lldb/trunk/scripts/interface/SBSymbolContextList.i +++ lldb/trunk/scripts/interface/SBSymbolContextList.i @@ -0,0 +1,140 @@ +//===-- SWIG Interface for SBSymbolContextList ------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents a list of symbol context object. See also SBSymbolContext. + +For example (from test/python_api/target/TestTargetAPI.py), + + def find_functions(self, exe_name): + '''Exercise SBTaget.FindFunctions() API.''' + exe = os.path.join(os.getcwd(), exe_name) + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + list = lldb.SBSymbolContextList() + num = target.FindFunctions('c', lldb.eFunctionNameTypeAuto, False, list) + self.assertTrue(num == 1 and list.GetSize() == 1) + + for sc in list: + self.assertTrue(sc.GetModule().GetFileSpec().GetFilename() == exe_name) + self.assertTrue(sc.GetSymbol().GetName() == 'c') +") SBSymbolContextList; +class SBSymbolContextList +{ +public: + SBSymbolContextList (); + + SBSymbolContextList (const lldb::SBSymbolContextList& rhs); + + ~SBSymbolContextList (); + + bool + IsValid () const; + + uint32_t + GetSize() const; + + SBSymbolContext + GetContextAtIndex (uint32_t idx); + + void + Append (lldb::SBSymbolContext &sc); + + void + Append (lldb::SBSymbolContextList &sc_list); + + bool + GetDescription (lldb::SBStream &description); + + void + Clear(); + + %pythoncode %{ + def __len__(self): + return int(self.GetSize()) + + def __getitem__(self, key): + count = len(self) + if type(key) is int: + if key < count: + return self.GetContextAtIndex(key) + else: + raise IndexError + raise TypeError + + def get_module_array(self): + a = [] + for i in range(len(self)): + obj = self.GetContextAtIndex(i).module + if obj: + a.append(obj) + return a + + def get_compile_unit_array(self): + a = [] + for i in range(len(self)): + obj = self.GetContextAtIndex(i).compile_unit + if obj: + a.append(obj) + return a + def get_function_array(self): + a = [] + for i in range(len(self)): + obj = self.GetContextAtIndex(i).function + if obj: + a.append(obj) + return a + def get_block_array(self): + a = [] + for i in range(len(self)): + obj = self.GetContextAtIndex(i).block + if obj: + a.append(obj) + return a + def get_symbol_array(self): + a = [] + for i in range(len(self)): + obj = self.GetContextAtIndex(i).symbol + if obj: + a.append(obj) + return a + def get_line_entry_array(self): + a = [] + for i in range(len(self)): + obj = self.GetContextAtIndex(i).line_entry + if obj: + a.append(obj) + return a + __swig_getmethods__["modules"] = get_module_array + if _newclass: modules = property(get_module_array, None, doc='''Returns a list() of lldb.SBModule objects, one for each module in each SBSymbolContext object in this list.''') + + __swig_getmethods__["compile_units"] = get_compile_unit_array + if _newclass: compile_units = property(get_compile_unit_array, None, doc='''Returns a list() of lldb.SBCompileUnit objects, one for each compile unit in each SBSymbolContext object in this list.''') + + __swig_getmethods__["functions"] = get_function_array + if _newclass: functions = property(get_function_array, None, doc='''Returns a list() of lldb.SBFunction objects, one for each function in each SBSymbolContext object in this list.''') + + __swig_getmethods__["blocks"] = get_block_array + if _newclass: blocks = property(get_block_array, None, doc='''Returns a list() of lldb.SBBlock objects, one for each block in each SBSymbolContext object in this list.''') + + __swig_getmethods__["line_entries"] = get_line_entry_array + if _newclass: line_entries = property(get_line_entry_array, None, doc='''Returns a list() of lldb.SBLineEntry objects, one for each line entry in each SBSymbolContext object in this list.''') + + __swig_getmethods__["symbols"] = get_symbol_array + if _newclass: symbols = property(get_symbol_array, None, doc='''Returns a list() of lldb.SBSymbol objects, one for each symbol in each SBSymbolContext object in this list.''') + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBTarget.i =================================================================== --- lldb/trunk/scripts/interface/SBTarget.i +++ lldb/trunk/scripts/interface/SBTarget.i @@ -0,0 +1,853 @@ +//===-- SWIG Interface for SBTarget -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + +%feature("docstring", +"Represents the target program running under the debugger. + +SBTarget supports module, breakpoint, and watchpoint iterations. For example, + + for m in target.module_iter(): + print m + +produces: + +(x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out +(x86_64) /usr/lib/dyld +(x86_64) /usr/lib/libstdc++.6.dylib +(x86_64) /usr/lib/libSystem.B.dylib +(x86_64) /usr/lib/system/libmathCommon.A.dylib +(x86_64) /usr/lib/libSystem.B.dylib(__commpage) + +and, + + for b in target.breakpoint_iter(): + print b + +produces: + +SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1 +SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1 + +and, + + for wp_loc in target.watchpoint_iter(): + print wp_loc + +produces: + +Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw + declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12' + hw_index = 0 hit_count = 2 ignore_count = 0" +) SBTarget; +class SBTarget +{ +public: + //------------------------------------------------------------------ + // Broadcaster bits. + //------------------------------------------------------------------ + enum + { + eBroadcastBitBreakpointChanged = (1 << 0), + eBroadcastBitModulesLoaded = (1 << 1), + eBroadcastBitModulesUnloaded = (1 << 2), + eBroadcastBitWatchpointChanged = (1 << 3), + eBroadcastBitSymbolsLoaded = (1 << 4) + }; + + //------------------------------------------------------------------ + // Constructors + //------------------------------------------------------------------ + SBTarget (); + + SBTarget (const lldb::SBTarget& rhs); + + //------------------------------------------------------------------ + // Destructor + //------------------------------------------------------------------ + ~SBTarget(); + + static const char * + GetBroadcasterClassName (); + + bool + IsValid() const; + + static bool + EventIsTargetEvent (const lldb::SBEvent &event); + + static lldb::SBTarget + GetTargetFromEvent (const lldb::SBEvent &event); + + static uint32_t + GetNumModulesFromEvent (const lldb::SBEvent &event); + + static lldb::SBModule + GetModuleAtIndexFromEvent (const uint32_t idx, const lldb::SBEvent &event); + + lldb::SBProcess + GetProcess (); + + + %feature("docstring", " + //------------------------------------------------------------------ + /// Return the platform object associated with the target. + /// + /// After return, the platform object should be checked for + /// validity. + /// + /// @return + /// A platform object. + //------------------------------------------------------------------ + ") GetPlatform; + lldb::SBPlatform + GetPlatform (); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Install any binaries that need to be installed. + /// + /// This function does nothing when debugging on the host system. + /// When connected to remote platforms, the target's main executable + /// and any modules that have their install path set will be + /// installed on the remote platform. If the main executable doesn't + /// have an install location set, it will be installed in the remote + /// platform's working directory. + /// + /// @return + /// An error describing anything that went wrong during + /// installation. + //------------------------------------------------------------------ + ") Install; + lldb::SBError + Install(); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Launch a new process. + /// + /// Launch a new process by spawning a new process using the + /// target object's executable module's file as the file to launch. + /// Arguments are given in \a argv, and the environment variables + /// are in \a envp. Standard input and output files can be + /// optionally re-directed to \a stdin_path, \a stdout_path, and + /// \a stderr_path. + /// + /// @param[in] listener + /// An optional listener that will receive all process events. + /// If \a listener is valid then \a listener will listen to all + /// process events. If not valid, then this target's debugger + /// (SBTarget::GetDebugger()) will listen to all process events. + /// + /// @param[in] argv + /// The argument array. + /// + /// @param[in] envp + /// The environment array. + /// + /// @param[in] launch_flags + /// Flags to modify the launch (@see lldb::LaunchFlags) + /// + /// @param[in] stdin_path + /// The path to use when re-directing the STDIN of the new + /// process. If all stdXX_path arguments are NULL, a pseudo + /// terminal will be used. + /// + /// @param[in] stdout_path + /// The path to use when re-directing the STDOUT of the new + /// process. If all stdXX_path arguments are NULL, a pseudo + /// terminal will be used. + /// + /// @param[in] stderr_path + /// The path to use when re-directing the STDERR of the new + /// process. If all stdXX_path arguments are NULL, a pseudo + /// terminal will be used. + /// + /// @param[in] working_directory + /// The working directory to have the child process run in + /// + /// @param[in] launch_flags + /// Some launch options specified by logical OR'ing + /// lldb::LaunchFlags enumeration values together. + /// + /// @param[in] stop_at_endtry + /// If false do not stop the inferior at the entry point. + /// + /// @param[out] + /// An error object. Contains the reason if there is some failure. + /// + /// @return + /// A process object for the newly created process. + //------------------------------------------------------------------ + + For example, + + process = target.Launch(self.dbg.GetListener(), None, None, + None, '/tmp/stdout.txt', None, + None, 0, False, error) + + launches a new process by passing nothing for both the args and the envs + and redirect the standard output of the inferior to the /tmp/stdout.txt + file. It does not specify a working directory so that the debug server + will use its idea of what the current working directory is for the + inferior. Also, we ask the debugger not to stop the inferior at the + entry point. If no breakpoint is specified for the inferior, it should + run to completion if no user interaction is required. + ") Launch; + lldb::SBProcess + Launch (SBListener &listener, + char const **argv, + char const **envp, + const char *stdin_path, + const char *stdout_path, + const char *stderr_path, + const char *working_directory, + uint32_t launch_flags, // See LaunchFlags + bool stop_at_entry, + lldb::SBError& error); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Launch a new process with sensible defaults. + /// + /// @param[in] argv + /// The argument array. + /// + /// @param[in] envp + /// The environment array. + /// + /// @param[in] working_directory + /// The working directory to have the child process run in + /// + /// Default: listener + /// Set to the target's debugger (SBTarget::GetDebugger()) + /// + /// Default: launch_flags + /// Empty launch flags + /// + /// Default: stdin_path + /// Default: stdout_path + /// Default: stderr_path + /// A pseudo terminal will be used. + /// + /// @return + /// A process object for the newly created process. + //------------------------------------------------------------------ + + For example, + + process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd()) + + launches a new process by passing 'X', 'Y', 'Z' as the args to the + executable. + ") LaunchSimple; + lldb::SBProcess + LaunchSimple (const char **argv, + const char **envp, + const char *working_directory); + + lldb::SBProcess + Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Load a core file + /// + /// @param[in] core_file + /// File path of the core dump. + /// + /// @return + /// A process object for the newly created core file. + //------------------------------------------------------------------ + + For example, + + process = target.LoadCore('./a.out.core') + + loads a new core file and returns the process object. + ") LoadCore; + lldb::SBProcess + LoadCore(const char *core_file); + + lldb::SBProcess + Attach (lldb::SBAttachInfo &attach_info, lldb::SBError& error); + + + %feature("docstring", " + //------------------------------------------------------------------ + /// Attach to process with pid. + /// + /// @param[in] listener + /// An optional listener that will receive all process events. + /// If \a listener is valid then \a listener will listen to all + /// process events. If not valid, then this target's debugger + /// (SBTarget::GetDebugger()) will listen to all process events. + /// + /// @param[in] pid + /// The process ID to attach to. + /// + /// @param[out] + /// An error explaining what went wrong if attach fails. + /// + /// @return + /// A process object for the attached process. + //------------------------------------------------------------------ + ") AttachToProcessWithID; + lldb::SBProcess + AttachToProcessWithID (SBListener &listener, + lldb::pid_t pid, + lldb::SBError& error); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Attach to process with name. + /// + /// @param[in] listener + /// An optional listener that will receive all process events. + /// If \a listener is valid then \a listener will listen to all + /// process events. If not valid, then this target's debugger + /// (SBTarget::GetDebugger()) will listen to all process events. + /// + /// @param[in] name + /// Basename of process to attach to. + /// + /// @param[in] wait_for + /// If true wait for a new instance of 'name' to be launched. + /// + /// @param[out] + /// An error explaining what went wrong if attach fails. + /// + /// @return + /// A process object for the attached process. + //------------------------------------------------------------------ + ") AttachToProcessWithName; + lldb::SBProcess + AttachToProcessWithName (SBListener &listener, + const char *name, + bool wait_for, + lldb::SBError& error); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Connect to a remote debug server with url. + /// + /// @param[in] listener + /// An optional listener that will receive all process events. + /// If \a listener is valid then \a listener will listen to all + /// process events. If not valid, then this target's debugger + /// (SBTarget::GetDebugger()) will listen to all process events. + /// + /// @param[in] url + /// The url to connect to, e.g., 'connect://localhost:12345'. + /// + /// @param[in] plugin_name + /// The plugin name to be used; can be NULL. + /// + /// @param[out] + /// An error explaining what went wrong if the connect fails. + /// + /// @return + /// A process object for the connected process. + //------------------------------------------------------------------ + ") ConnectRemote; + lldb::SBProcess + ConnectRemote (SBListener &listener, + const char *url, + const char *plugin_name, + SBError& error); + + lldb::SBFileSpec + GetExecutable (); + + bool + AddModule (lldb::SBModule &module); + + lldb::SBModule + AddModule (const char *path, + const char *triple, + const char *uuid); + + lldb::SBModule + AddModule (const char *path, + const char *triple, + const char *uuid_cstr, + const char *symfile); + + lldb::SBModule + AddModule (const SBModuleSpec &module_spec); + + uint32_t + GetNumModules () const; + + lldb::SBModule + GetModuleAtIndex (uint32_t idx); + + bool + RemoveModule (lldb::SBModule module); + + lldb::SBDebugger + GetDebugger() const; + + lldb::SBModule + FindModule (const lldb::SBFileSpec &file_spec); + + lldb::ByteOrder + GetByteOrder (); + + uint32_t + GetAddressByteSize(); + + const char * + GetTriple (); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Architecture data byte width accessor + /// + /// @return + /// The size in 8-bit (host) bytes of a minimum addressable + /// unit from the Architecture's data bus + //------------------------------------------------------------------ + ") GetDataByteSize; + uint32_t + GetDataByteSize (); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Architecture code byte width accessor + /// + /// @return + /// The size in 8-bit (host) bytes of a minimum addressable + /// unit from the Architecture's code bus + //------------------------------------------------------------------ + ") GetCodeByteSize; + uint32_t + GetCodeByteSize (); + + lldb::SBError + SetSectionLoadAddress (lldb::SBSection section, + lldb::addr_t section_base_addr); + + lldb::SBError + ClearSectionLoadAddress (lldb::SBSection section); + + lldb::SBError + SetModuleLoadAddress (lldb::SBModule module, + int64_t sections_offset); + + lldb::SBError + ClearModuleLoadAddress (lldb::SBModule module); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Find functions by name. + /// + /// @param[in] name + /// The name of the function we are looking for. + /// + /// @param[in] name_type_mask + /// A logical OR of one or more FunctionNameType enum bits that + /// indicate what kind of names should be used when doing the + /// lookup. Bits include fully qualified names, base names, + /// C++ methods, or ObjC selectors. + /// See FunctionNameType for more details. + /// + /// @return + /// A lldb::SBSymbolContextList that gets filled in with all of + /// the symbol contexts for all the matches. + //------------------------------------------------------------------ + ") FindFunctions; + lldb::SBSymbolContextList + FindFunctions (const char *name, + uint32_t name_type_mask = lldb::eFunctionNameTypeAny); + + lldb::SBType + FindFirstType (const char* type); + + lldb::SBTypeList + FindTypes (const char* type); + + lldb::SBType + GetBasicType(lldb::BasicType type); + + lldb::SBSourceManager + GetSourceManager (); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Find global and static variables by name. + /// + /// @param[in] name + /// The name of the global or static variable we are looking + /// for. + /// + /// @param[in] max_matches + /// Allow the number of matches to be limited to \a max_matches. + /// + /// @return + /// A list of matched variables in an SBValueList. + //------------------------------------------------------------------ + ") FindGlobalVariables; + lldb::SBValueList + FindGlobalVariables (const char *name, + uint32_t max_matches); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Find the first global (or static) variable by name. + /// + /// @param[in] name + /// The name of the global or static variable we are looking + /// for. + /// + /// @return + /// An SBValue that gets filled in with the found variable (if any). + //------------------------------------------------------------------ + ") FindFirstGlobalVariable; + lldb::SBValue + FindFirstGlobalVariable (const char* name); + + + lldb::SBValueList + FindGlobalVariables(const char *name, + uint32_t max_matches, + MatchType matchtype); + + lldb::SBSymbolContextList + FindGlobalFunctions(const char *name, + uint32_t max_matches, + MatchType matchtype); + + void + Clear (); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Resolve a current file address into a section offset address. + /// + /// @param[in] file_addr + /// + /// @return + /// An SBAddress which will be valid if... + //------------------------------------------------------------------ + ") ResolveFileAddress; + lldb::SBAddress + ResolveFileAddress (lldb::addr_t file_addr); + + lldb::SBAddress + ResolveLoadAddress (lldb::addr_t vm_addr); + + lldb::SBAddress + ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr); + + SBSymbolContext + ResolveSymbolContextForAddress (const SBAddress& addr, + uint32_t resolve_scope); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Read target memory. If a target process is running then memory + /// is read from here. Otherwise the memory is read from the object + /// files. For a target whose bytes are sized as a multiple of host + /// bytes, the data read back will preserve the target's byte order. + /// + /// @param[in] addr + /// A target address to read from. + /// + /// @param[out] buf + /// The buffer to read memory into. + /// + /// @param[in] size + /// The maximum number of host bytes to read in the buffer passed + /// into this call + /// + /// @param[out] error + /// Error information is written here if the memory read fails. + /// + /// @return + /// The amount of data read in host bytes. + //------------------------------------------------------------------ + ") ReadMemory; + size_t + ReadMemory (const SBAddress addr, void *buf, size_t size, lldb::SBError &error); + + lldb::SBBreakpoint + BreakpointCreateByLocation (const char *file, uint32_t line); + + lldb::SBBreakpoint + BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); + + lldb::SBBreakpoint + BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); + + lldb::SBBreakpoint + BreakpointCreateByName (const char *symbol_name, + uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint + BreakpointCreateByNames (const char *symbol_name[], + uint32_t num_names, + uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint + BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); + + lldb::SBBreakpoint + BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL); + + lldb::SBBreakpoint + BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpecList &module_list, const lldb::SBFileSpecList &file_list); + + lldb::SBBreakpoint + BreakpointCreateForException (lldb::LanguageType language, + bool catch_bp, + bool throw_bp); + + lldb::SBBreakpoint + BreakpointCreateByAddress (addr_t address); + + uint32_t + GetNumBreakpoints () const; + + lldb::SBBreakpoint + GetBreakpointAtIndex (uint32_t idx) const; + + bool + BreakpointDelete (break_id_t break_id); + + lldb::SBBreakpoint + FindBreakpointByID (break_id_t break_id); + + bool + EnableAllBreakpoints (); + + bool + DisableAllBreakpoints (); + + bool + DeleteAllBreakpoints (); + + uint32_t + GetNumWatchpoints () const; + + lldb::SBWatchpoint + GetWatchpointAtIndex (uint32_t idx) const; + + bool + DeleteWatchpoint (lldb::watch_id_t watch_id); + + lldb::SBWatchpoint + FindWatchpointByID (lldb::watch_id_t watch_id); + + bool + EnableAllWatchpoints (); + + bool + DisableAllWatchpoints (); + + bool + DeleteAllWatchpoints (); + + lldb::SBWatchpoint + WatchAddress (lldb::addr_t addr, + size_t size, + bool read, + bool write, + SBError &error); + + + lldb::SBBroadcaster + GetBroadcaster () const; + + lldb::SBValue + CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type); + + lldb::SBValue + CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type); + + lldb::SBValue + CreateValueFromExpression (const char *name, const char* expr); + + %feature("docstring", " + Disassemble a specified number of instructions starting at an address. + Parameters: + base_addr -- the address to start disassembly from + count -- the number of instructions to disassemble + flavor_string -- may be 'intel' or 'att' on x86 targets to specify that style of disassembly + Returns an SBInstructionList.") + ReadInstructions; + lldb::SBInstructionList + ReadInstructions (lldb::SBAddress base_addr, uint32_t count); + + lldb::SBInstructionList + ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string); + + %feature("docstring", " + Disassemble the bytes in a buffer and return them in an SBInstructionList. + Parameters: + base_addr -- used for symbolicating the offsets in the byte stream when disassembling + buf -- bytes to be disassembled + size -- (C++) size of the buffer + Returns an SBInstructionList.") + GetInstructions; + lldb::SBInstructionList + GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size); + + %feature("docstring", " + Disassemble the bytes in a buffer and return them in an SBInstructionList, with a supplied flavor. + Parameters: + base_addr -- used for symbolicating the offsets in the byte stream when disassembling + flavor -- may be 'intel' or 'att' on x86 targets to specify that style of disassembly + buf -- bytes to be disassembled + size -- (C++) size of the buffer + Returns an SBInstructionList.") + GetInstructionsWithFlavor; + lldb::SBInstructionList + GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size); + + lldb::SBSymbolContextList + FindSymbols (const char *name, lldb::SymbolType type = eSymbolTypeAny); + + bool + GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); + + lldb::addr_t + GetStackRedZoneSize(); + + lldb::SBLaunchInfo + GetLaunchInfo () const; + + void + SetLaunchInfo (const lldb::SBLaunchInfo &launch_info); + + bool + operator == (const lldb::SBTarget &rhs) const; + + bool + operator != (const lldb::SBTarget &rhs) const; + + lldb::SBValue + EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options); + %pythoncode %{ + class modules_access(object): + '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.''' + def __init__(self, sbtarget): + self.sbtarget = sbtarget + + def __len__(self): + if self.sbtarget: + return int(self.sbtarget.GetNumModules()) + return 0 + + def __getitem__(self, key): + num_modules = self.sbtarget.GetNumModules() + if type(key) is int: + if key < num_modules: + return self.sbtarget.GetModuleAtIndex(key) + elif type(key) is str: + if key.find('/') == -1: + for idx in range(num_modules): + module = self.sbtarget.GetModuleAtIndex(idx) + if module.file.basename == key: + return module + else: + for idx in range(num_modules): + module = self.sbtarget.GetModuleAtIndex(idx) + if module.file.fullpath == key: + return module + # See if the string is a UUID + try: + the_uuid = uuid.UUID(key) + if the_uuid: + for idx in range(num_modules): + module = self.sbtarget.GetModuleAtIndex(idx) + if module.uuid == the_uuid: + return module + except: + return None + elif type(key) is uuid.UUID: + for idx in range(num_modules): + module = self.sbtarget.GetModuleAtIndex(idx) + if module.uuid == key: + return module + elif type(key) is re.SRE_Pattern: + matching_modules = [] + for idx in range(num_modules): + module = self.sbtarget.GetModuleAtIndex(idx) + re_match = key.search(module.path.fullpath) + if re_match: + matching_modules.append(module) + return matching_modules + else: + print "error: unsupported item type: %s" % type(key) + return None + + def get_modules_access_object(self): + '''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.''' + return self.modules_access (self) + + def get_modules_array(self): + '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.''' + modules = [] + for idx in range(self.GetNumModules()): + modules.append(self.GetModuleAtIndex(idx)) + return modules + + __swig_getmethods__["modules"] = get_modules_array + if _newclass: modules = property(get_modules_array, None, doc='''A read only property that returns a list() of lldb.SBModule objects contained in this target. This list is a list all modules that the target currently is tracking (the main executable and all dependent shared libraries).''') + + __swig_getmethods__["module"] = get_modules_access_object + if _newclass: module = property(get_modules_access_object, None, doc=r'''A read only property that returns an object that implements python operator overloading with the square brackets().\n target.module[] allows array access to any modules.\n target.module[] allows access to modules by basename, full path, or uuid string value.\n target.module[uuid.UUID()] allows module access by UUID.\n target.module[re] allows module access using a regular expression that matches the module full path.''') + + __swig_getmethods__["process"] = GetProcess + if _newclass: process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that this target owns.''') + + __swig_getmethods__["executable"] = GetExecutable + if _newclass: executable = property(GetExecutable, None, doc='''A read only property that returns an lldb object that represents the main executable module (lldb.SBModule) for this target.''') + + __swig_getmethods__["debugger"] = GetDebugger + if _newclass: debugger = property(GetDebugger, None, doc='''A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.''') + + __swig_getmethods__["num_breakpoints"] = GetNumBreakpoints + if _newclass: num_breakpoints = property(GetNumBreakpoints, None, doc='''A read only property that returns the number of breakpoints that this target has as an integer.''') + + __swig_getmethods__["num_watchpoints"] = GetNumWatchpoints + if _newclass: num_watchpoints = property(GetNumWatchpoints, None, doc='''A read only property that returns the number of watchpoints that this target has as an integer.''') + + __swig_getmethods__["broadcaster"] = GetBroadcaster + if _newclass: broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this target.''') + + __swig_getmethods__["byte_order"] = GetByteOrder + if _newclass: byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this target.''') + + __swig_getmethods__["addr_size"] = GetAddressByteSize + if _newclass: addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this target.''') + + __swig_getmethods__["triple"] = GetTriple + if _newclass: triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''') + + __swig_getmethods__["data_byte_size"] = GetDataByteSize + if _newclass: data_byte_size = property(GetDataByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the data address space for this target.''') + + __swig_getmethods__["code_byte_size"] = GetCodeByteSize + if _newclass: code_byte_size = property(GetCodeByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the code address space for this target.''') + + __swig_getmethods__["platform"] = GetPlatform + if _newclass: platform = property(GetPlatform, None, doc='''A read only property that returns the platform associated with with this target.''') + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBThread.i =================================================================== --- lldb/trunk/scripts/interface/SBThread.i +++ lldb/trunk/scripts/interface/SBThread.i @@ -0,0 +1,401 @@ +//===-- SWIG Interface for SBThread -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents a thread of execution. SBProcess contains SBThread(s). + +SBThreads can be referred to by their ID, which maps to the system specific thread +identifier, or by IndexID. The ID may or may not be unique depending on whether the +system reuses its thread identifiers. The IndexID is a monotonically increasing identifier +that will always uniquely reference a particular thread, and when that thread goes +away it will not be reused. + +SBThread supports frame iteration. For example (from test/python_api/ +lldbutil/iter/TestLLDBIterator.py), + + from lldbutil import print_stacktrace + stopped_due_to_breakpoint = False + for thread in process: + if self.TraceOn(): + print_stacktrace(thread) + ID = thread.GetThreadID() + if thread.GetStopReason() == lldb.eStopReasonBreakpoint: + stopped_due_to_breakpoint = True + for frame in thread: + self.assertTrue(frame.GetThread().GetThreadID() == ID) + if self.TraceOn(): + print frame + + self.assertTrue(stopped_due_to_breakpoint) + +See also SBProcess and SBFrame." +) SBThread; +class SBThread +{ +public: + //------------------------------------------------------------------ + // Broadcaster bits. + //------------------------------------------------------------------ + enum + { + eBroadcastBitStackChanged = (1 << 0), + eBroadcastBitThreadSuspended = (1 << 1), + eBroadcastBitThreadResumed = (1 << 2), + eBroadcastBitSelectedFrameChanged = (1 << 3), + eBroadcastBitThreadSelected = (1 << 4) + }; + + + SBThread (); + + SBThread (const lldb::SBThread &thread); + + ~SBThread(); + + static const char * + GetBroadcasterClassName (); + + static bool + EventIsThreadEvent (const SBEvent &event); + + static SBFrame + GetStackFrameFromEvent (const SBEvent &event); + + static SBThread + GetThreadFromEvent (const SBEvent &event); + + bool + IsValid() const; + + void + Clear (); + + lldb::StopReason + GetStopReason(); + + %feature("docstring", " + /// Get the number of words associated with the stop reason. + /// See also GetStopReasonDataAtIndex(). + ") GetStopReasonDataCount; + size_t + GetStopReasonDataCount(); + + %feature("docstring", " + //-------------------------------------------------------------------------- + /// Get information associated with a stop reason. + /// + /// Breakpoint stop reasons will have data that consists of pairs of + /// breakpoint IDs followed by the breakpoint location IDs (they always come + /// in pairs). + /// + /// Stop Reason Count Data Type + /// ======================== ===== ========================================= + /// eStopReasonNone 0 + /// eStopReasonTrace 0 + /// eStopReasonBreakpoint N duple: {breakpoint id, location id} + /// eStopReasonWatchpoint 1 watchpoint id + /// eStopReasonSignal 1 unix signal number + /// eStopReasonException N exception data + /// eStopReasonExec 0 + /// eStopReasonPlanComplete 0 + //-------------------------------------------------------------------------- + ") GetStopReasonDataAtIndex; + uint64_t + GetStopReasonDataAtIndex(uint32_t idx); + + %feature("autodoc", " + Collects a thread's stop reason extended information dictionary and prints it + into the SBStream in a JSON format. The format of this JSON dictionary depends + on the stop reason and is currently used only for instrumentation plugins. + ") GetStopReasonExtendedInfoAsJSON; + bool + GetStopReasonExtendedInfoAsJSON (lldb::SBStream &stream); + + %feature("autodoc", " + Pass only an (int)length and expect to get a Python string describing the + stop reason. + ") GetStopDescription; + size_t + GetStopDescription (char *dst, size_t dst_len); + + SBValue + GetStopReturnValue (); + + %feature("autodoc", " + Returns a unique thread identifier (type lldb::tid_t, typically a 64-bit type) + for the current SBThread that will remain constant throughout the thread's + lifetime in this process and will not be reused by another thread during this + process lifetime. On Mac OS X systems, this is a system-wide unique thread + identifier; this identifier is also used by other tools like sample which helps + to associate data from those tools with lldb. See related GetIndexID. + ") + GetThreadID; + lldb::tid_t + GetThreadID () const; + + %feature("autodoc", " + Return the index number for this SBThread. The index number is the same thing + that a user gives as an argument to 'thread select' in the command line lldb. + These numbers start at 1 (for the first thread lldb sees in a debug session) + and increments up throughout the process lifetime. An index number will not be + reused for a different thread later in a process - thread 1 will always be + associated with the same thread. See related GetThreadID. + This method returns a uint32_t index number, takes no arguments. + ") + GetIndexID; + uint32_t + GetIndexID () const; + + const char * + GetName () const; + + %feature("autodoc", " + Return the queue name associated with this thread, if any, as a str. + For example, with a libdispatch (aka Grand Central Dispatch) queue. + ") GetQueueName; + + const char * + GetQueueName() const; + + %feature("autodoc", " + Return the dispatch_queue_id for this thread, if any, as a lldb::queue_id_t. + For example, with a libdispatch (aka Grand Central Dispatch) queue. + ") GetQueueID; + + lldb::queue_id_t + GetQueueID() const; + + %feature("autodoc", " + Takes a path string and a SBStream reference as parameters, returns a bool. + Collects the thread's 'info' dictionary from the remote system, uses the path + argument to descend into the dictionary to an item of interest, and prints + it into the SBStream in a natural format. Return bool is to indicate if + anything was printed into the stream (true) or not (false). + ") GetInfoItemByPathAsString; + + bool + GetInfoItemByPathAsString (const char *path, lldb::SBStream &strm); + + %feature("autodoc", " + Return the SBQueue for this thread. If this thread is not currently associated + with a libdispatch queue, the SBQueue object's IsValid() method will return false. + If this SBThread is actually a HistoryThread, we may be able to provide QueueID + and QueueName, but not provide an SBQueue. Those individual attributes may have + been saved for the HistoryThread without enough information to reconstitute the + entire SBQueue at that time. + This method takes no arguments, returns an SBQueue. + ") GetQueue; + + lldb::SBQueue + GetQueue () const; + + void + StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + + void + StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + + void + StepInto (const char *target_name, lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + + void + StepOut (); + + void + StepOutOfFrame (lldb::SBFrame &frame); + + void + StepInstruction(bool step_over); + + SBError + StepOverUntil (lldb::SBFrame &frame, + lldb::SBFileSpec &file_spec, + uint32_t line); + + SBError + StepUsingScriptedThreadPlan (const char *script_class_name); + + SBError + JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line); + + void + RunToAddress (lldb::addr_t addr); + + SBError + ReturnFromFrame (SBFrame &frame, SBValue &return_value); + + %feature("docstring", " + //-------------------------------------------------------------------------- + /// LLDB currently supports process centric debugging which means when any + /// thread in a process stops, all other threads are stopped. The Suspend() + /// call here tells our process to suspend a thread and not let it run when + /// the other threads in a process are allowed to run. So when + /// SBProcess::Continue() is called, any threads that aren't suspended will + /// be allowed to run. If any of the SBThread functions for stepping are + /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the + /// thread will now be allowed to run and these functions will simply return. + /// + /// Eventually we plan to add support for thread centric debugging where + /// each thread is controlled individually and each thread would broadcast + /// its state, but we haven't implemented this yet. + /// + /// Likewise the SBThread::Resume() call will again allow the thread to run + /// when the process is continued. + /// + /// Suspend() and Resume() functions are not currently reference counted, if + /// anyone has the need for them to be reference counted, please let us + /// know. + //-------------------------------------------------------------------------- + ") Suspend; + bool + Suspend(); + + bool + Resume (); + + bool + IsSuspended(); + + bool + IsStopped(); + + uint32_t + GetNumFrames (); + + lldb::SBFrame + GetFrameAtIndex (uint32_t idx); + + lldb::SBFrame + GetSelectedFrame (); + + lldb::SBFrame + SetSelectedFrame (uint32_t frame_idx); + + lldb::SBProcess + GetProcess (); + + bool + GetDescription (lldb::SBStream &description) const; + + bool + GetStatus (lldb::SBStream &status) const; + + bool + operator == (const lldb::SBThread &rhs) const; + + bool + operator != (const lldb::SBThread &rhs) const; + + %feature("autodoc"," + Given an argument of str to specify the type of thread-origin extended + backtrace to retrieve, query whether the origin of this thread is + available. An SBThread is retured; SBThread.IsValid will return true + if an extended backtrace was available. The returned SBThread is not + a part of the SBProcess' thread list and it cannot be manipulated like + normal threads -- you cannot step or resume it, for instance -- it is + intended to used primarily for generating a backtrace. You may request + the returned thread's own thread origin in turn. + ") GetExtendedBacktraceThread; + lldb::SBThread + GetExtendedBacktraceThread (const char *type); + + %feature("autodoc"," + Takes no arguments, returns a uint32_t. + If this SBThread is an ExtendedBacktrace thread, get the IndexID of the + original thread that this ExtendedBacktrace thread represents, if + available. The thread that was running this backtrace in the past may + not have been registered with lldb's thread index (if it was created, + did its work, and was destroyed without lldb ever stopping execution). + In that case, this ExtendedBacktrace thread's IndexID will be returned. + ") GetExtendedBacktraceOriginatingIndexID; + uint32_t + GetExtendedBacktraceOriginatingIndexID(); + + %feature("autodoc"," + Takes no arguments, returns a bool. + lldb may be able to detect that function calls should not be executed + on a given thread at a particular point in time. It is recommended that + this is checked before performing an inferior function call on a given + thread. + ") SafeToCallFunctions; + bool + SafeToCallFunctions (); + + %pythoncode %{ + class frames_access(object): + '''A helper object that will lazily hand out frames for a thread when supplied an index.''' + def __init__(self, sbthread): + self.sbthread = sbthread + + def __len__(self): + if self.sbthread: + return int(self.sbthread.GetNumFrames()) + return 0 + + def __getitem__(self, key): + if type(key) is int and key < self.sbthread.GetNumFrames(): + return self.sbthread.GetFrameAtIndex(key) + return None + + def get_frames_access_object(self): + '''An accessor function that returns a frames_access() object which allows lazy frame access from a lldb.SBThread object.''' + return self.frames_access (self) + + def get_thread_frames(self): + '''An accessor function that returns a list() that contains all frames in a lldb.SBThread object.''' + frames = [] + for frame in self: + frames.append(frame) + return frames + + __swig_getmethods__["id"] = GetThreadID + if _newclass: id = property(GetThreadID, None, doc='''A read only property that returns the thread ID as an integer.''') + + __swig_getmethods__["idx"] = GetIndexID + if _newclass: idx = property(GetIndexID, None, doc='''A read only property that returns the thread index ID as an integer. Thread index ID values start at 1 and increment as threads come and go and can be used to uniquely identify threads.''') + + __swig_getmethods__["return_value"] = GetStopReturnValue + if _newclass: return_value = property(GetStopReturnValue, None, doc='''A read only property that returns an lldb object that represents the return value from the last stop (lldb.SBValue) if we just stopped due to stepping out of a function.''') + + __swig_getmethods__["process"] = GetProcess + if _newclass: process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that owns this thread.''') + + __swig_getmethods__["num_frames"] = GetNumFrames + if _newclass: num_frames = property(GetNumFrames, None, doc='''A read only property that returns the number of stack frames in this thread as an integer.''') + + __swig_getmethods__["frames"] = get_thread_frames + if _newclass: frames = property(get_thread_frames, None, doc='''A read only property that returns a list() of lldb.SBFrame objects for all frames in this thread.''') + + __swig_getmethods__["frame"] = get_frames_access_object + if _newclass: frame = property(get_frames_access_object, None, doc='''A read only property that returns an object that can be used to access frames as an array ("frame_12 = lldb.thread.frame[12]").''') + + __swig_getmethods__["name"] = GetName + if _newclass: name = property(GetName, None, doc='''A read only property that returns the name of this thread as a string.''') + + __swig_getmethods__["queue"] = GetQueueName + if _newclass: queue = property(GetQueueName, None, doc='''A read only property that returns the dispatch queue name of this thread as a string.''') + + __swig_getmethods__["queue_id"] = GetQueueID + if _newclass: queue_id = property(GetQueueID, None, doc='''A read only property that returns the dispatch queue id of this thread as an integer.''') + + __swig_getmethods__["stop_reason"] = GetStopReason + if _newclass: stop_reason = property(GetStopReason, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eStopReason") that represents the reason this thread stopped.''') + + __swig_getmethods__["is_suspended"] = IsSuspended + if _newclass: is_suspended = property(IsSuspended, None, doc='''A read only property that returns a boolean value that indicates if this thread is suspended.''') + + __swig_getmethods__["is_stopped"] = IsStopped + if _newclass: is_stopped = property(IsStopped, None, doc='''A read only property that returns a boolean value that indicates if this thread is stopped but not exited.''') + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBThreadCollection.i =================================================================== --- lldb/trunk/scripts/interface/SBThreadCollection.i +++ lldb/trunk/scripts/interface/SBThreadCollection.i @@ -0,0 +1,38 @@ +//===-- SWIG Interface for SBThreadCollection -------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +namespace lldb { + +%feature("docstring", +"Represents a collection of SBThread objects." +) SBThreadCollection; +class SBThreadCollection +{ +public: + + SBThreadCollection (); + + SBThreadCollection (const SBThreadCollection &rhs); + + ~SBThreadCollection (); + + bool + IsValid () const; + + size_t + GetSize (); + + lldb::SBThread + GetThreadAtIndex (size_t idx); + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBThreadPlan.i =================================================================== --- lldb/trunk/scripts/interface/SBThreadPlan.i +++ lldb/trunk/scripts/interface/SBThreadPlan.i @@ -0,0 +1,123 @@ +//===-- SBThread.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBThreadPlan_h_ +#define LLDB_SBThreadPlan_h_ + +#include "lldb/API/SBDefines.h" + +#include + +namespace lldb { + +%feature("docstring", +"Represents a plan for the execution control of a given thread. + +See also SBThread and SBFrame." +) SBThread; + +class SBThreadPlan +{ + +friend class lldb_private::ThreadPlan; + +public: + SBThreadPlan (); + + SBThreadPlan (const lldb::SBThreadPlan &threadPlan); + + SBThreadPlan (const lldb::ThreadPlanSP& lldb_object_sp); + + SBThreadPlan (lldb::SBThread &thread, const char *class_name); + + ~SBThreadPlan (); + + bool + IsValid() const; + + void + Clear (); + + lldb::StopReason + GetStopReason(); + + /// Get the number of words associated with the stop reason. + /// See also GetStopReasonDataAtIndex(). + size_t + GetStopReasonDataCount(); + + //-------------------------------------------------------------------------- + /// Get information associated with a stop reason. + /// + /// Breakpoint stop reasons will have data that consists of pairs of + /// breakpoint IDs followed by the breakpoint location IDs (they always come + /// in pairs). + /// + /// Stop Reason Count Data Type + /// ======================== ===== ========================================= + /// eStopReasonNone 0 + /// eStopReasonTrace 0 + /// eStopReasonBreakpoint N duple: {breakpoint id, location id} + /// eStopReasonWatchpoint 1 watchpoint id + /// eStopReasonSignal 1 unix signal number + /// eStopReasonException N exception data + /// eStopReasonExec 0 + /// eStopReasonPlanComplete 0 + //-------------------------------------------------------------------------- + uint64_t + GetStopReasonDataAtIndex(uint32_t idx); + + SBThread + GetThread () const; + + bool + GetDescription (lldb::SBStream &description) const; + + void + SetPlanComplete (bool success); + + bool + IsPlanComplete(); + + bool + IsValid(); + + // This section allows an SBThreadPlan to push another of the common types of plans... + SBThreadPlan + QueueThreadPlanForStepOverRange (SBAddress &start_address, + lldb::addr_t range_size); + + SBThreadPlan + QueueThreadPlanForStepInRange (SBAddress &start_address, + lldb::addr_t range_size); + + SBThreadPlan + QueueThreadPlanForStepOut (uint32_t frame_idx_to_step_to, bool first_insn = false); + + SBThreadPlan + QueueThreadPlanForRunToAddress (SBAddress address); + + +protected: + friend class SBBreakpoint; + friend class SBBreakpointLocation; + friend class SBFrame; + friend class SBProcess; + friend class SBDebugger; + friend class SBValue; + friend class lldb_private::QueueImpl; + friend class SBQueueItem; + +private: + lldb::ThreadPlanSP m_opaque_sp; +}; + +} // namespace lldb + +#endif // LLDB_SBThreadPlan_h_ Index: lldb/trunk/scripts/interface/SBType.i =================================================================== --- lldb/trunk/scripts/interface/SBType.i +++ lldb/trunk/scripts/interface/SBType.i @@ -0,0 +1,491 @@ +//===-- SWIG Interface for SBType -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", +"Represents a member of a type in lldb. +") SBTypeMember; + +class SBTypeMember +{ +public: + SBTypeMember (); + + SBTypeMember (const lldb::SBTypeMember& rhs); + + ~SBTypeMember(); + + bool + IsValid() const; + + const char * + GetName (); + + lldb::SBType + GetType (); + + uint64_t + GetOffsetInBytes(); + + uint64_t + GetOffsetInBits(); + + bool + IsBitfield(); + + uint32_t + GetBitfieldSizeInBits(); + + %pythoncode %{ + __swig_getmethods__["name"] = GetName + if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this member as a string.''') + + __swig_getmethods__["type"] = GetType + if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this member.''') + + __swig_getmethods__["byte_offset"] = GetOffsetInBytes + if _newclass: byte_offset = property(GetOffsetInBytes, None, doc='''A read only property that returns offset in bytes for this member as an integer.''') + + __swig_getmethods__["bit_offset"] = GetOffsetInBits + if _newclass: bit_offset = property(GetOffsetInBits, None, doc='''A read only property that returns offset in bits for this member as an integer.''') + + __swig_getmethods__["is_bitfield"] = IsBitfield + if _newclass: is_bitfield = property(IsBitfield, None, doc='''A read only property that returns true if this member is a bitfield.''') + + __swig_getmethods__["bitfield_bit_size"] = GetBitfieldSizeInBits + if _newclass: bitfield_bit_size = property(GetBitfieldSizeInBits, None, doc='''A read only property that returns the bitfield size in bits for this member as an integer, or zero if this member is not a bitfield.''') + + %} + +protected: + std::unique_ptr m_opaque_ap; +}; + +class SBTypeMemberFunction +{ +public: + SBTypeMemberFunction (); + + SBTypeMemberFunction (const lldb::SBTypeMemberFunction& rhs); + + ~SBTypeMemberFunction(); + + bool + IsValid() const; + + const char * + GetName (); + + lldb::SBType + GetType (); + + lldb::SBType + GetReturnType (); + + uint32_t + GetNumberOfArguments (); + + lldb::SBType + GetArgumentTypeAtIndex (uint32_t); + + lldb::MemberFunctionKind + GetKind(); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + +protected: + lldb::TypeMemberFunctionImplSP m_opaque_sp; +}; + +%feature("docstring", +"Represents a data type in lldb. The FindFirstType() method of SBTarget/SBModule +returns a SBType. + +SBType supports the eq/ne operator. For example, + +main.cpp: + +class Task { +public: + int id; + Task *next; + Task(int i, Task *n): + id(i), + next(n) + {} +}; + +int main (int argc, char const *argv[]) +{ + Task *task_head = new Task(-1, NULL); + Task *task1 = new Task(1, NULL); + Task *task2 = new Task(2, NULL); + Task *task3 = new Task(3, NULL); // Orphaned. + Task *task4 = new Task(4, NULL); + Task *task5 = new Task(5, NULL); + + task_head->next = task1; + task1->next = task2; + task2->next = task4; + task4->next = task5; + + int total = 0; + Task *t = task_head; + while (t != NULL) { + if (t->id >= 0) + ++total; + t = t->next; + } + printf('We have a total number of %d tasks\\n', total); + + // This corresponds to an empty task list. + Task *empty_task_head = new Task(-1, NULL); + + return 0; // Break at this line +} + +find_type.py: + + # Get the type 'Task'. + task_type = target.FindFirstType('Task') + self.assertTrue(task_type) + + # Get the variable 'task_head'. + frame0.FindVariable('task_head') + task_head_type = task_head.GetType() + self.assertTrue(task_head_type.IsPointerType()) + + # task_head_type is 'Task *'. + task_pointer_type = task_type.GetPointerType() + self.assertTrue(task_head_type == task_pointer_type) + + # Get the child mmember 'id' from 'task_head'. + id = task_head.GetChildMemberWithName('id') + id_type = id.GetType() + + # SBType.GetBasicType() takes an enum 'BasicType' (lldb-enumerations.h). + int_type = id_type.GetBasicType(lldb.eBasicTypeInt) + # id_type and int_type should be the same type! + self.assertTrue(id_type == int_type) + +... +") SBType; +class SBType +{ +public: + SBType (); + + SBType (const lldb::SBType &rhs); + + ~SBType (); + + bool + IsValid(); + + uint64_t + GetByteSize(); + + bool + IsPointerType(); + + bool + IsReferenceType(); + + bool + IsFunctionType (); + + bool + IsPolymorphicClass (); + + bool + IsArrayType (); + + bool + IsVectorType (); + + bool + IsTypedefType (); + + lldb::SBType + GetPointerType(); + + lldb::SBType + GetPointeeType(); + + lldb::SBType + GetReferenceType(); + + lldb::SBType + SBType::GetTypedefedType(); + + lldb::SBType + GetDereferencedType(); + + lldb::SBType + GetUnqualifiedType(); + + lldb::SBType + GetCanonicalType(); + + lldb::SBType + GetArrayElementType (); + + lldb::SBType + GetVectorElementType (); + + lldb::BasicType + GetBasicType(); + + lldb::SBType + GetBasicType (lldb::BasicType type); + + uint32_t + GetNumberOfFields (); + + uint32_t + GetNumberOfDirectBaseClasses (); + + uint32_t + GetNumberOfVirtualBaseClasses (); + + lldb::SBTypeMember + GetFieldAtIndex (uint32_t idx); + + lldb::SBTypeMember + GetDirectBaseClassAtIndex (uint32_t idx); + + lldb::SBTypeMember + GetVirtualBaseClassAtIndex (uint32_t idx); + + lldb::SBTypeEnumMemberList + GetEnumMembers(); + + const char* + GetName(); + + const char * + GetDisplayTypeName (); + + lldb::TypeClass + GetTypeClass (); + + uint32_t + GetNumberOfTemplateArguments (); + + lldb::SBType + GetTemplateArgumentType (uint32_t idx); + + lldb::TemplateArgumentKind + GetTemplateArgumentKind (uint32_t idx); + + lldb::SBType + GetFunctionReturnType (); + + lldb::SBTypeList + GetFunctionArgumentTypes (); + + uint32_t + GetNumberOfMemberFunctions (); + + lldb::SBTypeMemberFunction + GetMemberFunctionAtIndex (uint32_t idx); + + bool + IsTypeComplete (); + + uint32_t + GetTypeFlags (); + + %pythoncode %{ + def template_arg_array(self): + num_args = self.num_template_args + if num_args: + template_args = [] + for i in range(num_args): + template_args.append(self.GetTemplateArgumentType(i)) + return template_args + return None + + __swig_getmethods__["name"] = GetName + if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this type as a string.''') + + __swig_getmethods__["size"] = GetByteSize + if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns size in bytes for this type as an integer.''') + + __swig_getmethods__["is_pointer"] = IsPointerType + if _newclass: is_pointer = property(IsPointerType, None, doc='''A read only property that returns a boolean value that indicates if this type is a pointer type.''') + + __swig_getmethods__["is_reference"] = IsReferenceType + if _newclass: is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a reference type.''') + + __swig_getmethods__["is_function"] = IsFunctionType + if _newclass: is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a function type.''') + + __swig_getmethods__["num_fields"] = GetNumberOfFields + if _newclass: num_fields = property(GetNumberOfFields, None, doc='''A read only property that returns number of fields in this type as an integer.''') + + __swig_getmethods__["num_bases"] = GetNumberOfDirectBaseClasses + if _newclass: num_bases = property(GetNumberOfDirectBaseClasses, None, doc='''A read only property that returns number of direct base classes in this type as an integer.''') + + __swig_getmethods__["num_vbases"] = GetNumberOfVirtualBaseClasses + if _newclass: num_vbases = property(GetNumberOfVirtualBaseClasses, None, doc='''A read only property that returns number of virtual base classes in this type as an integer.''') + + __swig_getmethods__["num_template_args"] = GetNumberOfTemplateArguments + if _newclass: num_template_args = property(GetNumberOfTemplateArguments, None, doc='''A read only property that returns number of template arguments in this type as an integer.''') + + __swig_getmethods__["template_args"] = template_arg_array + if _newclass: template_args = property(template_arg_array, None, doc='''A read only property that returns a list() of lldb.SBType objects that represent all template arguments in this type.''') + + __swig_getmethods__["type"] = GetTypeClass + if _newclass: type = property(GetTypeClass, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eTypeClass") that represents a classification for this type.''') + + __swig_getmethods__["is_complete"] = IsTypeComplete + if _newclass: is_complete = property(IsTypeComplete, None, doc='''A read only property that returns a boolean value that indicates if this type is a complete type (True) or a forward declaration (False).''') + + def get_bases_array(self): + '''An accessor function that returns a list() that contains all direct base classes in a lldb.SBType object.''' + bases = [] + for idx in range(self.GetNumberOfDirectBaseClasses()): + bases.append(self.GetDirectBaseClassAtIndex(idx)) + return bases + + def get_vbases_array(self): + '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.''' + vbases = [] + for idx in range(self.GetNumberOfVirtualBaseClasses()): + vbases.append(self.GetVirtualBaseClassAtIndex(idx)) + return vbases + + def get_fields_array(self): + '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.''' + fields = [] + for idx in range(self.GetNumberOfFields()): + fields.append(self.GetFieldAtIndex(idx)) + return fields + + def get_members_array(self): + '''An accessor function that returns a list() that contains all members (base classes and fields) in a lldb.SBType object in ascending bit offset order.''' + members = [] + bases = self.get_bases_array() + fields = self.get_fields_array() + vbases = self.get_vbases_array() + for base in bases: + bit_offset = base.bit_offset + added = False + for idx, member in enumerate(members): + if member.bit_offset > bit_offset: + members.insert(idx, base) + added = True + break + if not added: + members.append(base) + for vbase in vbases: + bit_offset = vbase.bit_offset + added = False + for idx, member in enumerate(members): + if member.bit_offset > bit_offset: + members.insert(idx, vbase) + added = True + break + if not added: + members.append(vbase) + for field in fields: + bit_offset = field.bit_offset + added = False + for idx, member in enumerate(members): + if member.bit_offset > bit_offset: + members.insert(idx, field) + added = True + break + if not added: + members.append(field) + return members + + def get_enum_members_array(self): + '''An accessor function that returns a list() that contains all enum members in an lldb.SBType object.''' + enum_members_list = [] + sb_enum_members = self.GetEnumMembers() + for idx in range(sb_enum_members.GetSize()): + enum_members_list.append(sb_enum_members.GetTypeEnumMemberAtIndex(idx)) + return enum_members_list + + __swig_getmethods__["bases"] = get_bases_array + if _newclass: bases = property(get_bases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the direct base classes for this type.''') + + __swig_getmethods__["vbases"] = get_vbases_array + if _newclass: vbases = property(get_vbases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the virtual base classes for this type.''') + + __swig_getmethods__["fields"] = get_fields_array + if _newclass: fields = property(get_fields_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the fields for this type.''') + + __swig_getmethods__["members"] = get_members_array + if _newclass: members = property(get_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeMember objects that represent all of the base classes, virtual base classes and fields for this type in ascending bit offset order.''') + + __swig_getmethods__["enum_members"] = get_enum_members_array + if _newclass: enum_members = property(get_enum_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeEnumMember objects that represent the enum members for this type.''') + + %} + +}; + +%feature("docstring", +"Represents a list of SBTypes. The FindTypes() method of SBTarget/SBModule +returns a SBTypeList. + +SBTypeList supports SBType iteration. For example, + +main.cpp: + +class Task { +public: + int id; + Task *next; + Task(int i, Task *n): + id(i), + next(n) + {} +}; + +... + +find_type.py: + + # Get the type 'Task'. + type_list = target.FindTypes('Task') + self.assertTrue(len(type_list) == 1) + # To illustrate the SBType iteration. + for type in type_list: + # do something with type + +... +") SBTypeList; +class SBTypeList +{ +public: + SBTypeList(); + + bool + IsValid(); + + void + Append (lldb::SBType type); + + lldb::SBType + GetTypeAtIndex (uint32_t index); + + uint32_t + GetSize(); + + ~SBTypeList(); +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBTypeCategory.i =================================================================== --- lldb/trunk/scripts/interface/SBTypeCategory.i +++ lldb/trunk/scripts/interface/SBTypeCategory.i @@ -0,0 +1,237 @@ +//===-- SWIG Interface for SBTypeCategory---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", + "Represents a category that can contain formatters for types. + ") SBTypeCategory; + + class SBTypeCategory + { + public: + + SBTypeCategory(); + + SBTypeCategory (const lldb::SBTypeCategory &rhs); + + ~SBTypeCategory (); + + bool + IsValid() const; + + bool + GetEnabled (); + + void + SetEnabled (bool); + + const char* + GetName(); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + uint32_t + GetNumFormats (); + + uint32_t + GetNumSummaries (); + + uint32_t + GetNumFilters (); + + uint32_t + GetNumSynthetics (); + + lldb::SBTypeNameSpecifier + GetTypeNameSpecifierForFilterAtIndex (uint32_t); + + lldb::SBTypeNameSpecifier + GetTypeNameSpecifierForFormatAtIndex (uint32_t); + + lldb::SBTypeNameSpecifier + GetTypeNameSpecifierForSummaryAtIndex (uint32_t); + + lldb::SBTypeNameSpecifier + GetTypeNameSpecifierForSyntheticAtIndex (uint32_t); + + lldb::SBTypeFilter + GetFilterForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeFormat + GetFormatForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeSummary + GetSummaryForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeSynthetic + GetSyntheticForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeFilter + GetFilterAtIndex (uint32_t); + + lldb::SBTypeFormat + GetFormatAtIndex (uint32_t); + + lldb::SBTypeSummary + GetSummaryAtIndex (uint32_t); + + lldb::SBTypeSynthetic + GetSyntheticAtIndex (uint32_t); + + bool + AddTypeFormat (lldb::SBTypeNameSpecifier, + lldb::SBTypeFormat); + + bool + DeleteTypeFormat (lldb::SBTypeNameSpecifier); + + bool + AddTypeSummary (lldb::SBTypeNameSpecifier, + lldb::SBTypeSummary); + + bool + DeleteTypeSummary (lldb::SBTypeNameSpecifier); + + bool + AddTypeFilter (lldb::SBTypeNameSpecifier, + lldb::SBTypeFilter); + + bool + DeleteTypeFilter (lldb::SBTypeNameSpecifier); + + bool + AddTypeSynthetic (lldb::SBTypeNameSpecifier, + lldb::SBTypeSynthetic); + + bool + DeleteTypeSynthetic (lldb::SBTypeNameSpecifier); + + %pythoncode %{ + + class formatters_access_class(object): + '''A helper object that will lazily hand out formatters for a specific category.''' + def __init__(self, sbcategory, get_count_function, get_at_index_function, get_by_name_function): + self.sbcategory = sbcategory + self.get_count_function = get_count_function + self.get_at_index_function = get_at_index_function + self.get_by_name_function = get_by_name_function + self.regex_type = type(re.compile('.')) + + + def __len__(self): + if self.sbcategory and self.get_count_function: + return int(self.get_count_function(self.sbcategory)) + return 0 + + def __getitem__(self, key): + num_items = len(self) + if type(key) is int: + if key < num_items: + return self.get_at_index_function(self.sbcategory,key) + elif type(key) is str: + return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key)) + elif isinstance(key,self.regex_type): + return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key.pattern,True)) + else: + print "error: unsupported item type: %s" % type(key) + return None + + def get_formats_access_object(self): + '''An accessor function that returns an accessor object which allows lazy format access from a lldb.SBTypeCategory object.''' + return self.formatters_access_class (self,self.__class__.GetNumFormats,self.__class__.GetFormatAtIndex,self.__class__.GetFormatForType) + + def get_formats_array(self): + '''An accessor function that returns a list() that contains all formats in a lldb.SBCategory object.''' + formats = [] + for idx in range(self.GetNumFormats()): + formats.append(self.GetFormatAtIndex(idx)) + return formats + + def get_summaries_access_object(self): + '''An accessor function that returns an accessor object which allows lazy summary access from a lldb.SBTypeCategory object.''' + return self.formatters_access_class (self,self.__class__.GetNumSummaries,self.__class__.GetSummaryAtIndex,self.__class__.GetSummaryForType) + + def get_summaries_array(self): + '''An accessor function that returns a list() that contains all summaries in a lldb.SBCategory object.''' + summaries = [] + for idx in range(self.GetNumSummaries()): + summaries.append(self.GetSummaryAtIndex(idx)) + return summaries + + def get_synthetics_access_object(self): + '''An accessor function that returns an accessor object which allows lazy synthetic children provider access from a lldb.SBTypeCategory object.''' + return self.formatters_access_class (self,self.__class__.GetNumSynthetics,self.__class__.GetSyntheticAtIndex,self.__class__.GetSyntheticForType) + + def get_synthetics_array(self): + '''An accessor function that returns a list() that contains all synthetic children providers in a lldb.SBCategory object.''' + synthetics = [] + for idx in range(self.GetNumSynthetics()): + synthetics.append(self.GetSyntheticAtIndex(idx)) + return synthetics + + def get_filters_access_object(self): + '''An accessor function that returns an accessor object which allows lazy filter access from a lldb.SBTypeCategory object.''' + return self.formatters_access_class (self,self.__class__.GetNumFilters,self.__class__.GetFilterAtIndex,self.__class__.GetFilterForType) + + def get_filters_array(self): + '''An accessor function that returns a list() that contains all filters in a lldb.SBCategory object.''' + filters = [] + for idx in range(self.GetNumFilters()): + filters.append(self.GetFilterAtIndex(idx)) + return filters + + __swig_getmethods__["formats"] = get_formats_array + if _newclass: formats = property(get_formats_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFormat objects contained in this category''') + + __swig_getmethods__["format"] = get_formats_access_object + if _newclass: format = property(get_formats_access_object, None, doc=r'''A read only property that returns an object that you can use to look for formats by index or type name.''') + + __swig_getmethods__["summaries"] = get_summaries_array + if _newclass: summaries = property(get_summaries_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSummary objects contained in this category''') + + __swig_getmethods__["summary"] = get_summaries_access_object + if _newclass: summary = property(get_summaries_access_object, None, doc=r'''A read only property that returns an object that you can use to look for summaries by index or type name or regular expression.''') + + __swig_getmethods__["filters"] = get_filters_array + if _newclass: filters = property(get_filters_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFilter objects contained in this category''') + + __swig_getmethods__["filter"] = get_filters_access_object + if _newclass: filter = property(get_filters_access_object, None, doc=r'''A read only property that returns an object that you can use to look for filters by index or type name or regular expression.''') + + __swig_getmethods__["synthetics"] = get_synthetics_array + if _newclass: synthetics = property(get_synthetics_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSynthetic objects contained in this category''') + + __swig_getmethods__["synthetic"] = get_synthetics_access_object + if _newclass: synthetic = property(get_synthetics_access_object, None, doc=r'''A read only property that returns an object that you can use to look for synthetic children provider by index or type name or regular expression.''') + + __swig_getmethods__["num_formats"] = GetNumFormats + if _newclass: num_formats = property(GetNumFormats, None) + __swig_getmethods__["num_summaries"] = GetNumSummaries + if _newclass: num_summaries = property(GetNumSummaries, None) + __swig_getmethods__["num_filters"] = GetNumFilters + if _newclass: num_filters = property(GetNumFilters, None) + __swig_getmethods__["num_synthetics"] = GetNumSynthetics + if _newclass: num_synthetics = property(GetNumSynthetics, None) + + __swig_getmethods__["name"] = GetName + if _newclass: name = property(GetName, None) + + __swig_getmethods__["enabled"] = GetEnabled + __swig_setmethods__["enabled"] = SetEnabled + if _newclass: enabled = property(GetEnabled, SetEnabled) + %} + + }; + + +} // namespace lldb + Index: lldb/trunk/scripts/interface/SBTypeEnumMember.i =================================================================== --- lldb/trunk/scripts/interface/SBTypeEnumMember.i +++ lldb/trunk/scripts/interface/SBTypeEnumMember.i @@ -0,0 +1,108 @@ +//===-- SWIG Interface for SBTypeEnumMember ---------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature( + "docstring", + "Represents a member of an enum in lldb." +) SBTypeEnumMember; + +class SBTypeEnumMember +{ +public: + SBTypeEnumMember (); + + SBTypeEnumMember (const SBTypeEnumMember& rhs); + + ~SBTypeEnumMember(); + + bool + IsValid() const; + + int64_t + GetValueAsSigned(); + + uint64_t + GetValueAsUnsigned(); + + const char * + GetName (); + + lldb::SBType + GetType (); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + %pythoncode %{ + __swig_getmethods__["name"] = GetName + if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this enum member as a string.''') + + __swig_getmethods__["type"] = GetType + if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this enum member.''') + + __swig_getmethods__["signed"] = GetValueAsSigned + if _newclass: signed = property(GetValueAsSigned, None, doc='''A read only property that returns the value of this enum member as a signed integer.''') + + __swig_getmethods__["unsigned"] = GetValueAsUnsigned + if _newclass: unsigned = property(GetValueAsUnsigned, None, doc='''A read only property that returns the value of this enum member as a unsigned integer.''') + %} + +protected: + friend class SBType; + friend class SBTypeEnumMemberList; + + void + reset (lldb_private::TypeEnumMemberImpl *); + + lldb_private::TypeEnumMemberImpl & + ref (); + + const lldb_private::TypeEnumMemberImpl & + ref () const; + + lldb::TypeEnumMemberImplSP m_opaque_sp; + + SBTypeEnumMember (const lldb::TypeEnumMemberImplSP &); +}; + +%feature( + "docstring", + "Represents a list of SBTypeEnumMembers." +) SBTypeEnumMemberList; + +class SBTypeEnumMemberList +{ +public: + SBTypeEnumMemberList(); + + SBTypeEnumMemberList(const SBTypeEnumMemberList& rhs); + + ~SBTypeEnumMemberList(); + + bool + IsValid(); + + void + Append (SBTypeEnumMember entry); + + SBTypeEnumMember + GetTypeEnumMemberAtIndex (uint32_t index); + + uint32_t + GetSize(); + + +private: + std::unique_ptr m_opaque_ap; +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBTypeFilter.i =================================================================== --- lldb/trunk/scripts/interface/SBTypeFilter.i +++ lldb/trunk/scripts/interface/SBTypeFilter.i @@ -0,0 +1,75 @@ +//===-- SWIG Interface for SBTypeFilter----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", + "Represents a filter that can be associated to one or more types. + ") SBTypeFilter; + + class SBTypeFilter + { + public: + + SBTypeFilter(); + + SBTypeFilter (uint32_t options); + + SBTypeFilter (const lldb::SBTypeFilter &rhs); + + ~SBTypeFilter (); + + bool + IsValid() const; + + bool + IsEqualTo (lldb::SBTypeFilter &rhs); + + uint32_t + GetNumberOfExpressionPaths (); + + const char* + GetExpressionPathAtIndex (uint32_t i); + + bool + ReplaceExpressionPathAtIndex (uint32_t i, const char* item); + + void + AppendExpressionPath (const char* item); + + void + Clear(); + + uint32_t + GetOptions(); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); + + bool + operator == (lldb::SBTypeFilter &rhs); + + bool + operator != (lldb::SBTypeFilter &rhs); + + %pythoncode %{ + __swig_getmethods__["options"] = GetOptions + __swig_setmethods__["options"] = SetOptions + if _newclass: options = property(GetOptions, SetOptions) + + __swig_getmethods__["count"] = GetNumberOfExpressionPaths + if _newclass: count = property(GetNumberOfExpressionPaths, None) + %} + + }; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBTypeFormat.i =================================================================== --- lldb/trunk/scripts/interface/SBTypeFormat.i +++ lldb/trunk/scripts/interface/SBTypeFormat.i @@ -0,0 +1,78 @@ +//===-- SWIG Interface for SBTypeFormat----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", + "Represents a format that can be associated to one or more types. + ") SBTypeFormat; + + class SBTypeFormat + { + public: + + SBTypeFormat(); + + SBTypeFormat (lldb::Format format, uint32_t options = 0); + + SBTypeFormat (const char* type, uint32_t options = 0); + + SBTypeFormat (const lldb::SBTypeFormat &rhs); + + ~SBTypeFormat (); + + bool + IsValid() const; + + bool + IsEqualTo (lldb::SBTypeFormat &rhs); + + lldb::Format + GetFormat (); + + const char* + GetTypeName (); + + uint32_t + GetOptions(); + + void + SetFormat (lldb::Format); + + void + SetTypeName (const char*); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + bool + operator == (lldb::SBTypeFormat &rhs); + + bool + operator != (lldb::SBTypeFormat &rhs); + + %pythoncode %{ + __swig_getmethods__["format"] = GetFormat + __swig_setmethods__["format"] = SetFormat + if _newclass: format = property(GetFormat, SetFormat) + + __swig_getmethods__["options"] = GetOptions + __swig_setmethods__["options"] = SetOptions + if _newclass: options = property(GetOptions, SetOptions) + %} + + }; + + +} // namespace lldb + Index: lldb/trunk/scripts/interface/SBTypeNameSpecifier.i =================================================================== --- lldb/trunk/scripts/interface/SBTypeNameSpecifier.i +++ lldb/trunk/scripts/interface/SBTypeNameSpecifier.i @@ -0,0 +1,68 @@ +//===-- SWIG Interface for SBTypeNameSpecifier---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", + "Represents a general way to provide a type name to LLDB APIs. + ") SBTypeNameSpecifier; + + class SBTypeNameSpecifier + { + public: + + SBTypeNameSpecifier(); + + SBTypeNameSpecifier (const char* name, + bool is_regex = false); + + SBTypeNameSpecifier (SBType type); + + SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs); + + ~SBTypeNameSpecifier (); + + bool + IsValid() const; + + bool + IsEqualTo (lldb::SBTypeNameSpecifier &rhs); + + const char* + GetName(); + + lldb::SBType + GetType (); + + bool + IsRegex(); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + bool + operator == (lldb::SBTypeNameSpecifier &rhs); + + bool + operator != (lldb::SBTypeNameSpecifier &rhs); + + %pythoncode %{ + __swig_getmethods__["name"] = GetName + if _newclass: name = property(GetName, None) + + __swig_getmethods__["is_regex"] = IsRegex + if _newclass: is_regex = property(IsRegex, None) + %} + + + }; + +} // namespace lldb + Index: lldb/trunk/scripts/interface/SBTypeSummary.i =================================================================== --- lldb/trunk/scripts/interface/SBTypeSummary.i +++ lldb/trunk/scripts/interface/SBTypeSummary.i @@ -0,0 +1,123 @@ +//===-- SWIG Interface for SBTypeSummary---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + class SBTypeSummaryOptions + { + public: + SBTypeSummaryOptions(); + + SBTypeSummaryOptions (const lldb::SBTypeSummaryOptions &rhs); + + ~SBTypeSummaryOptions (); + + bool + IsValid (); + + lldb::LanguageType + GetLanguage (); + + lldb::TypeSummaryCapping + GetCapping (); + + void + SetLanguage (lldb::LanguageType); + + void + SetCapping (lldb::TypeSummaryCapping); + }; + + %feature("docstring", + "Represents a summary that can be associated to one or more types. + ") SBTypeSummary; + + class SBTypeSummary + { + public: + + SBTypeSummary(); + + static SBTypeSummary + CreateWithSummaryString (const char* data, uint32_t options = 0); + + static SBTypeSummary + CreateWithFunctionName (const char* data, uint32_t options = 0); + + static SBTypeSummary + CreateWithScriptCode (const char* data, uint32_t options = 0); + + SBTypeSummary (const lldb::SBTypeSummary &rhs); + + ~SBTypeSummary (); + + bool + IsValid() const; + + bool + IsEqualTo (lldb::SBTypeSummary &rhs); + + bool + IsFunctionCode(); + + bool + IsFunctionName(); + + bool + IsSummaryString(); + + const char* + GetData (); + + void + SetSummaryString (const char* data); + + void + SetFunctionName (const char* data); + + void + SetFunctionCode (const char* data); + + uint32_t + GetOptions (); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + bool + operator == (lldb::SBTypeSummary &rhs); + + bool + operator != (lldb::SBTypeSummary &rhs); + + %pythoncode %{ + __swig_getmethods__["options"] = GetOptions + __swig_setmethods__["options"] = SetOptions + if _newclass: options = property(GetOptions, SetOptions) + + __swig_getmethods__["is_summary_string"] = IsSummaryString + if _newclass: is_summary_string = property(IsSummaryString, None) + + __swig_getmethods__["is_function_name"] = IsFunctionName + if _newclass: is_function_name = property(IsFunctionName, None) + + __swig_getmethods__["is_function_name"] = IsFunctionCode + if _newclass: is_function_name = property(IsFunctionCode, None) + + __swig_getmethods__["summary_data"] = GetData + if _newclass: summary_data = property(GetData, None) + %} + + }; + +} // namespace lldb + Index: lldb/trunk/scripts/interface/SBTypeSynthetic.i =================================================================== --- lldb/trunk/scripts/interface/SBTypeSynthetic.i +++ lldb/trunk/scripts/interface/SBTypeSynthetic.i @@ -0,0 +1,80 @@ +//===-- SWIG Interface for SBTypeSynthetic-------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", + "Represents a summary that can be associated to one or more types. + ") SBTypeSynthetic; + + class SBTypeSynthetic + { + public: + + SBTypeSynthetic(); + + static lldb::SBTypeSynthetic + CreateWithClassName (const char* data, uint32_t options = 0); + + static lldb::SBTypeSynthetic + CreateWithScriptCode (const char* data, uint32_t options = 0); + + SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs); + + ~SBTypeSynthetic (); + + bool + IsValid() const; + + bool + IsEqualTo (lldb::SBTypeSynthetic &rhs); + + bool + IsClassCode(); + + const char* + GetData (); + + void + SetClassName (const char* data); + + void + SetClassCode (const char* data); + + uint32_t + GetOptions (); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + bool + operator == (lldb::SBTypeSynthetic &rhs); + + bool + operator != (lldb::SBTypeSynthetic &rhs); + + %pythoncode %{ + __swig_getmethods__["options"] = GetOptions + __swig_setmethods__["options"] = SetOptions + if _newclass: options = property(GetOptions, SetOptions) + + __swig_getmethods__["contains_code"] = IsClassCode + if _newclass: contains_code = property(IsClassCode, None) + + __swig_getmethods__["synthetic_data"] = GetData + if _newclass: synthetic_data = property(GetData, None) + %} + + }; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBUnixSignals.i =================================================================== --- lldb/trunk/scripts/interface/SBUnixSignals.i +++ lldb/trunk/scripts/interface/SBUnixSignals.i @@ -0,0 +1,74 @@ +//===-- SWIG Interface for SBUnixSignals ------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Allows you to manipulate LLDB's signal disposition" +) SBUnixSignals; +class SBUnixSignals +{ +public: + SBUnixSignals (); + + SBUnixSignals (const lldb::SBUnixSignals &rhs); + + ~SBUnixSignals(); + + void + Clear (); + + bool + IsValid () const; + + const char * + GetSignalAsCString (int32_t signo) const; + + int32_t + GetSignalNumberFromName (const char *name) const; + + bool + GetShouldSuppress (int32_t signo) const; + + bool + SetShouldSuppress (int32_t signo, + bool value); + + bool + GetShouldStop (int32_t signo) const; + + bool + SetShouldStop (int32_t signo, + bool value); + + bool + GetShouldNotify (int32_t signo) const; + + bool + SetShouldNotify (int32_t signo, bool value); + + int32_t + GetNumSignals () const; + + int32_t + GetSignalAtIndex (int32_t index) const; + + %pythoncode %{ + def get_unix_signals_list(self): + signals = [] + for idx in range(0, self.GetNumSignals()): + signals.append(self.GetSignalAtIndex(sig)) + return signals + + __swig_getmethods__["signals"] = get_unix_signals_list + if _newclass: threads = property(get_unix_signals_list, None, doc='''A read only property that returns a list() of valid signal numbers for this platform.''') + %} +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBValue.i =================================================================== --- lldb/trunk/scripts/interface/SBValue.i +++ lldb/trunk/scripts/interface/SBValue.i @@ -0,0 +1,520 @@ +//===-- SWIG Interface for SBValue ------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents the value of a variable, a register, or an expression. + +SBValue supports iteration through its child, which in turn is represented +as an SBValue. For example, we can get the general purpose registers of a +frame as an SBValue, and iterate through all the registers, + + registerSet = frame.GetRegisters() # Returns an SBValueList. + for regs in registerSet: + if 'general purpose registers' in regs.getName().lower(): + GPRs = regs + break + + print '%s (number of children = %d):' % (GPRs.GetName(), GPRs.GetNumChildren()) + for reg in GPRs: + print 'Name: ', reg.GetName(), ' Value: ', reg.GetValue() + +produces the output: + +General Purpose Registers (number of children = 21): +Name: rax Value: 0x0000000100000c5c +Name: rbx Value: 0x0000000000000000 +Name: rcx Value: 0x00007fff5fbffec0 +Name: rdx Value: 0x00007fff5fbffeb8 +Name: rdi Value: 0x0000000000000001 +Name: rsi Value: 0x00007fff5fbffea8 +Name: rbp Value: 0x00007fff5fbffe80 +Name: rsp Value: 0x00007fff5fbffe60 +Name: r8 Value: 0x0000000008668682 +Name: r9 Value: 0x0000000000000000 +Name: r10 Value: 0x0000000000001200 +Name: r11 Value: 0x0000000000000206 +Name: r12 Value: 0x0000000000000000 +Name: r13 Value: 0x0000000000000000 +Name: r14 Value: 0x0000000000000000 +Name: r15 Value: 0x0000000000000000 +Name: rip Value: 0x0000000100000dae +Name: rflags Value: 0x0000000000000206 +Name: cs Value: 0x0000000000000027 +Name: fs Value: 0x0000000000000010 +Name: gs Value: 0x0000000000000048 + +See also linked_list_iter() for another perspective on how to iterate through an +SBValue instance which interprets the value object as representing the head of a +linked list." +) SBValue; +class SBValue +{ +public: + SBValue (); + + SBValue (const SBValue &rhs); + + ~SBValue (); + + bool + IsValid(); + + void + Clear(); + + SBError + GetError(); + + lldb::user_id_t + GetID (); + + const char * + GetName(); + + const char * + GetTypeName (); + + const char * + GetDisplayTypeName (); + + size_t + GetByteSize (); + + bool + IsInScope (); + + lldb::Format + GetFormat (); + + void + SetFormat (lldb::Format format); + + const char * + GetValue (); + + int64_t + GetValueAsSigned(SBError& error, int64_t fail_value=0); + + uint64_t + GetValueAsUnsigned(SBError& error, uint64_t fail_value=0); + + int64_t + GetValueAsSigned(int64_t fail_value=0); + + uint64_t + GetValueAsUnsigned(uint64_t fail_value=0); + + ValueType + GetValueType (); + + bool + GetValueDidChange (); + + const char * + GetSummary (); + + const char * + GetSummary (lldb::SBStream& stream, + lldb::SBTypeSummaryOptions& options); + + const char * + GetObjectDescription (); + + const char * + GetTypeValidatorResult (); + + lldb::SBValue + GetDynamicValue (lldb::DynamicValueType use_dynamic); + + lldb::SBValue + GetStaticValue (); + + lldb::SBValue + GetNonSyntheticValue (); + + lldb::DynamicValueType + GetPreferDynamicValue (); + + void + SetPreferDynamicValue (lldb::DynamicValueType use_dynamic); + + bool + GetPreferSyntheticValue (); + + void + SetPreferSyntheticValue (bool use_synthetic); + + bool + IsDynamic(); + + bool + IsSynthetic (); + + const char * + GetLocation (); + + bool + SetValueFromCString (const char *value_str); + + bool + SetValueFromCString (const char *value_str, lldb::SBError& error); + + lldb::SBTypeFormat + GetTypeFormat (); + + lldb::SBTypeSummary + GetTypeSummary (); + + lldb::SBTypeFilter + GetTypeFilter (); + + lldb::SBTypeSynthetic + GetTypeSynthetic (); + + lldb::SBValue + GetChildAtIndex (uint32_t idx); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Get a child value by index from a value. + /// + /// Structs, unions, classes, arrays and pointers have child + /// values that can be access by index. + /// + /// Structs and unions access child members using a zero based index + /// for each child member. For + /// + /// Classes reserve the first indexes for base classes that have + /// members (empty base classes are omitted), and all members of the + /// current class will then follow the base classes. + /// + /// Pointers differ depending on what they point to. If the pointer + /// points to a simple type, the child at index zero + /// is the only child value available, unless \a synthetic_allowed + /// is \b true, in which case the pointer will be used as an array + /// and can create 'synthetic' child values using positive or + /// negative indexes. If the pointer points to an aggregate type + /// (an array, class, union, struct), then the pointee is + /// transparently skipped and any children are going to be the indexes + /// of the child values within the aggregate type. For example if + /// we have a 'Point' type and we have a SBValue that contains a + /// pointer to a 'Point' type, then the child at index zero will be + /// the 'x' member, and the child at index 1 will be the 'y' member + /// (the child at index zero won't be a 'Point' instance). + /// + /// Arrays have a preset number of children that can be accessed by + /// index and will returns invalid child values for indexes that are + /// out of bounds unless the \a synthetic_allowed is \b true. In this + /// case the array can create 'synthetic' child values for indexes + /// that aren't in the array bounds using positive or negative + /// indexes. + /// + /// @param[in] idx + /// The index of the child value to get + /// + /// @param[in] use_dynamic + /// An enumeration that specifies whether to get dynamic values, + /// and also if the target can be run to figure out the dynamic + /// type of the child value. + /// + /// @param[in] synthetic_allowed + /// If \b true, then allow child values to be created by index + /// for pointers and arrays for indexes that normally wouldn't + /// be allowed. + /// + /// @return + /// A new SBValue object that represents the child member value. + //------------------------------------------------------------------ + ") GetChildAtIndex; + lldb::SBValue + GetChildAtIndex (uint32_t idx, + lldb::DynamicValueType use_dynamic, + bool can_create_synthetic); + + lldb::SBValue + CreateChildAtOffset (const char *name, uint32_t offset, lldb::SBType type); + + lldb::SBValue + SBValue::Cast (lldb::SBType type); + + lldb::SBValue + CreateValueFromExpression (const char *name, const char* expression); + + lldb::SBValue + CreateValueFromExpression (const char *name, const char* expression, SBExpressionOptions &options); + + lldb::SBValue + CreateValueFromAddress(const char* name, lldb::addr_t address, lldb::SBType type); + + lldb::SBValue + CreateValueFromData (const char* name, + lldb::SBData data, + lldb::SBType type); + + lldb::SBType + GetType(); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Returns the child member index. + /// + /// Matches children of this object only and will match base classes and + /// member names if this is a clang typed object. + /// + /// @param[in] name + /// The name of the child value to get + /// + /// @return + /// An index to the child member value. + //------------------------------------------------------------------ + ") GetIndexOfChildWithName; + uint32_t + GetIndexOfChildWithName (const char *name); + + lldb::SBValue + GetChildMemberWithName (const char *name); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Returns the child member value. + /// + /// Matches child members of this object and child members of any base + /// classes. + /// + /// @param[in] name + /// The name of the child value to get + /// + /// @param[in] use_dynamic + /// An enumeration that specifies whether to get dynamic values, + /// and also if the target can be run to figure out the dynamic + /// type of the child value. + /// + /// @return + /// A new SBValue object that represents the child member value. + //------------------------------------------------------------------ + ") GetChildMemberWithName; + lldb::SBValue + GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic); + + %feature("docstring", "Expands nested expressions like .a->b[0].c[1]->d." + ) GetValueForExpressionPath; + lldb::SBValue + GetValueForExpressionPath(const char* expr_path); + + lldb::SBDeclaration + GetDeclaration (); + + bool + MightHaveChildren (); + + bool + IsRuntimeSupportValue (); + + uint32_t + GetNumChildren (); + + void * + GetOpaqueType(); + + lldb::SBValue + Dereference (); + + lldb::SBValue + AddressOf(); + + bool + TypeIsPointerType (); + + lldb::SBTarget + GetTarget(); + + lldb::SBProcess + GetProcess(); + + lldb::SBThread + GetThread(); + + lldb::SBFrame + GetFrame(); + + %feature("docstring", " + /// Find and watch a variable. + /// It returns an SBWatchpoint, which may be invalid. + ") Watch; + lldb::SBWatchpoint + Watch (bool resolve_location, bool read, bool write, SBError &error); + + %feature("docstring", " + /// Find and watch the location pointed to by a variable. + /// It returns an SBWatchpoint, which may be invalid. + ") WatchPointee; + lldb::SBWatchpoint + WatchPointee (bool resolve_location, bool read, bool write, SBError &error); + + bool + GetDescription (lldb::SBStream &description); + + bool + GetExpressionPath (lldb::SBStream &description); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Get an SBData wrapping what this SBValue points to. + /// + /// This method will dereference the current SBValue, if its + /// data type is a T* or T[], and extract item_count elements + /// of type T from it, copying their contents in an SBData. + /// + /// @param[in] item_idx + /// The index of the first item to retrieve. For an array + /// this is equivalent to array[item_idx], for a pointer + /// to *(pointer + item_idx). In either case, the measurement + /// unit for item_idx is the sizeof(T) rather than the byte + /// + /// @param[in] item_count + /// How many items should be copied into the output. By default + /// only one item is copied, but more can be asked for. + /// + /// @return + /// An SBData with the contents of the copied items, on success. + /// An empty SBData otherwise. + //------------------------------------------------------------------ + ") GetPointeeData; + lldb::SBData + GetPointeeData (uint32_t item_idx = 0, + uint32_t item_count = 1); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Get an SBData wrapping the contents of this SBValue. + /// + /// This method will read the contents of this object in memory + /// and copy them into an SBData for future use. + /// + /// @return + /// An SBData with the contents of this SBValue, on success. + /// An empty SBData otherwise. + //------------------------------------------------------------------ + ") GetData; + lldb::SBData + GetData (); + + bool + SetData (lldb::SBData &data, lldb::SBError& error); + + lldb::addr_t + GetLoadAddress(); + + lldb::SBAddress + GetAddress(); + + lldb::SBValue + Persist (); + + %feature("docstring", "Returns an expression path for this value." + ) GetExpressionPath; + bool + GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes); + + %pythoncode %{ + def __get_dynamic__ (self): + '''Helper function for the "SBValue.dynamic" property.''' + return self.GetDynamicValue (eDynamicCanRunTarget) + + __swig_getmethods__["name"] = GetName + if _newclass: name = property(GetName, None, doc='''A read only property that returns the name of this value as a string.''') + + __swig_getmethods__["type"] = GetType + if _newclass: type = property(GetType, None, doc='''A read only property that returns a lldb.SBType object that represents the type for this value.''') + + __swig_getmethods__["size"] = GetByteSize + if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this value.''') + + __swig_getmethods__["is_in_scope"] = IsInScope + if _newclass: is_in_scope = property(IsInScope, None, doc='''A read only property that returns a boolean value that indicates whether this value is currently lexically in scope.''') + + __swig_getmethods__["format"] = GetFormat + __swig_setmethods__["format"] = SetFormat + if _newclass: format = property(GetName, SetFormat, doc='''A read/write property that gets/sets the format used for lldb.SBValue().GetValue() for this value. See enumerations that start with "lldb.eFormat".''') + + __swig_getmethods__["value"] = GetValue + __swig_setmethods__["value"] = SetValueFromCString + if _newclass: value = property(GetValue, SetValueFromCString, doc='''A read/write property that gets/sets value from a string.''') + + __swig_getmethods__["value_type"] = GetValueType + if _newclass: value_type = property(GetValueType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eValueType") that represents the type of this value (local, argument, global, register, etc.).''') + + __swig_getmethods__["changed"] = GetValueDidChange + if _newclass: changed = property(GetValueDidChange, None, doc='''A read only property that returns a boolean value that indicates if this value has changed since it was last updated.''') + + __swig_getmethods__["data"] = GetData + if _newclass: data = property(GetData, None, doc='''A read only property that returns an lldb object (lldb.SBData) that represents the bytes that make up the value for this object.''') + + __swig_getmethods__["load_addr"] = GetLoadAddress + if _newclass: load_addr = property(GetLoadAddress, None, doc='''A read only property that returns the load address of this value as an integer.''') + + __swig_getmethods__["addr"] = GetAddress + if _newclass: addr = property(GetAddress, None, doc='''A read only property that returns an lldb.SBAddress that represents the address of this value if it is in memory.''') + + __swig_getmethods__["deref"] = Dereference + if _newclass: deref = property(Dereference, None, doc='''A read only property that returns an lldb.SBValue that is created by dereferencing this value.''') + + __swig_getmethods__["address_of"] = AddressOf + if _newclass: address_of = property(AddressOf, None, doc='''A read only property that returns an lldb.SBValue that represents the address-of this value.''') + + __swig_getmethods__["error"] = GetError + if _newclass: error = property(GetError, None, doc='''A read only property that returns the lldb.SBError that represents the error from the last time the variable value was calculated.''') + + __swig_getmethods__["summary"] = GetSummary + if _newclass: summary = property(GetSummary, None, doc='''A read only property that returns the summary for this value as a string''') + + __swig_getmethods__["description"] = GetObjectDescription + if _newclass: description = property(GetObjectDescription, None, doc='''A read only property that returns the language-specific description of this value as a string''') + + __swig_getmethods__["dynamic"] = __get_dynamic__ + if _newclass: dynamic = property(__get_dynamic__, None, doc='''A read only property that returns an lldb.SBValue that is created by finding the dynamic type of this value.''') + + __swig_getmethods__["location"] = GetLocation + if _newclass: location = property(GetLocation, None, doc='''A read only property that returns the location of this value as a string.''') + + __swig_getmethods__["target"] = GetTarget + if _newclass: target = property(GetTarget, None, doc='''A read only property that returns the lldb.SBTarget that this value is associated with.''') + + __swig_getmethods__["process"] = GetProcess + if _newclass: process = property(GetProcess, None, doc='''A read only property that returns the lldb.SBProcess that this value is associated with, the returned value might be invalid and should be tested.''') + + __swig_getmethods__["thread"] = GetThread + if _newclass: thread = property(GetThread, None, doc='''A read only property that returns the lldb.SBThread that this value is associated with, the returned value might be invalid and should be tested.''') + + __swig_getmethods__["frame"] = GetFrame + if _newclass: frame = property(GetFrame, None, doc='''A read only property that returns the lldb.SBFrame that this value is associated with, the returned value might be invalid and should be tested.''') + + __swig_getmethods__["num_children"] = GetNumChildren + if _newclass: num_children = property(GetNumChildren, None, doc='''A read only property that returns the number of child lldb.SBValues that this value has.''') + + __swig_getmethods__["unsigned"] = GetValueAsUnsigned + if _newclass: unsigned = property(GetValueAsUnsigned, None, doc='''A read only property that returns the value of this SBValue as an usigned integer.''') + + __swig_getmethods__["signed"] = GetValueAsSigned + if _newclass: signed = property(GetValueAsSigned, None, doc='''A read only property that returns the value of this SBValue as a signed integer.''') + + def get_expr_path(self): + s = SBStream() + self.GetExpressionPath (s) + return s.GetData() + + __swig_getmethods__["path"] = get_expr_path + if _newclass: path = property(get_expr_path, None, doc='''A read only property that returns the expression path that one can use to reach this value in an expression.''') + %} + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBValueList.i =================================================================== --- lldb/trunk/scripts/interface/SBValueList.i +++ lldb/trunk/scripts/interface/SBValueList.i @@ -0,0 +1,142 @@ +//===-- SWIG Interface for SBValueList --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents a collection of SBValues. Both SBFrame's GetVariables() and +GetRegisters() return a SBValueList. + +SBValueList supports SBValue iteration. For example (from test/lldbutil.py), + +def get_registers(frame, kind): + '''Returns the registers given the frame and the kind of registers desired. + + Returns None if there's no such kind. + ''' + registerSet = frame.GetRegisters() # Return type of SBValueList. + for value in registerSet: + if kind.lower() in value.GetName().lower(): + return value + + return None + +def get_GPRs(frame): + '''Returns the general purpose registers of the frame as an SBValue. + + The returned SBValue object is iterable. An example: + ... + from lldbutil import get_GPRs + regs = get_GPRs(frame) + for reg in regs: + print '%s => %s' % (reg.GetName(), reg.GetValue()) + ... + ''' + return get_registers(frame, 'general purpose') + +def get_FPRs(frame): + '''Returns the floating point registers of the frame as an SBValue. + + The returned SBValue object is iterable. An example: + ... + from lldbutil import get_FPRs + regs = get_FPRs(frame) + for reg in regs: + print '%s => %s' % (reg.GetName(), reg.GetValue()) + ... + ''' + return get_registers(frame, 'floating point') + +def get_ESRs(frame): + '''Returns the exception state registers of the frame as an SBValue. + + The returned SBValue object is iterable. An example: + ... + from lldbutil import get_ESRs + regs = get_ESRs(frame) + for reg in regs: + print '%s => %s' % (reg.GetName(), reg.GetValue()) + ... + ''' + return get_registers(frame, 'exception state')" +) SBValueList; +class SBValueList +{ +public: + + SBValueList (); + + SBValueList (const lldb::SBValueList &rhs); + + ~SBValueList(); + + bool + IsValid() const; + + void + Clear(); + + void + Append (const lldb::SBValue &val_obj); + + void + Append (const lldb::SBValueList& value_list); + + uint32_t + GetSize() const; + + lldb::SBValue + GetValueAtIndex (uint32_t idx) const; + + lldb::SBValue + FindValueObjectByUID (lldb::user_id_t uid); + + lldb::SBValue + GetFirstValueByName (const char* name) const; + + %pythoncode %{ + def __len__(self): + return int(self.GetSize()) + + def __getitem__(self, key): + count = len(self) + #------------------------------------------------------------ + # Access with "int" to get Nth item in the list + #------------------------------------------------------------ + if type(key) is int: + if key < count: + return self.GetValueAtIndex(key) + #------------------------------------------------------------ + # Access with "str" to get values by name + #------------------------------------------------------------ + elif type(key) is str: + matches = [] + for idx in range(count): + value = self.GetValueAtIndex(idx) + if value.name == key: + matches.append(value) + return matches + #------------------------------------------------------------ + # Match with regex + #------------------------------------------------------------ + elif isinstance(key, type(re.compile('.'))): + matches = [] + for idx in range(count): + value = self.GetValueAtIndex(idx) + re_match = key.search(value.name) + if re_match: + matches.append(value) + return matches + + %} + + +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBVariablesOptions.i =================================================================== --- lldb/trunk/scripts/interface/SBVariablesOptions.i +++ lldb/trunk/scripts/interface/SBVariablesOptions.i @@ -0,0 +1,61 @@ +//===-- SWIG Interface for SBVariablesOptions ----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBVariablesOptions +{ +public: + SBVariablesOptions (); + + SBVariablesOptions (const SBVariablesOptions& options); + + ~SBVariablesOptions (); + + bool + IsValid () const; + + bool + GetIncludeArguments () const; + + void + SetIncludeArguments (bool); + + bool + GetIncludeLocals () const; + + void + SetIncludeLocals (bool); + + bool + GetIncludeStatics () const; + + void + SetIncludeStatics (bool); + + bool + GetInScopeOnly () const; + + void + SetInScopeOnly (bool); + + bool + GetIncludeRuntimeSupportValues () const; + + void + SetIncludeRuntimeSupportValues (bool); + + lldb::DynamicValueType + GetUseDynamic () const; + + void + SetUseDynamic (lldb::DynamicValueType); +}; + +} // namespace lldb Index: lldb/trunk/scripts/interface/SBWatchpoint.i =================================================================== --- lldb/trunk/scripts/interface/SBWatchpoint.i +++ lldb/trunk/scripts/interface/SBWatchpoint.i @@ -0,0 +1,99 @@ +//===-- SWIG Interface for SBWatchpoint -----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents an instance of watchpoint for a specific target program. + +A watchpoint is determined by the address and the byte size that resulted in +this particular instantiation. Each watchpoint has its settable options. + +See also SBTarget.watchpoint_iter() for example usage of iterating through the +watchpoints of the target." +) SBWatchpoint; +class SBWatchpoint +{ +public: + + SBWatchpoint (); + + SBWatchpoint (const lldb::SBWatchpoint &rhs); + + ~SBWatchpoint (); + + bool + IsValid(); + + SBError + GetError(); + + watch_id_t + GetID (); + + %feature("docstring", " + //------------------------------------------------------------------ + /// With -1 representing an invalid hardware index. + //------------------------------------------------------------------ + ") GetHardwareIndex; + int32_t + GetHardwareIndex (); + + lldb::addr_t + GetWatchAddress (); + + size_t + GetWatchSize(); + + void + SetEnabled(bool enabled); + + bool + IsEnabled (); + + uint32_t + GetHitCount (); + + uint32_t + GetIgnoreCount (); + + void + SetIgnoreCount (uint32_t n); + + %feature("docstring", " + //------------------------------------------------------------------ + /// Get the condition expression for the watchpoint. + //------------------------------------------------------------------ + ") GetCondition; + const char * + GetCondition (); + + %feature("docstring", " + //-------------------------------------------------------------------------- + /// The watchpoint stops only if the condition expression evaluates to true. + //-------------------------------------------------------------------------- + ") SetCondition; + void + SetCondition (const char *condition); + + bool + GetDescription (lldb::SBStream &description, DescriptionLevel level); + + static bool + EventIsWatchpointEvent (const lldb::SBEvent &event); + + static lldb::WatchpointEventType + GetWatchpointEventTypeFromEvent (const lldb::SBEvent& event); + + static lldb::SBWatchpoint + GetWatchpointFromEvent (const lldb::SBEvent& event); + +}; + +} // namespace lldb Index: lldb/trunk/scripts/lldb.swig =================================================================== --- lldb/trunk/scripts/lldb.swig +++ lldb/trunk/scripts/lldb.swig @@ -129,63 +129,63 @@ %include "lldb/API/SBDefines.h" /* Python interface files with docstrings. */ -%include "./Python/interface/SBAddress.i" -%include "./Python/interface/SBAttachInfo.i" -%include "./Python/interface/SBBlock.i" -%include "./Python/interface/SBBreakpoint.i" -%include "./Python/interface/SBBreakpointLocation.i" -%include "./Python/interface/SBBroadcaster.i" -%include "./Python/interface/SBCommandInterpreter.i" -%include "./Python/interface/SBCommandReturnObject.i" -%include "./Python/interface/SBCommunication.i" -%include "./Python/interface/SBCompileUnit.i" -%include "./Python/interface/SBData.i" -%include "./Python/interface/SBDebugger.i" -%include "./Python/interface/SBDeclaration.i" -%include "./Python/interface/SBError.i" -%include "./Python/interface/SBEvent.i" -%include "./Python/interface/SBExecutionContext.i" -%include "./Python/interface/SBExpressionOptions.i" -%include "./Python/interface/SBFileSpec.i" -%include "./Python/interface/SBFileSpecList.i" -%include "./Python/interface/SBFrame.i" -%include "./Python/interface/SBFunction.i" -%include "./Python/interface/SBHostOS.i" -%include "./Python/interface/SBInstruction.i" -%include "./Python/interface/SBInstructionList.i" -%include "./Python/interface/SBLaunchInfo.i" -%include "./Python/interface/SBLineEntry.i" -%include "./Python/interface/SBListener.i" -%include "./Python/interface/SBModule.i" -%include "./Python/interface/SBModuleSpec.i" -%include "./Python/interface/SBPlatform.i" -%include "./Python/interface/SBProcess.i" -%include "./Python/interface/SBQueue.i" -%include "./Python/interface/SBQueueItem.i" -%include "./Python/interface/SBSection.i" -%include "./Python/interface/SBSourceManager.i" -%include "./Python/interface/SBStream.i" -%include "./Python/interface/SBStringList.i" -%include "./Python/interface/SBSymbol.i" -%include "./Python/interface/SBSymbolContext.i" -%include "./Python/interface/SBSymbolContextList.i" -%include "./Python/interface/SBTarget.i" -%include "./Python/interface/SBThread.i" -%include "./Python/interface/SBThreadCollection.i" -%include "./Python/interface/SBThreadPlan.i" -%include "./Python/interface/SBType.i" -%include "./Python/interface/SBTypeCategory.i" -%include "./Python/interface/SBTypeEnumMember.i" -%include "./Python/interface/SBTypeFilter.i" -%include "./Python/interface/SBTypeFormat.i" -%include "./Python/interface/SBTypeNameSpecifier.i" -%include "./Python/interface/SBTypeSummary.i" -%include "./Python/interface/SBTypeSynthetic.i" -%include "./Python/interface/SBValue.i" -%include "./Python/interface/SBValueList.i" -%include "./Python/interface/SBVariablesOptions.i" -%include "./Python/interface/SBWatchpoint.i" -%include "./Python/interface/SBUnixSignals.i" +%include "./interface/SBAddress.i" +%include "./interface/SBAttachInfo.i" +%include "./interface/SBBlock.i" +%include "./interface/SBBreakpoint.i" +%include "./interface/SBBreakpointLocation.i" +%include "./interface/SBBroadcaster.i" +%include "./interface/SBCommandInterpreter.i" +%include "./interface/SBCommandReturnObject.i" +%include "./interface/SBCommunication.i" +%include "./interface/SBCompileUnit.i" +%include "./interface/SBData.i" +%include "./interface/SBDebugger.i" +%include "./interface/SBDeclaration.i" +%include "./interface/SBError.i" +%include "./interface/SBEvent.i" +%include "./interface/SBExecutionContext.i" +%include "./interface/SBExpressionOptions.i" +%include "./interface/SBFileSpec.i" +%include "./interface/SBFileSpecList.i" +%include "./interface/SBFrame.i" +%include "./interface/SBFunction.i" +%include "./interface/SBHostOS.i" +%include "./interface/SBInstruction.i" +%include "./interface/SBInstructionList.i" +%include "./interface/SBLaunchInfo.i" +%include "./interface/SBLineEntry.i" +%include "./interface/SBListener.i" +%include "./interface/SBModule.i" +%include "./interface/SBModuleSpec.i" +%include "./interface/SBPlatform.i" +%include "./interface/SBProcess.i" +%include "./interface/SBQueue.i" +%include "./interface/SBQueueItem.i" +%include "./interface/SBSection.i" +%include "./interface/SBSourceManager.i" +%include "./interface/SBStream.i" +%include "./interface/SBStringList.i" +%include "./interface/SBSymbol.i" +%include "./interface/SBSymbolContext.i" +%include "./interface/SBSymbolContextList.i" +%include "./interface/SBTarget.i" +%include "./interface/SBThread.i" +%include "./interface/SBThreadCollection.i" +%include "./interface/SBThreadPlan.i" +%include "./interface/SBType.i" +%include "./interface/SBTypeCategory.i" +%include "./interface/SBTypeEnumMember.i" +%include "./interface/SBTypeFilter.i" +%include "./interface/SBTypeFormat.i" +%include "./interface/SBTypeNameSpecifier.i" +%include "./interface/SBTypeSummary.i" +%include "./interface/SBTypeSynthetic.i" +%include "./interface/SBValue.i" +%include "./interface/SBValueList.i" +%include "./interface/SBVariablesOptions.i" +%include "./interface/SBWatchpoint.i" +%include "./interface/SBUnixSignals.i" %include "./Python/python-extensions.swig" Index: lldb/trunk/source/Interpreter/Makefile =================================================================== --- lldb/trunk/source/Interpreter/Makefile +++ lldb/trunk/source/Interpreter/Makefile @@ -36,7 +36,7 @@ SWIG_SOURCES := $(shell find $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts -type f -name '*.swig' -print) LLDBWrapPython.cpp lldb.py: $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/Python/modify-python-lldb.py \ - $(wildcard $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/Python/interface/*.i) \ + $(wildcard $(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/interface/*.i) \ ${SWIG_SOURCES} $(Echo) Generating LLDBWrapPython.cpp $(Verb) "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/build-swig-wrapper-classes.sh" "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)" "$(PROJ_OBJ_DIR)" "$(PROJ_OBJ_DIR)" "$(PYTHON_DIR)" -m $(if $(DISABLE_AUTO_DEPENDENCIES),,-M) Index: lldb/trunk/www/SB-api-coding-rules.html =================================================================== --- lldb/trunk/www/SB-api-coding-rules.html +++ lldb/trunk/www/SB-api-coding-rules.html @@ -59,7 +59,7 @@

Another piece of the SB API infrastructure is the Python (or other script interpreter) customization. SWIG allows you to add property access, iterators and documentation to classes, but to do that you have to use a Swig interface file in place of the .h file. Those files have a different format than a straight C++ header file. These - files are called SB<ClassName>.i, and live in "scripts/Python/interface". They are constructed by + files are called SB<ClassName>.i, and live in "scripts/interface". They are constructed by starting with the associated .h file, and adding documentation and the Python decorations, etc. We do this in a decidedly low-tech way, by maintaining the two files in parallel. That simplifies the build process, but it does mean that if you add a method to the C++ API's for an SB class, you have