[Lldb-commits] [PATCH] D136719: change debugserver to return an empty platform name for unknown platforms, instead of crashing

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 25 16:29:48 PDT 2022


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

debugserver is sometimes run in bringup environments, where debugserver doesn't yet recognize its platform code.  debugserver will crash shortly after when strlen() is run on the nullptr returned, creating a std::string.

Instead, have debugserver return an empty platform name back up to lldb.  lldb is in a better position to handle a triple with a missing component and surface an error message to the user, instead of having debugserver cease to be running.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136719

Files:
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm


Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===================================================================
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -743,7 +743,10 @@
   case PLATFORM_DRIVERKIT:
     return "driverkit";
   }
-  return nullptr;
+  DNBLogError(
+      "Unknown platform %u found for one binary, returning empty string",
+      platform);
+  return "";
 }
 
 static bool mach_header_validity_test(uint32_t magic, uint32_t cputype) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136719.470640.patch
Type: text/x-patch
Size: 540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221025/6a4132f5/attachment.bin>


More information about the lldb-commits mailing list