2011-07-19 04:13:38 +08:00
//===-- SWIG Interface for SBProcess ----------------------------*- C++ -*-===//
//
2019-01-19 16:50:56 +08:00
// 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
2011-07-19 04:13:38 +08:00
//
//===----------------------------------------------------------------------===//
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 t h e process a s s o c i a t e d with t h e target p r o g r a m .
2021-01-15 21:43:26 +08:00
S B P r o c e s s s u p p o r t s t h r e a d i t e r a t i o n . For e x a m p l e ( from t e s t / l l d b u t i l . p y ) , : :
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# U t i l i t y f u n c t i o n s r e l a t e d to T h r e a d s and P r o c e s s e s
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
def g e t _ s t o p p e d _ t h r e a d s ( process , r e a s o n ) :
''' Returns t h e t h r e a d ( s ) with t h e s p e c i f i e d stop r e a s o n in a l i s t .
T h e l i s t c a n b e empty if no s u c h t h r e a d exists .
'''
t h r e a d s = [ ]
for t in process :
if t . G e t S t o p R e a s o n ( ) = = r e a s o n :
t h r e a d s . append ( t )
return t h r e a d s
2011-07-19 04:13:38 +08:00
"
) S B P r o c e s s ;
class S B P r o c e s s
{
public :
enum
{
e B r o a d c a s t B i t S t a t e C h a n g e d = ( 1 < < 0 ) ,
e B r o a d c a s t B i t I n t e r r u p t = ( 1 < < 1 ) ,
e B r o a d c a s t B i t S T D O U T = ( 1 < < 2 ) ,
2012-11-17 08:21:04 +08:00
e B r o a d c a s t B i t S T D E R R = ( 1 < < 3 ) ,
2016-08-19 12:21:48 +08:00
e B r o a d c a s t B i t P r o f i l e D a t a = ( 1 < < 4 ) ,
e B r o a d c a s t B i t S t r u c t u r e d D a t a = ( 1 < < 5 )
2011-07-19 04:13:38 +08:00
} ;
S B P r o c e s s ( ) ;
S B P r o c e s s ( c o n s t l l d b : : S B P r o c e s s & rhs);
~ S B P r o c e s s ( ) ;
2012-02-16 14:50:00 +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-27 03:18:04 +08:00
c o n s t char *
G e t P l u g i n N a m e ( ) ;
2019-04-19 00:23:33 +08:00
2012-10-27 03:18:04 +08:00
c o n s t char *
G e t S h o r t P l u g i n N a m e ( ) ;
2019-04-19 00:23:33 +08:00
2011-07-19 04:13:38 +08:00
void
Clear ( ) ;
b o o l
I s V a l i d ( ) c o n s t ;
Add "operator bool" to SB APIs
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.
This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.
In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.
Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D58792
llvm-svn: 355824
2019-03-11 21:58:46 +08:00
explicit o p e r a t o r b o o l ( ) c o n s t ;
2011-07-19 04:13:38 +08:00
l l d b : : S B T a r g e t
G e t T a r g e t ( ) c o n s t ;
l l d b : : B y t e O r d e r
G e t B y t e O r d e r ( ) c o n s t ;
2011-11-29 05:39:07 +08:00
% f e a t u r e ( "autodoc" , "
W r i t e s d a t a into t h e current process ' s s t d i n . A P I c l i e n t s p e c i f i e s a P y t h o n
2019-04-19 00:23:33 +08:00
string as t h e o n l y a r g u m e n t . " ) P u t S T D I N ;
2011-07-19 04:13:38 +08:00
s i z e _ t
P u t S T D I N ( c o n s t char * s r c , s i z e _ t s r c _ l e n ) ;
2011-11-29 03:12:25 +08:00
% f e a t u r e ( "autodoc" , "
R e a d s d a t a from t h e current process ' s s t d o u t stream . A P I c l i e n t s p e c i f i e s
t h e size of t h e buffer to r e a d d a t a into . I t returns t h e b y t e buffer in a
2019-04-19 00:23:33 +08:00
P y t h o n string . " ) G e t S T D O U T ;
2011-07-19 04:13:38 +08:00
s i z e _ t
G e t S T D O U T ( char * d s t , s i z e _ t d s t _ l e n ) c o n s t ;
2011-11-29 03:12:25 +08:00
% f e a t u r e ( "autodoc" , "
R e a d s d a t a from t h e current process ' s s t d e r r stream . A P I c l i e n t s p e c i f i e s
t h e size of t h e buffer to r e a d d a t a into . I t returns t h e b y t e buffer in a
2019-04-19 00:23:33 +08:00
P y t h o n string . " ) G e t S T D E R R ;
2011-07-19 04:13:38 +08:00
s i z e _ t
G e t S T D E R R ( char * d s t , s i z e _ t d s t _ l e n ) c o n s t ;
2012-11-17 08:21:04 +08:00
s i z e _ t
G e t A s y n c P r o f i l e D a t a ( char * d s t , s i z e _ t d s t _ l e n ) c o n s t ;
2019-04-19 00:23:33 +08:00
2011-07-19 04:13:38 +08:00
void
2019-10-15 04:15:28 +08:00
R e p o r t E v e n t S t a t e ( c o n s t l l d b : : S B E v e n t &event, SBFile out) const;
void
R e p o r t E v e n t S t a t e ( c o n s t l l d b : : S B E v e n t &event, FileSP BORROWED) const;
2011-07-19 04:13:38 +08:00
void
A p p e n d E v e n t S t a t e R e p o r t ( c o n s t l l d b : : S B E v e n t &event, lldb::SBCommandReturnObject &result);
% f e a t u r e ( "docstring" , "
2019-04-19 00:23:33 +08:00
Remote c o n n e c t i o n r e l a t e d f u n c t i o n s . T h e s e w i l l f a i l if t h e
process is not in e S t a t e C o n n e c t e d . T h e y a r e i n t e n d e d for use
when c o n n e c t i n g to a n e x t e r n a l l y m a n a g e d d e b u g s e r v e r i n s t a n c e . " ) R e m o t e A t t a c h T o P r o c e s s W i t h I D ;
2011-07-19 04:13:38 +08:00
b o o l
R e m o t e A t t a c h T o P r o c e s s W i t h I D ( l l d b : : p i d _ t p i d ,
l l d b : : S B E r r o r & error);
2019-04-19 00:23:33 +08:00
2011-07-19 04:13:38 +08:00
% f e a t u r e ( "docstring" ,
"See SBTarget.Launch for argument description and usage."
) R e m o t e L a u n c h ;
b o o l
R e m o t e L a u n c h ( char c o n s t * * a r g v ,
char c o n s t * * e n v p ,
c o n s t char * s t d i n _ p a t h ,
c o n s t char * s t d o u t _ p a t h ,
c o n s t char * s t d e r r _ p a t h ,
c o n s t char * w o r k i n g _ d i r e c t o r y ,
u i n t 32 _ t l a u n c h _ f l a g s ,
b o o l s t o p _ a t _ e n t r y ,
l l d b : : S B E r r o r & error);
2019-04-19 00:23:33 +08:00
2011-07-19 04:13:38 +08:00
//------------------------------------------------------------------
// Thread related functions
//------------------------------------------------------------------
u i n t 32 _ t
G e t N u m T h r e a d s ( ) ;
2012-07-14 04:18:18 +08:00
% f e a t u r e ( "autodoc" , "
Returns t h e INDEX ' t h t h r e a d from t h e l i s t of current t h r e a d s . T h e index
of a t h r e a d is o n l y v a l i d for t h e current stop . For a persistent t h r e a d
i d e n t i f i e r use e i t h e r t h e t h r e a d I D or t h e I n d e x I D . S e e help on S B T h r e a d
2019-04-19 00:23:33 +08:00
for m o r e d e t a i l s . " ) G e t T h r e a d A t I n d e x ;
2011-07-19 04:13:38 +08:00
l l d b : : S B T h r e a d
G e t T h r e a d A t I n d e x ( s i z e _ t index ) ;
2012-07-14 04:18:18 +08:00
% f e a t u r e ( "autodoc" , "
2019-04-19 00:23:33 +08:00
Returns t h e t h r e a d with t h e g i v e n t h r e a d I D . " ) G e t T h r e a d B y I D ;
2011-07-19 04:13:38 +08:00
l l d b : : S B T h r e a d
G e t T h r e a d B y I D ( l l d b : : t i d _ t s b _ t h r e a d _ i d ) ;
2019-04-19 00:23:33 +08:00
2012-07-14 04:18:18 +08:00
% f e a t u r e ( "autodoc" , "
2019-04-19 00:23:33 +08:00
Returns t h e t h r e a d with t h e g i v e n t h r e a d I n d e x I D . " ) G e t T h r e a d B y I n d e x I D ;
2012-07-14 04:18:18 +08:00
l l d b : : S B T h r e a d
G e t T h r e a d B y I n d e x I D ( u i n t 32 _ t i n d e x _ i d ) ;
2011-07-19 04:13:38 +08:00
2012-07-14 04:18:18 +08:00
% f e a t u r e ( "autodoc" , "
2019-04-19 00:23:33 +08:00
Returns t h e c u r r e n t l y selected t h r e a d . " ) G e t S e l e c t e d T h r e a d ;
2011-07-19 04:13:38 +08:00
l l d b : : S B T h r e a d
G e t S e l e c t e d T h r e a d ( ) c o n s t ;
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-19 07:41:08 +08:00
% f e a t u r e ( "autodoc" , "
2019-04-19 00:23:33 +08:00
L a z i l y create a t h r e a d on d e m a n d through t h e current O p e r a t i n g S y s t e m p l u g - i n , if t h e current O p e r a t i n g S y s t e m p l u g - i n s u p p o r t s i t . " ) C r e a t e O S P l u g i n T h r e a d ;
<rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:
class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand
This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.
Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &
Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.
llvm-svn: 172873
2013-01-19 07:41:08 +08:00
l l d b : : S B T h r e a d
C r e a t e O S P l u g i n T h r e a d ( l l d b : : t i d _ t t i d , l l d b : : a d d r _ t context ) ;
2011-07-19 04:13:38 +08:00
b o o l
S e t S e l e c t e d T h r e a d ( c o n s t l l d b : : S B T h r e a d &thread);
b o o l
2012-10-13 07:32:11 +08:00
S e t S e l e c t e d T h r e a d B y I D ( l l d b : : t i d _ t t i d ) ;
2011-07-19 04:13:38 +08:00
2012-07-14 04:18:18 +08:00
b o o l
S e t S e l e c t e d T h r e a d B y I n d e x I D ( u i n t 32 _ t i n d e x _ i d ) ;
2019-04-19 00:23:33 +08:00
2013-12-13 08:29:16 +08:00
//------------------------------------------------------------------
// Queue related functions
//------------------------------------------------------------------
u i n t 32 _ t
G e t N u m Q u e u e s ( ) ;
l l d b : : S B Q u e u e
G e t Q u e u e A t I n d e x ( u i n t 32 _ t index ) ;
2011-07-19 04:13:38 +08:00
//------------------------------------------------------------------
// Stepping related functions
//------------------------------------------------------------------
l l d b : : S t a t e T y p e
G e t S t a t e ( ) ;
int
G e t E x i t S t a t u s ( ) ;
c o n s t char *
G e t E x i t D e s c r i p t i o n ( ) ;
2013-01-17 01:29:04 +08:00
% f e a t u r e ( "autodoc" , "
2019-04-19 00:23:33 +08:00
Returns t h e process I D of t h e process . " ) G e t P r o c e s s I D ;
2011-07-19 04:13:38 +08:00
l l d b : : p i d _ t
G e t P r o c e s s I D ( ) ;
2019-04-19 00:23:33 +08:00
2013-01-17 01:29:04 +08:00
% f e a t u r e ( "autodoc" , "
2019-04-19 00:23:33 +08:00
Returns a n integer I D t h a t is g u a r a n t e e d to b e unique a c r o s s all process i n s t a n c e s . T h i s is not t h e process I D , j u s t a unique integer for c o m p a r i s o n and c a c h i n g p u r p o s e s . " ) G e t U n i q u e I D ;
2013-01-17 01:29:04 +08:00
u i n t 32 _ t
G e t U n i q u e I D ( ) ;
2011-07-19 04:13:38 +08:00
u i n t 32 _ t
G e t A d d r e s s B y t e S i z e ( ) c o n s t ;
% f e a t u r e ( "docstring" , "
K i l l s t h e process and s h u t s down all t h r e a d s t h a t w e r e s p a w n e d to
2019-04-19 00:23:33 +08:00
t r a c k and m o n i t o r process . " ) D e s t r o y ;
2011-07-19 04:13:38 +08:00
l l d b : : S B E r r o r
D e s t r o y ( ) ;
l l d b : : S B E r r o r
C o n t i n u e ( ) ;
l l d b : : S B E r r o r
Stop ( ) ;
% f e a t u r e ( "docstring" , "Same as Destroy(self)." ) D e s t r o y ;
l l d b : : S B E r r o r
K i l l ( ) ;
l l d b : : S B E r r o r
D e t a c h ( ) ;
% f e a t u r e ( "docstring" , "Sends the process a unix signal." ) S i g n a l ;
l l d b : : S B E r r o r
S i g n a l ( int s i g n a l ) ;
2014-06-24 03:30:49 +08:00
l l d b : : S B U n i x S i g n a l s
G e t U n i x S i g n a l s ( ) ;
2013-01-09 07:22:42 +08:00
% f e a t u r e ( "docstring" , "
Returns a stop i d t h a t w i l l i n c r e a s e e v e r y time t h e process e x e c u t e s . If
i n c l u d e _ e x p r e s s i o n _ s t o p s is true , then s t o p s c a u s e d by e x p r e s s i o n e v a l u a t i o n
w i l l c a u s e t h e r e t u r n e d value to i n c r e a s e , otherwise t h e c o u n t e r r e t u r n e d w i l l
o n l y i n c r e a s e when e x e c u t i o n is c o n t i n u e d e x p l i c i t l y by t h e user . N o t e , t h e value
2019-04-19 00:23:33 +08:00
w i l l a l w a y s i n c r e a s e , b u t m a y i n c r e a s e by m o r e t h a n o n e p e r stop . " ) G e t S t o p I D ;
2013-01-09 07:22:42 +08:00
u i n t 32 _ t
G e t S t o p I D ( b o o l i n c l u d e _ e x p r e s s i o n _ s t o p s = false ) ;
2019-04-19 00:23:33 +08:00
2012-07-28 07:57:19 +08:00
void
S e n d A s y n c I n t e r r u p t ( ) ;
2019-04-19 00:23:33 +08:00
2011-07-19 04:13:38 +08:00
% f e a t u r e ( "autodoc" , "
R e a d s m e m o r y from t h e current process ' s a d d r e s s space and r e m o v e s any
t r a p s t h a t m a y h a v e b e e n i n s e r t e d into t h e m e m o r y . I t returns t h e b y t e
2021-01-18 17:47:16 +08:00
buffer in a P y t h o n string . E x a m p l e : : :
2011-07-19 04:13:38 +08:00
2021-01-18 17:47:16 +08:00
# R e a d 4 b y t e s from a d d r e s s 'addr' and a s s u m e error . S u c c e s s ( ) is True .
c o n t e n t = process . R e a d M e m o r y ( a d d r , 4 , error )
n e w _ b y t e s = b y t e a r r a y ( c o n t e n t ) " ) R e a d M e m o r y ;
2011-07-19 04:13:38 +08:00
s i z e _ t
R e a d M e m o r y ( a d d r _ t a d d r , void * b u f , s i z e _ t size , l l d b : : S B E r r o r &error);
% f e a t u r e ( "autodoc" , "
W r i t e s m e m o r y to t h e current process ' s a d d r e s s space and m a i n t a i n s any
2021-01-18 17:47:16 +08:00
t r a p s t h a t m i g h t b e p r e s e n t d u e to s o f t w a r e b r e a k p o i n t s . E x a m p l e : : :
2011-07-19 04:13:38 +08:00
2021-01-18 17:47:16 +08:00
# Create a P y t h o n string from t h e b y t e a r r a y .
n e w _ v a l u e = s t r ( b y t e s )
r e s u l t = process . W r i t e M e m o r y ( a d d r , n e w _ v a l u e , error )
if not error . S u c c e s s ( ) or r e s u l t ! = l e n ( b y t e s ) :
p r i n t ( 'SBProcess.WriteMemory() failed!' ) " ) W r i t e M e m o r y ;
2011-07-19 04:13:38 +08:00
s i z e _ t
W r i t e M e m o r y ( a d d r _ t a d d r , c o n s t void * b u f , s i z e _ t size , l l d b : : S B E r r o r &error);
2011-12-15 11:14:23 +08:00
% f e a t u r e ( "autodoc" , "
R e a d s a NULL t e r m i n a t e d C string from t h e current process ' s a d d r e s s space .
I t returns a p y t h o n string of t h e e x a c t length , or t r u n c a t e s t h e string if
2021-01-18 17:47:16 +08:00
t h e maximum character l i m i t is r e a c h e d . E x a m p l e : : :
2019-04-19 00:23:33 +08:00
2021-01-18 17:47:16 +08:00
# R e a d a C string of at m o s t 256 b y t e s from a d d r e s s '0x1000'
error = l l d b . S B E r r o r ( )
c s t r i n g = process . R e a d C S t r i n g F r o m M e m o r y ( 0x1000 , 256 , error )
if error . S u c c e s s ( ) :
p r i n t ( 'cstring: ' , c s t r i n g )
else
p r i n t ( 'error: ' , error ) " ) R e a d C S t r i n g F r o m M e m o r y ;
2011-12-15 11:14:23 +08:00
s i z e _ t
2016-01-26 07:21:18 +08:00
R e a d C S t r i n g F r o m M e m o r y ( a d d r _ t a d d r , void * c h a r _ b u f , s i z e _ t size , l l d b : : S B E r r o r &error);
2011-12-15 11:14:23 +08:00
% f e a t u r e ( "autodoc" , "
2019-04-19 00:23:33 +08:00
R e a d s a n u n s i g n e d integer from m e m o r y g i v e n a b y t e size and a n a d d r e s s .
2021-01-18 17:47:16 +08:00
Returns t h e u n s i g n e d integer t h a t w a s r e a d . E x a m p l e : : :
2019-04-19 00:23:33 +08:00
2021-01-18 17:47:16 +08:00
# R e a d a 4 b y t e u n s i g n e d integer from a d d r e s s 0x1000
error = l l d b . S B E r r o r ( )
u i n t = R e a d U n s i g n e d F r o m M e m o r y ( 0x1000 , 4 , error )
if error . S u c c e s s ( ) :
p r i n t ( 'integer: %u' % u i n t )
else
p r i n t ( 'error: ' , error ) " ) R e a d U n s i g n e d F r o m M e m o r y ;
2011-12-15 11:14:23 +08:00
u i n t 64 _ t
R e a d U n s i g n e d F r o m M e m o r y ( a d d r _ t a d d r , u i n t 32 _ t b y t e _ s i z e , l l d b : : S B E r r o r &error);
2019-04-19 00:23:33 +08:00
2011-12-15 11:14:23 +08:00
% f e a t u r e ( "autodoc" , "
2021-01-18 17:47:16 +08:00
R e a d s a p o i n t e r from m e m o r y from a n a d d r e s s and returns t h e value . E x a m p l e : : :
2019-04-19 00:23:33 +08:00
2021-01-18 17:47:16 +08:00
# R e a d a p o i n t e r from a d d r e s s 0x1000
error = l l d b . S B E r r o r ( )
p t r = R e a d P o i n t e r F r o m M e m o r y ( 0x1000 , error )
if error . S u c c e s s ( ) :
p r i n t ( 'pointer: 0x%x' % p t r )
else
p r i n t ( 'error: ' , error ) " ) R e a d P o i n t e r F r o m M e m o r y ;
2019-04-19 00:23:33 +08:00
2011-12-15 11:14:23 +08:00
l l d b : : a d d r _ t
R e a d P o i n t e r F r o m M e m o r y ( a d d r _ t a d d r , l l d b : : S B E r r o r &error);
2019-04-19 00:23:33 +08:00
2011-12-15 11:14:23 +08:00
2011-07-19 04:13:38 +08:00
// Events
static l l d b : : S t a t e T y p e
G e t S t a t 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 b o o l
G e t R e s t a r t e d 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);
2013-02-09 09:29:05 +08:00
static s i z e _ t
G e t N u m R e s t a r t e d R e a s 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);
2019-04-19 00:23:33 +08:00
2013-02-09 09:29:05 +08:00
static c o n s t char *
G e t R e s t a r t e d R e a s 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, size_t idx);
2011-07-19 04:13:38 +08:00
static l l d b : : S B P r o c e s s
G e t P r o c e s 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);
2015-05-15 17:29:09 +08:00
static b o o l
G e t I n t e r r u p t e d 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);
2011-07-19 04:13:38 +08:00
2016-08-19 12:21:48 +08:00
static l l d b : : S B S t r u c t u r e d D a t a
G e t S t r u c t u r e d D a t a 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);
2012-02-08 13:23:15 +08:00
static b o o l
E v e n t I s P r o c e s s E v e n t ( c o n s t l l d b : : S B E v e n t &event);
2016-08-19 12:21:48 +08:00
static b o o l
E v e n t I s S t r u c t u r e d D a t a 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 04:13:38 +08:00
l l d b : : S B B r o a d c a s t e r
G e t B r o a d c a s t e r ( ) 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);
2020-02-24 23:04:16 +08:00
% f e a t u r e ( "autodoc" , "
Returns t h e process ' extended c r a s h information . " ) G e t E x t e n d e d C r a s h I n f o r m a t i o n ;
l l d b : : S B S t r u c t u r e d D a t a
G e t E x t e n d e d C r a s h I n f o r m a t i o n ( ) ;
2012-05-24 06:34:34 +08:00
u i n t 32 _ t
G e t N u m S u p p o r t e d H a r d w a r e W a t c h p o i n t s ( l l d b : : S B E r r o r &error) const;
2011-07-19 04:13:38 +08:00
u i n t 32 _ t
L o a d I m a g e ( l l d b : : S B F i l e S p e c &image_spec, lldb::SBError &error);
2019-04-19 00:23:33 +08:00
2018-06-29 04:02:11 +08:00
% f e a t u r e ( "autodoc" , "
Load t h e library w h o s e filename is g i v e n by i m a g e _ s p e c l o o k i n g in all t h e
p a t h s s u p p l i e d in t h e p a t h s a r g u m e n t . If s u c c e s s f u l , return a t o k e n t h a t
c a n b e p a s s e d to U n l o a d I m a g e and fill l o a d e d _ p a t h with t h e p a t h t h a t w a s
2019-04-19 00:23:33 +08:00
s u c c e s s f u l l y l o a d e d . On f a i l u r e , return
l l d b . L L D B _ I N V A L I D _ I M A G E _ T O K E N . " ) L o a d I m a g e U s i n g P a t h s ;
u i n t 32 _ t
2018-06-29 04:02:11 +08:00
L o a d I m a g e U s i n g P a t h s ( c o n s t l l d b : : S B F i l e S p e c &image_spec,
S B S t r i n g L i s t &paths,
2019-04-19 00:23:33 +08:00
l l d b : : S B F i l e S p e c &loaded_path,
2018-06-29 04:02:11 +08:00
S B E r r o r &error);
2011-07-19 04:13:38 +08:00
l l d b : : S B E r r o r
U n l o a d I m a g e ( u i n t 32 _ t i m a g e _ t o k e n ) ;
2019-04-19 00:23:33 +08:00
2014-03-30 02:54:20 +08:00
l l d b : : S B E r r o r
S e n d E v e n t D a t a ( c o n s t char * e v e n t _ d a t a ) ;
2012-01-06 08:46:12 +08:00
2013-11-05 19:00:35 +08:00
% f e a t u r e ( "autodoc" , "
Return t h e n u m b e r of d i f f e r e n t t h r e a d - o r i g i n extended b a c k t r a c e s
t h i s process c a n s u p p o r t as a u i n t 32 _ t .
When t h e process is stopped and y o u h a v e a n S B T h r e a d , l l d b m a y b e
a b l e to s h o w a b a c k t r a c e of when t h a t t h r e a d w a s o r i g i n a l l y c r e a t e d ,
2019-04-19 00:23:33 +08:00
or t h e w o r k item w a s e n q u e u e d to i t ( in t h e case of a l i b d i s p a t c h
q u e u e ) . " ) G e t N u m E x t e n d e d B a c k t r a c e T y p e s ;
2013-11-05 19:00:35 +08:00
u i n t 32 _ t
2013-11-06 11:07:33 +08:00
G e t N u m E x t e n d e d B a c k t r a c e T y p e s ( ) ;
2013-11-05 19:00:35 +08:00
% f e a t u r e ( "autodoc" , "
2019-04-19 00:23:33 +08:00
T a k e s a n index a r g u m e n t , returns t h e name of o n e of t h e t h r e a d - o r i g i n
extended b a c k t r a c e m e t h o d s as a s t r . " ) G e t E x t e n d e d B a c k t r a c e T y p e A t I n d e x ;
2013-11-05 19:00:35 +08:00
c o n s t char *
2013-11-06 11:07:33 +08:00
G e t E x t e n d e d B a c k t r a c e T y p e A t I n d e x ( u i n t 32 _ t i d x ) ;
2013-11-05 19:00:35 +08:00
2014-09-06 09:33:13 +08:00
l l d b : : S B T h r e a d C o l l e c t i o n
G e t H i s t o r y T h r e a d s ( a d d r _ t a d d r ) ;
2019-04-19 00:23:33 +08:00
2014-10-11 09:59:32 +08:00
b o o l
I s I n s t r u m e n t a t i o n R u n t i m e P r e s e n t ( l l d b : : I n s t r u m e n t a t i o n R u n t i m e T y p e type ) ;
2014-09-06 09:33:13 +08:00
2015-11-21 07:09:11 +08:00
l l d b : : S B E r r o r
S a v e C o r e ( c o n s t char * f i l e _ n a m e ) ;
2016-06-25 07:40:35 +08:00
l l d b : : S B E r r o r
G e t M e m o r y R e g i o n I n f o ( l l d b : : a d d r _ t l o a d _ a d d r , l l d b : : S B M e m o r y R e g i o n I n f o ®ion_info);
l l d b : : S B M e m o r y R e g i o n I n f o L i s t
G e t M e m o r y R e g i o n s ( ) ;
2017-08-01 15:34:26 +08:00
% f e a t u r e ( "autodoc" , "
Get information a b o u t t h e process .
V a l i d process info w i l l o n l y b e r e t u r n e d when t h e process is a l i v e ,
2021-01-18 17:47:16 +08:00
use I s V a l i d ( ) to check if t h e info r e t u r n e d is v a l i d . : :
2017-08-01 15:34:26 +08:00
2021-01-18 17:47:16 +08:00
p r o c e s s _ i n f o = process . G e t P r o c e s s I n f o ( )
if p r o c e s s _ i n f o . I s V a l i d ( ) :
p r o c e s s _ i n f o . G e t P r o c e s s I D ( ) " ) G e t P r o c e s s I n f o ;
2017-08-01 15:34:26 +08:00
l l d b : : S B P r o c e s s I n f o
G e t P r o c e s s I n f o ( ) ;
2021-07-16 06:42:28 +08:00
% f e a t u r e ( "autodoc" , "
A l l o c a t e s a b l o c k of m e m o r y w i t h i n t h e process , with size and
a c c e s s p e r m i s s i o n s s p e c i f i e d in t h e a r g u m e n t s . T h e p e r m i s s s i o n s
a r g u m e n t is a n o r - c o m b i n a t i o n of z e r o or m o r e of
l l d b . e P e r m i s s i o n s W r i t a b l e , l l d b . e P e r m i s s i o n s R e a d a b l e , and
l l d b . e P e r m i s s i o n s E x e c u t a b l e . Returns t h e a d d r e s s
of t h e a l l o c a t e d buffer in t h e process , or
l l d b . L L D B _ I N V A L I D _ A D D R E S S if t h e a l l o c a t i o n f a i l e d . " ) A l l o c a t e M e m o r y ;
l l d b : : a d d r _ t
A l l o c a t e M e m o r y ( s i z e _ t size , u i n t 32 _ t p e r m i s s i o n s , l l d b : : S B E r r o r &error);
% f e a t u r e ( "autodoc" , "
D e a l l o c a t e s t h e b l o c k of m e m o r y ( p r e v i o u s l y a l l o c a t e d using
A l l o c a t e M e m o r y ) g i v e n in t h e a r g u m e n t . " ) D e a l l o c a t e M e m o r y ;
l l d b : : S B E r r o r
D e a l l o c a t e M e m o r y ( l l d b : : a d d r _ t p t r ) ;
2020-01-09 12:56:11 +08:00
S T R I N G _ E X T E N S I O N ( S B P r o c e s s )
2019-12-09 06:46:48 +08:00
# i f def S W I G P Y T H O N
2012-01-29 14:07:39 +08:00
% p y t h o n c o d e % {
2012-02-01 16:09:32 +08:00
def _ _ g e t _ i s _ a l i v e _ _ ( self ) :
''' Returns "True" if t h e process is c u r r e n t l y a l i v e , "False" otherwise '''
s = self . G e t S t a t e ( )
2019-04-19 00:23:33 +08:00
if ( s = = e S t a t e A t t a c h i n g or
s = = e S t a t e L a u n c h i n g or
s = = e S t a t e S t o p p e d or
s = = e S t a t e R u n n i n g or
s = = e S t a t e S t e p p i n g or
s = = e S t a t e C r a s h e d or
2012-02-01 16:09:32 +08:00
s = = e S t a t e S u s p e n d e d ) :
return True
return False
def _ _ g e t _ i s _ r u n n i n g _ _ ( self ) :
''' Returns "True" if t h e process is c u r r e n t l y r u n n i n g , "False" otherwise '''
s t a t e = self . G e t S t a t e ( )
if s t a t e = = e S t a t e R u n n i n g or s t a t e = = e S t a t e S t e p p i n g :
return True
return False
2016-07-06 02:19:43 +08:00
def _ _ g e t _ i s _ s t o p p e d _ _ ( self ) :
2012-02-01 16:09:32 +08:00
''' Returns "True" if t h e process is c u r r e n t l y stopped , "False" otherwise '''
s t a t e = self . G e t S t a t e ( )
if s t a t e = = e S t a t e S t o p p e d or s t a t e = = e S t a t e C r a s h e d or s t a t e = = e S t a t e S u s p e n d e d :
return True
return False
2012-02-03 11:22:53 +08:00
class t h r e a d 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 thread for a process when supplied an index.'''
def _ _ i n i t _ _ ( self , s b p r o c e s s ) :
self . s b p r o c e s s = s b p r o c e s s
2019-04-19 00:23:33 +08:00
2012-02-01 16:09:32 +08:00
def _ _ l e n _ _ ( self ) :
2012-05-12 04:39:42 +08:00
if self . s b p r o c e s s :
return int ( self . s b p r o c e s s . G e t N u m T h r e a d s ( ) )
2012-02-01 16:09:32 +08:00
return 0
2019-04-19 00:23:33 +08:00
2012-02-01 16:09:32 +08:00
def _ _ g e t i t e m _ _ ( self , key ) :
if type ( key ) is int and key < l e n ( self ) :
return self . s b p r o c e s s . G e t T h r e a d A t I n d e x ( key )
return None
2019-04-19 00:23:33 +08:00
2012-02-03 11:22:53 +08:00
def g e t _ t h r e a d s _ a c c e s s _ o b j e c t ( self ) :
'''An accessor function that returns a modules_access() object which allows lazy thread access from a lldb.SBProcess object.'''
return self . t h r e a d s _ a c c e s s ( self )
2019-04-19 00:23:33 +08:00
2012-02-01 16:09:32 +08:00
def g e t _ p r o c e s s _ t h r e a d _ l i s t ( self ) :
2012-02-03 11:22:53 +08:00
'''An accessor function that returns a list() that contains all threads in a lldb.SBProcess object.'''
2012-02-01 16:09:32 +08:00
t h r e a d s = [ ]
2012-10-09 03:06:11 +08:00
a c c e s s o r = self . g e t _ t h r e a d s _ a c c e s s _ o b j e c t ( )
for i d x in r a n g e ( l e n ( a c c e s s o r ) ) :
t h r e a d s . append ( a c c e s s o r [ i d x ] )
2012-02-01 16:09:32 +08:00
return t h r e a d s
2019-04-03 19:48:38 +08:00
def _ _ i t e r _ _ ( self ) :
'''Iterate over all threads in a lldb.SBProcess object.'''
return l l d b _ i t e r ( self , 'GetNumThreads', 'GetThreadAtIndex' )
2019-04-19 00:23:33 +08:00
2019-04-03 19:48:38 +08:00
def _ _ l e n _ _ ( self ) :
'''Return the number of threads in a lldb.SBProcess object.'''
return self . G e t N u m T h r e a d s ( )
2019-04-19 00:23:33 +08:00
2019-07-03 06:18:35 +08:00
t h r e a d s = property ( g e t _ p r o c e s s _ t h r e a d _ l i s t , None , d o c = '''A read only property that returns a list() of lldb.SBThread objects for this process.''' )
t h r e a d = property ( g e t _ t h r e a d s _ a c c e s s _ o b j e c t , None , d o c = '''A read only property that returns an object that can access threads by thread index (thread = lldb.process.thread[12]).''' )
i s _ a l i v e = property ( _ _ g e t _ i s _ a l i v e _ _ , None , d o c = '''A read only property that returns a boolean value that indicates if this process is currently alive.''' )
i s _ r u n n i n g = property ( _ _ g e t _ i s _ r u n n i n g _ _ , None , d o c = '''A read only property that returns a boolean value that indicates if this process is currently running.''' )
i s _ s t o p p e d = property ( _ _ g e t _ 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 process is currently stopped.''' )
i d = property ( G e t P r o c e s s I D , None , d o c = '''A read only property that returns the process ID as an integer.''' )
target = property ( G e t T a r g e t , None , d o c = '''A read only property that an lldb object that represents the target (lldb.SBTarget) that owns this process.''' )
n u m _ t h r e a d s = property ( G e t N u m T h r e a d s , None , d o c = '''A read only property that returns the number of threads in this process as an integer.''' )
s e l e c t e d _ t h r e a d = property ( G e t S e l e c t e d T h r e a d , S e t S e l e c t e d T h r e a d , d o c = '''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.''' )
s t a t e = property ( G e t S t a t e , 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.eState" ) t h a t r e p r e s e n t s t h e current s t a t e of t h i s process ( r u n n i n g , stopped , e x i t e d , e t c . ) . ''' )
e x i t _ s t a t e = property ( G e t E x i t S t a t u s , None , d o c = '''A read only property that returns an exit status as an integer of this process when the process state is lldb.eStateExited.''' )
e x i t _ d e s c r i p t i o n = property ( G e t E x i t D e s c r i p t i o n , None , d o c = '''A read only property that returns an exit description as a string of this process when the process state is lldb.eStateExited.''' )
b r o a d c a s t e r = property ( G e t B r o a d c a s t e r , None , d o c = '''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.''' )
2012-01-29 14:07:39 +08:00
% }
2019-12-09 06:46:48 +08:00
# e n d i f
2012-01-29 14:07:39 +08:00
2011-07-19 04:13:38 +08:00
} ;
} // namespace lldb