Skip to content

[lldb] Add more ARM checks in TestLldbGdbServer.py #130277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2025

Conversation

DavidSpickett
Copy link
Collaborator

When #130034 enabled RISC-V here I noticed that these should run for ARM as well.

ARM only has 4 argument registers, which matches Arm's ABI for it: https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#core-registers

The ABI defines a link register LR, and I assume that's what becomes 'ra' in LLDB.

Tested on ARM and AArch64 Linux.

When llvm#130034 enabled
RISC-V here I noticed that these should run for ARM as well.

ARM only has 4 argument registers, which matches Arm's ABI for it:
https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#core-registers

The ABI defines a link register LR, and I assume that's what becomes
'ra' in LLDB.

Tested on ARM and AArch64 Linux.
@llvmbot
Copy link
Member

llvmbot commented Mar 7, 2025

@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)

Changes

When #130034 enabled RISC-V here I noticed that these should run for ARM as well.

ARM only has 4 argument registers, which matches Arm's ABI for it: https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#core-registers

The ABI defines a link register LR, and I assume that's what becomes 'ra' in LLDB.

Tested on ARM and AArch64 Linux.


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

2 Files Affected:

  • (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+7)
  • (modified) lldb/test/API/tools/lldb-server/TestLldbGdbServer.py (+4-4)
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 7d0e6e9a970eb..590024ef77119 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1344,6 +1344,13 @@ def isAArch64(self):
         arch = self.getArchitecture().lower()
         return arch in ["aarch64", "arm64", "arm64e"]
 
+    def isARM(self):
+        """Returns true if the architecture is ARM, meaning 32-bit ARM. Which could
+        be M profile, A profile Armv7-a, or the AArch32 mode of Armv8-a."""
+        return not self.isAArch64() and (
+            self.getArchitecture().lower().startswith("arm")
+        )
+
     def isAArch64SVE(self):
         return self.isAArch64() and "sve" in self.getCPUInfo()
 
diff --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index ce75e3e89e0a6..12c97bc62dcef 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -199,12 +199,12 @@ def test_qRegisterInfo_contains_required_generics_debugserver(self):
         if not self.isRISCV():
             self.assertIn("flags", generic_regs)
 
-        if self.isRISCV():
-            # Special RISC-V register for a return address
+        if self.isRISCV() or self.isAArch64() or self.isARM():
+            # Specific register for a return address
             self.assertIn("ra", generic_regs)
 
-            # RISC-V's function arguments registers
-            for i in range(1, 9):
+            # Function arguments registers
+            for i in range(1, 5 if self.isARM() else 9):
                 self.assertIn(f"arg{i}", generic_regs)
 
     def test_qRegisterInfo_contains_at_least_one_register_set(self):

Copy link
Contributor

@omjavaid omjavaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@DavidSpickett DavidSpickett merged commit fe544d4 into llvm:main Mar 10, 2025
12 checks passed
@DavidSpickett DavidSpickett deleted the lldb-armregs branch March 10, 2025 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants