Automatic date update in version.in
[deliverable/binutils-gdb.git] / gdbserver / netbsd-i386-low.cc
CommitLineData
3666a048 1/* Copyright (C) 2020-2021 Free Software Foundation, Inc.
8b667fae
KR
2
3 This file is part of GDB.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <sys/types.h>
19#include <sys/ptrace.h>
20#include <limits.h>
21
22#include "server.h"
23#include "netbsd-low.h"
24#include "gdbsupport/x86-xstate.h"
25#include "arch/i386.h"
26#include "x86-tdesc.h"
27#include "tdesc.h"
28
29/* The index of various registers inside the regcache. */
30
31enum netbsd_i386_gdb_regnum
32{
33 I386_EAX_REGNUM, /* %eax */
34 I386_ECX_REGNUM, /* %ecx */
35 I386_EDX_REGNUM, /* %edx */
36 I386_EBX_REGNUM, /* %ebx */
37 I386_ESP_REGNUM, /* %esp */
38 I386_EBP_REGNUM, /* %ebp */
39 I386_ESI_REGNUM, /* %esi */
40 I386_EDI_REGNUM, /* %edi */
41 I386_EIP_REGNUM, /* %eip */
42 I386_EFLAGS_REGNUM, /* %eflags */
43 I386_CS_REGNUM, /* %cs */
44 I386_SS_REGNUM, /* %ss */
45 I386_DS_REGNUM, /* %ds */
46 I386_ES_REGNUM, /* %es */
47 I386_FS_REGNUM, /* %fs */
48 I386_GS_REGNUM, /* %gs */
49 I386_ST0_REGNUM /* %st(0) */
50};
51
52/* The fill_function for the general-purpose register set. */
53
54static void
55netbsd_i386_fill_gregset (struct regcache *regcache, char *buf)
56{
57 struct reg *r = (struct reg *) buf;
58
59#define netbsd_i386_collect_gp(regnum, fld) do { \
60 collect_register (regcache, regnum, &r->r_##fld); \
61 } while (0)
62
63 netbsd_i386_collect_gp (I386_EAX_REGNUM, eax);
64 netbsd_i386_collect_gp (I386_EBX_REGNUM, ebx);
65 netbsd_i386_collect_gp (I386_ECX_REGNUM, ecx);
66 netbsd_i386_collect_gp (I386_EDX_REGNUM, edx);
67 netbsd_i386_collect_gp (I386_ESP_REGNUM, esp);
68 netbsd_i386_collect_gp (I386_EBP_REGNUM, ebp);
69 netbsd_i386_collect_gp (I386_ESI_REGNUM, esi);
70 netbsd_i386_collect_gp (I386_EDI_REGNUM, edi);
71 netbsd_i386_collect_gp (I386_EIP_REGNUM, eip);
72 netbsd_i386_collect_gp (I386_EFLAGS_REGNUM, eflags);
73 netbsd_i386_collect_gp (I386_CS_REGNUM, cs);
74 netbsd_i386_collect_gp (I386_SS_REGNUM, ss);
75 netbsd_i386_collect_gp (I386_DS_REGNUM, ds);
76 netbsd_i386_collect_gp (I386_ES_REGNUM, es);
77 netbsd_i386_collect_gp (I386_FS_REGNUM, fs);
78 netbsd_i386_collect_gp (I386_GS_REGNUM, gs);
79}
80
81/* The store_function for the general-purpose register set. */
82
83static void
84netbsd_i386_store_gregset (struct regcache *regcache, const char *buf)
85{
86 struct reg *r = (struct reg *) buf;
87
88#define netbsd_i386_supply_gp(regnum, fld) do { \
89 supply_register (regcache, regnum, &r->r_##fld); \
90 } while(0)
91
92 netbsd_i386_supply_gp (I386_EAX_REGNUM, eax);
93 netbsd_i386_supply_gp (I386_EBX_REGNUM, ebx);
94 netbsd_i386_supply_gp (I386_ECX_REGNUM, ecx);
95 netbsd_i386_supply_gp (I386_EDX_REGNUM, edx);
96 netbsd_i386_supply_gp (I386_ESP_REGNUM, esp);
97 netbsd_i386_supply_gp (I386_EBP_REGNUM, ebp);
98 netbsd_i386_supply_gp (I386_ESI_REGNUM, esi);
99 netbsd_i386_supply_gp (I386_EDI_REGNUM, edi);
100 netbsd_i386_supply_gp (I386_EIP_REGNUM, eip);
101 netbsd_i386_supply_gp (I386_EFLAGS_REGNUM, eflags);
102 netbsd_i386_supply_gp (I386_CS_REGNUM, cs);
103 netbsd_i386_supply_gp (I386_SS_REGNUM, ss);
104 netbsd_i386_supply_gp (I386_DS_REGNUM, ds);
105 netbsd_i386_supply_gp (I386_ES_REGNUM, es);
106 netbsd_i386_supply_gp (I386_FS_REGNUM, fs);
107 netbsd_i386_supply_gp (I386_GS_REGNUM, gs);
108}
109
110/* Description of all the x86-netbsd register sets. */
111
112static const struct netbsd_regset_info netbsd_target_regsets[] =
113{
114 /* General Purpose Registers. */
115 {PT_GETREGS, PT_SETREGS, sizeof (struct reg),
116 netbsd_i386_fill_gregset, netbsd_i386_store_gregset},
117 /* End of list marker. */
118 {0, 0, -1, NULL, NULL }
119};
120
121/* NetBSD target op definitions for the amd64 architecture. */
122
123class netbsd_i386_target : public netbsd_process_target
124{
125public:
126 const netbsd_regset_info *get_regs_info () override;
127
128 void low_arch_setup () override;
129};
130
131const netbsd_regset_info *
132netbsd_i386_target::get_regs_info ()
133{
134 return netbsd_target_regsets;
135}
136
137/* Initialize the target description for the architecture of the
138 inferior. */
139
140void
141netbsd_i386_target::low_arch_setup ()
142{
143 target_desc *tdesc
144 = i386_create_target_description (X86_XSTATE_SSE_MASK, false, false);
145
146 init_target_desc (tdesc, i386_expedite_regs);
147
148 current_process ()->tdesc = tdesc;
149}
150
151/* The singleton target ops object. */
152
153static netbsd_i386_target the_netbsd_i386_target;
154
155/* The NetBSD target ops object. */
156
157netbsd_process_target *the_netbsd_target = &the_netbsd_i386_target;
This page took 0.064443 seconds and 4 git commands to generate.