1 /* 2 * Copyright (c) 2003, 2012, 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.amd64; 26 27 import sun.jvm.hotspot.debugger.*; 28 import sun.jvm.hotspot.debugger.cdbg.*; 29 30 /** Specifies the thread context on amd64 platforms; only a sub-portion 31 * of the context is guaranteed to be present on all operating 32 * systems. */ 33 34 public abstract class AMD64ThreadContext implements ThreadContext { 35 // Taken from /usr/include/sys/regset.h on Solaris/AMD64. 36 37 // NOTE: the indices for the various registers must be maintained as 38 // listed across various operating systems. However, only a small 39 // subset of the registers' values are guaranteed to be present (and 40 // must be present for the SA's stack walking to work) 41 42 public static final int R15 = 0; 43 public static final int R14 = 1; 44 public static final int R13 = 2; 45 public static final int R12 = 3; 46 public static final int R11 = 4; 47 public static final int R10 = 5; 48 public static final int R9 = 6; 49 public static final int R8 = 7; 50 public static final int RDI = 8; 51 public static final int RSI = 9; 52 public static final int RBP = 10; 53 public static final int RBX = 11; 54 public static final int RDX = 12; 55 public static final int RCX = 13; 56 public static final int RAX = 14; 57 public static final int TRAPNO = 15; 58 public static final int ERR = 16; 59 public static final int RIP = 17; 60 public static final int CS = 18; 61 public static final int RFL = 19; 62 public static final int RSP = 20; 63 public static final int SS = 21; 64 public static final int FS = 22; 65 public static final int GS = 23; 66 public static final int ES = 24; 67 public static final int DS = 25; 68 public static final int FSBASE = 26; 69 public static final int GSBASE = 27; 70 71 public static final int NPRGREG = 28; 72 73 private static final String[] regNames = { 74 "r15", "r14", "r13", "r12", "r11", "r10", "r9", "r8", 75 "rdi", "rsi", "rbp", "rbx", "rdx", "rcx", "rax", "trapno", 76 "err", "rip", "cs", "rfl", "rsp", "ss", "fs", "gs", 77 "es", "ds", "fsbase", "gsbase" 78 }; 79 80 private long[] data; 81 82 public AMD64ThreadContext() { 83 data = new long[NPRGREG]; 84 } 85 86 public int getNumRegisters() { 87 return NPRGREG; 88 } 89 90 public String getRegisterName(int index) { 91 return regNames[index]; 92 } 93 94 public void setRegister(int index, long value) { 95 data[index] = value; 96 } 97 98 public long getRegister(int index) { 99 return data[index]; 100 } 101 102 public CFrame getTopFrame(Debugger dbg) { 103 return null; 104 } 105 106 /** This can't be implemented in this class since we would have to 107 * tie the implementation to, for example, the debugging system */ 108 public abstract void setRegisterAsAddress(int index, Address value); 109 110 /** This can't be implemented in this class since we would have to 111 * tie the implementation to, for example, the debugging system */ 112 public abstract Address getRegisterAsAddress(int index); 113 }