2011-07-19 06:15:37 +08:00
//===-- SWIG Interface for SBFunction ---------------------------*- 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 06:15:37 +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 a g e n e r i c function , w h i c h c a n b e i n l i n e d or not .
2021-01-15 21:43:26 +08:00
For e x a m p l e ( from t e s t / l l d b u t i l . p y , b u t s l i g h t l y modified for d o c p u r p o s e ) , : :
2011-07-19 06:15:37 +08:00
. . .
frame = t h r e a d . G e t F r a m e A t I n d e x ( i )
a d d r = frame . G e t P C A d d r e s s ( )
l o a d _ a d d r = a d d r . G e t L o a d A d d r e s s ( target )
function = frame . G e t F u n c t i o n ( )
m o d _ n a m e = frame . G e t M o d u l e ( ) . G e t F i l e S p e c ( ) . G e t F i l e n a m e ( )
if not function :
# No debug info for 'function' .
s y m b o l = frame . G e t S y m b o l ( )
f i l e _ a d d r = a d d r . G e t F i l e A d d r e s s ( )
s t a r t _ a d d r = s y m b o l . G e t S t a r t A d d r e s s ( ) . G e t F i l e A d d r e s s ( )
s y m b o l _ n a m e = s y m b o l . G e t N a m e ( )
s y m b o l _ o f f s e t = f i l e _ a d d r - s t a r t _ a d d r
p r i n t > > output , ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}' . format (
n u m = i , a d d r = l o a d _ a d d r , mod = m o d _ n a m e , s y m b o l = s y m b o l _ n a m e , o f f s e t = s y m b o l _ o f f s e t )
else :
# Debug info is available for 'function' .
f u n c _ n a m e = frame . G e t F u n c t i o n N a m e ( )
f i l e _ n a m e = frame . G e t L i n e E n t r y ( ) . G e t F i l e S p e c ( ) . G e t F i l e n a m e ( )
l i n e _ n u m = frame . G e t L i n e E n t r y ( ) . G e t L i n e ( )
p r i n t > > output , ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}' . format (
n u m = i , a d d r = l o a d _ a d d r , mod = m o d _ n a m e ,
f u n c = '%s [inlined]' % f u n c _ n a m e ] if frame . I s I n l i n e d ( ) else f u n c _ n a m e ,
file = f i l e _ n a m e , line = l i n e _ n u m , a r g s = g e t _ a r g s _ a s _ s t r i n g ( frame , s h o w F u n c N a m e = False ) )
2019-04-19 00:23:33 +08:00
. . . " ) S B F u n c t i o n ;
2011-07-19 06:15:37 +08:00
class S B F u n c t i o n
{
public :
S B F u n c t i o n ( ) ;
S B F u n c t i o n ( c o n s t l l d b : : S B F u n c t i o n &rhs);
~ S B F u n c t i o n ( ) ;
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 06:15:37 +08:00
c o n s t char *
G e t N a m e ( ) c o n s t ;
2019-04-19 00:23:33 +08:00
2015-07-07 02:28:46 +08:00
c o n s t char *
G e t D i s p l a y N a m e ( ) c o n s t ;
2011-07-19 06:15:37 +08:00
c o n s t char *
G e t M a n g l e d N a m e ( ) c o n s t ;
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 T a r g e t target ) ;
2013-03-02 08:26:47 +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 T a r g e t target , c o n s t char * f l a v o r ) ;
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 A d d r e s s
2011-07-19 06:15:37 +08:00
G e t S t a r t A d d r e s 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 A d d r e s s
2011-07-19 06:15:37 +08:00
G e t E n d A d d r e s s ( ) ;
2015-11-11 01:47:04 +08:00
c o n s t char *
G e t A r g u m e n t N a m e ( u i n t 32 _ t a r g _ i d x ) ;
2011-07-19 06:15:37 +08:00
u i n t 32 _ t
G e t P r o l o g u e B y t e S i z e ( ) ;
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 T y p e
G e t T y p e ( ) ;
l l d b : : S B B l o c k
G e t B l o c k ( ) ;
2019-04-19 00:23:33 +08:00
2014-11-18 07:06:20 +08:00
l l d b : : L a n g u a g e T y p e
G e t L a n g u a g e ( ) ;
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
2015-07-29 08:42:47 +08:00
% f e a t u r e ( "docstring" , "
Returns true if t h e function w a s c o m p i l e d with o p t i m i z a t i o n .
O p t i m i z a t i o n , in t h i s case , is m e a n t to i n d i c a t e t h a t t h e debugger
e x p e r i e n c e m a y b e c o n f u s i n g for t h e user - - v a r i a b l e s o p t i m i z e d a w a y ,
2019-04-19 00:23:33 +08:00
s t e p p i n g j u m p i n g between source l i n e s - - and t h e d r i v e r m a y w a n t to
2015-07-29 08:42:47 +08:00
p r o v i d e some g u i d a n c e to t h e user a b o u t t h i s .
Returns false if u n o p t i m i z e d , or u n k n o w n . " ) G e t I s O p t i m i z e d ;
b o o l
G e t I s O p t i m i z e d ( ) ;
2011-07-19 06:15:37 +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);
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 F u n c t i o n &rhs) 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 F u n c t i o n &rhs) const;
2019-04-19 00:23:33 +08:00
2020-01-09 08:13:03 +08:00
S T R I N G _ E X T E N S I O N ( S B F u n c t i o n )
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 n s t r u c t i o n s _ f r o m _ c u r r e n t _ t a r g e t ( self ) :
return self . G e t I n s t r u c t i o n s ( target )
2019-07-03 06:18:35 +08:00
a d d r = property ( G e t S t a r t A d d r e s s , None , d o c = '''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this function.''' )
e n d _ a d d r = property ( G e t E n d A d d r e s s , None , d o c = '''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this function.''' )
b l o c k = property ( G e t B l o c k , None , d o c = '''A read only property that returns an lldb object that represents the top level lexical block (lldb.SBBlock) for this function.''' )
i n s t r u c t i o n s = property ( g e t _ i n s t r u c t i o n s _ f r o m _ c u r r e n t _ t a r g e t , None , d o c = '''A read only property that returns an lldb object that represents the instructions (lldb.SBInstructionList) for this function.''' )
m a n g l e d = property ( G e t M a n g l e d N a m e , None , d o c = '''A read only property that returns the mangled (linkage) name for this function as a string.''' )
name = property ( G e t N a m e , None , d o c = '''A read only property that returns the name for this function as a string.''' )
p r o l o g u e _ s i z e = property ( G e t P r o l o g u e B y t e S i z e , None , d o c = '''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''' )
type = property ( G e t T y p e , None , d o c = '''A read only property that returns an lldb object that represents the return type (lldb.SBType) for this function.''' )
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 06:15:37 +08:00
} ;
} // namespace lldb