2011-07-19 04:13:38 +08:00
//===-- SWIG Interface for SBThread -----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
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 t h r e a d of e x e c u t i o n . S B P r o c e s s contains S B T h r e a d ( s ) .
2012-07-14 04:18:18 +08:00
S B T h r e a d s c a n b e r e f e r r e d to by t h e i r I D , w h i c h m a p s to t h e s y s t e m s p e c i f i c t h r e a d
i d e n t i f i e r , or by I n d e x I D . T h e I D m a y or m a y not b e unique d e p e n d i n g on w h e t h e r t h e
s y s t e m r e u s e s i t s t h r e a d i d e n t i f i e r s . T h e I n d e x I D is a m o n o t o n i c a l l y i n c r e a s i n g i d e n t i f i e r
t h a t w i l l a l w a y s u n i q u e l y r e f e r e n c e a p a r t i c u l a r t h r e a d , and when t h a t t h r e a d g o e s
a w a y i t w i l l not b e r e u s e d .
2011-07-19 04:13:38 +08:00
S B T h r e a d s u p p o r t s frame i t e r a t i o n . For e x a m p l e ( from t e s t / p y t h o n _ a p i /
l l d b u t i l / i t e r / T e s t L L D B I t e r a t o r . p y ) ,
from l l d b u t i l import p r i n t _ s t a c k t r a c e
s t o p p e d _ d u e _ t o _ b r e a k p o i n t = False
for t h r e a d in process :
if self . T r a c e O n ( ) :
p r i n t _ s t a c k t r a c e ( t h r e a d )
I D = t h r e a d . G e t T h r e a d I D ( )
if t h r e a d . G e t S t o p R e a s o n ( ) = = 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 :
s t o p p e d _ d u e _ t o _ b r e a k p o i n t = True
for frame in t h r e a d :
self . a s s e r t T r u e ( frame . G e t T h r e a d ( ) . G e t T h r e a d I D ( ) = = I D )
if self . T r a c e O n ( ) :
p r i n t frame
self . a s s e r t T r u e ( s t o p p e d _ d u e _ t o _ b r e a k p o i n t )
S e e a l s o S B P r o c e s s and S B F r a m e . "
) S B T h r e a d ;
class S B T h r e a d
{
public :
2013-10-04 06:21:09 +08:00
//------------------------------------------------------------------
// Broadcaster bits.
//------------------------------------------------------------------
enum
{
e B r o a d c a s t B i t S t a c k C h a n g e d = ( 1 < < 0 ) ,
e B r o a d c a s t B i t T h r e a d S u s p e n d e d = ( 1 < < 1 ) ,
e B r o a d c a s t B i t T h r e a d R e s u m e d = ( 1 < < 2 ) ,
e B r o a d c a s t B i t S e l e c t e d F r a m e C h a n g e d = ( 1 < < 3 ) ,
e B r o a d c a s t B i t T h r e a d S e l e c t e d = ( 1 < < 4 )
} ;
2011-07-19 04:13:38 +08:00
S B T h r e a d ( ) ;
S B T h r e a d ( c o n s t l l d b : : S B T h r e a d &thread);
~ S B T h r e a d ( ) ;
2013-10-04 06:21:09 +08:00
static c o n s t char *
G e t B r o a d c a s t e r C l a s s N a m e ( ) ;
2012-10-11 02:32:14 +08:00
static b o o l
E v e n t I s T h r e a d E v e n t ( c o n s t S B E v e n t &event);
static S B F r a m e
G e t S t a c k F r a m e F r o m E v e n t ( c o n s t S B E v e n t &event);
static S B T h r e a d
G e t T h r e a d F r o m E v e n t ( c o n s t S B E v e n t &event);
2011-07-19 04:13:38 +08:00
b o o l
I s V a l i d ( ) c o n s t ;
void
Clear ( ) ;
l l d b : : S t o p R e a s o n
G e t S t o p R e a s o n ( ) ;
% f e a t u r e ( "docstring" , "
/// Get the number of words associated with the stop reason.
/// See also GetStopReasonDataAtIndex().
" ) G e t S t o p R e a s o n D a t a C o u n t ;
s i z e _ t
G e t S t o p R e a s o n D a t a C o u n t ( ) ;
% f e a t u r e ( "docstring" , "
//--------------------------------------------------------------------------
/// Get information associated with a stop reason.
///
/// Breakpoint stop reasons will have data that consists of pairs of
/// breakpoint IDs followed by the breakpoint location IDs (they always come
/// in pairs).
///
/// Stop Reason Count Data Type
/// ======================== ===== =========================================
/// eStopReasonNone 0
/// eStopReasonTrace 0
/// eStopReasonBreakpoint N duple: {breakpoint id, location id}
2011-12-17 10:07:52 +08:00
/// eStopReasonWatchpoint 1 watchpoint id
2011-07-19 04:13:38 +08:00
/// eStopReasonSignal 1 unix signal number
/// eStopReasonException N exception data
2012-12-05 08:16:59 +08:00
/// eStopReasonExec 0
2011-07-19 04:13:38 +08:00
/// eStopReasonPlanComplete 0
//--------------------------------------------------------------------------
" ) G e t S t o p R e a s o n D a t a A t I n d e x ;
u i n t 64 _ t
G e t S t o p R e a s o n D a t a A t I n d e x ( u i n t 32 _ t i d x ) ;
2011-12-20 03:38:09 +08:00
% f e a t u r e ( "autodoc" , "
P a s s o n l y a n ( int ) length and e x p e c t to get a P y t h o n string d e s c r i b i n g t h e
stop r e a s o n .
" ) G e t S t o p D e s c r i p t i o n ;
2011-07-19 04:13:38 +08:00
s i z e _ t
G e t S t o p D e s c r i p t i o n ( char * d s t , s i z e _ t d s t _ l e n ) ;
2011-12-17 09:35:57 +08:00
S B V a l u e
G e t S t o p R e t u r n V a l u e ( ) ;
2014-02-05 13:44:54 +08:00
% f e a t u r e ( "autodoc" , "
Returns a unique t h r e a d i d e n t i f i e r ( type l l d b : : t i d _ t , t y p i c a l l y a 64 - b i t type )
for t h e current S B T h r e a d t h a t w i l l r e m a i n c o n s t a n t t h r o u g h o u t t h e t h r e a d ' s
l i f e t i m e in t h i s process and w i l l not b e r e u s e d by a n o t h e r t h r e a d d u r i n g t h i s
process l i f e t i m e . On M a c O S X s y s t e m s , t h i s is a s y s t e m - w i d e unique t h r e a d
i d e n t i f i e r ; t h i s i d e n t i f i e r is a l s o u s e d by o t h e r t o o l s like s a m p l e w h i c h h e l p s
to a s s o c i a t e d a t a from t h o s e t o o l s with l l d b . S e e r e l a t e d G e t I n d e x I D .
" )
G e t T h r e a d I D ;
2011-07-19 04:13:38 +08:00
l l d b : : t i d _ t
G e t T h r e a d I D ( ) c o n s t ;
2014-02-05 13:44:54 +08:00
% f e a t u r e ( "autodoc" , "
Return t h e index n u m b e r for t h i s S B T h r e a d . T h e index n u m b e r is t h e s a m e t h i n g
t h a t a user g i v e s as a n a r g u m e n t to 'thread select' in t h e command line l l d b .
T h e s e n u m b e r s start at 1 ( for t h e first t h r e a d l l d b s e e s in a debug session )
and i n c r e m e n t s up t h r o u g h o u t t h e process l i f e t i m e . A n index n u m b e r w i l l not b e
r e u s e d for a d i f f e r e n t t h r e a d l a t e r in a process - t h r e a d 1 w i l l a l w a y s b e
a s s o c i a t e d with t h e s a m e t h r e a d . S e e r e l a t e d G e t T h r e a d I D .
T h i s method returns a u i n t 32 _ t index n u m b e r , t a k e s no a r g u m e n t s .
" )
G e t I n d e x I D ;
2011-07-19 04:13:38 +08:00
u i n t 32 _ t
G e t I n d e x I D ( ) c o n s t ;
c o n s t char *
G e t N a m e ( ) c o n s t ;
2013-11-05 19:00:35 +08:00
% f e a t u r e ( "autodoc" , "
Return t h e q u e u e name a s s o c i a t e d with t h i s t h r e a d , if any , as a s t r .
For e x a m p l e , with a l i b d i s p a t c h ( a k a G r a n d C e n t r a l D i s p a t c h ) q u e u e .
" ) G e t Q u e u e N a m e ;
2011-07-19 04:13:38 +08:00
c o n s t char *
G e t Q u e u e N a m e ( ) c o n s t ;
2013-11-05 19:00:35 +08:00
% f e a t u r e ( "autodoc" , "
Return t h e d i s p a t c h _ q u e u e _ i d for t h i s t h r e a d , if any , as a l l d b : : q u e u e _ i d _ t .
For e x a m p l e , with a l i b d i s p a t c h ( a k a G r a n d C e n t r a l D i s p a t c h ) q u e u e .
" ) G e t Q u e u e I D ;
2013-10-22 07:52:54 +08:00
l l d b : : q u e u e _ i d _ t
G e t Q u e u e I D ( ) c o n s t ;
2011-07-19 04:13:38 +08:00
void
S t e p O v e r ( l l d b : : R u n M o d e s t o p _ o t h e r _ t h r e a d s = l l d b : : e O n l y D u r i n g S t e p p i n g ) ;
void
S t e p I n t o ( l l d b : : R u n M o d e s t o p _ o t h e r _ t h r e a d s = l l d b : : e O n l y D u r i n g S t e p p i n g ) ;
Fixed a few bugs in the "step in" thread plan logic.
Added a "step-in-target" flag to "thread step-in" so if you have something like:
Process 28464 stopped
* thread #1: tid = 0x1c03, function: main , stop reason = breakpoint 1.1
frame #0: 0x0000000100000e08 a.out`main at main.c:62
61
-> 62 int A6 = complex (a(4), b(5), c(6)); // Stop here to step targetting b and hitting breakpoint.
63
and you want to get into "complex" skipping a, b and c, you can do:
(lldb) step -t complex
Process 28464 stopped
* thread #1: tid = 0x1c03, function: complex , stop reason = step in
frame #0: 0x0000000100000d0d a.out`complex at main.c:44
41
42 int complex (int first, int second, int third)
43 {
-> 44 return first + second + third; // Step in targetting complex should stop here
45 }
46
47 int main (int argc, char const *argv[])
llvm-svn: 170008
2012-12-13 03:58:40 +08:00
void
S t e p I n t o ( c o n s t char * t a r g e t _ n a m e , l l d b : : R u n M o d e s t o p _ o t h e r _ t h r e a d s = l l d b : : e O n l y D u r i n g S t e p p i n g ) ;
2011-07-19 04:13:38 +08:00
void
S t e p O u t ( ) ;
void
S t e p O u t O f F r a m e ( l l d b : : S B F r a m e &frame);
void
S t e p I n s t r u c t i o n ( b o o l s t e p _ o v e r ) ;
S B E r r o r
2013-09-12 10:20:34 +08:00
S t e p O v e r U n t i l ( l l d b : : S B F r a m e &frame,
l l d b : : S B F i l e S p e c &file_spec,
2011-07-19 04:13:38 +08:00
u i n t 32 _ t line ) ;
2013-09-12 10:20:34 +08:00
S B E r r o r
J u m p T o L i n e ( l l d b : : S B F i l e S p e c &file_spec, uint32_t line);
2011-07-19 04:13:38 +08:00
void
R u n T o A d d r e s s ( l l d b : : a d d r _ t a d d r ) ;
2012-09-12 08:40:39 +08:00
S B E r r o r
2012-09-14 10:14:15 +08:00
R e t u r n F r o m F r a m e ( S B F r a m e &frame, SBValue &return_value);
2012-09-12 08:40:39 +08:00
2011-07-19 04:13:38 +08:00
% f e a t u r e ( "docstring" , "
//--------------------------------------------------------------------------
/// LLDB currently supports process centric debugging which means when any
/// thread in a process stops, all other threads are stopped. The Suspend()
/// call here tells our process to suspend a thread and not let it run when
/// the other threads in a process are allowed to run. So when
/// SBProcess::Continue() is called, any threads that aren't suspended will
/// be allowed to run. If any of the SBThread functions for stepping are
/// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the
/// thread will now be allowed to run and these funtions will simply return.
///
/// Eventually we plan to add support for thread centric debugging where
/// each thread is controlled individually and each thread would broadcast
/// its state, but we haven't implemented this yet.
///
/// Likewise the SBThread::Resume() call will again allow the thread to run
/// when the process is continued.
///
/// Suspend() and Resume() functions are not currently reference counted, if
/// anyone has the need for them to be reference counted, please let us
/// know.
//--------------------------------------------------------------------------
" ) S u s p e n d ;
b o o l
S u s p e n d ( ) ;
b o o l
R e s u m e ( ) ;
b o o l
I s S u s p e n d e d ( ) ;
2013-04-16 07:33:53 +08:00
b o o l
I s S t o p p e d ( ) ;
2011-07-19 04:13:38 +08:00
u i n t 32 _ t
G e t N u m F r a m e s ( ) ;
l l d b : : S B F r a m e
G e t F r a m e A t I n d e x ( u i n t 32 _ t i d x ) ;
l l d b : : S B F r a m e
G e t S e l e c t e d F r a m e ( ) ;
l l d b : : S B F r a m e
S e t S e l e c t e d F r a m e ( u i n t 32 _ t f r a m e _ i d x ) ;
l l d b : : S B P r o c e s s
G e t P r o c e s s ( ) ;
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) const;
2012-01-29 14:07:39 +08:00
2012-10-11 02:32:14 +08:00
b o o l
G e t S t a t u s ( l l d b : : S B S t r e a m &status) const;
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 T h r e a d &rhs) const;
b o o l
o p e r a t o r ! = ( c o n s t l l d b : : S B T h r e a d &rhs) const;
2013-11-16 09:24:22 +08:00
2013-11-06 08:04:44 +08:00
% f e a t u r e ( "autodoc" , "
G i v e n a n a r g u m e n t of s t r to s p e c i f y t h e type of t h r e a d - o r i g i n extended
b a c k t r a c e to r e t r i e v e , query w h e t h e r t h e o r i g i n of t h i s t h r e a d is
available . A n S B T h r e a d is r e t u r e d ; S B T h r e a d . I s V a l i d w i l l return true
if a n extended b a c k t r a c e w a s available . T h e r e t u r n e d S B T h r e a d is not
a p a r t of t h e S B P r o c e s s ' t h r e a d l i s t and i t c a n n o t b e m a n i p u l a t e d like
n o r m a l t h r e a d s - - y o u c a n n o t s t e p or r e s u m e i t , for i n s t a n c e - - i t is
i n t e n d e d to u s e d p r i m a r i l y for g e n e r a t i n g a b a c k t r a c e . Y o u m a y request
t h e r e t u r n e d t h r e a d ' s o w n t h r e a d o r i g i n in t u r n .
2013-11-13 07:33:32 +08:00
" ) G e t E x t e n d e d B a c k t r a c e T h r e a d ;
2013-11-06 08:04:44 +08:00
l l d b : : S B T h r e a d
2013-11-13 07:33:32 +08:00
G e t E x t e n d e d B a c k t r a c e T h r e a d ( c o n s t char * type ) ;
2013-11-06 08:04:44 +08:00
2013-11-16 09:24:22 +08:00
% f e a t u r e ( "autodoc" , "
T a k e s no a r g u m e n t s , returns a u i n t 32 _ t .
If t h i s S B T h r e a d is a n E x t e n d e d B a c k t r a c e t h r e a d , get t h e I n d e x I D of t h e
o r i g i n a l t h r e a d t h a t t h i s E x t e n d e d B a c k t r a c e t h r e a d r e p r e s e n t s , if
available . T h e t h r e a d t h a t w a s r u n n i n g t h i s b a c k t r a c e in t h e p a s t m a y
not h a v e b e e n r e g i s t e r e d with l l d b ' s t h r e a d index ( if i t w a s c r e a t e d ,
d i d i t s w o r k , and w a s d e s t r o y e d w i t h o u t l l d b e v e r s t o p p i n g e x e c u t i o n ) .
In t h a t case , t h i s E x t e n d e d B a c k t r a c e t h r e a d ' s I n d e x I D w i l l b e r e t u r n e d .
" ) G e t E x t e n d e d B a c k t r a c e O r i g i n a t i n g I n d e x I D ;
u i n t 32 _ t
G e t E x t e n d e d B a c k t r a c e O r i g i n a t i n g I n d e x I D ( ) ;
2012-01-29 14:07:39 +08:00
% p y t h o n c o d e % {
2012-02-03 11:22:53 +08:00
class f r a m e s _ a c c e s s ( o b j e c t ) :
2012-02-01 16:09:32 +08:00
'''A helper object that will lazily hand out frames for a thread when supplied an index.'''
def _ _ i n i t _ _ ( self , s b t h r e a d ) :
self . s b t h r e a d = s b t h r e a d
def _ _ l e n _ _ ( self ) :
if self . s b t h r e a d :
2012-05-12 04:39:42 +08:00
return int ( self . s b t h r e a d . G e t N u m F r a m e s ( ) )
2012-02-01 16:09:32 +08:00
return 0
def _ _ g e t i t e m _ _ ( self , key ) :
if type ( key ) is int and key < self . s b t h r e a d . G e t N u m F r a m e s ( ) :
return self . s b t h r e a d . G e t F r a m e A t I n d e x ( key )
return None
2012-02-03 11:22:53 +08:00
def g e t _ f r a m e s _ a c c e s s _ o b j e c t ( self ) :
'''An accessor function that returns a frames_access() object which allows lazy frame access from a lldb.SBThread object.'''
return self . f r a m e s _ a c c e s s ( self )
2012-02-01 16:09:32 +08:00
2012-02-01 10:30:27 +08:00
def g e t _ t h r e a d _ f r a m e s ( self ) :
2012-02-03 11:22:53 +08:00
'''An accessor function that returns a list() that contains all frames in a lldb.SBThread object.'''
2012-02-01 10:30:27 +08:00
f r a m e s = [ ]
for frame in self :
f r a m e s . append ( frame )
return f r a m e s
2012-02-01 16:09:32 +08:00
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "id" ] = G e t T h r e a d I D
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : i d = property ( G e t T h r e a d I D , None , d o c = '''A read only property that returns the thread ID as an integer.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "idx" ] = G e t I n d e x I D
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : i d x = property ( G e t I n d e x I D , None , d o c = '''A read only property that returns the thread index ID as an integer. Thread index ID values start at 1 and increment as threads come and go and can be used to uniquely identify threads.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "return_value" ] = G e t S t o p R e t u r n V a l u e
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : r e t u r n _ v a l u e = property ( G e t S t o p R e t u r n V a l u e , None , d o c = '''A read only property that returns an lldb object that represents the return value from the last stop (lldb.SBValue) if we just stopped due to stepping out of a function.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "process" ] = G e t P r o c e s s
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : process = property ( G e t P r o c e s s , None , d o c = '''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that owns this thread.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "num_frames" ] = G e t N u m F r a m e s
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : n u m _ f r a m e s = property ( G e t N u m F r a m e s , None , d o c = '''A read only property that returns the number of stack frames in this thread as an integer.''' )
2012-01-29 14:07:39 +08:00
2012-02-01 10:30:27 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "frames" ] = g e t _ t h r e a d _ f r a m e s
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : f r a m e s = property ( g e t _ t h r e a d _ f r a m e s , None , d o c = '''A read only property that returns a list() of lldb.SBFrame objects for all frames in this thread.''' )
2012-02-01 10:30:27 +08:00
2012-02-03 11:22:53 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "frame" ] = g e t _ f r a m e s _ a c c e s s _ o b j e c t
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : frame = property ( g e t _ f r a m e s _ a c c e s s _ o b j e c t , None , d o c = ''' A r e a d o n l y property t h a t returns a n o b j e c t t h a t c a n b e u s e d to a c c e s s f r a m e s as a n a r r a y ( "frame_12 = lldb.thread.frame[12]" ) . ''' )
2012-02-01 16:09:32 +08:00
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "name" ] = G e t N a m e
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : name = property ( G e t N a m e , None , d o c = '''A read only property that returns the name of this thread as a string.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "queue" ] = G e t Q u e u e N a m e
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : q u e u e = property ( G e t Q u e u e N a m e , None , d o c = '''A read only property that returns the dispatch queue name of this thread as a string.''' )
2012-01-29 14:07:39 +08:00
2013-10-22 07:52:54 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "queue_id" ] = G e t Q u e u e I D
2013-10-22 09:37:18 +08:00
if _ n e w c l a s s : q u e u e _ i d = property ( G e t Q u e u e I D , None , d o c = '''A read only property that returns the dispatch queue id of this thread as an integer.''' )
2013-10-22 07:52:54 +08:00
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "stop_reason" ] = G e t S t o p R e a s o n
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : s t o p _ r e a s o n = property ( G e t S t o p R e a s o n , None , d o c = ''' A r e a d o n l y property t h a t returns a n l l d b e n u m e r a t i o n value ( s e e e n u m e r a t i o n s t h a t start with "lldb.eStopReason" ) t h a t r e p r e s e n t s t h e r e a s o n t h i s t h r e a d stopped . ''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "is_suspended" ] = I s S u s p e n d e d
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : i s _ s u s p e n d e d = property ( I s S u s p e n d e d , None , d o c = '''A read only property that returns a boolean value that indicates if this thread is suspended.''' )
2013-04-16 07:33:53 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "is_stopped" ] = I s S t o p p e d
if _ n e w c l a s s : i s _ s t o p p e d = property ( I s S t o p p e d , None , d o c = '''A read only property that returns a boolean value that indicates if this thread is stopped but not exited.''' )
2012-01-29 14:07:39 +08:00
% }
2011-07-19 04:13:38 +08:00
} ;
} // namespace lldb