Document directory
- 1. Set the symbol Directory: "tool" --> "option" --> "debug" --> "symbol" to add a symbol path. Then click "load all symbols" to automatically load the symbols.
- 2. If you do not want to set the symbol directory, find the module view, right-click the module, and select "load symbol" --> "symbol path" to manually select the correct symbol File
Visual c ++ is a component in Visual Studio. C ++ development in Windows is a preferred tool. This tool is powerful and everyone knows it. Haha
I plan to introduce some common debuggers in Windows:
Visual c ++
Ollydbg
Windbg
Visual c ++, as our development tool, is certainly not inferior to the debugger. What advantages and disadvantages does it have compared with other debuggers?
As a component of Visual C ++, the visual C ++ debugger is very powerful with source code debugging. The global symbol name, local variable name, and struct are displayed.
However, if you do not have a source code or PDB file, Visual C ++ debugging is a painful process. Because its Assembly display does not display more Assembly commands, it is not easy to understand the logic of a function!
So,Visual c ++ is a source code-level debugger.If you do not have the source code of this program, we recommend that you use ollydbg.
How to Use the Visual C ++ debugger? What functions does it provide?
- 1. The VC debugger supports local and remote debugging.
- 2. VC is an application-layer debugger and does not support driver debugging.
- 3. VC has powerful support for symbol files. If there are corresponding symbols, local variables and data structures can be displayed.
- 4. debug multiple processes at a time
- 5. You can debug a single thread (suspend other threads)
- 6. You can view all the thread call stacks.
- 7. switching between code and Assembly commands is convenient
- 8. Flexible breakpoint settings
1. Start debugging
1. Start debugging
There are two ways for VC debugger to debug a program: start debugging and attach debugging
Start debugging is the most commonly used one. After the program is compiled, press F5 to start debugging.
2. Additional debugging
How can I start additional debugging? "Tools" --> "attach to process" (or press Ctrl + Art + p). In the displayed dialog box, select the process to be debugged and click "Attach.
Ii. Set the symbol (PDB file)
If you cannot place a breakpoint in the Code, there are several possibilities:
1. The code is inconsistent with that at compilation. 2. There is no symbolic file. 3. The symbolic file does not match.
In the first case, if you force a breakpoint, the breakpoint may be at an incorrect position, so that it cannot be broken at the reserved position. It is best to find the corresponding source code file at that time, or go to the Assembly view and place a breakpoint in the Assembly.
In the second and third cases, the correct symbol file and path are required.
If there is no symbolic file, we recommend using ollydbg for debugging.
If you have a signed file and know the location, follow these steps,
1. Set the symbol Directory: "tool" --> "option" --> "debug" --> "symbol" to add a symbol path. Then click "load all symbols" to automatically load the symbols. 2. If you do not want to set the symbol directory, find the module view, right-click the module, and select "load symbol" --> "symbol path" to manually select the correct symbol File
Iii. breakpoint
Many breakpoints supported by VC
1. Normal breakpoint: Press F9 directly in the code. Cancel the breakpoint, and then press F9
Sometimes normal breakpoints cannot meet debugging requirements. Let's see what types of breakpoints are supported.
2. Disconnected based on the number of hits
If you only want to hit n times before interruption, you can right-click the breakpoint and choose "hit count ".
3. Print data when an interruption occurs
If you want to print some logs when hit, you can right-click the breakpoint and select "hit condition" Settings
4. Conditional breakpoint
A condition breakpoint is a common breakpoint, for example, it is interrupted when the value of a local variable is equal to or greater. You can right-click a breakpoint and select "condition" settings.
For exampleI = 5 & wsinfo. bnew = true(You can set conditions for fields in a structure)
String condition breakpoint: stricmp (proc32.szexefile, "system") = 0 (if the process name is system, it is interrupted)
VC also supports strcmp, strncmp, and other string comparison functions.
5. Conditional Filtering
If you only want to disconnect a thread, you can use a condition filter. Right-click the breakpoint and choose filter settings.
Iv. debugging window
You can find these windows in the submenu of "debug" --> "window ".
1. module list
Displays information about all modules. Including the module loading address and size, module path, and whether or not symbols are loaded.
2. Thread list
The call stack of each thread can be viewed in the thread list, and individual threads can be suspended (frozen ).
3. Monitor
The monitor can monitor the value of a global or local variable. Of course, the value of the Register can also be monitored.
To view the lasterror error code of the current thread, enter @ err in the monitor.
4. Assembler
We can see the compilation command corresponding to the source code.
5. Memory Viewer
You can view memory data based on an address.
6. Output Window
View log output
7. Call the stack
Call Stack of current thread
8. Automatic window and local variables
Displays the value of the current local or global variable, which is convenient.
9. breakpoint list
All breakpoint Information
10. Register window
Current value of all registers
V. Remote debugging
What should I do if I want to debug a program on a remote computer?
1. Run the remote host (vcmsmon.exe) on the remote machine)
Remote debugging monitor Directory: C: \ Program Files \ Microsoft Visual Studio 10.0 \ common7 \ ide \ remote debugger
(My VC is installed on drive C, and the path is default. The VC version is 2010. May be different from yours)
Select the version. If the target machine is x86, copy all files in the x86 directory to the target machine. If the target machine is IA64, copy the files from the x86 directory to the target machine.
Then, start the vcmsmon.exe process on the target machine. Set the port to the TCP connection mode, and set the port to the default mode. "Tool" --> set in "options"
2. remote start debugging
"Project" --> "property" "configuration property" "debugging"
In theDebugger to be started", Select" Remote Windows Debugger"
"Command", Enter the full path of the remote machine waiting for debugging.
"Working directorySets the working directory of the process.
"Remote Server Name"Enter the IP address of the remote machine.
"LinkSelect "remote access without authentication"
After setting, press F5 to start debugging.
3. Remote additional debugging
"Tools" --> "attach to process" (or press Ctrl + Art + p) in the displayed dialog box
"Transmission", Select"Remote (...)"
"Qualifier"InputRemote machine IP Address
Click "refresh"
Select the process to debug and click "add"
6. Other 1. debugging shortcuts:
F10 step by step
Step-by-Step F11
F5 continue
Shift + F11 jump out
Indicate the source for reprinting. Dianling rhinoceros sunyikuyu <ddlx studio>