2003-07-16 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / hppam3-nat.c
CommitLineData
c906108c 1/* Low level interface to HP800 running mach 4.0.
b6ba6518 2 Copyright 1995, 2000, 2001 Free Software Foundation, Inc.
c906108c 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"
4e052eda 24#include "regcache.h"
c906108c
SS
25
26#include <stdio.h>
27
28#include <mach.h>
29#include <mach/message.h>
30#include <mach/exception.h>
31#include <mach_error.h>
32
33#include <target.h>
34
35/*
36 * Fetch inferiors registers for gdb.
37 * REGNO specifies which (as gdb views it) register, -1 for all.
38 */
39
40void
fba45db2 41fetch_inferior_registers (int regno)
c906108c
SS
42{
43 kern_return_t ret;
44 thread_state_data_t state;
45 unsigned int stateCnt = TRACE_FLAVOR_SIZE;
46 int index;
c5aa993b
JM
47
48 if (!MACH_PORT_VALID (current_thread))
c906108c
SS
49 error ("fetch inferior registers: Invalid thread");
50
51 if (must_suspend_thread)
52 setup_thread (current_thread, 1);
53
54 ret = thread_get_state (current_thread,
55 TRACE_FLAVOR,
56 state,
57 &stateCnt);
58
59 if (ret != KERN_SUCCESS)
60 warning ("fetch_inferior_registers: %s ",
61 mach_error_string (ret));
62 else
63 {
c5aa993b
JM
64 for (index = 0; index < NUM_REGS; index++)
65 supply_register (index, (void *) &state[index]);
c906108c
SS
66 }
67
68 if (must_suspend_thread)
69 setup_thread (current_thread, 0);
70}
71\f
72/* Store our register values back into the inferior.
73 * If REGNO is -1, do this for all registers.
74 * Otherwise, REGNO specifies which register
75 *
76 * On mach3 all registers are always saved in one call.
77 */
78void
fba45db2 79store_inferior_registers (int regno)
c906108c
SS
80{
81 kern_return_t ret;
82 thread_state_data_t state;
83 unsigned int stateCnt = TRACE_FLAVOR_SIZE;
84 register int index;
85
c5aa993b 86 if (!MACH_PORT_VALID (current_thread))
c906108c
SS
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,
94 TRACE_FLAVOR,
95 state,
96 &stateCnt);
97
c5aa993b 98 if (ret != KERN_SUCCESS)
c906108c
SS
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
c5aa993b 109
c906108c
SS
110 * Since we save all registers anyway, save the ones
111 * that gdb thinks are valid (e.g. ignore the regno
112 * parameter)
113 */
c5aa993b 114 if (regno > 0 && regno < NUM_REGS)
c906108c 115 {
524d7c18 116 memcpy (&state[regno], &deprecated_registers[REGISTER_BYTE (regno)],
c5aa993b 117 REGISTER_RAW_SIZE (regno));
c906108c
SS
118 }
119 else
120 {
c5aa993b 121 for (index = 0; index < NUM_REGS; index++)
524d7c18 122 memcpy (&state[index], &deprecated_registers[REGISTER_BYTE (index)],
c5aa993b 123 REGISTER_RAW_SIZE (index));
524d7c18 124/* state[index] = deprecated_registers[REGISTER_BYTE (index)]; */
c906108c
SS
125
126 }
c5aa993b 127
c906108c
SS
128 /* Write gdb's current view of register to the thread
129 */
130 ret = thread_set_state (current_thread,
131 TRACE_FLAVOR,
132 state,
133 TRACE_FLAVOR_SIZE);
c5aa993b 134
c906108c
SS
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.297812 seconds and 4 git commands to generate.