JVM学习-2.1 编译并调试openjdk的zero版 之CDT篇

上篇解决了在netbeans下编译调试openjdk的问题。毕竟用惯了eclipse,我想着尝试用eclipse CDT来替代Netbeans.结果成功了。

过程如下:

  1. 在eclipse里Import项目,选择Exsiting code as makefile project,选择项目目录:icedtea6/openjdk-ecj/hotspot
  2. 配置项目,首先是build,在
    1. Builder Setting里,Build directory=${workspace_loc:/hotspot}/../..
    2. Behavior里,Build(Incremental build)=hotspot, clean不要选中
  3. 配置代码提示部分,C/C++Generall > Paths and Symbols.下面的是从.cproject文件里复制出来的,定义了很多宏
    1. C Symbols Tab,即预处理宏:
      <listOptionValue builtIn="false" value="CC_INTERP"/>
      <listOptionValue builtIn="false" value="&quot;DERIVATIVE_ID=&quot;IcedTea6 1.12pre+r3c02d4ef4cdd+&quot;"/>
      <listOptionValue builtIn="false" value="&quot;DISTRIBUTION_ID=&quot;Built on Ubuntu 10.04.4 LTS (Thu Feb 16 14:00:21 CST 2012)&quot;"/>
      <listOptionValue builtIn="false" value="HOTSPOT_BUILD_TARGET=&quot;product&quot;"/>
      <listOptionValue builtIn="false" value="HOTSPOT_BUILD_USER=&quot;jack&quot;"/>
      <listOptionValue builtIn="false" value="HOTSPOT_LIB_ARCH=&quot;i386&quot;"/>
      <listOptionValue builtIn="false" value="HOTSPOT_RELEASE_VERSION=&quot;20.0-b12&quot;"/>
      <listOptionValue builtIn="false" value="HOTSPOT_VM_DISTRO=&quot;OpenJDK&quot;"/>
      <listOptionValue builtIn="false" value="IA32"/>
      <listOptionValue builtIn="false" value="JRE_RELEASE_VERSION=&quot;1.6.0_24-b24&quot;"/>
      <listOptionValue builtIn="false" value="LINUX"/>
      <listOptionValue builtIn="false" value="PRODUCT"/>
      <listOptionValue builtIn="false" value="TARGET_ARCH_MODEL_zero"/>
      <listOptionValue builtIn="false" value="TARGET_ARCH_zero"/>
      <listOptionValue builtIn="false" value="TARGET_COMPILER_gcc"/>
      <listOptionValue builtIn="false" value="TARGET_OS_ARCH_MODEL_linux_zero"/>
      <listOptionValue builtIn="false" value="TARGET_OS_ARCH_linux_zero"/>
      <listOptionValue builtIn="false" value="TARGET_OS_FAMILY_linux"/>
      <listOptionValue builtIn="false" value="VM_LITTLE_ENDIAN"/>
      <listOptionValue builtIn="false" value="ZERO"/>
      <listOptionValue builtIn="false" value="ZERO_LIBARCH=&quot;i386&quot;"/>
      <listOptionValue builtIn="false" value="_GNU_SOURCE"/>
      <listOptionValue builtIn="false" value="_REENTRANT"/>
      <listOptionValue builtIn="false" value="DEBUG_PRINT_METHOD"/>
       
    2. C++ Symbols,
      <listOptionValue builtIn="false" value="ARCH=&quot;i386&quot;"/>
      <listOptionValue builtIn="false" value="CC_INTERP"/>
      <listOptionValue builtIn="false" value="&quot;DERIVATIVE_ID=&quot;IcedTea6 1.12pre+r3c02d4ef4cdd+&quot;"/>
      <listOptionValue builtIn="false" value="&quot;DISTRIBUTION_ID=&quot;Built on Ubuntu 10.04.4 LTS (Thu Feb 16 14:00:21 CST 2012)&quot;"/>
      <listOptionValue builtIn="false" value="FULL_VERSION=&quot;20.0-b12&quot;"/>
      <listOptionValue builtIn="false" value="GAMMA"/>
      <listOptionValue builtIn="false" value="HOTSPOT_BUILD_TARGET=&quot;product&quot;"/>
      <listOptionValue builtIn="false" value="HOTSPOT_BUILD_USER=&quot;jack&quot;"/>
      <listOptionValue builtIn="false" value="HOTSPOT_LIB_ARCH=&quot;i386&quot;"/>
      <listOptionValue builtIn="false" value="HOTSPOT_RELEASE_VERSION=&quot;20.0-b12&quot;"/>
      <listOptionValue builtIn="false" value="HOTSPOT_VM_DISTRO=&quot;OpenJDK&quot;"/>
      <listOptionValue builtIn="false" value="IA32"/>
      <listOptionValue builtIn="false" value="JDK_MAJOR_VERSION=&quot;1&quot;"/>
      <listOptionValue builtIn="false" value="JDK_MINOR_VERSION=&quot;6&quot;"/>
      <listOptionValue builtIn="false" value="JRE_RELEASE_VERSION=&quot;1.6.0_24-b24&quot;"/>
      <listOptionValue builtIn="false" value="LAUNCHER_TYPE=&quot;gamma&quot;"/>
      <listOptionValue builtIn="false" value="LINK_INTO_LIBJVM"/>
      <listOptionValue builtIn="false" value="LINUX"/>
      <listOptionValue builtIn="false" value="PRODUCT"/>
      <listOptionValue builtIn="false" value="TARGET_ARCH_MODEL_zero"/>
      <listOptionValue builtIn="false" value="TARGET_ARCH_zero"/>
      <listOptionValue builtIn="false" value="TARGET_COMPILER_gcc"/>
      <listOptionValue builtIn="false" value="TARGET_OS_ARCH_MODEL_linux_zero"/>
      <listOptionValue builtIn="false" value="TARGET_OS_ARCH_linux_zero"/>
      <listOptionValue builtIn="false" value="TARGET_OS_FAMILY_linux"/>
      <listOptionValue builtIn="false" value="ZERO"/>
      <listOptionValue builtIn="false" value="ZERO_LIBARCH=&quot;i386&quot;"/>
      <listOptionValue builtIn="false" value="_GNU_SOURCE"/>
      <listOptionValue builtIn="false" value="_REENTRANT"/>
      <listOptionValue builtIn="false" value="DEBUG_PRINT_METHOD"/>
        
    3. include path部分好像cdt会自动添加,如果需要没添加的,手工添加进去即可。
  4. 新建一个run configuration,
    1. Main tab > c/c++ Application = icedtea6/openjdk.build-ecj/hotspot/outputdir/linux_i486_zero/product/gamma
    2. disable auto build
    3. argument = -cp classic_hello_world foo.Hello -Djava.compiler=NONE,或者写你要执行的任何java类
    4. 添加环境变量,LD_LIBRARY_PATH=${YourIcedtea6}/openjdk.build-ecj/hotspot/outputdir/linux_i486_zero/product
  5. 大功告成,此时项目能有代码提示,请随意设置断点调试jvm。

最后上图,图中断点处正是主循环main_loop,"解释那些字节码"


JVM学习-2.1 编译并调试openjdk的zero版 之CDT篇_第1张图片
 

你可能感兴趣的:(OpenJDK)