[Lldb-commits] [PATCH] D142662: Allow bytes-only mach-o corefile to load into lldb

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 26 13:11:34 PST 2023


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

`ProcessMachCore::DoLoadCore` has an error check that if it found no thread contexts (`LC_THREAD`s), it is an improperly formed corefile and will be rejected.  We have a group that is creating memory-only corefiles, and will provide threads from an operating system or scripted process python plugin that they write.  This removes the error handling from DoLoadCore -- I can't remember this catching problems with corrupt corefiles in real world use.

I haven't cooked up a test for it at this point; it would be possible to run a user process, `process save-core` it, write a utility program that rewrites the corefiles to remove the LC_THREAD load commands, loads it into lldb, and confirms that memory can still be examined.  But given the simplicity of the change, I don't feel super motivated to write all that.  I'm open to it though, if other people feel it would be a good addition to our test coverage.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142662

Files:
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp


Index: lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
===================================================================
--- lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -483,13 +483,6 @@
     return error;
   }
 
-  if (core_objfile->GetNumThreadContexts() == 0) {
-    error.SetErrorString("core file doesn't contain any LC_THREAD load "
-                         "commands, or the LC_THREAD architecture is not "
-                         "supported in this lldb");
-    return error;
-  }
-
   SetCanJIT(false);
 
   // The corefile's architecture is our best starting point.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142662.492550.patch
Type: text/x-patch
Size: 670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230126/4d7a9e3f/attachment.bin>


More information about the lldb-commits mailing list