gem5
[DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
arch
sparc
remote_gdb.cc
Go to the documentation of this file.
1
/*
2
* Copyright 2015 LabWare
3
* Copyright 2014 Google, Inc.
4
* Copyright (c) 2002-2005 The Regents of The University of Michigan
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are
9
* met: redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer;
11
* redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution;
14
* neither the name of the copyright holders nor the names of its
15
* contributors may be used to endorse or promote products derived from
16
* this software without specific prior written permission.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
/*
32
* Copyright (c) 1990, 1993 The Regents of the University of California
33
* All rights reserved
34
*
35
* This software was developed by the Computer Systems Engineering group
36
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
37
* contributed to Berkeley.
38
*
39
* All advertising materials mentioning features or use of this software
40
* must display the following acknowledgement:
41
* This product includes software developed by the University of
42
* California, Lawrence Berkeley Laboratories.
43
*
44
* Redistribution and use in source and binary forms, with or without
45
* modification, are permitted provided that the following conditions
46
* are met:
47
* 1. Redistributions of source code must retain the above copyright
48
* notice, this list of conditions and the following disclaimer.
49
* 2. Redistributions in binary form must reproduce the above copyright
50
* notice, this list of conditions and the following disclaimer in the
51
* documentation and/or other materials provided with the distribution.
52
* 3. All advertising materials mentioning features or use of this software
53
* must display the following acknowledgement:
54
* This product includes software developed by the University of
55
* California, Berkeley and its contributors.
56
* 4. Neither the name of the University nor the names of its contributors
57
* may be used to endorse or promote products derived from this software
58
* without specific prior written permission.
59
*
60
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70
* SUCH DAMAGE.
71
*
72
* @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94
73
*/
74
75
/*-
76
* Copyright (c) 2001 The NetBSD Foundation, Inc.
77
* All rights reserved.
78
*
79
* This code is derived from software contributed to The NetBSD Foundation
80
* by Jason R. Thorpe.
81
*
82
* Redistribution and use in source and binary forms, with or without
83
* modification, are permitted provided that the following conditions
84
* are met:
85
* 1. Redistributions of source code must retain the above copyright
86
* notice, this list of conditions and the following disclaimer.
87
* 2. Redistributions in binary form must reproduce the above copyright
88
* notice, this list of conditions and the following disclaimer in the
89
* documentation and/or other materials provided with the distribution.
90
* 3. All advertising materials mentioning features or use of this software
91
* must display the following acknowledgement:
92
* This product includes software developed by the NetBSD
93
* Foundation, Inc. and its contributors.
94
* 4. Neither the name of The NetBSD Foundation nor the names of its
95
* contributors may be used to endorse or promote products derived
96
* from this software without specific prior written permission.
97
*
98
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
99
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
100
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
101
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
102
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
103
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
104
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
105
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
106
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
107
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
108
* POSSIBILITY OF SUCH DAMAGE.
109
*/
110
111
/*
112
* $NetBSD: kgdb_stub.c,v 1.8 2001/07/07 22:58:00 wdk Exp $
113
*
114
* Taken from NetBSD
115
*
116
* "Stub" to allow remote cpu to debug over a serial line using gdb.
117
*/
118
119
#include "
arch/sparc/remote_gdb.hh
"
120
121
#include <sys/signal.h>
122
#include <unistd.h>
123
124
#include <csignal>
125
#include <string>
126
127
#include "
arch/sparc/regs/int.hh
"
128
#include "
arch/sparc/regs/misc.hh
"
129
#include "
arch/sparc/types.hh
"
130
#include "
base/intmath.hh
"
131
#include "
base/remote_gdb.hh
"
132
#include "
base/socket.hh
"
133
#include "
base/trace.hh
"
134
#include "
cpu/static_inst.hh
"
135
#include "
cpu/thread_context.hh
"
136
#include "debug/GDBAcc.hh"
137
#include "debug/GDBRead.hh"
138
#include "
mem/page_table.hh
"
139
#include "
mem/physical.hh
"
140
#include "
mem/port.hh
"
141
#include "
sim/byteswap.hh
"
142
#include "
sim/full_system.hh
"
143
#include "
sim/process.hh
"
144
#include "
sim/system.hh
"
145
146
namespace
gem5
147
{
148
149
using namespace
SparcISA
;
150
151
RemoteGDB::RemoteGDB
(
System
*_system,
ListenSocketConfig
_listen_config)
152
:
BaseRemoteGDB
(_system, _listen_config),
153
regCache32(this), regCache64(this)
154
{}
155
157
// RemoteGDB::acc
158
//
159
// Determine if the mapping at va..(va+len) is valid.
160
//
161
bool
162
RemoteGDB::acc(Addr va,
size_t
len)
163
{
164
//@Todo In NetBSD, this function checks if all addresses
165
// from va to va + len have valid page map entries. Not
166
// sure how this will work for other OSes or in general.
167
if
(FullSystem) {
168
return
va
!= 0;
169
}
else
{
170
// Check to make sure the first byte is mapped into the processes
171
// address space.
172
return
context()->getProcessPtr()->pTable->lookup(va) !=
nullptr
;
173
}
174
}
175
176
void
177
RemoteGDB::SPARCGdbRegCache::getRegs
(
ThreadContext
*
context
)
178
{
179
DPRINTF
(GDBAcc,
"getRegs in remotegdb \n"
);
180
for
(
int
i
= 0;
i
< 32;
i
++)
181
r
.gpr[
i
] =
htobe
((uint32_t)
context
->getReg(
intRegClass
[
i
]));
182
auto
&
pc
=
context
->pcState().as<
SparcISA::PCState
>();
183
r
.pc =
htobe
((uint32_t)
pc
.pc());
184
r
.npc =
htobe
((uint32_t)
pc
.npc());
185
r
.y =
htobe
((uint32_t)
context
->getReg(
int_reg::Y
));
186
PSTATE pstate =
context
->readMiscReg(
MISCREG_PSTATE
);
187
r
.psr =
htobe
((uint32_t)pstate);
188
r
.fsr =
htobe
((uint32_t)
context
->readMiscReg(
MISCREG_FSR
));
189
r
.csr =
htobe
((uint32_t)
context
->getReg(
int_reg::Ccr
));
190
}
191
192
void
193
RemoteGDB::SPARC64GdbRegCache::getRegs
(
ThreadContext
*
context
)
194
{
195
DPRINTF
(GDBAcc,
"getRegs in remotegdb \n"
);
196
for
(
int
i
= 0;
i
< 32;
i
++)
197
r
.gpr[
i
] =
htobe
(
context
->getReg(
intRegClass
[
i
]));
198
for
(
int
i
= 0;
i
< 32;
i
++)
199
r
.fpr[
i
] = 0;
200
auto
&
pc
=
context
->pcState().as<
SparcISA::PCState
>();
201
r
.pc =
htobe
(
pc
.pc());
202
r
.npc =
htobe
(
pc
.npc());
203
r
.fsr =
htobe
(
context
->readMiscReg(
MISCREG_FSR
));
204
r
.fprs =
htobe
(
context
->readMiscReg(
MISCREG_FPRS
));
205
r
.y =
htobe
(
context
->getReg(
int_reg::Y
));
206
PSTATE pstate =
context
->readMiscReg(
MISCREG_PSTATE
);
207
r
.state =
htobe
(
208
context
->readMiscReg(
MISCREG_CWP
) |
209
pstate << 8 |
210
context
->readMiscReg(
MISCREG_ASI
) << 24 |
211
context
->getReg(
int_reg::Ccr
) << 32);
212
}
213
214
void
215
RemoteGDB::SPARCGdbRegCache::setRegs
(
ThreadContext
*
context
)
const
216
{
217
for
(
int
i
= 0;
i
< 32;
i
++)
218
context
->setReg(
intRegClass
[
i
],
r
.gpr[
i
]);
219
PCState
pc
;
220
pc
.pc(
r
.pc);
221
pc
.npc(
r
.npc);
222
pc
.nnpc(
pc
.npc() +
sizeof
(
MachInst
));
223
pc
.upc(0);
224
pc
.nupc(1);
225
context
->pcState(
pc
);
226
// Floating point registers are left at 0 in netbsd
227
// All registers other than the pc, npc and int regs
228
// are ignored as well.
229
}
230
231
void
232
RemoteGDB::SPARC64GdbRegCache::setRegs
(
ThreadContext
*
context
)
const
233
{
234
for
(
int
i
= 0;
i
< 32;
i
++)
235
context
->setReg(
intRegClass
[
i
],
r
.gpr[
i
]);
236
PCState
pc
;
237
pc
.pc(
r
.pc);
238
pc
.npc(
r
.npc);
239
pc
.nnpc(
pc
.npc() +
sizeof
(
MachInst
));
240
pc
.upc(0);
241
pc
.nupc(1);
242
context
->pcState(
pc
);
243
// Floating point registers are left at 0 in netbsd
244
// All registers other than the pc, npc and int regs
245
// are ignored as well.
246
}
247
248
249
BaseGdbRegCache
*
250
RemoteGDB::gdbRegs
()
251
{
252
PSTATE pstate =
context
()->readMiscReg(
MISCREG_PSTATE
);
253
if
(pstate.am) {
254
return
&
regCache32
;
255
}
else
{
256
return
®Cache64;
257
}
258
}
259
260
}
// namespace gem5
misc.hh
remote_gdb.hh
types.hh
remote_gdb.hh
trace.hh
DPRINTF
#define DPRINTF(x,...)
Definition
trace.hh:209
byteswap.hh
gem5::ArmISA::RemoteGDB::RemoteGDB
RemoteGDB(System *_system, ListenSocketConfig _listen_config)
Definition
remote_gdb.cc:204
gem5::BaseGdbRegCache
Concrete subclasses of this abstract class represent how the register values are transmitted on the w...
Definition
remote_gdb.hh:86
gem5::BaseRemoteGDB
Definition
remote_gdb.hh:49
gem5::BaseRemoteGDB::context
ThreadContext * context()
Definition
remote_gdb.hh:443
gem5::ListenSocketConfig
Definition
socket.hh:115
gem5::SparcISA::RemoteGDB::SPARC64GdbRegCache::setRegs
void setRegs(ThreadContext *) const
Set the ThreadContext's registers from the values in the raw buffer.
Definition
remote_gdb.cc:232
gem5::SparcISA::RemoteGDB::SPARC64GdbRegCache::pc
uint64_t pc
Definition
remote_gdb.hh:88
gem5::SparcISA::RemoteGDB::SPARC64GdbRegCache::getRegs
void getRegs(ThreadContext *)
Fill the raw buffer from the registers in the ThreadContext.
Definition
remote_gdb.cc:193
gem5::SparcISA::RemoteGDB::SPARC64GdbRegCache::r
struct gem5::SparcISA::RemoteGDB::SPARC64GdbRegCache::@277111046363350137356026323026356241320262103124 r
gem5::SparcISA::RemoteGDB::SPARCGdbRegCache::pc
uint32_t pc
Definition
remote_gdb.hh:63
gem5::SparcISA::RemoteGDB::SPARCGdbRegCache::getRegs
void getRegs(ThreadContext *)
Fill the raw buffer from the registers in the ThreadContext.
Definition
remote_gdb.cc:177
gem5::SparcISA::RemoteGDB::SPARCGdbRegCache::setRegs
void setRegs(ThreadContext *) const
Set the ThreadContext's registers from the values in the raw buffer.
Definition
remote_gdb.cc:215
gem5::SparcISA::RemoteGDB::SPARCGdbRegCache::r
struct gem5::SparcISA::RemoteGDB::SPARCGdbRegCache::@021024227317361326261356105121107021301012207067 r
gem5::SparcISA::RemoteGDB::gdbRegs
BaseGdbRegCache * gdbRegs()
gem5::SparcISA::RemoteGDB::regCache32
SPARCGdbRegCache regCache32
Definition
remote_gdb.hh:107
gem5::System
Definition
system.hh:75
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition
thread_context.hh:89
static_inst.hh
thread_context.hh
full_system.hh
intmath.hh
port.hh
Port Object Declaration.
gem5::ArmISA::i
Bitfield< 7 > i
Definition
misc_types.hh:67
gem5::ArmISA::va
Bitfield< 8 > va
Definition
misc_types.hh:357
gem5::SparcISA::int_reg::Y
constexpr RegId Y
Definition
int.hh:131
gem5::SparcISA::int_reg::Ccr
constexpr RegId Ccr
Definition
int.hh:132
gem5::SparcISA
Definition
asi.cc:35
gem5::SparcISA::MISCREG_CWP
@ MISCREG_CWP
Definition
misc.hh:70
gem5::SparcISA::MISCREG_PSTATE
@ MISCREG_PSTATE
Definition
misc.hh:67
gem5::SparcISA::MISCREG_FPRS
@ MISCREG_FPRS
Definition
misc.hh:49
gem5::SparcISA::MISCREG_ASI
@ MISCREG_ASI
Ancillary State Registers.
Definition
misc.hh:47
gem5::SparcISA::MISCREG_FSR
@ MISCREG_FSR
Floating Point Status Register.
Definition
misc.hh:88
gem5::SparcISA::intRegClass
constexpr RegClass intRegClass
Definition
int.hh:78
gem5::SparcISA::MachInst
uint32_t MachInst
Definition
types.hh:41
gem5::SparcISA::PCState
GenericISA::DelaySlotUPCState< 4 > PCState
Definition
pcstate.hh:40
gem5
Copyright (c) 2024 Arm Limited All rights reserved.
Definition
binary32.hh:36
gem5::htobe
T htobe(T value)
Definition
byteswap.hh:174
page_table.hh
Declarations of a non-full system Page Table.
physical.hh
process.hh
system.hh
socket.hh
int.hh
Generated on Mon May 26 2025 09:19:05 for gem5 by
doxygen
1.13.2