[lldb] Replace SB swig interfaces with API headers

Instead of maintaining separate swig interface files, we can use the API
headers directly. They implement the exact same C++ APIs and we can
conditionally include the python extensions as needed. To remove the
swig extensions from the API headers when building the LLDB
framework, we can use the unifdef tool when it is available. Otherwise
we just copy them as-is.

Differential Revision: https://reviews.llvm.org/D142926
This commit is contained in:
Alex Langford
2023-01-26 17:33:33 -08:00
parent 23d43e6977
commit 662548c826
205 changed files with 4606 additions and 10646 deletions

View File

@@ -23,6 +23,7 @@ endif()
set(SWIG_COMMON_FLAGS
-c++
-w361,362 # Ignore warnings about ignored operator overloads
-features autodoc
-I${LLDB_SOURCE_DIR}/include
-I${CMAKE_CURRENT_SOURCE_DIR}

View File

@@ -0,0 +1,56 @@
%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:
* file addresses
* 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."
) lldb::SBAddress;
%feature("docstring", "
Create an address by resolving a load address using the supplied target.")
lldb::SBAddress::SBAddress;
%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 :py:class:`SBAddress.SetLoadAddress' or
:py:class:`SBTarget.ResolveLoadAddress`.") lldb::SBAddress::GetSymbolContext;
%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 :py:class:`SBAddress.GetSymbolContext` or
:py:class:`SBTarget.ResolveSymbolContextForAddress` when you want multiple
debug symbol related objects for an address.
One or more bits from the SymbolContextItem enumerations can be logically
OR'ed together to more efficiently retrieve multiple symbol objects.")
lldb::SBAddress::GetModule;

View File

@@ -1,69 +1,6 @@
//===-- SWIG Interface for SBAddress ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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:
* file addresses
* 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;
explicit operator bool() const;
STRING_EXTENSION_OUTSIDE(SBAddress)
%extend lldb::SBAddress {
#ifdef SWIGPYTHON
// operator== is a free function, which swig does not handle, so we inject
// our own equality operator here
@@ -71,78 +8,7 @@ public:
def __eq__(self, other):
return not self.__ne__(other)
%}
#endif
bool operator!=(const SBAddress &rhs) 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);
%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 :py:class:`SBAddress.SetLoadAddress' or
:py:class:`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 :py:class:`SBAddress.GetSymbolContext` or
:py:class:`SBTarget.ResolveSymbolContextForAddress` when you want multiple
debug symbol related objects for an address.
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 ();
STRING_EXTENSION(SBAddress)
#ifdef SWIGPYTHON
%pythoncode %{
__runtime_error_str = 'This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'
@@ -186,7 +52,4 @@ public:
load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.''')
%}
#endif
};
} // namespace lldb
}

View File

@@ -1,117 +0,0 @@
//===-- SWIG Interface for SBAttachInfo--------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Describes how to attach when calling :py:class:`SBTarget.Attach`."
) SBAttachInfo;
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,3 @@
%feature("docstring",
"Describes how to attach when calling :py:class:`SBTarget.Attach`."
) lldb::SBAttachInfo;

View File

@@ -0,0 +1,32 @@
%feature("docstring",
"Represents a lexical block. SBFunction contains SBBlock(s)."
) lldb::SBBlock;
%feature("docstring",
"Is this block contained within an inlined function?"
) lldb::SBBlock::IsInlined;
%feature("docstring", "
Get the function name if this block represents an inlined function;
otherwise, return None.") lldb::SBBlock::GetInlinedName;
%feature("docstring", "
Get the call site file if this block represents an inlined function;
otherwise, return an invalid file spec.") lldb::SBBlock::GetInlinedCallSiteFile;
%feature("docstring", "
Get the call site line if this block represents an inlined function;
otherwise, return 0.") lldb::SBBlock::GetInlinedCallSiteLine;
%feature("docstring", "
Get the call site column if this block represents an inlined function;
otherwise, return 0.") lldb::SBBlock::GetInlinedCallSiteColumn;
%feature("docstring", "Get the parent block.") lldb::SBBlock::GetParent;
%feature("docstring", "Get the inlined block that is or contains this block."
) lldb::SBBlock::GetContainingInlinedBlock;
%feature("docstring", "Get the sibling block for this block.") lldb::SBBlock::GetSibling;
%feature("docstring", "Get the first child block.") lldb::SBBlock::GetFirstChild;

View File

@@ -1,107 +1,6 @@
//===-- SWIG Interface for SBBlock ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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",
"Is this block contained within an inlined function?"
) IsInlined;
bool
IsInlined () const;
bool
IsValid () const;
explicit operator bool() 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);
STRING_EXTENSION(SBBlock)
STRING_EXTENSION_OUTSIDE(SBBlock)
%extend lldb::SBBlock {
#ifdef SWIGPYTHON
%pythoncode %{
def get_range_at_index(self, idx):
@@ -157,7 +56,4 @@ public:
num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''')
%}
#endif
};
} // namespace lldb
}

View File

@@ -1,349 +0,0 @@
//===-- SWIG Interface for SBBreakpoint -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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();
bool operator==(const lldb::SBBreakpoint &rhs);
bool operator!=(const lldb::SBBreakpoint &rhs);
break_id_t
GetID () const;
bool
IsValid() const;
explicit operator bool() const;
void
ClearAllBreakpointSites ();
lldb::SBTarget
GetTarget() const;
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", "
Set the name of the script function to be called when the breakpoint is hit.
To use this variant, the function should take (frame, bp_loc, extra_args, internal_dict) and
when the breakpoint is hit the extra_args will be passed to the callback function.") SetScriptCallbackFunction;
SBError
SetScriptCallbackFunction (const char *callback_function_name,
SBStructuredData &extra_args);
%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);
SBError
AddNameWithErrorHandling (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);
// Can only be called from a ScriptedBreakpointResolver...
SBError
AddLocation(SBAddress &address);
SBStructuredData SBBreakpoint::SerializeToStructuredData();
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);
bool
IsHardware ();
STRING_EXTENSION(SBBreakpoint)
#ifdef SWIGPYTHON
%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 isinstance(key, int):
count = len(self)
if -count <= key < count:
key %= count
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
def __iter__(self):
'''Iterate over all breakpoint locations in a lldb.SBBreakpoint
object.'''
return lldb_iter(self, 'GetNumLocations', 'GetLocationAtIndex')
def __len__(self):
'''Return the number of breakpoint locations in a lldb.SBBreakpoint
object.'''
return self.GetNumLocations()
locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''')
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]).''')
id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''')
enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''')
one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''')
num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''')
%}
#endif
};
class SBBreakpointListImpl;
%feature("docstring",
"Represents a list of :py:class:`SBBreakpoint`."
) SBBreakpointList;
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,102 @@
%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."
) lldb::SBBreakpoint;
%feature("docstring", "
The breakpoint stops only if the condition expression evaluates to true."
) lldb::SBBreakpoint::SetCondition;
%feature("docstring", "
Get the condition expression for the breakpoint."
) lldb::SBBreakpoint::GetCondition;
%feature("docstring", "
Set the name of the script function to be called when the breakpoint is hit."
) lldb::SBBreakpoint::SetScriptCallbackFunction;
%feature("docstring", "
Set the name of the script function to be called when the breakpoint is hit.
To use this variant, the function should take (frame, bp_loc, extra_args, internal_dict) and
when the breakpoint is hit the extra_args will be passed to the callback function."
) lldb::SBBreakpoint::SetScriptCallbackFunction;
%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."
) lldb::SBBreakpoint::SetScriptCallbackBody;
%feature("docstring",
"Represents a list of :py:class:`SBBreakpoint`."
) lldb::SBBreakpointList;

View File

@@ -0,0 +1,55 @@
STRING_EXTENSION_OUTSIDE(SBBreakpoint)
%extend lldb::SBBreakpoint {
#ifdef SWIGPYTHON
%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 isinstance(key, int):
count = len(self)
if -count <= key < count:
key %= count
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
def __iter__(self):
'''Iterate over all breakpoint locations in a lldb.SBBreakpoint
object.'''
return lldb_iter(self, 'GetNumLocations', 'GetLocationAtIndex')
def __len__(self):
'''Return the number of breakpoint locations in a lldb.SBBreakpoint
object.'''
return self.GetNumLocations()
locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''')
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]).''')
id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''')
enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''')
one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''')
num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''')
%}
#endif
}

View File

@@ -1,141 +0,0 @@
//===-- SWIG Interface for SBBreakpointLocation -----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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.
:py:class:`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;
explicit operator bool() 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.
The function takes three arguments (frame, bp_loc, internal_dict).") SetScriptCallbackFunction;
void
SetScriptCallbackFunction (const char *callback_function_name);
%feature("docstring", "
Set the name of the script function to be called when the breakpoint is hit.
To use this variant, the function should take (frame, bp_loc, extra_args, internal_dict) and
when the breakpoint is hit the extra_args will be passed to the callback function.") SetScriptCallbackFunction;
SBError
SetScriptCallbackFunction (const char *callback_function_name,
SBStructuredData &extra_args);
%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 ();
STRING_EXTENSION_LEVEL(SBBreakpointLocation, lldb::eDescriptionLevelFull)
};
} // namespace lldb

View File

@@ -0,0 +1,40 @@
%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.
:py:class:`SBBreakpoint` contains SBBreakpointLocation(s). See docstring of SBBreakpoint
for retrieval of an SBBreakpointLocation from an SBBreakpoint."
) lldb::SBBreakpointLocation;
%feature("docstring", "
The breakpoint location stops only if the condition expression evaluates
to true.") lldb::SBBreakpointLocation::SetCondition;
%feature("docstring", "
Get the condition expression for the breakpoint location."
) lldb::SBBreakpointLocation::GetCondition;
%feature("docstring", "
Set the callback to the given Python function name.
The function takes three arguments (frame, bp_loc, internal_dict)."
) lldb::SBBreakpointLocation::SetScriptCallbackFunction;
%feature("docstring", "
Set the name of the script function to be called when the breakpoint is hit.
To use this variant, the function should take (frame, bp_loc, extra_args, internal_dict) and
when the breakpoint is hit the extra_args will be passed to the callback function."
) lldb::SBBreakpointLocation::SetScriptCallbackFunction;
%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."
) lldb::SBBreakpointLocation::SetScriptCallbackBody;

