emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r111339: * print.c (print_object): If


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111339: * print.c (print_object): If Lisp_Save_Value object's pointer
Date: Wed, 26 Dec 2012 19:40:19 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111339
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Wed 2012-12-26 19:40:19 +0400
message:
  * print.c (print_object): If Lisp_Save_Value object's pointer
  is the address of a memory area containing Lisp_Objects, try
  to print them.
  * alloc.c (valid_lisp_object_p): Adjust comment.
modified:
  src/ChangeLog
  src/alloc.c
  src/print.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-12-26 14:10:11 +0000
+++ b/src/ChangeLog     2012-12-26 15:40:19 +0000
@@ -2,6 +2,10 @@
 
        * lisp.h (toplevel): Add two notices to the comment about
        defining a new Lisp data type.
+       * print.c (print_object): If Lisp_Save_Value object's pointer
+       is the address of a memory area containing Lisp_Objects, try
+       to print them.
+       * alloc.c (valid_lisp_object_p): Adjust comment.
 
 2012-12-26  Dmitry Antipov  <address@hidden>
 

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2012-12-10 12:08:02 +0000
+++ b/src/alloc.c       2012-12-26 15:40:19 +0000
@@ -4721,12 +4721,12 @@
 #endif
 }
 
-/* Return 2 if OBJ is a killed or special buffer object.
-   Return 1 if OBJ is a valid lisp object.
-   Return 0 if OBJ is NOT a valid lisp object.
-   Return -1 if we cannot validate OBJ.
-   This function can be quite slow,
-   so it should only be used in code for manual debugging.  */
+/* Return 2 if OBJ is a killed or special buffer object, 1 if OBJ is a
+   valid lisp object, 0 if OBJ is NOT a valid lisp object, or -1 if we
+   cannot validate OBJ.  This function can be quite slow, so its primary
+   use is the manual debugging.  The only exception is print_object, where
+   we use it to check whether the memory referenced by the pointer of
+   Lisp_Save_Value object contains valid objects.  */
 
 int
 valid_lisp_object_p (Lisp_Object obj)

=== modified file 'src/print.c'
--- a/src/print.c       2012-11-08 21:58:55 +0000
+++ b/src/print.c       2012-12-26 15:40:19 +0000
@@ -2034,14 +2034,44 @@
          break;
 
        case Lisp_Misc_Save_Value:
-         strout ("#<save_value ", -1, -1, printcharfun);
          {
-           int len = sprintf (buf, "ptr=%p int=%"pD"d",
-                              XSAVE_VALUE (obj)->pointer,
-                              XSAVE_VALUE (obj)->integer);
-           strout (buf, len, len, printcharfun);
+           int i;
+           struct Lisp_Save_Value *v = XSAVE_VALUE (obj);
+
+           strout ("#<save-value ", -1, -1, printcharfun);
+           if (v->dogc)
+             {
+               int lim = min (v->integer, 8);
+               
+               /* Try to print up to 8 objects we have saved.  Although
+                  valid_lisp_object_p is slow, this shouldn't be a real
+                  bottleneck because such a saved values are quite rare.  */
+
+               i = sprintf (buf, "with %"pD"d objects", v->integer);
+               strout (buf, i, i, printcharfun);
+
+               for (i = 0; i < lim; i++)
+                 {
+                   Lisp_Object maybe = ((Lisp_Object *) v->pointer)[i];
+
+                   if (valid_lisp_object_p (maybe))
+                     {
+                       PRINTCHAR (' ');
+                       print_object (maybe, printcharfun, escapeflag);
+                     }
+                   else
+                     strout (" <invalid>", -1, -1, printcharfun);
+                 }
+               if (i == lim && i < v->integer)
+                 strout (" ...", 4, 4, printcharfun);
+             }
+           else
+             {
+               i = sprintf (buf, "ptr=%p int=%"pD"d", v->pointer, v->integer);
+               strout (buf, i, i, printcharfun);
+             }
+           PRINTCHAR ('>');
          }
-         PRINTCHAR ('>');
          break;
 
        default:


reply via email to

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