Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/runtime/win32_x86/Win32X86JavaThreadPDAccess.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 | f6f3bb0ee072 |
children |
comparison
equal
deleted
inserted
replaced
7959:7885e162c30f | 7974:43badbe2717a |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2000, 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. |
40 public class Win32X86JavaThreadPDAccess implements JavaThreadPDAccess { | 40 public class Win32X86JavaThreadPDAccess implements JavaThreadPDAccess { |
41 private static AddressField lastJavaFPField; | 41 private static AddressField lastJavaFPField; |
42 private static AddressField osThreadField; | 42 private static AddressField osThreadField; |
43 | 43 |
44 // Field from OSThread | 44 // Field from OSThread |
45 private static Field osThreadThreadHandleField; | 45 private static Field osThreadThreadIdField; |
46 | 46 |
47 // This is currently unneeded but is being kept in case we change | 47 // This is currently unneeded but is being kept in case we change |
48 // the currentFrameGuess algorithm | 48 // the currentFrameGuess algorithm |
49 private static final long GUESS_SCAN_RANGE = 128 * 1024; | 49 private static final long GUESS_SCAN_RANGE = 128 * 1024; |
50 | 50 |
61 Type anchorType = db.lookupType("JavaFrameAnchor"); | 61 Type anchorType = db.lookupType("JavaFrameAnchor"); |
62 lastJavaFPField = anchorType.getAddressField("_last_Java_fp"); | 62 lastJavaFPField = anchorType.getAddressField("_last_Java_fp"); |
63 osThreadField = type.getAddressField("_osthread"); | 63 osThreadField = type.getAddressField("_osthread"); |
64 | 64 |
65 type = db.lookupType("OSThread"); | 65 type = db.lookupType("OSThread"); |
66 osThreadThreadHandleField = type.getField("_thread_handle"); | 66 osThreadThreadIdField = type.getField("_thread_id"); |
67 } | 67 } |
68 | 68 |
69 public Address getLastJavaFP(Address addr) { | 69 public Address getLastJavaFP(Address addr) { |
70 return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset())); | 70 return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset())); |
71 } | 71 } |
125 public ThreadProxy getThreadProxy(Address addr) { | 125 public ThreadProxy getThreadProxy(Address addr) { |
126 // Addr is the address of the JavaThread. | 126 // Addr is the address of the JavaThread. |
127 // Fetch the OSThread (for now and for simplicity, not making a | 127 // Fetch the OSThread (for now and for simplicity, not making a |
128 // separate "OSThread" class in this package) | 128 // separate "OSThread" class in this package) |
129 Address osThreadAddr = osThreadField.getValue(addr); | 129 Address osThreadAddr = osThreadField.getValue(addr); |
130 // Get the address of the HANDLE within the OSThread | 130 // Get the address of the thread_id within the OSThread |
131 Address threadHandleAddr = | 131 Address threadIdAddr = |
132 osThreadAddr.addOffsetTo(osThreadThreadHandleField.getOffset()); | 132 osThreadAddr.addOffsetTo(osThreadThreadIdField.getOffset()); |
133 JVMDebugger debugger = VM.getVM().getDebugger(); | 133 JVMDebugger debugger = VM.getVM().getDebugger(); |
134 return debugger.getThreadForIdentifierAddress(threadHandleAddr); | 134 return debugger.getThreadForIdentifierAddress(threadIdAddr); |
135 } | 135 } |
136 } | 136 } |