aboutsummaryrefslogtreecommitdiffstats
path: root/src/print.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c73
1 files changed, 59 insertions, 14 deletions
diff --git a/src/print.c b/src/print.c
index b5e45438577..8420f8075a5 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2036,8 +2036,9 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2036 PRINTCHAR ('>'); 2036 PRINTCHAR ('>');
2037 break; 2037 break;
2038 2038
2039 /* Remaining cases shouldn't happen in normal usage, but let's print 2039 /* Remaining cases shouldn't happen in normal usage, but let's
2040 them anyway for the benefit of the debugger. */ 2040 print them anyway for the benefit of the debugger. */
2041
2041 case Lisp_Misc_Free: 2042 case Lisp_Misc_Free:
2042 strout ("#<misc free cell>", -1, -1, printcharfun); 2043 strout ("#<misc free cell>", -1, -1, printcharfun);
2043 break; 2044 break;
@@ -2048,20 +2049,28 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2048 struct Lisp_Save_Value *v = XSAVE_VALUE (obj); 2049 struct Lisp_Save_Value *v = XSAVE_VALUE (obj);
2049 2050
2050 strout ("#<save-value ", -1, -1, printcharfun); 2051 strout ("#<save-value ", -1, -1, printcharfun);
2051 if (v->dogc) 2052
2053 if (v->area)
2052 { 2054 {
2053 int lim = min (v->integer, 8); 2055 ptrdiff_t amount = v->data[1].integer;
2054 2056
2055 /* Try to print up to 8 objects we have saved. Although 2057#if GC_MARK_STACK
2056 valid_lisp_object_p is slow, this shouldn't be a real 2058
2057 bottleneck because such a saved values are quite rare. */ 2059 /* If GC_MARK_STACK, valid_lisp_object_p is quite reliable,
2060 and so we try to print up to 8 objects we have saved.
2061 Although valid_lisp_object_p is slow, this shouldn't be
2062 a real bottleneck because we do not use this code under
2063 normal circumstances. */
2058 2064
2059 i = sprintf (buf, "with %"pD"d objects", v->integer); 2065 int limit = min (amount, 8);
2066 Lisp_Object *area = v->data[0].pointer;
2067
2068 i = sprintf (buf, "with %"pD"d objects", amount);
2060 strout (buf, i, i, printcharfun); 2069 strout (buf, i, i, printcharfun);
2061 2070
2062 for (i = 0; i < lim; i++) 2071 for (i = 0; i < limit; i++)
2063 { 2072 {
2064 Lisp_Object maybe = ((Lisp_Object *) v->pointer)[i]; 2073 Lisp_Object maybe = area[i];
2065 2074
2066 if (valid_lisp_object_p (maybe) > 0) 2075 if (valid_lisp_object_p (maybe) > 0)
2067 { 2076 {
@@ -2071,13 +2080,49 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2071 else 2080 else
2072 strout (" <invalid>", -1, -1, printcharfun); 2081 strout (" <invalid>", -1, -1, printcharfun);
2073 } 2082 }
2074 if (i == lim && i < v->integer) 2083 if (i == limit && i < amount)
2075 strout (" ...", 4, 4, printcharfun); 2084 strout (" ...", 4, 4, printcharfun);
2085
2086#else /* not GC_MARK_STACK */
2087
2088 /* If !GC_MARK_STACK, we have no reliable way to find
2089 whether Lisp_Object pointers points to an initialized
2090 objects, and so we do not ever trying to print them. */
2091
2092 i = sprintf (buf, "with %"pD"d objects", amount);
2093 strout (buf, i, i, printcharfun);
2094
2095#endif /* GC_MARK_STACK */
2076 } 2096 }
2077 else 2097 else
2078 { 2098 {
2079 i = sprintf (buf, "ptr=%p int=%"pD"d", v->pointer, v->integer); 2099 /* Print each `data[N]' slot according to its type. */
2080 strout (buf, i, i, printcharfun); 2100
2101#define PRINTX(index) \
2102 do { \
2103 i = 0; \
2104 if (v->type ## index == SAVE_UNUSED) \
2105 i = sprintf (buf, "<unused>"); \
2106 else if (v->type ## index == SAVE_INTEGER) \
2107 i = sprintf (buf, "<integer %"pD"d>", v->data[index].integer); \
2108 else if (v->type ## index == SAVE_POINTER) \
2109 i = sprintf (buf, "<pointer %p>", v->data[index].pointer); \
2110 else /* SAVE_OBJECT */ \
2111 print_object (v->data[index].object, printcharfun, escapeflag); \
2112 if (i) \
2113 strout (buf, i, i, printcharfun); \
2114 } while (0)
2115
2116 PRINTX (0);
2117 PRINTCHAR (' ');
2118 PRINTX (1);
2119 PRINTCHAR (' ');
2120 PRINTX (2);
2121 PRINTCHAR (' ');
2122 PRINTX (3);
2123
2124#undef PRINTX
2125
2081 } 2126 }
2082 PRINTCHAR ('>'); 2127 PRINTCHAR ('>');
2083 } 2128 }