In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail the example analysis of the breakpoint operation of Visual Studio Debug. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Preface
Debugging skill is an important index to measure the level of programmers. It is also very important to master good debugging skills and the use of tools.
The Visual Studio debugger helps you observe the runtime behavior of the program and find problems. The debugger is available for all Visual Studio programming languages and their associated libraries. When using a debugger, you can interrupt program execution to check code, check and edit variables, view registers, view instructions created from source code, and view the memory space consumed by the application.
Breakpoints can be said to be the most commonly used function in the Debug process.
But what you are most familiar with and most frequently used is probably the ordinary breakpoint. In fact, with regard to breakpoints, Visual Studio has a lot of advanced features, some of which are simply debugging tools.
1. Ordinary breakpoint
In order to ensure the integrity of the content, we still need to talk about ordinary breakpoints.
The way to set a normal breakpoint is as simple as clicking in the gray area of the left column of the line of code or placing the cursor over a line of code and pressing F9.
As shown in the image above, the red dot in the left column represents a breakpoint.
Press F5 and Debugger will stop here.
two。 Conditional breakpoint
Unlike a normal breakpoint, the program stops every time it executes. The meaning of a conditional breakpoint is that Debugger stops here only if the condition is met.
The general way to set a conditional breakpoint is to right-select the condition at the red dot or place the cursor over the red dot, wait for the gear icon to appear and click.
The conditional breakpoint setting window is as follows.
There are three types of conditional breakpoints:
Conditional expression (Conditional Expression)
Hit times (Hit Count)
Filter (Filter)
Conditional expression
There are also two types of conditional expressions:
For ture (Is ture)
As shown in the following figure, the condition set here is that the breakpoint is hit when testInt = = 4 is ture.
On change (When changed)
As shown in the following figure, the condition set here is that the breakpoint is hit when the testInt is changed.
Hit times
The number of hits is very useful in Debug loop statements.
For example, if you suspect that the program error occurs after N loops or some loops, you can set the number of hits in the loop statement so that it stops at certain times or loops instead of every time.
As shown in the following figure, the condition set is: let it break every other loop.
Filter
Filters are used to limit the devices, processes, and threads on which the breakpoint is hit.
For example, in a multithreaded program, you don't have to GetThreadId manually, you can set it to stop only when it is executed in a thread at this point through a filter.
The filter expression usage is:
MachineName = "name"
ProcessId = value
ProcessName = "name"
ThreadId = value
ThreadName = "name"
You can use the operator & (AND), | | (OR), between multiple expressions! (NOT) connection.
3. Tracking breakpoint
In the breakpoint setting window, in addition to the conditions, we can also see the Action option box.
The meaning of Action is to set the tracking point (Tracepoint).
Tracepoint acts as a temporary Trace-enabled breakpoint that prints messages to the Output window.
Check the box to continue execution (Continue Execution), which means that when Tracepoint hits, Debugger will not stop, otherwise it will stop here. In both cases, the message is printed.
You can use the following keywords as messages.
4. Function breakpoint
Under the Debug menu, click New breakpoint to create two types of breakpoints: function breakpoints (Function Breakpoint) and data breakpoints (Data Breakpoint).
The breakpoint of a function is set by the name of the function, which is broken when the program executes the function.
5. Data breakpoint
Immediately above, let's talk about data breakpoints.
The point of a data breakpoint is to let the program break when the specified byte of an address changes. It can only be set under Break Mode.
The address bar can use a specific memory address or an expression to represent the memory address. For example, you can use & avar to break the program when the content of the variable avar changes.
6. Set breakpoints in Call Stack Window
Maybe you don't know, you can set breakpoints in the Call Stack window.
When you want to quickly set breakpoints in these functions when viewing the function call relationship, it is actually very simple: in the Call Stack window, click on the line of the function you want to set the breakpoint, and press F9.
7. Set breakpoints in Disassembly Window
You can also set breakpoints in the Disassembly window. But the premise must be under Break Mode.
The disassembly window sets breakpoints in the same way as in the source code, with a single click on the edge of the left column of the code and the red dot appears.
8. Breakpoint management
All the breakpoints we set earlier will appear in the breakpoint window (Breakpoints Windows).
Here, you can manage all breakpoints, such as batch enabling, disabling, deleting, and so on, and you can also view the hit status of breakpoints while the program is running.
It is very useful when your project is very large and Debug sets a lot of breakpoints.
This is the end of the article on "sample analysis of breakpoint operation of Visual Studio Debug". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.