About Eclipse code breakpoint debugging and related shortcut keys

About Eclipse code breakpoint debugging and related shortcut keys

Function shortcut key

First of all, the shortcut keys for Debug testing:
Debug
F5: Step Into (debug)
F6: Step over (debug)
F7: Step return (debug)
F8: Resume (debug)
F11: debug the previous application (debug)

Followed by some common shortcut keys for Eclipse:

  1. 【ALT+/】
    This shortcut key is a good helper for users to edit, and can provide content assistance for users. Don’t worry about not remembering the names of methods and attributes. When you can’t remember the names of classes, methods and attributes, try 【ALT+/ ] The benefits brought by the shortcut keys.
  2. 【Ctrl+O】
    Displays the outline of methods and properties in the class, can quickly locate the methods and properties of the class, and is very useful when finding bugs.
  3. 【Ctrl+/】
    Quickly add comments, you can quickly add comments or uncomments for the line where the cursor is located or the selected line, you may always need to comment or uncomment something when debugging, now it’s good, you don’t need to repeat every line Notes for .
  4. 【Ctrl+D】
    Delete the current line, which is also one of the author's favorites. You don't need to press the delete key so many times to delete a line.
  5. [Ctrl+M]
    Maximize and restore the window. When users operate in the window, they always feel that the current window is small (especially when writing code).
    Viewing and locating shortcut keys
    In the program, it is very difficult to quickly locate the location of the code and quickly find the location of the bug. Eclipse provides a powerful search function, and you can use the following shortcut keys to help complete the search and location work.
  6. [Ctrl+K], [Ctrl++Shift+K]
    Quickly search the selected content downward and upward, and no longer need to click the search dialog box with the mouse.
  7. 【Ctrl+Shift+T】
    Find the Java class files that can be found in the build path of the workspace (Workspace), don't worry about not finding the class, and you can use wildcards such as "*" and "?".
  8. [Ctrl+Shift+R]
    corresponds to [Ctrl+Shift+T], and searches for all files (including Java files) in the workspace (Workspace), and wildcards can also be used.
  9. [Ctrl+Shift+G]
    Find references to classes, methods and properties. This is a very practical shortcut key. For example, if you want to modify the code that refers to a certain method, you can use the [Ctrl+Shift+G] shortcut key to quickly locate all the locations that refer to this method.
  10. [Ctrl+Shift+O]
    Quickly generate imports. After copying a program from the Internet, you don’t know how to import into the called class. Try the shortcut keys of [Ctrl+Shift+O], and there will be surprises.
  11. 【Ctrl+Shift+F】
    Format the code. Writing code with a standardized format is a compulsory course for every programmer. When you see a piece of code that is not pleasing to the eye, press the shortcut key 【Ctrl+Shift+F】 after selecting it. Format this code, if no code is selected, the current file (Java file) will be formatted by default.
  12. [ALT+Shift+W]
    Find the path in the project where the current file is located, and you can quickly locate the location of the browser view. If you want to find the package where a certain file is located, this shortcut key is very useful (especially in relatively large projects) .
  13. 【Ctrl+L】
    Locate to a certain line of the current editor, and it is also valid for non-Java files.
  14. [Alt+←], [Alt+→]
    Back history and forward history are very useful when tracking codes. Users may find several related places, but they may not remember clearly. You can use these two shortcut keys to locate The order of lookup.
  15. 【F3】
    Quickly locate a certain class, method and property at the cursor position.
  16. 【F4】
    Display the inheritance relationship of the class, and open the class inheritance view.

Eclipse code breakpoint debugging

1. First, set a breakpoint: In the place where you need to debug in the code, double-click the left side of the code line number, and double-click again to cancel the breakpoint.

insert image description here
2. Start the service and start debugging: Method 1, for example, in the code above, click the main method -> right-click Debug As -> Java Application to start java code debugging; Method 2, directly click the "Debug" button, that is, click the little ladybug In the inverted triangle on the side, select Debug As–>Java Application,; method 3, shortcut key F11; method 4, select Run–>Debug in the menu bar, and other methods will not be described here. When the development tool is first debugged, a prompt will pop up, you need to switch to the Debug workspace, check "Remember my decision", and the prompt will not be displayed next time.
insert image description here
insert image description here

