1 /* 2 * Copyright (c) 2002, 2003, 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.bsd; 26 27 import sun.jvm.hotspot.debugger.*; 28 29 class BsdThread implements ThreadProxy { 30 private BsdDebugger debugger; 31 private int thread_id; 32 private long unique_thread_id; 33 34 /** The address argument must be the address of the _thread_id in the 35 OSThread. It's value is result ::gettid() call. */ 36 BsdThread(BsdDebugger debugger, Address threadIdAddr, Address uniqueThreadIdAddr) { 37 this.debugger = debugger; 38 // FIXME: size of data fetched here should be configurable. 39 // However, making it so would produce a dependency on the "types" 40 // package from the debugger package, which is not desired. 41 this.thread_id = (int) threadIdAddr.getCIntegerAt(0, 4, true); 42 this.unique_thread_id = uniqueThreadIdAddr.getCIntegerAt(0, 8, true); 43 } 44 45 BsdThread(BsdDebugger debugger, long id) { 46 this.debugger = debugger; 47 this.thread_id = (int) id; 48 } 49 50 public boolean equals(Object obj) { 51 if ((obj == null) || !(obj instanceof BsdThread)) { 52 return false; 53 } 54 55 return (((BsdThread) obj).thread_id == thread_id); 56 } 57 58 public int hashCode() { 59 return thread_id; 60 } 61 62 public String toString() { 63 return Integer.toString(thread_id); 64 } 65 66 public ThreadContext getContext() throws IllegalThreadStateException { 67 long[] data = debugger.getThreadIntegerRegisterSet(unique_thread_id); 68 ThreadContext context = BsdThreadContextFactory.createThreadContext(debugger); 69 for (int i = 0; i < data.length; i++) { 70 context.setRegister(i, data[i]); 71 } 72 return context; 73 } 74 75 public boolean canSetContext() throws DebuggerException { 76 return false; 77 } 78 79 public void setContext(ThreadContext context) 80 throws IllegalThreadStateException, DebuggerException { 81 throw new DebuggerException("Unimplemented"); 82 } 83 }