changeset d9a0136ab8cc in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=d9a0136ab8cc
description:
        arm: remote GDB: rationalize structure of register offsets

        Currently, the wire format of register values in g- and G-packets is
        modelled using a union of uint8/16/32/64 arrays.  The offset positions
        of each register are expressed as a "register count" scaled according
        to the width of the register in question.  This results in counter-
        intuitive and error-prone "register count arithmetic", and some
        formats would even be altogether unrepresentable in such model, e.g.
        a 64-bit register following a 32-bit one would have a fractional index
        in the regs64 array.
        Another difficulty is that the array is allocated before the actual
        architecture of the workload is known (and therefore before the correct
        size for the array can be calculated).

        With this patch I propose a simpler mechanism for expressing the
        register set structure.  In the new code, GdbRegCache is an abstract
        class; its subclasses contain straightforward structs reflecting the
        register representation.  The determination whether to use e.g. the
        AArch32 vs. AArch64 register set (or SPARCv8 vs SPARCv9, etc.) is made
        by polymorphically dispatching getregs() to the concrete subclass.
        The subclass is not instantiated until it is needed for actual
        g-/G-packet processing, when the mode is already known.

        This patch is not meant to be merged in on its own, because it changes
        the contract between src/base/remote_gdb.* and src/arch/*/remote_gdb.*,
        so as it stands right now, it would break the other architectures.
        In this patch only the base and the ARM code are provided for review;
        once we agree on the structure, I will provide src/arch/*/remote_gdb.*
        for the other architectures; those patches could then be merged in
        together.

        Review Request: http://reviews.gem5.org/r/3207/
        Pushed by Joel Hestness <[email protected]>

diffstat:

 src/arch/alpha/kgdb.h        |  163 ---------------------------
 src/arch/alpha/remote_gdb.cc |   58 ++++-----
 src/arch/alpha/remote_gdb.hh |   25 +++-
 src/arch/arm/remote_gdb.cc   |  206 +++++++++++++++-------------------
 src/arch/arm/remote_gdb.hh   |   67 ++++++----
 src/arch/mips/remote_gdb.cc  |   87 +++++---------
 src/arch/mips/remote_gdb.hh  |   52 +++++---
 src/arch/power/remote_gdb.cc |   70 ++++-------
 src/arch/power/remote_gdb.hh |   50 ++++---
 src/arch/sparc/remote_gdb.cc |  115 ++++++++++--------
 src/arch/sparc/remote_gdb.hh |   69 ++++++++---
 src/arch/x86/remote_gdb.cc   |  253 +++++++++++++++++++++---------------------
 src/arch/x86/remote_gdb.hh   |  141 ++++++++++++-----------
 src/base/remote_gdb.cc       |   60 +++------
 src/base/remote_gdb.hh       |   76 ++++++++----
 15 files changed, 686 insertions(+), 806 deletions(-)

diffs (truncated from 2096 to 300 lines):