View File

@@ -0,0 +1 @@
STRING_EXTENSION_LEVEL_OUTSIDE(SBBreakpointLocation, lldb::eDescriptionLevelFull)

View File

@@ -1,115 +0,0 @@
//===-- SWIG interface for SBBreakpointName.h -------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Represents a breakpoint name registered in a given :py:class:`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 :py:class:`SBBreakpoint` s 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();
// 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);
explicit operator bool() const;
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);
SBError
SetScriptCallbackFunction (const char *callback_function_name,
SBStructuredData &extra_args);
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);
STRING_EXTENSION(SBBreakpointName)
};
} // namespace lldb

View File

@@ -0,0 +1,15 @@
%feature("docstring",
"Represents a breakpoint name registered in a given :py:class:`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 :py:class:`SBBreakpoint` s 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."
) lldb::SBBreakpointName;

View File

@@ -0,0 +1 @@
STRING_EXTENSION_OUTSIDE(SBBreakpointName)

View File

@@ -1,71 +0,0 @@
//===-- SWIG Interface for SBBroadcaster ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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;
explicit operator bool() 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,13 @@
%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."
) lldb::SBBroadcaster;

View File

@@ -1,176 +0,0 @@
//===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"SBCommandInterpreter handles/interprets commands for lldb.
You get the command interpreter from the :py:class:`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;
explicit operator bool() const;
const char *
GetIOHandlerControlSequence(char ch);
bool
GetPromptOnQuit();
void
SetPromptOnQuit(bool b);
void
AllowExitCodeOnQuit(bool b);
bool
HasCustomQuitExitCode();
int
GetQuitStatus();
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 ();
bool
IsInteractive ();
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);
int
HandleCompletionWithDescriptions (const char *current_line,
uint32_t cursor_pos,
int match_start_point,
int max_return_elements,
lldb::SBStringList &matches,
lldb::SBStringList &descriptions);
bool
IsActive ();
bool
WasInterrupted () const;
};
} // namespace lldb

View File

@@ -0,0 +1,45 @@
%feature("docstring",
"SBCommandInterpreter handles/interprets commands for lldb.
You get the command interpreter from the :py:class:`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.") lldb::SBCommandInterpreter;

View File

@@ -1,84 +0,0 @@
//===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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
* PrintErrors: 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
GetPrintErrors () const;
void
SetPrintErrors (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;
};
} // namespace lldb

View File

@@ -0,0 +1,14 @@
%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
* PrintErrors: true
* AddToHistory: true
") lldb::SBCommandInterpreterRunOptions;

View File

@@ -1,127 +0,0 @@
//===-- SWIG Interface for SBCommandReturnObject ----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Represents a container which holds the result from command execution.
It works with :py:class:`SBCommandInterpreter.HandleCommand()` to encapsulate the result
of command execution.
See :py:class:`SBCommandInterpreter` for example usage of SBCommandReturnObject."
) SBCommandReturnObject;
class SBCommandReturnObject
{
public:
SBCommandReturnObject ();
SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs);
~SBCommandReturnObject ();
bool
IsValid() const;
explicit operator bool() 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 (lldb::SBFile file);
size_t
PutError (lldb::SBFile file);
size_t
PutOutput (lldb::FileSP BORROWED);
size_t
PutError (lldb::FileSP BORROWED);
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(lldb::SBFile file);
void SetImmediateErrorFile(lldb::SBFile file);
void SetImmediateOutputFile(lldb::FileSP BORROWED);
void SetImmediateErrorFile(lldb::FileSP BORROWED);
STRING_EXTENSION(SBCommandReturnObject)
%extend {
// transfer_ownership does nothing, and is here for compatibility with
// old scripts. Ownership is tracked by reference count in the ordinary way.
void SetImmediateOutputFile(lldb::FileSP BORROWED, bool transfer_ownership) {
self->SetImmediateOutputFile(BORROWED);
}
void SetImmediateErrorFile(lldb::FileSP BORROWED, bool transfer_ownership) {
self->SetImmediateErrorFile(BORROWED);
}
}
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,7 @@
%feature("docstring",
"Represents a container which holds the result from command execution.
It works with :py:class:`SBCommandInterpreter.HandleCommand()` to encapsulate the result
of command execution.
See :py:class:`SBCommandInterpreter` for example usage of SBCommandReturnObject."
) lldb::SBCommandReturnObject;

View File

@@ -0,0 +1,20 @@
STRING_EXTENSION_OUTSIDE(SBCommandReturnObject)
%extend lldb::SBCommandReturnObject {
// transfer_ownership does nothing, and is here for compatibility with
// old scripts. Ownership is tracked by reference count in the ordinary way.
void SetImmediateOutputFile(lldb::FileSP BORROWED, bool transfer_ownership) {
self->SetImmediateOutputFile(BORROWED);
}
void SetImmediateErrorFile(lldb::FileSP BORROWED, bool transfer_ownership) {
self->SetImmediateErrorFile(BORROWED);
}
// wrapping the variadic Printf() with a plain Print()
// because it is hard to support varargs in SWIG bridgings
void Print (const char* str)
{
self->Printf("%s", str);
}
}

View File

@@ -1,86 +0,0 @@
//===-- SWIG Interface for SBCommunication ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Allows sending/receiving data."
) SBCommunication;
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;
explicit operator bool() 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,3 @@
%feature("docstring",
"Allows sending/receiving data."
) lldb::SBCommunication;

View File

@@ -1,154 +0,0 @@
//===-- SWIG Interface for SBCompileUnit ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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 :py:class:`SBSymbolContext` and :py:class:`SBLineEntry`"
) SBCompileUnit;
class SBCompileUnit
{
public:
SBCompileUnit ();
SBCompileUnit (const lldb::SBCompileUnit &rhs);
~SBCompileUnit ();
bool
IsValid () const;
explicit operator bool() const;
lldb::SBFileSpec
GetFileSpec () const;
uint32_t
GetNumLineEntries () const;
lldb::SBLineEntry
GetLineEntryAtIndex (uint32_t idx) const;
%feature("docstring", "
Get the index for a provided line entry in this compile unit.
@param[in] line_entry
The SBLineEntry object for which we are looking for the index.
@param[in] exact
An optional boolean defaulting to false that ensures that the provided
line entry has a perfect match in the compile unit.
@return
The index of the user-provided line entry. UINT32_MAX if the line entry
was not found in the compile unit.") FindLineEntryIndex;
uint32_t
FindLineEntryIndex (lldb::SBLineEntry &line_entry, bool exact = false) 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 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 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;
STRING_EXTENSION(SBCompileUnit)
#ifdef SWIGPYTHON
%pythoncode %{
def __iter__(self):
'''Iterate over all line entries in a lldb.SBCompileUnit object.'''
return lldb_iter(self, 'GetNumLineEntries', 'GetLineEntryAtIndex')
def __len__(self):
'''Return the number of line entries in a lldb.SBCompileUnit
object.'''
return self.GetNumLineEntries()
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.''')
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.''')
%}
#endif
};
} // namespace lldb

View File

@@ -0,0 +1,65 @@
%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 :py:class:`SBSymbolContext` and :py:class:`SBLineEntry`"
) lldb::SBCompileUnit;
%feature("docstring", "
Get the index for a provided line entry in this compile unit.
@param[in] line_entry
The SBLineEntry object for which we are looking for the index.
@param[in] exact
An optional boolean defaulting to false that ensures that the provided
line entry has a perfect match in the compile unit.
@return
The index of the user-provided line entry. UINT32_MAX if the line entry
was not found in the compile unit.") lldb::SBCompileUnit::FindLineEntryIndex;
%feature("docstring", "
Get all types matching 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 type_mask"
) lldb::SBCompileUnit::GetTypes;

View File

@@ -0,0 +1,19 @@
STRING_EXTENSION_OUTSIDE(SBCompileUnit)
%extend lldb::SBCompileUnit {
#ifdef SWIGPYTHON
%pythoncode %{
def __iter__(self):
'''Iterate over all line entries in a lldb.SBCompileUnit object.'''
return lldb_iter(self, 'GetNumLineEntries', 'GetLineEntryAtIndex')
def __len__(self):
'''Return the number of line entries in a lldb.SBCompileUnit
object.'''
return self.GetNumLineEntries()
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.''')
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.''')
%}
#endif
}

View File

@@ -0,0 +1,3 @@
%feature("docstring",
"Represents a data buffer."
) lldb::SBData;

View File

@@ -1,148 +1,6 @@
//===-- SWIG Interface for SBData -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Represents a data buffer."
) SBData;
class SBData
{
public:
SBData ();
SBData (const SBData &rhs);
~SBData ();
uint8_t
GetAddressByteSize ();
void
SetAddressByteSize (uint8_t addr_byte_size);
void
Clear ();
bool
IsValid();
explicit operator bool() const;
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);
void
SetDataWithOwnership (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);
STRING_EXTENSION(SBData)
STRING_EXTENSION_OUTSIDE(SBData)
%extend lldb::SBData {
#ifdef SWIGPYTHON
%pythoncode %{
@@ -298,7 +156,4 @@ public:
size = property(GetByteSize, None, doc='''A read only property that returns the size the same result as GetByteSize().''')
%}
#endif
};
} // namespace lldb
}

View File

