1 //===-- EmulationStateARM.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_SOURCE_PLUGINS_INSTRUCTION_ARM_EMULATIONSTATEARM_H
10 #define LLDB_SOURCE_PLUGINS_INSTRUCTION_ARM_EMULATIONSTATEARM_H
11 
12 #include <map>
13 
14 #include "lldb/Core/EmulateInstruction.h"
15 #include "lldb/Core/Opcode.h"
16 
17 class EmulationStateARM {
18 public:
19   EmulationStateARM();
20 
21   virtual ~EmulationStateARM();
22 
23   bool StorePseudoRegisterValue(uint32_t reg_num, uint64_t value);
24 
25   uint64_t ReadPseudoRegisterValue(uint32_t reg_num, bool &success);
26 
27   bool StoreToPseudoAddress(lldb::addr_t p_address, uint32_t value);
28 
29   uint32_t ReadFromPseudoAddress(lldb::addr_t p_address, bool &success);
30 
31   void ClearPseudoRegisters();
32 
33   void ClearPseudoMemory();
34 
35   bool LoadPseudoRegistersFromFrame(lldb_private::StackFrame &frame);
36 
37   bool LoadStateFromDictionary(lldb_private::OptionValueDictionary *test_data);
38 
39   bool CompareState(EmulationStateARM &other_state,
40                     lldb_private::Stream *out_stream);
41 
42   static size_t
43   ReadPseudoMemory(lldb_private::EmulateInstruction *instruction, void *baton,
44                    const lldb_private::EmulateInstruction::Context &context,
45                    lldb::addr_t addr, void *dst, size_t length);
46 
47   static size_t
48   WritePseudoMemory(lldb_private::EmulateInstruction *instruction, void *baton,
49                     const lldb_private::EmulateInstruction::Context &context,
50                     lldb::addr_t addr, const void *dst, size_t length);
51 
52   static bool ReadPseudoRegister(lldb_private::EmulateInstruction *instruction,
53                                  void *baton,
54                                  const lldb_private::RegisterInfo *reg_info,
55                                  lldb_private::RegisterValue &reg_value);
56 
57   static bool
58   WritePseudoRegister(lldb_private::EmulateInstruction *instruction,
59                       void *baton,
60                       const lldb_private::EmulateInstruction::Context &context,
61                       const lldb_private::RegisterInfo *reg_info,
62                       const lldb_private::RegisterValue &reg_value);
63 
64 private:
65   bool LoadRegistersStateFromDictionary(
66       lldb_private::OptionValueDictionary *reg_dict, char kind, int first_reg,
67       int num);
68 
69   uint32_t m_gpr[17] = {0};
70   struct _sd_regs {
71     uint32_t s_regs[32]; // sregs 0 - 31 & dregs 0 - 15
72 
73     uint64_t d_regs[16]; // dregs 16-31
74 
75   } m_vfp_regs;
76 
77   std::map<lldb::addr_t, uint32_t> m_memory; // Eventually will want to change
78                                              // uint32_t to a data buffer heap
79                                              // type.
80 
81   EmulationStateARM(const EmulationStateARM &) = delete;
82   const EmulationStateARM &operator=(const EmulationStateARM &) = delete;
83 };
84 
85 #endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_ARM_EMULATIONSTATEARM_H
86