1 /* GNU/FreeBSD/amd64 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$");
29 #include <sys/stddef.h>
30 #include <sys/types.h>
31 #include <sys/ptrace.h>
32 #include <machine/reg.h>
34 /* Mapping between the general-purpose registers in `struct user'
35 format and GDB's register array layout. */
36 static int amd64_regmap[] = {
37 offsetof(struct reg, r_rax),
38 offsetof(struct reg, r_rbx),
39 offsetof(struct reg, r_rcx),
40 offsetof(struct reg, r_rdx),
41 offsetof(struct reg, r_rsi),
42 offsetof(struct reg, r_rdi),
43 offsetof(struct reg, r_rbp),
44 offsetof(struct reg, r_rsp),
45 offsetof(struct reg, r_r8),
46 offsetof(struct reg, r_r9),
47 offsetof(struct reg, r_r10),
48 offsetof(struct reg, r_r11),
49 offsetof(struct reg, r_r12),
50 offsetof(struct reg, r_r13),
51 offsetof(struct reg, r_r14),
52 offsetof(struct reg, r_r15),
53 offsetof(struct reg, r_rip),
54 offsetof(struct reg, r_rflags), /* XXX 64-bit */
55 offsetof(struct reg, r_cs),
56 offsetof(struct reg, r_ss),
57 offsetof(struct reg, r_ds),
58 offsetof(struct reg, r_es),
59 offsetof(struct reg, r_fs),
60 offsetof(struct reg, r_gs),
62 #define AMD64_NUM_REGS (sizeof(amd64_regmap) / sizeof(amd64_regmap[0]))
64 static const char amd64_breakpoint[] = { 0xCC };
65 #define AMD64_BP_LEN 1
67 extern int debug_threads;
70 amd64_cannot_store_register(int regno)
73 return (regno >= AMD64_NUM_REGS);
77 amd64_cannot_fetch_register(int regno)
80 return (regno >= AMD64_NUM_REGS);
84 amd64_fill_gregset(void *buf)
88 for (i = 0; i < AMD64_NUM_REGS; i++)
89 collect_register(i, ((char *)buf) + amd64_regmap[i]);
93 amd64_store_gregset(const void *buf)
97 for (i = 0; i < AMD64_NUM_REGS; i++)
98 supply_register(i, ((char *)buf) + amd64_regmap[i]);
102 amd64_fill_fpregset(void *buf)
105 i387_cache_to_fsave(buf);
109 amd64_store_fpregset(const void *buf)
112 i387_fsave_to_cache(buf);
116 amd64_fill_fpxregset(void *buf)
119 i387_cache_to_fxsave(buf);
123 amd64_store_fpxregset(const void *buf)
126 i387_fxsave_to_cache(buf);
130 struct regset_info target_regsets[] = {
139 #ifdef HAVE_PTRACE_GETFPXREGS
143 sizeof(elf_fpxregset_t),
145 amd64_fill_fpxregset,
146 amd64_store_fpxregset,
152 sizeof(struct fpreg),
155 amd64_store_fpregset,
172 collect_register_by_name("rip", &pc);
175 fprintf(stderr, "stop pc (before any decrement) is %016lx\n", pc);
181 amd64_set_pc(CORE_ADDR newpc)
185 fprintf(stderr, "set pc to %016lx\n", (long)newpc);
186 supply_register_by_name("rip", &newpc);
190 amd64_breakpoint_at(CORE_ADDR pc)
194 read_inferior_memory(pc, &c, 1);
201 struct fbsd_target_ops the_low_target = {
204 amd64_cannot_fetch_register,
205 amd64_cannot_store_register,