OpenJDK9 Hotspot Mac OSX 编译和调试

发布时间:2019-06-26 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了OpenJDK9 Hotspot Mac OSX 编译和调试脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

Intellij CLion CPU 占用率太高,还出各种奇怪问题,转投 xcode 调试 hotspot

安装 hg

# brew install hg 

下载 oPEn jdk 9 代码

# hg clone http://hg.openjdk.java.net/jdk9/dev

漫长等待,中间无数次中断

安装 freetype

# brew install freetype

安装 libffi(可选)

如果要使用 zero 解释器,需要安装 libffi

# brew install libffi

configure

# 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

--with-debug-level

设置调试级别,设成 slow debug 可以提供更多的调试信息

--with-free-type

设置 free type 路径

--disable-warnings-as-errors

忽略警告

--with-jvm-features

设置使用 c++ 实现的 zero 解释器,比基于模版的解释器更容易调试(如果汇编功力不够的话)

--with-jvm-variants

配合 --with-jvm-features 使用

--with-libffi

配合 --with-jvm-features 使用

--with-libffi-include

设置 libffi include 文件夹路径

make

# make

构建成功后:
jdk -> build/macosx-x86_64-normal-server-slowdebug/jdk
hotspot -> build/macOSX-x86_64-normal-server-slowdebug/hotspot

Xcode 调试

新建 command line 工程

新建一个 command line(命令行工具)工程,新建后删除 XCode 自动生成的代码

编辑 hotspot scheme

首先去掉 IDE build 配置,因为我们无法(也不需要)在IDE中构建 hotspot,其次将运行目标修改为: <jdk源代码目录>/build/macosx-x86_64-normal-server-slowdebug/jdk/bin/java(在编译源代码阶段已经生成)

添加 hotspot src 到工程

右击 hotspot 工程,选择 "add files to PRoject" 添加 <jdk源代码目录>/hotspot/src 到工程中

在 jni.cpp 的 JNI_CreateJavaVM 方法中设置断点, goooooo

如果出现 sigsegv 信号中断,可以在 lldb 中设置

(lldb) process handle SIGSEGV --stop=false

上图

OpenJDK9 Hotspot Mac OSX 编译和调试

脚本宝典总结

以上是脚本宝典为你收集整理的OpenJDK9 Hotspot Mac OSX 编译和调试全部内容,希望文章能够帮你解决OpenJDK9 Hotspot Mac OSX 编译和调试所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。