1 //===-- RegisterContextFreeBSD_arm.cpp -------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===---------------------------------------------------------------------===//
14 #include "llvm/Support/Compiler.h"
15 #include "lldb/lldb-defines.h"
17 #include "RegisterContextFreeBSD_arm.h"
20 using namespace lldb_private;
22 // Based on RegisterContextLinux_arm.cpp and
23 // http://svnweb.freebsd.org/base/head/sys/arm/include/reg.h
24 #define GPR_OFFSET(idx) ((idx) * 4)
25 #define FPU_OFFSET(idx) ((idx) * 4 + sizeof (RegisterContextFreeBSD_arm::GPR))
26 #define FPSCR_OFFSET (LLVM_EXTENSION offsetof (RegisterContextFreeBSD_arm::FPU, fpscr) + sizeof (RegisterContextFreeBSD_arm::GPR))
27 #define EXC_OFFSET(idx) ((idx) * 4 + sizeof (RegisterContextFreeBSD_arm::GPR) + sizeof (RegisterContextFreeBSD_arm::FPU))
28 #define DBG_OFFSET(reg) ((LLVM_EXTENSION offsetof (RegisterContextFreeBSD_arm::DBG, reg) + sizeof (RegisterContextFreeBSD_arm::GPR) + sizeof (RegisterContextFreeBSD_arm::FPU) + sizeof (RegisterContextFreeBSD_arm::EXC)))
30 #define DEFINE_DBG(reg, i) #reg, NULL, sizeof(((RegisterContextFreeBSD_arm::DBG *)NULL)->reg[i]), DBG_OFFSET(reg[i]), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, dbg_##reg##i }, NULL, NULL
31 #define REG_CONTEXT_SIZE (sizeof (RegisterContextFreeBSD_arm::GPR) + sizeof (RegisterContextFreeBSD_arm::FPU) + sizeof (RegisterContextFreeBSD_arm::EXC))
33 //-----------------------------------------------------------------------------
34 // Include RegisterInfos_arm to declare our g_register_infos_arm structure.
35 //-----------------------------------------------------------------------------
36 #define DECLARE_REGISTER_INFOS_ARM_STRUCT
37 #include "RegisterInfos_arm.h"
38 #undef DECLARE_REGISTER_INFOS_ARM_STRUCT
40 static const lldb_private::RegisterInfo *
41 GetRegisterInfoPtr (const lldb_private::ArchSpec &target_arch)
43 switch (target_arch.GetMachine())
45 case llvm::Triple::arm:
46 return g_register_infos_arm;
48 assert(false && "Unhandled target architecture.");
54 GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch)
56 switch (target_arch.GetMachine())
58 case llvm::Triple::arm:
59 return static_cast<uint32_t>(sizeof(g_register_infos_arm) / sizeof(g_register_infos_arm[0]));
61 assert(false && "Unhandled target architecture.");
66 RegisterContextFreeBSD_arm::RegisterContextFreeBSD_arm(const lldb_private::ArchSpec &target_arch) :
67 lldb_private::RegisterInfoInterface(target_arch),
68 m_register_info_p(GetRegisterInfoPtr(target_arch)),
69 m_register_info_count(GetRegisterInfoCount(target_arch))
74 RegisterContextFreeBSD_arm::GetGPRSize() const
76 return sizeof(struct RegisterContextFreeBSD_arm::GPR);
79 const lldb_private::RegisterInfo *
80 RegisterContextFreeBSD_arm::GetRegisterInfo() const
82 return m_register_info_p;
86 RegisterContextFreeBSD_arm::GetRegisterCount() const
88 return m_register_info_count;