pdb 源码服务器创建过程

pdb是调试程序必不可少的东西,它保存着一个exe或dll的调试信息,对pdb进行源码索引可以快速找到软件对应该版本的代码,本文以subversion版本控制服务器进行介绍

一、需要安装的软件

  1. windbg,在ddk安装包中可找到
  2. TortoiseSVN,安装时要选上命令行工具
  3. ActivePerl

  三个工具安装完成后要把windbg;windbg\srcsrv;TortoiseSVN\bin;Prel\bin加入到环境变量中

 

二、编译工程,索引PDB文件

  以KFileRecovery工程为例,编译后生成exe和PDB

  

  执行svnindex命令进行源码索引,执行命令前切保所的修改的代码已提交到svn

  svnindex /source="E:\work\c++\tu\KFileRecovery" /symbols="E:\work\c++\tu\KFileRecovery\bin" /debug

  source:表示源工程路径,可以有多个,用分号分隔

  symbols:表示pdb文件所在的路径,可以有多个,用分号分隔。svnindex会查找子目录下的pdb

  debug:表示输出调试信息

  

  svnindex.cmd调用ssindex.cmd完成操作,ssindex.cmd使用Perl脚本,脚本中调用了windbg的srctool和pdbstr完成pdb文件索引,流程如下:

  调用srctool -r $pdbfile,获取pdb文件中的把有源文件,处理每个文件,获取svn路径和修订版本号,写入.stream临时文件中,最后调用pdbstr把.stream写入pdb文件中

  

  如:pdbstr -w -p:KFileRecovery -s:srcsrv -i:"C:\Users\tuxingkai\AppData\Local\Temp\index11780.stream"

    注:-s选项一定要是srcsrv,不然调试器不认

  下面来看一下ssindex.cmd生成的.stream文件格式

  

SRCSRV: ini ------------------------------------------------
VERSION=1
INDEXVERSION=2
VERCTRL=Subversion
DATETIME=Sat Mar  1 00:49:12 2014
SRCSRV: variables ------------------------------------------
SVN_EXTRACT_TARGET=%targ%\%fnbksl%(%var3%)\%var4%\%fnfile%(%var1%)   //%targ%:索引时pdb文件路径,%fnbksl%表示转换‘/‘为‘\‘,%fnfile%表示取路径中的文件名,%varn%表示下面souce files的各个字段,以*分隔
SVN_EXTRACT_CMD=cmd /c svn.exe cat "%var2%%var3%@%var4%" --non-interactive > "%svn_extract_target%"
SRCSRVTRG=%SVN_extract_target%
SRCSRVCMD=%SVN_extract_cmd%
SRCSRV: source files ---------------------------------------
e:\work\c++\tu\kfilerecovery\disklib\pubfun.cpp*https://tuxingkai-pc/*svn/tu/KFileRecovery/DiskLib/PubFun.cpp*3
e:\work\c++\tu\kfilerecovery\disklib\pubfun.h*https://tuxingkai-pc/*svn/tu/KFileRecovery/DiskLib/PubFun.h*3
e:\work\c++\tu\kfilerecovery\stdafx.h*https://tuxingkai-pc/*svn/tu/KFileRecovery/stdafx.h*3
e:\work\c++\tu\kfilerecovery\disklib\kdiskenum.cpp*https://tuxingkai-pc/*svn/tu/KFileRecovery/DiskLib/KDiskEnum.cpp*3
e:\work\c++\tu\kfilerecovery\disklib\kdiskenum.h*https://tuxingkai-pc/*svn/tu/KFileRecovery/DiskLib/KDiskEnum.h*3
e:\work\c++\tu\kfilerecovery\disklib\kdisk.h*https://tuxingkai-pc/*svn/tu/KFileRecovery/DiskLib/KDisk.h*3
e:\work\c++\tu\kfilerecovery\disklib\kdisk.cpp*https://tuxingkai-pc/*svn/tu/KFileRecovery/DiskLib/KDisk.cpp*3
e:\work\c++\tu\kfilerecovery\disklib\kdiskdef.h*https://tuxingkai-pc/*svn/tu/KFileRecovery/DiskLib/KDiskDef.h*3
e:\work\c++\tu\kfilerecovery\stdafx.cpp*https://tuxingkai-pc/*svn/tu/KFileRecovery/stdafx.cpp*3
e:\work\c++\tu\kfilerecovery\selectpartitiondlg.cpp*https://tuxingkai-pc/*svn/tu/KFileRecovery/SelectPartitionDlg.cpp*3
e:\work\c++\tu\kfilerecovery\resource.h*https://tuxingkai-pc/*svn/tu/KFileRecovery/resource.h*3
e:\work\c++\tu\kfilerecovery\selectpartitiondlg.h*https://tuxingkai-pc/*svn/tu/KFileRecovery/SelectPartitionDlg.h*3
e:\work\c++\tu\kfilerecovery\kfilerecoveryview.h*https://tuxingkai-pc/*svn/tu/KFileRecovery/KFileRecoveryView.h*3
e:\work\c++\tu\kfilerecovery\mainfrm.cpp*https://tuxingkai-pc/*svn/tu/KFileRecovery/MainFrm.cpp*3
e:\work\c++\tu\kfilerecovery\aboutdlg.h*https://tuxingkai-pc/*svn/tu/KFileRecovery/AboutDlg.h*3
e:\work\c++\tu\kfilerecovery\mainfrm.h*https://tuxingkai-pc/*svn/tu/KFileRecovery/MainFrm.h*3
e:\work\c++\tu\kfilerecovery\childfrm.h*https://tuxingkai-pc/*svn/tu/KFileRecovery/ChildFrm.h*3
e:\work\c++\tu\kfilerecovery\kfilerecoveryview.cpp*https://tuxingkai-pc/*svn/tu/KFileRecovery/KFileRecoveryView.cpp*3
e:\work\c++\tu\kfilerecovery\kfilerecovery.cpp*https://tuxingkai-pc/*svn/tu/KFileRecovery/KFileRecovery.cpp*3
e:\work\c++\tu\kfilerecovery\childfrm.cpp*https://tuxingkai-pc/*svn/tu/KFileRecovery/ChildFrm.cpp*3
e:\work\c++\tu\kfilerecovery\aboutdlg.cpp*https://tuxingkai-pc/*svn/tu/KFileRecovery/AboutDlg.cpp*3
SRCSRV: end ------------------------------------------------

  SVN_EXTRACT_TARGET和SVN_EXTRACT_CMD是环境变量,供下面的SRCSRVTRG、SRCSRVCMD选项使用

  SRCSRVTRG: 执行srctool -x从pdb源码服务器下载文件时,下载到这个目录下

  SRCSRVCMD: 执行srctool -x从pdb源码服务器下载文件时,对于每个源码文件要执行的命令及命令行参数

三、查看索引后的pdb文件信息

  srctool KFileRecovery.pdb

  

  看到上面信息,表示索引成功

四、将pdb文件加入到符号服务器

  待续。。。

  

pdb 源码服务器创建过程,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。