Skip to content

Conversation

medismailben
Copy link
Member

This patch addresses 2 issues:

  1. It makes registers available on non-crashed threads all the time
  2. It fixes arm64 registers parsing for registers that don't use the x prefix (fp -> x29 / lr -> x30)

@llvmbot
Copy link
Member

llvmbot commented Jun 20, 2025

@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)

Changes

This patch addresses 2 issues:

  1. It makes registers available on non-crashed threads all the time
  2. It fixes arm64 registers parsing for registers that don't use the x prefix (fp -> x29 / lr -> x30)

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

2 Files Affected:

  • (modified) lldb/examples/python/crashlog.py (+4-4)
  • (modified) lldb/examples/python/crashlog_scripted_process.py (+7-5)
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index 5f07cda2892ab..bb20f3a25c1c1 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -777,10 +777,10 @@ def parse_threads(self, json_threads):
             if json_thread.get("triggered", False):
                 self.crashlog.crashed_thread_idx = idx
                 thread.crashed = True
-                if "threadState" in json_thread:
-                    thread.registers = self.parse_thread_registers(
-                        json_thread["threadState"]
-                    )
+            if "threadState" in json_thread:
+                thread.registers = self.parse_thread_registers(
+                    json_thread["threadState"]
+                )
             if "queue" in json_thread:
                 thread.queue = json_thread.get("queue")
             self.parse_frames(thread, json_thread.get("frames", []))
diff --git a/lldb/examples/python/crashlog_scripted_process.py b/lldb/examples/python/crashlog_scripted_process.py
index be0ed49d35904..f54a8df0479e7 100644
--- a/lldb/examples/python/crashlog_scripted_process.py
+++ b/lldb/examples/python/crashlog_scripted_process.py
@@ -123,11 +123,6 @@ def get_process_metadata(self):
 
 class CrashLogScriptedThread(ScriptedThread):
     def create_register_ctx(self):
-        if not self.has_crashed:
-            return dict.fromkeys(
-                [*map(lambda reg: reg["name"], self.register_info["registers"])], 0
-            )
-
         if not self.backing_thread or not len(self.backing_thread.registers):
             return dict.fromkeys(
                 [*map(lambda reg: reg["name"], self.register_info["registers"])], 0
@@ -135,8 +130,15 @@ def create_register_ctx(self):
 
         for reg in self.register_info["registers"]:
             reg_name = reg["name"]
+            reg_alt_name = None
+            if "alt-name" in reg:
+                reg_alt_name = reg["alt-name"]
             if reg_name in self.backing_thread.registers:
                 self.register_ctx[reg_name] = self.backing_thread.registers[reg_name]
+            elif reg_alt_name and reg_alt_name in self.backing_thread.registers:
+                self.register_ctx[reg_name] = self.backing_thread.registers[
+                    reg_alt_name
+                ]
             else:
                 self.register_ctx[reg_name] = 0
 

This patch addresses some register parsing issue where certain registers
would not be prefixed by 'x' but rather they where listed using their
alternate name (fp instead of x29, lr instead of x30, etc.)

rdar://149482608

Signed-off-by: Med Ismail Bennani <[email protected]>
This patch change the current crashlog behavior to always load the
register context, even for the non-crashed threads.

This is cheap to compute since it doesn't requires any module loading
and can be helful to investigate some crashes.

rdar://149481943

Signed-off-by: Med Ismail Bennani <[email protected]>
@medismailben medismailben force-pushed the crashlog-arm-registers branch from dee0b40 to fdbeca5 Compare June 20, 2025 21:45
@medismailben medismailben merged commit 1db9afb into llvm:main Jun 20, 2025
7 checks passed
medismailben added a commit to medismailben/llvm-project that referenced this pull request Sep 5, 2025
…llvm#145104)

This patch addresses 2 issues:
1. It makes registers available on non-crashed threads all the time
2. It fixes arm64 registers parsing for registers that don't use the `x`
prefix (`fp` -> `x29` / `lr` -> `x30`)

---------

Signed-off-by: Med Ismail Bennani <[email protected]>
(cherry picked from commit 1db9afb)
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