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 use IntelliJ IDEA for remote debugging

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article is about how to use IntelliJ IDEA for Remote Debugging. Xiaobian thinks it is quite practical, so share it with you to learn. I hope you can gain something after reading this article. Let's not say much. Let's take a look at it together with Xiaobian.

1. preface

There was a Bug on the line today, and the pit is related to WeChat related things can not be debugged offline. The traditional approach is to bury various log points in the code and then redeploy for debugging, and then analyze the information in the log. If your log burial point is unreasonable, you have to keep modifying the code and packaging deployment. Is there any way to avoid the above problem?

2. Remote Debugging

Of course there is a solution, and that is Remote Debugging. Remote Debugging enables developers to diagnose problems directly on servers or other online processes. It provides a way to trace online runtime errors and identify performance bottlenecks and root causes, allowing you to Debug remote servers just as you would debug locally. Next we will use the popular Java IDE IntelliJ IDEA from JetBrains for Remote Debugging. For the remote server to run code that supports Remote Debugging, specific JVM parameters must be added at startup. These parameters are:

debug_port is an open debug port on the server, which will be used for subsequent local configuration.

3. Remote Debugging Using IDEA

IntelliJ IDEA for Remote Debugging is not complicated and can be easily configured in the following steps.

3.1 Local parameter configuration

Open the configuration panel as shown in the figure above and create a new Remote Debugging Panel as follows:

Follow the sequence shown above to configure your server and local environment, and click OK. The ports in steps 2 and 4 are the debug_port port numbers we specify remotely.

3.2 JDWP protocol

There is a small knowledge point here is jdwp in the parameters. What is JDP?

JDWP stands for Java Debug Wire Protocol, which defines the communication protocol between the debugger and the target virtual machine. The Java program we want to debug runs in Target vm, which is no different from the general running JVM, except that JDWP Agent is loaded at startup to have debugging function. The debugger is our local debugger, which sends instructions to the running target vm to get the runtime state of the target vm and control the execution of the remote Java program. Debugger and target vm run in separate processes and communicate with each other via the JDWP communication protocol. 3.3 Turn on Remote Debugging

Click the green beetle button (shortcut key Shift + F9) shown by the arrow to start debugging, and then set the breakpoint of the local code, so that the remote logic triggers the breakpoint logic to debug the break point.

Make sure that the local debug code is exactly the same as the remote deployment code, and no modifications can occur! Otherwise, the breakpoint will not hit! 4. some points

In addition to the need to keep the code consistent, there are a few caveats here. After debugging, the remote JDWP Agent should be disabled, that is, the relevant parameters of the remote should be removed. In addition, remote logs are not mapped locally during debugging. Of course, you can map remote logs locally with the help of some tools to provide more powerful debugging functions.

Also keep in mind that while Remote Debugging is a very powerful tool, it's not a silver bullet! The production environment is not a suitable target for debugging. Do not abuse it!

The above is how to use IntelliJ IDEA for Remote Debugging. Xiaobian believes that some knowledge points may be seen or used 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