2011-07-19 04:13:38 +08:00
//===-- SWIG Interface for SBThread -----------------------------*- 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" ,
2021-01-15 21:43:26 +08:00
" 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 . : p y : class : ` S B P r o c e s s ` contains S B T h r e a d ( s ) .
2011-07-19 04:13:38 +08:00
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 /
2021-01-15 21:43:26 +08:00
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 ) , : :
2011-07-19 04:13:38 +08:00
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 )
2021-01-15 21:43:26 +08:00
S e e a l s o : p y : class : ` S B F r a m e ` . "
2011-07-19 04:13:38 +08:00
) 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 ( ) ;
2019-04-19 00:23:33 +08:00
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);
2019-04-19 00:23:33 +08:00
2012-10-11 02:32:14 +08:00
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);
2019-04-19 00:23:33 +08:00
2012-10-11 02:32:14 +08:00
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 ;
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
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" , "
2019-04-19 00:23:33 +08:00
Get t h e n u m b e r of w o r d s a s s o c i a t e d with t h e stop r e a s o n .
S e e a l s o G e t S t o p R e a s o n D a t a A t I n d e x ( ) . " ) G e t S t o p R e a s o n D a t a C o u n t ;
2011-07-19 04:13:38 +08:00
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" , "
2019-04-19 00:23:33 +08:00
Get information a s s o c i a t e d with a stop r e a s o n .
B r e a k p o i n t stop r e a s o n s w i l l h a v e d a t a t h a t c o n s i s t s of p a i r s of
b r e a k p o i n t I D s f o l l o w e d by t h e b r e a k p o i n t l o c a t i o n I D s ( t h e y a l w a y s c o m e
in p a i r s ) .
Stop R e a s o n Count D a t a Type
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
e S t o p R e a s o n N o n e 0
e S t o p R e a s o n T r a c e 0
e S t o p R e a s o n B r e a k p o i n t N d u p l e : { b r e a k p o i n t i d , l o c a t i o n i d }
e S t o p R e a s o n W a t c h p o i n t 1 w a t c h p o i n t i d
e S t o p R e a s o n S i g n a l 1 unix s i g n a l n u m b e r
e S t o p R e a s o n E x c e p t i o n N e x c e p t i o n d a t a
e S t o p R e a s o n E x e c 0
2021-03-29 23:05:30 +08:00
e S t o p R e a s o n F o r k 1 p i d of t h e c h i l d process
e S t o p R e a s o n V F o r k 1 p i d of t h e c h i l d process
e S t o p R e a s o n V F o r k D o n e 0
2019-04-19 00:23:33 +08:00
e S t o p R e a s o n P l a n C o m p l e t e 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 ;
2011-07-19 04:13:38 +08:00
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 ) ;
2019-04-19 00:23:33 +08:00
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
% f e a t u r e ( "autodoc" , "
C o l l e c t s a t h r e a d ' s stop r e a s o n extended information dictionary and p r i n t s i t
into t h e S B S t r e a m in a J S O N format . T h e format of t h i s J S O N dictionary d e p e n d s
2019-04-19 00:23:33 +08:00
on t h e stop r e a s o n and is c u r r e n t l y u s e d o n l y for i n s t r u m e n t a t i o n p l u g i n s . " ) G e t S t o p R e a s o n E x t e n d e d I n f o A s J S O N ;
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
b o o l
G e t S t o p R e a s o n E x t e n d e d I n f o A s J S O N ( l l d b : : S B S t r e a m &stream);
2019-04-19 00:23:33 +08:00
2016-03-23 23:36:22 +08:00
% f e a t u r e ( "autodoc" , "
Returns a c o l l e c t i o n of h i s t o r i c a l s t a c k t r a c e s t h a t a r e s i g n i f i c a n t to t h e
current stop r e a s o n . U s e d by T h r e a d S a n i t i z e r , where w e p r o v i d e v a r i o u s s t a c k
2019-04-19 00:23:33 +08:00
t r a c e s t h a t w e r e i n v o l v e d in a d a t a r a c e or o t h e r type of d e t e c t e d i s s u e . " ) G e t S t o p R e a s o n E x t e n d e d B a c k t r a c e s ;
2016-03-23 23:36:22 +08:00
S B T h r e a d C o l l e c t i o n
G e t S t o p R e a s o n E x t e n d e d B a c k t r a c e s ( 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 ) ;
2011-07-19 04:13:38 +08:00
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
2019-04-19 00:23:33 +08:00
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
2020-01-14 16:15:40 +08:00
G e t S t o p D e s c r i p t i o n ( char * d s t _ o r _ n u l l , s i z e _ t d s t _ l e n ) ;
2011-07-19 04:13:38 +08:00
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
2019-04-19 00:23:33 +08:00
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 . " )
2014-02-05 13:44:54 +08:00
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 .
2019-04-19 00:23:33 +08:00
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 . " )
2014-02-05 13:44:54 +08:00
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 .
2019-04-19 00:23:33 +08:00
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 ;
2013-11-05 19:00:35 +08:00
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 .
2019-04-19 00:23:33 +08:00
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-11-05 19:00:35 +08:00
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 ;
2017-02-02 11:02:51 +08:00
% f e a t u r e ( "docstring" , "
2019-04-19 00:23:33 +08:00
T a k e s a p a t h string and a S B S t r e a m r e f e r e n c e as p a r a m e t e r s , returns a b o o l .
C o l l e c t s t h e t h r e a d 's 'info' dictionary from t h e remote s y s t e m , u s e s t h e p a t h
a r g u m e n t to descend into t h e dictionary to a n item of i n t e r e s t , and p r i n t s
i t into t h e S B S t r e a m in a n a t u r a l format . Return b o o l is to i n d i c a t e if
a n y t h i n g w a s p r i n t e d into t h e stream ( true ) or not ( false ) . " ) G e t I n f o I t e m B y P a t h A s S t r i n g ;
2014-06-13 10:37:02 +08:00
b o o l
G e t I n f o I t e m B y P a t h A s S t r i n g ( c o n s t char * p a t h , l l d b : : S B S t r e a m &strm);
2014-04-25 08:01:15 +08:00
% f e a t u r e ( "autodoc" , "
Return t h e S B Q u e u e for t h i s t h r e a d . If t h i s t h r e a d is not c u r r e n t l y a s s o c i a t e d
with a l i b d i s p a t c h q u e u e , t h e S B Q u e u e o b j e c t ' s I s V a l i d ( ) method w i l l return false .
If t h i s S B T h r e a d is a c t u a l l y a H i s t o r y T h r e a d , w e m a y b e a b l e to p r o v i d e Q u e u e I D
and Q u e u e N a m e , b u t not p r o v i d e a n S B Q u e u e . T h o s e i n d i v i d u a l a t t r i b u t e s m a y h a v e
b e e n s a v e d for t h e H i s t o r y T h r e a d w i t h o u t e n o u g h information to r e c o n s t i t u t e t h e
e n t i r e S B Q u e u e at t h a t time .
2019-04-19 00:23:33 +08:00
T h i s method t a k e s no a r g u m e n t s , returns a n S B Q u e u e . " ) G e t Q u e u e ;
2014-04-25 08:01:15 +08:00
l l d b : : S B Q u e u e
G e t Q u e u e ( ) 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 ) ;
Improve SBThread's stepping API using SBError parameter.
Summary: The new methods will allow to get error messages from stepping API.
Reviewers: aprantl, clayborg, labath, jingham
Reviewed By: aprantl, clayborg, jingham
Subscribers: apolyakov, labath, jingham, clayborg, lemo, lldb-commits
Differential Revision: https://reviews.llvm.org/D47991
llvm-svn: 335180
2018-06-21 05:43:16 +08:00
% f e a t u r e ( "autodoc" ,
"Do a source level single step over in the currently selected thread." ) S t e p O v e r ;
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 , S B E r r o r &error);
2011-07-19 04:13:38 +08:00
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 ) ;
2016-02-13 08:31:47 +08:00
% f e a t u r e ( "autodoc" , "
Improve SBThread's stepping API using SBError parameter.
Summary: The new methods will allow to get error messages from stepping API.
Reviewers: aprantl, clayborg, labath, jingham
Reviewed By: aprantl, clayborg, jingham
Subscribers: apolyakov, labath, jingham, clayborg, lemo, lldb-commits
Differential Revision: https://reviews.llvm.org/D47991
llvm-svn: 335180
2018-06-21 05:43:16 +08:00
S t e p t h e current t h r e a d from t h e current source line to t h e line g i v e n by e n d _ l i n e , s t o p p i n g if
2016-02-13 08:31:47 +08:00
t h e t h r e a d s t e p s into t h e function g i v e n by t a r g e t _ n a m e . If t a r g e t _ n a m e is None , then s t e p p i n g w i l l stop
2019-04-19 00:23:33 +08:00
in any of t h e p l a c e s w e w o u l d n o r m a l l y stop . " ) S t e p I n t o ;
2016-02-13 08:31:47 +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 ,
u i n t 32 _ t e n d _ l i n e ,
S B E r r o r &error,
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 ( ) ;
Improve SBThread's stepping API using SBError parameter.
Summary: The new methods will allow to get error messages from stepping API.
Reviewers: aprantl, clayborg, labath, jingham
Reviewed By: aprantl, clayborg, jingham
Subscribers: apolyakov, labath, jingham, clayborg, lemo, lldb-commits
Differential Revision: https://reviews.llvm.org/D47991
llvm-svn: 335180
2018-06-21 05:43:16 +08:00
% f e a t u r e ( "autodoc" ,
"Step out of the currently selected thread." ) S t e p O u t ;
void
S t e p O u t ( S B E r r o r &error);
2011-07-19 04:13:38 +08:00
void
Improve SBThread's stepping API using SBError parameter.
Summary: The new methods will allow to get error messages from stepping API.
Reviewers: aprantl, clayborg, labath, jingham
Reviewed By: aprantl, clayborg, jingham
Subscribers: apolyakov, labath, jingham, clayborg, lemo, lldb-commits
Differential Revision: https://reviews.llvm.org/D47991
llvm-svn: 335180
2018-06-21 05:43:16 +08:00
S t e p O u t O f F r a m e ( S B F r a m e &frame);
% f e a t u r e ( "autodoc" ,
"Step out of the specified frame." ) S t e p O u t O f F r a m e ;
void
S t e p O u t O f F r a m e ( S B F r a m e &frame, SBError &error);
2011-07-19 04:13:38 +08:00
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 ) ;
Improve SBThread's stepping API using SBError parameter.
Summary: The new methods will allow to get error messages from stepping API.
Reviewers: aprantl, clayborg, labath, jingham
Reviewed By: aprantl, clayborg, jingham
Subscribers: apolyakov, labath, jingham, clayborg, lemo, lldb-commits
Differential Revision: https://reviews.llvm.org/D47991
llvm-svn: 335180
2018-06-21 05:43:16 +08:00
% f e a t u r e ( "autodoc" ,
2019-04-19 00:23:33 +08:00
"Do an instruction level single step in the currently selected thread." ) S t e p I n s t r u c t i o n ;
Improve SBThread's stepping API using SBError parameter.
Summary: The new methods will allow to get error messages from stepping API.
Reviewers: aprantl, clayborg, labath, jingham
Reviewed By: aprantl, clayborg, jingham
Subscribers: apolyakov, labath, jingham, clayborg, lemo, lldb-commits
Differential Revision: https://reviews.llvm.org/D47991
llvm-svn: 335180
2018-06-21 05:43:16 +08:00
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 &error);
2011-07-19 04:13:38 +08:00
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 ) ;
2014-09-30 07:17:18 +08:00
S B E r r o r
S t e p U s i n g S c r i p t e d T h r e a d P l a n ( c o n s t char * s c r i p t _ c l a s s _ n a m e ) ;
2016-08-06 06:06:12 +08:00
S B E r r o r
S t e p U s i n g S c r i p t e d T h r e a d P l a n ( c o n s t char * s c r i p t _ c l a s s _ n a m e , b o o l r e s u m e _ i m m e d i a t e l y ) ;
2019-10-04 06:50:18 +08:00
S B E r r o r
S t e p U s i n g S c r i p t e d T h r e a d P l a n ( c o n s t char * s c r i p t _ c l a s s _ n a m e ,
l l d b : : S B S t r u c t u r e d D a t a &args_data,
b o o l r e s u m e _ i m m e d i a t e l y ) ;
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 ) ;
Improve SBThread's stepping API using SBError parameter.
Summary: The new methods will allow to get error messages from stepping API.
Reviewers: aprantl, clayborg, labath, jingham
Reviewed By: aprantl, clayborg, jingham
Subscribers: apolyakov, labath, jingham, clayborg, lemo, lldb-commits
Differential Revision: https://reviews.llvm.org/D47991
llvm-svn: 335180
2018-06-21 05:43:16 +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 , S B E r r o r &error);
2015-10-13 03:02:08 +08:00
% f e a t u r e ( "autodoc" , "
F o r c e a return from t h e frame p a s s e d in ( and any f r a m e s y o u n g e r t h a n i t )
w i t h o u t e x e c u t i n g any m o r e code in t h o s e f r a m e s . If r e t u r n _ v a l u e contains
a v a l i d S B V a l u e , t h a t w i l l b e set as t h e return value from frame . N o t e , at
2019-04-19 00:23:33 +08:00
p r e s e n t o n l y s c a l a r return values a r e s u p p o r t e d . " ) R e t u r n F r o m F r a m e ;
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
2016-07-08 10:12:05 +08:00
% f e a t u r e ( "autodoc" , "
U n w i n d t h e s t a c k f r a m e s from t h e i n n e r m o s t e x p r e s s i o n e v a l u a t i o n .
2019-04-19 00:23:33 +08:00
T h i s A P I is e q u i v a l e n t to 'thread return -x' . " ) U n w i n d I n n e r m o s t E x p r e s s i o n ;
2016-07-08 10:12:05 +08:00
S B E r r o r
U n w i n d I n n e r m o s t E x p r e s s i o n ( ) ;
2011-07-19 04:13:38 +08:00
% f e a t u r e ( "docstring" , "
2019-04-19 00:23:33 +08:00
L L D B c u r r e n t l y s u p p o r t s process c e n t r i c d e b u g g i n g w h i c h m e a n s when any
t h r e a d in a process s t o p s , all o t h e r t h r e a d s a r e stopped . T h e S u s p e n d ( )
call h e r e t e l l s o u r process to s u s p e n d a t h r e a d and not l e t i t run when
t h e o t h e r t h r e a d s in a process a r e a l l o w e d to run . S o when
S B P r o c e s s : : C o n t i n u e ( ) is c a l l e d , any t h r e a d s t h a t a r e n ' t s u s p e n d e d w i l l
b e a l l o w e d to run . If any of t h e S B T h r e a d f u n c t i o n s for s t e p p i n g a r e
c a l l e d ( S t e p O v e r , S t e p I n t o , S t e p O u t , S t e p I n s t r u c t i o n , R u n T o A d d r e s ) , t h e
t h r e a d w i l l now b e a l l o w e d to run and t h e s e f u n c t i o n s w i l l s i m p l y return .
E v e n t u a l l y w e p l a n to add s u p p o r t for t h r e a d c e n t r i c d e b u g g i n g where
each t h r e a d is c o n t r o l l e d i n d i v i d u a l l y and each t h r e a d w o u l d b r o a d c a s t
i t s s t a t e , b u t w e h a v e n ' t i m p l e m e n t e d t h i s y e t .
L i k e w i s e t h e S B T h r e a d : : R e s u m e ( ) call w i l l a g a i n a l l o w t h e t h r e a d to run
when t h e process is c o n t i n u e d .
S u s p e n d ( ) and R e s u m e ( ) f u n c t i o n s a r e not c u r r e n t l y r e f e r e n c e c o u n t e d , if
a n y o n e h a s t h e n e e d for t h e m to b e r e f e r e n c e c o u n t e d , p l e a s e l e t u s
k n o w . " ) S u s p e n d ;
2011-07-19 04:13:38 +08:00
b o o l
S u s p e n d ( ) ;
Improve SBThread's stepping API using SBError parameter.
Summary: The new methods will allow to get error messages from stepping API.
Reviewers: aprantl, clayborg, labath, jingham
Reviewed By: aprantl, clayborg, jingham
Subscribers: apolyakov, labath, jingham, clayborg, lemo, lldb-commits
Differential Revision: https://reviews.llvm.org/D47991
llvm-svn: 335180
2018-06-21 05:43:16 +08:00
b o o l
S u s p e n d ( S B E r r o r &error);
2019-04-19 00:23:33 +08:00
2011-07-19 04:13:38 +08:00
b o o l
R e s u m e ( ) ;
Improve SBThread's stepping API using SBError parameter.
Summary: The new methods will allow to get error messages from stepping API.
Reviewers: aprantl, clayborg, labath, jingham
Reviewed By: aprantl, clayborg, jingham
Subscribers: apolyakov, labath, jingham, clayborg, lemo, lldb-commits
Differential Revision: https://reviews.llvm.org/D47991
llvm-svn: 335180
2018-06-21 05:43:16 +08:00
b o o l
R e s u m e ( S B E r r o r &error);
2019-04-19 00:23:33 +08:00
2011-07-19 04:13:38 +08:00
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;
2019-04-19 00:23:33 +08:00
2016-11-09 04:36:40 +08:00
% f e a t u r e ( "docstring" , "
2019-04-19 00:23:33 +08:00
Get t h e d e s c r i p t i o n s t r i n g s for t h i s t h r e a d t h a t m a t c h w h a t t h e
l l d b d r i v e r w i l l p r e s e n t , using t h e t h r e a d - f o r m a t ( s t o p _ f o r m a t = = false )
or t h r e a d - s t o p - f o r m a t ( s t o p _ f o r m a t = true ) . " ) G e t D e s c r i p t i o n ;
2016-11-09 04:36:40 +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 stop_format) const;
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;
2019-04-19 00:23:33 +08:00
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
2019-04-19 00:23:33 +08:00
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
2013-11-06 08:04:44 +08:00
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
2019-04-19 00:23:33 +08:00
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 . " ) 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
2019-04-19 00:23:33 +08:00
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
2013-11-16 09:24:22 +08:00
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 ) .
2019-04-19 00:23:33 +08:00
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 ;
2013-11-16 09:24:22 +08:00
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 ( ) ;
2019-04-19 00:23:33 +08:00
2018-12-20 10:01:59 +08:00
% f e a t u r e ( "autodoc" , "
Returns a n S B V a l u e o b j e c t r e p r e s e t i n g t h e current e x c e p t i o n for t h e t h r e a d ,
if t h e r e is any . C u r r e n t l y , t h i s w o r k s for O b j - C code and returns a n S B V a l u e
r e p r e s e n t i n g t h e N S E x c e p t i o n o b j e c t at t h e throw s i t e or t h a t ' s c u r r e n t l y
2019-04-19 00:23:33 +08:00
b e i n g p r o c e s s e s . " ) G e t C u r r e n t E x c e p t i o n ;
2018-12-20 10:01:59 +08:00
l l d b : : S B V a l u e
G e t C u r r e n t E x c e p t i o n ( ) ;
% f e a t u r e ( "autodoc" , "
Returns a h i s t o r i c a l ( f a k e ) S B T h r e a d r e p r e s e n t i n g t h e s t a c k t r a c e of a n
e x c e p t i o n , if t h e r e is o n e for t h e t h r e a d . C u r r e n t l y , t h i s w o r k s for O b j - C
code , and c a n r e t r i e v e t h e t h r o w - s i t e b a c k t r a c e of a n N S E x c e p t i o n o b j e c t
2019-04-19 00:23:33 +08:00
e v e n when t h e p r o g r a m is no l o n g e r at t h e throw s i t e . " ) G e t C u r r e n t E x c e p t i o n B a c k t r a c e ;
2018-12-20 10:01:59 +08:00
l l d b : : S B T h r e a d
G e t C u r r e n t E x c e p t i o n B a c k t r a c e ( ) ;
2013-11-16 09:24:22 +08:00
2014-05-14 06:02:48 +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 b o o l .
l l d b m a y b e a b l e to d e t e c t t h a t function c a l l s s h o u l d not b e e x e c u t e d
on a g i v e n t h r e a d at a p a r t i c u l a r p o i n t in time . I t is r e c o m m e n d e d t h a t
t h i s is checked b e f o r e p e r f o r m i n g a n i n f e r i o r function call on a g i v e n
2019-04-19 00:23:33 +08:00
t h r e a d . " ) S a f e T o C a l l F u n c t i o n s ;
2014-05-14 06:02:48 +08:00
b o o l
S a f e T o C a l l F u n c t i o n s ( ) ;
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 T h r e a d )
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 % {
2019-04-03 19:48:38 +08:00
def _ _ i t e r _ _ ( self ) :
'''Iterate over all frames in a lldb.SBThread object.'''
return l l d b _ i t e r ( self , 'GetNumFrames', 'GetFrameAtIndex' )
def _ _ l e n _ _ ( self ) :
'''Return the number of frames in a lldb.SBThread object.'''
return self . G e t N u m F r a m e s ( )
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
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 < 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
2019-04-19 00:23:33 +08:00
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
2019-04-19 00:23:33 +08:00
2019-07-03 06:18:35 +08:00
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.''' )
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.''' )
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.''' )
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.''' )
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.''' )
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.''' )
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]" ) . ''' )
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.''' )
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.''' )
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.''' )
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 . ''' )
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.''' )
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
% }
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