remote_gdb.cc (10601:6efb37480d87) remote_gdb.cc (11274:d9a0136ab8cc)
1/*
2 * Copyright 2014 Google, Inc.
3 * Copyright (c) 2002-2005 The Regents of The University of Michigan
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

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

119
120#include <sys/signal.h>
121#include <unistd.h>
122
123#include <string>
124
125
126#include "arch/alpha/decoder.hh"
1/*
2 * Copyright 2014 Google, Inc.
3 * Copyright (c) 2002-2005 The Regents of The University of Michigan
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

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

119
120#include <sys/signal.h>
121#include <unistd.h>
122
123#include <string>
124
125
126#include "arch/alpha/decoder.hh"
127#include "arch/alpha/kgdb.h"
128#include "arch/alpha/regredir.hh"
129#include "arch/alpha/remote_gdb.hh"
130#include "arch/alpha/utility.hh"
131#include "arch/alpha/vtophys.hh"
132#include "base/intmath.hh"
133#include "base/remote_gdb.hh"
134#include "base/socket.hh"
135#include "base/trace.hh"

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

141#include "mem/port.hh"
142#include "sim/system.hh"
143#include "sim/full_system.hh"
144
145using namespace std;
146using namespace AlphaISA;
147
148RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
127#include "arch/alpha/regredir.hh"
128#include "arch/alpha/remote_gdb.hh"
129#include "arch/alpha/utility.hh"
130#include "arch/alpha/vtophys.hh"
131#include "base/intmath.hh"
132#include "base/remote_gdb.hh"
133#include "base/socket.hh"
134#include "base/trace.hh"

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

140#include "mem/port.hh"
141#include "sim/system.hh"
142#include "sim/full_system.hh"
143
144using namespace std;
145using namespace AlphaISA;
146
147RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
149 : BaseRemoteGDB(_system, tc, KGDB_NUMREGS * sizeof(uint64_t))
148 : BaseRemoteGDB(_system, tc)
150{
149{
151 memset(gdbregs.regs, 0, gdbregs.bytes());
152}
153
154/*
155 * Determine if the mapping at va..(va+len) is valid.
156 */
157bool
158RemoteGDB::acc(Addr va, size_t len)
159{

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

198 }
199 va += PageBytes;
200 } while (va < last_va);
201
202 DPRINTF(GDBAcc, "acc: %#x mapping is valid\n", va);
203 return true;
204}
205
150}
151
152/*
153 * Determine if the mapping at va..(va+len) is valid.
154 */
155bool
156RemoteGDB::acc(Addr va, size_t len)
157{

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

196 }
197 va += PageBytes;
198 } while (va < last_va);
199
200 DPRINTF(GDBAcc, "acc: %#x mapping is valid\n", va);
201 return true;
202}
203
206/*
207 * Translate the kernel debugger register format into the GDB register
208 * format.
209 */
210void
204void
211RemoteGDB::getregs()
205RemoteGDB::AlphaGdbRegCache::getRegs(ThreadContext *context)
212{
206{
213 memset(gdbregs.regs, 0, gdbregs.bytes());
207 DPRINTF(GDBAcc, "getRegs in remotegdb \n");
214
208
215 gdbregs.regs64[KGDB_REG_PC] = context->pcState().pc();
209 r.pc = context->pcState().pc();
216
210
217 // @todo: Currently this is very Alpha specific.
218 if (PcPAL(gdbregs.regs64[KGDB_REG_PC])) {
219 for (int i = 0; i < NumIntArchRegs; ++i)
220 gdbregs.regs64[i] = context->readIntReg(reg_redir[i]);
211 if (PcPAL(r.pc)) {
212 for (int i = 0; i < 32; ++i)
213 r.gpr[i] = context->readIntReg(reg_redir[i]);
221 } else {
214 } else {
222 for (int i = 0; i < NumIntArchRegs; ++i)
223 gdbregs.regs64[i] = context->readIntReg(i);
215 for (int i = 0; i < 32; ++i)
216 r.gpr[i] = context->readIntReg(i);
224 }
225
217 }
218
219 for (int i = 0; i < 32; ++i)
226#ifdef KGDB_FP_REGS
220#ifdef KGDB_FP_REGS
227 for (int i = 0; i < NumFloatArchRegs; ++i)
228 gdbregs.regs64[i + KGDB_REG_F0] = context->readFloatRegBits(i);
221 r.fpr[i] = context->readFloatRegBits(i);
222#else
223 r.fpr[i] = 0;
229#endif
230}
231
224#endif
225}
226
232/*
233 * Translate the GDB register format into the kernel debugger register
234 * format.
235 */
236void
227void
237RemoteGDB::setregs()
228RemoteGDB::AlphaGdbRegCache::setRegs(ThreadContext *context) const
238{
229{
239 // @todo: Currently this is very Alpha specific.
240 if (PcPAL(gdbregs.regs64[KGDB_REG_PC])) {
241 for (int i = 0; i < NumIntArchRegs; ++i) {
242 context->setIntReg(reg_redir[i], gdbregs.regs64[i]);
230 DPRINTF(GDBAcc, "setRegs in remotegdb \n");
231
232 if (PcPAL(r.pc)) {
233 for (int i = 0; i < 32; ++i) {
234 context->setIntReg(reg_redir[i], r.gpr[i]);
243 }
244 } else {
235 }
236 } else {
245 for (int i = 0; i < NumIntArchRegs; ++i) {
246 context->setIntReg(i, gdbregs.regs64[i]);
237 for (int i = 0; i < 32; ++i) {
238 context->setIntReg(i, r.gpr[i]);
247 }
248 }
249
250#ifdef KGDB_FP_REGS
251 for (int i = 0; i < NumFloatArchRegs; ++i) {
252 context->setFloatRegBits(i, gdbregs.regs64[i + KGDB_REG_F0]);
253 }
254#endif
239 }
240 }
241
242#ifdef KGDB_FP_REGS
243 for (int i = 0; i < NumFloatArchRegs; ++i) {
244 context->setFloatRegBits(i, gdbregs.regs64[i + KGDB_REG_F0]);
245 }
246#endif
255 context->pcState(gdbregs.regs64[KGDB_REG_PC]);
247 context->pcState(r.pc);
256}
257
258// Write bytes to kernel address space for debugger.
259bool
260RemoteGDB::write(Addr vaddr, size_t size, const char *data)
261{
262 if (BaseRemoteGDB::write(vaddr, size, data)) {
263#ifdef IMB

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

272
273bool
274RemoteGDB::insertHardBreak(Addr addr, size_t len)
275{
276 warn_once("Breakpoints do not work in Alpha PAL mode.\n"
277 " See PCEventQueue::doService() in cpu/pc_event.cc.\n");
278 return BaseRemoteGDB::insertHardBreak(addr, len);
279}
248}
249
250// Write bytes to kernel address space for debugger.
251bool
252RemoteGDB::write(Addr vaddr, size_t size, const char *data)
253{
254 if (BaseRemoteGDB::write(vaddr, size, data)) {
255#ifdef IMB

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

264
265bool
266RemoteGDB::insertHardBreak(Addr addr, size_t len)
267{
268 warn_once("Breakpoints do not work in Alpha PAL mode.\n"
269 " See PCEventQueue::doService() in cpu/pc_event.cc.\n");
270 return BaseRemoteGDB::insertHardBreak(addr, len);
271}
272
273RemoteGDB::BaseGdbRegCache*
274RemoteGDB::gdbRegs() {
275 return new AlphaGdbRegCache(this);
276}
277