Greg Clayton | 64c8443 | 2011-01-21 22:02:52 +0000 | [diff] [blame] | 1 | //===-- lldb_EmulateInstructionARM.h ------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef lldb_EmulateInstructionARM_h_ |
| 11 | #define lldb_EmulateInstructionARM_h_ |
| 12 | |
Greg Clayton | 8482ded | 2011-02-01 00:04:43 +0000 | [diff] [blame] | 13 | #include "lldb/Core/EmulateInstruction.h" |
Greg Clayton | 31e2a38 | 2011-01-30 20:03:56 +0000 | [diff] [blame] | 14 | #include "lldb/Core/Error.h" |
| 15 | |
Greg Clayton | 64c8443 | 2011-01-21 22:02:52 +0000 | [diff] [blame] | 16 | namespace lldb_private { |
| 17 | |
| 18 | class EmulateInstructionARM : public EmulateInstruction |
| 19 | { |
| 20 | public: |
Greg Clayton | 2b8e8b0 | 2011-02-01 00:49:32 +0000 | [diff] [blame^] | 21 | typedef enum |
| 22 | { |
| 23 | eEncodingA1, |
| 24 | eEncodingA2, |
| 25 | eEncodingA3, |
| 26 | eEncodingA4, |
| 27 | eEncodingA5, |
| 28 | eEncodingT1, |
| 29 | eEncodingT2, |
| 30 | eEncodingT3, |
| 31 | eEncodingT4, |
| 32 | eEncodingT5, |
| 33 | } ARMEncoding; |
| 34 | |
| 35 | |
| 36 | static void |
| 37 | Initialize (); |
| 38 | |
| 39 | static void |
| 40 | Terminate (); |
Greg Clayton | 31e2a38 | 2011-01-30 20:03:56 +0000 | [diff] [blame] | 41 | |
| 42 | virtual const char * |
| 43 | GetPluginName() |
| 44 | { |
| 45 | return "EmulateInstructionARM"; |
| 46 | } |
| 47 | |
| 48 | virtual const char * |
| 49 | GetShortPluginName() |
| 50 | { |
| 51 | return "lldb.emulate-instruction.arm"; |
| 52 | } |
| 53 | |
| 54 | virtual uint32_t |
| 55 | GetPluginVersion() |
| 56 | { |
| 57 | return 1; |
| 58 | } |
| 59 | |
| 60 | virtual void |
| 61 | GetPluginCommandHelp (const char *command, Stream *strm) |
| 62 | { |
| 63 | } |
| 64 | |
| 65 | virtual lldb_private::Error |
| 66 | ExecutePluginCommand (Args &command, Stream *strm) |
| 67 | { |
| 68 | Error error; |
| 69 | error.SetErrorString("no plug-in commands are supported"); |
| 70 | return error; |
| 71 | } |
| 72 | |
| 73 | virtual Log * |
| 74 | EnablePluginLogging (Stream *strm, Args &command) |
| 75 | { |
| 76 | return NULL; |
| 77 | } |
| 78 | |
Greg Clayton | 64c8443 | 2011-01-21 22:02:52 +0000 | [diff] [blame] | 79 | enum Mode |
| 80 | { |
| 81 | eModeInvalid, |
| 82 | eModeARM, |
| 83 | eModeThumb |
| 84 | }; |
| 85 | |
| 86 | EmulateInstructionARM (void *baton, |
| 87 | ReadMemory read_mem_callback, |
| 88 | WriteMemory write_mem_callback, |
| 89 | ReadRegister read_reg_callback, |
| 90 | WriteRegister write_reg_callback) : |
| 91 | EmulateInstruction (lldb::eByteOrderLittle, // Byte order for ARM |
| 92 | 4, // Address size in byte |
| 93 | baton, |
| 94 | read_mem_callback, |
| 95 | write_mem_callback, |
| 96 | read_reg_callback, |
| 97 | write_reg_callback), |
Greg Clayton | 31e2a38 | 2011-01-30 20:03:56 +0000 | [diff] [blame] | 98 | m_arm_isa (0), |
| 99 | m_inst_mode (eModeInvalid), |
| 100 | m_inst_cpsr (0) |
Greg Clayton | 64c8443 | 2011-01-21 22:02:52 +0000 | [diff] [blame] | 101 | { |
| 102 | } |
Greg Clayton | 31e2a38 | 2011-01-30 20:03:56 +0000 | [diff] [blame] | 103 | |
| 104 | |
| 105 | virtual bool |
| 106 | SetTargetTriple (const ConstString &triple); |
Greg Clayton | 64c8443 | 2011-01-21 22:02:52 +0000 | [diff] [blame] | 107 | |
| 108 | virtual bool |
| 109 | ReadInstruction (); |
| 110 | |
| 111 | virtual bool |
| 112 | EvaluateInstruction (); |
| 113 | |
| 114 | bool |
| 115 | ConditionPassed (); |
| 116 | |
| 117 | uint32_t |
| 118 | CurrentCond (); |
| 119 | |
| 120 | protected: |
Greg Clayton | 2b8e8b0 | 2011-02-01 00:49:32 +0000 | [diff] [blame^] | 121 | |
| 122 | // Typedef for the callback function used during the emulation. |
| 123 | // Pass along (ARMEncoding)encoding as the callback data. |
| 124 | typedef enum |
| 125 | { |
| 126 | eSize16, |
| 127 | eSize32 |
| 128 | } ARMInstrSize; |
| 129 | |
| 130 | typedef struct |
| 131 | { |
| 132 | uint32_t mask; |
| 133 | uint32_t value; |
| 134 | uint32_t variants; |
| 135 | EmulateInstructionARM::ARMEncoding encoding; |
| 136 | ARMInstrSize size; |
| 137 | bool (EmulateInstructionARM::*callback) (EmulateInstructionARM::ARMEncoding encoding); |
| 138 | const char *name; |
| 139 | } ARMOpcode; |
| 140 | |
| 141 | |
| 142 | static ARMOpcode* |
| 143 | GetARMOpcodeForInstruction (const uint32_t opcode); |
| 144 | |
| 145 | static ARMOpcode* |
| 146 | GetThumbOpcodeForInstruction (const uint32_t opcode); |
| 147 | |
| 148 | bool |
| 149 | EmulatePush (ARMEncoding encoding); |
| 150 | |
| 151 | bool |
| 152 | EmulatePop (ARMEncoding encoding); |
| 153 | |
| 154 | bool |
| 155 | EmulateAddRdSPImmediate (ARMEncoding encoding); |
| 156 | |
| 157 | bool |
| 158 | EmulateMovRdSP (ARMEncoding encoding); |
| 159 | |
| 160 | bool |
| 161 | EmulateMovLowHigh (ARMEncoding encoding); |
| 162 | |
| 163 | bool |
| 164 | EmulateLDRRdPCRelative (ARMEncoding encoding); |
| 165 | |
| 166 | bool |
| 167 | EmulateAddSPImmediate (ARMEncoding encoding); |
| 168 | |
| 169 | bool |
| 170 | EmulateAddSPRm (ARMEncoding encoding); |
| 171 | |
| 172 | bool |
| 173 | EmulateSubR7IPImmediate (ARMEncoding encoding); |
| 174 | |
| 175 | bool |
| 176 | EmulateSubIPSPImmediate (ARMEncoding encoding); |
| 177 | |
| 178 | bool |
| 179 | EmulateSubSPImmdiate (ARMEncoding encoding); |
| 180 | |
| 181 | bool |
| 182 | EmulateSTRRtSP (ARMEncoding encoding); |
| 183 | |
| 184 | bool |
| 185 | EmulateVPUSH (ARMEncoding encoding); |
| 186 | |
Greg Clayton | 31e2a38 | 2011-01-30 20:03:56 +0000 | [diff] [blame] | 187 | uint32_t m_arm_isa; |
Greg Clayton | 64c8443 | 2011-01-21 22:02:52 +0000 | [diff] [blame] | 188 | Mode m_inst_mode; |
| 189 | uint32_t m_inst_cpsr; |
Greg Clayton | 64c8443 | 2011-01-21 22:02:52 +0000 | [diff] [blame] | 190 | }; |
| 191 | |
| 192 | } // namespace lldb_private |
| 193 | |
| 194 | #endif // lldb_EmulateInstructionARM_h_ |