diff -r 36dfd27e4a4e -r d9a0136ab8cc src/arch/alpha/kgdb.h
--- a/src/arch/alpha/kgdb.h     Fri Dec 18 10:14:17 2015 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 1992, 1993 The Regents of the University of California
- * All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Lawrence Berkeley Laboratories.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)remote-sl.h 8.1 (Berkeley) 6/11/93
- */
-
-/*     $NetBSD: kgdb.h,v 1.4 1998/08/13 02:10:59 eeh Exp $     */
-
-#ifndef __KGDB_H__
-#define __KGDB_H__
-
-/*
- * Message types.
- */
-#define KGDB_SIGNAL            '?'     // last sigal
-#define KGDB_SET_BAUD          'b'     // set baud (deprecated)
-#define KGDB_SET_BREAK         'B'     // set breakpoint (deprecated)
-#define KGDB_CONT              'c'     // resume
-#define KGDB_ASYNC_CONT                'C'     // continue with signal
-#define KGDB_DEBUG             'd'     // toggle debug flags (deprecated)
-#define KGDB_DETACH            'D'     // detach remote gdb
-#define KGDB_REG_R             'g'     // read general registers
-#define KGDB_REG_W             'G'     // write general registers
-#define KGDB_SET_THREAD                'H'     // set thread
-#define KGDB_CYCLE_STEP                'i'     // step a single cycle
-#define KGDB_SIG_CYCLE_STEP    'I'     // signal then single cycle step
-#define KGDB_KILL              'k'     // kill program
-#define KGDB_MEM_R             'm'     // read memory
-#define KGDB_MEM_W             'M'     // write memory
-#define KGDB_READ_REG          'p'     // read register
-#define KGDB_SET_REG           'P'     // write register
-#define KGDB_QUERY_VAR         'q'     // query variable
-#define KGDB_SET_VAR           'Q'     // set variable
-#define KGDB_RESET             'r'     // reset system.  (Deprecated)
-#define KGDB_STEP              's'     // step
-#define KGDB_ASYNC_STEP                'S'     // signal and step
-#define KGDB_THREAD_ALIVE      'T'     // find out if the thread is alive.
-#define KGDB_TARGET_EXIT       'W'     // target exited
-#define KGDB_BINARY_DLOAD      'X'     // write memory
-#define KGDB_CLR_HW_BKPT       'z'     // remove breakpoint or watchpoint
-#define KGDB_SET_HW_BKPT       'Z'     // insert breakpoint or watchpoint
-
-/*
- * start of frame/end of frame
- */
-#define KGDB_START     '$'
-#define KGDB_END       '#'
-#define KGDB_GOODP     '+'
-#define KGDB_BADP      '-'
-
-/*
- * Stuff for KGDB.
- */
-#define        KGDB_NUMREGS    66      /* from tm-alpha.h, NUM_REGS */
-#define        KGDB_REG_V0     0
-#define        KGDB_REG_T0     1
-#define        KGDB_REG_T1     2
-#define        KGDB_REG_T2     3
-#define        KGDB_REG_T3     4
-#define        KGDB_REG_T4     5
-#define        KGDB_REG_T5     6
-#define        KGDB_REG_T6     7
-#define        KGDB_REG_T7     8
-#define        KGDB_REG_S0     9
-#define        KGDB_REG_S1     10
-#define        KGDB_REG_S2     11
-#define        KGDB_REG_S3     12
-#define        KGDB_REG_S4     13
-#define        KGDB_REG_S5     14
-#define        KGDB_REG_S6     15      /* FP */
-#define        KGDB_REG_A0     16
-#define        KGDB_REG_A1     17
-#define        KGDB_REG_A2     18
-#define        KGDB_REG_A3     19
-#define        KGDB_REG_A4     20
-#define        KGDB_REG_A5     21
-#define        KGDB_REG_T8     22
-#define        KGDB_REG_T9     23
-#define        KGDB_REG_T10    24
-#define        KGDB_REG_T11    25
-#define        KGDB_REG_RA     26
-#define        KGDB_REG_T12    27
-#define        KGDB_REG_AT     28
-#define        KGDB_REG_GP     29
-#define        KGDB_REG_SP     30
-#define        KGDB_REG_ZERO   31
-#define        KGDB_REG_F0     32
-#define        KGDB_REG_F1     33
-#define        KGDB_REG_F2     34
-#define        KGDB_REG_F3     35
-#define        KGDB_REG_F4     36
-#define        KGDB_REG_F5     37
-#define        KGDB_REG_F6     38
-#define        KGDB_REG_F7     39
-#define        KGDB_REG_F8     40
-#define        KGDB_REG_F9     41
-#define        KGDB_REG_F10    42
-#define        KGDB_REG_F11    43
-#define        KGDB_REG_F12    44
-#define        KGDB_REG_F13    45
-#define        KGDB_REG_F14    46
-#define        KGDB_REG_F15    47
-#define        KGDB_REG_F16    48
-#define        KGDB_REG_F17    49
-#define        KGDB_REG_F18    50
-#define        KGDB_REG_F19    51
-#define        KGDB_REG_F20    52
-#define        KGDB_REG_F21    53
-#define        KGDB_REG_F22    54
-#define        KGDB_REG_F23    55
-#define        KGDB_REG_F24    56
-#define        KGDB_REG_F25    57
-#define        KGDB_REG_F26    58
-#define        KGDB_REG_F27    59
-#define        KGDB_REG_F28    60
-#define        KGDB_REG_F29    61
-#define        KGDB_REG_F30    62
-#define        KGDB_REG_F31    63
-#define        KGDB_REG_PC     64
-#define        KGDB_REG_VFP    65
-
-/* Too much?  Must be large enough for register transfer. */
-#define        KGDB_BUFLEN     1024
-
-#endif /* __KGDB_H__ */
diff -r 36dfd27e4a4e -r d9a0136ab8cc src/arch/alpha/remote_gdb.cc
--- a/src/arch/alpha/remote_gdb.cc      Fri Dec 18 10:14:17 2015 +0000
+++ b/src/arch/alpha/remote_gdb.cc      Fri Dec 18 15:12:07 2015 -0600
@@ -124,7 +124,6 @@
 
 
 #include "arch/alpha/decoder.hh"
-#include "arch/alpha/kgdb.h"
 #include "arch/alpha/regredir.hh"
 #include "arch/alpha/remote_gdb.hh"
 #include "arch/alpha/utility.hh"
