Mercurial > hg > graal-jvmci-8
annotate agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdThread.java @ 8023:758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
Summary: Do not rely on mach thread port names to identify threads from SA
Reviewed-by: dholmes, minqi, rbackman
author | sla |
---|---|
date | Fri, 08 Feb 2013 12:48:24 +0100 |
parents | f08d439fab8c |
children | 39432a1cefdd |
rev | line source |
---|---|
3960 | 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; | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
31 private int thread_id; |
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
32 private long unique_thread_id; |
3960 | 33 |
34 /** The address argument must be the address of the _thread_id in the | |
35 OSThread. It's value is result ::gettid() call. */ | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
36 BsdThread(BsdDebugger debugger, Address threadIdAddr, Address uniqueThreadIdAddr) { |
3960 | 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. | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
41 this.thread_id = (int) threadIdAddr.getCIntegerAt(0, 4, true); |
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
42 this.unique_thread_id = uniqueThreadIdAddr.getCIntegerAt(0, 8, true); |
3960 | 43 } |
44 | |
45 BsdThread(BsdDebugger debugger, long id) { | |
46 this.debugger = debugger; | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
47 this.thread_id = (int) id; |
3960 | 48 } |
49 | |
50 public boolean equals(Object obj) { | |
51 if ((obj == null) || !(obj instanceof BsdThread)) { | |
52 return false; | |
53 } | |
54 | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
55 return (((BsdThread) obj).thread_id == thread_id); |
3960 | 56 } |
57 | |
58 public int hashCode() { | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
59 return thread_id; |
3960 | 60 } |
61 | |
62 public String toString() { | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
63 return Integer.toString(thread_id); |
3960 | 64 } |
65 | |
66 public ThreadContext getContext() throws IllegalThreadStateException { | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
67 long[] data = debugger.getThreadIntegerRegisterSet(unique_thread_id); |
3960 | 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 } |