This is an archive of the discontinued LLVM Phabricator instance.

Fix inconsistent target arch when attaching to arm64 binaries on arm64e platforms.
ClosedPublic

Authored by aprantl on Aug 31 2022, 4:17 PM.

Details

Summary

On arm64e-capable Apple platforms, the system libraries are always arm64e, but applications often are arm64. When a target is created from file, LLDB recognizes it as an arm64 target, but debugserver will still (technically correct) report the process as being arm64e. For consistency, set the target to arm64 here.

rdar://92248684

Diff Detail

Event Timeline

aprantl created this revision.Aug 31 2022, 4:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2022, 4:17 PM
aprantl requested review of this revision.Aug 31 2022, 4:17 PM
mib added a subscriber: mib.Aug 31 2022, 4:21 PM
mib added inline comments.
lldb/include/lldb/Target/Target.h
1012

typo ?

JDevlieghere added inline comments.Aug 31 2022, 4:42 PM
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
584

Why can't you set the target_arch to exe_module_sp->GetArchitecture().GetTriple()?

aprantl added inline comments.Aug 31 2022, 6:18 PM
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
584

That would be shorter. I was worried that could undo any mac catalyst versus macos fixups we did in DynamicLinkerDarwin before.

JDevlieghere added inline comments.Aug 31 2022, 7:29 PM
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
584

Fair enough. Can we at least take the architecture from the triple then and pass that instead of hardcoding arm64?

aprantl updated this revision to Diff 457416.Sep 1 2022, 2:57 PM

Address feedback!

JDevlieghere accepted this revision.Sep 1 2022, 4:26 PM

That test is not going to win any beauty pageants but it looks like it gets the job done. LGTM.

This revision is now accepted and ready to land.Sep 1 2022, 4:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2022, 4:40 PM
rsmith added a subscriber: rsmith.Sep 2 2022, 4:03 PM

Hi, the newly-added test, TestDynamicLoaderDarwin.py, fails under asan: https://gist.github.com/zygoloid/bf7b21f03d7db966e456b6c365c4635d

Please can you take a look?

Hi, the newly-added test, TestDynamicLoaderDarwin.py, fails under asan: https://gist.github.com/zygoloid/bf7b21f03d7db966e456b6c365c4635d

Thanks! Should be fixed in

commit 603d5a8d632164038a869c200818c4cc238bb85a (HEAD -> main)
Author: Adrian Prantl <aprantl@apple.com>
Date:   Fri Sep 2 18:14:12 2022 -0700

    Fix out-of-bounds memory access in test