VS2013 uses PDB and dump files to locate problems and debug them

Posted by janggu on Wed, 05 Jan 2022 02:23:42 +0100

VC + + uses PDB and dump files to locate problems and debug them
	<div class="clear"></div>
	<div class="postBody">
		<div id="cnblogs_post_body" class="blogpost-body blogpost-body-html">

Reprint: https://blog.csdn.net/zfs_kuai/article/details/43646665

Reprint: https://blog.csdn.net/i_chaoren/article/details/81453142

1, What is a PDB file

       1. PDB file is the abbreviation of "Program Data Base", which contains the code information of the program

       2. Through this file, we can view the location of the corresponding power failure, stack information, etc

       3. Using PDB enables us to grasp the stack running state of the program without code

2, PDB file

       1. Automatically generated by linker

       2. The file consists of two parts, private symbol data and public symbol data

Private Symbol Data


Global variable

Local variable

User defined structure, class, data type

The name of the source file and the line number of each binary instruction in the source file

Public symbol table

Static variable

Global variable (external)
3, How to get PDB file

After the program is compiled, *. Will be generated in the Debug or Release directory pdb file

4, What is a dump file

Dump file is short for the storage file with stack information attached. The file extension is ". dmp". Through dump file, we can get the stack data at a certain time when the program is running.

When our program crashes unexpectedly, the program is usually interrupted immediately. At this time, we generate the dump file at this time, and we can analyze the stack at this time to find the crashed code and analyze the cause.

When a program meets an unhandled exception (mainly a non pointer), it causes the program to crash. If an SetUnhandledExceptionFilter() function is called before an exception occurs, the exception is assigned to the function processing.

Described in MSDN as:

  Issuing SetUnhandledExceptionFilter replaces the existing top-level exception filter for all existing and all future threads in the calling process.

Therefore, the required functions can be realized by adding the setunhandledexception filter() function at the beginning of the program and generating the Dump file in the function with an appropriate method.

The dump file is a memory image of the process. The execution state of the program can be saved to the dump file through the debugger.

5, Matching of EXE, DLL, etc. with pdb files

How does the debugger determine whether EXE, DLL, etc. match a pdb file?

Every time we link EXE or DLL or SYS, the linker will generate a unique GUID and write it to PDB and executable files. When the debugger loads, it will check the guids of the two. If they are consistent, it means they match.

Note: if we need debugging and we need to check the dmp file, please keep your code and pdb properly. Each time you recompile, even if all the code does not change, their guids are different.

6, The process by which a compiler generates symbols

If you specify to generate debugging information, the compiler will generate an obj file after compiling the file each time, and then generate its corresponding debugging information at the same time. When we connect, the compiler will help us compile all obj into an executable file, and then all debugging information will generate a PDB file.

7, pdb file generated by Release program

Debug the Release program with VS and find that it cannot be debugged. In fact, it is not that the released program cannot be debugged, but that the released program does not generate a pdb file. VS cannot load the pdb file and cannot debug the program.

Just set it up and let the Release program generate pdb files.


8, Local dump debugging

Directly open test with VS dmp file. During the test, the dmp file is generated locally, so VS will find the path of exe, pdb and source code according to the dmp file. Therefore, if you click debug directly, the program will make an error and the code line will be interrupted



10, Passive code dump debugging

However, if the dmp file is generated by exe on another machine, we'd better put exe, pdb and dmp in the same folder. We must ensure that the pdb is generated at the same time as the EXE in question. After opening the dmp file with VS, we also need to set the symbol table file path and source code path.

(1) when the pdb file and the dmp file are placed in the same directory, the path does not need to be set, otherwise it needs to be set

Tools - > Options - > debugging - > symbols:



(2) you also need to set the source code path:

Properties - > debug source code:


In this way, click "use native only for debugging" to interrupt in the error code line:

WinDbg debugging

The basic idea is consistent with VS. winDbg will provide more comprehensive debugging information

(1) set pdb path: File - > symbol file path

(2) set exe path: File - > image file path

(3) set source code path: File - > source file path (refers to the directory where sln is located)

(4) open dmp file: File - > Open crash dump

(5) execute the command! analyze –v  

Detailed anomaly analysis can be obtained


Classification: VC++
<div id="blog_post_info">
+Pay more attention
<div class="clear"></div>
<div id="post_next_prev">

<a href="https://www.cnblogs. com/chechen/p/10070018. html" class="p_ n_ p_ Prefix "> previous article: < a href =" " https://www.cnblogs.com/chechen/p/10070018.html "Title =" published at 11:41, December 5, 2018 "> MFC limits the character input length of edit control</a>
<a href="https://www.cnblogs. com/chechen/p/10077141. html" class="p_ n_ p_ Prefix "> » < / a > next: < a href =" " https://www.cnblogs.com/chechen/p/10077141.html "Title =" published on December 6, 2018 15:53 "> detect C + + memory leak</a>
posted @ 2018-12-05 17:26  Chechnya Read( 4162) comments( 0)  edit  Collect report

Refresh page Back to top
You can't view or comment until you're signed in. Now perhaps Stroll around Blog Garden Home Page
Edit recommendation:

· Dapper in .Net Core

· use. NET 6 to develop TodoList application (14) -- realize query filtering

· Architecture and Thinking: idempotent solution under high concurrency

· CSS to achieve smoke effect

· Online high concurrency application reconstruction (writing) pit filling experience sharing (I)

Latest news:
· Inspired by slugs, scientists have developed biomaterials that can accelerate the repair of damaged tendons
· Edge Chrome: password manager introduces the function of adding passwords manually
· How does Xiaopeng P5 redefine "smart sedan"? Multidimensional comparative evaluation
· Google and others exposed the "AI task difficulty": there are limited benchmarks such as ImageNet, just like museums that cannot represent the "whole world"
· 144 orbital launches and 133 successful launches, creating a new record for rocket entry in 2021
» More news

LoadPostCategoriesTags(cb_blogId, cb_entryId); LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid);
GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate, cb_postType);
GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate);

</div><!--end: forFlow -->
</div><!--end: topicList Article list container-->

<div id="sideBar">
	<div id="sideBarMain">
		<div id="sidebar_news" class="newsItem"><!--done-->


<div id="profile_block">
    <a href="https://home.cnblogs.com/u/chechen/">
    Garden age:
    <a href="https://home. cnblogs. COM / U / Chen / "title =" admission time: July 28, 2013 ">
        8 5 months a year
    <a href="https://home.cnblogs.com/u/chechen/followers/">
    <a href="https://home.cnblogs.com/u/chechen/followees/">
    <div id="p_b_follow">

+Pay more attention

< January 2022 >
262728293031 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
		<div id="leftcontentcontainer">
			<div id="blog-sidecolumn"><!-- search -->



Common links

    Topics: C++ p2p GNU