@@ -1,565 +0,0 @@
//===-- SWIG Interface for SBDebugger ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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 :py:class:`SBTarget.AttachToProcessWithID` .") SBDebugger;
class SBDebugger
{
public:
enum
{
eBroadcastBitProgress = (1 << 0),
eBroadcastBitWarning = (1 << 1),
eBroadcastBitError = (1 << 2),
};
static const char *GetProgressFromEvent(const lldb::SBEvent &event,
uint64_t &OUTPUT,
uint64_t &OUTPUT,
uint64_t &OUTPUT,
bool &OUTPUT);
static lldb::SBStructuredData GetProgressDataFromEvent(const lldb::SBEvent &event);
static lldb::SBStructuredData GetDiagnosticFromEvent(const lldb::SBEvent &event);
SBBroadcaster GetBroadcaster();
static void
Initialize();
static SBError
InitializeWithErrorHandling();
static void PrintStackTraceOnError();
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;
explicit operator bool() const;
void
Clear ();
void
SetAsync (bool b);
bool
GetAsync ();
void
SkipLLDBInitFiles (bool b);
#ifdef SWIGPYTHON
%pythoncode %{
def SetOutputFileHandle(self, file, transfer_ownership):
"DEPRECATED, use SetOutputFile"
if file is None:
import sys
file = sys.stdout
self.SetOutputFile(SBFile.Create(file, borrow=True))
def SetInputFileHandle(self, file, transfer_ownership):
"DEPRECATED, use SetInputFile"
if file is None:
import sys
file = sys.stdin
self.SetInputFile(SBFile.Create(file, borrow=True))
def SetErrorFileHandle(self, file, transfer_ownership):
"DEPRECATED, use SetErrorFile"
if file is None:
import sys
file = sys.stderr
self.SetErrorFile(SBFile.Create(file, borrow=True))
%}
#endif
%extend {
lldb::FileSP GetInputFileHandle() {
return self->GetInputFile().GetFile();
}
lldb::FileSP GetOutputFileHandle() {
return self->GetOutputFile().GetFile();
}
lldb::FileSP GetErrorFileHandle() {
return self->GetErrorFile().GetFile();
}
}
lldb::SBStructuredData GetSetting(const char *setting = nullptr);
SBError
SetInputString (const char* data);
SBError
SetInputFile (SBFile file);
SBError
SetOutputFile (SBFile file);
SBError
SetErrorFile (SBFile file);
SBError
SetInputFile (FileSP file);
SBError
SetOutputFile (FileSP file);
SBError
SetErrorFile (FileSP file);
SBFile
GetInputFile ();
SBFile
GetOutputFile ();
SBFile
GetErrorFile ();
lldb::SBCommandInterpreter
GetCommandInterpreter ();
void
HandleCommand (const char *command);
lldb::SBListener
GetListener ();
void
HandleProcessEvent (const lldb::SBProcess &process,
const lldb::SBEvent &event,
SBFile out,
SBFile err);
void
HandleProcessEvent (const lldb::SBProcess &process,
const lldb::SBEvent &event,
FileSP BORROWED,
FileSP BORROWED);
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 SBStructuredData GetBuildConfiguration();
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);
const char *
GetReproducerPath() const;
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);
SBStructuredData GetScriptInterpreterInfo(ScriptLanguage);
STRING_EXTENSION(SBDebugger)
%feature("docstring",
"Launch a command interpreter session. Commands are read from standard input or
from the input handle specified for the debugger object. Output/errors are
similarly redirected to standard output/error or the configured handles.
@param[in] auto_handle_events If true, automatically handle resulting events.
@param[in] spawn_thread If true, start a new thread for IO handling.
@param[in] options Parameter collection of type SBCommandInterpreterRunOptions.
@param[in] num_errors Initial error counter.
@param[in] quit_requested Initial quit request flag.
@param[in] stopped_for_crash Initial crash flag.
@return
A tuple with the number of errors encountered by the interpreter, a boolean
indicating whether quitting the interpreter was requested and another boolean
set to True in case of a crash.
Example: ::
# Start an interactive lldb session from a script (with a valid debugger object
# created beforehand):
n_errors, quit_requested, has_crashed = debugger.RunCommandInterpreter(True,
False, lldb.SBCommandInterpreterRunOptions(), 0, False, False)") RunCommandInterpreter;
%apply int& INOUT { int& num_errors };
%apply bool& INOUT { bool& quit_requested };
%apply bool& INOUT { bool& stopped_for_crash };
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);
SBTrace LoadTraceFromFile(SBError &error, const SBFileSpec &trace_description_file);
#ifdef SWIGPYTHON
%pythoncode%{
def __iter__(self):
'''Iterate over all targets in a lldb.SBDebugger object.'''
return lldb_iter(self, 'GetNumTargets', 'GetTargetAtIndex')
def __len__(self):
'''Return the number of targets in a lldb.SBDebugger object.'''
return self.GetNumTargets()
%}
#endif
}; // class SBDebugger
} // namespace lldb

View File

@@ -0,0 +1,160 @@
%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 :py:class:`SBTarget.AttachToProcessWithID` ."
) lldb::SBDebugger;
%feature("docstring",
"The dummy target holds breakpoints and breakpoint names that will prime newly created targets."
) lldb::SBDebugger::GetDummyTarget;
%feature("docstring",
"Return true if target is deleted from the target list of the debugger."
) lldb::SBDebugger::DeleteTarget;
%feature("docstring",
"Get the number of currently active platforms."
) lldb::SBDebugger::GetNumPlatforms;
%feature("docstring",
"Get one of the currently active platforms."
) lldb::SBDebugger::GetPlatformAtIndex;
%feature("docstring",
"Get the number of available platforms."
) lldb::SBDebugger::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()."
) lldb::SBDebugger::GetAvailablePlatformInfoAtIndex;
%feature("docstring",
"Launch a command interpreter session. Commands are read from standard input or
from the input handle specified for the debugger object. Output/errors are
similarly redirected to standard output/error or the configured handles.
@param[in] auto_handle_events If true, automatically handle resulting events.
@param[in] spawn_thread If true, start a new thread for IO handling.
@param[in] options Parameter collection of type SBCommandInterpreterRunOptions.
@param[in] num_errors Initial error counter.
@param[in] quit_requested Initial quit request flag.
@param[in] stopped_for_crash Initial crash flag.
@return
A tuple with the number of errors encountered by the interpreter, a boolean
indicating whether quitting the interpreter was requested and another boolean
set to True in case of a crash.
Example: ::
# Start an interactive lldb session from a script (with a valid debugger object
# created beforehand):
n_errors, quit_requested, has_crashed = debugger.RunCommandInterpreter(True,
False, lldb.SBCommandInterpreterRunOptions(), 0, False, False)"
) lldb::SBDebugger::RunCommandInterpreter;

View File

@@ -0,0 +1,48 @@
STRING_EXTENSION_OUTSIDE(SBDebugger)
%extend lldb::SBDebugger {
#ifdef SWIGPYTHON
%pythoncode %{
def SetOutputFileHandle(self, file, transfer_ownership):
"DEPRECATED, use SetOutputFile"
if file is None:
import sys
file = sys.stdout
self.SetOutputFile(SBFile.Create(file, borrow=True))
def SetInputFileHandle(self, file, transfer_ownership):
"DEPRECATED, use SetInputFile"
if file is None:
import sys
file = sys.stdin
self.SetInputFile(SBFile.Create(file, borrow=True))
def SetErrorFileHandle(self, file, transfer_ownership):
"DEPRECATED, use SetErrorFile"
if file is None:
import sys
file = sys.stderr
self.SetErrorFile(SBFile.Create(file, borrow=True))
def __iter__(self):
'''Iterate over all targets in a lldb.SBDebugger object.'''
return lldb_iter(self, 'GetNumTargets', 'GetTargetAtIndex')
def __len__(self):
'''Return the number of targets in a lldb.SBDebugger object.'''
return self.GetNumTargets()
%}
#endif
lldb::FileSP GetInputFileHandle() {
return self->GetInputFile().GetFile();
}
lldb::FileSP GetOutputFileHandle() {
return self->GetOutputFile().GetFile();
}
lldb::FileSP GetErrorFileHandle() {
return self->GetErrorFile().GetFile();
}
}

View File

@@ -1,67 +0,0 @@
//===-- SWIG Interface for SBDeclaration --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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;
explicit operator bool() 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;
STRING_EXTENSION(SBDeclaration)
#ifdef SWIGPYTHON
%pythoncode %{
file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''')
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.''')
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.''')
%}
#endif
};
} // namespace lldb

View File

@@ -0,0 +1,3 @@
%feature("docstring",
"Specifies an association with a line and column for a variable."
) lldb::SBDeclaration;

View File

@@ -0,0 +1,11 @@
STRING_EXTENSION_OUTSIDE(SBDeclaration)
%extend lldb::SBDeclaration {
#ifdef SWIGPYTHON
%pythoncode %{
file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''')
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.''')
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.''')
%}
#endif
}

View File

@@ -1,49 +0,0 @@
//===-- SWIG Interface for SBEnvironment-------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Represents the environment of a certain process.
Example: ::
for entry in lldb.debugger.GetSelectedTarget().GetEnvironment().GetEntries():
print(entry)
") SBEnvironment;
class SBEnvironment {
public:
SBEnvironment ();
SBEnvironment (const lldb::SBEnvironment &rhs);
~SBEnvironment();
size_t GetNumValues();
const char *Get(const char *name);
const char *GetNameAtIndex(size_t index);
const char *GetValueAtIndex(size_t index);
SBStringList GetEntries();
void PutEntry(const char *name_and_value);
void SetEntries(const SBStringList &entries, bool append);
bool Set(const char *name, const char *value, bool overwrite);
bool Unset(const char *name);
void Clear();
};
} // namespace lldb

View File

@@ -0,0 +1,9 @@
%feature("docstring",
"Represents the environment of a certain process.
Example: ::
for entry in lldb.debugger.GetSelectedTarget().GetEnvironment().GetEntries():
print(entry)
") lldb::SBEnvironment;

View File

@@ -1,122 +0,0 @@
//===-- SWIG Interface for SBError ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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;
explicit operator bool() const;
bool
GetDescription (lldb::SBStream &description);
STRING_EXTENSION(SBError)
#ifdef SWIGPYTHON
%pythoncode %{
value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''')
fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''')
success = property(Success, None, doc='''A read only property that returns the same result as Success().''')
description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''')
type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''')
%}
#endif
};
} // namespace lldb

View File

@@ -0,0 +1,46 @@
%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.") lldb::SBError;

View File

@@ -0,0 +1,13 @@
STRING_EXTENSION_OUTSIDE(SBError)
%extend lldb::SBError {
#ifdef SWIGPYTHON
%pythoncode %{
value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''')
fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''')
success = property(Success, None, doc='''A read only property that returns the same result as Success().''')
description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''')
type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''')
%}
#endif
}

View File

@@ -1,15 +1,3 @@
//===-- SWIG Interface for SBEvent ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
class SBBroadcaster;
%feature("docstring",
"API clients can register to receive events.
@@ -105,49 +93,9 @@ from test/python_api/event/TestEventspy: ::
process.Kill()
# Wait until the 'MyListeningThread' terminates.
my_thread.join()") SBEvent;
class SBEvent
{
public:
SBEvent();
my_thread.join()"
) lldb::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;
explicit operator bool() 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
%feature("autodoc",
"__init__(self, int type, str data) -> SBEvent (make an event that contains a C string)"
) lldb::SBEvent::SBEvent;

View File

@@ -1,54 +0,0 @@
//===-- SWIG Interface for SBExecutionContext ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Describes the program context in which a command should be executed."
) SBExecutionContext;
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;
#ifdef SWIGPYTHON
%pythoncode %{
target = property(GetTarget, None, doc='''A read only property that returns the same result as GetTarget().''')
process = property(GetProcess, None, doc='''A read only property that returns the same result as GetProcess().''')
thread = property(GetThread, None, doc='''A read only property that returns the same result as GetThread().''')
frame = property(GetFrame, None, doc='''A read only property that returns the same result as GetFrame().''')
%}
#endif
};
} // namespace lldb

View File

@@ -0,0 +1,3 @@
%feature("docstring",
"Describes the program context in which a command should be executed."
) lldb::SBExecutionContext;

View File

@@ -0,0 +1,10 @@
%extend lldb::SBExecutionContext {
#ifdef SWIGPYTHON
%pythoncode %{
target = property(GetTarget, None, doc='''A read only property that returns the same result as GetTarget().''')
process = property(GetProcess, None, doc='''A read only property that returns the same result as GetProcess().''')
thread = property(GetThread, None, doc='''A read only property that returns the same result as GetThread().''')
frame = property(GetFrame, None, doc='''A read only property that returns the same result as GetFrame().''')
%}
#endif
}

View File

@@ -1,166 +0,0 @@
//===-- SWIG interface for SBExpressionOptions -----------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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 expression 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 expressions. 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();
%feature("docstring", "Sets how often LLDB should retry applying fix-its to an expression.") SetRetriesWithFixIts;
void
SetRetriesWithFixIts(uint64_t retries);
%feature("docstring", "Gets how often LLDB will retry applying fix-its to an expression.") GetRetriesWithFixIts;
uint64_t
GetRetriesWithFixIts();
bool
GetTopLevel();
void
SetTopLevel(bool b = true);
%feature("docstring", "Gets whether to JIT an expression if it cannot be interpreted.") GetAllowJIT;
bool
GetAllowJIT();
%feature("docstring", "Sets whether to JIT an expression if it cannot be interpreted.") SetAllowJIT;
void
SetAllowJIT(bool allow);
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,63 @@
%feature("docstring",
"A container for options to use when evaluating expressions."
) lldb::SBExpressionOptions;
%feature("docstring", "Sets whether to coerce the expression result to ObjC id type after evaluation."
) lldb::SBExpressionOptions::SetCoerceResultToId;
%feature("docstring", "Sets whether to unwind the expression stack on error."
) lldb::SBExpressionOptions::SetUnwindOnError;
%feature("docstring", "Sets whether to ignore breakpoint hits while running expressions."
) lldb::SBExpressionOptions::SetIgnoreBreakpoints;
%feature("docstring", "Sets whether to cast the expression result to its dynamic type."
) lldb::SBExpressionOptions::SetFetchDynamicValue;
%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 expression will finish."
) lldb::SBExpressionOptions::SetTimeoutInMicroSeconds;
%feature("docstring", "Sets the timeout in microseconds to run the expression on one thread before either timing out or trying all threads."
) lldb::SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds;
%feature("docstring", "Sets whether to run all threads if the expression does not complete on one thread."
) lldb::SBExpressionOptions::SetTryAllThreads;
%feature("docstring", "Sets whether to stop other threads at all while running expressions. If false, TryAllThreads does nothing."
) lldb::SBExpressionOptions::SetStopOthers;
%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."
) lldb::SBExpressionOptions::SetTrapExceptions;
%feature ("docstring", "Sets the language that LLDB should assume the expression is written in"
) lldb::SBExpressionOptions::SetLanguage;
%feature("docstring", "Sets whether to generate debug information for the expression and also controls if a SBModule is generated."
) lldb::SBExpressionOptions::SetGenerateDebugInfo;
%feature("docstring", "Sets whether to produce a persistent result that can be used in future expressions."
) lldb::SBExpressionOptions::SetSuppressPersistentResult;
%feature("docstring", "Gets the prefix to use for this expression."
) lldb::SBExpressionOptions::GetPrefix;
%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."
) lldb::SBExpressionOptions::SetPrefix;
%feature("docstring", "Sets whether to auto-apply fix-it hints to the expression being evaluated."
) lldb::SBExpressionOptions::SetAutoApplyFixIts;
%feature("docstring", "Gets whether to auto-apply fix-it hints to an expression."
) lldb::SBExpressionOptions::GetAutoApplyFixIts;
%feature("docstring", "Sets how often LLDB should retry applying fix-its to an expression."
) lldb::SBExpressionOptions::SetRetriesWithFixIts;
%feature("docstring", "Gets how often LLDB will retry applying fix-its to an expression."
) lldb::SBExpressionOptions::GetRetriesWithFixIts;
%feature("docstring", "Gets whether to JIT an expression if it cannot be interpreted."
) lldb::SBExpressionOptions::GetAllowJIT;
%feature("docstring", "Sets whether to JIT an expression if it cannot be interpreted."
) lldb::SBExpressionOptions::SetAllowJIT;

View File

@@ -1,101 +0,0 @@
//===-- SWIG Interface for SBFile -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Represents a file."
) SBFile;
class SBFile
{
public:
SBFile();
%feature("docstring", "
Initialize a SBFile from a file descriptor. mode is
'r', 'r+', or 'w', like fdopen.");
SBFile(int fd, const char *mode, bool transfer_ownership);
%feature("docstring", "initialize a SBFile from a python file object");
SBFile(FileSP file);
%extend {
static lldb::SBFile MakeBorrowed(lldb::FileSP BORROWED) {
return lldb::SBFile(BORROWED);
}
static lldb::SBFile MakeForcingIOMethods(lldb::FileSP FORCE_IO_METHODS) {
return lldb::SBFile(FORCE_IO_METHODS);
}
static lldb::SBFile MakeBorrowedForcingIOMethods(lldb::FileSP BORROWED_FORCE_IO_METHODS) {
return lldb::SBFile(BORROWED_FORCE_IO_METHODS);
}
}
#ifdef SWIGPYTHON
%pythoncode {
@classmethod
def Create(cls, file, borrow=False, force_io_methods=False):
"""
Create a SBFile from a python file object, with options.
If borrow is set then the underlying file will
not be closed when the SBFile is closed or destroyed.
If force_scripting_io is set then the python read/write
methods will be called even if a file descriptor is available.
"""
if borrow:
if force_io_methods:
return cls.MakeBorrowedForcingIOMethods(file)
else:
return cls.MakeBorrowed(file)
else:
if force_io_methods:
return cls.MakeForcingIOMethods(file)
else:
return cls(file)
}
#endif
~SBFile ();
%feature("autodoc", "Read(buffer) -> SBError, bytes_read") Read;
SBError Read(uint8_t *buf, size_t num_bytes, size_t *OUTPUT);
%feature("autodoc", "Write(buffer) -> SBError, written_read") Write;
SBError Write(const uint8_t *buf, size_t num_bytes, size_t *OUTPUT);
void Flush();
bool IsValid() const;
operator bool() const;
SBError Close();
%feature("docstring", "
Convert this SBFile into a python io.IOBase file object.
If the SBFile is itself a wrapper around a python file object,
this will return that original object.
The file returned from here should be considered borrowed,
in the sense that you may read and write to it, and flush it,
etc, but you should not close it. If you want to close the
SBFile, call SBFile.Close().
If there is no underlying python file to unwrap, GetFile will
use the file descriptor, if available to create a new python
file object using ``open(fd, mode=..., closefd=False)``
");
FileSP GetFile();
};
} // namespace lldb

View File

@@ -0,0 +1,28 @@
%feature("docstring",
"Represents a file."
) lldb::SBFile;
%feature("docstring", "
Initialize a SBFile from a file descriptor. mode is
'r', 'r+', or 'w', like fdopen.") lldb::SBFile::SBFile;
%feature("docstring", "initialize a SBFile from a python file object") lldb::SBFile::SBFile;
%feature("autodoc", "Read(buffer) -> SBError, bytes_read") lldb::SBFile::Read;
%feature("autodoc", "Write(buffer) -> SBError, written_read") lldb::SBFile::Write;
%feature("docstring", "
Convert this SBFile into a python io.IOBase file object.
If the SBFile is itself a wrapper around a python file object,
this will return that original object.
The file returned from here should be considered borrowed,
in the sense that you may read and write to it, and flush it,
etc, but you should not close it. If you want to close the
SBFile, call SBFile.Close().
If there is no underlying python file to unwrap, GetFile will
use the file descriptor, if available to create a new python
file object using ``open(fd, mode=..., closefd=False)``
") lldb::SBFile::GetFile;

View File

@@ -0,0 +1,37 @@
%extend lldb::SBFile {
static lldb::SBFile MakeBorrowed(lldb::FileSP BORROWED) {
return lldb::SBFile(BORROWED);
}
static lldb::SBFile MakeForcingIOMethods(lldb::FileSP FORCE_IO_METHODS) {
return lldb::SBFile(FORCE_IO_METHODS);
}
static lldb::SBFile MakeBorrowedForcingIOMethods(lldb::FileSP BORROWED_FORCE_IO_METHODS) {
return lldb::SBFile(BORROWED_FORCE_IO_METHODS);
}
#ifdef SWIGPYTHON
%pythoncode {
@classmethod
def Create(cls, file, borrow=False, force_io_methods=False):
"""
Create a SBFile from a python file object, with options.
If borrow is set then the underlying file will
not be closed when the SBFile is closed or destroyed.
If force_scripting_io is set then the python read/write
methods will be called even if a file descriptor is available.
"""
if borrow:
if force_io_methods:
return cls.MakeBorrowedForcingIOMethods(file)
else:
return cls.MakeBorrowed(file)
else:
if force_io_methods:
return cls.MakeForcingIOMethods(file)
else:
return cls(file)
}
#endif
}

View File

@@ -1,96 +0,0 @@
//===-- SWIG Interface for SBFileSpec ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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 operator==(const SBFileSpec &rhs) const;
bool operator!=(const SBFileSpec &rhs) const;
bool
IsValid() const;
explicit operator bool() 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);
STRING_EXTENSION(SBFileSpec)
#ifdef SWIGPYTHON
%pythoncode %{
fullpath = property(str, None, doc='''A read only property that returns the fullpath as a python string.''')
basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''')
dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''')
exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''')
%}
#endif
};
} // namespace lldb

View File

@@ -0,0 +1,20 @@
%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.") lldb::SBFileSpec;

View File

@@ -0,0 +1,12 @@
STRING_EXTENSION_OUTSIDE(SBFileSpec)
%extend lldb::SBFileSpec {
#ifdef SWIGPYTHON
%pythoncode %{
fullpath = property(str, None, doc='''A read only property that returns the fullpath as a python string.''')
basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''')
dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''')
exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''')
%}
#endif
}

View File

@@ -1,47 +0,0 @@
//===-- SWIG Interface for SBFileSpecList -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Represents a list of :py:class:`SBFileSpec`."
) SBFileSpecList;
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

View File

@@ -0,0 +1,3 @@
%feature("docstring",
"Represents a list of :py:class:`SBFileSpec`."
) lldb::SBFileSpecList;

View File

@@ -1,372 +0,0 @@
//===-- SWIG Interface for SBFrame ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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;
explicit operator bool() const;
uint32_t
GetFrameID () const;
%feature("docstring", "
Get the Canonical Frame Address for this stack frame.
This is the DWARF standard's definition of a CFA, a stack address
that remains constant throughout the lifetime of the function.
Returns an lldb::addr_t stack address, or LLDB_INVALID_ADDRESS if
the CFA cannot be determined.") GetCFA;
lldb::addr_t
GetCFA () 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();
const char *
GetDisplayFunctionName ();
const char *
GetFunctionName() const;
%feature("docstring", "
Returns the language of the frame's SBFunction, or if there.
is no SBFunction, guess the language from the mangled name.
.") GuessLanguage;
lldb::LanguageType
GuessLanguage() const;
%feature("docstring", "
Return true if this frame represents an inlined function.
See also GetFunctionName().") IsInlined;
bool
IsInlined();
bool
IsInlined() const;
%feature("docstring", "
Return true if this frame is artificial (e.g a frame synthesized to
capture a tail call). Local variables may not be available in an artificial
frame.") IsArtificial;
bool
IsArtificial();
bool
IsArtificial() const;
%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();
bool
operator == (const lldb::SBFrame &rhs) const;
bool
operator != (const lldb::SBFrame &rhs) const;
%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 :py:class:`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);
STRING_EXTENSION(SBFrame)
#ifdef SWIGPYTHON
%pythoncode %{
def get_all_variables(self):
return self.GetVariables(True,True,True,True)
def get_parent_frame(self):
parent_idx = self.idx + 1
if parent_idx >= 0 and parent_idx < len(self.thread.frame):
return self.thread.frame[parent_idx]
else:
return SBFrame()
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)
pc = property(GetPC, SetPC)
addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''')
fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''')
sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''')
module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''')
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.''')
function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''')
symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''')
block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''')
is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''')
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).''')
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.''')
thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''')
disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''')
idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''')
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.''')
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.''')
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.''')
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.''')
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.''')
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.''')
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.''')
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.''')
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.''')
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''')
parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''')
%}
#endif
};
} // namespace lldb

View File

@@ -0,0 +1,153 @@
%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."
) lldb::SBFrame;
%feature("docstring", "
Get the Canonical Frame Address for this stack frame.
This is the DWARF standard's definition of a CFA, a stack address
that remains constant throughout the lifetime of the function.
Returns an lldb::addr_t stack address, or LLDB_INVALID_ADDRESS if
the CFA cannot be determined."
) lldb::SBFrame::GetCFA;
%feature("docstring", "
Gets the deepest block that contains the frame PC.
See also GetFrameBlock()."
) lldb::SBFrame::GetBlock;
%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()."
) lldb::SBFrame::GetFunctionName;
%feature("docstring", "
Returns the language of the frame's SBFunction, or if there.
is no SBFunction, guess the language from the mangled name.
."
) lldb::SBFrame::GuessLanguage;
%feature("docstring", "
Return true if this frame represents an inlined function.
See also GetFunctionName()."
) lldb::SBFrame::IsInlined;
%feature("docstring", "
Return true if this frame is artificial (e.g a frame synthesized to
capture a tail call). Local variables may not be available in an artificial
frame."
) lldb::SBFrame::IsArtificial;
%feature("docstring", "
The version that doesn't supply a 'use_dynamic' value will use the
target's default."
) lldb::SBFrame::EvaluateExpression;
%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."
) lldb::SBFrame::GetFrameBlock;
%feature("docstring", "
The version that doesn't supply a 'use_dynamic' value will use the
target's default."
) lldb::SBFrame::GetVariables;
%feature("docstring", "
The version that doesn't supply a 'use_dynamic' value will use the
target's default."
) lldb::SBFrame::FindVariable;
%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 :py:class:`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."
) lldb::SBFrame::GetValueForVariablePath;
%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."
) lldb::SBFrame::FindValue;

View File

@@ -0,0 +1,76 @@
STRING_EXTENSION_OUTSIDE(SBFrame)
%extend lldb::SBFrame {
#ifdef SWIGPYTHON
%pythoncode %{
def get_all_variables(self):
return self.GetVariables(True,True,True,True)
def get_parent_frame(self):
parent_idx = self.idx + 1
if parent_idx >= 0 and parent_idx < len(self.thread.frame):
return self.thread.frame[parent_idx]
else:
return SBFrame()
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)
pc = property(GetPC, SetPC)
addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''')
fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''')
sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''')
module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''')
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.''')
function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''')
symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''')
block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''')
is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''')
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).''')
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.''')
thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''')
disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''')
idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''')
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.''')
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.''')
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.''')
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.''')
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.''')
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.''')
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.''')
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.''')
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.''')
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''')
parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''')
%}
#endif
}

View File

@@ -1,134 +0,0 @@
//===-- SWIG Interface for SBFunction ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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;
explicit operator bool() const;
const char *
GetName() const;
const char *
GetDisplayName() 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 ();
const char *
GetArgumentName (uint32_t arg_idx);
uint32_t
GetPrologueByteSize ();
lldb::SBType
GetType ();
lldb::SBBlock
GetBlock ();
lldb::LanguageType
GetLanguage ();
%feature("docstring", "
Returns true if the function was compiled with optimization.
Optimization, in this case, is meant to indicate that the debugger
experience may be confusing for the user -- variables optimized away,
stepping jumping between source lines -- and the driver may want to
provide some guidance to the user about this.
Returns false if unoptimized, or unknown.") GetIsOptimized;
bool
GetIsOptimized();
bool
GetDescription (lldb::SBStream &description);
bool
operator == (const lldb::SBFunction &rhs) const;
bool
operator != (const lldb::SBFunction &rhs) const;
STRING_EXTENSION(SBFunction)
#ifdef SWIGPYTHON
%pythoncode %{
def get_instructions_from_current_target (self):
return self.GetInstructions (target)
addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this function.''')
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.''')
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.''')
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.''')
mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this function as a string.''')
name = property(GetName, None, doc='''A read only property that returns the name for this function as a string.''')
prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''')
type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the return type (lldb.SBType) for this function.''')
%}
#endif
};
} // namespace lldb

View File

@@ -0,0 +1,43 @@
%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))
..."
) lldb::SBFunction;
%feature("docstring", "
Returns true if the function was compiled with optimization.
Optimization, in this case, is meant to indicate that the debugger
experience may be confusing for the user -- variables optimized away,
stepping jumping between source lines -- and the driver may want to
provide some guidance to the user about this.
Returns false if unoptimized, or unknown."
) lldb::SBFunction::GetIsOptimized;

View File

@@ -0,0 +1,19 @@
STRING_EXTENSION_OUTSIDE(SBFunction)
%extend lldb::SBFunction {
#ifdef SWIGPYTHON
%pythoncode %{
def get_instructions_from_current_target (self):
return self.GetInstructions (target)
addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this function.''')
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.''')
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.''')
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.''')
mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this function as a string.''')
name = property(GetName, None, doc='''A read only property that returns the name for this function as a string.''')
prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''')
type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the return type (lldb.SBType) for this function.''')
%}
#endif
}

View File

@@ -1,52 +0,0 @@
//===-- SWIG Interface for SBHostOS -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Provides information about the host system."
) SBHostOS;
class SBHostOS
{
public:
static lldb::SBFileSpec
GetProgramFileSpec ();
static lldb::SBFileSpec
GetLLDBPythonPath ();
static lldb::SBFileSpec
GetLLDBPath (lldb::PathType path_type);
static lldb::SBFileSpec
GetUserHomeDirectory ();
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

View File

@@ -0,0 +1,3 @@
%feature("docstring",
"Provides information about the host system."
) lldb::SBHostOS;

View File

@@ -1,110 +0,0 @@
//===-- SWIG Interface for SBInstruction ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <stdio.h>
// There's a lot to be fixed here, but need to wait for underlying insn implementation
// to be revised & settle down first.
namespace lldb {
%feature("docstring",
"Represents a (machine language) instruction."
) SBInstruction;
class SBInstruction
{
public:
SBInstruction ();
SBInstruction (const SBInstruction &rhs);
~SBInstruction ();
bool
IsValid();
explicit operator bool() const;
lldb::SBAddress
GetAddress();
const char *
GetMnemonic (lldb::SBTarget target);
const char *
GetOperands (lldb::SBTarget target);
const char *
GetComment (lldb::SBTarget target);
lldb::InstructionControlFlowKind
GetControlFlowKind(lldb::SBTarget target);
lldb::SBData
GetData (lldb::SBTarget target);
size_t
GetByteSize ();
bool
DoesBranch ();
bool
HasDelaySlot ();
bool
CanSetBreakpoint ();
void
Print (lldb::SBFile out);
void
Print (lldb::FileSP BORROWED);
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);
STRING_EXTENSION(SBInstruction)
#ifdef SWIGPYTHON
%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)
mnemonic = property(__mnemonic_property__, None, doc='''A read only property that returns the mnemonic for this instruction as a string.''')
operands = property(__operands_property__, None, doc='''A read only property that returns the operands for this instruction as a string.''')
comment = property(__comment_property__, None, doc='''A read only property that returns the comment for this instruction as a string.''')
addr = property(GetAddress, None, doc='''A read only property that returns an lldb object that represents the address (lldb.SBAddress) for this instruction.''')
size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes for this instruction as an integer.''')
is_branch = property(DoesBranch, None, doc='''A read only property that returns a boolean value that indicates if this instruction is a branch instruction.''')
%}
#endif
};
} // namespace lldb

