I am used to the convenient debugging environment of VC ++, especially VS 2005 debugger. In VS 2005, you can easily view variable values, dynamically modify memory values, stack frameworks, and various memory Viewing Windows. It is more convenient to show the address of the variable and the variable value when you move the mouse to the variable. When the variable is a struct or class, you can easily view it. The automatic expansion of struct allows us to quickly understand the structure of the target variable.
I usually debug F5 every time I write a function or module, and check whether the process variables are the same as I expected. Through debugging, you can:
(1) You can quickly find out where the program went wrong.
(2) What are the errors?
(3) Dynamic Tracking of program execution helps to check whether our logic thinking before writing code is correct and whether the program process is reasonable.
(4) Through the stack call framework, you can determine which function module has an error.
(5) More importantly, debugging allows us to further understand the nature of the program and avoid inexplicable errors.
(6) debugging is an effective way to learn assembly languages.
(7) We have established a memory layout model for this language. This helps us understand how the memory is occupied and the stack situation when the program is running. in this way, we can clear the root cause of the error and quickly provide a solution, instead, some programmers have corrected the errors and do not know why they have changed several code programs everywhere to run OK.
Remember to write a project called vc dll by Delphi and forget the project. After Delphi calls the DLL provided by VC, the DLL export function is normal during execution, but an error occurs when the function exits. (now, this 99.99% is caused by different call Convention call conventions ). but at that time, the people in Delphi did not find out why the error occurred for an hour. I started to make an error with them. Under the same guidance, I started to open the Delphi debugger to dynamically track the program process. The first time I read the compilation code of Delphi, it was a little headache (originally $ is used for 0x of C/C ++, indicating that it is in hexadecimal format). I used OD (ollydbg) debugging. Fortunately, OD can be debugged at the source code level, and the type of assembly code can be specified. I used od to track the execution process of the program and found an error in the returned address after the function returns, functions in vc dll stack the parameters by themselves, but Delphi's assembly code re-stacks the parameters. No wonder an address error is returned. later, I posted the problem and related solutions to the Internet. the entire solution takes 10 minutes.
Sometimes I am lazy and don't think about it carefully before writing the code. I often say to my new graduate students: even if the code won't be written, I will be blinded. In any case, the most basic skill of a C/C ++ programmer is to use the debugger skillfully. Now I will show them how to use the debugger, including the system-level debugger windbg and syser debuger. SoftICE has already withdrawn from the stage of history. It just tells them about the brilliant history of SoftICE, which used to be a great deterrent.
When developing a driver, the debugger is even more essential. If you are not familiar with the debugger, advise you to study VB.
Using the debugger is not a simple task. At least you must be familiar with the following points:
(1) understand what a stack is and what it is used when the program is running.
(2) clearly understand the cpu structure and what registers are
(3) be familiar with the assembly language and be afraid not to see the assembly code.
(4) Understand how code in advanced languages is executed on the CPU
(5) understand the implementation principles and methods of the debugger to cope with problems with the debugging tool itself. It is more often used as a debugger.
(6) clearly understand the binary code structure of executable files, so that we can take reverse and cracking as the most interesting leisure and entertainment activities.
I believe that the above points are not very difficult. Even if it is very difficult, what if others are people and you are also people? Isn't it true that he will not, it's really cool !!
Many people say they are masters, and you dare to say that you don't even know assembly languages !! Shame !! If you don't understand compilation, don't say that you are learning C/C ++, let alone underlying development, because fellow developers cannot join you.