gem5  v21.0.1.0
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/registers.hh"
39 #include "base/remote_gdb.hh"
40 
41 class System;
42 class ThreadContext;
43 
44 namespace RiscvISA
45 {
46 
47 class RemoteGDB : public BaseRemoteGDB
48 {
49  protected:
50  static const int NumGDBRegs = 4162;
51  static const int NumCSRs = 4096;
52 
53  bool acc(Addr addr, size_t len) override;
54  // A breakpoint will be 2 bytes if it is compressed and 4 if not
55  bool checkBpLen(size_t len) override { return len == 2 || len == 4; }
56 
58  {
60  private:
69  struct {
70  uint64_t gpr[NumIntArchRegs];
71  uint64_t pc;
72  uint64_t fpu[NumFloatRegs];
73  uint32_t fflags;
74  uint32_t frm;
75  uint32_t fcsr;
76  // Placeholder for byte alignment
77  uint32_t placeholder;
78  uint64_t cycle;
79  uint64_t time;
80  uint64_t ustatus;
81  uint64_t uie;
82  uint64_t utvec;
83  uint64_t uscratch;
84  uint64_t uepc;
85  uint64_t ucause;
86  uint64_t utval;
87  uint64_t uip;
88  uint64_t sstatus;
89  uint64_t sedeleg;
90  uint64_t sideleg;
91  uint64_t sie;
92  uint64_t stvec;
93  uint64_t scounteren;
94  uint64_t sscratch;
95  uint64_t sepc;
96  uint64_t scause;
97  uint64_t stval;
98  uint64_t sip;
99  uint64_t satp;
100  uint64_t mvendorid;
101  uint64_t marchid;
102  uint64_t mimpid;
103  uint64_t mhartid;
104  uint64_t mstatus;
105  uint64_t misa;
106  uint64_t medeleg;
107  uint64_t mideleg;
108  uint64_t mie;
109  uint64_t mtvec;
110  uint64_t mcounteren;
111  uint64_t mscratch;
112  uint64_t mepc;
113  uint64_t mcause;
114  uint64_t mtval;
115  uint64_t mip;
116  uint64_t hstatus;
117  uint64_t hedeleg;
118  uint64_t hideleg;
119  uint64_t hie;
120  uint64_t htvec;
121  uint64_t hscratch;
122  uint64_t hepc;
123  uint64_t hcause;
124  uint64_t hbadaddr;
125  uint64_t hip;
126  } r;
127  public:
128  char *data() const { return (char *)&r; }
129  size_t size() const { return sizeof(r); }
130  void getRegs(ThreadContext*);
131  void setRegs(ThreadContext*) const;
132 
133  const std::string
134  name() const
135  {
136  return gdb->name() + ".RiscvGdbRegCache";
137  }
138  };
139 
141 
142  public:
143  RemoteGDB(System *_system, ThreadContext *tc, int _port);
144  BaseGdbRegCache *gdbRegs() override;
150  availableFeatures() const override
151  {
152  return {"qXfer:features:read+"};
153  };
157  bool getXferFeaturesRead(const std::string &annex,
158  std::string &output) override;
159 };
160 
161 } // namespace RiscvISA
162 
163 #endif /* __ARCH_RISCV_REMOTE_GDB_H__ */
RiscvISA::RemoteGDB::RiscvGdbRegCache::satp
uint64_t satp
Definition: remote_gdb.hh:99
RiscvISA::RemoteGDB::RiscvGdbRegCache::placeholder
uint32_t placeholder
Definition: remote_gdb.hh:77
output
static void output(const char *filename)
Definition: debug.cc:60
RiscvISA::RemoteGDB::RiscvGdbRegCache::sepc
uint64_t sepc
Definition: remote_gdb.hh:95
RiscvISA::RemoteGDB::RiscvGdbRegCache::mcounteren
uint64_t mcounteren
Definition: remote_gdb.hh:110
RiscvISA::RemoteGDB::RiscvGdbRegCache::uip
uint64_t uip
Definition: remote_gdb.hh:87
RiscvISA::RemoteGDB::RiscvGdbRegCache
Definition: remote_gdb.hh:57
RiscvISA::RemoteGDB::RiscvGdbRegCache::mtvec
uint64_t mtvec
Definition: remote_gdb.hh:109
RiscvISA::RemoteGDB::getXferFeaturesRead
bool getXferFeaturesRead(const std::string &annex, std::string &output) override
Reply to qXfer:features:read:xxx.xml qeuries.
Definition: remote_gdb.cc:458
RiscvISA::RemoteGDB::RiscvGdbRegCache::stval
uint64_t stval
Definition: remote_gdb.hh:97
RiscvISA::RemoteGDB::RiscvGdbRegCache::mip
uint64_t mip
Definition: remote_gdb.hh:115
RiscvISA::RemoteGDB::RiscvGdbRegCache::hip
uint64_t hip
Definition: remote_gdb.hh:125
RiscvISA::RemoteGDB::RiscvGdbRegCache::sedeleg
uint64_t sedeleg
Definition: remote_gdb.hh:89
RiscvISA::RemoteGDB::availableFeatures
std::vector< std::string > availableFeatures() const override
Informs GDB remote serial protocol that XML features are supported GDB then queries for xml blobs usi...
Definition: remote_gdb.hh:150
RiscvISA::RemoteGDB::RiscvGdbRegCache::marchid
uint64_t marchid
Definition: remote_gdb.hh:101
RiscvISA::RemoteGDB::RiscvGdbRegCache::frm
uint32_t frm
Definition: remote_gdb.hh:74
RiscvISA::RemoteGDB::RiscvGdbRegCache::mepc
uint64_t mepc
Definition: remote_gdb.hh:112
RiscvISA::RemoteGDB::RiscvGdbRegCache::fflags
uint32_t fflags
Definition: remote_gdb.hh:73
RiscvISA::RemoteGDB::NumCSRs
static const int NumCSRs
Definition: remote_gdb.hh:51
remote_gdb.hh
RiscvISA::RemoteGDB::RiscvGdbRegCache::uepc
uint64_t uepc
Definition: remote_gdb.hh:84
RiscvISA::RemoteGDB::RiscvGdbRegCache::mie
uint64_t mie
Definition: remote_gdb.hh:108
RiscvISA::RemoteGDB::RiscvGdbRegCache::mscratch
uint64_t mscratch
Definition: remote_gdb.hh:111
RiscvISA::RemoteGDB::RiscvGdbRegCache::fcsr
uint32_t fcsr
Definition: remote_gdb.hh:75
RiscvISA::RemoteGDB::RiscvGdbRegCache::scause
uint64_t scause
Definition: remote_gdb.hh:96
RiscvISA::RemoteGDB::RiscvGdbRegCache::sie
uint64_t sie
Definition: remote_gdb.hh:91
RiscvISA::RemoteGDB::RiscvGdbRegCache::getRegs
void getRegs(ThreadContext *)
Fill the raw buffer from the registers in the ThreadContext.
Definition: remote_gdb.cc:184
RiscvISA::RemoteGDB::RiscvGdbRegCache::r
struct RiscvISA::RemoteGDB::RiscvGdbRegCache::@15 r
RISC-V Register Cache Order and sizes of registers found in ext/gdb-xml/riscv.xml To add support for ...
RiscvISA::RemoteGDB::RiscvGdbRegCache::hepc
uint64_t hepc
Definition: remote_gdb.hh:122
BaseGdbRegCache::gdb
BaseRemoteGDB * gdb
Definition: remote_gdb.hh:127
BaseGdbRegCache::BaseGdbRegCache
BaseGdbRegCache(BaseRemoteGDB *g)
Definition: remote_gdb.hh:121
std::vector< std::string >
RiscvISA::RemoteGDB::RiscvGdbRegCache::uscratch
uint64_t uscratch
Definition: remote_gdb.hh:83
RiscvISA::RemoteGDB::RiscvGdbRegCache::setRegs
void setRegs(ThreadContext *) const
Set the ThreadContext's registers from the values in the raw buffer.
Definition: remote_gdb.cc:293
RiscvISA::RemoteGDB::RiscvGdbRegCache::hstatus
uint64_t hstatus
Definition: remote_gdb.hh:116
RiscvISA::RemoteGDB::gdbRegs
BaseGdbRegCache * gdbRegs() override
Definition: remote_gdb.cc:485
RiscvISA::RemoteGDB::RiscvGdbRegCache::sscratch
uint64_t sscratch
Definition: remote_gdb.hh:94
RiscvISA::RemoteGDB::RiscvGdbRegCache::size
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).
Definition: remote_gdb.hh:129
BaseRemoteGDB::tc
ThreadContext * tc
Definition: remote_gdb.hh:214
RiscvISA::RemoteGDB::RiscvGdbRegCache::pc
uint64_t pc
Definition: remote_gdb.hh:71
RiscvISA
Definition: fs_workload.cc:37
RiscvISA::RemoteGDB::RiscvGdbRegCache::mtval
uint64_t mtval
Definition: remote_gdb.hh:114
RiscvISA::RemoteGDB::RiscvGdbRegCache::utvec
uint64_t utvec
Definition: remote_gdb.hh:82
RiscvISA::RemoteGDB::checkBpLen
bool checkBpLen(size_t len) override
Definition: remote_gdb.hh:55
RiscvISA::RemoteGDB::RiscvGdbRegCache::hscratch
uint64_t hscratch
Definition: remote_gdb.hh:121
RiscvISA::RemoteGDB::RiscvGdbRegCache::mideleg
uint64_t mideleg
Definition: remote_gdb.hh:107
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
RiscvISA::RemoteGDB::RiscvGdbRegCache::cycle
uint64_t cycle
Definition: remote_gdb.hh:78
System
Definition: system.hh:73
BaseRemoteGDB::_port
int _port
Definition: remote_gdb.hh:195
RiscvISA::RemoteGDB::RiscvGdbRegCache::hie
uint64_t hie
Definition: remote_gdb.hh:119
RiscvISA::RemoteGDB::RiscvGdbRegCache::data
char * data() const
Return the pointer to the raw bytes buffer containing the register values.
Definition: remote_gdb.hh:128
RiscvISA::RemoteGDB::RiscvGdbRegCache::sstatus
uint64_t sstatus
Definition: remote_gdb.hh:88
RiscvISA::RemoteGDB::RiscvGdbRegCache::hbadaddr
uint64_t hbadaddr
Definition: remote_gdb.hh:124
RiscvISA::RemoteGDB::acc
bool acc(Addr addr, size_t len) override
Definition: remote_gdb.cc:159
RiscvISA::RemoteGDB::RiscvGdbRegCache::mcause
uint64_t mcause
Definition: remote_gdb.hh:113
RiscvISA::RemoteGDB::RiscvGdbRegCache::ucause
uint64_t ucause
Definition: remote_gdb.hh:85
RiscvISA::RemoteGDB::RiscvGdbRegCache::stvec
uint64_t stvec
Definition: remote_gdb.hh:92
RiscvISA::NumIntArchRegs
const int NumIntArchRegs
Definition: registers.hh:109
BaseRemoteGDB
Definition: remote_gdb.hh:43
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
BaseGdbRegCache
Concrete subclasses of this abstract class represent how the register values are transmitted on the w...
Definition: remote_gdb.hh:72
registers.hh
RiscvISA::RemoteGDB::RiscvGdbRegCache::medeleg
uint64_t medeleg
Definition: remote_gdb.hh:106
RiscvISA::RemoteGDB::RiscvGdbRegCache::misa
uint64_t misa
Definition: remote_gdb.hh:105
RiscvISA::RemoteGDB::RiscvGdbRegCache::mhartid
uint64_t mhartid
Definition: remote_gdb.hh:103
RiscvISA::RemoteGDB::RiscvGdbRegCache::scounteren
uint64_t scounteren
Definition: remote_gdb.hh:93
RiscvISA::RemoteGDB::RiscvGdbRegCache::ustatus
uint64_t ustatus
Definition: remote_gdb.hh:80
X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:80
RiscvISA::RemoteGDB
Definition: remote_gdb.hh:47
RiscvISA::RemoteGDB::regCache
RiscvGdbRegCache regCache
Definition: remote_gdb.hh:140
RiscvISA::RemoteGDB::RiscvGdbRegCache::hcause
uint64_t hcause
Definition: remote_gdb.hh:123
RiscvISA::RemoteGDB::NumGDBRegs
static const int NumGDBRegs
Definition: remote_gdb.hh:50
RiscvISA::RemoteGDB::RiscvGdbRegCache::fpu
uint64_t fpu[NumFloatRegs]
Definition: remote_gdb.hh:72
RiscvISA::RemoteGDB::RiscvGdbRegCache::name
const std::string name() const
Return the name to use in places like DPRINTF.
Definition: remote_gdb.hh:134
RiscvISA::RemoteGDB::RiscvGdbRegCache::mimpid
uint64_t mimpid
Definition: remote_gdb.hh:102
RiscvISA::RemoteGDB::RiscvGdbRegCache::gpr
uint64_t gpr[NumIntArchRegs]
Definition: remote_gdb.hh:70
ArmISA::len
Bitfield< 18, 16 > len
Definition: miscregs_types.hh:439
RiscvISA::RemoteGDB::RiscvGdbRegCache::mvendorid
uint64_t mvendorid
Definition: remote_gdb.hh:100
RiscvISA::RemoteGDB::RiscvGdbRegCache::sideleg
uint64_t sideleg
Definition: remote_gdb.hh:90
RiscvISA::NumFloatRegs
const int NumFloatRegs
Definition: registers.hh:112
BaseRemoteGDB::name
std::string name()
Definition: remote_gdb.cc:328
RiscvISA::RemoteGDB::RiscvGdbRegCache::time
uint64_t time
Definition: remote_gdb.hh:79
RiscvISA::RemoteGDB::RiscvGdbRegCache::hedeleg
uint64_t hedeleg
Definition: remote_gdb.hh:117
RiscvISA::RemoteGDB::RiscvGdbRegCache::uie
uint64_t uie
Definition: remote_gdb.hh:81
RiscvISA::RemoteGDB::RiscvGdbRegCache::utval
uint64_t utval
Definition: remote_gdb.hh:86
RiscvISA::RemoteGDB::RiscvGdbRegCache::hideleg
uint64_t hideleg
Definition: remote_gdb.hh:118
RiscvISA::RemoteGDB::RiscvGdbRegCache::sip
uint64_t sip
Definition: remote_gdb.hh:98
RiscvISA::RemoteGDB::RemoteGDB
RemoteGDB(System *_system, ThreadContext *tc, int _port)
Definition: remote_gdb.cc:153
RiscvISA::RemoteGDB::RiscvGdbRegCache::mstatus
uint64_t mstatus
Definition: remote_gdb.hh:104
RiscvISA::RemoteGDB::RiscvGdbRegCache::htvec
uint64_t htvec
Definition: remote_gdb.hh:120

Generated on Tue Jun 22 2021 15:28:21 for gem5 by doxygen 1.8.17