changeset 66779:06e83e43c727

(safe_debug_print): New function to be called from gdb to print Lisp objects; use valid_lisp_object_p to avoid crashing if user tries to print something which is not a Lisp object.
author Kim F. Storm <storm@cua.dk>
date Wed, 09 Nov 2005 23:14:32 +0000
parents aa81a85c6d8e
children 5bb175fa0f8e
files src/print.c
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/print.c	Wed Nov 09 23:14:19 2005 +0000
+++ b/src/print.c	Wed Nov 09 23:14:32 2005 +0000
@@ -970,6 +970,26 @@
   Fprin1 (arg, Qexternal_debugging_output);
   fprintf (stderr, "\r\n");
 }
+
+void
+safe_debug_print (arg)
+     Lisp_Object arg;
+{
+  int valid = valid_lisp_object_p (arg);
+
+  if (valid > 0)
+    debug_print (arg);
+  else
+    fprintf (stderr, "#<%s_LISP_OBJECT 0x%08lx>\r\n",
+	     !valid ? "INVALID" : "SOME",
+#ifdef NO_UNION_TYPE
+	     (unsigned long) arg
+#else
+	     (unsigned long) arg.i
+#endif
+	     );
+}
+
 
 DEFUN ("error-message-string", Ferror_message_string, Serror_message_string,
        1, 1, 0,