Debugging the HotSpot source code in eclipse, eclipsehotspot
Link to this article: http://www.cnblogs.com/myresearch/p/ide-buildhotspot.html.
When reading the OpenJDK source code, you often need to run and debug the program to help you understand it. Now we can compile a debugging version of the HotSpot virtual machine, disable optimization, and carry symbol information, so that we can use GDB for debugging. Many developers who have a deep understanding of virtual machines actually use GDB and VIM editors to develop and modify HotSpot, however, I believe most readers prefer to read and track the HotSpot source code in the IDE environment instead of text-only GDB. in the previous article, I have introduced how to compile OpenJDK7 source code on CentOS6.5, we will continue to introduce how to build an eclipse-based hot spot source code debugging environment in Linux.
Software Environment
Download eclipse at http://www.eclipse.org/cdt/downloads.php. eclipse supports C/C ++.
What I download is eclipse-cpp-kepler-sr2-linux-gtk-x86_64.tar.gz.
Operations
Step 1: First extract the JDK source code package, start eclipse, and selectFile>New>Makefile Project with Existing Code
The following interface is displayed:
Step 2: locate the project nameRight-click>Properties>C/C++ BuildYou need to modify the following two items:
Remove the check box of Use default build command in Builder and fill in the parameters.ARCH_DATA_MODEL=64
Append the Build directory of Build location to/make, which is $ {workspace_loc:/hotspot}/make. The purpose is to tell the make compiler to find the Makefile in this directory.
Step 3: select the menu barProject>Build ProjectYou can see that the build has started. take a lunch break (the first build may take 10-20 m ).
Some LOG information:
......
INFO: ENABLE_FULL_DEBUG_SYMBOLS = 1
INFO:/usr/bin/objcopy cmd found so will create. debuginfo files.
INFO: STRIP_POLICY = min_strip
INFO: ZIP_DEBUGINFO_FILES = 1
Make [1]: Entering directory '/home/jvm/opt/openjdk/hotspot/make'
Make [1]: Nothing to be done for 'generic _ export '.
Make [1]: Leaving directory '/home/jvm/opt/openjdk/hotspot/make'
02:01:39 Build Finished (took 23s. 540 ms)
Step 4: After the compilation is successful, you can test it. You need to configure the following steps:
Click Run> Debug deployments> New launch configuration in the menu bar, and enter/home/jvm/opt/openjdk/hotspot/build/linux/linux_amd64_compiler2/fastdebug/gamma in C/C ++ Application.
Select the current Project.
Enter-version in the Program arguments tab.
On the Environment tab, set Environment variables to set JAVA_HOME. |/application/java/jdk
Select Debug on the Common tab.
After the configuration is complete, click Debug to enter the debugging mode.
Because the HotSpot source code is long and the number of C/C ++ files is large, the code list provides the main usage of the Code in each directory for your reference.
Code List: HotSpot source code structure
Hotspot
├ ── Agent Serviceability Agent implementation
├ ── Make is used to build various configuration files of HotSpot.
Source code of javas── src HotSpot VM
│ Cpu-CPU-related code
│ Yun── OS operation code
│ ├ ── OS _cpu operating system + CPU combination code
│ Common‑share platform-independent code
│ ─ ── Tools
│ ├ ── Hsdis disassembly plug-in
│ ├ ── IdealGraphVisualizer: a tool that visualizes the intermediate code of the Server compiler.
│ Launch-launcher Startup Program "java"
│ ├-LogCompilation a tool that sorts the logs output by-XX: + LogCompilation (hotspot. log) into easier-to-read formats
│ └ ── ProjectCreator: a tool used to generate the project file of Visual Studio
│ Kernel-core code of vm HotSpot VM
│ Compiler-adlc platform description file (above cpu or *. ad file in OS _cpu)
│ ─ ── Asm assembler Interface
│ ─ ── C1 Client Compiler
│ ├ ── Ci Public Service/interface of dynamic Compiler
│ Processing of class‑classfile files (including class loading and system symbol tables)
│ ├-Code dynamically generated code management
│ Compiler Interface
│ ─ ── Gc_implementation GC implementation
│ ─ ── ConcurrentMarkSweep Concurrent Mark Sweep GC implementation
│ Implementation of Garbage-g1 Garbage-First GC (the old generational GC framework is not used)
│ ─ ── ParallelScavenge ParallelScavenge GC implementation (by default, Server VM does not use the old generational GC Framework)
│ ─ ── ParNew ParNew GC implementation
│ ─-Common implementation of shared GC
│ ─ ── Gc_interface GC Interface
│ ─ ── Interpreter, including "template interpreter" (in official use) and "C ++ interpreter" (the official version is no longer used)
│ ├ ── Libadt some abstract data structures
│ Memory-memory Management (the old generational GC framework is also here)
│ ├ ── Oops Implementation of the HotSpot VM Object System
│ Yun── opto Server Compiler
│ ├ ── Prims HotSpot VM's external interface, including native and JVMTI implementations of some standard Libraries
│ Runtime-runtime support library (including thread management, compiler scheduling, lock, reflection, etc)
│ ├ ── Services is mainly used to support interfaces for management functions such as JMX.
│ Mongo── shark JIT compiler based on LLVM (not used in official version)
│ └ ── Utilities some basic tool classes
Sequence-test unit test
References
Deep Java Virtual Machine