3. After running the java program in debug mode, jump to the debug view. The most commonly used windows are: Debug window, Variables window, Breakpoints window, code editing window, output Console window, and outline window. The Debug window displays the method call stack of the current thread, and the line to which the method is executed. Variables displays the local variables of the current method, non-static variables, etc., and variable values ​​can be modified. Breakpoints can be used to add and delete breakpoints. Console console Used to view printed log information.
insert image description here
4. The Debug view can be used to debug and run the program. The picture below shows the commonly used debug buttons and corresponding shortcut keys. 1 means continue to execute the code until the next breakpoint is encountered, shortcut key F8 (resume), 2 means stop debugging (terminate), 3 means enter the current method, execute step by step, shortcut key F5 (step into), 4 It means to run the next line of code, execute the current line, but not enter the execution details, the shortcut key is F6 (step over), and 5 means to exit the current method and return to the calling layer, the shortcut key is F7 (step return). During the debugging process, the Debug view has a lot of stack information. In addition, when the mouse is moved to the code editing window during debugging, the value of the current variable will be displayed when it is placed on the variable.
insert image description here
5.
Skip or clear breakpoints: 1 and 2 shown in the figure below are Skip All Breakpoints, set all breakpoints to skip, so there will be a slash on the breakpoint, indicating that the breakpoint is skipped, and the thread will not be suspended at this breakpoint. Click Run–>Remove All Breakpoints to clear all breakpoints, which can be done after breakpoint debugging.
insert image description here
6.
After the Debug debugging is completed, you need to switch back to the Java view. The following describes two switching methods. 1 is to switch through the two buttons in the upper right corner of the IDE, as shown in the figure below. 2 is to click the menu Window–>Perspective–>Open Perspective to select the corresponding view.
insert image description here
insert image description here

The knowledge points of the article are matched with the official knowledge files, and relevant knowledge can be further learned
Java skill treefront pageOverview 120,851 people are studying systematically

About Eclipse code breakpoint debugging and related shortcut keys

Function shortcut key

First of all, the shortcut keys for Debug testing:
Debug
F5: Step Into (debug)
F6: Step over (debug)
F7: Step return (debug)
F8: Resume (debug)
F11: debug the previous application (debug)

Followed by some common shortcut keys for Eclipse:

  1. 【ALT+/】
    This shortcut key is a good helper for users to edit, and can provide content assistance for users. Don’t worry about not remembering the names of methods and attributes. When you can’t remember the names of classes, methods and attributes, try 【ALT+/ ] The benefits brought by the shortcut keys.
  2. 【Ctrl+O】
    Displays the outline of methods and properties in the class, can quickly locate the methods and properties of the class, and is very useful when finding bugs.
  3. 【Ctrl+/】
    Quickly add comments, you can quickly add comments or uncomments for the line where the cursor is located or the selected line, you may always need to comment or uncomment something when debugging, now it’s good, you don’t need to repeat every line Notes for .
  4. 【Ctrl+D】
    Delete the current line, which is also one of the author's favorites. You don't need to press the delete key so many times to delete a line.
  5. [Ctrl+M]
    Maximize and restore the window. When users operate in the window, they always feel that the current window is small (especially when writing code).
    Viewing and locating shortcut keys
    In the program, it is very difficult to quickly locate the location of the code and quickly find the location of the bug. Eclipse provides a powerful search function, and you can use the following shortcut keys to help complete the search and location work.
  6. [Ctrl+K], [Ctrl++Shift+K]
    Quickly search the selected content downward and upward, and no longer need to click the search dialog box with the mouse.
  7. 【Ctrl+Shift+T】
    Find the Java class files that can be found in the build path of the workspace (Workspace), don't worry about not finding the class, and you can use wildcards such as "*" and "?".
  8. [Ctrl+Shift+R]
    corresponds to [Ctrl+Shift+T], and searches for all files (including Java files) in the workspace (Workspace), and wildcards can also be used.
  9. [Ctrl+Shift+G]
    Find references to classes, methods and properties. This is a very practical shortcut key. For example, if you want to modify the code that refers to a certain method, you can use the [Ctrl+Shift+G] shortcut key to quickly locate all the locations that refer to this method.
  10. [Ctrl+Shift+O]
    Quickly generate imports. After copying a program from the Internet, you don’t know how to import into the called class. Try the shortcut keys of [Ctrl+Shift+O], and there will be surprises.
  11. 【Ctrl+Shift+F】
    Format the code. Writing code with a standardized format is a compulsory course for every programmer. When you see a piece of code that is not pleasing to the eye, press the shortcut key 【Ctrl+Shift+F】 after selecting it. Format this code, if no code is selected, the current file (Java file) will be formatted by default.
  12. [ALT+Shift+W]
    Find the path in the project where the current file is located, and you can quickly locate the location of the browser view. If you want to find the package where a certain file is located, this shortcut key is very useful (especially in relatively large projects) .
  13. 【Ctrl+L】
    Locate to a certain line of the current editor, and it is also valid for non-Java files.
  14. [Alt+←], [Alt+→]
    Back history and forward history are very useful when tracking codes. Users may find several related places, but they may not remember clearly. You can use these two shortcut keys to locate The order of lookup.
  15. 【F3】
    Quickly locate a certain class, method and property at the cursor position.
  16. 【F4】
    Display the inheritance relationship of the class, and open the class inheritance view.

