How WinDbg get to know source code?

6.7k views Asked by At

I made C++ application to use with WinDbg, and intentionally add access violation run-time error.

Application was compiled as release build, and then I copied exe from release folder to desktop. Still when I use WinDbg, and application crashes, it open my source code file showing error line highlighted.

I am not able to understand, how WinDbg understand my source code file path.

Also, when I get crash dump from client, it may be possible, I do not have source code available with me. So I want to simulate real world scenario.

Regards

2

There are 2 answers

2
Violet Giraffe On BEST ANSWER

The way I understand it, Visual Studio compiler generates a .pdb file for any executable it creates (when /DEBUG flag is set). This PDB (Program Database) file contains information (including paths to source files) required for the debugger to match address in a binary module to source code. And it seems that a path to .pdb is hard-coded into the binary. So when you move a binary itself, debugger can still find pdb, from which it finds the sources.

All paths are probably absolute and will only work on the PC which compiled the binary.

1
codewarrior On

.pdb has source file full path name information. open a .pdb file you will see lines like this:f:\dd\vctools\crt\crtw32\stdcpp\locale0.cpp