gem5 v24.1.0.1
Loading...
Searching...
No Matches
remote_gdb.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Huawei International
3 * Copyright (c) 2017 The University of Virginia
4 * Copyright 2015 LabWare
5 * Copyright 2014 Google, Inc.
6 * Copyright (c) 2007 The Regents of The University of Michigan
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are
11 * met: redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer;
13 * redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution;
16 * neither the name of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef __ARCH_RISCV_REMOTE_GDB_HH__
34#define __ARCH_RISCV_REMOTE_GDB_HH__
35
36#include <string>
37
38#include "arch/riscv/isa.hh"
42#include "base/remote_gdb.hh"
43
44namespace gem5
45{
46
47class System;
48class ThreadContext;
49
50namespace RiscvISA
51{
52
54{
55 protected:
56 static const int NumGDBRegs = 4162;
57 static const int NumCSRs = 4096;
58
59 bool acc(Addr addr, size_t len) override;
60 // A breakpoint will be 2 bytes if it is compressed and 4 if not
61 bool checkBpKind(size_t kind) override { return kind == 2 || kind == 4; }
62 void insertHardBreak(Addr addr, size_t kind) override;
63 void removeHardBreak(Addr addr, size_t kind) override;
64
66 {
68 protected:
78 {
80 uint32_t pc;
82 uint32_t fflags;
83 uint32_t frm;
84 uint32_t fcsr;
85 // Placeholder for byte alignment
86 uint32_t placeholder;
87 uint32_t cycle;
88 uint32_t time;
89 uint32_t cycleh;
90 uint32_t timeh;
91 uint32_t ustatus;
92 uint32_t uie;
93 uint32_t utvec;
94 uint32_t uscratch;
95 uint32_t uepc;
96 uint32_t ucause;
97 uint32_t utval;
98 uint32_t uip;
99 uint32_t sstatus;
100 uint32_t sedeleg;
101 uint32_t sideleg;
102 uint32_t sie;
103 uint32_t stvec;
104 uint32_t scounteren;
105 uint32_t sscratch;
106 uint32_t sepc;
107 uint32_t scause;
108 uint32_t stval;
109 uint32_t sip;
110 uint32_t satp;
111 uint32_t senvcfg;
112 uint32_t mvendorid;
113 uint32_t marchid;
114 uint32_t mimpid;
115 uint32_t mhartid;
116 uint32_t mstatus;
117 uint32_t misa;
118 uint32_t medeleg;
119 uint32_t mideleg;
120 uint32_t mie;
121 uint32_t mtvec;
122 uint32_t mcounteren;
123 uint32_t mstatush;
124 uint32_t mscratch;
125 uint32_t mepc;
126 uint32_t mcause;
127 uint32_t mtval;
128 uint32_t mip;
129 uint32_t hstatus;
130 uint32_t hedeleg;
131 uint32_t hideleg;
132 uint32_t hie;
133 uint32_t htvec;
134 uint32_t hscratch;
135 uint32_t hepc;
136 uint32_t hcause;
137 uint32_t hbadaddr;
138 uint32_t hip;
139 } r;
140 public:
141 char *data() { return (char *)&r; }
142 size_t size() const { return sizeof(r); }
143 void getRegs(ThreadContext*);
144 void setRegs(ThreadContext*) const;
145
146 const std::string
147 name() const
148 {
149 return gdb->name() + ".RiscvGdbRegCache";
150 }
151 };
153 {
155 protected:
165 {
167 uint64_t pc;
169 uint32_t fflags;
170 uint32_t frm;
171 uint32_t fcsr;
172 // Placeholder for byte alignment
173 uint32_t placeholder;
174 uint64_t cycle;
175 uint64_t time;
176 uint64_t ustatus;
177 uint64_t uie;
178 uint64_t utvec;
179 uint64_t uscratch;
180 uint64_t uepc;
181 uint64_t ucause;
182 uint64_t utval;
183 uint64_t uip;
184 uint64_t sstatus;
185 uint64_t sedeleg;
186 uint64_t sideleg;
187 uint64_t sie;
188 uint64_t stvec;
189 uint64_t scounteren;
190 uint64_t sscratch;
191 uint64_t sepc;
192 uint64_t scause;
193 uint64_t stval;
194 uint64_t sip;
195 uint64_t satp;
196 uint64_t senvcfg;
197 uint64_t mvendorid;
198 uint64_t marchid;
199 uint64_t mimpid;
200 uint64_t mhartid;
201 uint64_t mstatus;
202 uint64_t misa;
203 uint64_t medeleg;
204 uint64_t mideleg;
205 uint64_t mie;
206 uint64_t mtvec;
207 uint64_t mcounteren;
208 uint64_t mscratch;
209 uint64_t mepc;
210 uint64_t mcause;
211 uint64_t mtval;
212 uint64_t mip;
213 uint64_t hstatus;
214 uint64_t hedeleg;
215 uint64_t hideleg;
216 uint64_t hie;
217 uint64_t htvec;
218 uint64_t hscratch;
219 uint64_t hepc;
220 uint64_t hcause;
221 uint64_t hbadaddr;
222 uint64_t hip;
223 } r;
224 public:
225 char *data() { return (char *)&r; }
226 size_t size() const { return sizeof(r); }
227 void getRegs(ThreadContext*);
228 void setRegs(ThreadContext*) const;
229
230 const std::string
231 name() const
232 {
233 return gdb->name() + ".RiscvGdbRegCache";
234 }
235 };
236
239
240 public:
241 RemoteGDB(System *_system, ListenSocketConfig _listen_config);
248 availableFeatures() const override
249 {
250 return {"qXfer:features:read+"};
251 };
255 bool getXferFeaturesRead(const std::string &annex,
256 std::string &output) override;
257
259
261};
262
263} // namespace RiscvISA
264} // namespace gem5
265
266#endif /* __ARCH_RISCV_REMOTE_GDB_H__ */
Concrete subclasses of this abstract class represent how the register values are transmitted on the w...
Definition remote_gdb.hh:86
BaseRemoteGDB * gdb
ThreadContext * tc
void getRegs(ThreadContext *)
Fill the raw buffer from the registers in the ThreadContext.
void setRegs(ThreadContext *) const
Set the ThreadContext's registers from the values in the raw buffer.
size_t size() const
Return the size of the raw buffer, in bytes (i.e., half of the number of digits in the g/G packet).
const std::string name() const
Return the name to use in places like DPRINTF.
char * data()
Return the pointer to the raw bytes buffer containing the register values.
struct gem5::RiscvISA::RemoteGDB::Riscv32GdbRegCache::GEM5_PACKED r
void getRegs(ThreadContext *)
Fill the raw buffer from the registers in the ThreadContext.
struct gem5::RiscvISA::RemoteGDB::Riscv64GdbRegCache::GEM5_PACKED r
size_t size() const
Return the size of the raw buffer, in bytes (i.e., half of the number of digits in the g/G packet).
char * data()
Return the pointer to the raw bytes buffer containing the register values.
const std::string name() const
Return the name to use in places like DPRINTF.
void setRegs(ThreadContext *) const
Set the ThreadContext's registers from the values in the raw buffer.
void removeHardBreak(Addr addr, size_t kind) override
BaseGdbRegCache * gdbRegs() override
static const int NumCSRs
Definition remote_gdb.hh:57
virtual PrivilegeModeSet getPrivilegeModeSet(ThreadContext *tc)
std::vector< std::string > availableFeatures() const override
Informs GDB remote serial protocol that XML features are supported GDB then queries for xml blobs usi...
bool getXferFeaturesRead(const std::string &annex, std::string &output) override
Reply to qXfer:features:read:xxx.xml qeuries.
bool acc(Addr addr, size_t len) override
static const int NumGDBRegs
Definition remote_gdb.hh:56
bool checkBpKind(size_t kind) override
Definition remote_gdb.hh:61
void insertHardBreak(Addr addr, size_t kind) override
Riscv32GdbRegCache regCache32
Riscv64GdbRegCache regCache64
virtual RiscvType getRvType(ThreadContext *tc)
RemoteGDB(System *_system, ListenSocketConfig _listen_config)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
STL vector class.
Definition stl.hh:37
BaseGdbRegCache(BaseRemoteGDB *g)
std::string name()
Bitfield< 18, 16 > len
enums::RiscvType RiscvType
Definition pcstate.hh:55
enums::PrivilegeModeSet PrivilegeModeSet
Definition pcstate.hh:59
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
static void output(const char *filename)
Definition debug.cc:60
RISC-V Register Cache Order and sizes of registers found in ext/gdb-xml/riscv.xml To add support for ...
Definition remote_gdb.hh:78
RISC-V Register Cache Order and sizes of registers found in ext/gdb-xml/riscv.xml To add support for ...

Generated on Mon Jan 13 2025 04:28:30 for gem5 by doxygen 1.9.8