Bionix1441
Bionix1441

Reputation: 2319

How to print out native stacktrace in Java?

I would like to print the stacktrace of native methods calls of a Java application. The Thread.dumpStack() is only printing java methods calls.

Upvotes: 2

Views: 2314

Answers (3)

Chris K
Chris K

Reputation: 11917

To view the internal JVM (C-level) function calls, attach a standard C debugger to the process.

Exactly how to do this does depends on your OS and debugger of choice, for example on OSX one would use xcode. Instructions for using gdb can be read here.

Upvotes: 2

Has QUIT--Anony-Mousse
Has QUIT--Anony-Mousse

Reputation: 77454

If you want the non-java stack, you need a "native" debugger, e.g. gdb.

You can attach to your running java with gdb, too.

For documentation on seamless debugging of Java with gdb, see also: http://gcc.gnu.org/java/gdb.html

(gcc can compile java code to native code; at which point the native debugger will also show Java backtraces.)

Upvotes: 4

K Erlandsson
K Erlandsson

Reputation: 13696

If it is OK to do it outside of your application you can run $JAVA_HOME/bin/jstack -m <jvm_pid>

Upvotes: 2

Related Questions