View File

@@ -0,0 +1,3 @@
%feature("docstring",
"Represents a (machine language) instruction."
) lldb::SBInstruction;

View File

@@ -0,0 +1,25 @@
STRING_EXTENSION_OUTSIDE(SBInstruction)
%extend lldb::SBInstruction {
#ifdef SWIGPYTHON
%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)
mnemonic = property(__mnemonic_property__, None, doc='''A read only property that returns the mnemonic for this instruction as a string.''')
operands = property(__operands_property__, None, doc='''A read only property that returns the operands for this instruction as a string.''')
comment = property(__comment_property__, None, doc='''A read only property that returns the comment for this instruction as a string.''')
addr = property(GetAddress, None, doc='''A read only property that returns an lldb object that represents the address (lldb.SBAddress) for this instruction.''')
size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes for this instruction as an integer.''')
is_branch = property(DoesBranch, None, doc='''A read only property that returns a boolean value that indicates if this instruction is a branch instruction.''')
%}
#endif
}

View File

@@ -1,109 +0,0 @@
//===-- SWIG Interface for SBInstructionList --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <stdio.h>
namespace lldb {
%feature("docstring",
"Represents a list of machine instructions. SBFunction and SBSymbol have
GetInstructions() methods which return SBInstructionList instances.
SBInstructionList supports instruction (:py:class:`SBInstruction` instance) iteration.
For example (see also :py:class:`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;
explicit operator bool() const;
size_t
GetSize ();
lldb::SBInstruction
GetInstructionAtIndex (uint32_t idx);
size_t GetInstructionsCount(const SBAddress &start, const SBAddress &end,
bool canSetBreakpoint);
void
Clear ();
void
AppendInstruction (lldb::SBInstruction inst);
void
Print (lldb::SBFile out);
void
Print (lldb::FileSP BORROWED);
bool
GetDescription (lldb::SBStream &description);
bool
DumpEmulationForAllInstructions (const char *triple);
STRING_EXTENSION(SBInstructionList)
#ifdef SWIGPYTHON
%pythoncode %{
def __iter__(self):
'''Iterate over all instructions in a lldb.SBInstructionList
object.'''
return lldb_iter(self, 'GetSize', 'GetInstructionAtIndex')
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
count = len(self)
if -count <= key < count:
key %= count
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
%}
#endif
};
} // namespace lldb

View File

@@ -0,0 +1,14 @@
%feature("docstring",
"Represents a list of machine instructions. SBFunction and SBSymbol have
GetInstructions() methods which return SBInstructionList instances.
SBInstructionList supports instruction (:py:class:`SBInstruction` instance) iteration.
For example (see also :py:class:`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."
) lldb::SBInstructionList;

View File

@@ -0,0 +1,39 @@
STRING_EXTENSION_OUTSIDE(SBInstructionList)
%extend lldb::SBInstructionList {
#ifdef SWIGPYTHON
%pythoncode %{
def __iter__(self):
'''Iterate over all instructions in a lldb.SBInstructionList
object.'''
return lldb_iter(self, 'GetSize', 'GetInstructionAtIndex')
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
count = len(self)
if -count <= key < count:
key %= count
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
%}
#endif
}

View File

@@ -1,24 +0,0 @@
//===-- SWIG Interface for SBLanguageRuntime --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Utility functions for :ref:`LanguageType`"
) SBLanguageRuntime;
class SBLanguageRuntime
{
public:
static lldb::LanguageType
GetLanguageTypeFromString (const char *string);
static const char *
GetNameForLanguageType (lldb::LanguageType language);
};
} // namespace lldb

View File

@@ -0,0 +1,3 @@
%feature("docstring",
"Utility functions for :ref:`LanguageType`"
) lldb::SBLanguageRuntime;

View File

@@ -1,150 +0,0 @@
//===-- SWIG Interface for SBLaunchInfo--------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Describes how a target or program should be launched."
) SBLaunchInfo;
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
SetEnvironment(const SBEnvironment &env, bool append);
SBEnvironment
GetEnvironment();
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);
const char *
GetScriptedProcessClassName() const;
void SetScriptedProcessClassName(const char *class_name);
lldb::SBStructuredData
GetScriptedProcessDictionary() const;
void SetScriptedProcessDictionary(lldb::SBStructuredData dict);
};
} // namespace lldb

View File

@@ -0,0 +1,3 @@
%feature("docstring",
"Describes how a target or program should be launched."
) lldb::SBLaunchInfo;

View File

@@ -1,102 +0,0 @@
//===-- SWIG Interface for SBLineEntry --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Specifies an association with a contiguous range of instructions and
a source file location.
:py:class:`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 :py:class:`SBCompileUnit` ."
) SBLineEntry;
class SBLineEntry
{
public:
SBLineEntry ();
SBLineEntry (const lldb::SBLineEntry &rhs);
~SBLineEntry ();
lldb::SBAddress
GetStartAddress () const;
lldb::SBAddress
GetEndAddress () const;
bool
IsValid () const;
explicit operator bool() 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;
STRING_EXTENSION(SBLineEntry)
#ifdef SWIGPYTHON
%pythoncode %{
file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''')
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.''')
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.''')
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.''')
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.''')
%}
#endif
};
} // namespace lldb

View File

@@ -0,0 +1,30 @@
%feature("docstring",
"Specifies an association with a contiguous range of instructions and
a source file location.
:py:class:`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 :py:class:`SBCompileUnit` ."
) lldb::SBLineEntry;

View File

@@ -0,0 +1,13 @@
STRING_EXTENSION_OUTSIDE(SBLineEntry)
%extend lldb::SBLineEntry {
#ifdef SWIGPYTHON
%pythoncode %{
file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''')
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.''')
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.''')
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.''')
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.''')
%}
#endif
}

View File

@@ -1,100 +0,0 @@
//===-- SWIG Interface for SBListener ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"API clients can register its own listener to debugger events.
See also :py:class:`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;
explicit operator bool() 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

View File

@@ -0,0 +1,5 @@
%feature("docstring",
"API clients can register its own listener to debugger events.
See also :py:class:`SBEvent` for example usage of creating and adding a listener."
) lldb::SBListener;

View File

@@ -1,100 +0,0 @@
//===-- SWIG Interface for SBMemoryRegionInfo -------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"API clients can get information about memory regions in processes."
) SBMemoryRegionInfo;
class SBMemoryRegionInfo
{
public:
SBMemoryRegionInfo ();
SBMemoryRegionInfo (const lldb::SBMemoryRegionInfo &rhs);
SBMemoryRegionInfo::SBMemoryRegionInfo(const char *name, lldb::addr_t begin,
lldb::addr_t end, uint32_t permissions, bool mapped, bool stack_memory);
~SBMemoryRegionInfo ();
void
Clear();
lldb::addr_t
GetRegionBase ();
lldb::addr_t
GetRegionEnd ();
bool
IsReadable ();
bool
IsWritable ();
bool
IsExecutable ();
bool
IsMapped ();
const char *
GetName ();
%feature("autodoc", "
GetRegionEnd(SBMemoryRegionInfo self) -> lldb::addr_t
Returns whether this memory region has a list of modified (dirty)
pages available or not. When calling GetNumDirtyPages(), you will
have 0 returned for both \"dirty page list is not known\" and
\"empty dirty page list\" (that is, no modified pages in this
memory region). You must use this method to disambiguate.") HasDirtyMemoryPageList;
bool
HasDirtyMemoryPageList();
%feature("autodoc", "
GetNumDirtyPages(SBMemoryRegionInfo self) -> uint32_t
Return the number of dirty (modified) memory pages in this
memory region, if available. You must use the
SBMemoryRegionInfo::HasDirtyMemoryPageList() method to
determine if a dirty memory list is available; it will depend
on the target system can provide this information.") GetNumDirtyPages;
uint32_t
GetNumDirtyPages();
%feature("autodoc", "
GetDirtyPageAddressAtIndex(SBMemoryRegionInfo self, uint32_t idx) -> lldb::addr_t
Return the address of a modified, or dirty, page of memory.
If the provided index is out of range, or this memory region
does not have dirty page information, LLDB_INVALID_ADDRESS
is returned.") GetDirtyPageAddressAtIndex;
addr_t
GetDirtyPageAddressAtIndex(uint32_t idx);
%feature("autodoc", "
GetPageSize(SBMemoryRegionInfo self) -> int
Return the size of pages in this memory region. 0 will be returned
if this information was unavailable.") GetPageSize();
int
GetPageSize();
bool
operator == (const lldb::SBMemoryRegionInfo &rhs) const;
bool
operator != (const lldb::SBMemoryRegionInfo &rhs) const;
bool
GetDescription (lldb::SBStream &description);
STRING_EXTENSION(SBMemoryRegionInfo)
};
} // namespace lldb

View File

@@ -0,0 +1,35 @@
%feature("docstring",
"API clients can get information about memory regions in processes."
) lldb::SBMemoryRegionInfo;
%feature("autodoc", "
GetRegionEnd(SBMemoryRegionInfo self) -> lldb::addr_t
Returns whether this memory region has a list of modified (dirty)
pages available or not. When calling GetNumDirtyPages(), you will
have 0 returned for both \"dirty page list is not known\" and
\"empty dirty page list\" (that is, no modified pages in this
memory region). You must use this method to disambiguate."
) lldb::SBMemoryRegionInfo::HasDirtyMemoryPageList;
%feature("autodoc", "
GetNumDirtyPages(SBMemoryRegionInfo self) -> uint32_t
Return the number of dirty (modified) memory pages in this
memory region, if available. You must use the
SBMemoryRegionInfo::HasDirtyMemoryPageList() method to
determine if a dirty memory list is available; it will depend
on the target system can provide this information."
) lldb::SBMemoryRegionInfo::GetNumDirtyPages;
%feature("autodoc", "
GetDirtyPageAddressAtIndex(SBMemoryRegionInfo self, uint32_t idx) -> lldb::addr_t
Return the address of a modified, or dirty, page of memory.
If the provided index is out of range, or this memory region
does not have dirty page information, LLDB_INVALID_ADDRESS
is returned."
) lldb::SBMemoryRegionInfo::GetDirtyPageAddressAtIndex;
%feature("autodoc", "
GetPageSize(SBMemoryRegionInfo self) -> int
Return the size of pages in this memory region. 0 will be returned
if this information was unavailable."
) lldb::SBMemoryRegionInfo::GetPageSize();

View File

@@ -0,0 +1 @@
STRING_EXTENSION_OUTSIDE(SBMemoryRegionInfo)

View File

@@ -1,43 +0,0 @@
//===-- SBMemoryRegionInfoList.h --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Represents a list of :py:class:`SBMemoryRegionInfo`."
) SBMemoryRegionInfoList;
class SBMemoryRegionInfoList
{
public:
SBMemoryRegionInfoList ();
SBMemoryRegionInfoList (const lldb::SBMemoryRegionInfoList &rhs);
~SBMemoryRegionInfoList ();
uint32_t
GetSize () const;
bool
GetMemoryRegionContainingAddress (lldb::addr_t addr, SBMemoryRegionInfo &region_info);
bool
GetMemoryRegionAtIndex (uint32_t idx, SBMemoryRegionInfo &region_info);
void
Append (lldb::SBMemoryRegionInfo &region);
void
Append (lldb::SBMemoryRegionInfoList &region_list);
void
Clear ();
};
} // namespace lldb

