1 //===-- SWIG Interface for SBInstruction ------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include <stdio.h>
10 
11 // There's a lot to be fixed here, but need to wait for underlying insn implementation
12 // to be revised & settle down first.
13 
14 namespace lldb {
15 
16 %feature("docstring",
17 "Represents a (machine language) instruction."
18 ) SBInstruction;
19 class SBInstruction
20 {
21 public:
22 
23     SBInstruction ();
24 
25     SBInstruction (const SBInstruction &rhs);
26 
27     ~SBInstruction ();
28 
29     bool
30     IsValid();
31 
32     explicit operator bool() const;
33 
34     lldb::SBAddress
35     GetAddress();
36 
37 
38     const char *
39     GetMnemonic (lldb::SBTarget target);
40 
41     const char *
42     GetOperands (lldb::SBTarget target);
43 
44     const char *
45     GetComment (lldb::SBTarget target);
46 
47     lldb::InstructionControlFlowKind
48     GetControlFlowKind(lldb::SBTarget target);
49 
50     lldb::SBData
51     GetData (lldb::SBTarget target);
52 
53     size_t
54     GetByteSize ();
55 
56     bool
57     DoesBranch ();
58 
59     bool
60     HasDelaySlot ();
61 
62     bool
63     CanSetBreakpoint ();
64 
65     void
66     Print (lldb::SBFile out);
67 
68     void
69     Print (lldb::FileSP BORROWED);
70 
71     bool
72     GetDescription (lldb::SBStream &description);
73 
74     bool
75     EmulateWithFrame (lldb::SBFrame &frame, uint32_t evaluate_options);
76 
77     bool
78     DumpEmulation (const char * triple); // triple is to specify the architecture, e.g. 'armv6' or 'armv7-apple-ios'
79 
80     bool
81     TestEmulation (lldb::SBStream &output_stream, const char *test_file);
82 
83     STRING_EXTENSION(SBInstruction)
84 
85 #ifdef SWIGPYTHON
86     %pythoncode %{
87         def __mnemonic_property__ (self):
88             return self.GetMnemonic (target)
89         def __operands_property__ (self):
90             return self.GetOperands (target)
91         def __comment_property__ (self):
92             return self.GetComment (target)
93         def __file_addr_property__ (self):
94             return self.GetAddress ().GetFileAddress()
95         def __load_adrr_property__ (self):
96             return self.GetComment (target)
97 
98         mnemonic = property(__mnemonic_property__, None, doc='''A read only property that returns the mnemonic for this instruction as a string.''')
99         operands = property(__operands_property__, None, doc='''A read only property that returns the operands for this instruction as a string.''')
100         comment = property(__comment_property__, None, doc='''A read only property that returns the comment for this instruction as a string.''')
101         addr = property(GetAddress, None, doc='''A read only property that returns an lldb object that represents the address (lldb.SBAddress) for this instruction.''')
102         size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes for this instruction as an integer.''')
103         is_branch = property(DoesBranch, None, doc='''A read only property that returns a boolean value that indicates if this instruction is a branch instruction.''')
104     %}
105 #endif
106 
107 
108 };
109 
110 } // namespace lldb
111