author | phh |
Sat, 30 Nov 2019 14:33:05 -0800 | |
changeset 59330 | 5b96c12f909d |
parent 58901 | 2700c409ff10 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
58901
2700c409ff10
8229516: Thread.isInterrupted() always returns false after thread termination
dholmes
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
package sun.jvm.hotspot.runtime; |
|
26 |
||
27 |
import java.util.*; |
|
28 |
import sun.jvm.hotspot.debugger.*; |
|
29 |
import sun.jvm.hotspot.types.*; |
|
30 |
||
31 |
// The OSThread class holds OS-specific thread information. It is equivalent |
|
32 |
// to the sys_thread_t structure of the classic JVM implementation. |
|
33 |
public class OSThread extends VMObject { |
|
19152
44fdfecd8f6c
8019396: SA-JDI OSThread class initialization throws an exception
dsamersoff
parents:
15455
diff
changeset
|
34 |
private static Field threadIdField; |
46636 | 35 |
private static CIntegerField threadStateField; |
36 |
||
37 |
// ThreadStates read from underlying process |
|
38 |
private static int ALLOCATED; |
|
39 |
private static int INITIALIZED; |
|
40 |
private static int RUNNABLE; |
|
41 |
private static int MONITOR_WAIT; |
|
42 |
private static int CONDVAR_WAIT; |
|
43 |
private static int OBJECT_WAIT; |
|
44 |
private static int BREAKPOINTED; |
|
45 |
private static int SLEEPING; |
|
46 |
private static int ZOMBIE; |
|
47 |
||
1 | 48 |
static { |
49 |
VM.registerVMInitializedObserver(new Observer() { |
|
50 |
public void update(Observable o, Object data) { |
|
51 |
initialize(VM.getVM().getTypeDataBase()); |
|
52 |
} |
|
53 |
}); |
|
54 |
} |
|
55 |
||
56 |
private static synchronized void initialize(TypeDataBase db) { |
|
57 |
Type type = db.lookupType("OSThread"); |
|
19152
44fdfecd8f6c
8019396: SA-JDI OSThread class initialization throws an exception
dsamersoff
parents:
15455
diff
changeset
|
58 |
threadIdField = type.getField("_thread_id"); |
46636 | 59 |
threadStateField = type.getCIntegerField("_state"); |
60 |
||
61 |
ALLOCATED = db.lookupIntConstant("ALLOCATED").intValue(); |
|
62 |
INITIALIZED = db.lookupIntConstant("INITIALIZED").intValue(); |
|
63 |
RUNNABLE = db.lookupIntConstant("RUNNABLE").intValue(); |
|
64 |
MONITOR_WAIT = db.lookupIntConstant("MONITOR_WAIT").intValue(); |
|
65 |
CONDVAR_WAIT = db.lookupIntConstant("CONDVAR_WAIT").intValue(); |
|
66 |
OBJECT_WAIT = db.lookupIntConstant("OBJECT_WAIT").intValue(); |
|
67 |
BREAKPOINTED = db.lookupIntConstant("BREAKPOINTED").intValue(); |
|
68 |
SLEEPING = db.lookupIntConstant("SLEEPING").intValue(); |
|
69 |
ZOMBIE = db.lookupIntConstant("ZOMBIE").intValue(); |
|
1 | 70 |
} |
71 |
||
72 |
public OSThread(Address addr) { |
|
73 |
super(addr); |
|
74 |
} |
|
75 |
||
15455 | 76 |
public int threadId() { |
19152
44fdfecd8f6c
8019396: SA-JDI OSThread class initialization throws an exception
dsamersoff
parents:
15455
diff
changeset
|
77 |
return threadIdField.getJInt(addr); |
15455 | 78 |
} |
79 |
||
46636 | 80 |
public ThreadState getThreadState() { |
81 |
int val = (int)threadStateField.getValue(addr); |
|
82 |
if (val == ALLOCATED) { |
|
83 |
return ThreadState.ALLOCATED; |
|
84 |
} else if (val == INITIALIZED) { |
|
85 |
return ThreadState.INITIALIZED; |
|
86 |
} else if (val == RUNNABLE) { |
|
87 |
return ThreadState.RUNNABLE; |
|
88 |
} else if (val == MONITOR_WAIT) { |
|
89 |
return ThreadState.MONITOR_WAIT; |
|
90 |
} else if (val == CONDVAR_WAIT) { |
|
91 |
return ThreadState.CONDVAR_WAIT; |
|
92 |
} else if (val == OBJECT_WAIT) { |
|
93 |
return ThreadState.OBJECT_WAIT; |
|
94 |
} else if (val == BREAKPOINTED) { |
|
95 |
return ThreadState.BREAKPOINTED; |
|
96 |
} else if (val == SLEEPING) { |
|
97 |
return ThreadState.SLEEPING; |
|
98 |
} else if (val == ZOMBIE) { |
|
99 |
return ThreadState.ZOMBIE; |
|
100 |
} else { |
|
101 |
throw new RuntimeException("Illegal thread state " + val); |
|
102 |
} |
|
103 |
} |
|
1 | 104 |
} |