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 "RegisterContextPOSIX_x86.h" 11 #include "RegisterContextFreeBSD_i386.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 { 19 uint32_t fs; 20 uint32_t es; 21 uint32_t ds; 22 uint32_t edi; 23 uint32_t esi; 24 uint32_t ebp; 25 uint32_t isp; 26 uint32_t ebx; 27 uint32_t edx; 28 uint32_t ecx; 29 uint32_t eax; 30 uint32_t trapno; 31 uint32_t err; 32 uint32_t eip; 33 uint32_t cs; 34 uint32_t eflags; 35 uint32_t esp; 36 uint32_t ss; 37 uint32_t gs; 38 }; 39 40 struct dbreg { 41 uint32_t dr[8]; /* debug registers */ 42 /* Index 0-3: debug address registers */ 43 /* Index 4-5: reserved */ 44 /* Index 6: debug status */ 45 /* Index 7: debug control */ 46 }; 47 48 using FPR_i386 = FXSAVE; 49 50 struct UserArea 51 { 52 GPR gpr; 53 FPR_i386 i387; 54 }; 55 56 #define DR_SIZE sizeof(uint32_t) 57 #define DR_OFFSET(reg_index) \ 58 (LLVM_EXTENSION offsetof(dbreg, dr[reg_index])) 59 60 //--------------------------------------------------------------------------- 61 // Include RegisterInfos_i386 to declare our g_register_infos_i386 structure. 62 //--------------------------------------------------------------------------- 63 #define DECLARE_REGISTER_INFOS_I386_STRUCT 64 #include "RegisterInfos_i386.h" 65 #undef DECLARE_REGISTER_INFOS_I386_STRUCT 66 67 RegisterContextFreeBSD_i386::RegisterContextFreeBSD_i386(const ArchSpec &target_arch) : 68 RegisterInfoInterface(target_arch) 69 { 70 } 71 72 size_t 73 RegisterContextFreeBSD_i386::GetGPRSize() const 74 { 75 return sizeof(GPR); 76 } 77 78 const RegisterInfo * 79 RegisterContextFreeBSD_i386::GetRegisterInfo() const 80 { 81 switch (m_target_arch.GetMachine()) 82 { 83 case llvm::Triple::x86: 84 return g_register_infos_i386; 85 default: 86 assert(false && "Unhandled target architecture."); 87 return NULL; 88 } 89 } 90 91 uint32_t 92 RegisterContextFreeBSD_i386::GetRegisterCount () const 93 { 94 return static_cast<uint32_t> (sizeof (g_register_infos_i386) / sizeof (g_register_infos_i386 [0])); 95 } 96