简体   繁体   中英

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.

If you want the non-java stack, you need a "native" debugger, eg 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.)

如果可以在应用程序外部执行此操作,则可以运行$JAVA_HOME/bin/jstack -m <jvm_pid>

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM