1 //===-- RegisterContextLinux_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 "RegisterContextLinux_i386.h"
13 #include "RegisterContextLinux_x86_64.h"
15 using namespace lldb_private;
51 GPR gpr; // General purpose registers.
52 int32_t fpvalid; // True if FPU is being used.
54 FXSAVE i387; // General purpose floating point registers (see FPR for extended register sets).
55 uint64_t tsize; // Text segment size.
56 uint64_t dsize; // Data segment size.
57 uint64_t ssize; // Stack segment size.
58 uint64_t start_code; // VM address of text.
59 uint64_t start_stack; // VM address of stack bottom (top in rsp).
60 int64_t signal; // Signal causing core dump.
61 int32_t reserved; // Unused.
63 uint64_t ar0; // Location of GPR's.
64 FXSAVE* fpstate; // Location of FPR's.
65 uint64_t magic; // Identifier for core dumps.
66 char u_comm[32]; // Command causing core dump.
67 uint64_t u_debugreg[8]; // Debug registers (DR0 - DR7).
68 uint64_t error_code; // CPU error code.
69 uint64_t fault_address; // Control register CR3.
72 #define DR_SIZE sizeof(UserArea::u_debugreg[0])
73 #define DR_OFFSET(reg_index) \
74 (LLVM_EXTENSION offsetof(UserArea, u_debugreg[reg_index]))
76 //---------------------------------------------------------------------------
77 // Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64 structure.
78 //---------------------------------------------------------------------------
79 #define DECLARE_REGISTER_INFOS_X86_64_STRUCT
80 #include "RegisterInfos_x86_64.h"
81 #undef DECLARE_REGISTER_INFOS_X86_64_STRUCT
83 static const RegisterInfo *
84 GetRegisterInfo_i386(const lldb_private::ArchSpec &arch)
86 static std::vector<lldb_private::RegisterInfo> g_register_infos;
88 // Allocate RegisterInfo only once
89 if (g_register_infos.empty())
91 // Copy the register information from base class
92 std::unique_ptr<RegisterContextLinux_i386> reg_interface(new RegisterContextLinux_i386 (arch));
93 const RegisterInfo *base_info = reg_interface->GetRegisterInfo();
94 g_register_infos.insert(g_register_infos.end(), &base_info[0], &base_info[k_num_registers_i386]);
96 //---------------------------------------------------------------------------
97 // Include RegisterInfos_x86_64 to update the g_register_infos structure
98 // with x86_64 offsets.
99 //---------------------------------------------------------------------------
100 #define UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
101 #include "RegisterInfos_x86_64.h"
102 #undef UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
105 return &g_register_infos[0];
108 RegisterContextLinux_x86_64::RegisterContextLinux_x86_64(const ArchSpec &target_arch) :
109 RegisterInfoInterface(target_arch)
113 RegisterContextLinux_x86_64::~RegisterContextLinux_x86_64()
118 RegisterContextLinux_x86_64::GetGPRSize()
124 RegisterContextLinux_x86_64::GetRegisterInfo()
126 switch (m_target_arch.GetCore())
128 case ArchSpec::eCore_x86_32_i386:
129 case ArchSpec::eCore_x86_32_i486:
130 case ArchSpec::eCore_x86_32_i486sx:
131 return GetRegisterInfo_i386 (m_target_arch);
132 case ArchSpec::eCore_x86_64_x86_64:
133 return g_register_infos_x86_64;
135 assert(false && "Unhandled target architecture.");