Skip to content

Commit 257c95b

Browse files
jasonmolendabnbarham
authored andcommitted
Simplify logic to identify dyld_sim in Simulator debugging on macos
When debugging a Simulator process on macOS (e.g. the iPhone simulator), the process will have both a dyld, and a dyld_sim present. The dyld_sim is an iOS Simulator binary. The dyld is a macOS binary. Both are MH_DYLINKER filetypes. lldb needs to identify & set a breakpoint in dyld, so it has to distinguish between these two. Previously lldb was checking if the inferior target was x86 (indicating macOS) and the OS of the MH_DYLINKER binary was iOS/watchOS/etc -- if so, then this is dyld_sim and we should ignore it. Now with arm64 macOS systems, this check was invalid, and we would set our breakpoint for new binaries being loaded in dyld_sim, causing binary loading to be missed by lldb. This patch uses the Target's ArchSpec triple environment, to see if this process is a simulator process. If this is a Simulator process, then we only recognize a MH_DYLINKER binary with OS type macOS as being dyld. This patch also removes some code that handled pre-2016 era debugservers which didn't give us the OS type for each binary. This was only being used on macOS, where we don't need to handle the presence of very old debugservers. Differential Revision: https://reviews.llvm.org/D115001 rdar://85907839 (cherry picked from commit fddafa1)
1 parent 0b38d7a commit 257c95b

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -540,35 +540,18 @@ void DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos(
540540
const size_t image_infos_size = image_infos.size();
541541
for (size_t i = 0; i < image_infos_size; i++) {
542542
if (image_infos[i].header.filetype == llvm::MachO::MH_DYLINKER) {
543-
// In a "simulator" process (an x86 process that is
544-
// ios/tvos/watchos/bridgeos) we will have two dyld modules --
543+
// In a "simulator" process we will have two dyld modules --
545544
// a "dyld" that we want to keep track of, and a "dyld_sim" which
546-
// we don't need to keep track of here. If the target is an x86
547-
// system and the OS of the dyld binary is ios/tvos/watchos/bridgeos,
548-
// then we are looking at dyld_sym.
549-
550-
// debugserver has only recently (late 2016) started sending up the os
551-
// type for each binary it sees -- so if we don't have an os type, use a
552-
// filename check as our next best guess.
553-
if (image_infos[i].os_type == llvm::Triple::OSType::UnknownOS) {
554-
if (image_infos[i].file_spec.GetFilename() != g_dyld_sim_filename) {
555-
dyld_idx = i;
556-
}
557-
} else if (target_arch.GetTriple().getArch() == llvm::Triple::x86 ||
558-
target_arch.GetTriple().getArch() == llvm::Triple::x86_64) {
559-
if (image_infos[i].os_type != llvm::Triple::OSType::IOS &&
560-
image_infos[i].os_type != llvm::Triple::TvOS &&
561-
image_infos[i].os_type != llvm::Triple::WatchOS) {
562-
// NEED_BRIDGEOS_TRIPLE image_infos[i].os_type != llvm::Triple::BridgeOS) {
563-
dyld_idx = i;
564-
}
545+
// we don't need to keep track of here. dyld_sim will have a non-macosx
546+
// OS.
547+
if (target_arch.GetTriple().getEnvironment() == llvm::Triple::Simulator &&
548+
image_infos[i].os_type != llvm::Triple::OSType::MacOSX) {
549+
continue;
565550
}
566-
else {
567-
// catch-all for any other environment -- trust that dyld is actually
568-
// dyld
569-
dyld_idx = i;
570-
}
571-
} else if (image_infos[i].header.filetype == llvm::MachO::MH_EXECUTE) {
551+
552+
dyld_idx = i;
553+
}
554+
if (image_infos[i].header.filetype == llvm::MachO::MH_EXECUTE) {
572555
exe_idx = i;
573556
}
574557
}

0 commit comments

Comments
 (0)