[Lldb-commits] [PATCH] D128956: make debugserver able to inspect mach-o binaries present in memory, but not yet registered with dyld

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 30 15:57:19 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.

lldb sends the jGetLoadedDynamicLibrariesInfos packet to debugserver with a list of addresses of mach-o binaries.  Today, debugserver collects a list of all binaries that are loaded in the process, along with their filenames, and then debugserver parsers the mach-o binaries in memory and returns the important details in a JSON response so lldb doesn't need to read this data from the inferior itself.  If lldb asks about a binary that isn't officially loaded in the process yet -- but is present in memory -- then this packet will return nothing about it.

This patch handles the case where dyld does not know about the binary.  We cannot get a filepath for the binary, so "" is returned there, but debugserver can examine memory and if there's something that looks like a mach-o header + load commands, return that information to lldb.

In macOS Ventura, as part of the early startup, we launch with one dynamic linker (dyld) and that dyld hands off control to a dyld in the shared cache.  During that transition, the new dyld is not officially loaded in the process yet.  I'd like to switch to having lldb parse the not-yet-running dyld and put a breakpoint in it.  This is needed first, to avoid a perf hit when lldb inspects the load commands of new-dyld.

I added a test case that constructs a tiny little mach-o binary in a memory buffer and have lldb send that buffer address to jGetLoadedDynamicLibrariesInfos.  Current debugserver will return an empty list of binaries found; with this patch, debugserver will have an empty filepath but return everything from the load commands.

There's no real good reviewer in this case, this is all jason code, but if anyone has any questions or comments they'd like to make, I'd be interested in hearing them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128956

Files:
  lldb/test/API/macosx/unregistered-macho/Makefile
  lldb/test/API/macosx/unregistered-macho/TestUnregisteredMacho.py
  lldb/test/API/macosx/unregistered-macho/main.c
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128956.441545.patch
Type: text/x-patch
Size: 5741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220630/39266ea4/attachment-0001.bin>


More information about the lldb-commits mailing list