《LINUX教學:Ubuntu 16.04下OpenJDK8編譯和Debug》要點:
本文介紹了LINUX教學:Ubuntu 16.04下OpenJDK8編譯和Debug,希望對您有用。如果有疑問,可以聯(lián)系我們。
系統(tǒng)情況為Ubuntu 16.04,uname -a:
Linux ddy-Aspire-V5-573G 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
在本文中,要編譯的openjdk版本為:openjdk-8u40-src-b25-10_feb_2015.
測驗考試了編譯openjdk-8-src-b132-03_mar_2014,但是失敗.網(wǎng)上說,因為ubuntu 16.04較新,但是該版本的JDK較老,所以失敗.
下面闡明編譯和debug過程.
openjdk-8u40-src-b25-10_feb_2015 與 openjdk-8-src-b132-03_mar_2014 及? jdk-7u76-linux-x64?下載見
可以到Linux公社資源站下載文本闡明,里面有下載地址:
------------------------------------------朋分線------------------------------------------
免費下載地址在 http://linux.linuxidc.com/
用戶名與暗碼都是www.linuxidc.com
具體下載目錄在 /2017年材料/6月/13日/Ubuntu 16.04下OpenJDK8編譯和Debug/
下載辦法見
------------------------------------------朋分線------------------------------------------
OpenJDK8可以使用"config && make"編譯構(gòu)建,不再使用Ant和ALT_ *環(huán)境變量來配置構(gòu)建.
不過必要GNU make 3.81或更新的版本
我使用的領導JDK是jdk-7u76-linux-x64.
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
安裝gcc、g++、make等sudo apt-get install build-essential
安裝XRendersudo apt-get install libxrender-dev
sudo apt-get install xorg-dev
安裝alsasudo apt-get install libasound2-dev
Cupssudo apt-get install libcups2-dev
安裝零碎的對象包sudo apt-get install gawk zip libxtst-dev libxi-dev libxt-dev
--with-boot-jdk:指定引導JDK地點目錄,以防其他安裝的JDK影響(本機上以前安裝了JDK8,并配置了JAVA_HOME指向JDK8);
--with-target-bits:指定編譯64位系統(tǒng)的JDK;
為可以進行源碼調(diào)試,再指定下面三個參數(shù):
--with-debug-level=slowdebug:指定可以生成最多的調(diào)試信息;
--enable-debug-symbols ZIP_DEBUGINFO_FILES=0:生成調(diào)試的符號信息,而且不壓縮;
在openjdk目錄下新建build.sh,內(nèi)容如下:
cd openjdk
bash ./configure --with-target-bits=64 --with-boot-jdk=/usr/java/jdk1.7.0_80/ --with-debug-level=slowdebug --enable-debug-symbols ZIP_DEBUGINFO_FILES=0
make all ZIP_DEBUGINFO_FILES=0
執(zhí)行./build.sh
編譯完成是如許的:
ddy@ddy-Aspire-V5-573G ~/openjdk-compile/openjdk-8u40-src-b25-10_feb_2015/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/bin $ ./java -version
openjdk version "1.8.0-internal-debug"
OpenJDK Runtime Environment (build 1.8.0-internal-debug-ddy_2017_06_11_23_26-b00)
OpenJDK 64-Bit Server VM (build 25.40-b25-debug, mixed mode)
ddy@ddy-Aspire-V5-573G ~/openjdk-compile/openjdk-8u40-src-b25-10_feb_2015/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/bin $ export CLASSPATH=.:/home/
ddy/java_src
ddy@ddy-Aspire-V5-573G ~/openjdk-compile/openjdk-8u40-src-b25-10_feb_2015/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/bin $ gdb --args java FileChann
elTest
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from java...done.
(gdb) break init.cpp:95
No source file named init.cpp.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (init.cpp:95) pending.
(gdb) run
Starting program: /home/ddy/openjdk-compile/openjdk-8u40-src-b25-10_feb_2015/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/bin/java FileChannelTest
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7fc8700 (LWP 9311)]
[Switching to Thread 0x7ffff7fc8700 (LWP 9311)]
Thread 2 "java" hit Breakpoint 1, init_globals ()
at /home/ddy/openjdk-compile/openjdk-8u40-src-b25-10_feb_2015/openjdk/hotspot/src/share/vm/runtime/init.cpp:95
95 jint init_globals() {
(gdb) l
90 chunkpool_init();
91 perfMemory_init();
92 }
93
94
95 jint init_globals() {
96 HandleMark hm;
97 management_init();
98 bytecodes_init();
99 classLoader_init();
(gdb) quit
A debugging session is active.
Inferior 1 [process 9307] will be killed.
Quit anyway? (y or n) y
ddy@ddy-Aspire-V5-573G ~/openjdk-compile/openjdk-8u40-src-b25-10_feb_2015/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/bin $
本文永遠更新鏈接地址:
維易PHP培訓學院每天發(fā)布《LINUX教學:Ubuntu 16.04下OpenJDK8編譯和Debug》等實戰(zhàn)技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培養(yǎng)人才。
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/12097.html