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