Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to import OpenJDK11 source code and debug Clion

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is to share with you about Clion how to import OpenJDK11 source code and debug, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Import source code to CLION

Open CLION-> New CMake Project from Sources

Then select the JDK source directory, then press the default check box, and click OK, as shown below:

Adjust CMakeList.txt

If you press the default CMakeList.txt directly, you will find that any open code is fully red.

There are two main parts of the retained CMakeList.txt:

I. include_directories

This is to build a code index, which doesn't look like a full hit in Clion.

II. Add_executable

This is to create an execution program in Clion, and you can execute our java program directly

Then delete all the original test directories.

The complete CMakeList.txt is not copied because of its large length. You can go forward to view it with github:

Https://github.com/xiaodaojava/openjkd11-CmakeList

Start debugging

In the upper right corner, in the same location as idea, create a Cmake Application

Then we hit the breakpoint to line 394 of jdk11/src/java.base/share/native/libjli/java.c

As shown in the following figure:

Then click debug to run:

You can see the entry breakpoint, and you can see the-version parameter we passed in the Debug panel

During debugging, you will encounter error: No current target; cannot handle signals until you have a valid target and process. This mistake, forget it, just continue to run.

You will eventually see the following output on the console:

Signal of LLDB: SIGSEGV (signal SIGSEGV)

To solve the LLDB abnormal pause error above, we need to enter the following command at the entry breakpoint, that is, when we enter line 394,

Process handle-pass true-stop false SIGSEGVprocess handle-pass true-stop false SIGBUS

As shown in the following figure:

Then let go of the breakpoint to continue to run, you can see that this time the program was not accidentally paused, and output in the console

The initial debugging is not troublesome, and only one-version parameter is passed for testing. Later, we are going to write java programs and observe how the virtual machine executes our java code. Come on, everyone!

The above is how Clion imports the OpenJDK11 source code and debugs. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report