윈도우에서 Visual Studio로 프로그램을 디버깅할 때, pdb 파일이 실행 파일과 일치하지 않으면 Visual Studio가 “기호 파일을 로드할 수 없음"이라는 메시지를 표시합니다. 프로그램이 충돌하고 덤프 파일이 생성되면, 일치하지 않는 pdb 파일 때문에 Visual Studio는 충돌 현장에 원활하게 진입하지 못합니다.
pdb 파일이 뭐죠?
PDB 파일은 마이크로소프트에서 제공하는 디버깅 정보 파일이며, 프로그램 디버깅에 사용됩니다. PDB 파일에는 프로그램의 심볼 테이블, 소스 코드 파일 이름, 행 번호 등의 정보가 포함되어 있습니다. 프로그램 컴파일 시 PDB 파일을 생성하여 프로그램을 디버깅할 수 있습니다.
WinDbg 디버깅
WinDbg는 마이크로소프트의 디버깅 도구이며, Windows 프로그램을 디버깅하는 데 사용될 수 있습니다. WinDbg는 호환되지 않는 pdb 파일을 로드할 수 있지만, 수동으로 로드해야 합니다. .reload /f /i
명령어를 사용하여 호환되지 않는 pdb 파일을 강제로 로드할 수 있습니다.
하지만 WinDbg는 Visual Studio만큼 사용하기 편리하지 않으므로, 저희는 Visual Studio에서도 호환되지 않는 PDB 파일을 로드할 수 있기를 바랍니다
비주얼 스튜디오에서 호환되지 않는 PDB 파일을 로드합니다
소스 코드는 보통 git으로 관리되므로, 해당 버전의 코드를 찾아 다시 컴파일하여 일치하는 pdb 파일을 생성할 수 있습니다. 왜 로드되지 않을까요? 주로 메타데이터가 매칭되지 않기 때문입니다.
작은 도구가 있는데, 실행 파일 정보에 기반하여 메타데이터를 수정하고 새로운 pdb 파일을 생성하여 Visual Studio가 로드할 수 있게 합니다
chkmatch 다운로드 주소: https://www.debuginfo.com/tools/chkmatch.html
사이트 캐시 주소: chkmatch.zip
ChkMatch utility can be used to check whether an executable and debug information file match. It can also be used to enforce matching between an executable and debug information file, if they are compatible.
For more information about debug information matching and related issues, see this article.
Supported debug information formats: DBG, PDB 2.0, PDB 7.0.
chkmatch [-c ExeFile DebugInfoFile ] |
[-m ExeFile DebugInfoFile]
-c
Check matching between the executable and the debug information file.
-m
Make the executable and the debug information file match.
ExeFile
The name of the executable file.
DebugInfoFile
The name of the debug information file.
chkmatch 사용하세요
먼저 검사 작업을 수행하고, 불일치 원인을 분석한 후 서명 불일치를 알립니다
C:\Users\tianlong.xiang\Downloads\chkmatch>ChkMatch.exe -c "D:\Program Files\Rolan\trade\UAT_YinStrade\YinTrade.Main.exe" E:\YinTech\ykcz_securities_trading_client\Sec_Trade\YinTrade.Main\bin\Release\YinTrade.Main.pdb
ChkMatch - version 1.0
Copyright (C) 2004 Oleg Starodumov
http://www.debuginfo.com/
Executable: D:\Program Files\Rolan\trade\UAT_YinStrade\YinTrade.Main.exe
Debug info file: E:\YinTech\ykcz_securities_trading_client\Sec_Trade\YinTrade.Main\bin\Release\YinTrade.Main.pdb
Executable:
TimeDateStamp: c26d9be3
Debug info: 2 ( CodeView )
TimeStamp: f86b0a4f Characteristics: 0 MajorVer: 0 MinorVer: 0
Size: 122 RVA: 001cdc44 FileOffset: 001cbe44
CodeView format: RSDS
Signature: {428c9b95-39a3-4a8d-a8e5-7be453684757} Age: 1
PdbFile: D:\stock_UAT\ykcz_securities_trading_client\Sec_Trade\YinTrade.Main\obj\Release\YinTrade.Main.pdb
Debug info: 16 ( Unknown )
TimeStamp: 00000000 Characteristics: 0 MajorVer: 0 MinorVer: 0
Size: 0 RVA: 00000000 FileOffset: 00000000
Debug information file:
Format: PDB 7.00
Signature: {06fae08e-c0a2-4f3d-9c7c-dfc684445dd1} Age: 1
Result: Unmatched (reason: Signature mismatch)
그런 다음 수정 작업을 실행하여 pdb 파일과 exe 파일을 일치시킵니다
C:\Users\tianlong.xiang\Downloads\chkmatch>ChkMatch.exe -m "D:\Program Files\Rolan\trade\UAT_YinStrade\YinTrade.Main.exe" E:\YinTech\ykcz_securities_trading_client\Sec_Trade\YinTrade.Main\bin\Release\YinTrade.Main.pdb
ChkMatch - version 1.0
Copyright (C) 2004 Oleg Starodumov
http://www.debuginfo.com/
Executable: D:\Program Files\Rolan\trade\UAT_YinStrade\YinTrade.Main.exe
Debug info file: E:\YinTech\ykcz_securities_trading_client\Sec_Trade\YinTrade.Main\bin\Release\YinTrade.Main.pdb
Executable:
TimeDateStamp: c26d9be3
Debug info: 2 ( CodeView )
TimeStamp: f86b0a4f Characteristics: 0 MajorVer: 0 MinorVer: 0
Size: 122 RVA: 001cdc44 FileOffset: 001cbe44
CodeView format: RSDS
Signature: {428c9b95-39a3-4a8d-a8e5-7be453684757} Age: 1
PdbFile: D:\stock_UAT\ykcz_securities_trading_client\Sec_Trade\YinTrade.Main\obj\Release\YinTrade.Main.pdb
Debug info: 16 ( Unknown )
TimeStamp: 00000000 Characteristics: 0 MajorVer: 0 MinorVer: 0
Size: 0 RVA: 00000000 FileOffset: 00000000
Debug information file:
Format: PDB 7.00
Signature: {06fae08e-c0a2-4f3d-9c7c-dfc684445dd1} Age: 1
Writing to the debug information file...
Result: Success.