Update FSF address.
[deliverable/binutils-gdb.git] / gdb / hppam3-nat.c
CommitLineData
2d2959e8
JL
1/* Low level interface to HP800 running mach 4.0.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
6c9638b4 18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2d2959e8
JL
19
20#include "defs.h"
21#include "inferior.h"
22#include "floatformat.h"
23
24#include <stdio.h>
25
26#include <mach.h>
27#include <mach/message.h>
28#include <mach/exception.h>
29#include <mach_error.h>
30
31#include <target.h>
32
33/*
34 * Fetch inferiors registers for gdb.
35 * REGNO specifies which (as gdb views it) register, -1 for all.
36 */
37
38void
39fetch_inferior_registers (regno)
40 int regno;
41{
42 kern_return_t ret;
43 thread_state_data_t state;
b3a34d4f 44 unsigned int stateCnt = TRACE_FLAVOR_SIZE;
2d2959e8
JL
45 int index;
46
47 if (! MACH_PORT_VALID (current_thread))
48 error ("fetch inferior registers: Invalid thread");
49
50 if (must_suspend_thread)
51 setup_thread (current_thread, 1);
52
53 ret = thread_get_state (current_thread,
b3a34d4f 54 TRACE_FLAVOR,
2d2959e8
JL
55 state,
56 &stateCnt);
57
58 if (ret != KERN_SUCCESS)
59 warning ("fetch_inferior_registers: %s ",
60 mach_error_string (ret));
61 else
62 {
63 for (index = 0; index < NUM_REGS; index++)
b3a34d4f 64 supply_register (index,(void*)&state[index]);
2d2959e8
JL
65 }
66
67 if (must_suspend_thread)
68 setup_thread (current_thread, 0);
69}
70\f
71/* Store our register values back into the inferior.
72 * If REGNO is -1, do this for all registers.
73 * Otherwise, REGNO specifies which register
74 *
75 * On mach3 all registers are always saved in one call.
76 */
77void
78store_inferior_registers (regno)
79 int regno;
80{
81 kern_return_t ret;
82 thread_state_data_t state;
b3a34d4f 83 unsigned int stateCnt = TRACE_FLAVOR_SIZE;
2d2959e8
JL
84 register int index;
85
86 if (! MACH_PORT_VALID (current_thread))
87 error ("store inferior registers: Invalid thread");
88
89 if (must_suspend_thread)
90 setup_thread (current_thread, 1);
91
92 /* Fetch the state of the current thread */
93 ret = thread_get_state (current_thread,
b3a34d4f 94 TRACE_FLAVOR,
2d2959e8
JL
95 state,
96 &stateCnt);
97
98 if (ret != KERN_SUCCESS)
99 {
100 warning ("store_inferior_registers (get): %s",
101 mach_error_string (ret));
102 if (must_suspend_thread)
103 setup_thread (current_thread, 0);
104 return;
105 }
106
107
108 /* move gdb's registers to thread's state
109 *
110 * Since we save all registers anyway, save the ones
111 * that gdb thinks are valid (e.g. ignore the regno
112 * parameter)
113 */
114 if (regno > 0 && regno < NUM_REGS )
115 {
116 memcpy(&state[regno], &registers[REGISTER_BYTE (regno)],
117 REGISTER_RAW_SIZE(regno));
118 }
119 else
120 {
121 for (index = 0; index < NUM_REGS; index++)
122 memcpy(&state[index], &registers[REGISTER_BYTE (index)],
123 REGISTER_RAW_SIZE(index));
124/* state[index] = registers[REGISTER_BYTE (index)];*/
125
126 }
127
128 /* Write gdb's current view of register to the thread
129 */
130 ret = thread_set_state (current_thread,
b3a34d4f 131 TRACE_FLAVOR,
2d2959e8 132 state,
b3a34d4f 133 TRACE_FLAVOR_SIZE);
2d2959e8
JL
134
135 if (ret != KERN_SUCCESS)
136 warning ("store_inferior_registers (set): %s",
137 mach_error_string (ret));
138
139 if (must_suspend_thread)
140 setup_thread (current_thread, 0);
141}
This page took 0.035732 seconds and 4 git commands to generate.