问题
Want to debug an executable under debugger. How to do it in visual studio.
Windbg has an option of open executable. But I find this is missing in VS 2010.
The question is not exactly same as Debug exe in visual studio 2010 as I am not really interested in image file execution to debug a start up.
Rather want to just debug the exe under debugger, once it is broken, want to set some break points and understand the flow of execution.
Albeit image file execution is a workaround for this.
I am not sure if this question is naive; But this is a very straight line use case scenario, I find missing in MS VS 2010.
回答1:
You did not specify it in the question, but I assume you do not have the source code. 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.
回答2:
If what your asking is how do you attach VS to the exe you want to run then you can follow these steps:
- Run the executable
- In VS navigate to Debug -> Attached to Process
- Find your process created by running your executable and click "attach".
However, if the executable you are trying to run fails almost immediately or runs quickly and exits then you could try the following steps:
- Set a debug point at the start of the code
- Switch your build to Debug and run the application.
If your application is running in Debug, but failing when you execute the exe then you could try these steps to see if the your app will give more information in a console window or other.
- Make sure your build is set to Release.
- Navigate to Debug -> Start Without Debugging
来源:https://stackoverflow.com/questions/15097610/debugging-an-executable-in-visual-studio