1 //===-- RegisterContextFreeBSD_x86_64.cpp ----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===---------------------------------------------------------------------===//
11 #include "RegisterContextPOSIX_x86.h"
12 #include "RegisterContextFreeBSD_i386.h"
13 #include "RegisterContextFreeBSD_x86_64.h"
15 using namespace lldb_private;
18 // http://svnweb.freebsd.org/base/head/sys/x86/include/reg.h
50 #define DR_OFFSET(reg_index) 0
52 //---------------------------------------------------------------------------
53 // Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64 structure.
54 //---------------------------------------------------------------------------
55 #define DECLARE_REGISTER_INFOS_X86_64_STRUCT
56 #include "RegisterInfos_x86_64.h"
57 #undef DECLARE_REGISTER_INFOS_X86_64_STRUCT
59 static const RegisterInfo *
60 GetRegisterInfo_i386(const lldb_private::ArchSpec& arch)
62 static std::vector<lldb_private::RegisterInfo> g_register_infos;
64 // Allocate RegisterInfo only once
65 if (g_register_infos.empty())
67 // Copy the register information from base class
68 std::unique_ptr<RegisterContextFreeBSD_i386> reg_interface(new RegisterContextFreeBSD_i386 (arch));
69 const RegisterInfo *base_info = reg_interface->GetRegisterInfo();
70 g_register_infos.insert(g_register_infos.end(), &base_info[0], &base_info[k_num_registers_i386]);
72 //---------------------------------------------------------------------------
73 // Include RegisterInfos_x86_64 to update the g_register_infos structure
74 // with x86_64 offsets.
75 //---------------------------------------------------------------------------
76 #define UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
77 #include "RegisterInfos_x86_64.h"
78 #undef UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
81 return &g_register_infos[0];
84 RegisterContextFreeBSD_x86_64::RegisterContextFreeBSD_x86_64(const ArchSpec &target_arch) :
85 RegisterInfoInterface(target_arch)
89 RegisterContextFreeBSD_x86_64::~RegisterContextFreeBSD_x86_64()
94 RegisterContextFreeBSD_x86_64::GetGPRSize()
100 RegisterContextFreeBSD_x86_64::GetRegisterInfo()
102 switch (m_target_arch.GetCore())
104 case ArchSpec::eCore_x86_32_i386:
105 case ArchSpec::eCore_x86_32_i486:
106 case ArchSpec::eCore_x86_32_i486sx:
107 return GetRegisterInfo_i386 (m_target_arch);
108 case ArchSpec::eCore_x86_64_x86_64:
109 return g_register_infos_x86_64;
111 assert(false && "Unhandled target architecture.");