fbsd-i386-low.c (157572) | fbsd-i386-low.c (157574) |
---|---|
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. 4 5 This file is part of GDB. 6 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 --- 5 unchanged lines hidden (view full) --- 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 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. */ 21 | 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. 4 5 This file is part of GDB. 6 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 --- 5 unchanged lines hidden (view full) --- 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 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. */ 21 |
22#include <sys/cdefs.h> 23__FBSDID("$FreeBSD: head/gnu/usr.bin/gdb/gdbserver/fbsd-i386-low.c 157574 2006-04-06 22:24:01Z jmg $"); 24 |
|
22#include "server.h" | 25#include "server.h" |
23#include "linux-low.h" | 26#include "fbsd-low.h" |
24#include "i387-fp.h" 25 26#ifdef HAVE_SYS_REG_H 27#include <sys/reg.h> | 27#include "i387-fp.h" 28 29#ifdef HAVE_SYS_REG_H 30#include <sys/reg.h> |
31#else 32#include <machine/reg.h> |
|
28#endif 29 30/* This module only supports access to the general purpose registers. */ 31 32#define i386_num_regs 16 33 | 33#endif 34 35/* This module only supports access to the general purpose registers. */ 36 37#define i386_num_regs 16 38 |
34/* This stuff comes from i386-linux-nat.c. */ | 39/* This stuff comes from i386-fbsd-nat.c. */ |
35 36/* Mapping between the general-purpose registers in `struct user' 37 format and GDB's register array layout. */ 38static int i386_regmap[] = 39{ | 40 41/* Mapping between the general-purpose registers in `struct user' 42 format and GDB's register array layout. */ 43static int i386_regmap[] = 44{ |
40 EAX * 4, ECX * 4, EDX * 4, EBX * 4, 41 UESP * 4, EBP * 4, ESI * 4, EDI * 4, 42 EIP * 4, EFL * 4, CS * 4, SS * 4, 43 DS * 4, ES * 4, FS * 4, GS * 4 | 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 |
44}; 45 46static int 47i386_cannot_store_register (int regno) 48{ 49 return (regno >= i386_num_regs); 50} 51 52static int 53i386_cannot_fetch_register (int regno) 54{ 55 return (regno >= i386_num_regs); 56} 57 58 | 49}; 50 51static int 52i386_cannot_store_register (int regno) 53{ 54 return (regno >= i386_num_regs); 55} 56 57static int 58i386_cannot_fetch_register (int regno) 59{ 60 return (regno >= i386_num_regs); 61} 62 63 |
59#ifdef HAVE_LINUX_REGSETS | |
60#include <sys/procfs.h> 61#include <sys/ptrace.h> 62 63static void 64i386_fill_gregset (void *buf) 65{ 66 int i; 67 68 for (i = 0; i < i386_num_regs; i++) 69 collect_register (i, ((char *) buf) + i386_regmap[i]); 70 | 64#include <sys/procfs.h> 65#include <sys/ptrace.h> 66 67static void 68i386_fill_gregset (void *buf) 69{ 70 int i; 71 72 for (i = 0; i < i386_num_regs; i++) 73 collect_register (i, ((char *) buf) + i386_regmap[i]); 74 |
71 collect_register_by_name ("orig_eax", ((char *) buf) + ORIG_EAX * 4); | |
72} 73 74static void 75i386_store_gregset (const void *buf) 76{ 77 int i; 78 79 for (i = 0; i < i386_num_regs; i++) 80 supply_register (i, ((char *) buf) + i386_regmap[i]); 81 | 75} 76 77static void 78i386_store_gregset (const void *buf) 79{ 80 int i; 81 82 for (i = 0; i < i386_num_regs; i++) 83 supply_register (i, ((char *) buf) + i386_regmap[i]); 84 |
82 supply_register_by_name ("orig_eax", ((char *) buf) + ORIG_EAX * 4); | |
83} 84 85static void 86i386_fill_fpregset (void *buf) 87{ 88 i387_cache_to_fsave (buf); 89} 90 --- 12 unchanged lines hidden (view full) --- 103static void 104i386_store_fpxregset (const void *buf) 105{ 106 i387_fxsave_to_cache (buf); 107} 108 109 110struct regset_info target_regsets[] = { | 85} 86 87static void 88i386_fill_fpregset (void *buf) 89{ 90 i387_cache_to_fsave (buf); 91} 92 --- 12 unchanged lines hidden (view full) --- 105static void 106i386_store_fpxregset (const void *buf) 107{ 108 i387_fxsave_to_cache (buf); 109} 110 111 112struct regset_info target_regsets[] = { |
111 { PTRACE_GETREGS, PTRACE_SETREGS, sizeof (elf_gregset_t), | 113 { PT_GETREGS, PT_SETREGS, sizeof (struct reg), |
112 GENERAL_REGS, 113 i386_fill_gregset, i386_store_gregset }, 114#ifdef HAVE_PTRACE_GETFPXREGS 115 { PTRACE_GETFPXREGS, PTRACE_SETFPXREGS, sizeof (elf_fpxregset_t), 116 EXTENDED_REGS, 117 i386_fill_fpxregset, i386_store_fpxregset }, 118#endif | 114 GENERAL_REGS, 115 i386_fill_gregset, i386_store_gregset }, 116#ifdef HAVE_PTRACE_GETFPXREGS 117 { PTRACE_GETFPXREGS, PTRACE_SETFPXREGS, sizeof (elf_fpxregset_t), 118 EXTENDED_REGS, 119 i386_fill_fpxregset, i386_store_fpxregset }, 120#endif |
119 { PTRACE_GETFPREGS, PTRACE_SETFPREGS, sizeof (elf_fpregset_t), | 121 { PT_GETFPREGS, PT_SETFPREGS, sizeof (struct fpreg), |
120 FP_REGS, 121 i386_fill_fpregset, i386_store_fpregset }, 122 { 0, 0, -1, -1, NULL, NULL } 123}; 124 | 122 FP_REGS, 123 i386_fill_fpregset, i386_store_fpregset }, 124 { 0, 0, -1, -1, NULL, NULL } 125}; 126 |
125#endif /* HAVE_LINUX_REGSETS */ 126 | |
127static const char i386_breakpoint[] = { 0xCC }; 128#define i386_breakpoint_len 1 129 130extern int debug_threads; 131 132static CORE_ADDR 133i386_get_pc () 134{ --- 21 unchanged lines hidden (view full) --- 156 157 read_inferior_memory (pc, &c, 1); 158 if (c == 0xCC) 159 return 1; 160 161 return 0; 162} 163 | 127static const char i386_breakpoint[] = { 0xCC }; 128#define i386_breakpoint_len 1 129 130extern int debug_threads; 131 132static CORE_ADDR 133i386_get_pc () 134{ --- 21 unchanged lines hidden (view full) --- 156 157 read_inferior_memory (pc, &c, 1); 158 if (c == 0xCC) 159 return 1; 160 161 return 0; 162} 163 |
164struct linux_target_ops the_low_target = { | 164struct fbsd_target_ops the_low_target = { |
165 i386_num_regs, 166 i386_regmap, 167 i386_cannot_fetch_register, 168 i386_cannot_store_register, 169 i386_get_pc, 170 i386_set_pc, 171 i386_breakpoint, 172 i386_breakpoint_len, 173 NULL, 174 1, 175 i386_breakpoint_at, 176}; | 165 i386_num_regs, 166 i386_regmap, 167 i386_cannot_fetch_register, 168 i386_cannot_store_register, 169 i386_get_pc, 170 i386_set_pc, 171 i386_breakpoint, 172 i386_breakpoint_len, 173 NULL, 174 1, 175 i386_breakpoint_at, 176}; |