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