]> git.eshelyaron.com Git - emacs.git/commitdiff
Extend support for debugging Emacs with LLDB
authorGerd Möllmann <gerd@gnu.org>
Fri, 15 Jul 2022 07:36:10 +0000 (09:36 +0200)
committerGerd Möllmann <gerd@gnu.org>
Fri, 15 Jul 2022 07:36:10 +0000 (09:36 +0200)
* 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

index b8530915f81c1a0b27c5c4c1343b4dfebd1c7fd9..64df13726713c8c66143253676cb2c5f4a721769 100644 (file)
@@ -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.