Intellij CLion CPU 占用率过高,还出各类奇怪问题,转投 Xcode 调试 hotspotjava
# brew install hg
# hg clone http://hg.openjdk.java.net/jdk9/dev
漫长等待,中间无数次中断c++
# brew install freetype
若是要使用 zero 解释器,须要安装 libffimacos
# brew install libffi
# bash configure --with-debug-level=slowdebug \ --with-freetype=/usr/local/opt/freetype \ --disable-warnings-as-errors \ --with-jvm-features=zero \ --with-jvm-variants=zero \ --with-libffi=/usr/local/opt/libffi \ --with-libffi-include=/usr/local/Cellar/libffi/3.0.13/lib/libffi-3.0.13/include
设置调试级别,设成 slow debug 能够提供更多的调试信息bash
设置 free type 路径jvm
忽略警告工具
设置使用 c++ 实现的 zero 解释器,比基于模版的解释器更容易调试(若是汇编功力不够的话)ui
配合 --with-jvm-features 使用spa
配合 --with-jvm-features 使用.net
设置 libffi include 文件夹路径命令行
# make
构建成功后:
jdk -> build/macosx-x86_64-normal-server-slowdebug/jdk
hotspot -> build/macosx-x86_64-normal-server-slowdebug/hotspot
新建一个 command line(命令行工具)工程,新建后删除 XCode 自动生成的代码
首先去掉 IDE build 配置,由于咱们没法(也不须要)在IDE中构建 hotspot,其次将运行目标修改成: <jdk源代码目录>/build/macosx-x86_64-normal-server-slowdebug/jdk/bin/java(在编译源代码阶段已经生成)
右击 hotspot 工程,选择 "add files to project" 添加 <jdk源代码目录>/hotspot/src 到工程中
在 jni.cpp 的 JNI_CreateJavaVM 方法中设置断点, goooooo
若是出现 sigsegv 信号中断,能够在 lldb 中设置
(lldb) process handle SIGSEGV --stop=false
上图