jGetLoadedDynamicLibrariesInfos can inspect machos not yet loaded
authorJason Molenda <jason@molenda.com>
Fri, 8 Jul 2022 21:01:15 +0000 (14:01 -0700)
committerJason Molenda <jason@molenda.com>
Fri, 8 Jul 2022 22:13:49 +0000 (15:13 -0700)
commit77a38f6839980bfac61babb40d83772c51427011
treeadf9a6d9280949465d7d108fe9bdf102104b5909
parentdf90d22704d8743746fa00bc6d67e2789ca9ee9e
jGetLoadedDynamicLibrariesInfos can inspect machos not yet loaded

jGetLoadedDynamicLibrariesInfos normally checks with dyld to find
the list of binaries loaded in the inferior, and getting the filepath,
before trying to parse the Mach-O binary in inferior memory.
This allows for debugserver to parse a Mach-O binary present in memory,
but not yet registered with dyld.  This patch also adds some simple
sanity checks that we're reading a Mach-O header before we begin
stepping through load commands, because we won't have the sanity check
of consulting dyld for the list of loaded binaries before parsing.
Also adds a testcase.

Differential Revision: https://reviews.llvm.org/D128956
rdar://95737734
lldb/test/API/macosx/unregistered-macho/Makefile [new file with mode: 0644]
lldb/test/API/macosx/unregistered-macho/TestUnregisteredMacho.py [new file with mode: 0644]
lldb/test/API/macosx/unregistered-macho/main.c [new file with mode: 0644]
lldb/tools/debugserver/source/MacOSX/MachProcess.h
lldb/tools/debugserver/source/MacOSX/MachProcess.mm