How to debug an existing C ++ executable using pdb but without source code

I work in an already compiled (in debug mode) C ++ project. I have an exe file and a pdb file. I can run exe from the command line.

How can I debug a project? (I don’t have a .sln file.)

I work in Visual Studio, but I also have cygwin on the system.

+4
source share
4 answers

Open the executable file from Visual Studio, just as you open a project or solution. This will allow you to debug it.

(It creates an empty solution for storing space around your exe, which you can use to change environment variables or command line arguments when running exe to debug it.)

+6
source

Run the Visual Studio command prompt and run the following command:

 devenv /debugexe yourapp.exe 

It should be equivalent to opening an executable in Visual Studio, as Macke suggested in his answer.

Then you can click, for example. F10 so that the debugger stops at the start of the application or sets a breakpoint as usual, etc.

+3
source

You can use WinDbg for debugging.
You can point Windbg to the sources or stick with disassembly, but the PDB files will contain at least the name of the methods being called, and you can see the readable stack trace.

0
source

You can also debug an already running process. Just run the program from the command line, and then use Visual Studio to attach to it (Tools β†’ Attach to process).

0
source

All Articles