This is an archive of the discontinued LLVM Phabricator instance.

[lldb][Breakpoint] Prevent crash when resolving regex breakpoint on functions with asm declaration
AcceptedPublic

Authored by Michael137 on Aug 11 2022, 9:43 AM.

Details

Reviewers
jingham
Summary

Currently, a function whose mangled name got
changed using an asm() statement on its
declaration will cause lldb to crash when
resolving restricted regex breakpoints.

The crash occurs because we previously assumed
that all functions in the SymbolContext will
cleanly demangle into a function name that we
can compare against the restrictions list.
However, with the asm() attribute applied
the mangled name may not conform to the
supported mangling schemes and we return
a nullptr.

The fix is to use the fallback parameter to
ConstString::AsCString().

Testing

  • Added API test

Diff Detail

Event Timeline

Michael137 created this revision.Aug 11 2022, 9:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2022, 9:43 AM
Michael137 requested review of this revision.Aug 11 2022, 9:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2022, 9:43 AM
  • Tweak test case
  • Skip Windows
jingham accepted this revision.Aug 29 2022, 10:31 AM

LGTM. It's hard to prove a negative, but it might be worth checking the other uses of GetFunctionName and make sure we aren't making a similar mistake?

This revision is now accepted and ready to land.Aug 29 2022, 10:31 AM