How do I debug an application crash (unhandled win32 exception) in vscode? - c++

I have a running application that crashes with "An unhandled win32 exception occurred in ..." dialog. This only contains full-fledged Visual Studio in the available debuggers list even though Visual Studio Code is installed.
I would rather use vscode as it is my main dev environment.
How can I add it to the "Choose Just-In-Time Debugger" window's "Available Debuggers" list?
Update:
I found where the setting exists in the registry, with an example of how to set WinDbg as the debugger instead of Visual Studio.
https://www.codeproject.com/articles/6084/windows-debuggers-part-1-a-windbg-tutorial#_Toc64133667
and
https://learn.microsoft.com/en-us/windows/win32/debug/configuring-automatic-debugging
Remaining step is to determine how VS Code's debugger likes to be invoked.
(I'm still open to cleaner ways to do this, however.)
Update 2:
Nearest I can tell, this last step is the big deal breaker.
According to this feature request:
https://github.com/Microsoft/vscode/issues/10979
It doesn't look like the team at Microsoft is interested in making that an option. :_(

Related

How to trace an unhandled exception in C++ using Visual Studio 2017

I am currently working on fixing a project for a client. A little information about the project first:
Originally developed in Visual Studio 2012 using xp_v110 build tools
Multiple projects in the solution
Currently updating/debugging in Visual Studio 2017 using VS 2015/xp_v140 build tools
Working on Windows 10
The application will run in debug mode, however if I just leave the application after starting the debug session (i.e. not opening/clicking on the application to open it as it starts minimized in the tray), the application crashes after 1-2 minutes.
Unfortunately the IDE is showing that the crash is taking place in chkstk.asm with the following message:
Exception thrown at 0x0064EDF9 in <<exe name>>: 0xC00000FD: Stack overflow (parameters 0x00000000, 0x000A2000).
I have updated the exception settings to break when all C++ Exceptions are thrown, checked the box that says "Break when this exception type is thrown", and wrapped the initial method that runs in a try block, however I can never catch the error in the C++ code; it always occurs in the chkstk.asm file.
Any suggestions on how I can find out where in the C++ code the exception is occurring. Like I said, this is an update for a client and the original programmer is not available, and they never commented their code, so it is difficult enough trying to go through all this. Any help/suggestions would be greatly appreciated. Thanks in advance.

How do I get stack trace in Visual Studio 2017

I am getting Exceptions in the Output window of Visual Studio but do not know what code is causing these exceptions. I would like to get a stack trace so I can properly debug them.
Here is a sample of the exceptions I am getting:
The one I am particularly interested in in the NullReferenceException.
I have looked at this SO post:
How do I find the stack trace in Visual Studio?
But my menu looks like this:
I tried to follow these instructions for adding the "Exceptions" choice to the Debug menu but all I can find it "Exceptions Settings":
Seeing a stack trace of an exceptions seems like such a common need I have a hard time believing that VS is hiding it.
I noticed a tabbed panel on the bottom of VS and was able to modify the Exceptions that cause VS to break on the "Exception Settings" tab.

Visual Studio 2015 -- CPU Usage Profiling Not Working?

I recently upgraded from Visual Studio 2013 Community to Visual Studio 2015 Community.
I've heavily relied on the "CPU Usage" Tool that can be found by doing the following:
Click "Debug"
Click "Start Diagnostic Tools without Debugging"
Click "CPU Usage" Check box
Click "Start" button
When the program is complete, it is supposed to show you the functions and the time spent in each. What I get instead is just the name of my executable that I can keep expanding instead of seeing the function names -- It doesn't know the names of the functions.
This worked fine on Visual Studio 2013... I would be able to see the function names and everything worked. I tried creating a new "test" solution/project to see whether this works and I get the same results: No function names.
Does this work for anybody? I also installed VS2015 on a fresh development box and still have no results. This seems like Microsoft shipped with a Visual Studio bug.
Note: I'm writing a C++ console application. I've tried this on debug and release builds and ensured that I'm building with debug information.
It's in the Visual Studio 2015 Update 1 release notes, so I suspect it was broken in the initial release:
Profile your CPU Usage while debugging
Now, you can get a detailed per-function profile of your CPU Usage while you are debugging. You can turn CPU Profiling on and off while debugging and view the results when you are in a break state, which allows you to view a per-function breakdown of CPU Usage of code that executed between breakpoints and during steps. (To use this functionality, open the Diagnostic Tools window (Debug -> Diagnostic Tools), switch to the CPU tab, and then click the "CPU Profiling" button.)
I have also noticed this, but if you use that little search box (top right corner of the results area) and try typing in either the name of the function you're looking for or part of the name and it will expand everything (there's usually a lot to expand) and highlight the function you're looking for. Its the only way I've been able to profile specific functions.

Visual Studio 2013: native C++ single-step debugging (F10) slow

I am using Visual Studio Premium 2013 Update 2 on a freshly installed (fast) machine with Windows 8.1 Update. Everything is running smoothly, only one thing bugs me:
Problem
When I debug a native C++ project (debug build) by going from line to line with F10 ("step over") it takes 1-2 seconds to go to the next line when I press the F10 key.
What I tried
I looked at several other questions related to slow debugging and made sure that neither of the following is not the reason in my case:
Everything is local (app and all data), no network shares involved
Disabling the Microsoft symbol server did not help
I only have a single breakpoint
Using the menu/toolbar instead of the keyboard does not make any difference
In the default configuration "edit and continue" is enabled, but apparently not for native code:
When I disabled "edit and continue" completely, F10 stepping became much faster (0.5-1 s). The speed is tolerable now. I had to restart Visual Studio after I changed the configuration to this:

silent closing VS 2008 on Windows 7

I am trying to build a MFC Windows Application with Visual Studio 2008 on Windows 7. I use the "Batch build" feature of Visual Studio to get both Release and Debug of several projects' outputs with only one-click.
The problem is: Frequently, after I instruct VS 2008, some minutes later VS closes its window without any explanation. I have already seach the Web about these things and it seems that nobody as an answer.
I cannot be more specific than this. VS simply closes and you will not get any information.
Thanks in advance,
Sérgio
The best answer I could give would be to contact Microsoft directly and let them know of your problem. If there is no error information, it could be that they are not handling an exception and the program is just closing instead.
Seems that installing the patch quoted on http://arstechnica.com/microsoft/news/2009/03/widely-reported-crash-in-visual-studio-2008-sp1-fixed.ars solves the issue.