Oops. missed a line.
[deliverable/binutils-gdb.git] / gdb / hppam3-nat.c
CommitLineData
69517000
AC
1/* Low level interface to HP800 running mach 4.0 for GDB, the GNU
2 debugger.
3
4 Copyright 1995, 2000, 2001, 2003 Free Software Foundation, Inc.
c906108c 5
c5aa993b 6 This file is part of GDB.
c906108c 7
c5aa993b
JM
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.
c906108c 12
c5aa993b
JM
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.
c906108c 17
c5aa993b
JM
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. */
c906108c
SS
22
23#include "defs.h"
24#include "inferior.h"
25#include "floatformat.h"
4e052eda 26#include "regcache.h"
c906108c
SS
27
28#include <stdio.h>
29
30#include <mach.h>
31#include <mach/message.h>
32#include <mach/exception.h>
33#include <mach_error.h>
34
35#include <target.h>
36
37/*
38 * Fetch inferiors registers for gdb.
39 * REGNO specifies which (as gdb views it) register, -1 for all.
40 */
41
42void
fba45db2 43fetch_inferior_registers (int regno)
c906108c
SS
44{
45 kern_return_t ret;
46 thread_state_data_t state;
47 unsigned int stateCnt = TRACE_FLAVOR_SIZE;
48 int index;
c5aa993b
JM
49
50 if (!MACH_PORT_VALID (current_thread))
c906108c
SS
51 error ("fetch inferior registers: Invalid thread");
52
53 if (must_suspend_thread)
54 setup_thread (current_thread, 1);
55
56 ret = thread_get_state (current_thread,
57 TRACE_FLAVOR,
58 state,
59 &stateCnt);
60
61 if (ret != KERN_SUCCESS)
62 warning ("fetch_inferior_registers: %s ",
63 mach_error_string (ret));
64 else
65 {
c5aa993b
JM
66 for (index = 0; index < NUM_REGS; index++)
67 supply_register (index, (void *) &state[index]);
c906108c
SS
68 }
69
70 if (must_suspend_thread)
71 setup_thread (current_thread, 0);
72}
73\f
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
77 *
78 * On mach3 all registers are always saved in one call.
79 */
80void
fba45db2 81store_inferior_registers (int regno)
c906108c
SS
82{
83 kern_return_t ret;
84 thread_state_data_t state;
85 unsigned int stateCnt = TRACE_FLAVOR_SIZE;
52f0bd74 86 int index;
c906108c 87
c5aa993b 88 if (!MACH_PORT_VALID (current_thread))
c906108c
SS
89 error ("store inferior registers: Invalid thread");
90
91 if (must_suspend_thread)
92 setup_thread (current_thread, 1);
93
94 /* Fetch the state of the current thread */
95 ret = thread_get_state (current_thread,
96 TRACE_FLAVOR,
97 state,
98 &stateCnt);
99
c5aa993b 100 if (ret != KERN_SUCCESS)
c906108c
SS
101 {
102 warning ("store_inferior_registers (get): %s",
103 mach_error_string (ret));
104 if (must_suspend_thread)
105 setup_thread (current_thread, 0);
106 return;
107 }
108
109
110 /* move gdb's registers to thread's state
c5aa993b 111
c906108c
SS
112 * Since we save all registers anyway, save the ones
113 * that gdb thinks are valid (e.g. ignore the regno
114 * parameter)
115 */
c5aa993b 116 if (regno > 0 && regno < NUM_REGS)
c906108c 117 {
62700349 118 memcpy (&state[regno], &deprecated_registers[DEPRECATED_REGISTER_BYTE (regno)],
12c266ea 119 DEPRECATED_REGISTER_RAW_SIZE (regno));
c906108c
SS
120 }
121 else
122 {
c5aa993b 123 for (index = 0; index < NUM_REGS; index++)
62700349 124 memcpy (&state[index], &deprecated_registers[DEPRECATED_REGISTER_BYTE (index)],
12c266ea 125 DEPRECATED_REGISTER_RAW_SIZE (index));
62700349 126/* state[index] = deprecated_registers[DEPRECATED_REGISTER_BYTE (index)]; */
c906108c
SS
127
128 }
c5aa993b 129
c906108c
SS
130 /* Write gdb's current view of register to the thread
131 */
132 ret = thread_set_state (current_thread,
133 TRACE_FLAVOR,
134 state,
135 TRACE_FLAVOR_SIZE);
c5aa993b 136
c906108c
SS
137 if (ret != KERN_SUCCESS)
138 warning ("store_inferior_registers (set): %s",
139 mach_error_string (ret));
140
141 if (must_suspend_thread)
142 setup_thread (current_thread, 0);
143}
This page took 0.294218 seconds and 4 git commands to generate.