aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog4
-rw-r--r--src/alloc.c12
-rw-r--r--src/print.c42
3 files changed, 46 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d0e08317fba..d4794667ead 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -2,6 +2,10 @@
2 2
3 * lisp.h (toplevel): Add two notices to the comment about 3 * lisp.h (toplevel): Add two notices to the comment about
4 defining a new Lisp data type. 4 defining a new Lisp data type.
5 * print.c (print_object): If Lisp_Save_Value object's pointer
6 is the address of a memory area containing Lisp_Objects, try
7 to print them.
8 * alloc.c (valid_lisp_object_p): Adjust comment.
5 9
62012-12-26 Dmitry Antipov <dmantipov@yandex.ru> 102012-12-26 Dmitry Antipov <dmantipov@yandex.ru>
7 11
diff --git a/src/alloc.c b/src/alloc.c
index 5a3ba465d81..f33c423ece7 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4721,12 +4721,12 @@ valid_pointer_p (void *p)
4721#endif 4721#endif
4722} 4722}
4723 4723
4724/* Return 2 if OBJ is a killed or special buffer object. 4724/* Return 2 if OBJ is a killed or special buffer object, 1 if OBJ is a
4725 Return 1 if OBJ is a valid lisp object. 4725 valid lisp object, 0 if OBJ is NOT a valid lisp object, or -1 if we
4726 Return 0 if OBJ is NOT a valid lisp object. 4726 cannot validate OBJ. This function can be quite slow, so its primary
4727 Return -1 if we cannot validate OBJ. 4727 use is the manual debugging. The only exception is print_object, where
4728 This function can be quite slow, 4728 we use it to check whether the memory referenced by the pointer of
4729 so it should only be used in code for manual debugging. */ 4729 Lisp_Save_Value object contains valid objects. */
4730 4730
4731int 4731int
4732valid_lisp_object_p (Lisp_Object obj) 4732valid_lisp_object_p (Lisp_Object obj)
diff --git a/src/print.c b/src/print.c
index 0788d110784..3df6c132c0a 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2043,14 +2043,44 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2043 break; 2043 break;
2044 2044
2045 case Lisp_Misc_Save_Value: 2045 case Lisp_Misc_Save_Value:
2046 strout ("#<save_value ", -1, -1, printcharfun);
2047 { 2046 {
2048 int len = sprintf (buf, "ptr=%p int=%"pD"d", 2047 int i;
2049 XSAVE_VALUE (obj)->pointer, 2048 struct Lisp_Save_Value *v = XSAVE_VALUE (obj);
2050 XSAVE_VALUE (obj)->integer); 2049
2051 strout (buf, len, len, printcharfun); 2050 strout ("#<save-value ", -1, -1, printcharfun);
2051 if (v->dogc)
2052 {
2053 int lim = min (v->integer, 8);
2054
2055 /* Try to print up to 8 objects we have saved. Although
2056 valid_lisp_object_p is slow, this shouldn't be a real
2057 bottleneck because such a saved values are quite rare. */
2058
2059 i = sprintf (buf, "with %"pD"d objects", v->integer);
2060 strout (buf, i, i, printcharfun);
2061
2062 for (i = 0; i < lim; i++)
2063 {
2064 Lisp_Object maybe = ((Lisp_Object *) v->pointer)[i];
2065
2066 if (valid_lisp_object_p (maybe) > 0)
2067 {
2068 PRINTCHAR (' ');
2069 print_object (maybe, printcharfun, escapeflag);
2070 }
2071 else
2072 strout (" <invalid>", -1, -1, printcharfun);
2073 }
2074 if (i == lim && i < v->integer)
2075 strout (" ...", 4, 4, printcharfun);
2076 }
2077 else
2078 {
2079 i = sprintf (buf, "ptr=%p int=%"pD"d", v->pointer, v->integer);
2080 strout (buf, i, i, printcharfun);
2081 }
2082 PRINTCHAR ('>');
2052 } 2083 }
2053 PRINTCHAR ('>');
2054 break; 2084 break;
2055 2085
2056 default: 2086 default: