2011-07-17 05:15:39 +08:00
//===-- SWIG Interface for SBTarget -----------------------------*- 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 {
2012-02-24 13:03:03 +08:00
class S B L a u n c h I n f o
{
2012-02-25 04:59:25 +08:00
public :
S B L a u n c h I n f o ( c o n s t char * * a r g v ) ;
2012-02-24 13:03:03 +08:00
u i n t 32 _ t
G e t U s e r I D ( ) ;
u i n t 32 _ t
G e t G r o u p I D ( ) ;
b o o l
U s e r I D I s V a l i d ( ) ;
b o o l
G r o u p I D I s V a l i d ( ) ;
void
SetUserID ( u i n t 32 _ t u i d ) ;
void
S e t G r o u p I D ( u i n t 32 _ t g i d ) ;
u i n t 32 _ t
G e t N u m A r g u m e n t s ( ) ;
c o n s t char *
G e t A r g u m e n t A t I n d e x ( u i n t 32 _ t i d x ) ;
void
S e t A r g u m e n t s ( c o n s t char * * a r g v , b o o l append ) ;
u i n t 32 _ t
G e t N u m E n v i r o n m e n t E n t r i e s ( ) ;
c o n s t char *
G e t E n v i r o n m e n t E n t r y A t I n d e x ( u i n t 32 _ t i d x ) ;
void
S e t E n v i r o n m e n t E n t r i e s ( c o n s t char * * e n v p , b o o l append ) ;
void
Clear ( ) ;
c o n s t char *
G e t W o r k i n g D i r e c t o r y ( ) c o n s t ;
void
S e t W o r k i n g D i r e c t o r y ( c o n s t char * w o r k i n g _ d i r ) ;
u i n t 32 _ t
G e t L a u n c h F l a g s ( ) ;
void
S e t L a u n c h F l a g s ( u i n t 32 _ t f l a g s ) ;
c o n s t char *
G e t P r o c e s s P l u g i n N a m e ( ) ;
void
S e t P r o c e s s P l u g i n N a m e ( c o n s t char * p l u g i n _ n a m e ) ;
c o n s t char *
G e t S h e l l ( ) ;
void
S e t S h e l l ( c o n s t char * p a t h ) ;
u i n t 32 _ t
G e t R e s u m e C o u n t ( ) ;
void
S e t R e s u m e C o u n t ( u i n t 32 _ t c ) ;
b o o l
A d d C l o s e F i l e A c t i o n ( int f d ) ;
b o o l
A d d D u p l i c a t e F i l e A c t i o n ( int f d , int d u p _ f d ) ;
b o o l
A d d O p e n F i l e A c t i o n ( int f d , c o n s t char * p a t h , b o o l r e a d , b o o l write ) ;
b o o l
A d d S u p p r e s s F i l e A c t i o n ( int f d , b o o l r e a d , b o o l write ) ;
} ;
class S B A t t a c h I n f o
{
public :
S B A t t a c h I n f o ( ) ;
S B A t t a c h I n f o ( l l d b : : p i d _ t p i d ) ;
S B A t t a c h I n f o ( c o n s t char * p a t h , b o o l w a i t _ f o r ) ;
S B A t t a c h I n f o ( c o n s t l l d b : : S B A t t a c h I n f o &rhs);
l l d b : : p i d _ t
G e t P r o c e s s I D ( ) ;
void
S e t P r o c e s s I D ( l l d b : : p i d _ t p i d ) ;
void
S e t E x e c u t a b l e ( c o n s t char * p a t h ) ;
void
S e t E x e c u t a b l e ( l l d b : : S B F i l e S p e c e x e _ f i l e ) ;
b o o l
G e t W a i t F o r L a u n c h ( ) ;
void
S e t W a i t F o r L a u n c h ( b o o l b ) ;
2012-07-21 05:37:13 +08:00
b o o l
G e t I g n o r e E x i s t i n g ( ) ;
void
S e t I g n o r e E x i s t i n g ( b o o l b ) ;
2012-02-24 13:03:03 +08:00
u i n t 32 _ t
G e t R e s u m e C o u n t ( ) ;
void
S e t R e s u m e C o u n t ( u i n t 32 _ t c ) ;
c o n s t char *
G e t P r o c e s s P l u g i n N a m e ( ) ;
void
S e t P r o c e s s P l u g i n N a m e ( c o n s t char * p l u g i n _ n a m e ) ;
2012-02-25 07:56:06 +08:00
u i n t 32 _ t
G e t U s e r I D ( ) ;
u i n t 32 _ t
G e t G r o u p I D ( ) ;
b o o l
U s e r I D I s V a l i d ( ) ;
b o o l
G r o u p I D I s V a l i d ( ) ;
void
SetUserID ( u i n t 32 _ t u i d ) ;
void
S e t G r o u p I D ( u i n t 32 _ t g i d ) ;
2012-02-24 13:03:03 +08:00
u i n t 32 _ t
G e t E f f e c t i v e U s e r I D ( ) ;
u i n t 32 _ t
G e t E f f e c t i v e G r o u p I D ( ) ;
b o o l
E f f e c t i v e U s e r I D I s V a l i d ( ) ;
b o o l
E f f e c t i v e G r o u p I D I s V a l i d ( ) ;
void
S e t E f f e c t i v e U s e r I D ( u i n t 32 _ t u i d ) ;
void
S e t E f f e c t i v e G r o u p I D ( u i n t 32 _ t g i d ) ;
l l d b : : p i d _ t
G e t P a r e n t P r o c e s s I D ( ) ;
void
S e t P a r e n t P r o c e s s I D ( l l d b : : p i d _ t p i d ) ;
b o o l
P a r e n t P r o c e s s I D I s V a l i d ( ) ;
} ;
2011-07-17 05:15:39 +08:00
% f e a t u r e ( "docstring" ,
" R e p r e s e n t s t h e target p r o g r a m r u n n i n g u n d e r t h e debugger .
2011-10-14 08:42:25 +08:00
S B T a r g e t s u p p o r t s m o d u l e , b r e a k p o i n t , and w a t c h p o i n t i t e r a t i o n s . For e x a m p l e ,
2011-07-17 05:15:39 +08:00
for m in target . m o d u l e _ i t e r ( ) :
p r i n t m
p r o d u c e s :
( x 86 _ 64 ) / V o l u m e s / d a t a / l l d b / s v n / t r u n k / 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 / a . o u t
( x 86 _ 64 ) / u s r / l i b / d y l d
( x 86 _ 64 ) / u s r / l i b / l i b s t d c + + . 6 . d y l i b
( x 86 _ 64 ) / u s r / l i b / l i b S y s t e m . B . d y l i b
( x 86 _ 64 ) / u s r / l i b / s y s t e m / l i b m a t h C o m m o n . A . d y l i b
( x 86 _ 64 ) / u s r / l i b / l i b S y s t e m . B . d y l i b ( _ _ c o m m p a g e )
and ,
for b in target . b r e a k p o i n t _ i t e r ( ) :
p r i n t b
p r o d u c e s :
S B B r e a k p o i n t : i d = 1 , file = 'main.cpp' , line = 66 , l o c a t i o n s = 1
2011-09-27 09:19:20 +08:00
S B B r e a k p o i n t : i d = 2 , file = 'main.cpp' , line = 85 , l o c a t i o n s = 1
and ,
2011-10-14 08:42:25 +08:00
for w p _ l o c in target . w a t c h p o i n t _ i t e r ( ) :
2011-09-27 09:19:20 +08:00
p r i n t w p _ l o c
p r o d u c e s :
2011-10-14 08:42:25 +08:00
W a t c h p o i n t 1 : a d d r = 0x1034ca048 size = 4 s t a t e = e n a b l e d type = r w
2011-09-27 09:19:20 +08:00
declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12'
2011-10-14 08:42:25 +08:00
h w _ i n d e x = 0 h i t _ c o u n t = 2 i g n o r e _ c o u n t = 0 "
2011-07-19 04:13:38 +08:00
) S B T a r g e t ;
2011-07-17 05:15:39 +08:00
class S B T a r g e t
{
public :
//------------------------------------------------------------------
// Broadcaster bits.
//------------------------------------------------------------------
enum
{
e B r o a d c a s t B i t B r e a k p o i n t C h a n g e d = ( 1 < < 0 ) ,
e B r o a d c a s t B i t M o d u l e s L o a d e d = ( 1 < < 1 ) ,
e B r o a d c a s t B i t M o d u l e s U n l o a d e d = ( 1 < < 2 )
} ;
//------------------------------------------------------------------
// Constructors
//------------------------------------------------------------------
S B T a r g e t ( ) ;
S B T a r g e t ( c o n s t l l d b : : S B T a r g e t & rhs);
//------------------------------------------------------------------
// Destructor
//------------------------------------------------------------------
~ S B T a r g e t ( ) ;
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 ( ) ;
2011-07-17 05:15:39 +08:00
b o o l
I s V a l i d ( ) c o n s t ;
l l d b : : S B P r o c e s s
G e t P r o c e s s ( ) ;
% f e a t u r e ( "docstring" , "
//------------------------------------------------------------------
/// Launch a new process.
///
/// Launch a new process by spawning a new process using the
/// target object's executable module's file as the file to launch.
/// Arguments are given in \a argv, and the environment variables
/// are in \a envp. Standard input and output files can be
/// optionally re-directed to \a stdin_path, \a stdout_path, and
/// \a stderr_path.
///
/// @param[in] listener
/// An optional listener that will receive all process events.
/// If \a listener is valid then \a listener will listen to all
/// process events. If not valid, then this target's debugger
/// (SBTarget::GetDebugger()) will listen to all process events.
///
/// @param[in] argv
/// The argument array.
///
/// @param[in] envp
/// The environment array.
///
/// @param[in] launch_flags
/// Flags to modify the launch (@see lldb::LaunchFlags)
///
/// @param[in] stdin_path
/// The path to use when re-directing the STDIN of the new
/// process. If all stdXX_path arguments are NULL, a pseudo
/// terminal will be used.
///
/// @param[in] stdout_path
/// The path to use when re-directing the STDOUT of the new
/// process. If all stdXX_path arguments are NULL, a pseudo
/// terminal will be used.
///
/// @param[in] stderr_path
/// The path to use when re-directing the STDERR of the new
/// process. If all stdXX_path arguments are NULL, a pseudo
/// terminal will be used.
///
/// @param[in] working_directory
/// The working directory to have the child process run in
///
/// @param[in] launch_flags
/// Some launch options specified by logical OR'ing
/// lldb::LaunchFlags enumeration values together.
///
/// @param[in] stop_at_endtry
/// If false do not stop the inferior at the entry point.
///
/// @param[out]
/// An error object. Contains the reason if there is some failure.
///
/// @return
/// A process object for the newly created process.
//------------------------------------------------------------------
For e x a m p l e ,
process = target . L a u n c h ( self . d b g . G e t L i s t e n e r ( ) , None , None ,
None , '/tmp/stdout.txt' , None ,
None , 0 , False , error )
l a u n c h e s a new process by p a s s i n g n o t h i n g for b o t h t h e a r g s and t h e e n v s
and r e d i r e c t t h e s t a n d a r d output of t h e i n f e r i o r to t h e / t m p / s t d o u t . t x t
file . I t d o e s not s p e c i f y a w o r k i n g d i r e c t o r y s o t h a t t h e debug server
w i l l use i t s i d e a of w h a t t h e current w o r k i n g d i r e c t o r y is for t h e
i n f e r i o r . A l s o , w e a s k t h e debugger not to stop t h e i n f e r i o r at t h e
entry p o i n t . If no b r e a k p o i n t is s p e c i f i e d for t h e i n f e r i o r , i t s h o u l d
run to c o m p l e t i o n if no user i n t e r a c t i o n is r e q u i r e d .
" ) L a u n c h ;
l l d b : : S B P r o c e s s
L a u n c h ( S B L i s t e n e r &listener,
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 , // See LaunchFlags
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);
% f e a t u r e ( "docstring" , "
//------------------------------------------------------------------
/// Launch a new process with sensible defaults.
///
/// @param[in] argv
/// The argument array.
///
/// @param[in] envp
/// The environment array.
///
/// @param[in] working_directory
/// The working directory to have the child process run in
///
/// Default: listener
/// Set to the target's debugger (SBTarget::GetDebugger())
///
/// Default: launch_flags
/// Empty launch flags
///
/// Default: stdin_path
/// Default: stdout_path
/// Default: stderr_path
/// A pseudo terminal will be used.
///
/// @return
/// A process object for the newly created process.
//------------------------------------------------------------------
For e x a m p l e ,
process = target . L a u n c h S i m p l e ( [ 'X', 'Y', 'Z' ] , None , o s . g e t c w d ( ) )
l a u n c h e s a new process by p a s s i n g 'X', 'Y', 'Z' as t h e a r g s to t h e
e x e c u t a b l e .
" ) L a u n c h S i m p l e ;
l l d b : : S B P r o c e s s
L a u n c h S i m p l e ( c o n s t char * * a r g v ,
c o n s t char * * e n v p ,
c o n s t char * w o r k i n g _ d i r e c t o r y ) ;
2012-02-24 13:03:03 +08:00
l l d b : : S B P r o c e s s
L a u n c h ( l l d b : : S B L a u n c h I n f o &launch_info, lldb::SBError& error);
l l d b : : S B P r o c e s s
A t t a c h ( l l d b : : S B A t t a c h I n f o &attach_info, lldb::SBError& error);
2011-07-17 05:15:39 +08:00
% f e a t u r e ( "docstring" , "
//------------------------------------------------------------------
/// Attach to process with pid.
///
/// @param[in] listener
/// An optional listener that will receive all process events.
/// If \a listener is valid then \a listener will listen to all
/// process events. If not valid, then this target's debugger
/// (SBTarget::GetDebugger()) will listen to all process events.
///
/// @param[in] pid
/// The process ID to attach to.
///
/// @param[out]
/// An error explaining what went wrong if attach fails.
///
/// @return
/// A process object for the attached process.
//------------------------------------------------------------------
" ) 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 : : S B P r o c e s s
A t t a c h T o P r o c e s s W i t h I D ( S B L i s t e n e r &listener,
l l d b : : p i d _ t p i d ,
l l d b : : S B E r r o r & error);
% f e a t u r e ( "docstring" , "
//------------------------------------------------------------------
/// Attach to process with name.
///
/// @param[in] listener
/// An optional listener that will receive all process events.
/// If \a listener is valid then \a listener will listen to all
/// process events. If not valid, then this target's debugger
/// (SBTarget::GetDebugger()) will listen to all process events.
///
/// @param[in] name
/// Basename of process to attach to.
///
/// @param[in] wait_for
/// If true wait for a new instance of 'name' to be launched.
///
/// @param[out]
/// An error explaining what went wrong if attach fails.
///
/// @return
/// A process object for the attached process.
//------------------------------------------------------------------
" ) A t t a c h T o P r o c e s s W i t h N a m e ;
l l d b : : S B P r o c e s s
A t t a c h T o P r o c e s s W i t h N a m e ( S B L i s t e n e r &listener,
c o n s t char * name ,
b o o l w a i t _ f o r ,
l l d b : : S B E r r o r & error);
% f e a t u r e ( "docstring" , "
//------------------------------------------------------------------
/// Connect to a remote debug server with url.
///
/// @param[in] listener
/// An optional listener that will receive all process events.
/// If \a listener is valid then \a listener will listen to all
/// process events. If not valid, then this target's debugger
/// (SBTarget::GetDebugger()) will listen to all process events.
///
/// @param[in] url
/// The url to connect to, e.g., 'connect://localhost:12345'.
///
/// @param[in] plugin_name
/// The plugin name to be used; can be NULL.
///
/// @param[out]
/// An error explaining what went wrong if the connect fails.
///
/// @return
/// A process object for the connected process.
//------------------------------------------------------------------
" ) C o n n e c t R e m o t e ;
l l d b : : S B P r o c e s s
C o n n e c t R e m o t e ( S B L i s t e n e r &listener,
c o n s t char * url ,
c o n s t char * p l u g i n _ n a m e ,
S B E r r o r & error);
l l d b : : S B F i l e S p e c
G e t E x e c u t a b l e ( ) ;
2011-09-24 08:52:29 +08:00
b o o l
A d d M o d u l e ( l l d b : : S B M o d u l e &module);
l l d b : : S B M o d u l e
A d d M o d u l e ( c o n s t char * p a t h ,
c o n s t char * t r i p l e ,
c o n s t char * u u i d ) ;
2012-04-24 04:23:39 +08:00
l l d b : : S B M o d u l e
A d d M o d u l e ( c o n s t char * p a t h ,
c o n s t char * t r i p l e ,
c o n s t char * u u i d _ c s t r ,
c o n s t char * s y m f i l e ) ;
2011-07-17 05:15:39 +08:00
u i n t 32 _ t
G e t N u m M o d u l e s ( ) c o n s t ;
l l d b : : S B M o d u l e
G e t M o d u l e A t I n d e x ( u i n t 32 _ t i d x ) ;
2011-09-24 08:52:29 +08:00
b o o l
R e m o v e M o d u l e ( l l d b : : S B M o d u l e m o d u l e ) ;
2011-07-17 05:15:39 +08:00
l l d b : : S B D e b u g g e r
G e t D e b u g g e r ( ) c o n s t ;
l l d b : : S B M o d u l e
F i n d M o d u l e ( c o n s t l l d b : : S B F i l e S p e c &file_spec);
2012-01-29 14:07:39 +08:00
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 ( ) ;
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 char *
G e t T r i p l e ( ) ;
2011-09-24 08:52:29 +08:00
l l d b : : S B E r r o r
S e t S e c t i o n L o a d A d d r e s s ( l l d b : : S B S e c t i o n section ,
l l d b : : a d d r _ t s e c t i o n _ b a s e _ a d d r ) ;
l l d b : : S B E r r o r
C l e a r S e c t i o n L o a d A d d r e s s ( l l d b : : S B S e c t i o n section ) ;
l l d b : : S B E r r o r
S e t M o d u l e L o a d A d d r e s s ( l l d b : : S B M o d u l e m o d u l e ,
i n t 64 _ t s e c t i o n s _ o f f s e t ) ;
l l d b : : S B E r r o r
C l e a r M o d u l e L o a d A d d r e s s ( l l d b : : S B M o d u l e m o d u l e ) ;
2011-07-17 05:15:39 +08:00
% f e a t u r e ( "docstring" , "
//------------------------------------------------------------------
/// Find functions by name.
///
/// @param[in] name
/// The name of the function we are looking for.
///
/// @param[in] name_type_mask
/// A logical OR of one or more FunctionNameType enum bits that
/// indicate what kind of names should be used when doing the
/// lookup. Bits include fully qualified names, base names,
/// C++ methods, or ObjC selectors.
/// See FunctionNameType for more details.
///
/// @return
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
/// A lldb::SBSymbolContextList that gets filled in with all of
/// the symbol contexts for all the matches.
2011-07-17 05:15:39 +08:00
//------------------------------------------------------------------
" ) F i n d F u n c t i o n s ;
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
l l d b : : S B S y m b o l C o n t e x t L i s t
2011-07-17 05:15:39 +08:00
F i n d F u n c t i o n s ( c o n s t char * name ,
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
u i n t 32 _ t n a m e _ t y p e _ m a s k = l l d b : : e F u n c t i o n N a m e T y p e A n y ) ;
2011-07-30 03:53:35 +08:00
l l d b : : S B T y p e
F i n d F i r s t T y p e ( c o n s t char * type ) ;
l l d b : : S B T y p e L i s t
F i n d T y p e s ( c o n s t char * type ) ;
2011-07-17 05:15:39 +08:00
2012-12-06 05:24:42 +08:00
l l d b : : S B T y p e
G e t B a s i c T y p e ( l l d b : : B a s i c T y p e type ) ;
2011-09-13 08:29:56 +08:00
l l d b : : S B S o u r c e M a n a g e r
G e t S o u r c e M a n a g e r ( ) ;
2011-07-17 05:15:39 +08:00
% f e a t u r e ( "docstring" , "
//------------------------------------------------------------------
/// Find global and static variables by name.
///
/// @param[in] name
/// The name of the global or static variable we are looking
/// for.
///
/// @param[in] max_matches
/// Allow the number of matches to be limited to \a max_matches.
///
/// @return
/// A list of matched variables in an SBValueList.
//------------------------------------------------------------------
" ) F i n d G l o b a l V a r i a b l e s ;
l l d b : : S B V a l u e L i s t
F i n d G l o b a l V a r i a b l e s ( c o n s t char * name ,
u i n t 32 _ t m a x _ m a t c h e s ) ;
void
Clear ( ) ;
2011-07-23 00:46:35 +08:00
l l d b : : S B A d d r e s s
R e s o l v e L o a d A d d r e s s ( l l d b : : a d d r _ t v m _ a d d r ) ;
2011-07-17 05:15:39 +08:00
S B S y m b o l C o n t e x t
R e s o l v e S y m b o l C o n t e x t F o r A d d r e s s ( c o n s t S B A d d r e s s & addr,
u i n t 32 _ t r e s o l v e _ s c o p e ) ;
l l d b : : S B B r e a k p o i n t
B r e a k p o i n t C r e a t e B y L o c a t i o n ( c o n s t char * file , u i n t 32 _ t line ) ;
l l d b : : S B B r e a k p o i n t
B r e a k p o i n t C r e a t e B y L o c a t i o n ( c o n s t l l d b : : S B F i l e S p e c &file_spec, uint32_t line);
l l d b : : S B B r e a k p o i n t
B r e a k p o i n t C r e a t e B y N a m e ( c o n s t char * s y m b o l _ n a m e , c o n s t char * m o d u l e _ n a m e = NULL ) ;
2011-10-11 09:18:55 +08:00
l l d b : : S B B r e a k p o i n t
B r e a k p o i n t C r e a t e B y N a m e ( c o n s t char * s y m b o l _ n a m e ,
u i n t 32 _ t f u n c _ n a m e _ t y p e , // Logical OR one or more FunctionNameType enum bits
c o n s t S B F i l e S p e c L i s t &module_list,
c o n s t S B F i l e S p e c L i s t &comp_unit_list);
2012-03-06 08:37:27 +08:00
l l d b : : S B B r e a k p o i n t
B r e a k p o i n t C r e a t e B y N a m e s ( c o n s t char * s y m b o l _ n a m e [ ] ,
u i n t 32 _ t n u m _ n a m e s ,
u i n t 32 _ t n a m e _ t y p e _ m a s k , // Logical OR one or more FunctionNameType enum bits
c o n s t S B F i l e S p e c L i s t &module_list,
c o n s t S B F i l e S p e c L i s t &comp_unit_list);
2011-07-17 05:15:39 +08:00
l l d b : : S B B r e a k p o i n t
B r e a k p o i n t C r e a t e B y R e g e x ( c o n s t char * s y m b o l _ n a m e _ r e g e x , c o n s t char * m o d u l e _ n a m e = NULL ) ;
2011-09-21 09:17:13 +08:00
l l d b : : S B B r e a k p o i n t
B r e a k p o i n t C r e a t e B y S o u r c e R e g e x ( c o n s t char * s o u r c e _ r e g e x , c o n s t l l d b : : S B F i l e S p e c &source_file, const char *module_name = NULL);
2012-03-06 08:37:27 +08:00
l l d b : : S B B r e a k p o i n t
B r e a k p o i n t C r e a t e F o r E x c e p t i o n ( l l d b : : L a n g u a g e T y p e language ,
b o o l c a t c h _ b p ,
b o o l t h r o w _ b p ) ;
2011-07-17 05:15:39 +08:00
l l d b : : S B B r e a k p o i n t
B r e a k p o i n t C r e a t e B y A d d r e s s ( a d d r _ t a d d r e s s ) ;
u i n t 32 _ t
G e t N u m B r e a k p o i n t s ( ) c o n s t ;
l l d b : : S B B r e a k p o i n t
G e t B r e a k p o i n t A t I n d e x ( u i n t 32 _ t i d x ) c o n s t ;
b o o l
B r e a k p o i n t D e l e t e ( b r e a k _ i d _ t b r e a k _ i d ) ;
l l d b : : S B B r e a k p o i n t
F i n d B r e a k p o i n t B y I D ( b r e a k _ i d _ t b r e a k _ i d ) ;
b o o l
E n a b l e A l l B r e a k p o i n t s ( ) ;
b o o l
D i s a b l e A l l B r e a k p o i n t s ( ) ;
b o o l
D e l e t e A l l B r e a k p o i n t s ( ) ;
2011-09-27 09:19:20 +08:00
u i n t 32 _ t
2011-10-14 02:08:26 +08:00
G e t N u m W a t c h p o i n t s ( ) c o n s t ;
l l d b : : S B W a t c h p o i n t
G e t W a t c h p o i n t A t I n d e x ( u i n t 32 _ t i d x ) c o n s t ;
2011-09-27 09:19:20 +08:00
b o o l
2011-10-14 02:08:26 +08:00
D e l e t e W a t c h p o i n t ( l l d b : : w a t c h _ i d _ t w a t c h _ i d ) ;
l l d b : : S B W a t c h p o i n t
F i n d W a t c h p o i n t B y I D ( l l d b : : w a t c h _ i d _ t w a t c h _ i d ) ;
2011-09-27 09:19:20 +08:00
b o o l
2011-10-14 02:08:26 +08:00
E n a b l e A l l W a t c h p o i n t s ( ) ;
2011-09-27 09:19:20 +08:00
b o o l
2011-10-14 02:08:26 +08:00
D i s a b l e A l l W a t c h p o i n t s ( ) ;
2011-09-27 09:19:20 +08:00
b o o l
2011-10-14 02:08:26 +08:00
D e l e t e A l l W a t c h p o i n t s ( ) ;
l l d b : : S B W a t c h p o i n t
W a t c h A d d r e s s ( l l d b : : a d d r _ t a d d r ,
s i z e _ t size ,
b o o l r e a d ,
2012-06-05 07:19:54 +08:00
b o o l write ,
S B E r r o r &error);
2011-10-14 02:08:26 +08:00
2011-09-27 09:19:20 +08:00
2011-07-17 05:15:39 +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 ;
2011-12-15 07:49:37 +08:00
2012-03-07 06:24:44 +08:00
l l d b : : S B I n s t r u c t i o n L i s t
R e a d I n s t r u c t i o n s ( l l d b : : S B A d d r e s s b a s e _ a d d r , u i n t 32 _ t count ) ;
2011-12-15 07:49:37 +08:00
l l d b : : S B I n s t r u c t i o n L i s t
G e t I n s t r u c t i o n s ( l l d b : : S B A d d r e s s b a s e _ a d d r , c o n s t void * b u f , s i z e _ t size ) ;
2012-12-04 10:22:16 +08:00
l l d b : : S B S y m b o l C o n t e x t L i s t
F i n d S y m b o l s ( c o n s t char * name , l l d b : : S y m b o l T y p e type = e S y m b o l T y p e A n y ) ;
2011-07-17 05:15:39 +08:00
b o o l
2011-11-13 14:57:31 +08:00
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, lldb::DescriptionLevel description_level);
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
class m o d u l e s _ a c c e s s ( o b j e c t ) :
'''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
def _ _ i n i t _ _ ( self , s b t a r g e t ) :
self . s b t a r g e t = s b t a r g e t
def _ _ l e n _ _ ( self ) :
if self . s b t a r g e t :
2012-05-12 04:39:42 +08:00
return int ( self . s b t a r g e t . G e t N u m M o d u l e s ( ) )
2012-02-01 16:09:32 +08:00
return 0
def _ _ g e t i t e m _ _ ( self , key ) :
n u m _ m o d u l e s = self . s b t a r g e t . G e t N u m M o d u l e s ( )
if type ( key ) is int :
if key < n u m _ m o d u l e s :
return self . s b t a r g e t . G e t M o d u l e A t I n d e x ( key )
e l i f type ( key ) is s t r :
if key . find ( '/' ) = = - 1 :
for i d x in r a n g e ( n u m _ m o d u l e s ) :
m o d u l e = self . s b t a r g e t . G e t M o d u l e A t I n d e x ( i d x )
if m o d u l e . file . b a s e n a m e = = key :
return m o d u l e
else :
for i d x in r a n g e ( n u m _ m o d u l e s ) :
m o d u l e = self . s b t a r g e t . G e t M o d u l e A t I n d e x ( i d x )
if m o d u l e . file . f u l l p a t h = = key :
return m o d u l e
# S e e if t h e string is a U U I D
t h e _ u u i d = u u i d . U U I D ( key )
if t h e _ u u i d :
for i d x in r a n g e ( n u m _ m o d u l e s ) :
m o d u l e = self . s b t a r g e t . G e t M o d u l e A t I n d e x ( i d x )
if m o d u l e . u u i d = = t h e _ u u i d :
return m o d u l e
e l i f type ( key ) is u u i d . U U I D :
for i d x in r a n g e ( n u m _ m o d u l e s ) :
m o d u l e = self . s b t a r g e t . G e t M o d u l e A t I n d e x ( i d x )
if m o d u l e . u u i d = = key :
return m o d u l e
e l i f type ( key ) is r e . S R E _ P a t t e r n :
m a t c h i n g _ m o d u l e s = [ ]
for i d x in r a n g e ( n u m _ m o d u l e s ) :
m o d u l e = self . s b t a r g e t . G e t M o d u l e A t I n d e x ( i d x )
r e _ m a t c h = key . search ( m o d u l e . p a t h . f u l l p a t h )
if r e _ m a t c h :
m a t c h i n g _ m o d u l e s . append ( m o d u l e )
return m a t c h i n g _ m o d u l e s
else :
p r i n t "error: unsupported item type: %s" % type ( key )
return None
def g e t _ m o d u l e s _ a c c e s s _ o b j e c t ( self ) :
2012-02-03 11:22:53 +08:00
'''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.'''
2012-02-01 16:09:32 +08:00
return self . m o d u l e s _ a c c e s s ( self )
def g e t _ m o d u l e s _ a r r a y ( self ) :
2012-02-03 11:22:53 +08:00
'''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.'''
2012-02-01 16:09:32 +08:00
m o d u l e s = [ ]
for i d x in r a n g e ( self . G e t N u m M o d u l e s ( ) ) :
m o d u l e s . append ( self . G e t M o d u l e A t I n d e x ( i d x ) )
return m o d u l e s
_ _ s w i g _ g e t m e t h o d s _ _ [ "modules" ] = g e t _ m o d u l e s _ a r r a y
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : m o d u l e s = property ( g e t _ m o d u l e s _ a r r a y , None , d o c = '''A read only property that returns a list() of lldb.SBModule objects contained in this target. This list is a list all modules that the target currently is tracking (the main executable and all dependent shared libraries).''' )
2012-02-01 16:09:32 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "module" ] = g e t _ m o d u l 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 : m o d u l e = property ( g e t _ m o d u l e s _ a c c e s s _ o b j e c t , None , d o c = r '''A read only property that returns an object that implements python operator overloading with the square brackets().\n target.module[<int>] allows array access to any modules.\n target.module[<str>] allows access to modules by basename, full path, or uuid string value.\n target.module[uuid.UUID()] allows module access by UUID.\n target.module[re] allows module access using a regular expression that matches the module full path.''' )
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 _ _ [ "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 this target owns.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "executable" ] = G e t E x e c u t a b l e
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : e x e c u t a b l e = property ( G e t E x e c u t a b l e , None , d o c = '''A read only property that returns an lldb object that represents the main executable module (lldb.SBModule) for this target.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "debugger" ] = G e t D e b u g g e r
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : debugger = property ( G e t D e b u g g e r , None , d o c = '''A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "num_breakpoints" ] = G e t N u m B r e a k p o i n t s
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : n u m _ b r e a k p o i n t s = property ( G e t N u m B r e a k p o i n t s , None , d o c = '''A read only property that returns the number of breakpoints that this target has 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 _ _ [ "num_watchpoints" ] = G e t N u m W a t c h p o i n t s
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : n u m _ w a t c h p o i n t s = property ( G e t N u m W a t c h p o i n t s , None , d o c = '''A read only property that returns the number of watchpoints that this target has 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 _ _ [ "broadcaster" ] = G e t B r o a d c a s t e r
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : 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 target.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "byte_order" ] = G e t B y t e O r d e r
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : b y t e _ o r d e r = property ( G e t B y t e O r d e r , None , d o c = '''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this target.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "addr_size" ] = G e t A d d r e s s B y t e S i z e
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : a d d r _ s i z e = property ( G e t A d d r e s s B y t e S i z e , None , d o c = '''A read only property that returns the size in bytes of an address for this target.''' )
2012-01-29 14:07:39 +08:00
_ _ s w i g _ g e t m e t h o d s _ _ [ "triple" ] = G e t T r i p l e
2012-06-30 06:00:42 +08:00
if _ n e w c l a s s : t r i p l e = property ( G e t T r i p l e , None , d o c = '''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''' )
2012-01-29 14:07:39 +08:00
% }
2011-07-17 05:15:39 +08:00
} ;
} // namespace lldb