This is addressing a regression introduced by Greg's change in https://reviews.llvm.org/D86122 . His change was fine, but the original code was written unclearly as to what it was doing.
When a binary is in the system's "shared cache", the file addresses will be different from the dSYM's file addresses. The binary (both binary file & dSYM) usually start with a file address of 0, but when the binary is integrated into the "shared cache" of all common binaries, the segments are rearranged and now the TEXT segment has a non-0 file address. This is pretty unusual normally -- when the UUID matches for a binary and its dSYMs, they should have identical file addresses for their segments, for example.
When we add a dSYM SymbolFile to an ObjectFile that is in the shared cache, we're going to use the symbol table and debug information from the dSYM (SymbolFile) -- we need the Sections to have file addresses that match the symbol table and debug info in the dSYM. In other words, the dSYM's file addresses must win.
This is handled in ObjectFileMachO::ProcessSegmentCommand. This was previously behind a check of "does this section have a valid base address" or something that didn't make sense. Greg noticed this and changed it to "Is this ObjectFile a memory image". This seems like the right thing to do but "IsInMemory()" doesn't apply to the way we create shared cache binaries when lldb and the inferior are using the same shared cache. lldb thinks of these as the same as an on-disk ObjectFile that we've mmap'ed into our space, except it's contents are represented by a DataBufferUnowned. With this "file addr fixup" code behind a "IsInMemory()" check, now we weren't fixing the file addresses and none of the debug info was ever found because the fileaddrs were contained by any of the Sections.
I shouldn't intermix changes, but I was also annoyed by how many places we check if a binary is in the shared cache by checking flags in ObjectFileMachO, and put it in a little method.
This seems like a good thing to log to a log channel maybe?