Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug an existing C++ executable with pdb but without source code

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

How can I debug the project? (I so not have its .sln file.)

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

like image 767
Yakov Avatar asked Aug 15 '11 13:08

Yakov


People also ask

How do I debug an external exe in Visual Studio?

Just use File/Open Project/Solution, select EXE file and Open it. Then select Debug/Start debugging. The other option is to run the EXE first and then Select Debug/Attach to process. Save this answer.

How do you debug and run C in Visual Studio code?

To do that, open C++ file in VSCode and either hit F5 or go to Debug -> Start Debugging and select C++ (GDB/LLDB) then select g++.exe build and debug active file . Notice that I've added one more optional configuration g++ build & run active file in launch.


2 Answers

Open the executable from Visual Studio, in the same way as you would open a project or a solution. That will allow you to debug it.

(It creates an empty place-holder solution around your exe, which you can use to change environment variables or command-line arguments when you run the exe to debug it.)

like image 55
Macke Avatar answered Oct 31 '22 18:10

Macke


Start a Visual Studio command prompt, and run the following command:

devenv /debugexe yourapp.exe

It must be equivalent to opening the executable file in Visual Studio as Macke suggested in his answer.

You can then press e.g. F10 for the debugger to stop in the beginning of app execution, or set a breakpoint as usual, etc.

like image 32
Alexey Kukanov Avatar answered Oct 31 '22 17:10

Alexey Kukanov