1 /* 2 * Copyright (c) 2004, 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.proc.aarch64; 27 28 import sun.jvm.hotspot.debugger.*; 29 import sun.jvm.hotspot.debugger.aarch64.*; 30 import sun.jvm.hotspot.debugger.proc.*; 31 import sun.jvm.hotspot.utilities.*; 32 33 public class ProcAARCH64Thread implements ThreadProxy { 34 private ProcDebugger debugger; 35 private int id; 36 37 public ProcAARCH64Thread(ProcDebugger debugger, Address addr) { 38 this.debugger = debugger; 39 40 // FIXME: the size here should be configurable. However, making it 41 // so would produce a dependency on the "types" package from the 42 // debugger package, which is not desired. 43 this.id = (int) addr.getCIntegerAt(0, 4, true); 44 } 45 46 public ProcAARCH64Thread(ProcDebugger debugger, long id) { 47 this.debugger = debugger; 48 this.id = (int) id; 49 } 50 51 public ThreadContext getContext() throws IllegalThreadStateException { 52 ProcAARCH64ThreadContext context = new ProcAARCH64ThreadContext(debugger); 53 long[] regs = debugger.getThreadIntegerRegisterSet(id); 54 if (Assert.ASSERTS_ENABLED) { 55 Assert.that(regs.length == AARCH64ThreadContext.NPRGREG, "size mismatch"); 56 } 57 for (int i = 0; i < regs.length; i++) { 58 context.setRegister(i, regs[i]); 59 } 60 return context; 61 } 62 63 public boolean canSetContext() throws DebuggerException { 64 return false; 65 } 66 67 public void setContext(ThreadContext context) 68 throws IllegalThreadStateException, DebuggerException { 69 throw new DebuggerException("Unimplemented"); 70 } 71 72 public String toString() { 73 return "t@" + id; 74 } 75 76 public boolean equals(Object obj) { 77 if ((obj == null) || !(obj instanceof ProcAARCH64Thread)) { 78 return false; 79 } 80 81 return (((ProcAARCH64Thread) obj).id == id); 82 } 83 84 public int hashCode() { 85 return id; 86 } 87 }