1 /* Low level interface to HP800 running mach 4.0 for GDB, the GNU
4 Copyright 1995, 2000, 2001, 2003 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
25 #include "floatformat.h"
31 #include <mach/message.h>
32 #include <mach/exception.h>
33 #include <mach_error.h>
38 * Fetch inferiors registers for gdb.
39 * REGNO specifies which (as gdb views it) register, -1 for all.
43 fetch_inferior_registers (int regno
)
46 thread_state_data_t state
;
47 unsigned int stateCnt
= TRACE_FLAVOR_SIZE
;
50 if (!MACH_PORT_VALID (current_thread
))
51 error ("fetch inferior registers: Invalid thread");
53 if (must_suspend_thread
)
54 setup_thread (current_thread
, 1);
56 ret
= thread_get_state (current_thread
,
61 if (ret
!= KERN_SUCCESS
)
62 warning ("fetch_inferior_registers: %s ",
63 mach_error_string (ret
));
66 for (index
= 0; index
< NUM_REGS
; index
++)
67 supply_register (index
, (void *) &state
[index
]);
70 if (must_suspend_thread
)
71 setup_thread (current_thread
, 0);
74 /* Store our register values back into the inferior.
75 * If REGNO is -1, do this for all registers.
76 * Otherwise, REGNO specifies which register
78 * On mach3 all registers are always saved in one call.
81 store_inferior_registers (int regno
)
84 thread_state_data_t state
;
85 unsigned int stateCnt
= TRACE_FLAVOR_SIZE
;
88 if (!MACH_PORT_VALID (current_thread
))
89 error ("store inferior registers: Invalid thread");
91 if (must_suspend_thread
)
92 setup_thread (current_thread
, 1);
94 /* Fetch the state of the current thread */
95 ret
= thread_get_state (current_thread
,
100 if (ret
!= KERN_SUCCESS
)
102 warning ("store_inferior_registers (get): %s",
103 mach_error_string (ret
));
104 if (must_suspend_thread
)
105 setup_thread (current_thread
, 0);
110 /* move gdb's registers to thread's state
112 * Since we save all registers anyway, save the ones
113 * that gdb thinks are valid (e.g. ignore the regno
116 if (regno
> 0 && regno
< NUM_REGS
)
118 memcpy (&state
[regno
], &deprecated_registers
[DEPRECATED_REGISTER_BYTE (regno
)],
119 DEPRECATED_REGISTER_RAW_SIZE (regno
));
123 for (index
= 0; index
< NUM_REGS
; index
++)
124 memcpy (&state
[index
], &deprecated_registers
[DEPRECATED_REGISTER_BYTE (index
)],
125 DEPRECATED_REGISTER_RAW_SIZE (index
));
126 /* state[index] = deprecated_registers[DEPRECATED_REGISTER_BYTE (index)]; */
130 /* Write gdb's current view of register to the thread
132 ret
= thread_set_state (current_thread
,
137 if (ret
!= KERN_SUCCESS
)
138 warning ("store_inferior_registers (set): %s",
139 mach_error_string (ret
));
141 if (must_suspend_thread
)
142 setup_thread (current_thread
, 0);