View File

@@ -0,0 +1,3 @@
%feature("docstring",
"Represents a list of :py:class:`SBMemoryRegionInfo`."
) lldb::SBMemoryRegionInfoList;

View File

@@ -0,0 +1,214 @@
%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 :py:class:`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 comparison 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
:py:class:`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
"
) lldb::SBModule;
%feature("docstring", "
Check if the module is file backed.
@return
True, if the module is backed by an object file on disk.
False, if the module is backed by an object file in memory."
) lldb::SBModule::IsFileBacked;
%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."
) lldb::SBModule::GetFileSpec;
%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."
) lldb::SBModule::GetPlatformFileSpec;
%feature("docstring", "Returns the UUID of the module as a Python string."
) lldb::SBModule::GetUUIDString;
%feature("docstring", "
Find compile units related to this module and passed source
file.
@param[in] sb_file_spec
A :py:class:`SBFileSpec` object that contains source file
specification.
@return
A :py:class:`SBSymbolContextList` that gets filled in with all of
the symbol contexts for all the matches."
) lldb::SBModule::FindCompileUnits;
%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."
) lldb::SBModule::FindFunctions;
%feature("docstring", "
Get all types matching 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 type_mask"
) lldb::SBModule::GetTypes;
%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 max_matches.
@return
A list of matched variables in an SBValueList."
) lldb::SBModule::FindGlobalVariables;
%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)."
) lldb::SBModule::FindFirstGlobalVariable;
%feature("docstring", "
Returns the number of modules in the module cache. This is an
implementation detail exposed for testing and should not be relied upon.
@return
The number of modules in the module cache."
) lldb::SBModule::GetNumberAllocatedModules;
%feature("docstring", "
Removes all modules which are no longer needed by any part of LLDB from
the module cache.
This is an implementation detail exposed for testing and should not be
relied upon. Use SBDebugger::MemoryPressureDetected instead to reduce
LLDB's memory consumption during execution.
") lldb::SBModule::GarbageCollectAllocatedModules;

View File

@@ -1,13 +1,3 @@
//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
#ifdef SWIGPYTHON
%pythoncode%{
# ==================================
@@ -33,349 +23,9 @@ def in_range(symbol, section):
%}
#endif
%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 :py:class:`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 comparison 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
:py:class:`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;
explicit operator bool() const;
void
Clear();
%feature("docstring", "
Check if the module is file backed.
@return
True, if the module is backed by an object file on disk.
False, if the module is backed by an object file in memory.") IsFileBacked;
bool
IsFileBacked() const;
%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;
bool operator==(const lldb::SBModule &rhs) const;
bool operator!=(const lldb::SBModule &rhs) 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);
%feature("docstring", "
Find compile units related to this module and passed source
file.
@param[in] sb_file_spec
A :py:class:`SBFileSpec` object that contains source file
specification.
@return
A :py:class:`SBSymbolContextList` that gets filled in with all of
the symbol contexts for all the matches.") FindCompileUnits;
lldb::SBSymbolContextList
FindCompileUnits (const lldb::SBFileSpec &sb_file_spec);
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 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 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 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;
lldb::SBAddress
GetObjectFileEntryPointAddress() const;
%feature("docstring", "
Returns the number of modules in the module cache. This is an
implementation detail exposed for testing and should not be relied upon.
@return
The number of modules in the module cache.") GetNumberAllocatedModules;
static uint32_t
GetNumberAllocatedModules();
%feature("docstring", "
Removes all modules which are no longer needed by any part of LLDB from
the module cache.
This is an implementation detail exposed for testing and should not be
relied upon. Use SBDebugger::MemoryPressureDetected instead to reduce
LLDB's memory consumption during execution.
") GarbageCollectAllocatedModules;
static void
GarbageCollectAllocatedModules();
STRING_EXTENSION(SBModule)
STRING_EXTENSION_OUTSIDE(SBModule)
%extend lldb::SBModule {
#ifdef SWIGPYTHON
%pythoncode %{
def __len__(self):
@@ -581,7 +231,4 @@ public:
%}
#endif
};
} // namespace lldb
}

View File

@@ -1,137 +0,0 @@
//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
class SBModuleSpec
{
public:
SBModuleSpec ();
SBModuleSpec (const lldb::SBModuleSpec &rhs);
~SBModuleSpec ();
bool
IsValid () const;
explicit operator bool() const;
void
Clear();
%feature("docstring", "
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.") GetFileSpec;
lldb::SBFileSpec
GetFileSpec ();
void
SetFileSpec (const lldb::SBFileSpec &fspec);
%feature("docstring", "
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.") GetPlatformFileSpec;
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);
STRING_EXTENSION(SBModuleSpec)
};
%feature("docstring",
"Represents a list of :py:class:`SBModuleSpec`."
) SBModuleSpecList;
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);
STRING_EXTENSION(SBModuleSpecList)
};
} // namespace lldb

View File

@@ -0,0 +1,30 @@
%feature("docstring", "
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::SBModuleSpec::GetFileSpec;
%feature("docstring", "
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::SBModuleSpec::GetPlatformFileSpec;
%feature("docstring",
"Represents a list of :py:class:`SBModuleSpec`."
) lldb::SBModuleSpecList;

View File

@@ -0,0 +1,3 @@
STRING_EXTENSION_OUTSIDE(SBModuleSpec)
STRING_EXTENSION_OUTSIDE(SBModuleSpecList)

View File

@@ -1,218 +0,0 @@
//===-- SWIG Interface for SBPlatform ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Describes how :py:class:`SBPlatform.ConnectRemote` connects to a remote platform."
) SBPlatformConnectOptions;
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);
};
%feature("docstring",
"Represents a shell command that can be run by :py:class:`SBPlatform.Run`."
) SBPlatformShellCommand;
class SBPlatformShellCommand
{
public:
SBPlatformShellCommand (const char *shell, const char *shell_command);
SBPlatformShellCommand (const char *shell_command);
SBPlatformShellCommand (const SBPlatformShellCommand &rhs);
~SBPlatformShellCommand();
void
Clear();
const char *
GetShell();
void
SetShell(const char *shell_interpreter);
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 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 :py:class:`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();
static SBPlatform GetHostPlatform();
bool
IsValid () const;
explicit operator bool() 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 ();
void
SetSDKRoot(const char *sysroot);
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);
lldb::SBUnixSignals
GetUnixSignals();
lldb::SBEnvironment
GetEnvironment();
};
} // namespace lldb

View File

@@ -0,0 +1,31 @@
%feature("docstring",
"Describes how :py:class:`SBPlatform.ConnectRemote` connects to a remote platform."
) lldb::SBPlatformConnectOptions;
%feature("docstring",
"Represents a shell command that can be run by :py:class:`SBPlatform.Run`."
) lldb::SBPlatformShellCommand;
%feature("docstring",
"A class that represents 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 :py:class:`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."
) lldb::SBPlatform;

View File

@@ -1,536 +0,0 @@
//===-- SWIG Interface for SBProcess ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
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:
enum
{
eBroadcastBitStateChanged = (1 << 0),
eBroadcastBitInterrupt = (1 << 1),
eBroadcastBitSTDOUT = (1 << 2),
eBroadcastBitSTDERR = (1 << 3),
eBroadcastBitProfileData = (1 << 4),
eBroadcastBitStructuredData = (1 << 5)
};
SBProcess ();
SBProcess (const lldb::SBProcess& rhs);
~SBProcess();
static const char *
GetBroadcasterClassName ();
const char *
GetPluginName ();
const char *
GetShortPluginName ();
void
Clear ();
bool
IsValid() const;
explicit operator bool() 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, SBFile out) const;
void
ReportEventState (const lldb::SBEvent &event, FileSP BORROWED) 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 *char_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
GetInterruptedFromEvent (const lldb::SBEvent &event);
static lldb::SBStructuredData
GetStructuredDataFromEvent (const lldb::SBEvent &event);
static bool
EventIsProcessEvent (const lldb::SBEvent &event);
static bool
EventIsStructuredDataEvent (const lldb::SBEvent &event);
lldb::SBBroadcaster
GetBroadcaster () const;
bool
GetDescription (lldb::SBStream &description);
%feature("autodoc", "
Returns the implementation object of the process plugin if available. None
otherwise.") GetScriptedImplementation;
ScriptedObject
GetScriptedImplementation();
%feature("autodoc", "
Returns the process' extended crash information.") GetExtendedCrashInformation;
lldb::SBStructuredData
GetExtendedCrashInformation ();
uint32_t
GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const;
uint32_t
LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error);
%feature("autodoc", "
Load the library whose filename is given by image_spec looking in all the
paths supplied in the paths argument. If successful, return a token that
can be passed to UnloadImage and fill loaded_path with the path that was
successfully loaded. On failure, return
lldb.LLDB_INVALID_IMAGE_TOKEN.") LoadImageUsingPaths;
uint32_t
LoadImageUsingPaths(const lldb::SBFileSpec &image_spec,
SBStringList &paths,
lldb::SBFileSpec &loaded_path,
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);
lldb::SBError
SaveCore(const char *file_name, const char *flavor, lldb::SaveCoreStyle core_style);
lldb::SBError
SaveCore(const char *file_name);
lldb::SBError
GetMemoryRegionInfo(lldb::addr_t load_addr, lldb::SBMemoryRegionInfo &region_info);
lldb::SBMemoryRegionInfoList
GetMemoryRegions();
%feature("autodoc", "
Get information about the process.
Valid process info will only be returned when the process is alive,
use IsValid() to check if the info returned is valid. ::
process_info = process.GetProcessInfo()
if process_info.IsValid():
process_info.GetProcessID()") GetProcessInfo;
lldb::SBProcessInfo
GetProcessInfo();
%feature("autodoc", "
Allocates a block of memory within the process, with size and
access permissions specified in the arguments. The permissions
argument is an or-combination of zero or more of
lldb.ePermissionsWritable, lldb.ePermissionsReadable, and
lldb.ePermissionsExecutable. Returns the address
of the allocated buffer in the process, or
lldb.LLDB_INVALID_ADDRESS if the allocation failed.") AllocateMemory;
lldb::addr_t
AllocateMemory(size_t size, uint32_t permissions, lldb::SBError &error);
%feature("autodoc", "
Deallocates the block of memory (previously allocated using
AllocateMemory) given in the argument.") DeallocateMemory;
lldb::SBError
DeallocateMemory(lldb::addr_t ptr);
STRING_EXTENSION(SBProcess)
#ifdef SWIGPYTHON
%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_stopped__(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 isinstance(key, int):
count = len(self)
if -count <= key < count:
key %= count
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
def __iter__(self):
'''Iterate over all threads in a lldb.SBProcess object.'''
return lldb_iter(self, 'GetNumThreads', 'GetThreadAtIndex')
def __len__(self):
'''Return the number of threads in a lldb.SBProcess object.'''
return self.GetNumThreads()
threads = property(get_process_thread_list, None, doc='''A read only property that returns a list() of lldb.SBThread objects for this process.''')
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]).''')
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.''')
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.''')
is_stopped = property(__get_is_stopped__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently stopped.''')
id = property(GetProcessID, None, doc='''A read only property that returns the process ID as an integer.''')
target = property(GetTarget, None, doc='''A read only property that an lldb object that represents the target (lldb.SBTarget) that owns this process.''')
num_threads = property(GetNumThreads, None, doc='''A read only property that returns the number of threads in this process as an integer.''')
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.''')
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.).''')
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.''')
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.''')
broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.''')
%}
#endif
};
} // namespace lldb

View File

@@ -0,0 +1,215 @@
%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
"
) lldb::SBProcess;
%feature("autodoc", "
Writes data into the current process's stdin. API client specifies a Python
string as the only argument."
) lldb::SBProcess::PutSTDIN;
%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."
) lldb::SBProcess::GetSTDOUT;
%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."
) lldb::SBProcess::GetSTDERR;
%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."
) lldb::SBProcess::RemoteAttachToProcessWithID;
%feature("docstring",
"See SBTarget.Launch for argument description and usage."
) lldb::SBProcess::RemoteLaunch;
%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."
) lldb::SBProcess::GetThreadAtIndex;
%feature("autodoc", "
Returns the thread with the given thread ID."
) lldb::SBProcess::GetThreadByID;
%feature("autodoc", "
Returns the thread with the given thread IndexID."
) lldb::SBProcess::GetThreadByIndexID;
%feature("autodoc", "
Returns the currently selected thread."
) lldb::SBProcess::GetSelectedThread;
%feature("autodoc", "
Lazily create a thread on demand through the current OperatingSystem plug-in, if the current OperatingSystem plug-in supports it."
) lldb::SBProcess::CreateOSPluginThread;
%feature("autodoc", "
Returns the process ID of the process."
) lldb::SBProcess::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."
) lldb::SBProcess::GetUniqueID;
%feature("docstring", "
Kills the process and shuts down all threads that were spawned to
track and monitor process."
) lldb::SBProcess::Destroy;
%feature("docstring", "Same as Destroy(self).") lldb::SBProcess::Kill;
%feature("docstring", "Sends the process a unix signal.") lldb::SBProcess::Signal;
%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."
) lldb::SBProcess::GetStopID;
%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)"
) lldb::SBProcess::ReadMemory;
%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!')"
) lldb::SBProcess::WriteMemory;
%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)"
) lldb::SBProcess::ReadCStringFromMemory;
%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)"
) lldb::SBProcess::ReadUnsignedFromMemory;
%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)"
) lldb::SBProcess::ReadPointerFromMemory;
%feature("autodoc", "
Returns the implementation object of the process plugin if available. None
otherwise."
) lldb::SBProcess::GetScriptedImplementation;
%feature("autodoc", "
Returns the process' extended crash information."
) lldb::SBProcess::GetExtendedCrashInformation;
%feature("autodoc", "
Load the library whose filename is given by image_spec looking in all the
paths supplied in the paths argument. If successful, return a token that
can be passed to UnloadImage and fill loaded_path with the path that was
successfully loaded. On failure, return
lldb.LLDB_INVALID_IMAGE_TOKEN."
) lldb::SBProcess::LoadImageUsingPaths;
%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)."
) lldb::SBProcess::GetNumExtendedBacktraceTypes;
%feature("autodoc", "
Takes an index argument, returns the name of one of the thread-origin
extended backtrace methods as a str."
) lldb::SBProcess::GetExtendedBacktraceTypeAtIndex;
%feature("autodoc", "
Get information about the process.
Valid process info will only be returned when the process is alive,
use IsValid() to check if the info returned is valid. ::
process_info = process.GetProcessInfo()
if process_info.IsValid():
process_info.GetProcessID()"
) lldb::SBProcess::GetProcessInfo;
%feature("autodoc", "
Allocates a block of memory within the process, with size and
access permissions specified in the arguments. The permissions
argument is an or-combination of zero or more of
lldb.ePermissionsWritable, lldb.ePermissionsReadable, and
lldb.ePermissionsExecutable. Returns the address
of the allocated buffer in the process, or
lldb.LLDB_INVALID_ADDRESS if the allocation failed."
) lldb::SBProcess::AllocateMemory;
%feature("autodoc", "
Deallocates the block of memory (previously allocated using
AllocateMemory) given in the argument."
) lldb::SBProcess::DeallocateMemory;

View File

@@ -0,0 +1,86 @@
STRING_EXTENSION_OUTSIDE(SBProcess)
%extend lldb::SBProcess {
#ifdef SWIGPYTHON
%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_stopped__(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 isinstance(key, int):
count = len(self)
if -count <= key < count:
key %= count
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
def __iter__(self):
'''Iterate over all threads in a lldb.SBProcess object.'''
return lldb_iter(self, 'GetNumThreads', 'GetThreadAtIndex')
def __len__(self):
'''Return the number of threads in a lldb.SBProcess object.'''
return self.GetNumThreads()
threads = property(get_process_thread_list, None, doc='''A read only property that returns a list() of lldb.SBThread objects for this process.''')
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]).''')
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.''')
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.''')
is_stopped = property(__get_is_stopped__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently stopped.''')
id = property(GetProcessID, None, doc='''A read only property that returns the process ID as an integer.''')
target = property(GetTarget, None, doc='''A read only property that an lldb object that represents the target (lldb.SBTarget) that owns this process.''')
num_threads = property(GetNumThreads, None, doc='''A read only property that returns the number of threads in this process as an integer.''')
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.''')
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.).''')
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.''')
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.''')
broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.''')
%}
#endif
}

View File

@@ -1,73 +0,0 @@
//===-- SWIG Interface for SBProcessInfo-------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Describes an existing process and any discoverable information that pertains to
that process."
) SBProcessInfo;
class SBProcessInfo
{
public:
SBProcessInfo();
SBProcessInfo (const SBProcessInfo &rhs);
~SBProcessInfo ();
bool
IsValid ();
explicit operator bool() const;
const char *
GetName ();
SBFileSpec
GetExecutableFile ();
lldb::pid_t
GetProcessID ();
uint32_t
GetUserID ();
uint32_t
GetGroupID ();
bool
UserIDIsValid ();
bool
GroupIDIsValid ();
uint32_t
GetEffectiveUserID ();
uint32_t
GetEffectiveGroupID ();
bool
EffectiveUserIDIsValid ();
bool
EffectiveGroupIDIsValid ();
lldb::pid_t
GetParentProcessID ();
%feature("docstring",
"Return the target triple (arch-vendor-os) for the described process."
) GetTriple;
const char *
GetTriple ();
};
} // namespace lldb

View File

@@ -0,0 +1,8 @@
%feature("docstring",
"Describes an existing process and any discoverable information that pertains to
that process."
) lldb::SBProcessInfo;
%feature("docstring",
"Return the target triple (arch-vendor-os) for the described process."
) lldb::SBProcessInfo::GetTriple;

View File

@@ -1,77 +0,0 @@
//===-- SWIG Interface for SBQueue.h -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Represents a libdispatch queue in the process."
) SBQueue;
class SBQueue
{
public:
SBQueue ();
SBQueue (const lldb::QueueSP& queue_sp);
~SBQueue();
bool
IsValid() const;
explicit operator bool() 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

View File

@@ -0,0 +1,16 @@
%feature("docstring",
"Represents a libdispatch queue in the process."
) lldb::SBQueue;
%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."
) lldb::SBQueue::GetQueueID;
%feature("autodoc", "
Returns an lldb::QueueKind enumerated value (e.g. eQueueKindUnknown,
eQueueKindSerial, eQueueKindConcurrent) describing the type of this
queue."
) lldb::SBQueue::GetKind;

View File

@@ -1,50 +0,0 @@
//===-- SWIG Interface for SBQueueItem.h ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"This class represents an item in an :py:class:`SBQueue`."
) SBQueueItem;
class SBQueueItem
{
public:
SBQueueItem ();
SBQueueItem (const lldb::QueueItemSP& queue_item_sp);
~SBQueueItem();
bool
IsValid() const;
explicit operator bool() 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

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