In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "what are the methods of IDEA debugging". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
I. Conditional Breakpoints
This technique is often used in loops, such as traversing a large List and wanting the breakpoint to stop at a particular value.
Refer to the above figure. At the breakpoint position, right click the red dot next to the breakpoint, and an interface will appear. Fill in the breakpoint condition here. In this way, debugging will automatically stop at i=10.
II. Return to "Previous"
This technique is most suitable for particularly complex method sets of scenes, finally run up, accidentally shake hands, breakpoint passed, want to look back at the variable value just now, if you do not know this technique, can only run again.
Refer to the above figure. Method1 calls method2. The current breakpoint position j=100. After clicking the Drop Frame icon at the red arrow position in the above figure, time passes.
Back to when method1 was first invoked, variable i became 99. There's nothing wrong with it, old guys. Isn't it very 6 :)
Note: Curiosity is the ladder of human progress. If you want to know why this function is called Drop Frame, rather than something like Back To Previous, you can go through the JVM book. The JVM stores the running state of the thread in stack frame units. Drop frame means throwing away the currently running stack frame, so that the current "pointer" position naturally reaches the position of the previous frame.
Third, multithreaded debugging
When multi-threads are running at the same time, who executes first and who executes later depends entirely on the CPU mood. It is impossible to control the sequence. There may be no problem when running, but debugging is more troublesome. The most obvious is breakpoint jumping. Stop this thread for a while and stop it in another thread for a while. For example, the following figure:
If you want the next breakpoint position to be the second verse, you may be disappointed:
If you want a thread to stop at whatever thread you want when debugging, you can right-click on the red dot of the three breakpoints in the figure.
Suspend suspends on a per-thread basis, not All. After setting all three breakpoints like this, try again.
Notice the red box in the image above. When the breakpoint stops, this drop-down box shows the threads (note: it's a good habit to give threads easily recognizable names!), We can choose the thread "Birds in the sky."
The breakpoint stops at the second verse as desired.
IV. Remote Debugging
This is also a weapon equipped with B, this machine does not need to start the project, as long as there is source code, you can directly Remote Debugging the code on the server in this machine, open posture is as follows:
1. Allow Remote Debugging when starting the project
java -server -Xms512m -Xmx512m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9081 -Djava.ext.dirs=. ${main_class}
What works is
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9081
Note: Remote Debugging is technically to establish scoket communication between local and remote, so ports should not conflict, and local must allow access to remote ports. In addition, this parameter should be placed before-jar or ${main_class}.
2. Set Remote Debugging in idea
And then you can debug it.
If you have the source code for your project, hit a breakpoint where you need it, and then try visiting a remote url, the breakpoint will stop.
V. Temporarily executing expressions/modifying running values of variables
When debugging, you can temporarily execute some expressions, refer to the following figure: click on any one of these two icons
Clicking on the + sign allows you to enter expressions in the new input box, such as i+5
Then enter, and you'll see the results immediately.
Of course, if you want to dynamically modify the value of a variable during debugging, it's also easy. Right-click on the variable and select Set Value. The rest is known to everyone on Earth.
"What are the methods of IDEA debugging?" The content is introduced here. Thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.