说说Debug文件夹下的.pdb文件
.PDB文件,全称为“程序数据库”文件。我们使用它(更确切的说是看到它被应用)大多数场景是调试应用程序。目前我们对.PDB文件的普遍认知是它存储了被编译文件的调试信息,作为符号文件存在。那么,它具体包含哪些内容呢?在调试过程中是怎样发挥作用的呢?我们有没有办法去操作这个文件呢?
1、PDB文件内容
一个非托管C++程序的PDB文件包含如下信息:
- l Public, private,和static函数地址
- l 全局变量的名称和地址
- l 参数和局部变量的名称及它们在栈中的偏移量
- l 类型定义,包括class, structure,和 data definitions
- l FPO(Frame Pointer Omission,帧指针省略)数据
- l 源文件名称和行号
说明:从XP SP2起就不再启用FPO。对于.NET PDB文件,只包含上面说到的两种信息:
- l 源文件名称和行号
- l 局部变量名称
.NET PDB文件包含如此少的信息,原因在于其他信息我们可以从元数据中获取,所以也就没有必要重复存储了。
2、PDB文件匹配
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace dumptest{class Program{static void Main(string[] args){}}}
编译上面的代码,obj目录中的文件如图2所示。
E:\test\c#\dumptest\dumptest\obj\x86\Debug>dumpbin /headers dumptest.exeMicrosoft (R) COFF/PE Dumper Version 10.00.30319.01Copyright (C) Microsoft Corporation. All rights reserved.Dump of file dumptest.exePE signature foundFile Type: EXECUTABLE IMAGEFILE HEADER VALUES14C machine (x86)3 number of sections4E92A178 time date stamp Mon Oct 10 15:40:40 20110 file pointer to symbol table0 number of symbolsE0 size of optional header102 characteristicsExecutable32 bit word machineOPTIONAL HEADER VALUES10B magic # (PE32)8.00 linker version800 size of code800 size of initialized data0 size of uninitialized data272E entry point (0040272E)2000 base of code4000 base of data400000 image base (00400000 to 00407FFF)2000 section alignment200 file alignment4.00 operating system version0.00 image version4.00 subsystem version0 Win32 version8000 size of image200 size of headers0 checksum3 subsystem (Windows CUI)8540 DLL characteristicsDynamic baseNX compatibleNo structured exception handlerTerminal Server Aware100000 size of stack reserve1000 size of stack commit100000 size of heap reserve1000 size of heap commit0 loader flags10 number of directories0 [0] RVA [size] of Export Directory26D4 [57] RVA [size] of Import Directory4000 [588] RVA [size] of Resource Directory0 [0] RVA [size] of Exception Directory0 [0] RVA [size] of Certificates Directory6000 [C] RVA [size] of Base Relocation Directory2668 [1C] RVA [size] of Debug Directory0 [0] RVA [size] of Architecture Directory0 [0] RVA [size] of Global Pointer Directory0 [0] RVA [size] of Thread Storage Directory0 [0] RVA [size] of Load Configuration Directory0 [0] RVA [size] of Bound Import Directory2000 [8] RVA [size] of Import Address Table Directory0 [0] RVA [size] of Delay Import Directory2008 [48] RVA [size] of COM Descriptor Directory0 [0] RVA [size] of Reserved DirectorySECTION HEADER #1.text name734 virtual size2000 virtual address (00402000 to 00402733)800 size of raw data200 file pointer to raw data (00000200 to 000009FF)0 file pointer to relocation table0 file pointer to line numbers0 number of relocations0 number of line numbers60000020 flagsCodeExecute Read<strong>Debug DirectoriesTime Type Size RVA Pointer-------- ------ -------- -------- --------4E92A178 cv 50 00002684 884 Format: RSDS, {99F34C5E-5BC3-4043-AE11-D85F7990AF00}, 1, E:\test\c#\dumptest\dumptest\obj\x86\Debug\dumptest.pdb
</strong>
SECTION HEADER #2.rsrc name588 virtual size4000 virtual address (00404000 to 00404587)600 size of raw dataA00 file pointer to raw data (00000A00 to 00000FFF)0 file pointer to relocation table0 file pointer to line numbers0 number of relocations0 number of line numbers40000040 flagsInitialized DataRead OnlySECTION HEADER #3.reloc nameC virtual size6000 virtual address (00406000 to 0040600B)200 size of raw data1000 file pointer to raw data (00001000 to 000011FF)0 file pointer to relocation table0 file pointer to line numbers0 number of relocations0 number of line numbers42000040 flagsInitialized DataDiscardableRead OnlySummary2000 .reloc2000 .rsrc2000 .text
现在我们将目光集中在代码清单2中斜体加粗的部分,这里我们可以找到调试路径的信息,一个GUID值(99F34C5E-5BC3-4043-AE11-D85F7990AF00)和一个路径(E:\test\c#\dumptest\dumptest\obj\x86\Debug\dumptest.pdb)。现在我们已经清楚了调试器如何判断PDB文件是否匹配,下面我们再来看调试器是如何寻找PDB文件的。
3、PDB文件寻路
4、PDB与GAC
Private Build与Public Build的区别
private build, 用来表示在开发人员自己机器上生成的build;public build,表示在公用的build机器上生成的build。对于public build,需要symbol server存储所有的PDB,然后当用户报告错误的时候,debugger才可以自动地找到binay相应的PDB文件, visual studio 和 windbg都知道如何访问symbol server。在将PDB和binay存储到symbol server前,还需要对PDB运行进行source indexing, source indexing的作用是将PDB和source关联起来。
第一种方案是我们在GAC的目录中找到被安装的程序集,然后将PDB文件拷贝到该目录下。通常我们安装到GAC中的程序集会存在于类似这样的路径中:C:Windows\assembly\GAC_MSIL\Example\1.0.0.0__682bc775ff82796a,该示例目录中“Example”代表程序集的名称,“1.0.0.0”代表版本号,“682bc775ff82796a”代表程序集的Public Token。当你找到确切的目录,将PDB文件放到该目录下,调试器就可以加载符号文件了。
<configuration>
<runtime>
<developmentMode developerInstallation="true"/>
</runtime>
</configuration>
在你打开了development模式后,如果DEVPATH没有定义或路径不存在的话会导致程序启动时异常"Invalid value for registry"。而且如果在machine.config中开启DEVPATH的使用会影响其他的所有的程序,所以要慎重使用machine.config。
5、PDB与源文件
说明:
subst用于路径替换 ,将路径与驱动器号关联,就是把一个目录当作一个磁盘驱动器来看,不过不能格式化。运用一定技巧,subst命令还可以实现隐藏驱动器、特殊软件的安装、模拟光盘自动运行等功能。
用法格式
一、subst [盘符] [路径] 将指定的路径替代盘符,该路径将作为驱动器使用
二、subst /d 解除替代
三、不加任何参数键入 SUBST,可以显示当前虚拟驱动器的清单。
[例子]
C:\DOS>subst a: c:\temp 将c:\temp虚拟化成a盘
C:\>subst a: /d? 解除替代
想到解决上面问题的方法了吗?我们只需将本机源码的路径虚拟化成一个磁盘,例如M,之后无论你将代码部署到任何机器上,只需将被部署的路径虚拟成M就可以了,就不会出现符号文件和目标代码不匹配的情况了。
转载于:https://www.cnblogs.com/ice-/p/6165788.html
说说Debug文件夹下的.pdb文件相关推荐
- c语言 遍历文件夹中所有文件名,C# 遍历文件夹下所有子文件夹中的文件,得到文件名...
假设a文件夹在F盘下,代码如下.将文件名输出到一个ListBox中 using System.Data; using System.Drawing; using System.Linq; using ...
- C#遍历得到指定文件夹下的所有文件和子文件夹
1.遍历指定文件夹下的所有文件 string path = Application.StartupPath + "\\data\\采集数据\\"; DirectoryInfo ro ...
- 删除某个文件夹下的所有文件
//删除本地文件夹下保存的文件 NSFileManager *fileManager = [NSFileManager defaultManager]; NSS ...
- python下载文件到指定文件夹-python实现指定文件夹下的指定文件移动到指定位置...
# coding:utf-8 import os import shutil import sys reload(sys) sys.setdefaultencoding('utf8') # print ...
- 怎么查看linux文件夹下有多少个文件(mac同样)
查看目录下有多少个文件及文件夹,在终端输入 ls | wc -w 查看目录下有多少个文件,在终端输入 ls | wc -c 查看文件夹下有多少个文件,多少个子目录,在终端输入 ls -l |wc -l ...
- BAT 批处理命令 - 实现输出当前文件夹下的所有文件夹名的功能实例演示
如下功能为输出当前文件夹下的所有文件夹名并用逗号连接. 需要把 bat 文件放到指定文件夹下执行即可. @echo off for /D %%i in (*) do set /p=%%i,<nu ...
- python遍历指定文件夹的所有文件_python 统计指定文件夹下所有的文件数量,BFS方式...
python 统计指定文件夹下所有的文件数量 本来一直是有这个需求,只是以前写的是递归的方式处理,感觉对资源的占用不友好,而且python的最大递归深度不超过1000,所以改了一下,这里用广度优先遍历 ...
- java 读文件夹_java怎么读取读取文件夹下的所有文件夹和文件?
下是实现的代码:package com.borland.samples.welcome; import java.io.FileNotFoundException; import java.io.IO ...
- python批量生成文件夹_python实现批量获取指定文件夹下的所有文件的厂
本文实例讲述了python实现批量获取指定文件夹下的所有文件的厂商信息的方法.分享给大家供大家参考.具体如下: 功能代码如下: import os, string, shutil,re import ...
最新文章
- python 博弈论 库_SHAP:Python的可解释机器学习库
- 你的项目应该如何正确分层?
- (转载)不断进阶:从“学渣”到P10,一位阿里工程师的逆袭故事
- mysql 更改 uf_SQL经典实例(四)插入、更新和删除
- JavaScript中变量提升是什么?如何实现?
- 昂贵的聘礼 Dijkstra法
- “3+3”看华为云FusionInsight如何引领“数据新基建”持续发展
- 64位win7/win8/win10系统注册32位控件(.OCX)
- 用计算机里可以加50度电,一台电脑一天用多少度电 节电节能的建议和措施
- python网络图可视化_蜘蛛网图实现Python可视化的方法
- 【工作周报】2019年7月 前端开发工作周报汇总
- 音频总线之I2S总线介绍及相关协议
- Http协议/JSON格式
- 子网掩码最简单通俗的解释
- 您觉得目前网页最小字体应该多大呢?
- 腾讯云--添加二级域名
- pick out.php,pick_out.php
- Python前世今生
- c++ 数组置0_鸣小亮C语言笔记(5)——数组
- JavaScript学习之路(WebAPIs阶段)