remote_gdb.cc (11176:741b3059946e) | remote_gdb.cc (11274:d9a0136ab8cc) |
---|---|
1/* | 1/* |
2 * Copyright 2015 LabWare |
|
2 * Copyright 2014 Google, Inc. 3 * Copyright (c) 2010 ARM Limited 4 * All rights reserved 5 * 6 * The license below extends only to copyright in the software and shall 7 * not be construed as granting a license to any other intellectual 8 * property including but not limited to intellectual property relating 9 * to a hardware implementation of the functionality of the software --- 134 unchanged lines hidden (view full) --- 144#include "debug/GDBAcc.hh" 145#include "debug/GDBMisc.hh" 146#include "sim/byteswap.hh" 147 148using namespace std; 149using namespace PowerISA; 150 151RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc) | 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 --- 134 unchanged lines hidden (view full) --- 145#include "debug/GDBAcc.hh" 146#include "debug/GDBMisc.hh" 147#include "sim/byteswap.hh" 148 149using namespace std; 150using namespace PowerISA; 151 152RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc) |
152 : BaseRemoteGDB(_system, tc, GDB_REG_BYTES) | 153 : BaseRemoteGDB(_system, tc) |
153{ 154} 155 156/* 157 * Determine if the mapping at va..(va+len) is valid. 158 */ 159bool 160RemoteGDB::acc(Addr va, size_t len) --- 5 unchanged lines hidden (view full) --- 166 //port proxy to read/writeBlob. I (bgs) am not convinced the first byte 167 //check is enough. 168 if (FullSystem) 169 panic("acc not implemented for POWER FS!"); 170 else 171 return context->getProcessPtr()->pTable->lookup(va, entry); 172} 173 | 154{ 155} 156 157/* 158 * Determine if the mapping at va..(va+len) is valid. 159 */ 160bool 161RemoteGDB::acc(Addr va, size_t len) --- 5 unchanged lines hidden (view full) --- 167 //port proxy to read/writeBlob. I (bgs) am not convinced the first byte 168 //check is enough. 169 if (FullSystem) 170 panic("acc not implemented for POWER FS!"); 171 else 172 return context->getProcessPtr()->pTable->lookup(va, entry); 173} 174 |
174/* 175 * Translate the kernel debugger register format into the GDB register 176 * format. 177 * 178 * The PowerPC ISA is quite flexible in what register sets may be present 179 * depending on the features implemented by the particular CPU; 180 * GDB addresses this by describing the format of how register contents 181 * are transferred on the wire, in XML files such as 'power-core.xml'. 182 * Ideally, we should be reading these files instead of hardcoding this 183 * information, but for now the following implementation is enough to 184 * serve as the RSP backend for the out-of-the-box, default GDB. 185 */ | |
186void | 175void |
187RemoteGDB::getregs() | 176RemoteGDB::PowerGdbRegCache::getRegs(ThreadContext *context) |
188{ | 177{ |
189 DPRINTF(GDBAcc, "getregs in remotegdb \n"); 190 memset(gdbregs.regs, 0, gdbregs.bytes()); | 178 DPRINTF(GDBAcc, "getRegs in remotegdb \n"); |
191 192 // Default order on 32-bit PowerPC: 193 // R0-R31 (32-bit each), F0-F31 (64-bit IEEE754 double), 194 // PC, MSR, CR, LR, CTR, XER (32-bit each) 195 | 179 180 // Default order on 32-bit PowerPC: 181 // R0-R31 (32-bit each), F0-F31 (64-bit IEEE754 double), 182 // PC, MSR, CR, LR, CTR, XER (32-bit each) 183 |
196 // INTREG: R0~R31 | |
197 for (int i = 0; i < NumIntArchRegs; i++) | 184 for (int i = 0; i < NumIntArchRegs; i++) |
198 gdbregs.regs32[GdbFirstGPRIndex + i] = htobe((uint32_t)context->readIntReg(i)); | 185 r.gpr[i] = htobe((uint32_t)context->readIntReg(i)); |
199 | 186 |
200 // FLOATREG: F0~F31 | |
201 for (int i = 0; i < NumFloatArchRegs; i++) | 187 for (int i = 0; i < NumFloatArchRegs; i++) |
202 gdbregs.regs32[GdbFirstFPRIndex + i] = context->readFloatRegBits(i); | 188 r.fpr[i] = context->readFloatRegBits(i); |
203 | 189 |
204 // PC, MSR, CR, LR, CTR, XER 205 gdbregs.regs32[GdbPCIndex] = htobe((uint32_t)context->pcState().pc()); 206 gdbregs.regs32[GdbMSRIndex] = 0; // Is MSR modeled? 207 gdbregs.regs32[GdbCRIndex] = htobe((uint32_t)context->readIntReg(INTREG_CR)); 208 gdbregs.regs32[GdbLRIndex] = htobe((uint32_t)context->readIntReg(INTREG_LR)); 209 gdbregs.regs32[GdbCTRIndex] = htobe((uint32_t)context->readIntReg(INTREG_CTR)); 210 gdbregs.regs32[GdbXERIndex] = htobe((uint32_t)context->readIntReg(INTREG_XER)); | 190 r.pc = htobe((uint32_t)context->pcState().pc()); 191 r.msr = 0; // Is MSR modeled? 192 r.cr = htobe((uint32_t)context->readIntReg(INTREG_CR)); 193 r.lr = htobe((uint32_t)context->readIntReg(INTREG_LR)); 194 r.ctr = htobe((uint32_t)context->readIntReg(INTREG_CTR)); 195 r.xer = htobe((uint32_t)context->readIntReg(INTREG_XER)); |
211} 212 | 196} 197 |
213/* 214 * Translate the GDB register format into the kernel debugger register 215 * format. 216 */ | |
217void | 198void |
218RemoteGDB::setregs() | 199RemoteGDB::PowerGdbRegCache::setRegs(ThreadContext *context) const |
219{ | 200{ |
220 DPRINTF(GDBAcc, "setregs in remotegdb \n"); | 201 DPRINTF(GDBAcc, "setRegs in remotegdb \n"); |
221 | 202 |
222 // INTREG: R0~R31 | |
223 for (int i = 0; i < NumIntArchRegs; i++) | 203 for (int i = 0; i < NumIntArchRegs; i++) |
224 context->setIntReg(i, betoh(gdbregs.regs32[GdbFirstGPRIndex + i])); | 204 context->setIntReg(i, betoh(r.gpr[i])); |
225 | 205 |
226 // FLOATREG: F0~F31 | |
227 for (int i = 0; i < NumFloatArchRegs; i++) | 206 for (int i = 0; i < NumFloatArchRegs; i++) |
228 context->setFloatRegBits(i, gdbregs.regs64[GdbFirstFPRIndex + i]); | 207 context->setFloatRegBits(i, r.fpr[i]); |
229 | 208 |
230 // PC, MSR, CR, LR, CTR, XER 231 context->pcState(betoh(gdbregs.regs32[GdbPCIndex])); | 209 context->pcState(betoh(r.pc)); |
232 // Is MSR modeled? | 210 // Is MSR modeled? |
233 context->setIntReg(INTREG_CR, betoh(gdbregs.regs32[GdbCRIndex])); 234 context->setIntReg(INTREG_LR, betoh(gdbregs.regs32[GdbLRIndex])); 235 context->setIntReg(INTREG_CTR, betoh(gdbregs.regs32[GdbCTRIndex])); 236 context->setIntReg(INTREG_XER, betoh(gdbregs.regs32[GdbXERIndex])); | 211 context->setIntReg(INTREG_CR, betoh(r.cr)); 212 context->setIntReg(INTREG_LR, betoh(r.lr)); 213 context->setIntReg(INTREG_CTR, betoh(r.ctr)); 214 context->setIntReg(INTREG_XER, betoh(r.xer)); |
237} | 215} |
216 217RemoteGDB::BaseGdbRegCache* 218RemoteGDB::gdbRegs() { 219 return new PowerGdbRegCache(this); 220} 221 |
|