2011-09-24 09:32:22 +08:00
//===-- SWIG Interface for SBSection ----------------------------*- 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-09-24 09:32:22 +08:00
//
//===----------------------------------------------------------------------===//
n a m e s p a c e l l d b {
% f e a t u r e ( "docstring" ,
2011-09-24 12:51:43 +08:00
" R e p r e s e n t s a n e x e c u t a b l e image section .
S B S e c t i o n s u p p o r t s i t e r a t i o n through i t s s u b s e c t i o n , r e p r e s e n t e d as S B S e c t i o n
2021-01-15 21:43:26 +08:00
as w e l l . For e x a m p l e , : :
2011-10-04 07:06:33 +08:00
for s e c in e x e _ m o d u l e :
if s e c . G e t N a m e ( ) = = '__TEXT' :
p r i n t s e c
break
p r i n t I N D E N T + 'Number of subsections: %d' % s e c . G e t N u m S u b S e c t i o n s ( )
for s u b s e c in s e c :
p r i n t I N D E N T + r e p r ( s u b s e c )
2021-01-15 21:43:26 +08:00
p r o d u c e s : : :
2011-10-04 07:06:33 +08:00
2021-01-15 21:43:26 +08:00
[ 0x0000000100000000 - 0x0000000100002000 ) a . o u t . _ _ T E X T
N u m b e r of s u b s e c t i o n s : 6
[ 0x0000000100001780 - 0x0000000100001d5c ) a . o u t . _ _ T E X T . _ _ t e x t
[ 0x0000000100001d5c - 0x0000000100001da4 ) a . o u t . _ _ T E X T . _ _ s t u b s
[ 0x0000000100001da4 - 0x0000000100001e2c ) a . o u t . _ _ T E X T . _ _ s t u b _ h e l p e r
[ 0x0000000100001e2c - 0x0000000100001f10 ) a . o u t . _ _ T E X T . _ _ c s t r i n g
[ 0x0000000100001f10 - 0x0000000100001f68 ) a . o u t . _ _ T E X T . _ _ u n w i n d _ i n f o
[ 0x0000000100001f68 - 0x0000000100001ff8 ) a . o u t . _ _ T E X T . _ _ e h _ f r a m e
2011-10-04 07:06:33 +08:00
2021-01-15 21:43:26 +08:00
S e e a l s o : p y : class : ` S B M o d u l e ` . "
2011-09-24 09:32:22 +08:00
) S B S e c t i o n ;
class S B S e c t i o n
{
public :
S B S e c t i o n ( ) ;
S B S e c t i o n ( c o n s t l l d b : : S B S e c t i o n &rhs);
~ S B S e 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-09-24 09:37:21 +08:00
c o n s t char *
G e t N a m e ( ) ;
2013-06-14 05:23:23 +08:00
l l d b : : S B S e c t i o n
G e t P a r e n t ( ) ;
2011-09-24 09:32:22 +08:00
l l d b : : S B S e c t i o n
F i n d S u b S e c t i o n ( c o n s t char * s e c t _ n a m e ) ;
s i z e _ t
G e t N u m S u b S e c t i o n s ( ) ;
l l d b : : S B S e c t i o n
G e t S u b S e c t i o n A t I n d e x ( s i z e _ t i d x ) ;
l l d b : : a d d r _ t
G e t F i l e A d d r e s s ( ) ;
2012-06-28 06:22:28 +08:00
l l d b : : a d d r _ t
G e t L o a d A d d r e s s ( l l d b : : S B T a r g e t &target);
2019-04-19 00:23:33 +08:00
2011-09-24 09:32:22 +08:00
l l d b : : a d d r _ t
G e t B y t e S i z e ( ) ;
u i n t 64 _ t
G e t F i l e O f f s e t ( ) ;
u i n t 64 _ t
G e t F i l e B y t e S i z e ( ) ;
2019-04-19 00:23:33 +08:00
2011-09-24 13:04:40 +08:00
l l d b : : S B D a t a
G e t S e c t i o n D a t a ( ) ;
2011-09-24 09:32:22 +08:00
l l d b : : S B D a t a
G e t S e c t i o n D a t a ( u i n t 64 _ t o f f s e t ,
u i n t 64 _ t size ) ;
S e c t i o n T y p e
G e t S e c t i o n T y p e ( ) ;
2016-09-08 20:22:56 +08:00
u i n t 32 _ t
G e t P e r m i s s i o n s ( ) c o n s t ;
2014-10-22 15:22:56 +08:00
% f e a t u r e ( "docstring" , "
2019-04-19 00:23:33 +08:00
Return t h e size of a target ' s b y t e r e p r e s e n t e d by t h i s section
in n u m b e r s of h o s t b y t e s . N o t e t h a t c e r t a i n a r c h i t e c t u r e s h a v e
v a r y i n g minimum a d d r e s s a b l e u n i t ( i . e . b y t e ) size for t h e i r
CODE or D A T A b u s e s .
@ return
T h e n u m b e r of h o s t ( 8 - b i t ) b y t e s n e e d e d to h o l d a target b y t e " ) G e t T a r g e t B y t e S i z e ;
2014-10-22 15:22:56 +08:00
u i n t 32 _ t
G e t T a r g e t B y t e S i z e ( ) ;
2011-09-24 09:32:22 +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 S e c t i o n &rhs);
b o o l
o p e r a t o r ! = ( c o n s t l l d b : : S B S e c t i o n &rhs);
2019-04-19 00:23:33 +08:00
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 S e 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 % {
2019-04-03 19:48:38 +08:00
def _ _ i t e r _ _ ( self ) :
'''Iterate over all subsections in a lldb.SBSection object.'''
return l l d b _ i t e r ( self , 'GetNumSubSections', 'GetSubSectionAtIndex' )
def _ _ l e n _ _ ( self ) :
'''Return the number of subsections in a lldb.SBSection object.'''
return self . G e t N u m S u b S e c t i o n s ( )
2012-02-04 10:58:17 +08:00
def g e t _ a d d r ( self ) :
return S B A d d r e s s ( self , 0 )
2019-07-03 06:18:35 +08:00
name = property ( G e t N a m e , None , d o c = '''A read only property that returns the name of this section as a string.''' )
a d d r = property ( g e t _ a d d r , None , d o c = '''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this section.''' )
f i l e _ a d d r = property ( G e t F i l e A d d r e s s , None , d o c = ''' A r e a d o n l y property t h a t returns a n integer t h a t r e p r e s e n t s t h e s t a r t i n g "file" a d d r e s s for t h i s section , or t h e a d d r e s s of t h e section in t h e o b j e c t file in w h i c h i t is defined . ''' )
size = property ( G e t B y t e S i z e , None , d o c = '''A read only property that returns the size in bytes of this section as an integer.''' )
f i l e _ o f f s e t = property ( G e t F i l e O f f s e t , None , d o c = '''A read only property that returns the file offset in bytes of this section as an integer.''' )
f i l e _ s i z e = property ( G e t F i l e B y t e S i z e , None , d o c = '''A read only property that returns the file size in bytes of this section as an integer.''' )
d a t a = property ( G e t S e c t i o n D a t a , None , d o c = '''A read only property that returns an lldb object that represents the bytes for this section (lldb.SBData) for this section.''' )
type = property ( G e t S e c t i o n T y p e , None , d o c = ''' A r e a d o n l y property t h a t returns a n l l d b e n u m e r a t i o n value ( s e e e n u m e r a t i o n s t h a t start with "lldb.eSectionType" ) t h a t r e p r e s e n t s t h e type of t h i s section ( code , d a t a , e t c . ) . ''' )
t a r g e t _ b y t e _ s i z e = property ( G e t T a r g e t B y t e S i z e , None , d o c = '''A read only property that returns the size of a target byte represented by this section as a number of host bytes.''' )
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-09-24 09:32:22 +08:00
private :
2013-04-19 06:45:39 +08:00
s t d : : u n i q u e _ p t r < l l d b _ p r i v a t e : : S e c t i o n I m p l > m _ o p a q u e _ a p ;
2011-09-24 09:32:22 +08:00
} ;
} // namespace lldb