1 /* GNU/Linux/i386 specific low level interface, for the remote server for GDB.
2 Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 #include <sys/cdefs.h>
23 __FBSDID("$FreeBSD$");
32 #include <machine/reg.h>
35 /* This module only supports access to the general purpose registers. */
37 #define i386_num_regs 16
39 /* This stuff comes from i386-fbsd-nat.c. */
41 /* Mapping between the general-purpose registers in `struct user'
42 format and GDB's register array layout. */
43 static int i386_regmap[] =
45 tEAX * 4, tECX * 4, tEDX * 4, tEBX * 4,
46 tESP * 4, tEBP * 4, tESI * 4, tEDI * 4,
47 tEIP * 4, tEFLAGS * 4, tCS * 4, tSS * 4,
48 tDS * 4, tES * 4, tFS * 4, tGS * 4
52 i386_cannot_store_register (int regno)
54 return (regno >= i386_num_regs);
58 i386_cannot_fetch_register (int regno)
60 return (regno >= i386_num_regs);
64 #include <sys/procfs.h>
65 #include <sys/ptrace.h>
68 i386_fill_gregset (void *buf)
72 for (i = 0; i < i386_num_regs; i++)
73 collect_register (i, ((char *) buf) + i386_regmap[i]);
78 i386_store_gregset (const void *buf)
82 for (i = 0; i < i386_num_regs; i++)
83 supply_register (i, ((char *) buf) + i386_regmap[i]);
88 i386_fill_fpregset (void *buf)
90 i387_cache_to_fsave (buf);
94 i386_store_fpregset (const void *buf)
96 i387_fsave_to_cache (buf);
100 i386_fill_fpxregset (void *buf)
102 i387_cache_to_fxsave (buf);
106 i386_store_fpxregset (const void *buf)
108 i387_fxsave_to_cache (buf);
112 struct regset_info target_regsets[] = {
113 { PT_GETREGS, PT_SETREGS, sizeof (struct reg),
115 i386_fill_gregset, i386_store_gregset },
116 #ifdef HAVE_PTRACE_GETFPXREGS
117 { PTRACE_GETFPXREGS, PTRACE_SETFPXREGS, sizeof (elf_fpxregset_t),
119 i386_fill_fpxregset, i386_store_fpxregset },
121 { PT_GETFPREGS, PT_SETFPREGS, sizeof (struct fpreg),
123 i386_fill_fpregset, i386_store_fpregset },
124 { 0, 0, -1, -1, NULL, NULL }
127 static const char i386_breakpoint[] = { 0xCC };
128 #define i386_breakpoint_len 1
130 extern int debug_threads;
137 collect_register_by_name ("eip", &pc);
140 fprintf (stderr, "stop pc (before any decrement) is %08lx\n", pc);
145 i386_set_pc (CORE_ADDR newpc)
148 fprintf (stderr, "set pc to %08lx\n", (long) newpc);
149 supply_register_by_name ("eip", &newpc);
153 i386_breakpoint_at (CORE_ADDR pc)
157 read_inferior_memory (pc, &c, 1);
164 struct fbsd_target_ops the_low_target = {
167 i386_cannot_fetch_register,
168 i386_cannot_store_register,