]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.cpp
Merge ^/head r294169 through r294598.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / Utility / RegisterContextFreeBSD_arm.cpp
1 //===-- RegisterContextFreeBSD_arm.cpp -------------------------*- 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 #include <stddef.h>
11 #include <vector>
12 #include <cassert>
13
14 #include "llvm/Support/Compiler.h"
15 #include "lldb/lldb-defines.h"
16
17 #include "RegisterContextFreeBSD_arm.h"
18
19 using namespace lldb;
20 using namespace lldb_private;
21
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)))
29
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))
32
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
39
40 static const lldb_private::RegisterInfo *
41 GetRegisterInfoPtr (const lldb_private::ArchSpec &target_arch)
42 {
43     switch (target_arch.GetMachine())
44     {
45         case llvm::Triple::arm:
46             return g_register_infos_arm;
47         default:
48             assert(false && "Unhandled target architecture.");
49             return NULL;
50     }
51 }
52
53 static uint32_t
54 GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch)
55 {
56     switch (target_arch.GetMachine())
57     {
58         case llvm::Triple::arm:
59             return static_cast<uint32_t>(sizeof(g_register_infos_arm) / sizeof(g_register_infos_arm[0]));
60         default:
61             assert(false && "Unhandled target architecture.");
62             return 0;
63     }
64 }
65
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))
70 {
71 }
72
73 size_t
74 RegisterContextFreeBSD_arm::GetGPRSize() const
75 {
76     return sizeof(struct RegisterContextFreeBSD_arm::GPR);
77 }
78
79 const lldb_private::RegisterInfo *
80 RegisterContextFreeBSD_arm::GetRegisterInfo() const
81 {
82     return m_register_info_p;
83 }
84
85 uint32_t
86 RegisterContextFreeBSD_arm::GetRegisterCount() const
87 {
88     return m_register_info_count;
89 }