1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Nathan Binkert 29 */ 30 31/* 32 * Copyright (c) 1990, 1993 The Regents of the University of California 33 * All rights reserved. 34 * 35 * This software was developed by the Computer Systems Engineering group 36 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 37 * contributed to Berkeley. 38 * 39 * All advertising materials mentioning features or use of this software 40 * must display the following acknowledgement: 41 * This product includes software developed by the University of 42 * California, Lawrence Berkeley Laboratories. 43 * 44 * Redistribution and use in source and binary forms, with or without 45 * modification, are permitted provided that the following conditions 46 * are met: 47 * 1. Redistributions of source code must retain the above copyright 48 * notice, this list of conditions and the following disclaimer. 49 * 2. Redistributions in binary form must reproduce the above copyright 50 * notice, this list of conditions and the following disclaimer in the 51 * documentation and/or other materials provided with the distribution. 52 * 3. All advertising materials mentioning features or use of this software 53 * must display the following acknowledgement: 54 * This product includes software developed by the University of 55 * California, Berkeley and its contributors. 56 * 4. Neither the name of the University nor the names of its contributors 57 * may be used to endorse or promote products derived from this software 58 * without specific prior written permission. 59 * 60 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 61 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 63 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 66 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 67 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 68 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 69 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 70 * SUCH DAMAGE. 71 * 72 * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94 73 */ 74 75/*- 76 * Copyright (c) 2001 The NetBSD Foundation, Inc. 77 * All rights reserved. 78 * 79 * This code is derived from software contributed to The NetBSD Foundation 80 * by Jason R. Thorpe. 81 * 82 * Redistribution and use in source and binary forms, with or without 83 * modification, are permitted provided that the following conditions 84 * are met: 85 * 1. Redistributions of source code must retain the above copyright 86 * notice, this list of conditions and the following disclaimer. 87 * 2. Redistributions in binary form must reproduce the above copyright 88 * notice, this list of conditions and the following disclaimer in the 89 * documentation and/or other materials provided with the distribution. 90 * 3. All advertising materials mentioning features or use of this software 91 * must display the following acknowledgement: 92 * This product includes software developed by the NetBSD 93 * Foundation, Inc. and its contributors. 94 * 4. Neither the name of The NetBSD Foundation nor the names of its 95 * contributors may be used to endorse or promote products derived 96 * from this software without specific prior written permission. 97 * 98 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 99 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 100 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 101 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 102 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 103 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 104 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 105 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 106 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 107 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 108 * POSSIBILITY OF SUCH DAMAGE. 109 */ 110 111/* 112 * $NetBSD: kgdb_stub.c,v 1.8 2001/07/07 22:58:00 wdk Exp $ 113 * 114 * Taken from NetBSD 115 * 116 * "Stub" to allow remote cpu to debug over a serial line using gdb. 117 */ 118 119#include <sys/signal.h> 120#include <unistd.h> 121 122#include <string> 123
| 1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Nathan Binkert 29 */ 30 31/* 32 * Copyright (c) 1990, 1993 The Regents of the University of California 33 * All rights reserved. 34 * 35 * This software was developed by the Computer Systems Engineering group 36 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 37 * contributed to Berkeley. 38 * 39 * All advertising materials mentioning features or use of this software 40 * must display the following acknowledgement: 41 * This product includes software developed by the University of 42 * California, Lawrence Berkeley Laboratories. 43 * 44 * Redistribution and use in source and binary forms, with or without 45 * modification, are permitted provided that the following conditions 46 * are met: 47 * 1. Redistributions of source code must retain the above copyright 48 * notice, this list of conditions and the following disclaimer. 49 * 2. Redistributions in binary form must reproduce the above copyright 50 * notice, this list of conditions and the following disclaimer in the 51 * documentation and/or other materials provided with the distribution. 52 * 3. All advertising materials mentioning features or use of this software 53 * must display the following acknowledgement: 54 * This product includes software developed by the University of 55 * California, Berkeley and its contributors. 56 * 4. Neither the name of the University nor the names of its contributors 57 * may be used to endorse or promote products derived from this software 58 * without specific prior written permission. 59 * 60 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 61 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 63 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 66 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 67 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 68 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 69 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 70 * SUCH DAMAGE. 71 * 72 * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94 73 */ 74 75/*- 76 * Copyright (c) 2001 The NetBSD Foundation, Inc. 77 * All rights reserved. 78 * 79 * This code is derived from software contributed to The NetBSD Foundation 80 * by Jason R. Thorpe. 81 * 82 * Redistribution and use in source and binary forms, with or without 83 * modification, are permitted provided that the following conditions 84 * are met: 85 * 1. Redistributions of source code must retain the above copyright 86 * notice, this list of conditions and the following disclaimer. 87 * 2. Redistributions in binary form must reproduce the above copyright 88 * notice, this list of conditions and the following disclaimer in the 89 * documentation and/or other materials provided with the distribution. 90 * 3. All advertising materials mentioning features or use of this software 91 * must display the following acknowledgement: 92 * This product includes software developed by the NetBSD 93 * Foundation, Inc. and its contributors. 94 * 4. Neither the name of The NetBSD Foundation nor the names of its 95 * contributors may be used to endorse or promote products derived 96 * from this software without specific prior written permission. 97 * 98 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 99 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 100 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 101 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 102 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 103 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 104 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 105 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 106 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 107 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 108 * POSSIBILITY OF SUCH DAMAGE. 109 */ 110 111/* 112 * $NetBSD: kgdb_stub.c,v 1.8 2001/07/07 22:58:00 wdk Exp $ 113 * 114 * Taken from NetBSD 115 * 116 * "Stub" to allow remote cpu to debug over a serial line using gdb. 117 */ 118 119#include <sys/signal.h> 120#include <unistd.h> 121 122#include <string> 123
|
124#include "config/full_system.hh" 125#if FULL_SYSTEM 126#include "arch/alpha/vtophys.hh" 127#endif
| |
128 129#include "arch/alpha/kgdb.h" 130#include "arch/alpha/regredir.hh" 131#include "arch/alpha/remote_gdb.hh" 132#include "arch/alpha/utility.hh"
| 124 125#include "arch/alpha/kgdb.h" 126#include "arch/alpha/regredir.hh" 127#include "arch/alpha/remote_gdb.hh" 128#include "arch/alpha/utility.hh"
|
| 129#include "arch/alpha/vtophys.hh"
|
133#include "base/intmath.hh" 134#include "base/remote_gdb.hh" 135#include "base/socket.hh" 136#include "base/trace.hh" 137#include "cpu/decode.hh" 138#include "cpu/static_inst.hh" 139#include "cpu/thread_context.hh" 140#include "debug/GDBAcc.hh" 141#include "debug/GDBMisc.hh" 142#include "mem/physical.hh" 143#include "mem/port.hh" 144#include "sim/system.hh"
| 130#include "base/intmath.hh" 131#include "base/remote_gdb.hh" 132#include "base/socket.hh" 133#include "base/trace.hh" 134#include "cpu/decode.hh" 135#include "cpu/static_inst.hh" 136#include "cpu/thread_context.hh" 137#include "debug/GDBAcc.hh" 138#include "debug/GDBMisc.hh" 139#include "mem/physical.hh" 140#include "mem/port.hh" 141#include "sim/system.hh"
|
| 142#include "sim/full_system.hh"
|
145 146using namespace std; 147using namespace AlphaISA; 148 149RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc) 150 : BaseRemoteGDB(_system, tc, KGDB_NUMREGS) 151{ 152 memset(gdbregs.regs, 0, gdbregs.bytes()); 153} 154 155/* 156 * Determine if the mapping at va..(va+len) is valid. 157 */ 158bool 159RemoteGDB::acc(Addr va, size_t len) 160{
| 143 144using namespace std; 145using namespace AlphaISA; 146 147RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc) 148 : BaseRemoteGDB(_system, tc, KGDB_NUMREGS) 149{ 150 memset(gdbregs.regs, 0, gdbregs.bytes()); 151} 152 153/* 154 * Determine if the mapping at va..(va+len) is valid. 155 */ 156bool 157RemoteGDB::acc(Addr va, size_t len) 158{
|
161#if !FULL_SYSTEM 162 panic("acc function needs to be rewritten for SE mode\n"); 163#else 164 Addr last_va;
| 159 if (FullSystem) { 160 Addr last_va;
|
165
| 161
|
166 va = TruncPage(va); 167 last_va = RoundPage(va + len);
| 162 va = TruncPage(va); 163 last_va = RoundPage(va + len);
|
168
| 164
|
169 do { 170 if (IsK0Seg(va)) { 171 if (va < (K0SegBase + pmem->size())) { 172 DPRINTF(GDBAcc, "acc: Mapping is valid K0SEG <= " 173 "%#x < K0SEG + size\n", va); 174 return true; 175 } else { 176 DPRINTF(GDBAcc, "acc: Mapping invalid %#x > K0SEG + size\n", 177 va); 178 return false;
| 165 do { 166 if (IsK0Seg(va)) { 167 if (va < (K0SegBase + pmem->size())) { 168 DPRINTF(GDBAcc, "acc: Mapping is valid K0SEG <= " 169 "%#x < K0SEG + size\n", va); 170 return true; 171 } else { 172 DPRINTF(GDBAcc, "acc: Mapping invalid %#x " 173 "> K0SEG + size\n", va); 174 return false; 175 }
|
179 }
| 176 }
|
180 }
| |
181
| 177
|
182 /** 183 * This code says that all accesses to palcode (instruction 184 * and data) are valid since there isn't a va->pa mapping 185 * because palcode is accessed physically. At some point this 186 * should probably be cleaned up but there is no easy way to 187 * do it. 188 */
| 178 /** 179 * This code says that all accesses to palcode (instruction 180 * and data) are valid since there isn't a va->pa mapping 181 * because palcode is accessed physically. At some point this 182 * should probably be cleaned up but there is no easy way to 183 * do it. 184 */
|
189
| 185
|
190 if (PcPAL(va) || va < 0x10000) 191 return true;
| 186 if (PcPAL(va) || va < 0x10000) 187 return true;
|
192
| 188
|
193 Addr ptbr = context->readMiscRegNoEffect(IPR_PALtemp20); 194 PageTableEntry pte = 195 kernel_pte_lookup(context->getPhysProxy(), ptbr, va); 196 if (!pte.valid()) { 197 DPRINTF(GDBAcc, "acc: %#x pte is invalid\n", va); 198 return false; 199 } 200 va += PageBytes; 201 } while (va < last_va);
| 189 Addr ptbr = context->readMiscRegNoEffect(IPR_PALtemp20); 190 PageTableEntry pte = 191 kernel_pte_lookup(context->getPhysPort(), ptbr, va); 192 if (!pte.valid()) { 193 DPRINTF(GDBAcc, "acc: %#x pte is invalid\n", va); 194 return false; 195 } 196 va += PageBytes; 197 } while (va < last_va);
|
202
| 198
|
203 DPRINTF(GDBAcc, "acc: %#x mapping is valid\n", va); 204 return true; 205#endif
| 199 DPRINTF(GDBAcc, "acc: %#x mapping is valid\n", va); 200 return true; 201 } else { 202 panic("acc function needs to be rewritten for SE mode\n"); 203 }
|
206} 207 208/* 209 * Translate the kernel debugger register format into the GDB register 210 * format. 211 */ 212void 213RemoteGDB::getregs() 214{ 215 memset(gdbregs.regs, 0, gdbregs.bytes()); 216 217 gdbregs.regs[KGDB_REG_PC] = context->pcState().pc(); 218 219 // @todo: Currently this is very Alpha specific. 220 if (PcPAL(gdbregs.regs[KGDB_REG_PC])) { 221 for (int i = 0; i < NumIntArchRegs; ++i) { 222 gdbregs.regs[i] = context->readIntReg(reg_redir[i]); 223 } 224 } else { 225 for (int i = 0; i < NumIntArchRegs; ++i) { 226 gdbregs.regs[i] = context->readIntReg(i); 227 } 228 } 229 230#ifdef KGDB_FP_REGS 231 for (int i = 0; i < NumFloatArchRegs; ++i) { 232 gdbregs.regs[i + KGDB_REG_F0] = context->readFloatRegBits(i); 233 } 234#endif 235} 236 237/* 238 * Translate the GDB register format into the kernel debugger register 239 * format. 240 */ 241void 242RemoteGDB::setregs() 243{ 244 // @todo: Currently this is very Alpha specific. 245 if (PcPAL(gdbregs.regs[KGDB_REG_PC])) { 246 for (int i = 0; i < NumIntArchRegs; ++i) { 247 context->setIntReg(reg_redir[i], gdbregs.regs[i]); 248 } 249 } else { 250 for (int i = 0; i < NumIntArchRegs; ++i) { 251 context->setIntReg(i, gdbregs.regs[i]); 252 } 253 } 254 255#ifdef KGDB_FP_REGS 256 for (int i = 0; i < NumFloatArchRegs; ++i) { 257 context->setFloatRegBits(i, gdbregs.regs[i + KGDB_REG_F0]); 258 } 259#endif 260 context->pcState(gdbregs.regs[KGDB_REG_PC]); 261} 262 263void 264RemoteGDB::clearSingleStep() 265{ 266 DPRINTF(GDBMisc, "clearSingleStep bt_addr=%#x nt_addr=%#x\n", 267 takenBkpt, notTakenBkpt); 268 269 if (takenBkpt != 0) 270 clearTempBreakpoint(takenBkpt); 271 272 if (notTakenBkpt != 0) 273 clearTempBreakpoint(notTakenBkpt); 274} 275 276void 277RemoteGDB::setSingleStep() 278{ 279 PCState pc = context->pcState(); 280 PCState bpc; 281 bool set_bt = false; 282 283 // User was stopped at pc, e.g. the instruction at pc was not 284 // executed. 285 MachInst inst = read<MachInst>(pc.pc()); 286 StaticInstPtr si = context->getDecoderPtr()->decode(inst, pc.pc()); 287 if (si->hasBranchTarget(pc, context, bpc)) { 288 // Don't bother setting a breakpoint on the taken branch if it 289 // is the same as the next pc 290 if (bpc.pc() != pc.npc()) 291 set_bt = true; 292 } 293 294 DPRINTF(GDBMisc, "setSingleStep bt_addr=%#x nt_addr=%#x\n", 295 takenBkpt, notTakenBkpt); 296 297 setTempBreakpoint(notTakenBkpt = pc.npc()); 298 299 if (set_bt) 300 setTempBreakpoint(takenBkpt = bpc.pc()); 301} 302 303// Write bytes to kernel address space for debugger. 304bool 305RemoteGDB::write(Addr vaddr, size_t size, const char *data) 306{ 307 if (BaseRemoteGDB::write(vaddr, size, data)) { 308#ifdef IMB 309 alpha_pal_imb(); 310#endif 311 return true; 312 } else { 313 return false; 314 } 315} 316
| 204} 205 206/* 207 * Translate the kernel debugger register format into the GDB register 208 * format. 209 */ 210void 211RemoteGDB::getregs() 212{ 213 memset(gdbregs.regs, 0, gdbregs.bytes()); 214 215 gdbregs.regs[KGDB_REG_PC] = context->pcState().pc(); 216 217 // @todo: Currently this is very Alpha specific. 218 if (PcPAL(gdbregs.regs[KGDB_REG_PC])) { 219 for (int i = 0; i < NumIntArchRegs; ++i) { 220 gdbregs.regs[i] = context->readIntReg(reg_redir[i]); 221 } 222 } else { 223 for (int i = 0; i < NumIntArchRegs; ++i) { 224 gdbregs.regs[i] = context->readIntReg(i); 225 } 226 } 227 228#ifdef KGDB_FP_REGS 229 for (int i = 0; i < NumFloatArchRegs; ++i) { 230 gdbregs.regs[i + KGDB_REG_F0] = context->readFloatRegBits(i); 231 } 232#endif 233} 234 235/* 236 * Translate the GDB register format into the kernel debugger register 237 * format. 238 */ 239void 240RemoteGDB::setregs() 241{ 242 // @todo: Currently this is very Alpha specific. 243 if (PcPAL(gdbregs.regs[KGDB_REG_PC])) { 244 for (int i = 0; i < NumIntArchRegs; ++i) { 245 context->setIntReg(reg_redir[i], gdbregs.regs[i]); 246 } 247 } else { 248 for (int i = 0; i < NumIntArchRegs; ++i) { 249 context->setIntReg(i, gdbregs.regs[i]); 250 } 251 } 252 253#ifdef KGDB_FP_REGS 254 for (int i = 0; i < NumFloatArchRegs; ++i) { 255 context->setFloatRegBits(i, gdbregs.regs[i + KGDB_REG_F0]); 256 } 257#endif 258 context->pcState(gdbregs.regs[KGDB_REG_PC]); 259} 260 261void 262RemoteGDB::clearSingleStep() 263{ 264 DPRINTF(GDBMisc, "clearSingleStep bt_addr=%#x nt_addr=%#x\n", 265 takenBkpt, notTakenBkpt); 266 267 if (takenBkpt != 0) 268 clearTempBreakpoint(takenBkpt); 269 270 if (notTakenBkpt != 0) 271 clearTempBreakpoint(notTakenBkpt); 272} 273 274void 275RemoteGDB::setSingleStep() 276{ 277 PCState pc = context->pcState(); 278 PCState bpc; 279 bool set_bt = false; 280 281 // User was stopped at pc, e.g. the instruction at pc was not 282 // executed. 283 MachInst inst = read<MachInst>(pc.pc()); 284 StaticInstPtr si = context->getDecoderPtr()->decode(inst, pc.pc()); 285 if (si->hasBranchTarget(pc, context, bpc)) { 286 // Don't bother setting a breakpoint on the taken branch if it 287 // is the same as the next pc 288 if (bpc.pc() != pc.npc()) 289 set_bt = true; 290 } 291 292 DPRINTF(GDBMisc, "setSingleStep bt_addr=%#x nt_addr=%#x\n", 293 takenBkpt, notTakenBkpt); 294 295 setTempBreakpoint(notTakenBkpt = pc.npc()); 296 297 if (set_bt) 298 setTempBreakpoint(takenBkpt = bpc.pc()); 299} 300 301// Write bytes to kernel address space for debugger. 302bool 303RemoteGDB::write(Addr vaddr, size_t size, const char *data) 304{ 305 if (BaseRemoteGDB::write(vaddr, size, data)) { 306#ifdef IMB 307 alpha_pal_imb(); 308#endif 309 return true; 310 } else { 311 return false; 312 } 313} 314
|
317 318bool 319RemoteGDB::insertHardBreak(Addr addr, size_t len) 320{ 321 warn_once("Breakpoints do not work in Alpha PAL mode.\n" 322 " See PCEventQueue::doService() in cpu/pc_event.cc.\n"); 323 return BaseRemoteGDB::insertHardBreak(addr, len); 324}
| |
| |