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