remote_gdb.cc (11723:0596db108c53) remote_gdb.cc (11963:3fb6bb58e6a4)
1/*
1/*
2 * Copyright 2015 LabWare
3 * Copyright 2014 Google, Inc.
4 * Copyright (c) 2010 ARM Limited
5 * All rights reserved
6 *
7 * The license below extends only to copyright in the software and shall
8 * not be construed as granting a license to any other intellectual
9 * property including but not limited to intellectual property relating
10 * to a hardware implementation of the functionality of the software
11 * licensed hereunder. You may use the software subject to the license
12 * terms below provided that you ensure that this notice is replicated
13 * unmodified and in its entirety in all distributions of the software,
14 * modified or unmodified, in source code or in binary form.
15 *
16 * Copyright (c) 2017 The University of Virginia
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
17 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * Copyright (c) 2007-2008 The Florida State University
4 * Copyright (c) 2009 The University of Edinburgh
5 * Copyright (c) 2015 Sven Karlsson
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met: redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer;
12 * redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the

--- 10 unchanged lines hidden (view full) ---

24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 * Authors: Nathan Binkert
18 * All rights reserved.
19 *
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions are
22 * met: redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer;
24 * redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in the

--- 10 unchanged lines hidden (view full) ---

36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 *
43 * Authors: Nathan Binkert
32 * Stephen Hines
33 * Timothy M. Jones
34 * Sven Karlsson
44 * William Wang
45 * Deyuan Guo
46 * Boris Shingarov
47 * Alec Roelke
35 */
36
48 */
49
37 #include "base/remote_gdb.hh"
38 #include "arch/riscv/remote_gdb.hh"
39 #include "sim/system.hh"
50/*
51 * Copyright (c) 1990, 1993 The Regents of the University of California
52 * All rights reserved
53 *
54 * This software was developed by the Computer Systems Engineering group
55 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
56 * contributed to Berkeley.
57 *
58 * All advertising materials mentioning features or use of this software
59 * must display the following acknowledgement:
60 * This product includes software developed by the University of
61 * California, Lawrence Berkeley Laboratories.
62 *
63 * Redistribution and use in source and binary forms, with or without
64 * modification, are permitted provided that the following conditions
65 * are met:
66 * 1. Redistributions of source code must retain the above copyright
67 * notice, this list of conditions and the following disclaimer.
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in the
70 * documentation and/or other materials provided with the distribution.
71 * 3. All advertising materials mentioning features or use of this software
72 * must display the following acknowledgement:
73 * This product includes software developed by the University of
74 * California, Berkeley and its contributors.
75 * 4. Neither the name of the University nor the names of its contributors
76 * may be used to endorse or promote products derived from this software
77 * without specific prior written permission.
78 *
79 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
80 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
81 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
82 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
83 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
84 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
85 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
86 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
87 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
88 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
89 * SUCH DAMAGE.
90 *
91 * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94
92 */
40
93
94/*-
95 * Copyright (c) 2001 The NetBSD Foundation, Inc.
96 * All rights reserved.
97 *
98 * This code is derived from software contributed to The NetBSD Foundation
99 * by Jason R. Thorpe.
100 *
101 * Redistribution and use in source and binary forms, with or without
102 * modification, are permitted provided that the following conditions
103 * are met:
104 * 1. Redistributions of source code must retain the above copyright
105 * notice, this list of conditions and the following disclaimer.
106 * 2. Redistributions in binary form must reproduce the above copyright
107 * notice, this list of conditions and the following disclaimer in the
108 * documentation and/or other materials provided with the distribution.
109 * 3. All advertising materials mentioning features or use of this software
110 * must display the following acknowledgement:
111 * This product includes software developed by the NetBSD
112 * Foundation, Inc. and its contributors.
113 * 4. Neither the name of The NetBSD Foundation nor the names of its
114 * contributors may be used to endorse or promote products derived
115 * from this software without specific prior written permission.
116 *
117 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
118 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
119 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
120 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
121 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
122 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
123 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
124 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
125 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
126 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
127 * POSSIBILITY OF SUCH DAMAGE.
128 */
129
130/*
131 * $NetBSD: kgdb_stub.c,v 1.8 2001/07/07 22:58:00 wdk Exp $
132 *
133 * Taken from NetBSD
134 *
135 * "Stub" to allow remote cpu to debug over a serial line using gdb.
136 */
137
138#include "arch/riscv/remote_gdb.hh"
139
140#include <string>
141
142#include "arch/riscv/registers.hh"
143#include "cpu/thread_state.hh"
144#include "debug/GDBAcc.hh"
145#include "mem/page_table.hh"
146#include "sim/full_system.hh"
147
41using namespace std;
42using namespace RiscvISA;
43
148using namespace std;
149using namespace RiscvISA;
150
44RemoteGDB::RemoteGDB(System *system, ThreadContext *context)
45 : BaseRemoteGDB(system, context)
151RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
152 : BaseRemoteGDB(_system, tc)
46{
47}
48
153{
154}
155
49RemoteGDB::BaseGdbRegCache*
50RemoteGDB::gdbRegs()
51{
52 panic("gdbRegs not implemented for Riscv!");
53}
54
55bool
156bool
56RemoteGDB::acc(Addr, size_t)
157RemoteGDB::acc(Addr va, size_t len)
57{
158{
58 panic("acc not implemented for Riscv!");
159 TlbEntry entry;
160 if (FullSystem)
161 panic("acc not implemented for RISCV FS!");
162 else
163 return context->getProcessPtr()->pTable->lookup(va, entry);
59}
60
61void
164}
165
166void
62RemoteGDB::getregs()
167RemoteGDB::RiscvGdbRegCache::getRegs(ThreadContext *context)
63{
168{
64 panic("getregs not implemented for Riscv!");
169 DPRINTF(GDBAcc, "getregs in remotegdb, size %lu\n", size());
170 for (int i = 0; i < NumIntArchRegs; i++)
171 r.gpr[i] = context->readIntReg(i);
172 r.pc = context->pcState().pc();
173 for (int i = 0; i < NumFloatRegs; i++)
174 r.fpr[i] = context->readFloatRegBits(i);
175
176 r.csr_base = context->readMiscReg(0);
177 r.fflags = context->readMiscReg(MISCREG_FFLAGS);
178 r.frm = context->readMiscReg(MISCREG_FRM);
179 r.fcsr = context->readMiscReg(MISCREG_FCSR);
180 for (int i = ExplicitCSRs; i < NumMiscRegs; i++)
181 r.csr[i - ExplicitCSRs] = context->readMiscReg(i);
65}
66
67void
182}
183
184void
68RemoteGDB::setregs()
185RemoteGDB::RiscvGdbRegCache::setRegs(ThreadContext *context) const
69{
186{
70 panic("setregs not implemented for Riscv!");
187 DPRINTF(GDBAcc, "setregs in remotegdb \n");
188 for (int i = 0; i < NumIntArchRegs; i++)
189 context->setIntReg(i, r.gpr[i]);
190 context->pcState(r.pc);
191 for (int i = 0; i < NumFloatRegs; i++)
192 context->setFloatRegBits(i, r.fpr[i]);
193
194 context->setMiscReg(0, r.csr_base);
195 context->setMiscReg(MISCREG_FFLAGS, r.fflags);
196 context->setMiscReg(MISCREG_FRM, r.frm);
197 context->setMiscReg(MISCREG_FCSR, r.fcsr);
198 for (int i = ExplicitCSRs; i < NumMiscRegs; i++)
199 context->setMiscReg(i, r.csr[i - ExplicitCSRs]);
71}
200}
201
202RemoteGDB::BaseGdbRegCache*
203RemoteGDB::gdbRegs() {
204 return new RiscvGdbRegCache(this);
205}