2011-07-20 06:41:47 +08:00
//===-- SWIG Interface for SBInstruction ------------------------*- 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-20 06:41:47 +08:00
//
//===----------------------------------------------------------------------===//
# i n c l u d e < s t d i o . h >
// There's a lot to be fixed here, but need to wait for underlying insn implementation
// to be revised & settle down first.
n a m e s p a c e l l d b {
2021-01-16 02:49:51 +08:00
% f e a t u r e ( "docstring" ,
"Represents a (machine language) instruction."
) S B I n s t r u c t i o n ;
2011-07-20 06:41:47 +08:00
class S B I n s t r u c t i o n
{
public :
S B I n s t r u c t i o n ( ) ;
S B I n s t r u c t i o n ( c o n s t S B I n s t r u c t i o n &rhs);
2019-04-19 00:23:33 +08:00
2011-07-20 06:41:47 +08:00
~ S B I n s t r u c t i o n ( ) ;
b o o l
I s V a l i d ( ) ;
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 ;
2012-04-13 08:07:34 +08:00
l l d b : : S B A d d r e s s
2011-07-20 06:41:47 +08:00
G e t A d d r e s s ( ) ;
2019-04-19 00:23:33 +08:00
2011-09-26 15:11:27 +08:00
c o n s t char *
2011-09-27 08:58:45 +08:00
G e t M n e m o n i c ( l l d b : : S B T a r g e t target ) ;
2019-04-19 00:23:33 +08:00
2011-09-26 15:11:27 +08:00
c o n s t char *
2011-09-27 08:58:45 +08:00
G e t O p e r a n d s ( l l d b : : S B T a r g e t target ) ;
2019-04-19 00:23:33 +08:00
2011-09-26 15:11:27 +08:00
c o n s t char *
G e t C o m m e n t ( l l d b : : S B T a r g e t target ) ;
2019-04-19 00:23:33 +08:00
2011-09-26 15:11:27 +08:00
l l d b : : S B D a t a
G e t D a t a ( l l d b : : S B T a r g e t target ) ;
2019-04-19 00:23:33 +08:00
2011-07-20 06:41:47 +08:00
s i z e _ t
G e t B y t e S i z e ( ) ;
b o o l
D o e s B r a n c h ( ) ;
2016-01-27 18:16:30 +08:00
b o o l
H a s D e l a y S l o t ( ) ;
2017-05-04 19:34:42 +08:00
b o o l
C a n S e t B r e a k p o i n t ( ) ;
2011-07-20 06:41:47 +08:00
void
2019-10-15 04:59:57 +08:00
P r i n t ( l l d b : : S B F i l e o u t ) ;
void
P r i n t ( l l d b : : F i l e S P B O R R O W E D ) ;
2011-07-20 06:41:47 +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);
b o o l
E m u l a t e W i t h F r a m e ( l l d b : : S B F r a m e &frame, uint32_t evaluate_options);
b o o l
2012-05-08 09:45:38 +08:00
D u m p E m u l a t i o n ( c o n s t char * t r i p l e ) ; // triple is to specify the architecture, e.g. 'armv6' or 'armv7-apple-ios'
2019-04-19 00:23:33 +08:00
2011-07-20 06:41:47 +08:00
b o o l
T e s t E m u l a t i o n ( l l d b : : S B S t r e a m &output_stream, const char *test_file);
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 I n s t r u 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 _ _ m n e m o n i c _ p r o p e r t y _ _ ( self ) :
return self . G e t M n e m o n i c ( target )
def _ _ o p e r a n d s _ p r o p e r t y _ _ ( self ) :
return self . G e t O p e r a n d s ( target )
def _ _ c o m m e n t _ p r o p e r t y _ _ ( self ) :
return self . G e t C o m m e n t ( target )
def _ _ f i l e _ a d d r _ p r o p e r t y _ _ ( self ) :
return self . G e t A d d r e s s ( ) . G e t F i l e A d d r e s s ( )
def _ _ l o a d _ a d r r _ p r o p e r t y _ _ ( self ) :
return self . G e t C o m m e n t ( target )
2019-07-03 06:18:35 +08:00
m n e m o n i c = property ( _ _ m n e m o n i c _ p r o p e r t y _ _ , None , d o c = '''A read only property that returns the mnemonic for this instruction as a string.''' )
o p e r a n d s = property ( _ _ o p e r a n d s _ p r o p e r t y _ _ , None , d o c = '''A read only property that returns the operands for this instruction as a string.''' )
c o m m e n t = property ( _ _ c o m m e n t _ p r o p e r t y _ _ , None , d o c = '''A read only property that returns the comment for this instruction as a string.''' )
a d d r = property ( G e t A d d r e s s , None , d o c = '''A read only property that returns an lldb object that represents the address (lldb.SBAddress) for this instruction.''' )
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 for this instruction as an integer.''' )
i s _ b r a n c h = property ( D o e s B r a n c h , None , d o c = '''A read only property that returns a boolean value that indicates if this instruction is a branch instruction.''' )
2012-01-29 14:07:39 +08:00
% }
2019-12-09 06:46:48 +08:00
# e n d i f
2019-04-19 00:23:33 +08:00
2012-01-29 14:07:39 +08:00
2011-07-20 06:41:47 +08:00
} ;
} // namespace lldb