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 java.lang.annotation.Native; 29 30 import sun.jvm.hotspot.debugger.*; 31 import sun.jvm.hotspot.debugger.cdbg.*; 32 33 /** Specifies the thread context on aarch64 platforms; only a sub-portion 34 * of the context is guaranteed to be present on all operating 35 * systems. */ 36 37 public abstract class AARCH64ThreadContext implements ThreadContext { 38 // Taken from /usr/include/asm/sigcontext.h on Linux/AARCH64. 39 40 // NOTE: the indices for the various registers must be maintained as 41 // listed across various operating systems. However, only a small 42 // subset of the registers' values are guaranteed to be present (and 43 // must be present for the SA's stack walking to work) 44 45 // One instance of the Native annotation is enough to trigger header generation 46 // for this file. 47 @Native 48 public static final int R0 = 0; 49 public static final int R1 = 1; 50 public static final int R2 = 2; 51 public static final int R3 = 3; 52 public static final int R4 = 4; 53 public static final int R5 = 5; 54 public static final int R6 = 6; 55 public static final int R7 = 7; 56 public static final int R8 = 8; 57 public static final int R9 = 9; 58 public static final int R10 = 10; 59 public static final int R11 = 11; 60 public static final int R12 = 12; 61 public static final int R13 = 13; 62 public static final int R14 = 14; 63 public static final int R15 = 15; 64 public static final int R16 = 16; 65 public static final int R17 = 17; 66 public static final int R18 = 18; 67 public static final int R19 = 19; 68 public static final int R20 = 20; 69 public static final int R21 = 21; 70 public static final int R22 = 22; 71 public static final int R23 = 23; 72 public static final int R24 = 24; 73 public static final int R25 = 25; 74 public static final int R26 = 26; 75 public static final int R27 = 27; 76 public static final int R28 = 28; 77 public static final int FP = 29; 78 public static final int LR = 30; 79 public static final int SP = 31; 80 public static final int PC = 32; 81 82 public static final int NPRGREG = 33; 83 84 private long[] data; 85 86 public AARCH64ThreadContext() { 87 data = new long[NPRGREG]; 88 } 89 90 public int getNumRegisters() { 91 return NPRGREG; 92 } 93 94 public String getRegisterName(int index) { 95 switch (index) { 96 case LR: return "lr"; 97 case SP: return "sp"; 98 case PC: return "pc"; 99 default: 100 return "r" + index; 101 } 102 } 103 104 public void setRegister(int index, long value) { 105 data[index] = value; 106 } 107 108 public long getRegister(int index) { 109 return data[index]; 110 } 111 112 public CFrame getTopFrame(Debugger dbg) { 113 return null; 114 } 115 116 /** This can't be implemented in this class since we would have to 117 * tie the implementation to, for example, the debugging system */ 118 public abstract void setRegisterAsAddress(int index, Address value); 119 120 /** This can't be implemented in this class since we would have to 121 * tie the implementation to, for example, the debugging system */ 122 public abstract Address getRegisterAsAddress(int index); 123 }