emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master ffe4a5dac0: Extend support for debugging Emacs with LLDB


From: Gerd Moellmann
Subject: master ffe4a5dac0: Extend support for debugging Emacs with LLDB
Date: Fri, 15 Jul 2022 03:39:04 -0400 (EDT)

branch: master
commit ffe4a5dac0dbc9fd85064200ed7b46b4ab3b910a
Author: Gerd Möllmann <gerd@gnu.org>
Commit: Gerd Möllmann <gerd@gnu.org>

    Extend support for debugging Emacs with LLDB
    
    * etc/emacs_lldb.py: Handle case of Lisp_Object being a
    struct (--enable-lisp-type-checking).  Enable Emacs type category by
    default.  Expand children in type summary for Lisp_Object.
---
 etc/emacs_lldb.py | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/etc/emacs_lldb.py b/etc/emacs_lldb.py
index b8530915f8..64df137267 100644
--- a/etc/emacs_lldb.py
+++ b/etc/emacs_lldb.py
@@ -75,15 +75,24 @@ class Lisp_Object:
 
     # Object construction/initialization.
     def __init__(self, lisp_obj):
-        self.frame = lisp_obj.GetFrame()
         self.lisp_obj = lisp_obj
-        self.unsigned = lisp_obj.GetValueAsUnsigned()
+        self.frame = lisp_obj.GetFrame()
         self.lisp_type = None
         self.pvec_type = None
         self.value = None
+        self.init_unsigned()
         self.init_lisp_types()
         self.init_values()
 
+    def init_unsigned(self):
+        if self.lisp_obj.GetNumChildren() != 0:
+            # Lisp_Object is actually a struct.
+            lisp_word = self.lisp_obj.GetValueForExpressionPath(".i")
+            self.unsigned = lisp_word.GetValueAsUnsigned()
+        else:
+            self.unsigned = self.lisp_obj.GetValueAsUnsigned()
+        pass
+
     # Initialize self.lisp_type to the C Lisp_Type enumerator of the
     # Lisp_Object, as a string.  Initialize self.pvec_type likewise to
     # the pvec_type enumerator if the object is a vector-like, as a
@@ -222,17 +231,22 @@ def define_command (debugger, function):
 # and deleted in a similar way.
 def define_type_summary(debugger, regex, function):
     python_function = __name__ + "." + function.__name__
-    debugger.HandleCommand(f"type summary add "
+    debugger.HandleCommand(f"type summary add --expand "
                            f"--cascade true "
                            f"--category Emacs "
-                           f'--regex "{regex}" '
-                           f"--python-function {python_function}")
+                           f"--python-function {python_function} "
+                           + regex)
+
+# Enable a given category of type summary providers.
+def enable_type_category(debugger, category):
+    debugger.HandleCommand(f"type category enable {category}")
 
 # This function is called by LLDB to initialize the module.
 def __lldb_init_module(debugger, internal_dict):
     define_command(debugger, xbacktrace)
     define_command(debugger, xdebug_print)
     define_type_summary(debugger, "Lisp_Object", type_summary_Lisp_Object)
+    enable_type_category(debugger, "Emacs")
     print('Emacs debugging support has been installed.')
 
 # end.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]