1/* Native-dependent code for Haiku i386. 2 3 Copyright 2005 Ingo Weinhold <bonefish@cs.tu-berlin.de>. 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 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 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. 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 "defs.h" 23#include "haiku-nat.h" 24#include "i386-tdep.h" 25#include "i387-tdep.h" 26#include "inferior.h" 27#include "regcache.h" 28#include "target.h" 29 30/* Offset in `struct debug_cpu_state' where MEMBER is stored. */ 31#define REG_OFFSET(member) offsetof (struct x86_debug_cpu_state, member) 32 33/* At kHaikuI386RegOffset[REGNUM] you'll find the offset in `struct 34 debug_cpu_state' where the GDB register REGNUM is stored. */ 35static int kHaikuI386RegOffset[] = { 36 REG_OFFSET (eax), 37 REG_OFFSET (ecx), 38 REG_OFFSET (edx), 39 REG_OFFSET (ebx), 40 REG_OFFSET (user_esp), 41 REG_OFFSET (ebp), 42 REG_OFFSET (esi), 43 REG_OFFSET (edi), 44 REG_OFFSET (eip), 45 REG_OFFSET (eflags), 46 REG_OFFSET (cs), 47 REG_OFFSET (user_ss), 48 REG_OFFSET (ds), 49 REG_OFFSET (es), 50 REG_OFFSET (fs), 51 REG_OFFSET (gs) 52}; 53 54 55void 56haiku_supply_registers(int reg, const debug_cpu_state *cpuState) 57{ 58 if (reg == -1) { 59 int i; 60 for (i = 0; i < NUM_REGS; i++) 61 haiku_supply_registers(i, cpuState); 62 } else if (reg < I386_ST0_REGNUM) { 63 int offset = kHaikuI386RegOffset[reg]; 64 regcache_raw_supply (current_regcache, reg, (char*)cpuState + offset); 65 } else { 66 i387_supply_fxsave (current_regcache, -1, 67 &cpuState->extended_registers); 68 } 69} 70 71 72void 73haiku_collect_registers(int reg, debug_cpu_state *cpuState) 74{ 75 if (reg == -1) { 76 int i; 77 for (i = 0; i < NUM_REGS; i++) 78 haiku_collect_registers(i, cpuState); 79 } else if (reg < I386_ST0_REGNUM) { 80 int offset = kHaikuI386RegOffset[reg]; 81 regcache_raw_collect (current_regcache, reg, (char*)cpuState + offset); 82 } else { 83 i387_collect_fxsave (current_regcache, -1, 84 &cpuState->extended_registers); 85 } 86} 87 88