@@ -146,9 +145,8 @@
 using namespace AlphaISA;
 
 RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
-    : BaseRemoteGDB(_system, tc, KGDB_NUMREGS * sizeof(uint64_t))
+    : BaseRemoteGDB(_system, tc)
 {
-    memset(gdbregs.regs, 0, gdbregs.bytes());
 }
 
 /*
@@ -203,47 +201,41 @@
     return true;
 }
 
-/*
- * Translate the kernel debugger register format into the GDB register
- * format.
- */
 void
-RemoteGDB::getregs()
+RemoteGDB::AlphaGdbRegCache::getRegs(ThreadContext *context)
 {
-    memset(gdbregs.regs, 0, gdbregs.bytes());
+    DPRINTF(GDBAcc, "getRegs in remotegdb \n");
 
-    gdbregs.regs64[KGDB_REG_PC] = context->pcState().pc();
+    r.pc = context->pcState().pc();
 
-    // @todo: Currently this is very Alpha specific.
-    if (PcPAL(gdbregs.regs64[KGDB_REG_PC])) {
-        for (int i = 0; i < NumIntArchRegs; ++i)
-            gdbregs.regs64[i] = context->readIntReg(reg_redir[i]);
+    if (PcPAL(r.pc)) {
+        for (int i = 0; i < 32; ++i)
+            r.gpr[i] = context->readIntReg(reg_redir[i]);
     } else {
-        for (int i = 0; i < NumIntArchRegs; ++i)
-            gdbregs.regs64[i] = context->readIntReg(i);
+        for (int i = 0; i < 32; ++i)
+            r.gpr[i] = context->readIntReg(i);
     }
 
+    for (int i = 0; i < 32; ++i)
 #ifdef KGDB_FP_REGS
-    for (int i = 0; i < NumFloatArchRegs; ++i)
-        gdbregs.regs64[i + KGDB_REG_F0] = context->readFloatRegBits(i);
+       r.fpr[i] = context->readFloatRegBits(i);
+#else
+       r.fpr[i] = 0;
 #endif
 }
 
-/*
- * Translate the GDB register format into the kernel debugger register
- * format.
- */
 void
-RemoteGDB::setregs()
+RemoteGDB::AlphaGdbRegCache::setRegs(ThreadContext *context) const
 {
-    // @todo: Currently this is very Alpha specific.
-    if (PcPAL(gdbregs.regs64[KGDB_REG_PC])) {
-        for (int i = 0; i < NumIntArchRegs; ++i) {
-            context->setIntReg(reg_redir[i], gdbregs.regs64[i]);
+    DPRINTF(GDBAcc, "setRegs in remotegdb \n");
+
+    if (PcPAL(r.pc)) {
+        for (int i = 0; i < 32; ++i) {
+            context->setIntReg(reg_redir[i], r.gpr[i]);
         }
     } else {
-        for (int i = 0; i < NumIntArchRegs; ++i) {
-            context->setIntReg(i, gdbregs.regs64[i]);
+        for (int i = 0; i < 32; ++i) {
+            context->setIntReg(i, r.gpr[i]);
         }
     }
 
@@ -252,7 +244,7 @@
         context->setFloatRegBits(i, gdbregs.regs64[i + KGDB_REG_F0]);
     }
 #endif
-    context->pcState(gdbregs.regs64[KGDB_REG_PC]);
+    context->pcState(r.pc);
 }
 
 // Write bytes to kernel address space for debugger.
@@ -277,3 +269,9 @@
               "      See PCEventQueue::doService() in cpu/pc_event.cc.\n");
     return BaseRemoteGDB::insertHardBreak(addr, len);
 }
+
+RemoteGDB::BaseGdbRegCache*
+RemoteGDB::gdbRegs() {
+            return new AlphaGdbRegCache(this);
+}
+
diff -r 36dfd27e4a4e -r d9a0136ab8cc src/arch/alpha/remote_gdb.hh
--- a/src/arch/alpha/remote_gdb.hh      Fri Dec 18 10:14:17 2015 +0000
+++ b/src/arch/alpha/remote_gdb.hh      Fri Dec 18 15:12:07 2015 -0600
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2015 LabWare
  * Copyright (c) 2002-2005 The Regents of The University of Michigan
  * All rights reserved.
  *
@@ -26,6 +27,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Authors: Nathan Binkert
+ *          Boris Shingarov
  */
 
 #ifndef __ARCH_ALPHA_REMOTE_GDB_HH__
@@ -33,7 +35,6 @@
 
 #include <map>
 
-#include "arch/alpha/kgdb.h"
 #include "arch/alpha/types.hh"
 #include "base/pollevent.hh"
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to