]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / Utility / RegisterContextFreeBSD_i386.cpp
1 //===-- RegisterContextFreeBSD_i386.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 "RegisterContextFreeBSD_i386.h"
11 #include "RegisterContextPOSIX_x86.h"
12
13 using namespace lldb_private;
14 using namespace lldb;
15
16 // http://svnweb.freebsd.org/base/head/sys/x86/include/reg.h
17 struct GPR {
18   uint32_t fs;
19   uint32_t es;
20   uint32_t ds;
21   uint32_t edi;
22   uint32_t esi;
23   uint32_t ebp;
24   uint32_t isp;
25   uint32_t ebx;
26   uint32_t edx;
27   uint32_t ecx;
28   uint32_t eax;
29   uint32_t trapno;
30   uint32_t err;
31   uint32_t eip;
32   uint32_t cs;
33   uint32_t eflags;
34   uint32_t esp;
35   uint32_t ss;
36   uint32_t gs;
37 };
38
39 struct dbreg {
40   uint32_t dr[8]; /* debug registers */
41                   /* Index 0-3: debug address registers */
42                   /* Index 4-5: reserved */
43                   /* Index 6: debug status */
44                   /* Index 7: debug control */
45 };
46
47 using FPR_i386 = FXSAVE;
48
49 struct UserArea {
50   GPR gpr;
51   FPR_i386 i387;
52 };
53
54 #define DR_SIZE sizeof(uint32_t)
55 #define DR_OFFSET(reg_index) (LLVM_EXTENSION offsetof(dbreg, dr[reg_index]))
56
57 //---------------------------------------------------------------------------
58 // Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.
59 //---------------------------------------------------------------------------
60 #define DECLARE_REGISTER_INFOS_I386_STRUCT
61 #include "RegisterInfos_i386.h"
62 #undef DECLARE_REGISTER_INFOS_I386_STRUCT
63
64 RegisterContextFreeBSD_i386::RegisterContextFreeBSD_i386(
65     const ArchSpec &target_arch)
66     : RegisterInfoInterface(target_arch) {}
67
68 size_t RegisterContextFreeBSD_i386::GetGPRSize() const { return sizeof(GPR); }
69
70 const RegisterInfo *RegisterContextFreeBSD_i386::GetRegisterInfo() const {
71   switch (m_target_arch.GetMachine()) {
72   case llvm::Triple::x86:
73     return g_register_infos_i386;
74   default:
75     assert(false && "Unhandled target architecture.");
76     return NULL;
77   }
78 }
79
80 uint32_t RegisterContextFreeBSD_i386::GetRegisterCount() const {
81   return static_cast<uint32_t>(sizeof(g_register_infos_i386) /
82                                sizeof(g_register_infos_i386[0]));
83 }