remote_gdb.cc revision 8544
18544Sguodeyuan@tsinghua.org.cn/* 28544Sguodeyuan@tsinghua.org.cn * Copyright (c) 2010 ARM Limited 38544Sguodeyuan@tsinghua.org.cn * All rights reserved 48544Sguodeyuan@tsinghua.org.cn * 58544Sguodeyuan@tsinghua.org.cn * The license below extends only to copyright in the software and shall 68544Sguodeyuan@tsinghua.org.cn * not be construed as granting a license to any other intellectual 78544Sguodeyuan@tsinghua.org.cn * property including but not limited to intellectual property relating 88544Sguodeyuan@tsinghua.org.cn * to a hardware implementation of the functionality of the software 98544Sguodeyuan@tsinghua.org.cn * licensed hereunder. You may use the software subject to the license 108544Sguodeyuan@tsinghua.org.cn * terms below provided that you ensure that this notice is replicated 118544Sguodeyuan@tsinghua.org.cn * unmodified and in its entirety in all distributions of the software, 128544Sguodeyuan@tsinghua.org.cn * modified or unmodified, in source code or in binary form. 138544Sguodeyuan@tsinghua.org.cn * 148544Sguodeyuan@tsinghua.org.cn * Copyright (c) 2002-2005 The Regents of The University of Michigan 158544Sguodeyuan@tsinghua.org.cn * All rights reserved. 168544Sguodeyuan@tsinghua.org.cn * 178544Sguodeyuan@tsinghua.org.cn * Redistribution and use in source and binary forms, with or without 188544Sguodeyuan@tsinghua.org.cn * modification, are permitted provided that the following conditions are 198544Sguodeyuan@tsinghua.org.cn * met: redistributions of source code must retain the above copyright 208544Sguodeyuan@tsinghua.org.cn * notice, this list of conditions and the following disclaimer; 218544Sguodeyuan@tsinghua.org.cn * redistributions in binary form must reproduce the above copyright 228544Sguodeyuan@tsinghua.org.cn * notice, this list of conditions and the following disclaimer in the 238544Sguodeyuan@tsinghua.org.cn * documentation and/or other materials provided with the distribution; 248544Sguodeyuan@tsinghua.org.cn * neither the name of the copyright holders nor the names of its 258544Sguodeyuan@tsinghua.org.cn * contributors may be used to endorse or promote products derived from 268544Sguodeyuan@tsinghua.org.cn * this software without specific prior written permission. 278544Sguodeyuan@tsinghua.org.cn * 288544Sguodeyuan@tsinghua.org.cn * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 298544Sguodeyuan@tsinghua.org.cn * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 308544Sguodeyuan@tsinghua.org.cn * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 318544Sguodeyuan@tsinghua.org.cn * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 328544Sguodeyuan@tsinghua.org.cn * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 338544Sguodeyuan@tsinghua.org.cn * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 348544Sguodeyuan@tsinghua.org.cn * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 358544Sguodeyuan@tsinghua.org.cn * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 368544Sguodeyuan@tsinghua.org.cn * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 378544Sguodeyuan@tsinghua.org.cn * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 388544Sguodeyuan@tsinghua.org.cn * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 398544Sguodeyuan@tsinghua.org.cn * 408544Sguodeyuan@tsinghua.org.cn * Authors: Nathan Binkert 418544Sguodeyuan@tsinghua.org.cn * William Wang 428544Sguodeyuan@tsinghua.org.cn * Deyuan Guo 438544Sguodeyuan@tsinghua.org.cn */ 448544Sguodeyuan@tsinghua.org.cn 458544Sguodeyuan@tsinghua.org.cn/* 468544Sguodeyuan@tsinghua.org.cn * Copyright (c) 1990, 1993 The Regents of the University of California 478544Sguodeyuan@tsinghua.org.cn * All rights reserved 488544Sguodeyuan@tsinghua.org.cn * 498544Sguodeyuan@tsinghua.org.cn * This software was developed by the Computer Systems Engineering group 508544Sguodeyuan@tsinghua.org.cn * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 518544Sguodeyuan@tsinghua.org.cn * contributed to Berkeley. 528544Sguodeyuan@tsinghua.org.cn * 538544Sguodeyuan@tsinghua.org.cn * All advertising materials mentioning features or use of this software 548544Sguodeyuan@tsinghua.org.cn * must display the following acknowledgement: 558544Sguodeyuan@tsinghua.org.cn * This product includes software developed by the University of 568544Sguodeyuan@tsinghua.org.cn * California, Lawrence Berkeley Laboratories. 578544Sguodeyuan@tsinghua.org.cn * 588544Sguodeyuan@tsinghua.org.cn * Redistribution and use in source and binary forms, with or without 598544Sguodeyuan@tsinghua.org.cn * modification, are permitted provided that the following conditions 608544Sguodeyuan@tsinghua.org.cn * are met: 618544Sguodeyuan@tsinghua.org.cn * 1. Redistributions of source code must retain the above copyright 628544Sguodeyuan@tsinghua.org.cn * notice, this list of conditions and the following disclaimer. 638544Sguodeyuan@tsinghua.org.cn * 2. Redistributions in binary form must reproduce the above copyright 648544Sguodeyuan@tsinghua.org.cn * notice, this list of conditions and the following disclaimer in the 658544Sguodeyuan@tsinghua.org.cn * documentation and/or other materials provided with the distribution. 668544Sguodeyuan@tsinghua.org.cn * 3. All advertising materials mentioning features or use of this software 678544Sguodeyuan@tsinghua.org.cn * must display the following acknowledgement: 688544Sguodeyuan@tsinghua.org.cn * This product includes software developed by the University of 698544Sguodeyuan@tsinghua.org.cn * California, Berkeley and its contributors. 708544Sguodeyuan@tsinghua.org.cn * 4. Neither the name of the University nor the names of its contributors 718544Sguodeyuan@tsinghua.org.cn * may be used to endorse or promote products derived from this software 728544Sguodeyuan@tsinghua.org.cn * without specific prior written permission. 738544Sguodeyuan@tsinghua.org.cn * 748544Sguodeyuan@tsinghua.org.cn * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 758544Sguodeyuan@tsinghua.org.cn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 768544Sguodeyuan@tsinghua.org.cn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 778544Sguodeyuan@tsinghua.org.cn * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 788544Sguodeyuan@tsinghua.org.cn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 798544Sguodeyuan@tsinghua.org.cn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 808544Sguodeyuan@tsinghua.org.cn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 818544Sguodeyuan@tsinghua.org.cn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 828544Sguodeyuan@tsinghua.org.cn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 838544Sguodeyuan@tsinghua.org.cn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 848544Sguodeyuan@tsinghua.org.cn * SUCH DAMAGE. 858544Sguodeyuan@tsinghua.org.cn * 868544Sguodeyuan@tsinghua.org.cn * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94 878544Sguodeyuan@tsinghua.org.cn */ 888544Sguodeyuan@tsinghua.org.cn 898544Sguodeyuan@tsinghua.org.cn/*- 908544Sguodeyuan@tsinghua.org.cn * Copyright (c) 2001 The NetBSD Foundation, Inc. 918544Sguodeyuan@tsinghua.org.cn * All rights reserved. 928544Sguodeyuan@tsinghua.org.cn * 938544Sguodeyuan@tsinghua.org.cn * This code is derived from software contributed to The NetBSD Foundation 948544Sguodeyuan@tsinghua.org.cn * by Jason R. Thorpe. 958544Sguodeyuan@tsinghua.org.cn * 968544Sguodeyuan@tsinghua.org.cn * Redistribution and use in source and binary forms, with or without 978544Sguodeyuan@tsinghua.org.cn * modification, are permitted provided that the following conditions 988544Sguodeyuan@tsinghua.org.cn * are met: 998544Sguodeyuan@tsinghua.org.cn * 1. Redistributions of source code must retain the above copyright 1008544Sguodeyuan@tsinghua.org.cn * notice, this list of conditions and the following disclaimer. 1018544Sguodeyuan@tsinghua.org.cn * 2. Redistributions in binary form must reproduce the above copyright 1028544Sguodeyuan@tsinghua.org.cn * notice, this list of conditions and the following disclaimer in the 1038544Sguodeyuan@tsinghua.org.cn * documentation and/or other materials provided with the distribution. 1048544Sguodeyuan@tsinghua.org.cn * 3. All advertising materials mentioning features or use of this software 1058544Sguodeyuan@tsinghua.org.cn * must display the following acknowledgement: 1068544Sguodeyuan@tsinghua.org.cn * This product includes software developed by the NetBSD 1078544Sguodeyuan@tsinghua.org.cn * Foundation, Inc. and its contributors. 1088544Sguodeyuan@tsinghua.org.cn * 4. Neither the name of The NetBSD Foundation nor the names of its 1098544Sguodeyuan@tsinghua.org.cn * contributors may be used to endorse or promote products derived 1108544Sguodeyuan@tsinghua.org.cn * from this software without specific prior written permission. 1118544Sguodeyuan@tsinghua.org.cn * 1128544Sguodeyuan@tsinghua.org.cn * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1138544Sguodeyuan@tsinghua.org.cn * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 1148544Sguodeyuan@tsinghua.org.cn * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1158544Sguodeyuan@tsinghua.org.cn * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 1168544Sguodeyuan@tsinghua.org.cn * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 1178544Sguodeyuan@tsinghua.org.cn * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 1188544Sguodeyuan@tsinghua.org.cn * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 1198544Sguodeyuan@tsinghua.org.cn * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 1208544Sguodeyuan@tsinghua.org.cn * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 1218544Sguodeyuan@tsinghua.org.cn * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 1228544Sguodeyuan@tsinghua.org.cn * POSSIBILITY OF SUCH DAMAGE. 1238544Sguodeyuan@tsinghua.org.cn */ 1248544Sguodeyuan@tsinghua.org.cn 1258544Sguodeyuan@tsinghua.org.cn/* 1268544Sguodeyuan@tsinghua.org.cn * $NetBSD: kgdb_stub.c,v 1.8 2001/07/07 22:58:00 wdk Exp $ 1278544Sguodeyuan@tsinghua.org.cn * 1288544Sguodeyuan@tsinghua.org.cn * Taken from NetBSD 1298544Sguodeyuan@tsinghua.org.cn * 1308544Sguodeyuan@tsinghua.org.cn * "Stub" to allow remote cpu to debug over a serial line using gdb. 1318544Sguodeyuan@tsinghua.org.cn */ 1328544Sguodeyuan@tsinghua.org.cn 1338544Sguodeyuan@tsinghua.org.cn#include <sys/signal.h> 1348544Sguodeyuan@tsinghua.org.cn#include <unistd.h> 1358544Sguodeyuan@tsinghua.org.cn 1368544Sguodeyuan@tsinghua.org.cn#include <string> 1378544Sguodeyuan@tsinghua.org.cn 1388544Sguodeyuan@tsinghua.org.cn#include "arch/mips/remote_gdb.hh" 1398544Sguodeyuan@tsinghua.org.cn#include "arch/mips/vtophys.hh" 1408544Sguodeyuan@tsinghua.org.cn#include "config/full_system.hh" 1418544Sguodeyuan@tsinghua.org.cn#include "cpu/decode.hh" 1428544Sguodeyuan@tsinghua.org.cn#include "cpu/thread_state.hh" 1438544Sguodeyuan@tsinghua.org.cn#include "debug/GDBAcc.hh" 1448544Sguodeyuan@tsinghua.org.cn#include "debug/GDBMisc.hh" 1458544Sguodeyuan@tsinghua.org.cn#include "mem/page_table.hh" 1468544Sguodeyuan@tsinghua.org.cn 1478544Sguodeyuan@tsinghua.org.cnusing namespace std; 1488544Sguodeyuan@tsinghua.org.cnusing namespace MipsISA; 1498544Sguodeyuan@tsinghua.org.cn 1508544Sguodeyuan@tsinghua.org.cnRemoteGDB::RemoteGDB(System *_system, ThreadContext *tc) 1518544Sguodeyuan@tsinghua.org.cn : BaseRemoteGDB(_system, tc, GdbNumRegs) 1528544Sguodeyuan@tsinghua.org.cn{ 1538544Sguodeyuan@tsinghua.org.cn} 1548544Sguodeyuan@tsinghua.org.cn 1558544Sguodeyuan@tsinghua.org.cn/* 1568544Sguodeyuan@tsinghua.org.cn * Determine if the mapping at va..(va+len) is valid. 1578544Sguodeyuan@tsinghua.org.cn */ 1588544Sguodeyuan@tsinghua.org.cnbool 1598544Sguodeyuan@tsinghua.org.cnRemoteGDB::acc(Addr va, size_t len) 1608544Sguodeyuan@tsinghua.org.cn{ 1618544Sguodeyuan@tsinghua.org.cn#if FULL_SYSTEM 1628544Sguodeyuan@tsinghua.org.cn panic("acc not implemented for MIPS FS!"); 1638544Sguodeyuan@tsinghua.org.cn#endif 1648544Sguodeyuan@tsinghua.org.cn TlbEntry entry; 1658544Sguodeyuan@tsinghua.org.cn //Check to make sure the first byte is mapped into the processes address 1668544Sguodeyuan@tsinghua.org.cn //space. 1678544Sguodeyuan@tsinghua.org.cn return context->getProcessPtr()->pTable->lookup(va, entry); 1688544Sguodeyuan@tsinghua.org.cn} 1698544Sguodeyuan@tsinghua.org.cn 1708544Sguodeyuan@tsinghua.org.cn/* 1718544Sguodeyuan@tsinghua.org.cn * Translate the kernel debugger register format into the GDB register 1728544Sguodeyuan@tsinghua.org.cn * format. 1738544Sguodeyuan@tsinghua.org.cn */ 1748544Sguodeyuan@tsinghua.org.cnvoid 1758544Sguodeyuan@tsinghua.org.cnRemoteGDB::getregs() 1768544Sguodeyuan@tsinghua.org.cn{ 1778544Sguodeyuan@tsinghua.org.cn DPRINTF(GDBAcc, "getregs in remotegdb \n"); 1788544Sguodeyuan@tsinghua.org.cn memset(gdbregs.regs, 0, gdbregs.bytes()); 1798544Sguodeyuan@tsinghua.org.cn 1808544Sguodeyuan@tsinghua.org.cn // MIPS registers are 32 bits wide, gdb registers are 64 bits wide 1818544Sguodeyuan@tsinghua.org.cn // two MIPS registers are packed into one gdb register (little endian) 1828544Sguodeyuan@tsinghua.org.cn 1838544Sguodeyuan@tsinghua.org.cn // INTREG: R0~R31 1848544Sguodeyuan@tsinghua.org.cn for (int i = 0; i < GdbIntArchRegs; i++) { 1858544Sguodeyuan@tsinghua.org.cn gdbregs.regs[i] = pack( 1868544Sguodeyuan@tsinghua.org.cn context->readIntReg(i * 2), 1878544Sguodeyuan@tsinghua.org.cn context->readIntReg(i * 2 + 1)); 1888544Sguodeyuan@tsinghua.org.cn } 1898544Sguodeyuan@tsinghua.org.cn // SR, LO, HI, BADVADDR, CAUSE, PC 1908544Sguodeyuan@tsinghua.org.cn gdbregs.regs[GdbIntArchRegs + 0] = pack( 1918544Sguodeyuan@tsinghua.org.cn context->readMiscRegNoEffect(MISCREG_STATUS), 1928544Sguodeyuan@tsinghua.org.cn context->readIntReg(INTREG_LO)); 1938544Sguodeyuan@tsinghua.org.cn gdbregs.regs[GdbIntArchRegs + 1] = pack( 1948544Sguodeyuan@tsinghua.org.cn context->readIntReg(INTREG_HI), 1958544Sguodeyuan@tsinghua.org.cn context->readMiscRegNoEffect(MISCREG_BADVADDR)); 1968544Sguodeyuan@tsinghua.org.cn gdbregs.regs[GdbIntArchRegs + 2] = pack( 1978544Sguodeyuan@tsinghua.org.cn context->readMiscRegNoEffect(MISCREG_CAUSE), 1988544Sguodeyuan@tsinghua.org.cn context->pcState().pc()); 1998544Sguodeyuan@tsinghua.org.cn // FLOATREG: F0~F31 2008544Sguodeyuan@tsinghua.org.cn for (int i = 0; i < GdbFloatArchRegs; i++) { 2018544Sguodeyuan@tsinghua.org.cn gdbregs.regs[GdbIntRegs + i] = pack( 2028544Sguodeyuan@tsinghua.org.cn context->readFloatRegBits(i * 2), 2038544Sguodeyuan@tsinghua.org.cn context->readFloatRegBits(i * 2 + 1)); 2048544Sguodeyuan@tsinghua.org.cn } 2058544Sguodeyuan@tsinghua.org.cn // FCR, FIR 2068544Sguodeyuan@tsinghua.org.cn gdbregs.regs[GdbIntRegs + GdbFloatArchRegs + 0] = pack( 2078544Sguodeyuan@tsinghua.org.cn context->readFloatRegBits(FLOATREG_FCCR), 2088544Sguodeyuan@tsinghua.org.cn context->readFloatRegBits(FLOATREG_FIR)); 2098544Sguodeyuan@tsinghua.org.cn} 2108544Sguodeyuan@tsinghua.org.cn 2118544Sguodeyuan@tsinghua.org.cn/* 2128544Sguodeyuan@tsinghua.org.cn * Translate the GDB register format into the kernel debugger register 2138544Sguodeyuan@tsinghua.org.cn * format. 2148544Sguodeyuan@tsinghua.org.cn */ 2158544Sguodeyuan@tsinghua.org.cnvoid 2168544Sguodeyuan@tsinghua.org.cnRemoteGDB::setregs() 2178544Sguodeyuan@tsinghua.org.cn{ 2188544Sguodeyuan@tsinghua.org.cn DPRINTF(GDBAcc, "setregs in remotegdb \n"); 2198544Sguodeyuan@tsinghua.org.cn 2208544Sguodeyuan@tsinghua.org.cn // MIPS registers are 32 bits wide, gdb registers are 64 bits wide 2218544Sguodeyuan@tsinghua.org.cn // two MIPS registers are packed into one gdb register (little endian) 2228544Sguodeyuan@tsinghua.org.cn 2238544Sguodeyuan@tsinghua.org.cn // INTREG: R0~R31 2248544Sguodeyuan@tsinghua.org.cn for (int i = 0; i < GdbIntArchRegs; i++) { 2258544Sguodeyuan@tsinghua.org.cn if (i) context->setIntReg(i * 2, 2268544Sguodeyuan@tsinghua.org.cn unpackLo(gdbregs.regs[i])); 2278544Sguodeyuan@tsinghua.org.cn context->setIntReg(i * 2 + 1, 2288544Sguodeyuan@tsinghua.org.cn unpackHi(gdbregs.regs[i])); 2298544Sguodeyuan@tsinghua.org.cn } 2308544Sguodeyuan@tsinghua.org.cn // SR, LO, HI, BADVADDR, CAUSE, PC 2318544Sguodeyuan@tsinghua.org.cn context->setMiscRegNoEffect(MISCREG_STATUS, 2328544Sguodeyuan@tsinghua.org.cn unpackLo(gdbregs.regs[GdbIntArchRegs + 0])); 2338544Sguodeyuan@tsinghua.org.cn context->setIntReg(INTREG_LO, 2348544Sguodeyuan@tsinghua.org.cn unpackHi(gdbregs.regs[GdbIntArchRegs + 0])); 2358544Sguodeyuan@tsinghua.org.cn context->setIntReg(INTREG_HI, 2368544Sguodeyuan@tsinghua.org.cn unpackLo(gdbregs.regs[GdbIntArchRegs + 1])); 2378544Sguodeyuan@tsinghua.org.cn context->setMiscRegNoEffect(MISCREG_BADVADDR, 2388544Sguodeyuan@tsinghua.org.cn unpackHi(gdbregs.regs[GdbIntArchRegs + 1])); 2398544Sguodeyuan@tsinghua.org.cn context->setMiscRegNoEffect(MISCREG_CAUSE, 2408544Sguodeyuan@tsinghua.org.cn unpackLo(gdbregs.regs[GdbIntArchRegs + 2])); 2418544Sguodeyuan@tsinghua.org.cn context->pcState( 2428544Sguodeyuan@tsinghua.org.cn unpackHi(gdbregs.regs[GdbIntArchRegs + 2])); 2438544Sguodeyuan@tsinghua.org.cn // FLOATREG: F0~F31 2448544Sguodeyuan@tsinghua.org.cn for (int i = 0; i < GdbFloatArchRegs; i++) { 2458544Sguodeyuan@tsinghua.org.cn context->setFloatRegBits(i * 2, 2468544Sguodeyuan@tsinghua.org.cn unpackLo(gdbregs.regs[GdbIntRegs + i])); 2478544Sguodeyuan@tsinghua.org.cn context->setFloatRegBits(i * 2 + 1, 2488544Sguodeyuan@tsinghua.org.cn unpackHi(gdbregs.regs[GdbIntRegs + i])); 2498544Sguodeyuan@tsinghua.org.cn } 2508544Sguodeyuan@tsinghua.org.cn // FCR, FIR 2518544Sguodeyuan@tsinghua.org.cn context->setFloatRegBits(FLOATREG_FCCR, 2528544Sguodeyuan@tsinghua.org.cn unpackLo(gdbregs.regs[GdbIntRegs + GdbFloatArchRegs + 0])); 2538544Sguodeyuan@tsinghua.org.cn context->setFloatRegBits(FLOATREG_FIR, 2548544Sguodeyuan@tsinghua.org.cn unpackHi(gdbregs.regs[GdbIntRegs + GdbFloatArchRegs + 0])); 2558544Sguodeyuan@tsinghua.org.cn} 2568544Sguodeyuan@tsinghua.org.cn 2578544Sguodeyuan@tsinghua.org.cnvoid 2588544Sguodeyuan@tsinghua.org.cnRemoteGDB::clearSingleStep() 2598544Sguodeyuan@tsinghua.org.cn{ 2608544Sguodeyuan@tsinghua.org.cn DPRINTF(GDBMisc, "clearSingleStep bt_addr=%#x nt_addr=%#x\n", 2618544Sguodeyuan@tsinghua.org.cn takenBkpt, notTakenBkpt); 2628544Sguodeyuan@tsinghua.org.cn 2638544Sguodeyuan@tsinghua.org.cn if (takenBkpt != 0) 2648544Sguodeyuan@tsinghua.org.cn clearTempBreakpoint(takenBkpt); 2658544Sguodeyuan@tsinghua.org.cn 2668544Sguodeyuan@tsinghua.org.cn if (notTakenBkpt != 0) 2678544Sguodeyuan@tsinghua.org.cn clearTempBreakpoint(notTakenBkpt); 2688544Sguodeyuan@tsinghua.org.cn} 2698544Sguodeyuan@tsinghua.org.cn 2708544Sguodeyuan@tsinghua.org.cnvoid 2718544Sguodeyuan@tsinghua.org.cnRemoteGDB::setSingleStep() 2728544Sguodeyuan@tsinghua.org.cn{ 2738544Sguodeyuan@tsinghua.org.cn PCState pc = context->pcState(); 2748544Sguodeyuan@tsinghua.org.cn PCState bpc; 2758544Sguodeyuan@tsinghua.org.cn bool set_bt = false; 2768544Sguodeyuan@tsinghua.org.cn 2778544Sguodeyuan@tsinghua.org.cn // User was stopped at pc, e.g. the instruction at pc was not 2788544Sguodeyuan@tsinghua.org.cn // executed. 2798544Sguodeyuan@tsinghua.org.cn MachInst inst = read<MachInst>(pc.pc()); 2808544Sguodeyuan@tsinghua.org.cn StaticInstPtr si = context->getDecoderPtr()->decode(inst, pc.pc()); 2818544Sguodeyuan@tsinghua.org.cn if (si->hasBranchTarget(pc, context, bpc)) { 2828544Sguodeyuan@tsinghua.org.cn // Don't bother setting a breakpoint on the taken branch if it 2838544Sguodeyuan@tsinghua.org.cn // is the same as the next npc 2848544Sguodeyuan@tsinghua.org.cn if (bpc.npc() != pc.nnpc()) 2858544Sguodeyuan@tsinghua.org.cn set_bt = true; 2868544Sguodeyuan@tsinghua.org.cn } 2878544Sguodeyuan@tsinghua.org.cn 2888544Sguodeyuan@tsinghua.org.cn DPRINTF(GDBMisc, "setSingleStep bt_addr=%#x nt_addr=%#x\n", 2898544Sguodeyuan@tsinghua.org.cn takenBkpt, notTakenBkpt); 2908544Sguodeyuan@tsinghua.org.cn 2918544Sguodeyuan@tsinghua.org.cn notTakenBkpt = pc.nnpc(); 2928544Sguodeyuan@tsinghua.org.cn setTempBreakpoint(notTakenBkpt); 2938544Sguodeyuan@tsinghua.org.cn 2948544Sguodeyuan@tsinghua.org.cn if (set_bt) { 2958544Sguodeyuan@tsinghua.org.cn takenBkpt = bpc.npc(); 2968544Sguodeyuan@tsinghua.org.cn setTempBreakpoint(takenBkpt); 2978544Sguodeyuan@tsinghua.org.cn } 2988544Sguodeyuan@tsinghua.org.cn} 2998544Sguodeyuan@tsinghua.org.cn 300