What file is pdb?

青灯夜游
Release: 2022-04-08 14:48:11
Original
36758 people have browsed it

pdb refers to the "program database" file, which is a file generated when VS is compiled and linked. The DPB file mainly stores the basic information required by VS when debugging the program, including source file name, variable name, function name, FPO, corresponding line number, etc. The PDB file is generated when compiling the project, and it is generated together with the corresponding module.

What file is pdb?

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

PDB (Program DataBase), the full name is "Program Database" file, which is a file generated when VS is compiled and linked. The DPB file mainly stores the basic information required by VS when debugging the program, including source file name, variable name, function name, FPO (frame pointer), corresponding line number, etc. Because debugging information is stored, PDB files are generally generated in Debug mode.

The PDB file records relevant information about the source file path, so when loading the PDB file, the relevant debugging information can be matched with the source code. This allows you to visually view function calls, variable values ​​and other related information during debugging in real time. The PDB file recorded in the module is an absolute path. So as long as the module is loaded on the current computer, the debugger will naturally find the corresponding PDB file based on the path information in the module and load it. Similarly, the source file path recorded in the PDB file is also an absolute path, so as long as the PDB file is loaded on the current computer and debugged into the corresponding module, it can match the recorded source file, and then visually view the corresponding information.

When is the PDB file generated?

The PDB file is generated when we compile the project. It is generated together with the corresponding module (exe or dll). We generally may not realize the importance of PDB files, because if we only develop locally, we can always make adjustments. Here I want to 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 said above, there is generally no problem with Private Build, because all the necessary files for debugging on the compiled machine are where they should be. Most of the problems 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 file and source files of the version you publish. Note: You only have one chance to save the published PDB file. If you lose it, you will not be able to retrieve it. 2 (The reasons are explained below)

Why is PDB so important?

Maybe you will think that if you use Just recompile a PDB file with the exact same source code and then use it for debugging. I used to think so, until one day...

The direct reason is that the Header part of the binary file generated by VS contains the GUID of its corresponding PDB, and the PDB also contains A GUIID. These two GUIDs are added during compilation. The VS debugger will compare the two GUIDs when loading the PDB. If they are inconsistent, they cannot be used.

Of course, the above reason is just a superficial phenomenon. The fundamental reason is that the files compiled by the compiler may be different from two identical codes. Because the compiler will optimize the code when compiling, and the same code may have many optimization methods, it will choose the fastest generation method based on the specific machine environment at the time. So the files it generates may be different! So if even the generated files are different, then the addresses corresponding to the symbols in the original PDB will be meaningless.

How to view the GUID of binary files and PDB?

Use the DUMPBIN tool that comes with VS to view the GUID of the PDB expected by the binary file. The basic usage is the DUMPBIN /HEADER file. For specific usage, please refer to MSDN (http://msdn.microsoft.com/zh-cn/library/c1h23y6c(v=vs.80).aspx).

To view the GUID of the PDB, you can use the following tool to directly pull the PDB in.

http://www.codeproject.com/Articles/37456/How-To-Inspect-the-Content-of-a-Program-Database-P

Search strategy for PDB files

First show the test results, and then you can find the search strategy for the symbol of a module from the Module serial port of Visual Studio during debugging. From the screenshot, we can see the results as follows:

What file is pdb?

1. The address where the file is executed or loaded

2. It is hard-coded in the PE file the address in the header. You can see that obj\ is the original generated address, but it was copied to the first address later.

2.5 If the symbol server is configured, after the second step, you should first search in the cache directory of the symbol server. If you cannot find it, go to the symbol server to search. If found, it will be downloaded to the cache directory.

3. The third part is the directories for some symbol queries set in my VS. Because I have installed Reflector, these directories are added to my settings by default.

4. Windows folder.

An interesting phenomenon here is that the search strategy of VS will first find symbol\exe\project.pdb in a directory, then exe\project.pdb, and finally project.pdb. This order is somewhat surprising.

Will PDB files affect performance?

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

wrong! For .NET applications, generating PDB files will not affect the compiler's optimization, so it will not affect the performance of the application at all. It will only affect one DebuggableAttribute attribute in the generated assembly. Those who are interested can read Do PDB Files Affect Performance?

Related video tutorial recommendations: "ASP.NET Tutorial"

The above is the detailed content of What file is pdb?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!