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