[Lldb-commits] [lldb] Change debugserver to report the cpu(sub)type of process, not the host. (PR #82938)

2024-02-25 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl created 
https://github.com/llvm/llvm-project/pull/82938

This reapplies [Replace ArchSpec::PiecewiseCompare() with 
Triple::operator==()](https://github.com/llvm/llvm-project/commit/5c9e53d45ba948b8a5e8416aa9b3322c87fc46c8),
 with an additional fix in debugserver.

[Change debugserver to report the cpu(sub)type of process, not the 
host.](https://github.com/llvm/llvm-project/commit/3ca8611705613f4c483e34c75dfa1dfad1572f77)
 
This way debugserver can correctly report qProcessInfo for arm64
processes on arm64e-capable hosts.

Patch implemented with help from Jason Molenda!

>From 5c9e53d45ba948b8a5e8416aa9b3322c87fc46c8 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Fri, 23 Feb 2024 09:58:17 -0800
Subject: [PATCH 1/2] Replace ArchSpec::PiecewiseCompare() with
 Triple::operator==()

Looking ast the definition of both functions this is *almost* an NFC
change, except that Triple also looks at the SubArch (important) and
ObjectFormat (less so).

This fixes a bug that only manifests with how Xcode uses the SBAPI to
attach to a process by name: it guesses the architecture based on the
system. If the system is arm64 and the Process is arm64e Target fails
to update the triple because it deemed the two to be equivalent.

rdar://123338218
---
 lldb/include/lldb/Utility/ArchSpec.h  |  5 
 lldb/source/Target/Target.cpp |  8 +-
 lldb/source/Utility/ArchSpec.cpp  | 17 ---
 lldb/test/API/macosx/arm64e-attach/Makefile   |  2 ++
 .../macosx/arm64e-attach/TestArm64eAttach.py  | 28 +++
 lldb/test/API/macosx/arm64e-attach/main.c |  2 ++
 6 files changed, 33 insertions(+), 29 deletions(-)
 create mode 100644 lldb/test/API/macosx/arm64e-attach/Makefile
 create mode 100644 lldb/test/API/macosx/arm64e-attach/TestArm64eAttach.py
 create mode 100644 lldb/test/API/macosx/arm64e-attach/main.c

diff --git a/lldb/include/lldb/Utility/ArchSpec.h 
b/lldb/include/lldb/Utility/ArchSpec.h
index a226a3a5a9b71d..50830b889b9115 100644
--- a/lldb/include/lldb/Utility/ArchSpec.h
+++ b/lldb/include/lldb/Utility/ArchSpec.h
@@ -505,11 +505,6 @@ class ArchSpec {
 
   bool IsFullySpecifiedTriple() const;
 
-  void PiecewiseTripleCompare(const ArchSpec &other, bool &arch_different,
-  bool &vendor_different, bool &os_different,
-  bool &os_version_different,
-  bool &env_different) const;
-
   /// Detect whether this architecture uses thumb code exclusively
   ///
   /// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can only execute
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index e17bfcb5d5e2ad..e982a30a3ae4ff 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1568,14 +1568,8 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, 
bool set_platform,
 
   if (m_arch.GetSpec().IsCompatibleMatch(other)) {
 compatible_local_arch = true;
-bool arch_changed, vendor_changed, os_changed, os_ver_changed,
-env_changed;
 
-m_arch.GetSpec().PiecewiseTripleCompare(other, arch_changed,
-vendor_changed, os_changed,
-os_ver_changed, env_changed);
-
-if (!arch_changed && !vendor_changed && !os_changed && !env_changed)
+if (m_arch.GetSpec().GetTriple() == other.GetTriple())
   replace_local_arch = false;
   }
 }
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index fb0e985a0d5657..07ef435ef451d2 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -1421,23 +1421,6 @@ bool ArchSpec::IsFullySpecifiedTriple() const {
   return true;
 }
 
-void ArchSpec::PiecewiseTripleCompare(
-const ArchSpec &other, bool &arch_different, bool &vendor_different,
-bool &os_different, bool &os_version_different, bool &env_different) const 
{
-  const llvm::Triple &me(GetTriple());
-  const llvm::Triple &them(other.GetTriple());
-
-  arch_different = (me.getArch() != them.getArch());
-
-  vendor_different = (me.getVendor() != them.getVendor());
-
-  os_different = (me.getOS() != them.getOS());
-
-  os_version_different = (me.getOSMajorVersion() != them.getOSMajorVersion());
-
-  env_different = (me.getEnvironment() != them.getEnvironment());
-}
-
 bool ArchSpec::IsAlwaysThumbInstructions() const {
   std::string Status;
   if (GetTriple().getArch() == llvm::Triple::arm ||
diff --git a/lldb/test/API/macosx/arm64e-attach/Makefile 
b/lldb/test/API/macosx/arm64e-attach/Makefile
new file mode 100644
index 00..c9319d6e6888a4
--- /dev/null
+++ b/lldb/test/API/macosx/arm64e-attach/Makefile
@@ -0,0 +1,2 @@
+C_SOURCES := main.c
+include Makefile.rules
diff --git a/lldb/test/API/macosx/arm64e-attach/TestArm64eAttach.py 
b/lldb/test/API/macosx/arm64e-attach/TestArm64eAttach.py
new fil

[Lldb-commits] [lldb] Change debugserver to report the cpu(sub)type of process, not the host. (PR #82938)

2024-02-25 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

This reapplies [Replace ArchSpec::PiecewiseCompare() with 
Triple::operator==()](https://github.com/llvm/llvm-project/commit/5c9e53d45ba948b8a5e8416aa9b3322c87fc46c8),
 with an additional fix in debugserver.

[Change debugserver to report the cpu(sub)type of process, not the 
host.](https://github.com/llvm/llvm-project/commit/3ca8611705613f4c483e34c75dfa1dfad1572f77)
 
This way debugserver can correctly report qProcessInfo for arm64
processes on arm64e-capable hosts.

Patch implemented with help from Jason Molenda!

---
Full diff: https://github.com/llvm/llvm-project/pull/82938.diff


11 Files Affected:

- (modified) lldb/include/lldb/Utility/ArchSpec.h (-5) 
- (modified) lldb/source/Target/Target.cpp (+9-7) 
- (modified) lldb/source/Utility/ArchSpec.cpp (-17) 
- (added) lldb/test/API/macosx/arm64e-attach/Makefile (+7) 
- (added) lldb/test/API/macosx/arm64e-attach/TestArm64eAttach.py (+38) 
- (added) lldb/test/API/macosx/arm64e-attach/main.c (+2) 
- (modified) lldb/tools/debugserver/source/DNB.cpp (+8) 
- (modified) lldb/tools/debugserver/source/DNB.h (+2) 
- (modified) lldb/tools/debugserver/source/MacOSX/MachProcess.h (+2) 
- (modified) lldb/tools/debugserver/source/MacOSX/MachProcess.mm (+17) 
- (modified) lldb/tools/debugserver/source/RNBRemote.cpp (+58-48) 


``diff
diff --git a/lldb/include/lldb/Utility/ArchSpec.h 
b/lldb/include/lldb/Utility/ArchSpec.h
index a226a3a5a9b71d..50830b889b9115 100644
--- a/lldb/include/lldb/Utility/ArchSpec.h
+++ b/lldb/include/lldb/Utility/ArchSpec.h
@@ -505,11 +505,6 @@ class ArchSpec {
 
   bool IsFullySpecifiedTriple() const;
 
-  void PiecewiseTripleCompare(const ArchSpec &other, bool &arch_different,
-  bool &vendor_different, bool &os_different,
-  bool &os_version_different,
-  bool &env_different) const;
-
   /// Detect whether this architecture uses thumb code exclusively
   ///
   /// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can only execute
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index e17bfcb5d5e2ad..089915cab4915a 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -33,6 +33,7 @@
 #include "lldb/Expression/UtilityFunction.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/PosixApi.h"
+#include "lldb/Host/SafeMachO.h"
 #include "lldb/Host/StreamFile.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
@@ -1568,15 +1569,16 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, 
bool set_platform,
 
   if (m_arch.GetSpec().IsCompatibleMatch(other)) {
 compatible_local_arch = true;
-bool arch_changed, vendor_changed, os_changed, os_ver_changed,
-env_changed;
 
-m_arch.GetSpec().PiecewiseTripleCompare(other, arch_changed,
-vendor_changed, os_changed,
-os_ver_changed, env_changed);
-
-if (!arch_changed && !vendor_changed && !os_changed && !env_changed)
+if (m_arch.GetSpec().GetTriple() == other.GetTriple())
   replace_local_arch = false;
+// Workaround for for pre-2024 debugserver, which always
+// returns arm64e on arm64e-capable hardware regardless of
+// what the process is. This can be deleted at some point in
+// the future.
+if (!m_arch.GetSpec().GetMachOCPUSubType() &&
+other.GetMachOCPUSubType() == llvm::MachO::CPU_SUBTYPE_ARM64E)
+  replace_local_arch = true;
   }
 }
   }
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index fb0e985a0d5657..07ef435ef451d2 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -1421,23 +1421,6 @@ bool ArchSpec::IsFullySpecifiedTriple() const {
   return true;
 }
 
-void ArchSpec::PiecewiseTripleCompare(
-const ArchSpec &other, bool &arch_different, bool &vendor_different,
-bool &os_different, bool &os_version_different, bool &env_different) const 
{
-  const llvm::Triple &me(GetTriple());
-  const llvm::Triple &them(other.GetTriple());
-
-  arch_different = (me.getArch() != them.getArch());
-
-  vendor_different = (me.getVendor() != them.getVendor());
-
-  os_different = (me.getOS() != them.getOS());
-
-  os_version_different = (me.getOSMajorVersion() != them.getOSMajorVersion());
-
-  env_different = (me.getEnvironment() != them.getEnvironment());
-}
-
 bool ArchSpec::IsAlwaysThumbInstructions() const {
   std::string Status;
   if (GetTriple().getArch() == llvm::Triple::arm ||
diff --git a/lldb/test/API/macosx/arm64e-attach/Makefile 
b/lldb/test/API/macosx/arm64e-attach/Makefile
new file mode 100644
index 00..248a93e0324883
--- /dev/null
+++ b/lldb/test/API/macosx/arm64e-attach/Makefile
@@ -0,

[Lldb-commits] [lldb] Change debugserver to report the cpu(sub)type of process, not the host. (PR #82938)

2024-02-25 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/82938

>From 5c9e53d45ba948b8a5e8416aa9b3322c87fc46c8 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Fri, 23 Feb 2024 09:58:17 -0800
Subject: [PATCH 1/2] Replace ArchSpec::PiecewiseCompare() with
 Triple::operator==()

Looking ast the definition of both functions this is *almost* an NFC
change, except that Triple also looks at the SubArch (important) and
ObjectFormat (less so).

This fixes a bug that only manifests with how Xcode uses the SBAPI to
attach to a process by name: it guesses the architecture based on the
system. If the system is arm64 and the Process is arm64e Target fails
to update the triple because it deemed the two to be equivalent.

rdar://123338218
---
 lldb/include/lldb/Utility/ArchSpec.h  |  5 
 lldb/source/Target/Target.cpp |  8 +-
 lldb/source/Utility/ArchSpec.cpp  | 17 ---
 lldb/test/API/macosx/arm64e-attach/Makefile   |  2 ++
 .../macosx/arm64e-attach/TestArm64eAttach.py  | 28 +++
 lldb/test/API/macosx/arm64e-attach/main.c |  2 ++
 6 files changed, 33 insertions(+), 29 deletions(-)
 create mode 100644 lldb/test/API/macosx/arm64e-attach/Makefile
 create mode 100644 lldb/test/API/macosx/arm64e-attach/TestArm64eAttach.py
 create mode 100644 lldb/test/API/macosx/arm64e-attach/main.c

diff --git a/lldb/include/lldb/Utility/ArchSpec.h 
b/lldb/include/lldb/Utility/ArchSpec.h
index a226a3a5a9b71d..50830b889b9115 100644
--- a/lldb/include/lldb/Utility/ArchSpec.h
+++ b/lldb/include/lldb/Utility/ArchSpec.h
@@ -505,11 +505,6 @@ class ArchSpec {
 
   bool IsFullySpecifiedTriple() const;
 
-  void PiecewiseTripleCompare(const ArchSpec &other, bool &arch_different,
-  bool &vendor_different, bool &os_different,
-  bool &os_version_different,
-  bool &env_different) const;
-
   /// Detect whether this architecture uses thumb code exclusively
   ///
   /// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can only execute
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index e17bfcb5d5e2ad..e982a30a3ae4ff 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1568,14 +1568,8 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, 
bool set_platform,
 
   if (m_arch.GetSpec().IsCompatibleMatch(other)) {
 compatible_local_arch = true;
-bool arch_changed, vendor_changed, os_changed, os_ver_changed,
-env_changed;
 
-m_arch.GetSpec().PiecewiseTripleCompare(other, arch_changed,
-vendor_changed, os_changed,
-os_ver_changed, env_changed);
-
-if (!arch_changed && !vendor_changed && !os_changed && !env_changed)
+if (m_arch.GetSpec().GetTriple() == other.GetTriple())
   replace_local_arch = false;
   }
 }
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index fb0e985a0d5657..07ef435ef451d2 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -1421,23 +1421,6 @@ bool ArchSpec::IsFullySpecifiedTriple() const {
   return true;
 }
 
-void ArchSpec::PiecewiseTripleCompare(
-const ArchSpec &other, bool &arch_different, bool &vendor_different,
-bool &os_different, bool &os_version_different, bool &env_different) const 
{
-  const llvm::Triple &me(GetTriple());
-  const llvm::Triple &them(other.GetTriple());
-
-  arch_different = (me.getArch() != them.getArch());
-
-  vendor_different = (me.getVendor() != them.getVendor());
-
-  os_different = (me.getOS() != them.getOS());
-
-  os_version_different = (me.getOSMajorVersion() != them.getOSMajorVersion());
-
-  env_different = (me.getEnvironment() != them.getEnvironment());
-}
-
 bool ArchSpec::IsAlwaysThumbInstructions() const {
   std::string Status;
   if (GetTriple().getArch() == llvm::Triple::arm ||
diff --git a/lldb/test/API/macosx/arm64e-attach/Makefile 
b/lldb/test/API/macosx/arm64e-attach/Makefile
new file mode 100644
index 00..c9319d6e6888a4
--- /dev/null
+++ b/lldb/test/API/macosx/arm64e-attach/Makefile
@@ -0,0 +1,2 @@
+C_SOURCES := main.c
+include Makefile.rules
diff --git a/lldb/test/API/macosx/arm64e-attach/TestArm64eAttach.py 
b/lldb/test/API/macosx/arm64e-attach/TestArm64eAttach.py
new file mode 100644
index 00..0dc8700ed02dd8
--- /dev/null
+++ b/lldb/test/API/macosx/arm64e-attach/TestArm64eAttach.py
@@ -0,0 +1,28 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestArm64eAttach(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+# On Darwin systems, arch arm64e means ARMv8.3 with ptrauth ABI used.
+@skipIf(archs=no_match(["arm64e"]))
+def test(self):
+# Skip this test if not run

[Lldb-commits] [lldb] Change debugserver to report the cpu(sub)type of process, not the host. (PR #82938)

2024-02-25 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
3f91bdfdd50aa4eaf1d3e49cf797220cfeccaf16...aecc7f751328a11c12bb910b1e30cab41b98a146
 lldb/test/API/macosx/arm64e-attach/TestArm64eAttach.py
``





View the diff from darker here.


``diff
--- TestArm64eAttach.py 2024-02-25 23:15:23.00 +
+++ TestArm64eAttach.py 2024-02-25 23:17:50.411840 +
@@ -12,11 +12,11 @@
 def test(self):
 # Skip this test if not running on AArch64 target that supports PAC
 if not self.isAArch64PAuth():
 self.skipTest("Target must support pointer authentication.")
 
-packets = self.getBuildArtifact('packet.log')
+packets = self.getBuildArtifact("packet.log")
 self.expect('log enable -f "%s" gdb-remote packets' % packets)
 
 self.build()
 popen = self.spawnSubprocess(self.getBuildArtifact(), [])
 
@@ -25,14 +25,16 @@
 target = self.dbg.CreateTarget("", "arm64", "", True, error)
 listener = lldb.SBListener("my.attach.listener")
 process = target.AttachToProcessWithID(listener, popen.pid, error)
 self.assertSuccess(error)
 self.assertTrue(process, PROCESS_IS_VALID)
-self.assertEqual(target.GetTriple().split('-')[0], "arm64e",
- "target triple is updated correctly")
+self.assertEqual(
+target.GetTriple().split("-")[0],
+"arm64e",
+"target triple is updated correctly",
+)
 error = process.Kill()
 self.assertSuccess(error)
 
 # Test debugserver behavior.
 self.filecheck('platform shell cat "%s"' % packets, __file__)
 # CHECK: 
cputype:10c;cpusubtype:2;ptrsize:8;ostype:macosx;vendor:apple;endian:little;
-

``




https://github.com/llvm/llvm-project/pull/82938
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change debugserver to report the cpu(sub)type of process, not the host. (PR #82938)

2024-02-25 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere edited 
https://github.com/llvm/llvm-project/pull/82938
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change debugserver to report the cpu(sub)type of process, not the host. (PR #82938)

2024-02-25 Thread Jonas Devlieghere via lldb-commits


@@ -1568,15 +1569,16 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, 
bool set_platform,
 
   if (m_arch.GetSpec().IsCompatibleMatch(other)) {
 compatible_local_arch = true;
-bool arch_changed, vendor_changed, os_changed, os_ver_changed,
-env_changed;
 
-m_arch.GetSpec().PiecewiseTripleCompare(other, arch_changed,
-vendor_changed, os_changed,
-os_ver_changed, env_changed);
-
-if (!arch_changed && !vendor_changed && !os_changed && !env_changed)
+if (m_arch.GetSpec().GetTriple() == other.GetTriple())
   replace_local_arch = false;
+// Workaround for for pre-2024 debugserver, which always
+// returns arm64e on arm64e-capable hardware regardless of
+// what the process is. This can be deleted at some point in
+// the future.

JDevlieghere wrote:

@jasonmolenda I really wish we could report a version number from debugserver 
so we don't have to make guesses as to what's supported and what not. This is 
the second time this has come up in a few months (I think previously this came 
up in the context of large watchpoints?). Maybe it's time to bite the bullet? 

https://github.com/llvm/llvm-project/pull/82938
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change debugserver to report the cpu(sub)type of process, not the host. (PR #82938)

2024-02-25 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,7 @@
+C_SOURCES := main.c
+
+# Uncomment this for q&d local debugging.

JDevlieghere wrote:

Q&D?

https://github.com/llvm/llvm-project/pull/82938
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change debugserver to report the cpu(sub)type of process, not the host. (PR #82938)

2024-02-25 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere commented:

Overall this looks good but we should verify that this doesn't regress running 
unmodified iOS binaries on macOS (https://reviews.llvm.org/D117340, 
https://reviews.llvm.org/D121444). It was really tricky to get that right and 
it's all based on the binary and host triples. We should at least hand-test 
before & after this patch and possibly report an arm64e triple in 
TestPlatformMacOSX.py. 

https://github.com/llvm/llvm-project/pull/82938
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change debugserver to report the cpu(sub)type of process, not the host. (PR #82938)

2024-02-25 Thread Jason Molenda via lldb-commits


@@ -1568,15 +1569,16 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, 
bool set_platform,
 
   if (m_arch.GetSpec().IsCompatibleMatch(other)) {
 compatible_local_arch = true;
-bool arch_changed, vendor_changed, os_changed, os_ver_changed,
-env_changed;
 
-m_arch.GetSpec().PiecewiseTripleCompare(other, arch_changed,
-vendor_changed, os_changed,
-os_ver_changed, env_changed);
-
-if (!arch_changed && !vendor_changed && !os_changed && !env_changed)
+if (m_arch.GetSpec().GetTriple() == other.GetTriple())
   replace_local_arch = false;
+// Workaround for for pre-2024 debugserver, which always
+// returns arm64e on arm64e-capable hardware regardless of
+// what the process is. This can be deleted at some point in
+// the future.

jasonmolenda wrote:

The packet is poorly defined to return a "version" which lldb expects to be 
able to convert to an integer, so what we get today with an Xcode debugserver:

```
(lldb) process plugin packet send qGDBServerVersion
  packet: qGDBServerVersion
response: name:debugserver;version:1500;
```

With github main we'll get the llvm version, so `name:debugserver;version:19;`, 
lol.

This is one of those "version has never been properly/really defined" so we 
could add a "vendor" (llvm.org, apple, linode, etc) and a version *string* that 
might contain more than the major number, the vendor string informing how to 
interpret the version.

https://github.com/llvm/llvm-project/pull/82938
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change debugserver to report the cpu(sub)type of process, not the host. (PR #82938)

2024-02-25 Thread Jason Molenda via lldb-commits


@@ -26,3 +31,8 @@ def test(self):
  "target triple is updated correctly")
 error = process.Kill()
 self.assertSuccess(error)
+
+# Test debugserver behavior.
+self.filecheck('platform shell cat "%s"' % packets, __file__)
+# CHECK: 
cputype:10c;cpusubtype:2;ptrsize:8;ostype:macosx;vendor:apple;endian:little;

jasonmolenda wrote:

this is could be done, but you could also just `self.expect("process plugin 
packet send qProcessInfo", substrs=["cputype:10c;cpusubtype:2;"])`.  We may 
add additional keys to this response in the future so I'm not sure I like 
matching all of the keys.

https://github.com/llvm/llvm-project/pull/82938
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change debugserver to report the cpu(sub)type of process, not the host. (PR #82938)

2024-02-25 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

The debugserver changes all look good to me, fwiw. My only feedback is about 
the API test.

https://github.com/llvm/llvm-project/pull/82938
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change debugserver to report the cpu(sub)type of process, not the host. (PR #82938)

2024-02-25 Thread Jason Molenda via lldb-commits


@@ -1568,15 +1569,16 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, 
bool set_platform,
 
   if (m_arch.GetSpec().IsCompatibleMatch(other)) {
 compatible_local_arch = true;
-bool arch_changed, vendor_changed, os_changed, os_ver_changed,
-env_changed;
 
-m_arch.GetSpec().PiecewiseTripleCompare(other, arch_changed,
-vendor_changed, os_changed,
-os_ver_changed, env_changed);
-
-if (!arch_changed && !vendor_changed && !os_changed && !env_changed)
+if (m_arch.GetSpec().GetTriple() == other.GetTriple())
   replace_local_arch = false;
+// Workaround for for pre-2024 debugserver, which always
+// returns arm64e on arm64e-capable hardware regardless of
+// what the process is. This can be deleted at some point in
+// the future.

jasonmolenda wrote:

Another way of saying this -- we DO have a version packet, but it is kinda not 
doing what we need, so maybe we should redefine what it returns.  We added it 
but never actually used it in lldb, we can change what it returns without 
breaking anything.

https://github.com/llvm/llvm-project/pull/82938
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits