remote_gdb.cc revision 10037
13536SN/A/*
210037SARM gem5 Developers * Copyright (c) 2010, 2013 ARM Limited
37752SWilliam.Wang@arm.com * All rights reserved
47752SWilliam.Wang@arm.com *
57752SWilliam.Wang@arm.com * The license below extends only to copyright in the software and shall
67752SWilliam.Wang@arm.com * not be construed as granting a license to any other intellectual
77752SWilliam.Wang@arm.com * property including but not limited to intellectual property relating
87752SWilliam.Wang@arm.com * to a hardware implementation of the functionality of the software
97752SWilliam.Wang@arm.com * licensed hereunder.  You may use the software subject to the license
107752SWilliam.Wang@arm.com * terms below provided that you ensure that this notice is replicated
117752SWilliam.Wang@arm.com * unmodified and in its entirety in all distributions of the software,
127752SWilliam.Wang@arm.com * modified or unmodified, in source code or in binary form.
137752SWilliam.Wang@arm.com *
143536SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan
153536SN/A * All rights reserved.
163536SN/A *
173536SN/A * Redistribution and use in source and binary forms, with or without
183536SN/A * modification, are permitted provided that the following conditions are
193536SN/A * met: redistributions of source code must retain the above copyright
203536SN/A * notice, this list of conditions and the following disclaimer;
213536SN/A * redistributions in binary form must reproduce the above copyright
223536SN/A * notice, this list of conditions and the following disclaimer in the
233536SN/A * documentation and/or other materials provided with the distribution;
243536SN/A * neither the name of the copyright holders nor the names of its
253536SN/A * contributors may be used to endorse or promote products derived from
263536SN/A * this software without specific prior written permission.
273536SN/A *
283536SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
293536SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
303536SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
313536SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
323536SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
333536SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
343536SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
353536SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
363536SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
373536SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
383536SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
393536SN/A *
403536SN/A * Authors: Nathan Binkert
417752SWilliam.Wang@arm.com *          William Wang
423536SN/A */
433536SN/A
443536SN/A/*
458332Snate@binkert.org * Copyright (c) 1990, 1993 The Regents of the University of California
468332Snate@binkert.org * All rights reserved
473536SN/A *
483536SN/A * This software was developed by the Computer Systems Engineering group
493536SN/A * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
503536SN/A * contributed to Berkeley.
513536SN/A *
523536SN/A * All advertising materials mentioning features or use of this software
533536SN/A * must display the following acknowledgement:
545543SN/A *      This product includes software developed by the University of
555543SN/A *      California, Lawrence Berkeley Laboratories.
563536SN/A *
573536SN/A * Redistribution and use in source and binary forms, with or without
583536SN/A * modification, are permitted provided that the following conditions
593536SN/A * are met:
603536SN/A * 1. Redistributions of source code must retain the above copyright
613536SN/A *    notice, this list of conditions and the following disclaimer.
623536SN/A * 2. Redistributions in binary form must reproduce the above copyright
633536SN/A *    notice, this list of conditions and the following disclaimer in the
643536SN/A *    documentation and/or other materials provided with the distribution.
653536SN/A * 3. All advertising materials mentioning features or use of this software
663536SN/A *    must display the following acknowledgement:
675543SN/A *      This product includes software developed by the University of
685543SN/A *      California, Berkeley and its contributors.
693536SN/A * 4. Neither the name of the University nor the names of its contributors
703536SN/A *    may be used to endorse or promote products derived from this software
713536SN/A *    without specific prior written permission.
723536SN/A *
733536SN/A * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
743536SN/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
753536SN/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
763536SN/A * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
773536SN/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
783536SN/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
793536SN/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
803536SN/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
813536SN/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
823536SN/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
833536SN/A * SUCH DAMAGE.
843536SN/A *
855543SN/A *      @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94
863536SN/A */
873536SN/A
883536SN/A/*-
893536SN/A * Copyright (c) 2001 The NetBSD Foundation, Inc.
903536SN/A * All rights reserved.
913536SN/A *
923536SN/A * This code is derived from software contributed to The NetBSD Foundation
933536SN/A * by Jason R. Thorpe.
943536SN/A *
953536SN/A * Redistribution and use in source and binary forms, with or without
963536SN/A * modification, are permitted provided that the following conditions
973536SN/A * are met:
983536SN/A * 1. Redistributions of source code must retain the above copyright
993536SN/A *    notice, this list of conditions and the following disclaimer.
1003536SN/A * 2. Redistributions in binary form must reproduce the above copyright
1013536SN/A *    notice, this list of conditions and the following disclaimer in the
1023536SN/A *    documentation and/or other materials provided with the distribution.
1033536SN/A * 3. All advertising materials mentioning features or use of this software
1043536SN/A *    must display the following acknowledgement:
1055543SN/A *      This product includes software developed by the NetBSD
1065543SN/A *      Foundation, Inc. and its contributors.
1073536SN/A * 4. Neither the name of The NetBSD Foundation nor the names of its
1083536SN/A *    contributors may be used to endorse or promote products derived
1093536SN/A *    from this software without specific prior written permission.
1103536SN/A *
1113536SN/A * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1123536SN/A * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1133536SN/A * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1143536SN/A * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1153536SN/A * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1163536SN/A * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1173536SN/A * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1183536SN/A * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1193536SN/A * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1203536SN/A * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1213536SN/A * POSSIBILITY OF SUCH DAMAGE.
1223536SN/A */
1233536SN/A
1243536SN/A/*
1253536SN/A * $NetBSD: kgdb_stub.c,v 1.8 2001/07/07 22:58:00 wdk Exp $
1263536SN/A *
1273536SN/A * Taken from NetBSD
1283536SN/A *
1293536SN/A * "Stub" to allow remote cpu to debug over a serial line using gdb.
1303536SN/A */
1313536SN/A
1323536SN/A#include <sys/signal.h>
1335569SN/A#include <unistd.h>
1343536SN/A
1353536SN/A#include <string>
1363536SN/A
1379020Sgblack@eecs.umich.edu#include "arch/arm/decoder.hh"
1388229Snate@binkert.org#include "arch/arm/pagetable.hh"
1398229Snate@binkert.org#include "arch/arm/registers.hh"
1408229Snate@binkert.org#include "arch/arm/remote_gdb.hh"
14110037SARM gem5 Developers#include "arch/arm/system.hh"
1427752SWilliam.Wang@arm.com#include "arch/arm/utility.hh"
1437752SWilliam.Wang@arm.com#include "arch/arm/vtophys.hh"
1443536SN/A#include "base/intmath.hh"
1453536SN/A#include "base/remote_gdb.hh"
1463536SN/A#include "base/socket.hh"
1473536SN/A#include "base/trace.hh"
1488229Snate@binkert.org#include "cpu/static_inst.hh"
1493536SN/A#include "cpu/thread_context.hh"
1507752SWilliam.Wang@arm.com#include "cpu/thread_state.hh"
1518232Snate@binkert.org#include "debug/GDBAcc.hh"
1528232Snate@binkert.org#include "debug/GDBMisc.hh"
1538229Snate@binkert.org#include "mem/page_table.hh"
1543536SN/A#include "mem/physical.hh"
1553536SN/A#include "mem/port.hh"
1568782Sgblack@eecs.umich.edu#include "sim/full_system.hh"
1573536SN/A#include "sim/system.hh"
1583536SN/A
1593536SN/Ausing namespace std;
1607752SWilliam.Wang@arm.comusing namespace ArmISA;
1613536SN/A
1625569SN/ARemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
16310037SARM gem5 Developers    : BaseRemoteGDB(_system, tc, MAX_NUMREGS)
1643536SN/A{
1653536SN/A}
1663536SN/A
1675569SN/A/*
1685569SN/A * Determine if the mapping at va..(va+len) is valid.
1695569SN/A */
1703536SN/Abool
1713536SN/ARemoteGDB::acc(Addr va, size_t len)
1723536SN/A{
1738782Sgblack@eecs.umich.edu    if (FullSystem) {
1748782Sgblack@eecs.umich.edu        Addr last_va;
1758782Sgblack@eecs.umich.edu        va       = truncPage(va);
1768782Sgblack@eecs.umich.edu        last_va  = roundPage(va + len);
1773536SN/A
1788782Sgblack@eecs.umich.edu        do  {
1798782Sgblack@eecs.umich.edu            if (virtvalid(context, va)) {
1808782Sgblack@eecs.umich.edu                return true;
1818782Sgblack@eecs.umich.edu            }
1828782Sgblack@eecs.umich.edu            va += PageBytes;
1838782Sgblack@eecs.umich.edu        } while (va < last_va);
1848782Sgblack@eecs.umich.edu
1858782Sgblack@eecs.umich.edu        DPRINTF(GDBAcc, "acc:   %#x mapping is valid\n", va);
1868782Sgblack@eecs.umich.edu        return true;
1878782Sgblack@eecs.umich.edu    } else {
1888782Sgblack@eecs.umich.edu        TlbEntry entry;
1898782Sgblack@eecs.umich.edu        //Check to make sure the first byte is mapped into the processes address
1908782Sgblack@eecs.umich.edu        //space.
1918782Sgblack@eecs.umich.edu        if (context->getProcessPtr()->pTable->lookup(va, entry))
1923536SN/A            return true;
1938782Sgblack@eecs.umich.edu        return false;
1948782Sgblack@eecs.umich.edu    }
1953536SN/A}
1963536SN/A
1975569SN/A/*
1985569SN/A * Translate the kernel debugger register format into the GDB register
1995569SN/A * format.
2005569SN/A */
2013536SN/Avoid
2023536SN/ARemoteGDB::getregs()
2033536SN/A{
2047752SWilliam.Wang@arm.com    DPRINTF(GDBAcc, "getregs in remotegdb \n");
2057752SWilliam.Wang@arm.com
2063579SN/A    memset(gdbregs.regs, 0, gdbregs.bytes());
2073536SN/A
20810037SARM gem5 Developers    if (inAArch64(context)) {  // AArch64
20910037SARM gem5 Developers        // x0-x31
21010037SARM gem5 Developers        for (int i = 0; i < 32; ++i) {
21110037SARM gem5 Developers            gdbregs.regs[REG_X0 + i] = context->readIntReg(INTREG_X0 + i);
21210037SARM gem5 Developers        }
21310037SARM gem5 Developers        // pc
21410037SARM gem5 Developers        gdbregs.regs[REG_PC_64] = context->pcState().pc();
21510037SARM gem5 Developers        // cpsr
21610037SARM gem5 Developers        gdbregs.regs[REG_CPSR_64] = context->readMiscRegNoEffect(MISCREG_CPSR);
21710037SARM gem5 Developers        // v0-v31
21810037SARM gem5 Developers        for (int i = 0; i < 32; ++i) {
21910037SARM gem5 Developers            gdbregs.regs[REG_V0 + 2 * i] = static_cast<uint64_t>(
22010037SARM gem5 Developers                context->readFloatRegBits(i * 4 + 3)) << 32 |
22110037SARM gem5 Developers                    context->readFloatRegBits(i * 4 + 2);
22210037SARM gem5 Developers            gdbregs.regs[REG_V0 + 2 * i + 1] = static_cast<uint64_t>(
22310037SARM gem5 Developers                context->readFloatRegBits(i * 4 + 1)) << 32 |
22410037SARM gem5 Developers                    context->readFloatRegBits(i * 4 + 0);
22510037SARM gem5 Developers        }
22610037SARM gem5 Developers    } else {  // AArch32
22710037SARM gem5 Developers        // R0-R15 supervisor mode
22810037SARM gem5 Developers        // arm registers are 32 bits wide, gdb registers are 64 bits wide two
22910037SARM gem5 Developers        // arm registers are packed into one gdb register (little endian)
23010037SARM gem5 Developers        gdbregs.regs[REG_R0 + 0] = context->readIntReg(INTREG_R1) << 32 |
23110037SARM gem5 Developers            context->readIntReg(INTREG_R0);
23210037SARM gem5 Developers        gdbregs.regs[REG_R0 + 1] = context->readIntReg(INTREG_R3) << 32 |
23310037SARM gem5 Developers            context->readIntReg(INTREG_R2);
23410037SARM gem5 Developers        gdbregs.regs[REG_R0 + 2] = context->readIntReg(INTREG_R5) << 32 |
23510037SARM gem5 Developers            context->readIntReg(INTREG_R4);
23610037SARM gem5 Developers        gdbregs.regs[REG_R0 + 3] = context->readIntReg(INTREG_R7) << 32 |
23710037SARM gem5 Developers            context->readIntReg(INTREG_R6);
23810037SARM gem5 Developers        gdbregs.regs[REG_R0 + 4] = context->readIntReg(INTREG_R9) << 32 |
23910037SARM gem5 Developers            context->readIntReg(INTREG_R8);
24010037SARM gem5 Developers        gdbregs.regs[REG_R0 + 5] = context->readIntReg(INTREG_R11) << 32|
24110037SARM gem5 Developers            context->readIntReg(INTREG_R10);
24210037SARM gem5 Developers        gdbregs.regs[REG_R0 + 6] = context->readIntReg(INTREG_SP) << 32 |
24310037SARM gem5 Developers            context->readIntReg(INTREG_R12);
24410037SARM gem5 Developers        gdbregs.regs[REG_R0 + 7] = context->pcState().pc() << 32        |
24510037SARM gem5 Developers            context->readIntReg(INTREG_LR);
2463536SN/A
24710037SARM gem5 Developers        // CPSR
24810037SARM gem5 Developers        gdbregs.regs[REG_CPSR]  = context->readMiscRegNoEffect(MISCREG_CPSR);
2497752SWilliam.Wang@arm.com
25010037SARM gem5 Developers        // vfpv3/neon floating point registers (32 double or 64 float)
2517752SWilliam.Wang@arm.com
25210037SARM gem5 Developers        gdbregs.regs[REG_F0] =
25310037SARM gem5 Developers            static_cast<uint64_t>(context->readFloatRegBits(0)) << 32 |
25410037SARM gem5 Developers            gdbregs.regs[REG_CPSR];
2557752SWilliam.Wang@arm.com
25610037SARM gem5 Developers        for (int i = 1; i < (NumFloatV7ArchRegs>>1); ++i) {
25710037SARM gem5 Developers            gdbregs.regs[i + REG_F0] =
25810037SARM gem5 Developers                static_cast<uint64_t>(context->readFloatRegBits(2*i)) << 32 |
25910037SARM gem5 Developers                context->readFloatRegBits(2*i-1);
26010037SARM gem5 Developers        }
26110037SARM gem5 Developers
26210037SARM gem5 Developers        // FPSCR
26310037SARM gem5 Developers        gdbregs.regs[REG_FPSCR] = static_cast<uint64_t>(
26410037SARM gem5 Developers            context->readMiscRegNoEffect(MISCREG_FPSCR)) << 32 |
26510037SARM gem5 Developers                context->readFloatRegBits(NumFloatV7ArchRegs - 1);
2663536SN/A    }
2673536SN/A}
2683536SN/A
2695569SN/A/*
2705569SN/A * Translate the GDB register format into the kernel debugger register
2715569SN/A * format.
2725569SN/A */
2733536SN/Avoid
2743536SN/ARemoteGDB::setregs()
2753536SN/A{
2767752SWilliam.Wang@arm.com
2777752SWilliam.Wang@arm.com    DPRINTF(GDBAcc, "setregs in remotegdb \n");
27810037SARM gem5 Developers    if (inAArch64(context)) {  // AArch64
27910037SARM gem5 Developers        // x0-x31
28010037SARM gem5 Developers        for (int i = 0; i < 32; ++i) {
28110037SARM gem5 Developers            context->setIntReg(INTREG_X0 + i, gdbregs.regs[REG_X0 + i]);
28210037SARM gem5 Developers        }
28310037SARM gem5 Developers        // pc
28410037SARM gem5 Developers        context->pcState(gdbregs.regs[REG_PC_64]);
28510037SARM gem5 Developers        // cpsr
28610037SARM gem5 Developers        context->setMiscRegNoEffect(MISCREG_CPSR, gdbregs.regs[REG_CPSR_64]);
28710037SARM gem5 Developers        // v0-v31
28810037SARM gem5 Developers        for (int i = 0; i < 32; ++i) {
28910037SARM gem5 Developers          context->setFloatRegBits(i * 4 + 3,
29010037SARM gem5 Developers                                   gdbregs.regs[REG_V0 + 2 * i] >> 32);
29110037SARM gem5 Developers          context->setFloatRegBits(i * 4 + 2,
29210037SARM gem5 Developers                                   gdbregs.regs[REG_V0 + 2 * i]);
29310037SARM gem5 Developers          context->setFloatRegBits(i * 4 + 1,
29410037SARM gem5 Developers                                   gdbregs.regs[REG_V0 + 2 * i + 1] >> 32);
29510037SARM gem5 Developers          context->setFloatRegBits(i * 4 + 0,
29610037SARM gem5 Developers                                   gdbregs.regs[REG_V0 + 2 * i + 1]);
29710037SARM gem5 Developers        }
29810037SARM gem5 Developers    } else {  // AArch32
29910037SARM gem5 Developers        // R0-R15 supervisor mode
30010037SARM gem5 Developers        // arm registers are 32 bits wide, gdb registers are 64 bits wide
30110037SARM gem5 Developers        // two arm registers are packed into one gdb register (little endian)
30210037SARM gem5 Developers        context->setIntReg(INTREG_R0 , bits(gdbregs.regs[REG_R0 + 0], 31, 0));
30310037SARM gem5 Developers        context->setIntReg(INTREG_R1 , bits(gdbregs.regs[REG_R0 + 0], 63, 32));
30410037SARM gem5 Developers        context->setIntReg(INTREG_R2 , bits(gdbregs.regs[REG_R0 + 1], 31, 0));
30510037SARM gem5 Developers        context->setIntReg(INTREG_R3 , bits(gdbregs.regs[REG_R0 + 1], 63, 32));
30610037SARM gem5 Developers        context->setIntReg(INTREG_R4 , bits(gdbregs.regs[REG_R0 + 2], 31, 0));
30710037SARM gem5 Developers        context->setIntReg(INTREG_R5 , bits(gdbregs.regs[REG_R0 + 2], 63, 32));
30810037SARM gem5 Developers        context->setIntReg(INTREG_R6 , bits(gdbregs.regs[REG_R0 + 3], 31, 0));
30910037SARM gem5 Developers        context->setIntReg(INTREG_R7 , bits(gdbregs.regs[REG_R0 + 3], 63, 32));
31010037SARM gem5 Developers        context->setIntReg(INTREG_R8 , bits(gdbregs.regs[REG_R0 + 4], 31, 0));
31110037SARM gem5 Developers        context->setIntReg(INTREG_R9 , bits(gdbregs.regs[REG_R0 + 4], 63, 32));
31210037SARM gem5 Developers        context->setIntReg(INTREG_R10, bits(gdbregs.regs[REG_R0 + 5], 31, 0));
31310037SARM gem5 Developers        context->setIntReg(INTREG_R11, bits(gdbregs.regs[REG_R0 + 5], 63, 32));
31410037SARM gem5 Developers        context->setIntReg(INTREG_R12, bits(gdbregs.regs[REG_R0 + 6], 31, 0));
31510037SARM gem5 Developers        context->setIntReg(INTREG_SP , bits(gdbregs.regs[REG_R0 + 6], 63, 32));
31610037SARM gem5 Developers        context->setIntReg(INTREG_LR , bits(gdbregs.regs[REG_R0 + 7], 31, 0));
31710037SARM gem5 Developers        context->pcState(bits(gdbregs.regs[REG_R0 + 7], 63, 32));
3187752SWilliam.Wang@arm.com
31910037SARM gem5 Developers        //CPSR
32010037SARM gem5 Developers        context->setMiscRegNoEffect(MISCREG_CPSR, gdbregs.regs[REG_CPSR]);
3217752SWilliam.Wang@arm.com
32210037SARM gem5 Developers        //vfpv3/neon floating point registers (32 double or 64 float)
32310037SARM gem5 Developers        context->setFloatRegBits(0, gdbregs.regs[REG_F0]>>32);
3247752SWilliam.Wang@arm.com
32510037SARM gem5 Developers        for (int i = 1; i < NumFloatV7ArchRegs; ++i) {
32610037SARM gem5 Developers            if (i%2) {
32710037SARM gem5 Developers                int j = (i+1)/2;
32810037SARM gem5 Developers                context->setFloatRegBits(i, bits(gdbregs.regs[j + REG_F0], 31, 0));
32910037SARM gem5 Developers            } else {
33010037SARM gem5 Developers                int j = i/2;
33110037SARM gem5 Developers                context->setFloatRegBits(i, gdbregs.regs[j + REG_F0]>>32);
33210037SARM gem5 Developers            }
33310037SARM gem5 Developers        }
3347752SWilliam.Wang@arm.com
33510037SARM gem5 Developers        //FPSCR
33610037SARM gem5 Developers        context->setMiscReg(MISCREG_FPSCR, gdbregs.regs[REG_FPSCR]>>32);
3373536SN/A    }
3383536SN/A}
3393536SN/A
3403536SN/Avoid
3413536SN/ARemoteGDB::clearSingleStep()
3423536SN/A{
3433536SN/A    DPRINTF(GDBMisc, "clearSingleStep bt_addr=%#x nt_addr=%#x\n",
3443550SN/A            takenBkpt, notTakenBkpt);
3453536SN/A
3463550SN/A    if (takenBkpt != 0)
3473536SN/A        clearTempBreakpoint(takenBkpt);
3483536SN/A
3493550SN/A    if (notTakenBkpt != 0)
3503536SN/A        clearTempBreakpoint(notTakenBkpt);
3513536SN/A}
3523536SN/A
3533536SN/Avoid
3543536SN/ARemoteGDB::setSingleStep()
3553536SN/A{
3567720SN/A    PCState pc = context->pcState();
3577720SN/A    PCState bpc;
3583536SN/A    bool set_bt = false;
3593536SN/A
3603536SN/A    // User was stopped at pc, e.g. the instruction at pc was not
3613536SN/A    // executed.
3627720SN/A    MachInst inst = read<MachInst>(pc.pc());
3638541Sgblack@eecs.umich.edu    StaticInstPtr si = context->getDecoderPtr()->decode(inst, pc.pc());
3643536SN/A    if (si->hasBranchTarget(pc, context, bpc)) {
3653536SN/A        // Don't bother setting a breakpoint on the taken branch if it
3663536SN/A        // is the same as the next pc
3677720SN/A        if (bpc.pc() != pc.npc())
3683536SN/A            set_bt = true;
3693536SN/A    }
3703536SN/A
3713536SN/A    DPRINTF(GDBMisc, "setSingleStep bt_addr=%#x nt_addr=%#x\n",
3723550SN/A            takenBkpt, notTakenBkpt);
3733536SN/A
3747720SN/A    setTempBreakpoint(notTakenBkpt = pc.npc());
3753536SN/A
3763536SN/A    if (set_bt)
3777720SN/A        setTempBreakpoint(takenBkpt = bpc.pc());
3783536SN/A}
3793536SN/A
3803536SN/A// Write bytes to kernel address space for debugger.
3813536SN/Abool
3823536SN/ARemoteGDB::write(Addr vaddr, size_t size, const char *data)
3833536SN/A{
3847752SWilliam.Wang@arm.com    return BaseRemoteGDB::write(vaddr, size, data);
3853536SN/A}
3863536SN/A
387