comparison agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/ia64/WindbgIA64Thread.java @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children c18cbe5936b8
comparison
equal deleted inserted replaced
-1:000000000000 0:a61af66fc99e
1 /*
2 * Copyright 2003 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 package sun.jvm.hotspot.debugger.windbg.ia64;
26
27 import sun.jvm.hotspot.debugger.*;
28 import sun.jvm.hotspot.debugger.ia64.*;
29 import sun.jvm.hotspot.debugger.windbg.*;
30
31 class WindbgIA64Thread implements ThreadProxy {
32 private WindbgDebugger debugger;
33 private long sysId;
34 private boolean gotID;
35 private long id;
36
37 /** The address argument must be the address of the HANDLE of the
38 desired thread in the target process. */
39 WindbgIA64Thread(WindbgDebugger debugger, Address addr) {
40 this.debugger = debugger;
41 // FIXME: size of data fetched here should be configurable.
42 // However, making it so would produce a dependency on the "types"
43 // package from the debugger package, which is not desired.
44
45 // another hack here is that we use sys thread id instead of handle.
46 // windbg can't get details based on handles it seems.
47 // I assume that osThread_win32 thread struct has _thread_id (which
48 // sys thread id) just after handle field.
49
50 this.sysId = (int) addr.addOffsetTo(debugger.getAddressSize()).getCIntegerAt(0, 4, true);
51 gotID = false;
52 }
53
54 WindbgIA64Thread(WindbgDebugger debugger, long sysId) {
55 this.debugger = debugger;
56 this.sysId = sysId;
57 gotID = false;
58 }
59
60 public ThreadContext getContext() throws IllegalThreadStateException {
61 long[] data = debugger.getThreadIntegerRegisterSet(getThreadID());
62 WindbgIA64ThreadContext context = new WindbgIA64ThreadContext(debugger);
63 for (int i = 0; i < data.length; i++) {
64 context.setRegister(i, data[i]);
65 }
66 return context;
67 }
68
69 public boolean canSetContext() throws DebuggerException {
70 return false;
71 }
72
73 public void setContext(ThreadContext thrCtx)
74 throws IllegalThreadStateException, DebuggerException {
75 throw new DebuggerException("Unimplemented");
76 }
77
78 public boolean equals(Object obj) {
79 if ((obj == null) || !(obj instanceof WindbgIA64Thread)) {
80 return false;
81 }
82
83 return (((WindbgIA64Thread) obj).getThreadID() == getThreadID());
84 }
85
86 public int hashCode() {
87 return (int) getThreadID();
88 }
89
90 public String toString() {
91 return Long.toString(getThreadID());
92 }
93
94 /** Retrieves the thread ID of this thread by examining the Thread
95 Information Block. */
96 private long getThreadID() {
97 if (!gotID) {
98 id = debugger.getThreadIdFromSysId(sysId);
99 }
100
101 return id;
102 }
103 }