Skip to content

Commit 8a87f76

Browse files
Aim debugserver workaround more precisely. (#83099)
1 parent 8b56d9e commit 8a87f76

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "lldb/Core/ModuleSpec.h"
1919
#include "lldb/Host/HostInfo.h"
20+
#include "lldb/Host/SafeMachO.h"
2021
#include "lldb/Host/XML.h"
2122
#include "lldb/Symbol/Symbol.h"
2223
#include "lldb/Target/MemoryRegionInfo.h"
@@ -2147,8 +2148,20 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) {
21472148
if (!value.getAsInteger(16, cpu))
21482149
++num_keys_decoded;
21492150
} else if (name.equals("cpusubtype")) {
2150-
if (!value.getAsInteger(16, sub))
2151+
if (!value.getAsInteger(16, sub)) {
21512152
++num_keys_decoded;
2153+
// Workaround for pre-2024 Apple debugserver, which always
2154+
// returns arm64e on arm64e-capable hardware regardless of
2155+
// what the process is. This can be deleted at some point
2156+
// in the future.
2157+
if (cpu == llvm::MachO::CPU_TYPE_ARM64 &&
2158+
sub == llvm::MachO::CPU_SUBTYPE_ARM64E) {
2159+
if (GetGDBServerVersion())
2160+
if (m_gdb_server_version >= 1000 &&
2161+
m_gdb_server_version <= 1504)
2162+
sub = 0;
2163+
}
2164+
}
21522165
} else if (name.equals("triple")) {
21532166
StringExtractor extractor(value);
21542167
extractor.GetHexByteString(triple);

lldb/source/Target/Target.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "lldb/Expression/UtilityFunction.h"
3434
#include "lldb/Host/Host.h"
3535
#include "lldb/Host/PosixApi.h"
36-
#include "lldb/Host/SafeMachO.h"
3736
#include "lldb/Host/StreamFile.h"
3837
#include "lldb/Interpreter/CommandInterpreter.h"
3938
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -1572,13 +1571,6 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, bool set_platform,
15721571

15731572
if (m_arch.GetSpec().GetTriple() == other.GetTriple())
15741573
replace_local_arch = false;
1575-
// Workaround for for pre-2024 debugserver, which always
1576-
// returns arm64e on arm64e-capable hardware regardless of
1577-
// what the process is. This can be deleted at some point in
1578-
// the future.
1579-
if (!m_arch.GetSpec().GetMachOCPUSubType() &&
1580-
other.GetMachOCPUSubType() == llvm::MachO::CPU_SUBTYPE_ARM64E)
1581-
replace_local_arch = true;
15821574
}
15831575
}
15841576
}

0 commit comments

Comments
 (0)