Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@ -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

View File

@ -0,0 +1,116 @@
//===-- 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 char *path, bool wait_for, bool async);
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);
void
SetWaitForLaunch (bool b, bool async);
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

View File

@ -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

View File

@ -0,0 +1,332 @@
//===-- 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 comparison methods which allow the API program to use,
if aBreakpoint == bBreakpoint:
...
to compare two breakpoints for equality."
) SBBreakpoint;
class SBBreakpoint
{
public:
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 SetAutoContinue(bool auto_continue);
bool GetAutoContinue();
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);
void SetCommandLineCommands(SBStringList &commands);
bool GetCommandLineCommands(SBStringList &commands);
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
GetDescription(lldb::SBStream &description, bool include_locations);
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 %{
class locations_access(object):
'''A helper object that will lazily hand out locations for a breakpoint when supplied an index.'''
def __init__(self, sbbreakpoint):
self.sbbreakpoint = sbbreakpoint
def __len__(self):
if self.sbbreakpoint:
return int(self.sbbreakpoint.GetNumLocations())
return 0
def __getitem__(self, key):
if type(key) is int and key < len(self):
return self.sbbreakpoint.GetLocationAtIndex(key)
return None
def get_locations_access_object(self):
'''An accessor function that returns a locations_access() object which allows lazy location access from a lldb.SBBreakpoint object.'''
return self.locations_access (self)
def get_breakpoint_location_list(self):
'''An accessor function that returns a list() that contains all locations in a lldb.SBBreakpoint object.'''
locations = []
accessor = self.get_locations_access_object()
for idx in range(len(accessor)):
locations.append(accessor[idx])
return locations
__swig_getmethods__["locations"] = get_breakpoint_location_list
if _newclass: locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''')
__swig_getmethods__["location"] = get_locations_access_object
if _newclass: location = property(get_locations_access_object, None, doc='''A read only property that returns an object that can access locations by index (not location ID) (location = bkpt.location[12]).''')
__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.''')
%}
};
class SBBreakpointListImpl;
class LLDB_API SBBreakpointList
{
public:
SBBreakpointList(SBTarget &target);
~SBBreakpointList();
size_t GetSize() const;
SBBreakpoint
GetBreakpointAtIndex(size_t idx);
SBBreakpoint
FindBreakpointByID(lldb::break_id_t);
void Append(const SBBreakpoint &sb_bkpt);
bool AppendIfUnique(const SBBreakpoint &sb_bkpt);
void AppendByID (lldb::break_id_t id);
void Clear();
private:
std::shared_ptr<SBBreakpointListImpl> m_opaque_sp;
};
} // namespace lldb

View File

@ -0,0 +1,141 @@
//===-- 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
GetHitCount ();
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 ();
bool GetAutoContinue();
void SetAutoContinue(bool auto_continue);
%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 SetCommandLineCommands(SBStringList &commands);
bool GetCommandLineCommands(SBStringList &commands);
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

View File

@ -0,0 +1,111 @@
//===-- SWIG interface for SBBreakpointName.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 {
%feature("docstring",
"Represents a breakpoint name registered in a given SBTarget.
Breakpoint names provide a way to act on groups of breakpoints. When you add a
name to a group of breakpoints, you can then use the name in all the command
line lldb commands for that name. You can also configure the SBBreakpointName
options and those options will be propagated to any SBBreakpoints currently
using that name. Adding a name to a breakpoint will also apply any of the
set options to that breakpoint.
You can also set permissions on a breakpoint name to disable listing, deleting
and disabling breakpoints. That will disallow the given operation for breakpoints
except when the breakpoint is mentioned by ID. So for instance deleting all the
breakpoints won't delete breakpoints so marked."
) SBBreakpointName;
class LLDB_API SBBreakpointName {
public:
SBBreakpointName();
SBBreakpointName(SBTarget &target, const char *name);
SBBreakpointName(SBBreakpoint &bkpt, const char *name);
SBBreakpointName(const lldb::SBBreakpointName &rhs);
~SBBreakpointName();
const lldb::SBBreakpointName &operator=(const lldb::SBBreakpointName &rhs);
// Tests to see if the opaque breakpoint object in this object matches the
// opaque breakpoint object in "rhs".
bool operator==(const lldb::SBBreakpointName &rhs);
bool operator!=(const lldb::SBBreakpointName &rhs);
bool IsValid() const;
const char *GetName() const;
void SetEnabled(bool enable);
bool IsEnabled();
void SetOneShot(bool one_shot);
bool IsOneShot() const;
void SetIgnoreCount(uint32_t count);
uint32_t GetIgnoreCount() const;
void SetCondition(const char *condition);
const char *GetCondition();
void SetAutoContinue(bool auto_continue);
bool GetAutoContinue();
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;
void SetScriptCallbackFunction(const char *callback_function_name);
void SetCommandLineCommands(SBStringList &commands);
bool GetCommandLineCommands(SBStringList &commands);
SBError SetScriptCallbackBody(const char *script_body_text);
const char *GetHelpString() const;
void SetHelpString(const char *help_string);
bool GetAllowList() const;
void SetAllowList(bool value);
bool GetAllowDelete();
void SetAllowDelete(bool value);
bool GetAllowDisable();
void SetAllowDisable(bool value);
bool GetDescription(lldb::SBStream &description);
};
} // namespace lldb

