Commit 6cda572a authored by Dmitry Antipov's avatar Dmitry Antipov
Browse files

* 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.
parent 8847a0de
......@@ -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 <dmantipov@yandex.ru>
 
......
......@@ -4721,12 +4721,12 @@ valid_pointer_p (void *p)
#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)
......
......@@ -2034,14 +2034,44 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment