[Lldb-commits] [PATCH] D125434: Make a more convenient way to allow Darwin users to ignore certain Mach Exceptions

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 11 16:58:38 PDT 2022


jingham created this revision.
jingham added reviewers: JDevlieghere, jasonmolenda, labath.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

For relatively uninteresting reasons, it is not possible when running under the debugger to invoke the mechanism that converts a Mach Exception into its BSD signal equivalent.  The Mach Exceptions contain more information than the signal does, so we prefer to stop at the mach exception raise for most purposes.  But if your application relies on a SIGBUS, SIGSEGV, etc. handler, then your application won't run properly in the debugger, it will just get stuck on the exception.

The was a workaround for this added a while back - by passing -U to the debugger, EXC_BAD_ACCESS, EXC_BAD_INSTRUCTION and EXC_ARITHMETIC are masked out.  But this isn't terribly convenient, because you have to invoke debugserver specially so you have to do this every time you debug, you can't use the feature when you don't control how debugserver is launched, and you can't control which exception you want to mask out.

I made this more convenient by adding a QSetIgnoredExceptions packet to debugserver which will set the exceptions not to include, so we can direct this from lldb.

Then I added a way for Platform to provide "extra startup commands" to the remote startup sequence - there was already a way for the user to supply extra startup commands, and I could have had users set the QSetIgnoredExceptions in the "target.extra-startup-commands", but that would be pretty undiscoverable.  Instead, I added a "platform.plugin.darwin.ignored-exceptions" property that users can set with just the exception mask.  Then PlatformDarwin gathers the results of this setting, and conses up the appropriate packet and returns that from PlatformDarwin::ExtraStartupCommands.

I also wanted to add a validator for the property.  Since I don't control the property creation (that all happens through processing the .td file) I couldn't put my validator in the OptionValueString made for the setting on construction, so I added an API to set it after the fact.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125434

Files:
  lldb/include/lldb/Interpreter/OptionValueString.h
  lldb/include/lldb/Target/Platform.h
  lldb/include/lldb/Utility/StringExtractorGDBRemote.h
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSXProperties.td
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Utility/StringExtractorGDBRemote.cpp
  lldb/test/API/macosx/ignore_exceptions/Makefile
  lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
  lldb/test/API/macosx/ignore_exceptions/main.c
  lldb/tools/debugserver/source/DNB.cpp
  lldb/tools/debugserver/source/DNB.h
  lldb/tools/debugserver/source/MacOSX/MachException.cpp
  lldb/tools/debugserver/source/MacOSX/MachException.h
  lldb/tools/debugserver/source/MacOSX/MachProcess.h
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm
  lldb/tools/debugserver/source/MacOSX/MachTask.h
  lldb/tools/debugserver/source/MacOSX/MachTask.mm
  lldb/tools/debugserver/source/RNBContext.cpp
  lldb/tools/debugserver/source/RNBContext.h
  lldb/tools/debugserver/source/RNBRemote.cpp
  lldb/tools/debugserver/source/RNBRemote.h
  lldb/tools/debugserver/source/debugserver.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125434.428817.patch
Type: text/x-patch
Size: 38739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220511/8f78195c/attachment-0001.bin>


More information about the lldb-commits mailing list