remote_gdb.cc revision 10707
15132Sgblack@eecs.umich.edu/*
25132Sgblack@eecs.umich.edu * Copyright 2014 Google Inc.
35132Sgblack@eecs.umich.edu * Copyright (c) 2010, 2013 ARM Limited
45132Sgblack@eecs.umich.edu * All rights reserved
55132Sgblack@eecs.umich.edu *
65132Sgblack@eecs.umich.edu * The license below extends only to copyright in the software and shall
75132Sgblack@eecs.umich.edu * not be construed as granting a license to any other intellectual
85132Sgblack@eecs.umich.edu * property including but not limited to intellectual property relating
95132Sgblack@eecs.umich.edu * to a hardware implementation of the functionality of the software
105132Sgblack@eecs.umich.edu * licensed hereunder.  You may use the software subject to the license
115132Sgblack@eecs.umich.edu * terms below provided that you ensure that this notice is replicated
125132Sgblack@eecs.umich.edu * unmodified and in its entirety in all distributions of the software,
135132Sgblack@eecs.umich.edu * modified or unmodified, in source code or in binary form.
145132Sgblack@eecs.umich.edu *
155132Sgblack@eecs.umich.edu * Copyright (c) 2002-2005 The Regents of The University of Michigan
165132Sgblack@eecs.umich.edu * All rights reserved.
175132Sgblack@eecs.umich.edu *
185132Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
195132Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
205132Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
215132Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
225132Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
235132Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
245132Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
255132Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
265132Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
275132Sgblack@eecs.umich.edu * this software without specific prior written permission.
285132Sgblack@eecs.umich.edu *
295132Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
305132Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
315132Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
325132Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
335132Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
345132Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
355132Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
365132Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
375132Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
385132Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
395132Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
405132Sgblack@eecs.umich.edu *
415132Sgblack@eecs.umich.edu * Authors: Nathan Binkert
425132Sgblack@eecs.umich.edu *          William Wang
435132Sgblack@eecs.umich.edu */
445132Sgblack@eecs.umich.edu
455132Sgblack@eecs.umich.edu/*
465132Sgblack@eecs.umich.edu * Copyright (c) 1990, 1993 The Regents of the University of California
475132Sgblack@eecs.umich.edu * All rights reserved
485132Sgblack@eecs.umich.edu *
495132Sgblack@eecs.umich.edu * This software was developed by the Computer Systems Engineering group
505132Sgblack@eecs.umich.edu * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
515132Sgblack@eecs.umich.edu * contributed to Berkeley.
525132Sgblack@eecs.umich.edu *
535132Sgblack@eecs.umich.edu * All advertising materials mentioning features or use of this software
545132Sgblack@eecs.umich.edu * must display the following acknowledgement:
555132Sgblack@eecs.umich.edu *      This product includes software developed by the University of
565132Sgblack@eecs.umich.edu *      California, Lawrence Berkeley Laboratories.
575132Sgblack@eecs.umich.edu *
585612Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
595625Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions
605299Sgblack@eecs.umich.edu * are met:
615132Sgblack@eecs.umich.edu * 1. Redistributions of source code must retain the above copyright
625132Sgblack@eecs.umich.edu *    notice, this list of conditions and the following disclaimer.
635625Sgblack@eecs.umich.edu * 2. Redistributions in binary form must reproduce the above copyright
645132Sgblack@eecs.umich.edu *    notice, this list of conditions and the following disclaimer in the
655132Sgblack@eecs.umich.edu *    documentation and/or other materials provided with the distribution.
665625Sgblack@eecs.umich.edu * 3. All advertising materials mentioning features or use of this software
675132Sgblack@eecs.umich.edu *    must display the following acknowledgement:
685299Sgblack@eecs.umich.edu *      This product includes software developed by the University of
695132Sgblack@eecs.umich.edu *      California, Berkeley and its contributors.
705132Sgblack@eecs.umich.edu * 4. Neither the name of the University nor the names of its contributors
715132Sgblack@eecs.umich.edu *    may be used to endorse or promote products derived from this software
725132Sgblack@eecs.umich.edu *    without specific prior written permission.
735132Sgblack@eecs.umich.edu *
745299Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
755299Sgblack@eecs.umich.edu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
765132Sgblack@eecs.umich.edu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
775625Sgblack@eecs.umich.edu * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
785625Sgblack@eecs.umich.edu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
795625Sgblack@eecs.umich.edu * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
805627Sgblack@eecs.umich.edu * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
815627Sgblack@eecs.umich.edu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
825615Sgblack@eecs.umich.edu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
835132Sgblack@eecs.umich.edu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
846220Sgblack@eecs.umich.edu * SUCH DAMAGE.
856220Sgblack@eecs.umich.edu *
866220Sgblack@eecs.umich.edu *      @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94
876220Sgblack@eecs.umich.edu */
886220Sgblack@eecs.umich.edu
896220Sgblack@eecs.umich.edu/*-
906220Sgblack@eecs.umich.edu * Copyright (c) 2001 The NetBSD Foundation, Inc.
916220Sgblack@eecs.umich.edu * All rights reserved.
926220Sgblack@eecs.umich.edu *
936220Sgblack@eecs.umich.edu * This code is derived from software contributed to The NetBSD Foundation
946220Sgblack@eecs.umich.edu * by Jason R. Thorpe.
956220Sgblack@eecs.umich.edu *
966222Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
976222Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions
986222Sgblack@eecs.umich.edu * are met:
996222Sgblack@eecs.umich.edu * 1. Redistributions of source code must retain the above copyright
1006222Sgblack@eecs.umich.edu *    notice, this list of conditions and the following disclaimer.
1016222Sgblack@eecs.umich.edu * 2. Redistributions in binary form must reproduce the above copyright
1026222Sgblack@eecs.umich.edu *    notice, this list of conditions and the following disclaimer in the
1036222Sgblack@eecs.umich.edu *    documentation and/or other materials provided with the distribution.
1046222Sgblack@eecs.umich.edu * 3. All advertising materials mentioning features or use of this software
1056222Sgblack@eecs.umich.edu *    must display the following acknowledgement:
1066220Sgblack@eecs.umich.edu *      This product includes software developed by the NetBSD
1076220Sgblack@eecs.umich.edu *      Foundation, Inc. and its contributors.
1086220Sgblack@eecs.umich.edu * 4. Neither the name of The NetBSD Foundation nor the names of its
1096222Sgblack@eecs.umich.edu *    contributors may be used to endorse or promote products derived
1106220Sgblack@eecs.umich.edu *    from this software without specific prior written permission.
1116222Sgblack@eecs.umich.edu *
1126220Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1136220Sgblack@eecs.umich.edu * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1146222Sgblack@eecs.umich.edu * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1156220Sgblack@eecs.umich.edu * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1166220Sgblack@eecs.umich.edu * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1176220Sgblack@eecs.umich.edu * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1186220Sgblack@eecs.umich.edu * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1196222Sgblack@eecs.umich.edu * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1206220Sgblack@eecs.umich.edu * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1216220Sgblack@eecs.umich.edu * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1226220Sgblack@eecs.umich.edu * POSSIBILITY OF SUCH DAMAGE.
1236220Sgblack@eecs.umich.edu */
1246220Sgblack@eecs.umich.edu
1256220Sgblack@eecs.umich.edu/*
1266220Sgblack@eecs.umich.edu * $NetBSD: kgdb_stub.c,v 1.8 2001/07/07 22:58:00 wdk Exp $
1276220Sgblack@eecs.umich.edu *
1286220Sgblack@eecs.umich.edu * Taken from NetBSD
1296220Sgblack@eecs.umich.edu *
1305299Sgblack@eecs.umich.edu * "Stub" to allow remote cpu to debug over a serial line using gdb.
1315299Sgblack@eecs.umich.edu */
1325299Sgblack@eecs.umich.edu
1335299Sgblack@eecs.umich.edu#include <sys/signal.h>
1346220Sgblack@eecs.umich.edu#include <unistd.h>
1355299Sgblack@eecs.umich.edu
1365299Sgblack@eecs.umich.edu#include <string>
1375299Sgblack@eecs.umich.edu
1385299Sgblack@eecs.umich.edu#include "arch/arm/decoder.hh"
1395299Sgblack@eecs.umich.edu#include "arch/arm/pagetable.hh"
1405299Sgblack@eecs.umich.edu#include "arch/arm/registers.hh"
1415299Sgblack@eecs.umich.edu#include "arch/arm/remote_gdb.hh"
1425299Sgblack@eecs.umich.edu#include "arch/arm/system.hh"
1435299Sgblack@eecs.umich.edu#include "arch/arm/utility.hh"
1445299Sgblack@eecs.umich.edu#include "arch/arm/vtophys.hh"
1455299Sgblack@eecs.umich.edu#include "base/chunk_generator.hh"
1465299Sgblack@eecs.umich.edu#include "base/intmath.hh"
1475299Sgblack@eecs.umich.edu#include "base/remote_gdb.hh"
1485299Sgblack@eecs.umich.edu#include "base/socket.hh"
1495299Sgblack@eecs.umich.edu#include "base/trace.hh"
1505299Sgblack@eecs.umich.edu#include "cpu/static_inst.hh"
1515299Sgblack@eecs.umich.edu#include "cpu/thread_context.hh"
1525299Sgblack@eecs.umich.edu#include "cpu/thread_state.hh"
1535299Sgblack@eecs.umich.edu#include "debug/GDBAcc.hh"
1545299Sgblack@eecs.umich.edu#include "debug/GDBMisc.hh"
1555299Sgblack@eecs.umich.edu#include "mem/page_table.hh"
1566220Sgblack@eecs.umich.edu#include "mem/physical.hh"
1575299Sgblack@eecs.umich.edu#include "mem/port.hh"
1585299Sgblack@eecs.umich.edu#include "sim/full_system.hh"
1595299Sgblack@eecs.umich.edu#include "sim/system.hh"
1605299Sgblack@eecs.umich.edu
1616220Sgblack@eecs.umich.eduusing namespace std;
1625299Sgblack@eecs.umich.eduusing namespace ArmISA;
1635299Sgblack@eecs.umich.edu
1646220Sgblack@eecs.umich.eduRemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
1656220Sgblack@eecs.umich.edu    : BaseRemoteGDB(_system, tc, GDB_REG_BYTES)
1666220Sgblack@eecs.umich.edu{
1675299Sgblack@eecs.umich.edu}
1685299Sgblack@eecs.umich.edu
1695299Sgblack@eecs.umich.edu/*
1706220Sgblack@eecs.umich.edu * Determine if the mapping at va..(va+len) is valid.
1715299Sgblack@eecs.umich.edu */
1726220Sgblack@eecs.umich.edubool
1735299Sgblack@eecs.umich.eduRemoteGDB::acc(Addr va, size_t len)
1745299Sgblack@eecs.umich.edu{
1755299Sgblack@eecs.umich.edu    if (FullSystem) {
1765299Sgblack@eecs.umich.edu        for (ChunkGenerator gen(va, len, PageBytes); !gen.done(); gen.next()) {
1776220Sgblack@eecs.umich.edu            if (!virtvalid(context, gen.addr())) {
1786220Sgblack@eecs.umich.edu                DPRINTF(GDBAcc, "acc:   %#x mapping is invalid\n", va);
1796220Sgblack@eecs.umich.edu                return false;
1806220Sgblack@eecs.umich.edu            }
1815299Sgblack@eecs.umich.edu        }
1825299Sgblack@eecs.umich.edu
1835299Sgblack@eecs.umich.edu        DPRINTF(GDBAcc, "acc:   %#x mapping is valid\n", va);
1845299Sgblack@eecs.umich.edu        return true;
1855299Sgblack@eecs.umich.edu    } else {
1866220Sgblack@eecs.umich.edu        TlbEntry entry;
1876220Sgblack@eecs.umich.edu        //Check to make sure the first byte is mapped into the processes address
1885299Sgblack@eecs.umich.edu        //space.
1896220Sgblack@eecs.umich.edu        if (context->getProcessPtr()->pTable->lookup(va, entry))
1906220Sgblack@eecs.umich.edu            return true;
1916220Sgblack@eecs.umich.edu        return false;
1926220Sgblack@eecs.umich.edu    }
1936220Sgblack@eecs.umich.edu}
1946220Sgblack@eecs.umich.edu
1956220Sgblack@eecs.umich.edu/*
1966220Sgblack@eecs.umich.edu * Translate the kernel debugger register format into the GDB register
1976220Sgblack@eecs.umich.edu * format.
1986220Sgblack@eecs.umich.edu */
1996220Sgblack@eecs.umich.eduvoid
2006220Sgblack@eecs.umich.eduRemoteGDB::getregs()
2016220Sgblack@eecs.umich.edu{
2026220Sgblack@eecs.umich.edu    DPRINTF(GDBAcc, "getregs in remotegdb \n");
2036220Sgblack@eecs.umich.edu
2046220Sgblack@eecs.umich.edu    memset(gdbregs.regs, 0, gdbregs.bytes());
2056220Sgblack@eecs.umich.edu
2066220Sgblack@eecs.umich.edu    if (inAArch64(context)) {  // AArch64
2076220Sgblack@eecs.umich.edu        // x0-x31
2086220Sgblack@eecs.umich.edu        for (int i = 0; i < 32; ++i)
2096220Sgblack@eecs.umich.edu            gdbregs.regs64[GDB64_X0 + i] = context->readIntReg(INTREG_X0 + i);
2106220Sgblack@eecs.umich.edu        // pc
2116220Sgblack@eecs.umich.edu        gdbregs.regs64[GDB64_PC] = context->pcState().pc();
2126220Sgblack@eecs.umich.edu        // cpsr
2136220Sgblack@eecs.umich.edu        gdbregs.regs64[GDB64_CPSR] =
2146712Snate@binkert.org            context->readMiscRegNoEffect(MISCREG_CPSR);
2156220Sgblack@eecs.umich.edu        // v0-v31
2166220Sgblack@eecs.umich.edu        for (int i = 0; i < 128; i += 4) {
2176220Sgblack@eecs.umich.edu            int gdboff = GDB64_V0_32 + i;
2186220Sgblack@eecs.umich.edu            gdbregs.regs32[gdboff + 0] = context->readFloatRegBits(i + 2);
2196220Sgblack@eecs.umich.edu            gdbregs.regs32[gdboff + 1] = context->readFloatRegBits(i + 3);
2206220Sgblack@eecs.umich.edu            gdbregs.regs32[gdboff + 2] = context->readFloatRegBits(i + 0);
2216220Sgblack@eecs.umich.edu            gdbregs.regs32[gdboff + 3] = context->readFloatRegBits(i + 1);
2226220Sgblack@eecs.umich.edu        }
2236220Sgblack@eecs.umich.edu    } else {  // AArch32
2246220Sgblack@eecs.umich.edu        // R0-R15 supervisor mode
2256220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 0] = context->readIntReg(INTREG_R0);
2266220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 1] = context->readIntReg(INTREG_R1);
2276220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 2] = context->readIntReg(INTREG_R2);
2286220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 3] = context->readIntReg(INTREG_R3);
2296220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 4] = context->readIntReg(INTREG_R4);
2306220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 5] = context->readIntReg(INTREG_R5);
2316220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 6] = context->readIntReg(INTREG_R6);
2326220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 7] = context->readIntReg(INTREG_R7);
2336220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 8] = context->readIntReg(INTREG_R8);
2346220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 9] = context->readIntReg(INTREG_R9);
2356220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 10] = context->readIntReg(INTREG_R10);
2366220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 11] = context->readIntReg(INTREG_R11);
2376220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 12] = context->readIntReg(INTREG_R12);
2386220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 13] = context->readIntReg(INTREG_SP);
2396220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 14] = context->readIntReg(INTREG_LR);
2406220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_R0 + 15] = context->pcState().pc();
2416220Sgblack@eecs.umich.edu
2426220Sgblack@eecs.umich.edu        // CPSR
2436220Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_CPSR] = context->readMiscRegNoEffect(MISCREG_CPSR);
2446220Sgblack@eecs.umich.edu
2456220Sgblack@eecs.umich.edu        // vfpv3/neon floating point registers (32 double or 64 float)
2466220Sgblack@eecs.umich.edu        for (int i = 0; i < NumFloatV7ArchRegs; ++i)
2475299Sgblack@eecs.umich.edu            gdbregs.regs32[GDB32_F0 + i] = context->readFloatRegBits(i);
2485299Sgblack@eecs.umich.edu
2495299Sgblack@eecs.umich.edu        // FPSCR
2505299Sgblack@eecs.umich.edu        gdbregs.regs32[GDB32_FPSCR] =
2515299Sgblack@eecs.umich.edu            context->readMiscRegNoEffect(MISCREG_FPSCR);
2525299Sgblack@eecs.umich.edu    }
2535299Sgblack@eecs.umich.edu}
2545299Sgblack@eecs.umich.edu
2555299Sgblack@eecs.umich.edu/*
2565299Sgblack@eecs.umich.edu * Translate the GDB register format into the kernel debugger register
2575299Sgblack@eecs.umich.edu * format.
2585299Sgblack@eecs.umich.edu */
2595299Sgblack@eecs.umich.eduvoid
2605299Sgblack@eecs.umich.eduRemoteGDB::setregs()
2615299Sgblack@eecs.umich.edu{
2625299Sgblack@eecs.umich.edu
2635299Sgblack@eecs.umich.edu    DPRINTF(GDBAcc, "setregs in remotegdb \n");
2645299Sgblack@eecs.umich.edu    if (inAArch64(context)) {  // AArch64
2655299Sgblack@eecs.umich.edu        // x0-x31
2665299Sgblack@eecs.umich.edu        for (int i = 0; i < 32; ++i)
2675299Sgblack@eecs.umich.edu            context->setIntReg(INTREG_X0 + i, gdbregs.regs64[GDB64_X0 + i]);
2685299Sgblack@eecs.umich.edu        // pc
2695299Sgblack@eecs.umich.edu        context->pcState(gdbregs.regs64[GDB64_PC]);
2705299Sgblack@eecs.umich.edu        // cpsr
2715299Sgblack@eecs.umich.edu        context->setMiscRegNoEffect(MISCREG_CPSR, gdbregs.regs64[GDB64_CPSR]);
2725299Sgblack@eecs.umich.edu        // v0-v31
2735299Sgblack@eecs.umich.edu        for (int i = 0; i < 128; i += 4) {
2745299Sgblack@eecs.umich.edu            int gdboff = GDB64_V0_32 + i;
2755299Sgblack@eecs.umich.edu            context->setFloatRegBits(i + 2, gdbregs.regs32[gdboff + 0]);
2765299Sgblack@eecs.umich.edu            context->setFloatRegBits(i + 3, gdbregs.regs32[gdboff + 1]);
2775299Sgblack@eecs.umich.edu            context->setFloatRegBits(i + 0, gdbregs.regs32[gdboff + 2]);
2785299Sgblack@eecs.umich.edu            context->setFloatRegBits(i + 1, gdbregs.regs32[gdboff + 3]);
2795299Sgblack@eecs.umich.edu        }
2805299Sgblack@eecs.umich.edu    } else {  // AArch32
2815299Sgblack@eecs.umich.edu        // R0-R15 supervisor mode
2825299Sgblack@eecs.umich.edu        // arm registers are 32 bits wide, gdb registers are 64 bits wide
2835299Sgblack@eecs.umich.edu        // two arm registers are packed into one gdb register (little endian)
2845299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R0, gdbregs.regs32[GDB32_R0 + 0]);
2855299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R1, gdbregs.regs32[GDB32_R0 + 1]);
2865299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R2, gdbregs.regs32[GDB32_R0 + 2]);
2875299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R3, gdbregs.regs32[GDB32_R0 + 3]);
2885299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R4, gdbregs.regs32[GDB32_R0 + 4]);
2895299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R5, gdbregs.regs32[GDB32_R0 + 5]);
2905299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R6, gdbregs.regs32[GDB32_R0 + 6]);
2915299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R7, gdbregs.regs32[GDB32_R0 + 7]);
2925299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R8, gdbregs.regs32[GDB32_R0 + 8]);
2935299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R9, gdbregs.regs32[GDB32_R0 + 9]);
2945299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R10, gdbregs.regs32[GDB32_R0 + 10]);
2955299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R11, gdbregs.regs32[GDB32_R0 + 11]);
2965299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_R12, gdbregs.regs32[GDB32_R0 + 12]);
2975299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_SP, gdbregs.regs32[GDB32_R0 + 13]);
2985299Sgblack@eecs.umich.edu        context->setIntReg(INTREG_LR, gdbregs.regs32[GDB32_R0 + 14]);
2995299Sgblack@eecs.umich.edu        context->pcState(gdbregs.regs32[GDB32_R0 + 7]);
3005299Sgblack@eecs.umich.edu
3015299Sgblack@eecs.umich.edu        //CPSR
3025299Sgblack@eecs.umich.edu        context->setMiscRegNoEffect(MISCREG_CPSR, gdbregs.regs32[GDB32_CPSR]);
3035299Sgblack@eecs.umich.edu
3045299Sgblack@eecs.umich.edu        //vfpv3/neon floating point registers (32 double or 64 float)
3056220Sgblack@eecs.umich.edu        for (int i = 0; i < NumFloatV7ArchRegs; ++i)
3065299Sgblack@eecs.umich.edu            context->setFloatRegBits(i, gdbregs.regs32[GDB32_F0 + i]);
3075299Sgblack@eecs.umich.edu
3086220Sgblack@eecs.umich.edu        //FPSCR
3095299Sgblack@eecs.umich.edu        context->setMiscReg(MISCREG_FPSCR, gdbregs.regs32[GDB32_FPSCR]);
3105299Sgblack@eecs.umich.edu    }
3116220Sgblack@eecs.umich.edu}
3125299Sgblack@eecs.umich.edu
3136220Sgblack@eecs.umich.edu// Write bytes to kernel address space for debugger.
3145299Sgblack@eecs.umich.edubool
3155299Sgblack@eecs.umich.eduRemoteGDB::write(Addr vaddr, size_t size, const char *data)
3166220Sgblack@eecs.umich.edu{
3175299Sgblack@eecs.umich.edu    return BaseRemoteGDB::write(vaddr, size, data);
3185299Sgblack@eecs.umich.edu}
3196220Sgblack@eecs.umich.edu
3205299Sgblack@eecs.umich.edu