Skip to content

Conversation

@delcypher
Copy link

This patch refactors the trap reason demangling logic in lldb_private::VerboseTrapFrameRecognizer::RecognizeFrame into a new public function clang::CodeGen::DemangleTrapReasonInDebugInfo.

There are two reasons for doing this:

  1. In a future patch the logic for demangling needs to be used somewhere else in LLDB and thus the logic needs refactoring to avoid duplicating code.
  2. The logic for demangling shouldn't really be in LLDB anyway because it's a Clang implementation detail and thus the logic really belongs inside Clang, not LLDB.

Unit tests have been added for the new function that demonstrate how to use the new API.

The function names recognized by VerboseTrapFrameRecognizer are identical to before. However, this patch isn't NFC because:

  • The lldbTarget library now links against clangCodeGen which it didn't previously.
  • The LLDB logging output is a little different now. The previous code tried to log failures for an invalid regex pattern and for the Regex::match API not returning the correct number of matches. These failure conditions are unreachable via unit testing so they have been made assertions failures inside the DemangleTrapReasonInDebugInfo implementation instead of trying to log them in LLDB.

rdar://163230807
(cherry picked from commit 3ebed51)

…ang (llvm#165996)

This patch refactors the trap reason demangling logic in
`lldb_private::VerboseTrapFrameRecognizer::RecognizeFrame` into a new
public function `clang::CodeGen::DemangleTrapReasonInDebugInfo`.

There are two reasons for doing this:

1. In a future patch the logic for demangling needs to be used somewhere
else in LLDB and thus the logic needs refactoring to avoid duplicating
code.
2. The logic for demangling shouldn't really be in LLDB anyway because
it's a Clang implementation detail and thus the logic really belongs
inside Clang, not LLDB.

Unit tests have been added for the new function that demonstrate how to
use the new API.

The function names recognized by VerboseTrapFrameRecognizer are
identical to before. However, this patch isn't NFC because:

* The `lldbTarget` library now links against `clangCodeGen` which it
didn't previously.
* The LLDB logging output is a little different now. The previous code
tried to log failures for an invalid regex pattern and for the
`Regex::match` API not returning the correct number of matches. These
failure conditions are unreachable via unit testing so they have been
made assertions failures inside the `DemangleTrapReasonInDebugInfo`
implementation instead of trying to log them in LLDB.

rdar://163230807
(cherry picked from commit 3ebed51)
@delcypher delcypher requested a review from Michael137 November 5, 2025 00:30
@delcypher delcypher self-assigned this Nov 5, 2025
@delcypher delcypher added the clang:bounds-safety Issue relating to the experimental -fbounds-safety feature in Clang label Nov 5, 2025
@delcypher
Copy link
Author

@swift-ci test

@delcypher
Copy link
Author

@swift-ci test llvm

@delcypher
Copy link
Author

@swift-ci please test Windows platform

@kavon kavon merged commit 5614bc4 into stable/21.x Nov 5, 2025
4 of 5 checks passed
@kavon kavon deleted the dliew/demangle-trap-reason-refactor-cherry-pick-stable-21.x branch November 5, 2025 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bounds-safety Issue relating to the experimental -fbounds-safety feature in Clang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants