microsoft / microsoft-ui-xaml

WinUI: a modern UI framework with a rich set of controls and styles to build dynamic and high-performing Windows applications.
MIT License
6.38k stars 683 forks source link

Missing documentation on OnFailureEncountered crash debugging #10168

Open lolametro opened 1 week ago

lolametro commented 1 week ago

In the WinUI community call March 6, 2024 @Scottj1s presented "Crash debugging in 1.5". https://www.youtube.com/live/uFgGhNGlPm4?t=1035

It showed how to debug nasty crashes within WinUI/WASDK where the exception raised contains no helpful error code and no call stack. Unfortunately, within the video the screen sharing didn't properly work, so we were partially unable to see which steps were taken.

In https://github.com/microsoft/microsoft-ui-xaml/discussions/9361#discussioncomment-9288079 I have asked whether the steps could be documented in a blog post/docs page. While it was promised, unfortunately it didn't happen yet.

Therefore I would like to request the steps to be documented, so Google Bing (and AI models 😊) can index this information more easily.


In the meantime, I will document the steps here as well:

  1. Ensure Microsoft public symbols server is enabled in Visual Studio Options -> Debugging -> Symbols
  2. Ensure Source Link & Source Server is enabled in Visual Studio Options -> Debugging -> General (not mentioned in the video!)
  3. Enable native debugging in project debug properties
  4. Debug the project
  5. Go to the "Breakpoints" tab in the lower Visual Studio pane
  6. Add "New Function Breakpoint"
  7. Enter "Microsoft.ui.xaml.dll!OnFailureEncountered" and select C++
  8. Click OK
  9. Restart debugging, and now your debugger will break early in C++ code which allows you to inspect the call stack and find the line of code that threw the error

Image

Image