How to get stack contents in an Exception stack trace

Hi

Currenty when an exception in thrown in a java class copiled with debug option we get line numbers in the stacktrace but we do not get the state of the stack.

How can I the details of the stack (i.e. values of all the local variables visible in that thread) ?

As information is available when we debug the application so I presume this information should be available but I do not know how to access it.

Obviously I would need to override this in my custom Exception as this feature is not provided by JAVA currently

I analyzed that the fillStacktrace() method is the most likely candidate but it has a native implementation in class Throwable hence was not able to get the details.

This would be a nice feature to have in future Java release

[789 byte] By [borntougha] at [2007-10-2 9:52:10]
# 1

Without any debugger agent running [a JVMDI or a JVM TI agent (since 5.0)], you won't be able to get values of local variables etc. When you debug a Java program "jdwp" agent is running in the JVM. With JVM running without any debugger agent, you can just get stacktrace with line numbers (provided you compiled java program with -g).

sundararajan.aa at 2007-7-16 23:57:11 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...