7

openjdk 单步调试

 2 years ago
source link: https://segmentfault.com/a/1190000040821702
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

openjdk 单步调试

发布于 10 月 16 日

大家好,最近搭建了 openjdk 单步调试 环境,看了一些博客,过程中还是耗费很多时间,这次把步骤发出来,希望大家可以作为参照,节省环境搭建的时间。

从 gitee 上面把拉带代码,最好可以fork 一份到自己的仓库,这样以后对源码的修改可以push到远程,在跨设备工作时会更加方便,另外,个人帐号可以设置仓库为私有。

git clone https://gitee.com/mirrors/openjdk.git

切换到指定标签,从指定标签建立新分支。

git tag | grep b120
git checkout jdk8-b120
git checkout -b jdk8-b120

如果是自己的仓库,可以将新分支 push 到远程。

git remote add jdk8-b120 https://gitee.com/xxx/openjdk.git
git push jdk8-b120

接下来就是编译源码,是一个有门槛的部分,作为一名JAVA程序员,对c、c++编译,linux系统自带的gcc版本还是比较陌生的,下面会列出组件的版本。

基础环境配置

# gcc
gcc version 4.8.5 20150623
# centos
CentOS Linux release 7.9.2009 (Core)
# bootstrap java
java-se-7u75-ri

开始编译,先安装一波系统组件

sudo yum install libXtst-devel libXt-devel \
libXrender-devel cups-devel freetype-devel \
alsa-lib-devel -y

将 /home/xxx/xxx/java-se-7u75-ri 替换为自己的 java
若未采用上面列出的组件版本,这一步很有可能出现问题,可根据问题描述,百度解决的,需要一些耐心。

sudo bash configure --with-target-bits=64 \
--with-boot-jdk=/home/xxx/xxx/java-se-7u75-ri \
--with-debug-level=slowdebug \
--enable-debug-symbols ZIP_DEBUGINFO_FILES=0

这条命令耗时较久,可耐心等待

sudo make all DISABLE_HOTSPOT_OS_VERSION_CHECK=OK ZIP_DEBUGINFO_FILES=0

以上就是编译步骤,每一步都有说明,若大家完成了编译,接下来就是下载IDE,开始调试了。

说起IDE的选择,就比较纠结,尝试过几个IDE,最后选择了 eclipse cpp ,原因就是当初对 C 语言很不了解,边猜边试,试了几个IDE后,在 eclipse cpp 上面很容易就可以调试了,以下就是详细说明。

下载 eclipse cpp,这是国内的 eclipse 镜像站。

https://mirrors.neusoft.edu.cn/eclipse/technology/epp/downloads/release/2020-03/R/eclipse-cpp-2020-03-R-incubation-linux-gtk-x86_64.tar.gz

下载完成直接解压,进入 eclipse 目录使用命令启动 ./eclipse

设置调试配置

开始调试

以上就是本次分享的 单步调试,希望可以帮助到大家,谢谢~


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK