gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
remote_gdb.cc
Go to the documentation of this file.
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) 2002-2005 The Regents of The University of Michigan
17  * All rights reserved.
18  *
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions are
21  * met: redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer;
23  * redistributions in binary form must reproduce the above copyright
24  * notice, this list of conditions and the following disclaimer in the
25  * documentation and/or other materials provided with the distribution;
26  * neither the name of the copyright holders nor the names of its
27  * contributors may be used to endorse or promote products derived from
28  * this software without specific prior written permission.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  *
42  * Authors: Nathan Binkert
43  * William Wang
44  * Deyuan Guo
45  * Boris Shingarov
46  */
47 
48 /*
49  * Copyright (c) 1990, 1993 The Regents of the University of California
50  * All rights reserved
51  *
52  * This software was developed by the Computer Systems Engineering group
53  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
54  * contributed to Berkeley.
55  *
56  * All advertising materials mentioning features or use of this software
57  * must display the following acknowledgement:
58  * This product includes software developed by the University of
59  * California, Lawrence Berkeley Laboratories.
60  *
61  * Redistribution and use in source and binary forms, with or without
62  * modification, are permitted provided that the following conditions
63  * are met:
64  * 1. Redistributions of source code must retain the above copyright
65  * notice, this list of conditions and the following disclaimer.
66  * 2. Redistributions in binary form must reproduce the above copyright
67  * notice, this list of conditions and the following disclaimer in the
68  * documentation and/or other materials provided with the distribution.
69  * 3. All advertising materials mentioning features or use of this software
70  * must display the following acknowledgement:
71  * This product includes software developed by the University of
72  * California, Berkeley and its contributors.
73  * 4. Neither the name of the University nor the names of its contributors
74  * may be used to endorse or promote products derived from this software
75  * without specific prior written permission.
76  *
77  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
78  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
79  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
80  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
81  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
82  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
83  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
84  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
85  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
86  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
87  * SUCH DAMAGE.
88  *
89  * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94
90  */
91 
92 /*-
93  * Copyright (c) 2001 The NetBSD Foundation, Inc.
94  * All rights reserved.
95  *
96  * This code is derived from software contributed to The NetBSD Foundation
97  * by Jason R. Thorpe.
98  *
99  * Redistribution and use in source and binary forms, with or without
100  * modification, are permitted provided that the following conditions
101  * are met:
102  * 1. Redistributions of source code must retain the above copyright
103  * notice, this list of conditions and the following disclaimer.
104  * 2. Redistributions in binary form must reproduce the above copyright
105  * notice, this list of conditions and the following disclaimer in the
106  * documentation and/or other materials provided with the distribution.
107  * 3. All advertising materials mentioning features or use of this software
108  * must display the following acknowledgement:
109  * This product includes software developed by the NetBSD
110  * Foundation, Inc. and its contributors.
111  * 4. Neither the name of The NetBSD Foundation nor the names of its
112  * contributors may be used to endorse or promote products derived
113  * from this software without specific prior written permission.
114  *
115  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
116  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
117  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
118  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
119  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
120  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
121  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
122  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
123  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
124  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
125  * POSSIBILITY OF SUCH DAMAGE.
126  */
127 
128 /*
129  * $NetBSD: kgdb_stub.c,v 1.8 2001/07/07 22:58:00 wdk Exp $
130  *
131  * Taken from NetBSD
132  *
133  * "Stub" to allow remote cpu to debug over a serial line using gdb.
134  */
135 
136 
137 #include "arch/power/remote_gdb.hh"
138 
139 #include <sys/signal.h>
140 #include <unistd.h>
141 
142 #include <string>
143 
144 #include "arch/power/vtophys.hh"
145 #include "cpu/thread_state.hh"
146 #include "debug/GDBAcc.hh"
147 #include "debug/GDBMisc.hh"
148 #include "mem/page_table.hh"
149 #include "sim/byteswap.hh"
150 
151 using namespace std;
152 using namespace PowerISA;
153 
154 RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
155  : BaseRemoteGDB(_system, tc), regCache(this)
156 {
157 }
158 
159 /*
160  * Determine if the mapping at va..(va+len) is valid.
161  */
162 bool
164 {
165  TlbEntry entry;
166  //Check to make sure the first byte is mapped into the processes address
167  //space. At the time of this writing, the acc() check is used when
168  //processing the MemR/MemW packets before actually asking the translating
169  //port proxy to read/writeBlob. I (bgs) am not convinced the first byte
170  //check is enough.
171  if (FullSystem)
172  panic("acc not implemented for POWER FS!");
173  else
174  return context->getProcessPtr()->pTable->lookup(va, entry);
175 }
176 
177 void
179 {
180  DPRINTF(GDBAcc, "getRegs in remotegdb \n");
181 
182  // Default order on 32-bit PowerPC:
183  // R0-R31 (32-bit each), F0-F31 (64-bit IEEE754 double),
184  // PC, MSR, CR, LR, CTR, XER (32-bit each)
185 
186  for (int i = 0; i < NumIntArchRegs; i++)
187  r.gpr[i] = htobe((uint32_t)context->readIntReg(i));
188 
189  for (int i = 0; i < NumFloatArchRegs; i++)
190  r.fpr[i] = context->readFloatRegBits(i);
191 
192  r.pc = htobe((uint32_t)context->pcState().pc());
193  r.msr = 0; // Is MSR modeled?
194  r.cr = htobe((uint32_t)context->readIntReg(INTREG_CR));
195  r.lr = htobe((uint32_t)context->readIntReg(INTREG_LR));
196  r.ctr = htobe((uint32_t)context->readIntReg(INTREG_CTR));
197  r.xer = htobe((uint32_t)context->readIntReg(INTREG_XER));
198 }
199 
200 void
202 {
203  DPRINTF(GDBAcc, "setRegs in remotegdb \n");
204 
205  for (int i = 0; i < NumIntArchRegs; i++)
206  context->setIntReg(i, betoh(r.gpr[i]));
207 
208  for (int i = 0; i < NumFloatArchRegs; i++)
209  context->setFloatRegBits(i, r.fpr[i]);
210 
211  context->pcState(betoh(r.pc));
212  // Is MSR modeled?
213  context->setIntReg(INTREG_CR, betoh(r.cr));
214  context->setIntReg(INTREG_LR, betoh(r.lr));
215  context->setIntReg(INTREG_CTR, betoh(r.ctr));
216  context->setIntReg(INTREG_XER, betoh(r.xer));
217 }
218 
221  return &regCache;
222 }
223 
#define DPRINTF(x,...)
Definition: trace.hh:212
Bitfield< 7 > i
Definition: miscregs.hh:1378
#define panic(...)
Definition: misc.hh:153
void setRegs(ThreadContext *) const
Definition: remote_gdb.cc:201
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:146
virtual Process * getProcessPtr()=0
Definition: system.hh:83
virtual void setIntReg(int reg_idx, uint64_t val)=0
virtual FloatRegBits readFloatRegBits(int reg_idx)=0
virtual TheISA::PCState pcState()=0
ThreadContext is the external interface to all thread state for anything outside of the CPU...
const int NumFloatArchRegs
Definition: registers.hh:64
Concrete subclasses of this abstract class represent how the register values are transmitted on the w...
Definition: remote_gdb.hh:183
virtual void setFloatRegBits(int reg_idx, FloatRegBits val)=0
ThreadContext * context
Definition: remote_gdb.hh:173
virtual uint64_t readIntReg(int reg_idx)=0
BaseGdbRegCache * gdbRegs()
Definition: remote_gdb.cc:220
struct PowerISA::RemoteGDB::PowerGdbRegCache::@19 r
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Bitfield< 8 > va
Definition: miscregs.hh:1473
PowerGdbRegCache regCache
Definition: remote_gdb.hh:79
PageTableBase * pTable
Definition: process.hh:178
bool acc(Addr addr, size_t len)
Definition: remote_gdb.cc:163
const int NumIntArchRegs
Definition: registers.hh:59
Declarations of a non-full system Page Table.
T htobe(T value)
Definition: byteswap.hh:153
virtual bool lookup(Addr vaddr, TheISA::TlbEntry &entry)=0
Lookup function.
Bitfield< 18, 16 > len
Definition: miscregs.hh:1626
T betoh(T value)
Definition: byteswap.hh:154

Generated on Fri Jun 9 2017 13:03:36 for gem5 by doxygen 1.8.6