1 /*
   2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot.debugger.sparc;
  26 
  27 import java.lang.annotation.Native;
  28 
  29 import sun.jvm.hotspot.debugger.*;
  30 import sun.jvm.hotspot.debugger.cdbg.*;
  31 
  32 /** Currently provides just the minimal information necessary to get
  33     stack traces working. FIXME: currently hardwired for v9 -- will
  34     have to factor out v8/v9 specific code. FIXME: may want to try to
  35     share code between this class and asm/sparc. */
  36 
  37 public abstract class SPARCThreadContext implements ThreadContext {
  38   // Taken from /usr/include/sys/procfs_isa.h
  39 
  40   // One instance of the Native annotation is enough to trigger header generation
  41   // for this file.
  42   @Native
  43   public static final int R_G0 = 0;
  44   public static final int R_G1 = 1;
  45   public static final int R_G2 = 2;
  46   public static final int R_G3 = 3;
  47   public static final int R_G4 = 4;
  48   public static final int R_G5 = 5;
  49   public static final int R_G6 = 6;
  50   public static final int R_G7 = 7;
  51   public static final int R_O0 = 8;
  52   public static final int R_O1 = 9;
  53   public static final int R_O2 = 10;
  54   public static final int R_O3 = 11;
  55   public static final int R_O4 = 12;
  56   public static final int R_O5 = 13;
  57   public static final int R_O6 = 14;
  58   public static final int R_O7 = 15;
  59   public static final int R_L0 = 16;
  60   public static final int R_L1 = 17;
  61   public static final int R_L2 = 18;
  62   public static final int R_L3 = 19;
  63   public static final int R_L4 = 20;
  64   public static final int R_L5 = 21;
  65   public static final int R_L6 = 22;
  66   public static final int R_L7 = 23;
  67   public static final int R_I0 = 24;
  68   public static final int R_I1 = 25;
  69   public static final int R_I2 = 26;
  70   public static final int R_I3 = 27;
  71   public static final int R_I4 = 28;
  72   public static final int R_I5 = 29;
  73   public static final int R_I6 = 30;
  74   public static final int R_I7 = 31;
  75 
  76   // sparc-v9
  77   public static final int R_CCR = 32;
  78   // sparc-v8
  79   public static final int R_PSR = 32;
  80 
  81   public static final int R_PC = 33;
  82   public static final int R_nPC = 34;
  83 
  84   public static final int R_SP = R_O6;
  85   public static final int R_FP = R_I6;
  86 
  87   public static final int R_Y  = 35;
  88 
  89   // sparc-v9
  90   public static final int R_ASI = 36;
  91   public static final int R_FPRS = 37;
  92 
  93   // sparc-v8
  94   public static final int R_WIM = 36;
  95   public static final int R_TBR = 37;
  96 
  97   public static final int NPRGREG = 38;
  98 
  99   private static final String[] regNames = {
 100     "G0",    "G1",    "G2",    "G3",
 101     "G4",    "G5",    "G6",    "G7",
 102     "O0",    "O1",    "O2",    "O3",
 103     "O4",    "O5",    "O6/SP", "O7",
 104     "L0",    "L1",    "L2",    "L3",
 105     "L4",    "L5",    "L6",    "L7",
 106     "I0",    "I1",    "I2",    "I3",
 107     "I4",    "I5",    "I6/FP", "I7",
 108     "CCR/PSR", "PC",  "nPC",   "Y",
 109     "ASI/WIM", "FPRS/TBR"
 110   };
 111 
 112   private long[] data;
 113 
 114   public SPARCThreadContext() {
 115     data = new long[NPRGREG];
 116   }
 117 
 118   public int getNumRegisters() {
 119     return NPRGREG;
 120   }
 121 
 122   public String getRegisterName(int index) {
 123     return regNames[index];
 124   }
 125 
 126   public void setRegister(int index, long value) {
 127     data[index] = value;
 128   }
 129 
 130   public long getRegister(int index) {
 131     return data[index];
 132   }
 133 
 134   public CFrame getTopFrame(Debugger dbg) {
 135     return null;
 136   }
 137 
 138   /** This can't be implemented in this class since we would have to
 139       tie the implementation to, for example, the debugging system */
 140   public abstract void setRegisterAsAddress(int index, Address value);
 141 
 142   /** This can't be implemented in this class since we would have to
 143       tie the implementation to, for example, the debugging system */
 144   public abstract Address getRegisterAsAddress(int index);
 145 }