comparison agent/src/share/classes/sun/jvm/hotspot/runtime/OSThread.java @ 7974:43badbe2717a

8000973: SA on windows thread inspection is broken Summary: After bug 7161732, On Windows SA could not find correct address of thread_id of OSThread since _thread_id moved to end of the class . The presupposition of the address is following thread handle no longer stands. Fix by adding thread_id field to OSThread and getting the address directly from OSThread. Reviewed-by: nloodin, sspitsyn Contributed-by: yumin.qi@oracle.com
author minqi
date Thu, 31 Jan 2013 17:43:01 -0800
parents c18cbe5936b8
children 22a5aff0df0b
comparison
equal deleted inserted replaced
7959:7885e162c30f 7974:43badbe2717a
1 /* 1 /*
2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
30 30
31 // The OSThread class holds OS-specific thread information. It is equivalent 31 // The OSThread class holds OS-specific thread information. It is equivalent
32 // to the sys_thread_t structure of the classic JVM implementation. 32 // to the sys_thread_t structure of the classic JVM implementation.
33 public class OSThread extends VMObject { 33 public class OSThread extends VMObject {
34 private static JIntField interruptedField; 34 private static JIntField interruptedField;
35 private static JIntField threadIdField;
35 static { 36 static {
36 VM.registerVMInitializedObserver(new Observer() { 37 VM.registerVMInitializedObserver(new Observer() {
37 public void update(Observable o, Object data) { 38 public void update(Observable o, Object data) {
38 initialize(VM.getVM().getTypeDataBase()); 39 initialize(VM.getVM().getTypeDataBase());
39 } 40 }
41 } 42 }
42 43
43 private static synchronized void initialize(TypeDataBase db) { 44 private static synchronized void initialize(TypeDataBase db) {
44 Type type = db.lookupType("OSThread"); 45 Type type = db.lookupType("OSThread");
45 interruptedField = type.getJIntField("_interrupted"); 46 interruptedField = type.getJIntField("_interrupted");
47 threadIdField = type.getJIntField("_thread_id");
46 } 48 }
47 49
48 public OSThread(Address addr) { 50 public OSThread(Address addr) {
49 super(addr); 51 super(addr);
50 } 52 }
51 53
52 public boolean interrupted() { 54 public boolean interrupted() {
53 return ((int)interruptedField.getValue(addr)) != 0; 55 return ((int)interruptedField.getValue(addr)) != 0;
54 } 56 }
57
58 public int threadId() {
59 return (int)threadIdField.getValue(addr);
60 }
61
55 } 62 }