1 //===-- SBInstruction.h -----------------------------------------*- 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 #ifndef LLDB_API_SBINSTRUCTION_H
10 #define LLDB_API_SBINSTRUCTION_H
11 
12 #include "lldb/API/SBData.h"
13 #include "lldb/API/SBDefines.h"
14 
15 #include <cstdio>
16 
17 // There's a lot to be fixed here, but need to wait for underlying insn
18 // implementation to be revised & settle down first.
19 
20 class InstructionImpl;
21 
22 namespace lldb {
23 
24 class LLDB_API SBInstruction {
25 public:
26   SBInstruction();
27 
28   SBInstruction(const SBInstruction &rhs);
29 
30   const SBInstruction &operator=(const SBInstruction &rhs);
31 
32   ~SBInstruction();
33 
34   explicit operator bool() const;
35 
36   bool IsValid();
37 
38   SBAddress GetAddress();
39 
40   const char *GetMnemonic(lldb::SBTarget target);
41 
42   const char *GetOperands(lldb::SBTarget target);
43 
44   const char *GetComment(lldb::SBTarget target);
45 
46   lldb::InstructionControlFlowKind GetControlFlowKind(lldb::SBTarget target);
47 
48   lldb::SBData GetData(lldb::SBTarget target);
49 
50   size_t GetByteSize();
51 
52   bool DoesBranch();
53 
54   bool HasDelaySlot();
55 
56   bool CanSetBreakpoint();
57 
58   void Print(FILE *out);
59 
60   void Print(SBFile out);
61 
62   void Print(FileSP out);
63 
64   bool GetDescription(lldb::SBStream &description);
65 
66   bool EmulateWithFrame(lldb::SBFrame &frame, uint32_t evaluate_options);
67 
68   bool DumpEmulation(const char *triple); // triple is to specify the
69                                           // architecture, e.g. 'armv6' or
70                                           // 'armv7-apple-ios'
71 
72   bool TestEmulation(lldb::SBStream &output_stream, const char *test_file);
73 
74 protected:
75   friend class SBInstructionList;
76 
77   SBInstruction(const lldb::DisassemblerSP &disasm_sp,
78                 const lldb::InstructionSP &inst_sp);
79 
80   void SetOpaque(const lldb::DisassemblerSP &disasm_sp,
81                  const lldb::InstructionSP &inst_sp);
82 
83   lldb::InstructionSP GetOpaque();
84 
85 private:
86   std::shared_ptr<InstructionImpl> m_opaque_sp;
87 };
88 
89 } // namespace lldb
90 
91 #endif // LLDB_API_SBINSTRUCTION_H
92