View File

@ -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

View File

@ -0,0 +1,220 @@
//===-- 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<lldb_private::CommandInterpreterRunOptions> 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 ();
bool
WasInterrupted () const;
};
} // namespace lldb

View File

@ -0,0 +1,113 @@
//===-- 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);
// wrapping here so that lldb takes ownership of the
// new FILE* created inside of the swig interface
%extend {
void SetImmediateOutputFile(FILE *fh) {
self->SetImmediateOutputFile(fh, true);
}
void SetImmediateErrorFile(FILE *fh) {
self->SetImmediateErrorFile(fh, true);
}
}
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

View File

@ -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

View File

@ -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

View File

@ -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,six.integer_types)):
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

View File

@ -0,0 +1,431 @@
//===-- 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()
Sometimes you need to create an empty target that will get filled in later. The most common use for this
is to attach to a process by name or pid where you don't know the executable up front. The most convenient way
to do this is:
target = debugger.CreateTarget('')
error = lldb.SBError()
process = target.AttachToProcessWithName(debugger.GetListener(), 'PROCESS_NAME', False, error)
or the equivalent arguments for AttachToProcessWithID.
") 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",
"The dummy target holds breakpoints and breakpoint names that will prime newly created targets."
) GetDummyTarget;
lldb::SBTarget GetDummyTarget();
%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);
%feature("docstring",
"Get the number of currently active platforms."
) GetNumPlatforms;
uint32_t
GetNumPlatforms ();
%feature("docstring",
"Get one of the currently active platforms."
) GetPlatformAtIndex;
lldb::SBPlatform
GetPlatformAtIndex (uint32_t idx);
%feature("docstring",
"Get the number of available platforms."
) GetNumAvailablePlatforms;
uint32_t
GetNumAvailablePlatforms ();
%feature("docstring", "
Get the name and description of one of the available platforms.
@param idx Zero-based index of the platform for which info should be
retrieved, must be less than the value returned by
GetNumAvailablePlatforms().
") GetAvailablePlatformInfoAtIndex;
lldb::SBStructuredData
GetAvailablePlatformInfoAtIndex (uint32_t idx);
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);
SBTypeCategory
GetCategory (lldb::LanguageType lang_type);
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);
lldb::SBError
RunREPL (lldb::LanguageType language, const char *repl_options);
}; // class SBDebugger
} // namespace lldb

View File

@ -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

View File

@ -0,0 +1,128 @@
//===-- 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);
%varargs(3, char *str = NULL) SetErrorStringWithFormat;
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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,151 @@
//===-- 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);
%feature("docstring", "Gets the prefix to use for this expression.") GetPrefix;
const char *
GetPrefix () const;
%feature("docstring", "Sets the prefix to use for this expression. This prefix gets inserted after the 'target.expr-prefix' prefix contents, but before the wrapped expression function body.") SetPrefix;
void
SetPrefix (const char *prefix);
%feature("docstring", "Sets whether to auto-apply fix-it hints to the expression being evaluated.") SetAutoApplyFixIts;
void
SetAutoApplyFixIts(bool b = true);
%feature("docstring", "Gets whether to auto-apply fix-it hints to an expression.") GetAutoApplyFixIts;
bool
GetAutoApplyFixIts();
bool
GetTopLevel();
void
SetTopLevel(bool b = true);
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<lldb_private::EvaluateExpressionOptions> m_opaque_ap;
};
} // namespace lldb

View File

@ -0,0 +1,106 @@
//===-- 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;
void
AppendPathComponent (const char *file_or_directory);
%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

View File

@ -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

Some files were not shown because too many files have changed in this diff Show More