Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
96380 views
//===-- RegisterContextFreeBSD_i386.cpp -----------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===---------------------------------------------------------------------===//78#include "RegisterContextFreeBSD_i386.h"9#include "RegisterContextPOSIX_x86.h"1011using namespace lldb_private;12using namespace lldb;1314// http://svnweb.freebsd.org/base/head/sys/x86/include/reg.h15struct GPR {16uint32_t fs;17uint32_t es;18uint32_t ds;19uint32_t edi;20uint32_t esi;21uint32_t ebp;22uint32_t isp;23uint32_t ebx;24uint32_t edx;25uint32_t ecx;26uint32_t eax;27uint32_t trapno;28uint32_t err;29uint32_t eip;30uint32_t cs;31uint32_t eflags;32uint32_t esp;33uint32_t ss;34uint32_t gs;35};3637struct DBG {38uint32_t dr[8]; /* debug registers */39/* Index 0-3: debug address registers */40/* Index 4-5: reserved */41/* Index 6: debug status */42/* Index 7: debug control */43};4445using FPR_i386 = FXSAVE;4647struct UserArea {48GPR gpr;49FPR_i386 i387;50DBG dbg;51};5253#define DR_SIZE sizeof(uint32_t)54#define DR_OFFSET(reg_index) \55(LLVM_EXTENSION offsetof(UserArea, dbg) + \56LLVM_EXTENSION offsetof(DBG, dr[reg_index]))5758// Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.59#define DECLARE_REGISTER_INFOS_I386_STRUCT60#include "RegisterInfos_i386.h"61#undef DECLARE_REGISTER_INFOS_I386_STRUCT6263RegisterContextFreeBSD_i386::RegisterContextFreeBSD_i386(64const ArchSpec &target_arch)65: RegisterInfoInterface(target_arch) {}6667size_t RegisterContextFreeBSD_i386::GetGPRSize() const { return sizeof(GPR); }6869const RegisterInfo *RegisterContextFreeBSD_i386::GetRegisterInfo() const {70switch (GetTargetArchitecture().GetMachine()) {71case llvm::Triple::x86:72return g_register_infos_i386;73default:74assert(false && "Unhandled target architecture.");75return nullptr;76}77}7879uint32_t RegisterContextFreeBSD_i386::GetRegisterCount() const {80return static_cast<uint32_t>(sizeof(g_register_infos_i386) /81sizeof(g_register_infos_i386[0]));82}838485