Thu, 16 May 2013 12:40:27 +0100
6313816: SA: jstack -m fails on Win32 : UnalignedAddressException
Reviewed-by: sla, poonam
1.1 --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/amd64/AMD64CFrame.java Thu May 16 17:54:11 2013 +0200 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,73 +0,0 @@ 1.4 -/* 1.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 - * 1.8 - * This code is free software; you can redistribute it and/or modify it 1.9 - * under the terms of the GNU General Public License version 2 only, as 1.10 - * published by the Free Software Foundation. 1.11 - * 1.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 - * version 2 for more details (a copy is included in the LICENSE file that 1.16 - * accompanied this code). 1.17 - * 1.18 - * You should have received a copy of the GNU General Public License version 1.19 - * 2 along with this work; if not, write to the Free Software Foundation, 1.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 - * 1.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 - * or visit www.oracle.com if you need additional information or have any 1.24 - * questions. 1.25 - * 1.26 - */ 1.27 - 1.28 -package sun.jvm.hotspot.debugger.cdbg.basic.amd64; 1.29 - 1.30 -import sun.jvm.hotspot.debugger.*; 1.31 -import sun.jvm.hotspot.debugger.amd64.*; 1.32 -import sun.jvm.hotspot.debugger.cdbg.*; 1.33 -import sun.jvm.hotspot.debugger.cdbg.basic.*; 1.34 - 1.35 -/** Basic AMD64 frame functionality providing sender() functionality. */ 1.36 - 1.37 -public class AMD64CFrame extends BasicCFrame { 1.38 - private Address rbp; 1.39 - private Address pc; 1.40 - 1.41 - private static final int ADDRESS_SIZE = 8; 1.42 - 1.43 - /** Constructor for topmost frame */ 1.44 - public AMD64CFrame(CDebugger dbg, Address rbp, Address pc) { 1.45 - super(dbg); 1.46 - this.rbp = rbp; 1.47 - this.pc = pc; 1.48 - } 1.49 - 1.50 - public CFrame sender(ThreadProxy thread) { 1.51 - AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext(); 1.52 - Address rsp = context.getRegisterAsAddress(AMD64ThreadContext.RSP); 1.53 - 1.54 - if ( (rbp == null) || rbp.lessThan(rsp) ) { 1.55 - return null; 1.56 - } 1.57 - 1.58 - Address nextRBP = rbp.getAddressAt( 0 * ADDRESS_SIZE); 1.59 - if (nextRBP == null) { 1.60 - return null; 1.61 - } 1.62 - Address nextPC = rbp.getAddressAt( 1 * ADDRESS_SIZE); 1.63 - if (nextPC == null) { 1.64 - return null; 1.65 - } 1.66 - return new AMD64CFrame(dbg(), nextRBP, nextPC); 1.67 - } 1.68 - 1.69 - public Address pc() { 1.70 - return pc; 1.71 - } 1.72 - 1.73 - public Address localVariableBase() { 1.74 - return rbp; 1.75 - } 1.76 -}
2.1 --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/x86/X86CFrame.java Thu May 16 17:54:11 2013 +0200 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,73 +0,0 @@ 2.4 -/* 2.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 2.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 - * 2.8 - * This code is free software; you can redistribute it and/or modify it 2.9 - * under the terms of the GNU General Public License version 2 only, as 2.10 - * published by the Free Software Foundation. 2.11 - * 2.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 - * version 2 for more details (a copy is included in the LICENSE file that 2.16 - * accompanied this code). 2.17 - * 2.18 - * You should have received a copy of the GNU General Public License version 2.19 - * 2 along with this work; if not, write to the Free Software Foundation, 2.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 - * 2.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 - * or visit www.oracle.com if you need additional information or have any 2.24 - * questions. 2.25 - * 2.26 - */ 2.27 - 2.28 -package sun.jvm.hotspot.debugger.cdbg.basic.x86; 2.29 - 2.30 -import sun.jvm.hotspot.debugger.*; 2.31 -import sun.jvm.hotspot.debugger.x86.*; 2.32 -import sun.jvm.hotspot.debugger.cdbg.*; 2.33 -import sun.jvm.hotspot.debugger.cdbg.basic.*; 2.34 - 2.35 -/** Basic X86 frame functionality providing sender() functionality. */ 2.36 - 2.37 -public class X86CFrame extends BasicCFrame { 2.38 - private Address ebp; 2.39 - private Address pc; 2.40 - 2.41 - private static final int ADDRESS_SIZE = 4; 2.42 - 2.43 - /** Constructor for topmost frame */ 2.44 - public X86CFrame(CDebugger dbg, Address ebp, Address pc) { 2.45 - super(dbg); 2.46 - this.ebp = ebp; 2.47 - this.pc = pc; 2.48 - } 2.49 - 2.50 - public CFrame sender(ThreadProxy thread) { 2.51 - X86ThreadContext context = (X86ThreadContext) thread.getContext(); 2.52 - Address esp = context.getRegisterAsAddress(X86ThreadContext.ESP); 2.53 - 2.54 - if ( (ebp == null) || ebp.lessThan(esp) ) { 2.55 - return null; 2.56 - } 2.57 - 2.58 - Address nextEBP = ebp.getAddressAt( 0 * ADDRESS_SIZE); 2.59 - if (nextEBP == null) { 2.60 - return null; 2.61 - } 2.62 - Address nextPC = ebp.getAddressAt( 1 * ADDRESS_SIZE); 2.63 - if (nextPC == null) { 2.64 - return null; 2.65 - } 2.66 - return new X86CFrame(dbg(), nextEBP, nextPC); 2.67 - } 2.68 - 2.69 - public Address pc() { 2.70 - return pc; 2.71 - } 2.72 - 2.73 - public Address localVariableBase() { 2.74 - return ebp; 2.75 - } 2.76 -}
3.1 --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java Thu May 16 17:54:11 2013 +0200 3.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java Thu May 16 12:40:27 2013 +0100 3.3 @@ -28,10 +28,10 @@ 3.4 import java.util.*; 3.5 import sun.jvm.hotspot.debugger.*; 3.6 import sun.jvm.hotspot.debugger.cdbg.*; 3.7 -import sun.jvm.hotspot.debugger.cdbg.basic.x86.*; 3.8 -import sun.jvm.hotspot.debugger.cdbg.basic.amd64.*; 3.9 import sun.jvm.hotspot.debugger.x86.*; 3.10 import sun.jvm.hotspot.debugger.amd64.*; 3.11 +import sun.jvm.hotspot.debugger.windows.x86.*; 3.12 +import sun.jvm.hotspot.debugger.windows.amd64.*; 3.13 import sun.jvm.hotspot.utilities.AddressOps; 3.14 3.15 class WindbgCDebugger implements CDebugger { 3.16 @@ -75,14 +75,14 @@ 3.17 if (ebp == null) return null; 3.18 Address pc = context.getRegisterAsAddress(X86ThreadContext.EIP); 3.19 if (pc == null) return null; 3.20 - return new X86CFrame(this, ebp, pc); 3.21 + return new WindowsX86CFrame(dbg, ebp, pc); 3.22 } else if (dbg.getCPU().equals("amd64")) { 3.23 AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext(); 3.24 Address rbp = context.getRegisterAsAddress(AMD64ThreadContext.RBP); 3.25 if (rbp == null) return null; 3.26 Address pc = context.getRegisterAsAddress(AMD64ThreadContext.RIP); 3.27 if (pc == null) return null; 3.28 - return new AMD64CFrame(this, rbp, pc); 3.29 + return new WindowsAMD64CFrame(dbg, rbp, pc); 3.30 } else { 3.31 // unsupported CPU! 3.32 return null;
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/amd64/WindowsAMD64CFrame.java Thu May 16 12:40:27 2013 +0100 4.3 @@ -0,0 +1,80 @@ 4.4 +/* 4.5 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.7 + * 4.8 + * This code is free software; you can redistribute it and/or modify it 4.9 + * under the terms of the GNU General Public License version 2 only, as 4.10 + * published by the Free Software Foundation. 4.11 + * 4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.15 + * version 2 for more details (a copy is included in the LICENSE file that 4.16 + * accompanied this code). 4.17 + * 4.18 + * You should have received a copy of the GNU General Public License version 4.19 + * 2 along with this work; if not, write to the Free Software Foundation, 4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.21 + * 4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4.23 + * or visit www.oracle.com if you need additional information or have any 4.24 + * questions. 4.25 + * 4.26 + */ 4.27 + 4.28 +package sun.jvm.hotspot.debugger.windows.amd64; 4.29 + 4.30 +import sun.jvm.hotspot.debugger.*; 4.31 +import sun.jvm.hotspot.debugger.amd64.*; 4.32 +import sun.jvm.hotspot.debugger.cdbg.*; 4.33 +import sun.jvm.hotspot.debugger.cdbg.basic.*; 4.34 +import sun.jvm.hotspot.debugger.windbg.*; 4.35 + 4.36 +public class WindowsAMD64CFrame extends BasicCFrame { 4.37 + private Address rbp; 4.38 + private Address pc; 4.39 + 4.40 + private static final int ADDRESS_SIZE = 8; 4.41 + 4.42 + /** Constructor for topmost frame */ 4.43 + public WindowsAMD64CFrame(WindbgDebugger dbg, Address rbp, Address pc) { 4.44 + super(dbg.getCDebugger()); 4.45 + this.rbp = rbp; 4.46 + this.pc = pc; 4.47 + this.dbg = dbg; 4.48 + } 4.49 + 4.50 + public CFrame sender(ThreadProxy thread) { 4.51 + AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext(); 4.52 + Address rsp = context.getRegisterAsAddress(AMD64ThreadContext.RSP); 4.53 + 4.54 + if ( (rbp == null) || rbp.lessThan(rsp) ) { 4.55 + return null; 4.56 + } 4.57 + 4.58 + // Check alignment of rbp 4.59 + if ( dbg.getAddressValue(rbp) % ADDRESS_SIZE != 0) { 4.60 + return null; 4.61 + } 4.62 + 4.63 + Address nextRBP = rbp.getAddressAt( 0 * ADDRESS_SIZE); 4.64 + if (nextRBP == null || nextRBP.lessThanOrEqual(rbp)) { 4.65 + return null; 4.66 + } 4.67 + Address nextPC = rbp.getAddressAt( 1 * ADDRESS_SIZE); 4.68 + if (nextPC == null) { 4.69 + return null; 4.70 + } 4.71 + return new WindowsAMD64CFrame(dbg, nextRBP, nextPC); 4.72 + } 4.73 + 4.74 + public Address pc() { 4.75 + return pc; 4.76 + } 4.77 + 4.78 + public Address localVariableBase() { 4.79 + return rbp; 4.80 + } 4.81 + 4.82 + private WindbgDebugger dbg; 4.83 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java Thu May 16 12:40:27 2013 +0100 5.3 @@ -0,0 +1,80 @@ 5.4 +/* 5.5 + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 + * 5.8 + * This code is free software; you can redistribute it and/or modify it 5.9 + * under the terms of the GNU General Public License version 2 only, as 5.10 + * published by the Free Software Foundation. 5.11 + * 5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.15 + * version 2 for more details (a copy is included in the LICENSE file that 5.16 + * accompanied this code). 5.17 + * 5.18 + * You should have received a copy of the GNU General Public License version 5.19 + * 2 along with this work; if not, write to the Free Software Foundation, 5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.21 + * 5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 5.23 + * or visit www.oracle.com if you need additional information or have any 5.24 + * questions. 5.25 + * 5.26 + */ 5.27 + 5.28 +package sun.jvm.hotspot.debugger.windows.x86; 5.29 + 5.30 +import sun.jvm.hotspot.debugger.*; 5.31 +import sun.jvm.hotspot.debugger.x86.*; 5.32 +import sun.jvm.hotspot.debugger.cdbg.*; 5.33 +import sun.jvm.hotspot.debugger.cdbg.basic.*; 5.34 +import sun.jvm.hotspot.debugger.windbg.*; 5.35 + 5.36 +public class WindowsX86CFrame extends BasicCFrame { 5.37 + private Address ebp; 5.38 + private Address pc; 5.39 + 5.40 + private static final int ADDRESS_SIZE = 4; 5.41 + 5.42 + /** Constructor for topmost frame */ 5.43 + public WindowsX86CFrame(WindbgDebugger dbg, Address ebp, Address pc) { 5.44 + super(dbg.getCDebugger()); 5.45 + this.ebp = ebp; 5.46 + this.pc = pc; 5.47 + this.dbg = dbg; 5.48 + } 5.49 + 5.50 + public CFrame sender(ThreadProxy thread) { 5.51 + X86ThreadContext context = (X86ThreadContext) thread.getContext(); 5.52 + Address esp = context.getRegisterAsAddress(X86ThreadContext.ESP); 5.53 + 5.54 + if ( (ebp == null) || ebp.lessThan(esp) ) { 5.55 + return null; 5.56 + } 5.57 + 5.58 + // Check alignment of ebp 5.59 + if ( dbg.getAddressValue(ebp) % ADDRESS_SIZE != 0) { 5.60 + return null; 5.61 + } 5.62 + 5.63 + Address nextEBP = ebp.getAddressAt( 0 * ADDRESS_SIZE); 5.64 + if (nextEBP == null || nextEBP.lessThanOrEqual(ebp)) { 5.65 + return null; 5.66 + } 5.67 + Address nextPC = ebp.getAddressAt( 1 * ADDRESS_SIZE); 5.68 + if (nextPC == null) { 5.69 + return null; 5.70 + } 5.71 + return new WindowsX86CFrame(dbg, nextEBP, nextPC); 5.72 + } 5.73 + 5.74 + public Address pc() { 5.75 + return pc; 5.76 + } 5.77 + 5.78 + public Address localVariableBase() { 5.79 + return ebp; 5.80 + } 5.81 + 5.82 + private WindbgDebugger dbg; 5.83 +}
6.1 --- a/make/sa.files Thu May 16 17:54:11 2013 +0200 6.2 +++ b/make/sa.files Thu May 16 12:40:27 2013 +0100 6.3 @@ -48,8 +48,6 @@ 6.4 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/bsd/x86/*.java \ 6.5 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/*.java \ 6.6 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/*.java \ 6.7 -$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/x86/*.java \ 6.8 -$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/amd64/*.java \ 6.9 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/dummy/*.java \ 6.10 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/linux/*.java \ 6.11 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/linux/amd64/*.java \ 6.12 @@ -70,6 +68,8 @@ 6.13 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/*.java \ 6.14 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/amd64/*.java \ 6.15 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/x86/*.java \ 6.16 +$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windows/x86/*.java \ 6.17 +$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windows/amd64/*.java \ 6.18 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/x86/*.java \ 6.19 $(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/g1/*.java \ 6.20 $(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/parallelScavenge/*.java \