Eclipse code breakpoint debugging

1. First, set a breakpoint: In the place where you need to debug in the code, double-click the left side of the code line number, and double-click again to cancel the breakpoint.

insert image description here
2. Start the service and start debugging: Method 1, for example, in the code above, click the main method -> right-click Debug As -> Java Application to start java code debugging; Method 2, directly click the "Debug" button, that is, click the little ladybug In the inverted triangle on the side, select Debug As–>Java Application,; method 3, shortcut key F11; method 4, select Run–>Debug in the menu bar, and other methods will not be described here. When the development tool is first debugged, a prompt will pop up, you need to switch to the Debug workspace, check "Remember my decision", and the prompt will not be displayed next time.
insert image description here
insert image description here

3. After running the java program in debug mode, jump to the debug view. The most commonly used windows are: Debug window, Variables window, Breakpoints window, code editing window, output Console window, and outline window. The Debug window displays the method call stack of the current thread, and the line to which the method is executed. Variables displays the local variables of the current method, non-static variables, etc., and variable values ​​can be modified. Breakpoints can be used to add and delete breakpoints. Console console Used to view printed log information.
insert image description here
4. The Debug view can be used to debug and run the program. The picture below shows the commonly used debug buttons and corresponding shortcut keys. 1 means continue to execute the code until the next breakpoint is encountered, shortcut key F8 (resume), 2 means stop debugging (terminate), 3 means enter the current method, execute step by step, shortcut key F5 (step into), 4 It means to run the next line of code, execute the current line, but not enter the execution details, the shortcut key is F6 (step over), and 5 means to exit the current method and return to the calling layer, the shortcut key is F7 (step return). During the debugging process, the Debug view has a lot of stack information. In addition, when the mouse is moved to the code editing window during debugging, the value of the current variable will be displayed when it is placed on the variable.
insert image description here
5.
Skip or clear breakpoints: 1 and 2 shown in the figure below are Skip All Breakpoints, set all breakpoints to skip, so there will be a slash on the breakpoint, indicating that the breakpoint is skipped, and the thread will not be suspended at this breakpoint. Click Run–>Remove All Breakpoints to clear all breakpoints, which can be done after breakpoint debugging.
insert image description here
6.
After the Debug debugging is completed, you need to switch back to the Java view. The following describes two switching methods. 1 is to switch through the two buttons in the upper right corner of the IDE, as shown in the figure below. 2 is to click the menu Window–>Perspective–>Open Perspective to select the corresponding view.
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/qq_44543774/article/details/131320535