What is the. net pdb file?

Source: Internet
Author: User
Tags reflector

PDB is short for "program database" and does not know what the Chinese translation is. I believe that those who have used Vs will not be unfamiliar with the extended name file. This file will mainly store all the symbols inside the corresponding module (DLL or EXE, and the address, file name, and row number corresponding to the symbol.

This file will be used during debugging. It can be understood as an application during debugging.ProgramAnd the source file. It is thanks to this file that we can see the current execution of the program in debug.CodeAnd monitors some variables.

PDBWhen Will files be generated?

The PDB file is generated when we compile the project. It is generated together with the corresponding module (exe or DLL. We may not be aware of the importance of the PDB file, because if we only develop locally, we can always make adjustments. Here I will introduce two concepts: Private build and public build1. Private build refers to compilation on the development machine, and public build refers to compilation on the machine responsible for compilation.

As I mentioned above, private build is generally normal, because all necessary files for debugging on the compiled machine are in this place. Most of the issues that cannot be debugged occur in the case of public build.

If your application needs to be published or sold as a product, you need to pay special attention to saving the PDB files and source files of the released version.Note: you only have one chance to savePDBFile. 2(The reason is described below) <of course, it is acceptable to use a tool similar to reflector for debugging>

Why?PDBSo important?

Maybe you will think that if you get the same copySource codeRecompile a PDB file and use it for debugging. I used to think so until one day .........

The direct cause is that the header of the binary file generated by vs contains the guid of the corresponding PDB, And the PDB also contains a guiid. These two guids are added during compilation. The vs debugger compares the two guids when loading PDB. If they are inconsistent, they cannot be used.

Of course, the above reason is only a superficial phenomenon. The root cause is that the files compiled by the two identical code compilers may be different. The compiler will optimize the code during compilation, and there may be many Optimization Methods for the same code, it selects the fastest generation method based on the environment of the specific machine at that time. So the files generated by it may be different! Therefore, if the generated file is different, the address corresponding to the symbol in the original PDB is meaningless. For details, refer to reference 2.

How to view binary files andPDBOfGuid?

Use the dumpbin tool provided by Vs to view the guid of the PDB expected by the binary file. The basic usage is the dumpbin/header file. For details, refer to msdn.

To view the guid of PDB, you can use the following tool to pull the PDB directly. Http://www.codeproject.com/Articles/37456/How-To-Inspect-the-Content-of-a-Program-Database-P

PDBFile Search Policy

First, the test results can be found from the module serial port of Visual Studio during debugging. The result is as follows:

 

1. address where the file is executed or loaded

2. It is the address of the hard-coded PE file header. As you can see, OBJ \ <config> is the original generated address, but is copied to the first address.

2.5 If the symbol server is configured, you should first find it in the cache directory of the symbol server after Step 2. If not, go to the symbol server. If it is found, it will be downloaded to the cache directory.

3. The third part is the directory for symbol query set in vs. Because I installed reflector, these directories are added to my settings by default.

4. Windows folder.

An interesting phenomenon is that the vs search policy first finds the symbol \ exe \ project under the directory. PDB, then exe \ project. PDB. PDB. This order is somewhat surprising.

PDBWill files affect performance?

Some may think that the generation of the PDB file will have a certain impact on the performance of the final application, so they do not think that the PDB file should be generated in the release version.

Error! For. NET applications, generating PDB files does not affect Compiler optimization, so it does not affect application performance. It will only affect the attribute of one debuggableattribute in the generated assembly. If you are interested, can you read do PDB files affect performance?

Summary

Microsoft has not published PDB internal details, but only published some APIs, so this file has always been a fan. This article only writes some things I learned and I think. Net programmers need to know. If something is wrong, I hope to point out that it will be added if you have a deeper understanding in the future.

This article references some of the links. If you are interested, you can take a look.

 

Reference:

1. John Robbins,PDB files: What every developer must know

2. greazer,Why does Visual Studio require debugger symbol files to * exactly * match the binary files that they were built?

3. Summary of Xuan soul and PDB

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.