2011-07-19 05:30:21 +08:00
//===-- SWIG Interface for SBBreakpoint -------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
n a m e s p a c e l l d b {
% f e a t u r e ( "docstring" ,
" R e p r e s e n t s a logical b r e a k p o i n t and i t s a s s o c i a t e d s e t t i n g s .
For e x a m p l e ( from t e s t / f u n c t i o n a l i t i e s / b r e a k p o i n t / b r e a k p o i n t _ i g n o r e _ c o u n t /
T e s t B r e a k p o i n t I g n o r e C o u n t . p y ) ,
def b r e a k p o i n t _ i g n o r e _ c o u n t _ p y t h o n ( self ) :
'''Use Python APIs to set breakpoint ignore count.'''
e x e = o s . p a t h . join ( o s . g e t c w d ( ) , 'a.out' )
# Create a target by t h e debugger .
target = self . d b g . C r e a t e T a r g e t ( e x e )
self . a s s e r t T r u e ( target , V A L I D _ T A R G E T )
# Now create a b r e a k p o i n t on m a i n . c by name 'c' .
b r e a k p o i n t = target . B r e a k p o i n t C r e a t e B y N a m e ( 'c', 'a.out' )
self . a s s e r t T r u e ( b r e a k p o i n t and
b r e a k p o i n t . G e t N u m L o c a t i o n s ( ) = = 1 ,
V A L I D _ B R E A K P O I N T )
# Get t h e b r e a k p o i n t l o c a t i o n from b r e a k p o i n t a f t e r w e v e r i f i e d t h a t ,
# i n d e e d , i t h a s o n e l o c a t i o n .
l o c a t i o n = b r e a k p o i n t . G e t L o c a t i o n A t I n d e x ( 0 )
self . a s s e r t T r u e ( l o c a t i o n and
l o c a t i o n . I s E n a b l e d ( ) ,
V A L I D _ B R E A K P O I N T _ L O C A T I O N )
# Set t h e i g n o r e count on t h e b r e a k p o i n t l o c a t i o n .
l o c a t i o n . S e t I g n o r e C o u n t ( 2 )
self . a s s e r t T r u e ( l o c a t i o n . G e t I g n o r e C o u n t ( ) = = 2 ,
'SetIgnoreCount() works correctly' )
# Now l a u n c h t h e process , and do not stop at entry p o i n t .
process = target . L a u n c h S i m p l e ( None , None , o s . g e t c w d ( ) )
self . a s s e r t T r u e ( process , P R O C E S S _ I S _ V A L I D )
# Frame # 0 s h o u l d b e on m a i n . c : 37 , frame # 1 s h o u l d b e on m a i n . c : 25 , and
# frame # 2 s h o u l d b e on m a i n . c : 48 .
# l l d b u t i l . p r i n t _ s t a c k t r a c e s ( process )
from l l d b u t i l import g e t _ s t o p p e d _ t h r e a d
t h r e a d = g e t _ s t o p p e d _ t h r e a d ( process , l l d b . e S t o p R e a s o n B r e a k p o i n t )
self . a s s e r t T r u e ( t h r e a d ! = None , 'There should be a thread stopped due to breakpoint' )
f r a m e 0 = t h r e a d . G e t F r a m e A t I n d e x ( 0 )
f r a m e 1 = t h r e a d . G e t F r a m e A t I n d e x ( 1 )
f r a m e 2 = t h r e a d . G e t F r a m e A t I n d e x ( 2 )
self . a s s e r t T r u e ( f r a m e 0 . G e t L i n e E n t r y ( ) . G e t L i n e ( ) = = self . l i n e 1 and
f r a m e 1 . G e t L i n e E n t r y ( ) . G e t L i n e ( ) = = self . l i n e 3 and
f r a m e 2 . G e t L i n e E n t r y ( ) . G e t L i n e ( ) = = self . l i n e 4 ,
S T O P P E D _ D U E _ T O _ B R E A K P O I N T _ I G N O R E _ C O U N T )
# T h e h i t count for t h e b r e a k p o i n t s h o u l d b e 3 .
self . a s s e r t T r u e ( b r e a k p o i n t . G e t H i t C o u n t ( ) = = 3 )
process . C o n t i n u e ( )
2011-07-19 07:11:07 +08:00
S B B r e a k p o i n t s u p p o r t s b r e a k p o i n t l o c a t i o n i t e r a t i o n , for e x a m p l e ,
2011-07-19 05:30:21 +08:00
for b l in b r e a k p o i n t :
2015-10-17 01:52:32 +08:00
p r i n t ( 'breakpoint location load addr: %s' % h e x ( b l . G e t L o a d A d d r e s s ( ) ) )
p r i n t ( 'breakpoint location condition: %s' % h e x ( b l . G e t C o n d i t i o n ( ) ) )
2011-07-19 07:11:07 +08:00
and r i c h c o m p a r i o n m e t h o d s w h i c h a l l o w t h e A P I p r o g r a m to use ,
if a B r e a k p o i n t = = b B r e a k p o i n t :
. . .
to c o m p a r e t w o b r e a k p o i n t s for e q u a l i t y . "
) S B B r e a k p o i n t ;
2011-07-19 05:30:21 +08:00
class S B B r e a k p o i n t
{
public :
t y p e def b o o l ( * B r e a k p o i n t H i t C a l l b a c k ) ( void * b a t o n ,
S B P r o c e s s &process,
S B T h r e a d &thread,
l l d b : : S B B r e a k p o i n t L o c a t i o n &location);
S B B r e a k p o i n t ( ) ;
S B B r e a k p o i n t ( c o n s t l l d b : : S B B r e a k p o i n t & rhs);
~ S B B r e a k p o i n t ( ) ;
b r e a k _ i d _ t
G e t I D ( ) c o n s t ;
b o o l
I s V a l i d ( ) c o n s t ;
void
C l e a r A l l B r e a k p o i n t S i t e s ( ) ;
l l d b : : S B B r e a k p o i n t L o c a t i o n
F i n d L o c a t i o n B y A d d r e s s ( l l d b : : a d d r _ t v m _ a d d r ) ;
l l d b : : b r e a k _ i d _ t
F i n d L o c a t i o n I D B y A d d r e s s ( l l d b : : a d d r _ t v m _ a d d r ) ;
l l d b : : S B B r e a k p o i n t L o c a t i o n
F i n d L o c a t i o n B y I D ( l l d b : : b r e a k _ i d _ t b p _ l o c _ i d ) ;
l l d b : : S B B r e a k p o i n t L o c a t i o n
G e t L o c a t i o n A t I n d e x ( u i n t 32 _ t index ) ;
void
S e t E n a b l e d ( b o o l enable ) ;
b o o l
I s E n a b l e d ( ) ;
2012-09-26 07:55:19 +08:00
2012-10-06 03:16:31 +08:00
void
S e t O n e S h o t ( b o o l o n e _ s h o t ) ;
b o o l
I s O n e S h o t ( ) ;
2012-09-26 07:55:19 +08:00
b o o l
I s I n t e r n a l ( ) ;
2011-07-19 05:30:21 +08:00
u i n t 32 _ t
G e t H i t C o u n t ( ) c o n s t ;
void
S e t I g n o r e C o u n t ( u i n t 32 _ t count ) ;
u i n t 32 _ t
G e t I g n o r e C o u n t ( ) c o n s t ;
2011-10-19 03:13:06 +08:00
% f e a t u r e ( "docstring" , "
//--------------------------------------------------------------------------
/// The breakpoint stops only if the condition expression evaluates to true.
//--------------------------------------------------------------------------
" ) S e t C o n d i t i o n ;
2011-07-19 05:30:21 +08:00
void
S e t C o n d i t i o n ( c o n s t char * c o n d i t i o n ) ;
2011-10-19 03:13:06 +08:00
% f e a t u r e ( "docstring" , "
//------------------------------------------------------------------
/// Get the condition expression for the breakpoint.
//------------------------------------------------------------------
" ) G e t C o n d i t i o n ;
2011-07-19 05:30:21 +08:00
c o n s t char *
G e t C o n d i t i o n ( ) ;
void
S e t T h r e a d I D ( l l d b : : t i d _ t s b _ t h r e a d _ i d ) ;
l l d b : : t i d _ t
G e t T h r e a d I D ( ) ;
void
S e t T h r e a d I n d e x ( u i n t 32 _ t index ) ;
u i n t 32 _ t
G e t T h r e a d I n d e x ( ) c o n s t ;
void
S e t T h r e a d N a m e ( c o n s t char * t h r e a d _ n a m e ) ;
c o n s t char *
G e t T h r e a d N a m e ( ) c o n s t ;
void
S e t Q u e u e N a m e ( c o n s t char * q u e u e _ n a m e ) ;
c o n s t char *
G e t Q u e u e N a m e ( ) c o n s t ;
2014-04-02 09:04:55 +08:00
% f e a t u r e ( "docstring" , "
//------------------------------------------------------------------
/// Set the name of the script function to be called when the breakpoint is hit.
//------------------------------------------------------------------
" ) S e t S c r i p t C a l l b a c k F u n c t i o n ;
2011-07-19 05:30:21 +08:00
void
2014-04-02 09:04:55 +08:00
S e t S c r i p t C a l l b a c k F u n c t i o n ( c o n s t char * c a l l b a c k _ f u n c t i o n _ n a m e ) ;
2011-07-19 05:30:21 +08:00
2014-04-02 09:04:55 +08:00
% f e a t u r e ( "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.
//------------------------------------------------------------------
" ) S e t S c r i p t C a l l b a c k B o d y ;
S B E r r o r
S e t S c r i p t C a l l b a c k B o d y ( c o n s t char * s c r i p t _ b o d y _ t e x t ) ;
2016-09-21 06:54:49 +08:00
void S e t C o m m a n d L i n e C o m m a n d s ( S B S t r i n g L i s t &commands);
b o o l G e t C o m m a n d L i n e C o m m a n d s ( S B S t r i n g L i s t &commands);
2014-12-17 07:40:14 +08:00
b o o l
A d d N a m e ( c o n s t char * n e w _ n a m e ) ;
void
R e m o v e N a m e ( c o n s t char * n a m e _ t o _ r e m o v e ) ;
b o o l
M a t c h e s N a m e ( c o n s t char * name ) ;
void
G e t N a m e s ( S B S t r i n g L i s t &names);
2011-07-19 05:30:21 +08:00
s i z e _ t
G e t N u m R e s o l v e d L o c a t i o n s ( ) c o n s t ;
s i z e _ t
G e t N u m L o c a t i o n s ( ) c o n s t ;
b o o l
G e t D e s c r i p t i o n ( l l d b : : S B S t r e a m &description);
2016-09-16 09:41:27 +08:00
b o o l
G e t D e s c r i p t i o n ( l l d b : : S B S t r e a m &description, bool include_locations);
2013-05-03 09:29:27 +08:00
b o o l
o p e r a t o r = = ( c o n s t l l d b : : S B B r e a k p o i n t & rhs);
b o o l
o p e r a t o r ! = ( c o n s t l l d b : : S B B r e a k p o i n t & rhs);
2012-02-08 13:23:15 +08:00
static b o o l
E v e n t I s B r e a k p o i n t E v e n t ( c o n s t l l d b : : S B E v e n t &event);
2011-07-19 05:30:21 +08:00
static l l d b : : B r e a k p o i n t E v e n t T y p e
G e t B r e a k p o i n t E v e n t T y p e F r o m E v e n t ( c o n s t l l d b : : S B E v e n t & event);
static l l d b : : S B B r e a k p o i n t
G e t B r e a k p o i n t F r o m E v e n t ( c o n s t l l d b : : S B E v e n t & event);
static l l d b : : S B B r e a k p o i n t L o c a t i o n
G e t B r e a k p o i n t L o c a t i o n A t I n d e x F r o m E v e n t ( c o n s t l l d b : : S B E v e n t & event, uint32_t loc_idx);
2012-02-08 13:23:15 +08:00
static u i n t 32 _ t
G e t N u m B r e a k p o i n t L o c a t i o n s F r o m E v e n t ( c o n s t l l d b : : S B E v e n t &event_sp);
2013-06-11 06:39:08 +08:00
% p y t h o n c o d e % {
_ _ s w i g _ g e t m e t h o d s _ _ [ "id" ] = G e t I D
if _ n e w c l a s s : i d = property ( G e t I D , None , d o c = '''A read only property that returns the ID of this breakpoint.''' )
_ _ s w i g _ g e t m e t h o d s _ _ [ "enabled" ] = I s E n a b l e d
_ _ s w i g _ s e t m e t h o d s _ _ [ "enabled" ] = S e t E n a b l e d
if _ n e w c l a s s : e n a b l e d = property ( I s E n a b l e d , S e t E n a b l e d , d o c = '''A read/write property that configures whether this breakpoint is enabled or not.''' )
_ _ s w i g _ g e t m e t h o d s _ _ [ "one_shot" ] = I s O n e S h o t
_ _ s w i g _ s e t m e t h o d s _ _ [ "one_shot" ] = S e t O n e S h o t
if _ n e w c l a s s : o n e _ s h o t = property ( I s O n e S h o t , S e t O n e S h o t , d o c = '''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''' )
_ _ s w i g _ g e t m e t h o d s _ _ [ "num_locations" ] = G e t N u m L o c a t i o n s
if _ n e w c l a s s : n u m _ l o c a t i o n s = property ( G e t N u m L o c a t i o n s , None , d o c = '''A read only property that returns the count of locations of this breakpoint.''' )
% }
2011-07-19 05:30:21 +08:00
} ;
2016-09-15 03:07:35 +08:00
class S B B r e a k p o i n t L i s t I m p l ;
class L L D B _ A P I S B B r e a k p o i n t L i s t
{
public :
S B B r e a k p o i n t L i s t ( S B T a r g e t &target);
~ S B B r e a k p o i n t L i s t ( ) ;
s i z e _ t G e t S i z e ( ) c o n s t ;
S B B r e a k p o i n t
G e t B r e a k p o i n t A t I n d e x ( s i z e _ t i d x ) ;
2016-09-16 09:41:27 +08:00
S B B r e a k p o i n t
F i n d B r e a k p o i n t B y I D ( l l d b : : b r e a k _ i d _ t ) ;
2016-09-15 03:07:35 +08:00
void Append ( c o n s t S B B r e a k p o i n t &sb_bkpt);
b o o l A p p e n d I f U n i q u e ( c o n s t S B B r e a k p o i n t &sb_bkpt);
void A p p e n d B y I D ( l l d b : : b r e a k _ i d _ t i d ) ;
void Clear ( ) ;
private :
s t d : : s h a r e d _ p t r < S B B r e a k p o i n t L i s t I m p l > m _ o p a q u e _ s p ;
} ;
2011-07-19 05:30:21 +08:00
} // namespace lldb