In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to use windbg debugging and analyzing dump files to solve Unity problems. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
Terminology, acronym
Windbg
Windows platform, powerful user mode and kernel mode debugging tools.
Dmp
Memory image files, usually files generated by system errors.
Pdb
Program database file.
Symbol
A symbol file (Symbol Files) is a data information file that contains debugging information for application binaries (such as EXE, DLL, etc.)
Overview
Windbg is a powerful tool under the Windows platform. Compared with Visual Studio, it is a lightweight debugging tool, the so-called lightweight means that its installation file size is small, but its debugging capabilities are more powerful than VS. Another use is that it can be used to analyze dump data and debug process deadlocks. Debugging function, similar to Visual Studio, also supports command mode. This document only applies to VC++, while C# requires some additional configuration, with roughly the same principle.
Windbg is just a tool. We should master its basic usage and debug commands, and constantly improve our debugging means in practice. At the same time, you can refer to the literature of masters, "efficient debugging of Windows user-mode programs", "Windows Advanced debugging", "Software debugging"
download
Windbg is widely used, there are many downloaded versions on the Internet, and there are many documents, which can be downloaded from CSDN or other websites to support green packages to run.
Configuration
Windbg needs to be configured before use.
1.1 Environmental variables
1. Add environment variable: _ NT_SYMBOL_PATH
2. The value of environmental variable:
C:\ MyCodesSymbols;SRV*C:\ MyLocalSymbols* http://msdl.microsoft.com/download/symbols
Environment variable configuration
3, according to the value of environment variables, create a new folder under C disk: MyCodesSymbols,MyLocalSymbols these two folders mainly store windows symbol files, that is, some pdb files by default, which are not included in the system and need to be configured to link. When debugging for the first time, windbg downloads the missing symbol files by default.
Windbg tool configuration
Symbol configuration Symbol File Path
C:\ MyCodesSymbols;SRV*C:\ MyLocalSymbols* http://msdl.microsoft.com/download/symbols
Symbol configuration
Source code path configuration Source File Path
The tool will not intelligently locate the corresponding source code, so configure the path of your source project to be the path of the project file (for example, a file in this format: * .vcxproj).
Compiler configuration
Support Visual Studio compilers above VC6 and set related properties
Generate program database files
Use
After the tool is configured before use, you are ready to work. Here are the steps to bind the process for debugging.
Binding process
Note that the process needs to be started before binding, because the Attach to Process window does not refresh the process in real time like the task manager. Select the process name and click Ok to confirm.
Binding process
Debug
After binding the process, you can enter the g command in the command window, and then enter. Or use the shortcut key F5. You can run the process in debugging. Note: you need the pdb file, along with exe or dll, or put the pdb file in the C:\ MyCodesSymbols directory as mentioned above. Because the debugging information is based on the pdb file timestamp to locate the history file, it is best to back up the code and files after the release. Otherwise, if the version is sent out, the native source code is compiled, the pdb is different, and the source code is modified, then the captured * .dmp memory image cannot be debugged accurately.
After the program is bound by windbg, F5 runs and can now operate the software normally. When there is an exception in the software, the command window will print the relevant exception command.
Debug
Enter the lowercase k command to print the stack. The left window is also the corresponding source code, debugging like vs.
Debug Toolbar
For example, the local variable data display window: Locals
Command
In addition to basic visual debugging, windbg supports commands for other kernel debugging, which can be used according to actual needs. Here are some common commands:
1. View version information: version, vertarget.
2. View module information: lm,! dlls,! lmvi, etc.
3. Call stack: display the call stack with the k command and switch the stack frame with the .calls command.
4. Memory operation: read memory with d command and write memory with e command.
5. Automatic analysis:! analyze,! owner, etc.
6. Symbol commands: .reload loads symbols, .sympath sets symbol paths, and! sym sets symbol options.
7, process thread:! process displays process information; .process displays the current process, or uses .process / I to switch the current process;! peb displays the contents of the process environment block; ~ the command displays the list of threads, using ~ n s to switch the current thread, n represents the thread number; .thread displays the current thread.
Analyze dmp files
Windbg is a powerful tool for debugging, which can bind a process for debugging, and can also debug the process's memory image * .dmp file, usually the dmp file generated by the system after the process crash, or the dmp file generated by the code generated by the program try catch. Analyze the dmp file, also roughly the above steps, but the above is the binding file, this is to open the dmp file.
Expansion
Bind the process, debug dmp files, of course, in addition to windbg, you can also directly use the vs compiler, this is the best thing, but the vs compiler is too large, not as small and convenient as windbg.
After reading the above, do you have any further understanding of how to use windbg debugging and analyzing dump files to solve Unity problems? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.