1 /* 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2015, Red Hat Inc. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 package sun.jvm.hotspot.debugger.aarch64; 27 28 import sun.jvm.hotspot.debugger.*; 29 import sun.jvm.hotspot.debugger.cdbg.*; 30 31 /** Specifies the thread context on aarch64 platforms; only a sub-portion 32 * of the context is guaranteed to be present on all operating 33 * systems. */ 34 35 public abstract class AARCH64ThreadContext implements ThreadContext { 36 // Taken from /usr/include/asm/sigcontext.h on Linux/AARCH64. 37 38 // NOTE: the indices for the various registers must be maintained as 39 // listed across various operating systems. However, only a small 40 // subset of the registers' values are guaranteed to be present (and 41 // must be present for the SA's stack walking to work) 42 43 public static final int R0 = 0; 44 public static final int R1 = 1; 45 public static final int R2 = 2; 46 public static final int R3 = 3; 47 public static final int R4 = 4; 48 public static final int R5 = 5; 49 public static final int R6 = 6; 50 public static final int R7 = 7; 51 public static final int R8 = 8; 52 public static final int R9 = 9; 53 public static final int R10 = 10; 54 public static final int R11 = 11; 55 public static final int R12 = 12; 56 public static final int R13 = 13; 57 public static final int R14 = 14; 58 public static final int R15 = 15; 59 public static final int R16 = 16; 60 public static final int R17 = 17; 61 public static final int R18 = 18; 62 public static final int R19 = 19; 63 public static final int R20 = 20; 64 public static final int R21 = 21; 65 public static final int R22 = 22; 66 public static final int R23 = 23; 67 public static final int R24 = 24; 68 public static final int R25 = 25; 69 public static final int R26 = 26; 70 public static final int R27 = 27; 71 public static final int R28 = 28; 72 public static final int FP = 29; 73 public static final int LR = 30; 74 public static final int SP = 31; 75 public static final int PC = 32; 76 77 public static final int NPRGREG = 33; 78 79 private long[] data; 80 81 public AARCH64ThreadContext() { 82 data = new long[NPRGREG]; 83 } 84 85 public int getNumRegisters() { 86 return NPRGREG; 87 } 88 89 public String getRegisterName(int index) { 90 switch (index) { 91 case LR: return "lr"; 92 case SP: return "sp"; 93 case PC: return "pc"; 94 default: 95 return "r" + index; 96 } 97 } 98 99 public void setRegister(int index, long value) { 100 data[index] = value; 101 } 102 103 public long getRegister(int index) { 104 return data[index]; 105 } 106 107 public CFrame getTopFrame(Debugger dbg) { 108 return null; 109 } 110 111 /** This can't be implemented in this class since we would have to 112 * tie the implementation to, for example, the debugging system */ 113 public abstract void setRegisterAsAddress(int index, Address value); 114 115 /** This can't be implemented in this class since we would have to 116 * tie the implementation to, for example, the debugging system */ 117 public abstract Address getRegisterAsAddress(int index); 118 }