Can we debug a running process in Visual Studio using PDB file and incomplete source code?

78 views Asked by At

I have to debug a running process for which I have matching PDB file, but do not have complete source code. Is it possible to debug specific functions in the available C++ source code?

I tried configuring PDB file and source code paths in VS and then attached to the running process, but execution is not stopping at expected locations. I added debug points in the available source code but it is not making any change because the binaries are built using VS.

1

There are 1 answers

1
Bowman Zhu-MSFT On

Can we debug a running process in Visual Studio using PDB file and incomplete source code?

Yes, you can.

But the extremely vital thing you need to pay attention is the source files used for debugging must be the same version as the ones used to build the binary and the PDB file must match the binary exactly.

An official document that explain this:

Why does Visual Studio require debugger symbol files to exactly match the binary files that they were built with?

For example, I created a MFC Cpp file on my side, the major structure of the solution/project is:

enter image description here

After I build the solution/project, a execution application will be generated under the solution directory:

enter image description here

You just need to pick up the execution application and related pdb like this(Make sure they are in the same directory. This step is to make sure when attach binary file .exe, the VS will be able to find the related pdb file.):

enter image description here

After that, follow this official document to use attach process feature to achieve your requirement:

Attach to running processes with the Visual Studio debugger

At this time, even I remove all of other cpp files, I am still able to hit the breakpoint in View Tree:

enter image description here