提交 22603112 编写于 作者: P poonam

6310967: SA: jstack -m produce failures in output

Summary: While looking for the sender frame check that the frame pointer should not be less than the stack pointer.
Reviewed-by: dholmes, sla
上级 41bcf476
/* /*
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -657,7 +657,7 @@ public class BugSpot extends JPanel { ...@@ -657,7 +657,7 @@ public class BugSpot extends JPanel {
while (fr != null) { while (fr != null) {
trace.add(new StackTraceEntry(fr, getCDebugger())); trace.add(new StackTraceEntry(fr, getCDebugger()));
try { try {
fr = fr.sender(); fr = fr.sender(t);
} catch (AddressException e) { } catch (AddressException e) {
e.printStackTrace(); e.printStackTrace();
showMessageDialog("Error while walking stack; stack trace will be truncated\n(see console for details)", showMessageDialog("Error while walking stack; stack trace will be truncated\n(see console for details)",
......
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
package sun.jvm.hotspot.debugger.bsd.amd64; package sun.jvm.hotspot.debugger.bsd.amd64;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.amd64.*;
import sun.jvm.hotspot.debugger.bsd.*; import sun.jvm.hotspot.debugger.bsd.*;
import sun.jvm.hotspot.debugger.cdbg.*; import sun.jvm.hotspot.debugger.cdbg.*;
import sun.jvm.hotspot.debugger.cdbg.basic.*; import sun.jvm.hotspot.debugger.cdbg.basic.*;
...@@ -51,8 +52,11 @@ final public class BsdAMD64CFrame extends BasicCFrame { ...@@ -51,8 +52,11 @@ final public class BsdAMD64CFrame extends BasicCFrame {
return rbp; return rbp;
} }
public CFrame sender() { public CFrame sender(ThreadProxy thread) {
if (rbp == null) { AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
Address rsp = context.getRegisterAsAddress(AMD64ThreadContext.RSP);
if ( (rbp == null) || rbp.lessThan(rsp) ) {
return null; return null;
} }
......
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -28,6 +28,7 @@ import sun.jvm.hotspot.debugger.*; ...@@ -28,6 +28,7 @@ import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.bsd.*; import sun.jvm.hotspot.debugger.bsd.*;
import sun.jvm.hotspot.debugger.cdbg.*; import sun.jvm.hotspot.debugger.cdbg.*;
import sun.jvm.hotspot.debugger.cdbg.basic.*; import sun.jvm.hotspot.debugger.cdbg.basic.*;
import sun.jvm.hotspot.debugger.x86.*;
final public class BsdX86CFrame extends BasicCFrame { final public class BsdX86CFrame extends BasicCFrame {
// package/class internals only // package/class internals only
...@@ -52,8 +53,11 @@ final public class BsdX86CFrame extends BasicCFrame { ...@@ -52,8 +53,11 @@ final public class BsdX86CFrame extends BasicCFrame {
return ebp; return ebp;
} }
public CFrame sender() { public CFrame sender(ThreadProxy thread) {
if (ebp == null) { X86ThreadContext context = (X86ThreadContext) thread.getContext();
Address esp = context.getRegisterAsAddress(X86ThreadContext.ESP);
if ( (ebp == null) || ebp.lessThan(esp) ) {
return null; return null;
} }
......
/* /*
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -34,7 +34,7 @@ import sun.jvm.hotspot.debugger.*; ...@@ -34,7 +34,7 @@ import sun.jvm.hotspot.debugger.*;
public interface CFrame { public interface CFrame {
/** Returns null when no more frames on stack */ /** Returns null when no more frames on stack */
public CFrame sender(); public CFrame sender(ThreadProxy th);
/** Get the program counter of this frame */ /** Get the program counter of this frame */
public Address pc(); public Address pc();
......
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
package sun.jvm.hotspot.debugger.cdbg.basic.amd64; package sun.jvm.hotspot.debugger.cdbg.basic.amd64;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.amd64.*;
import sun.jvm.hotspot.debugger.cdbg.*; import sun.jvm.hotspot.debugger.cdbg.*;
import sun.jvm.hotspot.debugger.cdbg.basic.*; import sun.jvm.hotspot.debugger.cdbg.basic.*;
...@@ -43,8 +44,11 @@ public class AMD64CFrame extends BasicCFrame { ...@@ -43,8 +44,11 @@ public class AMD64CFrame extends BasicCFrame {
this.pc = pc; this.pc = pc;
} }
public CFrame sender() { public CFrame sender(ThreadProxy thread) {
if (rbp == null) { AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
Address rsp = context.getRegisterAsAddress(AMD64ThreadContext.RSP);
if ( (rbp == null) || rbp.lessThan(rsp) ) {
return null; return null;
} }
......
/* /*
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
package sun.jvm.hotspot.debugger.cdbg.basic.x86; package sun.jvm.hotspot.debugger.cdbg.basic.x86;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.x86.*;
import sun.jvm.hotspot.debugger.cdbg.*; import sun.jvm.hotspot.debugger.cdbg.*;
import sun.jvm.hotspot.debugger.cdbg.basic.*; import sun.jvm.hotspot.debugger.cdbg.basic.*;
...@@ -43,8 +44,11 @@ public class X86CFrame extends BasicCFrame { ...@@ -43,8 +44,11 @@ public class X86CFrame extends BasicCFrame {
this.pc = pc; this.pc = pc;
} }
public CFrame sender() { public CFrame sender(ThreadProxy thread) {
if (ebp == null) { X86ThreadContext context = (X86ThreadContext) thread.getContext();
Address esp = context.getRegisterAsAddress(X86ThreadContext.ESP);
if ( (ebp == null) || ebp.lessThan(esp) ) {
return null; return null;
} }
......
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
package sun.jvm.hotspot.debugger.linux.amd64; package sun.jvm.hotspot.debugger.linux.amd64;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.amd64.*;
import sun.jvm.hotspot.debugger.linux.*; import sun.jvm.hotspot.debugger.linux.*;
import sun.jvm.hotspot.debugger.cdbg.*; import sun.jvm.hotspot.debugger.cdbg.*;
import sun.jvm.hotspot.debugger.cdbg.basic.*; import sun.jvm.hotspot.debugger.cdbg.basic.*;
...@@ -51,8 +52,11 @@ final public class LinuxAMD64CFrame extends BasicCFrame { ...@@ -51,8 +52,11 @@ final public class LinuxAMD64CFrame extends BasicCFrame {
return rbp; return rbp;
} }
public CFrame sender() { public CFrame sender(ThreadProxy thread) {
if (rbp == null) { AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
Address rsp = context.getRegisterAsAddress(AMD64ThreadContext.RSP);
if ( (rbp == null) || rbp.lessThan(rsp) ) {
return null; return null;
} }
......
/* /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -57,7 +57,7 @@ final public class LinuxSPARCCFrame extends BasicCFrame { ...@@ -57,7 +57,7 @@ final public class LinuxSPARCCFrame extends BasicCFrame {
return sp; return sp;
} }
public CFrame sender() { public CFrame sender(ThreadProxy thread) {
if (sp == null) { if (sp == null) {
return null; return null;
} }
......
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -28,6 +28,7 @@ import sun.jvm.hotspot.debugger.*; ...@@ -28,6 +28,7 @@ import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.linux.*; import sun.jvm.hotspot.debugger.linux.*;
import sun.jvm.hotspot.debugger.cdbg.*; import sun.jvm.hotspot.debugger.cdbg.*;
import sun.jvm.hotspot.debugger.cdbg.basic.*; import sun.jvm.hotspot.debugger.cdbg.basic.*;
import sun.jvm.hotspot.debugger.x86.*;
final public class LinuxX86CFrame extends BasicCFrame { final public class LinuxX86CFrame extends BasicCFrame {
// package/class internals only // package/class internals only
...@@ -52,8 +53,11 @@ final public class LinuxX86CFrame extends BasicCFrame { ...@@ -52,8 +53,11 @@ final public class LinuxX86CFrame extends BasicCFrame {
return ebp; return ebp;
} }
public CFrame sender() { public CFrame sender(ThreadProxy thread) {
if (ebp == null) { X86ThreadContext context = (X86ThreadContext) thread.getContext();
Address esp = context.getRegisterAsAddress(X86ThreadContext.ESP);
if ( (ebp == null) || ebp.lessThan(esp) ) {
return null; return null;
} }
......
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -37,7 +37,7 @@ final class ProcCFrame extends BasicCFrame { ...@@ -37,7 +37,7 @@ final class ProcCFrame extends BasicCFrame {
return fp; return fp;
} }
public CFrame sender() { public CFrame sender(ThreadProxy t) {
return sender; return sender;
} }
......
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -158,7 +158,7 @@ public class PStack extends Tool { ...@@ -158,7 +158,7 @@ public class PStack extends Tool {
printUnknown(out); printUnknown(out);
} }
} }
f = f.sender(); f = f.sender(th);
} }
} catch (Exception exp) { } catch (Exception exp) {
exp.printStackTrace(); exp.printStackTrace();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册