1190207Srpaulo//===-- RegisterContextFreeBSD_i386.cpp -----------------------------------===// 2162017Ssam// 3162017Ssam// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4162017Ssam// See https://llvm.org/LICENSE.txt for license information. 5162017Ssam// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6162017Ssam// 7162017Ssam//===---------------------------------------------------------------------===// 8162017Ssam 9162017Ssam#include "RegisterContextFreeBSD_i386.h" 10162017Ssam#include "RegisterContextPOSIX_x86.h" 11162017Ssam 12162017Ssamusing namespace lldb_private; 13162017Ssamusing namespace lldb; 14162017Ssam 15162017Ssam// http://svnweb.freebsd.org/base/head/sys/x86/include/reg.h 16162017Ssamstruct GPR { 17162017Ssam uint32_t fs; 18162017Ssam uint32_t es; 19162017Ssam uint32_t ds; 20162017Ssam uint32_t edi; 21162017Ssam uint32_t esi; 22162017Ssam uint32_t ebp; 23162017Ssam uint32_t isp; 24162017Ssam uint32_t ebx; 25162017Ssam uint32_t edx; 26162017Ssam uint32_t ecx; 27162017Ssam uint32_t eax; 28162017Ssam uint32_t trapno; 29162017Ssam uint32_t err; 30162017Ssam uint32_t eip; 31162017Ssam uint32_t cs; 32162017Ssam uint32_t eflags; 33162017Ssam uint32_t esp; 34162017Ssam uint32_t ss; 35162017Ssam uint32_t gs; 36162017Ssam}; 37162017Ssam 38162017Ssamstruct DBG { 39190207Srpaulo uint32_t dr[8]; /* debug registers */ 40190207Srpaulo /* Index 0-3: debug address registers */ 41162017Ssam /* Index 4-5: reserved */ 42162017Ssam /* Index 6: debug status */ 43162017Ssam /* Index 7: debug control */ 44162017Ssam}; 45162017Ssam 46162017Ssamusing FPR_i386 = FXSAVE; 47162017Ssam 48162017Ssamstruct UserArea { 49162017Ssam GPR gpr; 50162017Ssam FPR_i386 i387; 51162017Ssam DBG dbg; 52162017Ssam}; 53162017Ssam 54162017Ssam#define DR_SIZE sizeof(uint32_t) 55162017Ssam#define DR_OFFSET(reg_index) \ 56162017Ssam (LLVM_EXTENSION offsetof(UserArea, dbg) + \ 57162017Ssam LLVM_EXTENSION offsetof(DBG, dr[reg_index])) 58162017Ssam 59162017Ssam// Include RegisterInfos_i386 to declare our g_register_infos_i386 structure. 60162017Ssam#define DECLARE_REGISTER_INFOS_I386_STRUCT 61162017Ssam#include "RegisterInfos_i386.h" 62162017Ssam#undef DECLARE_REGISTER_INFOS_I386_STRUCT 63162017Ssam 64162017SsamRegisterContextFreeBSD_i386::RegisterContextFreeBSD_i386( 65162017Ssam const ArchSpec &target_arch) 66162017Ssam : RegisterInfoInterface(target_arch) {} 67162017Ssam 68162017Ssamsize_t RegisterContextFreeBSD_i386::GetGPRSize() const { return sizeof(GPR); } 69162017Ssam 70162017Ssamconst RegisterInfo *RegisterContextFreeBSD_i386::GetRegisterInfo() const { 71162017Ssam switch (GetTargetArchitecture().GetMachine()) { 72162017Ssam case llvm::Triple::x86: 73162017Ssam return g_register_infos_i386; 74162017Ssam default: 75162017Ssam assert(false && "Unhandled target architecture."); 76162017Ssam return nullptr; 77162017Ssam } 78162017Ssam} 79162017Ssam 80162017Ssamuint32_t RegisterContextFreeBSD_i386::GetRegisterCount() const { 81162017Ssam return static_cast<uint32_t>(sizeof(g_register_infos_i386) / 82162017Ssam sizeof(g_register_infos_i386[0])); 83162017Ssam} 84162017Ssam