In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "what are the Visual Studio debugging skills", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "what are the Visual Studio debugging skills"!
1 hover the mouse to view the expression value
Debugging is very challenging. For example, you can see what went wrong by running through the function step by step, you can see who called the function by looking at the stack information, and so on.
But in either case, it's troublesome to look at the values of expressions and local variables (put expressions and local variables in the watch window).
An easier way is to hover the mouse over the data you want to view. If it is a class or structure, click expand to easily and quickly view its fields.
2 change the value of the variable during operation
The debugger is not only a tool for analyzing program crashes and weird behavior, but can also solve many bug by gradually debugging to check whether the data and behavior meet the program's expectations. Sometimes you wonder whether to set certain conditions to true so that the program will run correctly. In fact, all you have to do is move the mouse over the variable, double-click the value, and enter the value you want. In this way, there is no need to modify the code and restart the program.
3 set the next running location
A typical debugging case is that we often use the step-by-step debugging method to analyze why the function went wrong. At this time, you encounter this function calling other functions to return an error, and this error is not what you want, what should you do? Restart the debugger? Here's a better way to drag the yellow run location arrow directly to the location you want. In fact, it is to skip the middle to run the code and go straight to the desired location. It must be very simple.
4 Edit and then continue to run
When running a complex program and plug-in, you find an error, but you don't want to waste time recompiling and restarting the program.
It's simple, just modify the bug at this location and continue debugging. Visual studio will modify the program so that you can continue debugging without having to restart the program.
It is worth noting that the "Edit and then continue to run" feature has several limitations. First, it cannot be used on 64-bit code. If you want to use this feature, go to the compilation option in the project settings and select "x86" as the target platform. Don't worry, the target platform is separate from "debug" in reslease configuration, that is, it is still the "Any CPU" setting. Second, the "Edit and continue to run" function only applies to internal changes in a function. If you want to change the declaration of this function or add a new method, you can only choose to restart the program or continue without making any changes. If the modified method contains an lambda expression, it means that the delegate type automatically generated by the compiler is modified, which causes the compiler to stop running.
5 A convenient viewing window
Most modern debuggers have a view window. However, the visual studio view window is very easy to use, you can easily add and delete variables. Just click on the blank line in the window, enter the expression and press enter. Or click on the expression and press delete to delete the unwanted expression.
In the debug window, you can not only view ordinary variable values, you can even type $handles to track the number of open handles, $err to view the function's error code (and then use Tools- > Error to see the description of the error code), or type @ eax (@ rax below 64 bits) to see the register value that contains the function's return value.
6 Annotation disassembly
The use of internal disassembly makes it easier to optimize local code. Visual studio can display assembly instructions under each line of your code, and can debug assembly code step by step, or you can set breakpoints anywhere. Viewing and modifying assembly code is similar to C++.
7 Thread window for stack information
Debugging multithreaded code is painful. Maybe it's interesting, too. It depends on your debugger. One of the great features of Visual studio is to view the thread's stack information in the thread window. You can easily see all threads and their stack information directly.
8 conditional breakpoint
If you want to reproduce a small probability event, but breakpoints can also be triggered under a large number of unwanted conditions. You can easily set conditional breakpoints. When the breakpoint condition is set in the breakpoint window, Visual studio automatically ignores breakpoints that do not meet the criteria.
9 memory window
Some bug is caused by incorrect structural definition, lack of alignment attributes, and so on. Looking at the contents of each line of memory makes it easy to locate and resolve these bug. Visual studio's memory window can translate data into 8/16/32/64-bit numbers or floating-point numbers. You can change the value directly in the editing window.
10 Jump to definition
If you are solving a bug in code written by someone else, you will encounter questions such as "what is this type" and "what does this function do?" you can use the jump to definition command of visual studio to view the definition of the type or function.
11 Command window
This tip, suggested by chaau, can save you a lot of time. Visual studio supports a command window, which you can open from the menu View- > Other Windows- > Command Window. You can enter different commands in the window to automate debugging. For example, you can test the COleDateTime variable of MFC with a very simple command.
At this point, I believe you have a deeper understanding of "what are the Visual Studio debugging skills?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.