This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Print lldbassert to debugger diagnostics
ClosedPublic

Authored by JDevlieghere on Jun 13 2023, 4:12 PM.

Details

Summary

When hitting an lldbassert in a non-assert build, we emit a blurb including the assertion, the triggering file and line and a pretty backtrace leading up to the issue. Currently, this emitted to stderr. That's fine for the command line, but when used as library, for example from Xcode or VSCode, this information doesn't make it to the user. This patch redirects these messages to use the diagnostic infrastructure so they're emitted as diagnostic events.

The patch is slightly more complicated than I would've liked because of layering. lldbassert is part of Utility while the diagnostics are implemented in Core.

Diff Detail

Event Timeline

JDevlieghere created this revision.Jun 13 2023, 4:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 4:12 PM
JDevlieghere requested review of this revision.Jun 13 2023, 4:12 PM

I like this idea quite a bit! I assume that when somebody hits a bug, they can give us their diagnostics file and we will hopefully see the assertion somewhere (if there was one)?

lldb/source/Target/Target.cpp
115

.

I like this idea quite a bit! I assume that when somebody hits a bug, they can give us their diagnostics file and we will hopefully see the assertion somewhere (if there was one)?

Unfortunate naming, but these are different diagnostics: these are errors and warnings that are emitted as events. What you're thinking of is the Diagnostic class.

  • I should really rename one of them to avoid confusion.
  • We could totally combine the two and emit a file with the lldbassert in the "diagnostics dir" that we generate on crash. I'll tackle that in a follow-up commit.
JDevlieghere updated this revision to Diff 531111.
JDevlieghere marked an inline comment as done.
bulbazord accepted this revision.Jun 13 2023, 4:24 PM

I like this idea quite a bit! I assume that when somebody hits a bug, they can give us their diagnostics file and we will hopefully see the assertion somewhere (if there was one)?

Unfortunate naming, but these are different diagnostics: these are errors and warnings that are emitted as events. What you're thinking of is the Diagnostic class.

  • I should really rename one of them to avoid confusion.
  • We could totally combine the two and emit a file with the lldbassert in the "diagnostics dir" that we generate on crash. I'll tackle that in a follow-up commit.

Oh I see. Yeah, the fact that we have multiple things named Diagnostics is confusing. :( Unfortunate but still better than nothing. Let's definitely figure out a resolution as a follow-up.

This revision is now accepted and ready to land.Jun 13 2023, 4:24 PM

Separate out message, backtrace and prompt. This works better for a custom (downstream) callback that prompts the user to automatically file a bug report.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 8:46 PM