]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/POSIX/RegisterContextLinux_i386.cpp
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / source / Plugins / Process / POSIX / RegisterContextLinux_i386.cpp
1 //===-- RegisterContextLinux_i386.cpp --------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===---------------------------------------------------------------------===//
9
10 #include "RegisterContextPOSIX_x86.h"
11 #include "RegisterContextLinux_i386.h"
12
13 using namespace lldb_private;
14 using namespace lldb;
15
16 struct GPR
17 {
18     uint32_t ebx;
19     uint32_t ecx;
20     uint32_t edx;
21     uint32_t esi;
22     uint32_t edi;
23     uint32_t ebp;
24     uint32_t eax;
25     uint32_t ds;
26     uint32_t es;
27     uint32_t fs;
28     uint32_t gs;
29     uint32_t orig_ax;
30     uint32_t eip;
31     uint32_t cs;
32     uint32_t eflags;
33     uint32_t esp;
34     uint32_t ss;
35 };
36
37 struct UserArea
38 {
39     GPR      regs;          // General purpose registers.
40     int32_t  fpvalid;       // True if FPU is being used.
41     FXSAVE   i387;          // FPU registers.
42     uint32_t tsize;         // Text segment size.
43     uint32_t dsize;         // Data segment size.
44     uint32_t ssize;         // Stack segment size.
45     uint32_t start_code;    // VM address of text.
46     uint32_t start_stack;   // VM address of stack bottom (top in rsp).
47     int32_t  signal;        // Signal causing core dump.
48     int32_t  reserved;      // Unused.
49     uint32_t ar0;           // Location of GPR's.
50     uint32_t fpstate;       // Location of FPR's. Should be a FXSTATE *, but this
51                                 //  has to be 32-bits even on 64-bit systems.
52     uint32_t magic;         // Identifier for core dumps.
53     char     u_comm[32];    // Command causing core dump.
54     uint32_t u_debugreg[8]; // Debug registers (DR0 - DR7).
55 };
56
57 #define DR_SIZE sizeof(UserArea::u_debugreg[0])
58 #define DR_OFFSET(reg_index) \
59     (LLVM_EXTENSION offsetof(UserArea, u_debugreg[reg_index]))
60
61 //---------------------------------------------------------------------------
62 // Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.
63 //---------------------------------------------------------------------------
64 #define DECLARE_REGISTER_INFOS_I386_STRUCT
65 #include "RegisterInfos_i386.h"
66 #undef DECLARE_REGISTER_INFOS_I386_STRUCT
67
68 RegisterContextLinux_i386::RegisterContextLinux_i386(const ArchSpec &target_arch) :
69     RegisterInfoInterface(target_arch)
70 {
71 }
72
73 RegisterContextLinux_i386::~RegisterContextLinux_i386()
74 {
75 }
76
77 size_t
78 RegisterContextLinux_i386::GetGPRSize()
79 {
80     return sizeof(GPR);
81 }
82
83 const RegisterInfo *
84 RegisterContextLinux_i386::GetRegisterInfo()
85 {
86     switch (m_target_arch.GetCore())
87     {
88         case ArchSpec::eCore_x86_32_i386:
89         case ArchSpec::eCore_x86_32_i486:
90         case ArchSpec::eCore_x86_32_i486sx:
91             return g_register_infos_i386;
92         default:
93             assert(false && "Unhandled target architecture.");
94             return NULL;
95     }
96 }