microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.51k stars 1.55k forks source link

[Visual C++] Hold console window open after program termination #1004

Open colemickens opened 7 years ago

colemickens commented 7 years ago

I want to debug my application, but it takes a lot of flags. I'm missing one of those flags in launch.json. However, when I start debugging with cppvsdbg, then I can't see the error message when debugging because it just terminates before I can see the error message. Some helper function in a library down inside is calling os exit, so it's not easy for me to just set a breakpoint at the bottom of my program.

Would it be possible to have the debugger launch myapplication & pause or something so that I can see stdout?

pieandcakes commented 7 years ago

If you want us to launch your app and then pause, you can enable stopAtEntry to be true and we will stop at the first line of the main() method.

Otherwise this will be a feature request.

colemickens commented 7 years ago

I am aware of that flag… but it's not the behavior I'm looking for. I really just want to see the output of my application after it exits when running in debug mode. I think this is a feature request, though I was hoping maybe it was an undocumented feature or one with a workaround.

I suppose alternatively, if this ran in the integrated debugger, presumably it's buffer would stick around. But there are already a couple issues open for that.

On Aug 30, 2017 4:13 PM, "Pierson Lee" notifications@github.com wrote:

If you want us to launch your app and then pause, you can enable stopAtEntry to be true and we will stop at the first line of the main() method.

Otherwise this will be a feature request.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode-cpptools/issues/1004#issuecomment-326144718, or mute the thread https://github.com/notifications/unsubscribe-auth/AAT9dL2L4cI1DzBnqcGwV9eTWJRQlvY1ks5sdeyZgaJpZM4PGmTq .

colemickens commented 7 years ago

In particular, I was hoping there was some way I could trick the whole thing into just executing the debugger command but also running pause afterward somehow. Or something similar. Alternatively, if it's an easy contribution here I could try to add it.

Thanks!

On Aug 30, 2017 4:20 PM, "Cole Mickens" notifications@github.com wrote:

I am aware of that flag… but it's not the behavior I'm looking for. I really just want to see the output of my application after it exits when running in debug mode. I think this is a feature request, though I was hoping maybe it was an undocumented feature or one with a workaround.

I suppose alternatively, if this ran in the integrated debugger, presumably it's buffer would stick around. But there are already a couple issues open for that.

On Aug 30, 2017 4:13 PM, "Pierson Lee" notifications@github.com wrote:

If you want us to launch your app and then pause, you can enable stopAtEntry to be true and we will stop at the first line of the main() method.

Otherwise this will be a feature request.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode-cpptools/issues/1004# issuecomment-326144718, or mute the thread https://github.com/notifications/unsubscribe-auth/ AAT9dL2L4cI1DzBnqcGwV9eTWJRQlvY1ks5sdeyZgaJpZM4PGmTq .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode-cpptools/issues/1004#issuecomment-326145694, or mute the thread https://github.com/notifications/unsubscribe-auth/AAT9dG8V0OkxcDD9s0J5u3shvjZ1lCAsks5sde4pgaJpZM4PGmTq .

pieandcakes commented 7 years ago

For Visual C++ we can look at doing it but since the console showing the output is child process of the debugger and when you stop debugging, the debugger exits, this might not be something we can solve.

One of the items on our backlog is to output the text to the debug console in VSCode.

Alternatively, if it's an easy contribution here I could try to add it.

Unfortunately the Visual C++ debugger itself is not open source but thanks for the offer!

Anandesh-Sharma commented 7 years ago

I have also the same problem but using cin.get() i was able to pause the console output screen and press ctrl + C to exit the output screen. But there should be a way to attach this command to launch.json

colemickens commented 7 years ago

I'm not debugging C and I need to be able to debug exceptional program exits, so the various tricks all over StackOverflow are not applicable. All I've found are confusing, unexplained answers that involve what look to be a VS specific switch (that I wouldn't know how to use otherwise).

Is there no other workaround? Even if I could just get it redirected to a file, I would at least not be blocked. How are people using the C++ debugger effectively with this serious of a limitation?

(edited briefly to fix a couple of minor typos)

liudonghua123 commented 6 years ago

I have the same problem, need features like Ctrl+F5 run features like Visual studio.