================ @@ -578,20 +605,47 @@ Status ProcessMachCore::DoLoadCore() { SetCanJIT(false); + // If we have an executable binary in the Target already, + // use that to set the Target's ArchSpec. + // + // Don't initialize the ArchSpec based on the corefile's cputype/cpusubtype + // here, the corefile creator may not know the correct subtype of the code + // that is executing, initialize the Target to that, and if the + // main binary has Python code which initializes based on the Target arch, + // get the wrong subtype value. + ModuleSP exe_module_sp = GetTarget().GetExecutableModule(); + if (exe_module_sp && exe_module_sp->GetArchitecture().IsValid()) { + LLDB_LOGF(log, + "ProcessMachCore::%s: Was given binary + corefile, setting " + "target ArchSpec to binary to start", + __FUNCTION__); + GetTarget().SetArchitecture(exe_module_sp->GetArchitecture()); + } + CreateMemoryRegions(); LoadBinariesAndSetDYLD(); CleanupMemoryRegionPermissions(); - ModuleSP exe_module_sp = GetTarget().GetExecutableModule(); + exe_module_sp = GetTarget().GetExecutableModule(); ---------------- jimingham wrote:
If there's a reason that's then that's all good, but it might be helpful to future us to say why. https://github.com/llvm/llvm-project/pull/136065 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits