centos7 gdb调试jdk11源码
##首先你得编译一个debug版本的jdk11。教程centos7下openjdk11源码下载编译安装_openjdk11下载-CSDN博客
##gdb 启动java进程 设置运行参数、设置断点
运行、调试进入main断点
gdb /home/yym/code/jdk11u-master/build/linux-x86_64-normal-server-slowdebug/jdk/bin/java
(gdb) set args GDBDebugJava
(gdb) b b JavaMain
(gdb) b InitializeJVM
(gdb) b JNI_CreateJavaVM_inner
(gdb) handle SIGSEGV pass noprint nostop
##GDBDebugJava.java代码
import java.util.concurrent.TimeUnit;public class GDBDebugJava {public static void main(String[] args) {int i=0;try {TimeUnit.SECONDS.sleep(1);System.out.println("mi"+i++);}catch (Exception e) {e.printStackTrace();}MiDept miDept = new MiDept();miDept.show();}}
##MiDept.java
public class MiDept {public void show() {System.out.println("mi--------------");}}