mirror of
https://github.com/intel/llvm.git
synced 2026-01-18 07:57:36 +08:00
Export the watchpoint related API (SBWatchpointLocation class and added SBTarget methods)
to the Python interface. Implement yet another (threre're 3 now) iterator protocol for SBTarget: watchpoint_location_iter(), to iterate on the available watchpoint locations. And add a print representation for SBWatchpointLocation. Exercise some of these Python API with TestWatchpointLocationIter.py. llvm-svn: 140595
This commit is contained in:
@@ -71,7 +71,8 @@ HEADER_FILES="${SRC_ROOT}/include/lldb/lldb.h"\
|
||||
" ${SRC_ROOT}/include/lldb/API/SBThread.h"\
|
||||
" ${SRC_ROOT}/include/lldb/API/SBType.h"\
|
||||
" ${SRC_ROOT}/include/lldb/API/SBValue.h"\
|
||||
" ${SRC_ROOT}/include/lldb/API/SBValueList.h"
|
||||
" ${SRC_ROOT}/include/lldb/API/SBValueList.h"\
|
||||
" ${SRC_ROOT}/include/lldb/API/SBWatchpointLocation.h"\
|
||||
|
||||
INTERFACE_FILES="${SRC_ROOT}/scripts/Python/interface/SBAddress.i"\
|
||||
" ${SRC_ROOT}/scripts/Python/interface/SBBlock.i"\
|
||||
@@ -106,7 +107,8 @@ INTERFACE_FILES="${SRC_ROOT}/scripts/Python/interface/SBAddress.i"\
|
||||
" ${SRC_ROOT}/scripts/Python/interface/SBThread.i"\
|
||||
" ${SRC_ROOT}/scripts/Python/interface/SBType.i"\
|
||||
" ${SRC_ROOT}/scripts/Python/interface/SBValue.i"\
|
||||
" ${SRC_ROOT}/scripts/Python/interface/SBValueList.i"
|
||||
" ${SRC_ROOT}/scripts/Python/interface/SBValueList.i"\
|
||||
" ${SRC_ROOT}/scripts/Python/interface/SBWatchpointLocation.i"
|
||||
|
||||
if [ $Debug == 1 ]
|
||||
then
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace lldb {
|
||||
%feature("docstring",
|
||||
"Represents the target program running under the debugger.
|
||||
|
||||
SBTarget supports module and breakpoint iterations. For example,
|
||||
SBTarget supports module, breakpoint, and watchpoint_location iterations. For
|
||||
example,
|
||||
|
||||
for m in target.module_iter():
|
||||
print m
|
||||
@@ -34,7 +35,18 @@ and,
|
||||
produces:
|
||||
|
||||
SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1
|
||||
SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1"
|
||||
SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1
|
||||
|
||||
and,
|
||||
|
||||
for wp_loc in target.watchpoint_location_iter():
|
||||
print wp_loc
|
||||
|
||||
produces:
|
||||
|
||||
WatchpointLocation 1: addr = 0x1034ca048 size = 4 state = enabled type = rw
|
||||
declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12'
|
||||
hw_index = 0 hit_count = 2 ignore_count = 0 callback = 0x0 baton = 0x0"
|
||||
) SBTarget;
|
||||
class SBTarget
|
||||
{
|
||||
@@ -423,6 +435,27 @@ public:
|
||||
bool
|
||||
DeleteAllBreakpoints ();
|
||||
|
||||
uint32_t
|
||||
GetNumWatchpointLocations () const;
|
||||
|
||||
lldb::SBWatchpointLocation
|
||||
GetWatchpointLocationAtIndex (uint32_t idx) const;
|
||||
|
||||
bool
|
||||
WatchpointLocationDelete (watch_id_t watch_id);
|
||||
|
||||
lldb::SBWatchpointLocation
|
||||
FindWatchpointLocationByID (watch_id_t watch_id);
|
||||
|
||||
bool
|
||||
EnableAllWatchpointLocations ();
|
||||
|
||||
bool
|
||||
DisableAllWatchpointLocations ();
|
||||
|
||||
bool
|
||||
DeleteAllWatchpointLocations ();
|
||||
|
||||
lldb::SBBroadcaster
|
||||
GetBroadcaster () const;
|
||||
|
||||
|
||||
71
lldb/scripts/Python/interface/SBWatchpointLocation.i
Normal file
71
lldb/scripts/Python/interface/SBWatchpointLocation.i
Normal file
@@ -0,0 +1,71 @@
|
||||
//===-- SWIG Interface for SBWatchpointLocation -----------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace lldb {
|
||||
|
||||
%feature("docstring",
|
||||
"Represents an instance of watchpoint location for a specific target program.
|
||||
|
||||
A watchpoint location is determined by the address and the byte size that
|
||||
resulted in this particular instantiation. Each watchpoint location has its
|
||||
settable options.
|
||||
|
||||
See also SBTarget.watchpoint_location_iter() for for example usage of iterating
|
||||
through the watchpoint locations of the target."
|
||||
) SBWatchpointLocation;
|
||||
class SBWatchpointLocation
|
||||
{
|
||||
public:
|
||||
|
||||
SBWatchpointLocation ();
|
||||
|
||||
SBWatchpointLocation (const lldb::SBWatchpointLocation &rhs);
|
||||
|
||||
~SBWatchpointLocation ();
|
||||
|
||||
watch_id_t
|
||||
GetID () const;
|
||||
|
||||
bool
|
||||
IsValid() const;
|
||||
|
||||
%feature("docstring", "
|
||||
//------------------------------------------------------------------
|
||||
/// With -1 representing an invalid hardware index.
|
||||
//------------------------------------------------------------------
|
||||
") GetHardwareIndex;
|
||||
int32_t
|
||||
GetHardwareIndex () const;
|
||||
|
||||
lldb::addr_t
|
||||
GetWatchAddress () const;
|
||||
|
||||
size_t
|
||||
GetWatchSize() const;
|
||||
|
||||
void
|
||||
SetEnabled(bool enabled);
|
||||
|
||||
bool
|
||||
IsEnabled ();
|
||||
|
||||
uint32_t
|
||||
GetHitCount () const;
|
||||
|
||||
uint32_t
|
||||
GetIgnoreCount ();
|
||||
|
||||
void
|
||||
SetIgnoreCount (uint32_t n);
|
||||
|
||||
bool
|
||||
GetDescription (lldb::SBStream &description, DescriptionLevel level);
|
||||
};
|
||||
|
||||
} // namespace lldb
|
||||
@@ -150,6 +150,7 @@ linked_list_iter_def = '''
|
||||
iter_def = " def __iter__(self): return lldb_iter(self, '%s', '%s')"
|
||||
module_iter = " def module_iter(self): return lldb_iter(self, '%s', '%s')"
|
||||
breakpoint_iter = " def breakpoint_iter(self): return lldb_iter(self, '%s', '%s')"
|
||||
watchpoint_location_iter = " def watchpoint_location_iter(self): return lldb_iter(self, '%s', '%s')"
|
||||
section_iter = " def section_iter(self): return lldb_iter(self, '%s', '%s')"
|
||||
|
||||
# Called to implement the built-in function len().
|
||||
@@ -187,7 +188,8 @@ d = { 'SBBreakpoint': ('GetNumLocations', 'GetLocationAtIndex'),
|
||||
|
||||
# SBTarget needs special processing, see below.
|
||||
'SBTarget': {'module': ('GetNumModules', 'GetModuleAtIndex'),
|
||||
'breakpoint': ('GetNumBreakpoints', 'GetBreakpointAtIndex')
|
||||
'breakpoint': ('GetNumBreakpoints', 'GetBreakpointAtIndex'),
|
||||
'watchpoint_location': ('GetNumWatchpointLocations', 'GetWatchpointLocationAtIndex')
|
||||
},
|
||||
|
||||
# SBModule has an additional section_iter(), see below.
|
||||
@@ -325,10 +327,11 @@ for line in content.splitlines():
|
||||
# We found the beginning of the __init__ method definition.
|
||||
# This is a good spot to insert the iter and/or eq-ne support.
|
||||
#
|
||||
# But note that SBTarget has two types of iterations.
|
||||
# But note that SBTarget has three types of iterations.
|
||||
if cls == "SBTarget":
|
||||
new_content.add_line(module_iter % (d[cls]['module']))
|
||||
new_content.add_line(breakpoint_iter % (d[cls]['breakpoint']))
|
||||
new_content.add_line(watchpoint_location_iter % (d[cls]['watchpoint_location']))
|
||||
else:
|
||||
if (state & DEFINING_ITERATOR):
|
||||
new_content.add_line(iter_def % d[cls])
|
||||
|
||||
@@ -160,4 +160,11 @@
|
||||
return PyString_FromString (description.GetData());
|
||||
}
|
||||
}
|
||||
%extend lldb::SBWatchpointLocation {
|
||||
PyObject *lldb::SBWatchpointLocation::__repr__ (){
|
||||
lldb::SBStream description;
|
||||
$self->GetDescription (description, lldb::eDescriptionLevelVerbose);
|
||||
return PyString_FromString (description.GetData());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user