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