changeset 5146:88bd4f3ef8e4

make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-03-15 Ben Wing <ben@xemacs.org> * alloc.c: * alloc.c (c_readonly): * alloc.c (deadbeef_memory): * alloc.c (make_compiled_function): * alloc.c (make_button_data): * alloc.c (make_motion_data): * alloc.c (make_process_data): * alloc.c (make_timeout_data): * alloc.c (make_magic_data): * alloc.c (make_magic_eval_data): * alloc.c (make_eval_data): * alloc.c (make_misc_user_data): * alloc.c (noseeum_make_marker): * alloc.c (ADDITIONAL_FREE_string): * alloc.c (common_init_alloc_early): * alloc.c (init_alloc_once_early): * bytecode.c (print_compiled_function): * bytecode.c (mark_compiled_function): * casetab.c: * casetab.c (print_case_table): * console.c: * console.c (print_console): * database.c (print_database): * database.c (finalize_database): * device-msw.c (sync_printer_with_devmode): * device-msw.c (print_devmode): * device-msw.c (finalize_devmode): * device.c: * device.c (print_device): * elhash.c: * elhash.c (print_hash_table): * eval.c (print_multiple_value): * eval.c (mark_multiple_value): * events.c (deinitialize_event): * events.c (print_event): * events.c (event_equal): * extents.c: * extents.c (soe_dump): * extents.c (soe_insert): * extents.c (soe_delete): * extents.c (soe_move): * extents.c (extent_fragment_update): * extents.c (print_extent_1): * extents.c (print_extent): * extents.c (vars_of_extents): * frame.c: * frame.c (print_frame): * free-hook.c: * free-hook.c (check_free): * glyphs.c: * glyphs.c (print_image_instance): * glyphs.c (print_glyph): * gui.c: * gui.c (copy_gui_item): * hash.c: * hash.c (NULL_ENTRY): * hash.c (KEYS_DIFFER_P): * keymap.c (print_keymap): * keymap.c (MARKED_SLOT): * lisp.h: * lrecord.h: * lrecord.h (LISP_OBJECT_UID): * lrecord.h (set_lheader_implementation): * lrecord.h (struct old_lcrecord_header): * lstream.c (print_lstream): * lstream.c (finalize_lstream): * marker.c (print_marker): * marker.c (marker_equal): * mc-alloc.c (visit_all_used_page_headers): * mule-charset.c: * mule-charset.c (print_charset): * objects.c (print_color_instance): * objects.c (print_font_instance): * objects.c (finalize_font_instance): * opaque.c (print_opaque): * opaque.c (print_opaque_ptr): * opaque.c (equal_opaque_ptr): * print.c (internal_object_printer): * print.c (enum printing_badness): * rangetab.c (print_range_table): * rangetab.c (range_table_equal): * specifier.c (print_specifier): * specifier.c (finalize_specifier): * symbols.c: * symbols.c (print_symbol_value_magic): * tooltalk.c: * tooltalk.c (print_tooltalk_message): * tooltalk.c (print_tooltalk_pattern): * window.c (print_window): * window.c (debug_print_window): (1) Make lrecord UID's have a separate UID space for each object. Otherwise, with 20-bit UID's, we rapidly wrap around, especially when common objects like conses and strings increment the UID value for every object created. (Originally I tried making two UID spaces, one for objects that always print readably and hence don't display the UID, and one for other objects. But certain objects like markers for which a UID is displayed are still generated rapidly enough that UID overflow is a serious issue.) This also has the advantage of making UID values smaller, hence easier to remember -- their main purpose is to make it easier to keep track of different objects of the same type when debugging code. Make sure we dump lrecord UID's so that we don't have problems with pdumped and non-dumped objects having the same UID. (2) Display UID's consistently whenever an object (a) doesn't consistently print readably (objects like cons and string, which always print readably, can't display a UID), and (b) doesn't otherwise have a unique property that makes objects of a particular type distinguishable. (E.g. buffers didn't and still don't print an ID, but the buffer name uniquely identifies the buffer.) Some types, such as event, extent, compiled-function, didn't always (or didn't ever) display an ID; others (such as marker, extent, lstream, opaque, opaque-ptr, any object using internal_object_printer()) used to display the actual machine pointer instead. (3) Rename NORMAL_LISP_OBJECT_UID to LISP_OBJECT_UID; make it work over all Lisp objects and take a Lisp object, not a struct pointer. (4) Some misc cleanups in alloc.c, elhash.c. (5) Change code in events.c that "deinitializes" an event so that it doesn't increment the event UID counter in the process. Also use deadbeef_memory() to overwrite memory instead of doing the same with custom code. In the process, make deadbeef_memory() in alloc.c always available, and delete extraneous copy in mc-alloc.c. Also capitalize all uses of 0xDEADBEEF. Similarly in elhash.c call deadbeef_memory(). (6) Resurrect "debug SOE" code in extents.c. Make it conditional on DEBUG_XEMACS and on a `debug-soe' variable, rather than on SOE_DEBUG. Make it output to stderr, not stdout. (7) Delete some custom print methods that were identical to external_object_printer().
author Ben Wing <ben@xemacs.org>
date Mon, 15 Mar 2010 16:35:38 -0500
parents 0b0241ae382f
children b0ab9aa48977
files src/ChangeLog src/alloc.c src/bytecode.c src/casetab.c src/console.c src/database.c src/device-msw.c src/device.c src/elhash.c src/eval.c src/events.c src/extents.c src/frame.c src/free-hook.c src/glyphs.c src/gui.c src/hash.c src/keymap.c src/lisp.h src/lrecord.h src/lstream.c src/marker.c src/mc-alloc.c src/mule-charset.c src/objects.c src/opaque.c src/print.c src/rangetab.c src/specifier.c src/symbols.c src/tooltalk.c src/window.c
diffstat 32 files changed, 373 insertions(+), 234 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/ChangeLog	Mon Mar 15 16:35:38 2010 -0500
@@ -1,3 +1,153 @@
+2010-03-15  Ben Wing  <ben@xemacs.org>
+
+	* alloc.c:
+	* alloc.c (c_readonly):
+	* alloc.c (deadbeef_memory):
+	* alloc.c (make_compiled_function):
+	* alloc.c (make_button_data):
+	* alloc.c (make_motion_data):
+	* alloc.c (make_process_data):
+	* alloc.c (make_timeout_data):
+	* alloc.c (make_magic_data):
+	* alloc.c (make_magic_eval_data):
+	* alloc.c (make_eval_data):
+	* alloc.c (make_misc_user_data):
+	* alloc.c (noseeum_make_marker):
+	* alloc.c (ADDITIONAL_FREE_string):
+	* alloc.c (common_init_alloc_early):
+	* alloc.c (init_alloc_once_early):
+	* bytecode.c (print_compiled_function):
+	* bytecode.c (mark_compiled_function):
+	* casetab.c:
+	* casetab.c (print_case_table):
+	* console.c:
+	* console.c (print_console):
+	* database.c (print_database):
+	* database.c (finalize_database):
+	* device-msw.c (sync_printer_with_devmode):
+	* device-msw.c (print_devmode):
+	* device-msw.c (finalize_devmode):
+	* device.c:
+	* device.c (print_device):
+	* elhash.c:
+	* elhash.c (print_hash_table):
+	* eval.c (print_multiple_value):
+	* eval.c (mark_multiple_value):
+	* events.c (deinitialize_event):
+	* events.c (print_event):
+	* events.c (event_equal):
+	* extents.c:
+	* extents.c (soe_dump):
+	* extents.c (soe_insert):
+	* extents.c (soe_delete):
+	* extents.c (soe_move):
+	* extents.c (extent_fragment_update):
+	* extents.c (print_extent_1):
+	* extents.c (print_extent):
+	* extents.c (vars_of_extents):
+	* frame.c:
+	* frame.c (print_frame):
+	* free-hook.c:
+	* free-hook.c (check_free):
+	* glyphs.c:
+	* glyphs.c (print_image_instance):
+	* glyphs.c (print_glyph):
+	* gui.c:
+	* gui.c (copy_gui_item):
+	* hash.c:
+	* hash.c (NULL_ENTRY):
+	* hash.c (KEYS_DIFFER_P):
+	* keymap.c (print_keymap):
+	* keymap.c (MARKED_SLOT):
+	* lisp.h:
+	* lrecord.h:
+	* lrecord.h (LISP_OBJECT_UID):
+	* lrecord.h (set_lheader_implementation):
+	* lrecord.h (struct old_lcrecord_header):
+	* lstream.c (print_lstream):
+	* lstream.c (finalize_lstream):
+	* marker.c (print_marker):
+	* marker.c (marker_equal):
+	* mc-alloc.c (visit_all_used_page_headers):
+	* mule-charset.c:
+	* mule-charset.c (print_charset):
+	* objects.c (print_color_instance):
+	* objects.c (print_font_instance):
+	* objects.c (finalize_font_instance):
+	* opaque.c (print_opaque):
+	* opaque.c (print_opaque_ptr):
+	* opaque.c (equal_opaque_ptr):
+	* print.c (internal_object_printer):
+	* print.c (enum printing_badness):
+	* rangetab.c (print_range_table):
+	* rangetab.c (range_table_equal):
+	* specifier.c (print_specifier):
+	* specifier.c (finalize_specifier):
+	* symbols.c:
+	* symbols.c (print_symbol_value_magic):
+	* tooltalk.c:
+	* tooltalk.c (print_tooltalk_message):
+	* tooltalk.c (print_tooltalk_pattern):
+	* window.c (print_window):
+	* window.c (debug_print_window):
+	(1) Make lrecord UID's have a separate UID space for each object.
+	Otherwise, with 20-bit UID's, we rapidly wrap around, especially
+	when common objects like conses and strings increment the UID value
+	for every object created. (Originally I tried making two UID spaces,
+	one for objects that always print readably and hence don't display
+	the UID, and one for other objects.  But certain objects like markers
+	for which a UID is displayed are still generated rapidly enough that
+	UID overflow is a serious issue.) This also has the advantage of
+	making UID values smaller, hence easier to remember -- their main
+	purpose is to make it easier to keep track of different objects of
+	the same type when debugging code.  Make sure we dump lrecord UID's
+	so that we don't have problems with pdumped and non-dumped objects
+	having the same UID.
+
+	(2) Display UID's consistently whenever an object (a) doesn't
+	consistently print readably (objects like cons and string, which
+	always print readably, can't display a UID), and (b) doesn't
+	otherwise have a unique property that makes objects of a
+	particular type distinguishable. (E.g. buffers didn't and still
+	don't print an ID, but the buffer name uniquely identifies the
+	buffer.) Some types, such as event, extent, compiled-function,
+	didn't always (or didn't ever) display an ID; others (such as
+	marker, extent, lstream, opaque, opaque-ptr, any object using
+	internal_object_printer()) used to display the actual machine
+	pointer instead.
+
+	(3) Rename NORMAL_LISP_OBJECT_UID to LISP_OBJECT_UID; make it work
+	over all Lisp objects and take a Lisp object, not a struct pointer.
+
+	(4) Some misc cleanups in alloc.c, elhash.c.
+
+	(5) Change code in events.c that "deinitializes" an event so that
+	it doesn't increment the event UID counter in the process.  Also
+	use deadbeef_memory() to overwrite memory instead of doing the same
+	with custom code.  In the process, make deadbeef_memory() in
+	alloc.c always available, and delete extraneous copy in mc-alloc.c.
+	Also capitalize all uses of 0xDEADBEEF.  Similarly in elhash.c
+	call deadbeef_memory().
+
+	(6) Resurrect "debug SOE" code in extents.c.  Make it conditional
+	on DEBUG_XEMACS and on a `debug-soe' variable, rather than on
+	SOE_DEBUG.  Make it output to stderr, not stdout.
+
+	(7) Delete some custom print methods that were identical to
+	external_object_printer().
+
+2010-03-15  Ben Wing  <ben@xemacs.org>
+
+	* extents.c:
+	* extents.c (soe_dump):
+	* extents.c (soe_insert):
+	* extents.c (soe_delete):
+	* extents.c (soe_move):
+	* extents.c (extent_fragment_update):
+	* extents.c (print_extent_1):
+	* extents.c (print_extent):
+	* extents.c (vars_of_extents):
+
 2010-03-12  Ben Wing  <ben@xemacs.org>
 
 	* lisp.h:
--- a/src/alloc.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/alloc.c	Mon Mar 15 16:35:38 2010 -0500
@@ -102,6 +102,36 @@
 Bytecount __temp_alloca_size__;
 Bytecount funcall_alloca_count;
 
+/* All the built-in lisp object types are enumerated in `enum lrecord_type'.
+   Additional ones may be defined by a module (none yet).  We leave some
+   room in `lrecord_implementations_table' for such new lisp object types. */
+const struct lrecord_implementation *lrecord_implementations_table[(int)lrecord_type_last_built_in_type + MODULE_DEFINABLE_TYPE_COUNT];
+int lrecord_type_count = lrecord_type_last_built_in_type;
+
+/* This is just for use by the printer, to allow things to print uniquely.
+   We have a separate UID space for each object. (Important because the
+   UID is only 20 bits in old-GC, and 22 in NEW_GC.) */
+int lrecord_uid_counter[countof (lrecord_implementations_table)];
+
+/* Non-zero means we're in the process of doing the dump */
+int purify_flag;
+
+/* Non-zero means we're pdumping out or in */
+#ifdef PDUMP
+int in_pdump;
+#endif
+
+#ifdef ERROR_CHECK_TYPES
+
+Error_Behavior ERROR_ME, ERROR_ME_NOT, ERROR_ME_WARN, ERROR_ME_DEBUG_WARN;
+
+#endif
+
+/* Very cheesy ways of figuring out how much memory is being used for
+   data. #### Need better (system-dependent) ways. */
+void *minimum_address_seen;
+void *maximum_address_seen;
+
 /* Determine now whether we need to garbage collect or not, to make
    Ffuncall() faster */
 #define INCREMENT_CONS_COUNTER_1(size)		\
@@ -172,28 +202,6 @@
 } while (0)
 #endif /*not NEW_GC */
 
-/* This is just for use by the printer, to allow things to print uniquely */
-int lrecord_uid_counter;
-
-/* Non-zero means we're in the process of doing the dump */
-int purify_flag;
-
-/* Non-zero means we're pdumping out or in */
-#ifdef PDUMP
-int in_pdump;
-#endif
-
-#ifdef ERROR_CHECK_TYPES
-
-Error_Behavior ERROR_ME, ERROR_ME_NOT, ERROR_ME_WARN, ERROR_ME_DEBUG_WARN;
-
-#endif
-
-/* Very cheesy ways of figuring out how much memory is being used for
-   data. #### Need better (system-dependent) ways. */
-void *minimum_address_seen;
-void *maximum_address_seen;
-
 #ifndef NEW_GC
 int
 c_readonly (Lisp_Object obj)
@@ -436,10 +444,7 @@
   MALLOC_END ();
 }
 
-#ifdef ERROR_CHECK_GC
-
-#ifndef NEW_GC
-static void
+void
 deadbeef_memory (void *ptr, Bytecount size)
 {
   UINT_32_BIT *ptr4 = (UINT_32_BIT *) ptr;
@@ -449,14 +454,6 @@
   while (beefs--)
     (*ptr4++) = 0xDEADBEEF; /* -559038737 base 10 */
 }
-#endif /* not NEW_GC */
-
-#else /* !ERROR_CHECK_GC */
-
-
-#define deadbeef_memory(ptr, size)
-
-#endif /* !ERROR_CHECK_GC */
 
 #undef xstrdup
 char *
@@ -1953,7 +1950,7 @@
   Lisp_Compiled_Function *f;
 
   ALLOC_FROB_BLOCK_LISP_OBJECT (compiled_function, Lisp_Compiled_Function,
-				    f, &lrecord_compiled_function);
+				f, &lrecord_compiled_function);
 
   f->stack_depth = 0;
   f->specpdl_depth = 0;
@@ -2170,7 +2167,8 @@
 {
   Lisp_Button_Data *d;
 
-  ALLOC_FROB_BLOCK_LISP_OBJECT (button_data, Lisp_Button_Data, d, &lrecord_button_data);
+  ALLOC_FROB_BLOCK_LISP_OBJECT (button_data, Lisp_Button_Data, d,
+				&lrecord_button_data);
   zero_nonsized_lisp_object (wrap_button_data (d));
   return wrap_button_data (d);
 }
@@ -2183,7 +2181,8 @@
 {
   Lisp_Motion_Data *d;
 
-  ALLOC_FROB_BLOCK_LISP_OBJECT (motion_data, Lisp_Motion_Data, d, &lrecord_motion_data);
+  ALLOC_FROB_BLOCK_LISP_OBJECT (motion_data, Lisp_Motion_Data, d,
+				&lrecord_motion_data);
   zero_nonsized_lisp_object (wrap_motion_data (d));
 
   return wrap_motion_data (d);
@@ -2197,7 +2196,8 @@
 {
   Lisp_Process_Data *d;
 
-  ALLOC_FROB_BLOCK_LISP_OBJECT (process_data, Lisp_Process_Data, d, &lrecord_process_data);
+  ALLOC_FROB_BLOCK_LISP_OBJECT (process_data, Lisp_Process_Data, d,
+				&lrecord_process_data);
   zero_nonsized_lisp_object (wrap_process_data (d));
   d->process = Qnil;
 
@@ -2212,7 +2212,8 @@
 {
   Lisp_Timeout_Data *d;
 
-  ALLOC_FROB_BLOCK_LISP_OBJECT (timeout_data, Lisp_Timeout_Data, d, &lrecord_timeout_data);
+  ALLOC_FROB_BLOCK_LISP_OBJECT (timeout_data, Lisp_Timeout_Data, d,
+				&lrecord_timeout_data);
   zero_nonsized_lisp_object (wrap_timeout_data (d));
   d->function = Qnil;
   d->object = Qnil;
@@ -2228,7 +2229,8 @@
 {
   Lisp_Magic_Data *d;
 
-  ALLOC_FROB_BLOCK_LISP_OBJECT (magic_data, Lisp_Magic_Data, d, &lrecord_magic_data);
+  ALLOC_FROB_BLOCK_LISP_OBJECT (magic_data, Lisp_Magic_Data, d,
+				&lrecord_magic_data);
   zero_nonsized_lisp_object (wrap_magic_data (d));
 
   return wrap_magic_data (d);
@@ -2242,7 +2244,8 @@
 {
   Lisp_Magic_Eval_Data *d;
 
-  ALLOC_FROB_BLOCK_LISP_OBJECT (magic_eval_data, Lisp_Magic_Eval_Data, d, &lrecord_magic_eval_data);
+  ALLOC_FROB_BLOCK_LISP_OBJECT (magic_eval_data, Lisp_Magic_Eval_Data, d,
+				&lrecord_magic_eval_data);
   zero_nonsized_lisp_object (wrap_magic_eval_data (d));
   d->object = Qnil;
 
@@ -2257,7 +2260,8 @@
 {
   Lisp_Eval_Data *d;
 
-  ALLOC_FROB_BLOCK_LISP_OBJECT (eval_data, Lisp_Eval_Data, d, &lrecord_eval_data);
+  ALLOC_FROB_BLOCK_LISP_OBJECT (eval_data, Lisp_Eval_Data, d,
+				&lrecord_eval_data);
   zero_nonsized_lisp_object (wrap_eval_data (d));
   d->function = Qnil;
   d->object = Qnil;
@@ -2273,7 +2277,8 @@
 {
   Lisp_Misc_User_Data *d;
 
-  ALLOC_FROB_BLOCK_LISP_OBJECT (misc_user_data, Lisp_Misc_User_Data, d, &lrecord_misc_user_data);
+  ALLOC_FROB_BLOCK_LISP_OBJECT (misc_user_data, Lisp_Misc_User_Data, d,
+				&lrecord_misc_user_data);
   zero_nonsized_lisp_object (wrap_misc_user_data (d));
   d->function = Qnil;
   d->object = Qnil;
@@ -2312,7 +2317,7 @@
   Lisp_Marker *p;
 
   NOSEEUM_ALLOC_FROB_BLOCK_LISP_OBJECT (marker, Lisp_Marker, p,
-					    &lrecord_marker);
+					&lrecord_marker);
   p->buffer = 0;
   p->membpos = 0;
   marker_next (p) = 0;
@@ -3356,11 +3361,6 @@
 /*			   Garbage Collection				*/
 /************************************************************************/
 
-/* All the built-in lisp object types are enumerated in `enum lrecord_type'.
-   Additional ones may be defined by a module (none yet).  We leave some
-   room in `lrecord_implementations_table' for such new lisp object types. */
-const struct lrecord_implementation *lrecord_implementations_table[(int)lrecord_type_last_built_in_type + MODULE_DEFINABLE_TYPE_COUNT];
-int lrecord_type_count = lrecord_type_last_built_in_type;
 #ifndef USE_KKCC
 /* Object marker functions are in the lrecord_implementation structure.
    But copying them to a parallel array is much more cache-friendly.
@@ -4391,7 +4391,7 @@
 #define ADDITIONAL_FREE_string(ptr) do {	\
     Bytecount size = ptr->size_;		\
     if (BIG_STRING_SIZE_P (size))		\
-      xfree (ptr->data_);		\
+      xfree (ptr->data_);			\
   } while (0)
 
   SWEEP_FIXED_TYPE_BLOCK_1 (string, Lisp_String, u.lheader);
@@ -5117,7 +5117,6 @@
   funcall_allocation_flag = 0;
   funcall_alloca_count = 0;
 
-  lrecord_uid_counter = 259;
 #ifndef NEW_GC
   debug_string_purity = 0;
 #endif /* not NEW_GC */
@@ -5185,6 +5184,8 @@
       lrecord_implementations_table[i] = 0;
   }
 
+  dump_add_opaque (lrecord_uid_counter, sizeof (lrecord_uid_counter));
+
   INIT_LISP_OBJECT (cons);
   INIT_LISP_OBJECT (vector);
   INIT_LISP_OBJECT (string);
--- a/src/bytecode.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/bytecode.c	Mon Mar 15 16:35:38 2010 -0500
@@ -2245,7 +2245,8 @@
   struct gcpro gcpro1, gcpro2;
   GCPRO2 (obj, printcharfun);
 
-  write_ascstring (printcharfun, print_readably ? "#[" : "#<compiled-function ");
+  write_ascstring (printcharfun, print_readably ? "#[" :
+		   "#<compiled-function ");
 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
   if (!print_readably)
     {
@@ -2298,7 +2299,10 @@
     }
 
   UNGCPRO;
-  write_ascstring (printcharfun, print_readably ? "]" : ">");
+  if (print_readably)
+    write_ascstring (printcharfun, "]");
+  else
+    write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 
--- a/src/casetab.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/casetab.c	Mon Mar 15 16:35:38 2010 -0500
@@ -1,7 +1,7 @@
 /* XEmacs routines to deal with case tables.
    Copyright (C) 1987, 1992, 1993, 1994 Free Software Foundation, Inc.
    Copyright (C) 1995 Sun Microsystems, Inc.
-   Copyright (C) 2002 Ben Wing.
+   Copyright (C) 2002, 2010 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -110,7 +110,7 @@
     (printcharfun, "#<case-table downcase=%s upcase=%s canon=%s eqv=%s ", 4,
      CASE_TABLE_DOWNCASE (ct), CASE_TABLE_UPCASE (ct),
      CASE_TABLE_CANON (ct), CASE_TABLE_EQV (ct));
-  write_fmt_string (printcharfun, "0x%x>", NORMAL_LISP_OBJECT_UID (ct));
+  write_fmt_string (printcharfun, "0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static const struct memory_description case_table_description [] = {
--- a/src/console.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/console.c	Mon Mar 15 16:35:38 2010 -0500
@@ -170,7 +170,7 @@
   if (CONSOLE_LIVE_P (con) && !NILP (CONSOLE_CONNECTION (con)))
     write_fmt_string_lisp (printcharfun, " on %S", 1,
 			   CONSOLE_CONNECTION (con));
-  write_fmt_string (printcharfun, " 0x%x>", NORMAL_LISP_OBJECT_UID (con));
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 DEFINE_NODUMP_LISP_OBJECT ("console", console, mark_console,
--- a/src/database.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/database.c	Mon Mar 15 16:35:38 2010 -0500
@@ -232,7 +232,7 @@
                          XSYMBOL_NAME (XCODING_SYSTEM_NAME
                                        (db->coding_system)));
 
-  write_fmt_string (printcharfun, "0x%x>", NORMAL_LISP_OBJECT_UID (db));
+  write_fmt_string (printcharfun, "0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static void
--- a/src/device-msw.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/device-msw.c	Mon Mar 15 16:35:38 2010 -0500
@@ -665,7 +665,7 @@
 	     suffix. */
 	  Ibyte new_connext[20];
 
-	  qxesprintf (new_connext, ":%X", NORMAL_LISP_OBJECT_UID (d));
+	  qxesprintf (new_connext, ":%X", LISP_OBJECT_UID (wrap_device (d)));
 	  new_connection = concat2 (devname, build_istring (new_connext));
 	}
       DEVICE_CONNECTION (d) = new_connection;
@@ -1154,7 +1154,7 @@
     write_fmt_string_lisp (printcharfun, " for %S", 1, dm->printer_name);
   if (!NILP (dm->device))
     write_fmt_string_lisp (printcharfun, " (currently on %s)", 1, dm->device);
-  write_fmt_string (printcharfun, " 0x%x>", NORMAL_LISP_OBJECT_UID (dm));
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static void
--- a/src/device.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/device.c	Mon Mar 15 16:35:38 2010 -0500
@@ -166,7 +166,7 @@
 		    DEVICE_TYPE_NAME (d));
   if (DEVICE_LIVE_P (d) && !NILP (DEVICE_CONNECTION (d)))
     write_fmt_string_lisp (printcharfun, " on %S", 1, DEVICE_CONNECTION (d));
-  write_fmt_string (printcharfun, " 0x%x>", NORMAL_LISP_OBJECT_UID (d));
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 DEFINE_NODUMP_LISP_OBJECT ("device", device,
--- a/src/elhash.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/elhash.c	Mon Mar 15 16:35:38 2010 -0500
@@ -395,25 +395,23 @@
   if (print_readably)
     write_ascstring (printcharfun, ")");
   else
-    write_fmt_string (printcharfun, " 0x%x>", NORMAL_LISP_OBJECT_UID (ht));
+    write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 #ifndef NEW_GC
 static void
 free_hentries (htentry *hentries,
 #ifdef ERROR_CHECK_STRUCTURES
-	       size_t size
+	       Elemcount size
 #else /* not ERROR_CHECK_STRUCTURES) */
-	       size_t UNUSED (size)
+	       Elemcount UNUSED (size)
 #endif /* not ERROR_CHECK_STRUCTURES) */
 	       )
 {
 #ifdef ERROR_CHECK_STRUCTURES
   /* Ensure a crash if other code uses the discarded entries afterwards. */
-  htentry *e, *sentinel;
-
-  for (e = hentries, sentinel = e + size; e < sentinel; e++)
-    * (unsigned long *) e = 0xdeadbeef; /* -559038737 base 10 */
+  deadbeef_memory (hentries,
+		   (Rawbyte *) (hentries + size) - (Rawbyte *) hentries);
 #endif
 
   if (!DUMPEDP (hentries))
--- a/src/eval.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/eval.c	Mon Mar 15 16:35:38 2010 -0500
@@ -4605,7 +4605,8 @@
 
   if (print_readably)
     {
-      printing_unreadable_object_fmt ("multiple values");
+      printing_unreadable_object_fmt ("#<multiple values 0x%x>",
+				      LISP_OBJECT_UID (obj));
     }
 
   write_fmt_string (printcharfun,
@@ -4635,7 +4636,7 @@
         }
     }
 
-  write_fmt_string (printcharfun, ") 0x%lx>", (unsigned long) XPNTR (obj));
+  write_fmt_string (printcharfun, ") 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static Lisp_Object
--- a/src/events.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/events.c	Mon Mar 15 16:35:38 2010 -0500
@@ -74,14 +74,10 @@
 deinitialize_event (Lisp_Object ev)
 {
   Lisp_Event *event = XEVENT (ev);
-  int i;
-  /* Preserve the old UID for this event, for tracking it */
-  unsigned int old_uid = event->lheader.uid;
 
-  for (i = 0; i < (int) (sizeof (Lisp_Event) / sizeof (int)); i++)
-    ((int *) event) [i] = 0xdeadbeef; /* -559038737 base 10 */
-  set_lheader_implementation (&event->lheader, &lrecord_event);
-  event->lheader.uid = old_uid;
+  deadbeef_memory ((Rawbyte *) event + sizeof (event->lheader),
+		   sizeof (*event) - sizeof (event->lheader));
+
   set_event_type (event, dead_event);
   SET_EVENT_CHANNEL (event, Qnil);
   XSET_EVENT_NEXT (ev, Qnil);
@@ -308,7 +304,7 @@
 	     int UNUSED (escapeflag))
 {
   if (print_readably)
-    printing_unreadable_object_fmt ("#<event>");
+    printing_unreadable_object_fmt ("#<event 0x%x>", LISP_OBJECT_UID (obj));
 
   switch (XEVENT (obj)->event_type)
     {
@@ -366,7 +362,7 @@
 	write_ascstring (printcharfun, "#<UNKNOWN-EVENT-TYPE");
 	break;
       }
-  write_ascstring (printcharfun, ">");
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static int
--- a/src/extents.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/extents.c	Mon Mar 15 16:35:38 2010 -0500
@@ -506,6 +506,8 @@
    changes */
 int in_modeline_generation;
 
+int debug_soe;
+
 
 /************************************************************************/
 /*                       Generalized gap array                          */
@@ -1529,24 +1531,7 @@
   return info->soe;
 }
 
-/* #### don't even think of #define'ing this, the prototype of
-   print_extent_1 has changed! */
-/* #define SOE_DEBUG */
-
-#ifdef SOE_DEBUG
-
-static void print_extent_1 (char *buf, Lisp_Object extent);
-
-static void
-print_extent_2 (EXTENT e)
-{
-  Lisp_Object extent;
-  char buf[200];
-
-  extent = wrap_extent (e);
-  print_extent_1 (buf, extent);
-  fputs (buf, stdout);
-}
+#ifdef DEBUG_XEMACS
 
 static void
 soe_dump (Lisp_Object obj)
@@ -1558,29 +1543,29 @@
 
   if (!soe)
     {
-      printf ("No SOE");
+      stderr_out ("No SOE");
       return;
     }
   sel = soe->extents;
-  printf ("SOE pos is %d (memxpos %d)\n",
-	  soe->pos < 0 ? soe->pos :
-	  buffer_or_string_memxpos_to_bytexpos (obj, soe->pos),
-	  soe->pos);
+  stderr_out ("SOE pos is %ld (memxpos %ld)\n",
+	      soe->pos < 0 ? soe->pos :
+	      buffer_or_string_memxpos_to_bytexpos (obj, soe->pos),
+	      soe->pos);
   for (endp = 0; endp < 2; endp++)
     {
-      printf (endp ? "SOE end:" : "SOE start:");
+      stderr_out (endp ? "SOE end:" : "SOE start:");
       for (i = 0; i < extent_list_num_els (sel); i++)
 	{
 	  EXTENT e = extent_list_at (sel, i, endp);
-	  putchar ('\t');
-	  print_extent_2 (e);
+	  stderr_out ("\t");
+	  debug_print (wrap_extent (e));
 	}
-      putchar ('\n');
-    }
-  putchar ('\n');
-}
-
-#endif
+      stderr_out ("\n");
+    }
+  stderr_out ("\n");
+}
+
+#endif /* DEBUG_XEMACS */
 
 /* Insert EXTENT into OBJ's stack of extents, if necessary. */
 
@@ -1589,23 +1574,30 @@
 {
   Stack_Of_Extents *soe = buffer_or_string_stack_of_extents (obj);
 
-#ifdef SOE_DEBUG
-  printf ("Inserting into SOE: ");
-  print_extent_2 (extent);
-  putchar ('\n');
+#ifdef DEBUG_XEMACS
+  if (debug_soe)
+    {
+      stderr_out ("Inserting into SOE: ");
+      debug_print (wrap_extent (extent));
+      stderr_out ("\n");
+    }
 #endif
   if (!soe || soe->pos < extent_start (extent) ||
       soe->pos > extent_end (extent))
     {
-#ifdef SOE_DEBUG
-      printf ("(not needed)\n\n");
+#ifdef DEBUG_XEMACS
+      if (debug_soe)
+	stderr_out ("(not needed)\n\n");
 #endif
       return;
     }
   extent_list_insert (soe->extents, extent);
-#ifdef SOE_DEBUG
-  puts ("SOE afterwards is:");
-  soe_dump (obj);
+#ifdef DEBUG_XEMACS
+  if (debug_soe)
+    {
+      stderr_out ("SOE afterwards is:\n");
+      soe_dump (obj);
+    }
 #endif
 }
 
@@ -1616,23 +1608,30 @@
 {
   Stack_Of_Extents *soe = buffer_or_string_stack_of_extents (obj);
 
-#ifdef SOE_DEBUG
-  printf ("Deleting from SOE: ");
-  print_extent_2 (extent);
-  putchar ('\n');
+#ifdef DEBUG_XEMACS
+  if (debug_soe)
+    {
+      stderr_out ("Deleting from SOE: ");
+      debug_print (wrap_extent (extent));
+      stderr_out ("\n");
+    }
 #endif
   if (!soe || soe->pos < extent_start (extent) ||
       soe->pos > extent_end (extent))
     {
-#ifdef SOE_DEBUG
-      puts ("(not needed)\n");
+#ifdef DEBUG_XEMACS
+      if (debug_soe)
+	stderr_out ("(not needed)\n\n");
 #endif
       return;
     }
   extent_list_delete (soe->extents, extent);
-#ifdef SOE_DEBUG
-  puts ("SOE afterwards is:");
-  soe_dump (obj);
+#ifdef DEBUG_XEMACS
+  if (debug_soe)
+    {
+      stderr_out ("SOE afterwards is:\n");
+      soe_dump (obj);
+    }
 #endif
 }
 
@@ -1652,11 +1651,12 @@
   assert (bel);
 #endif
 
-#ifdef SOE_DEBUG
-  printf ("Moving SOE from %d (memxpos %d) to %d (memxpos %d)\n",
-	  soe->pos < 0 ? soe->pos :
-	  buffer_or_string_memxpos_to_bytexpos (obj, soe->pos), soe->pos,
-	  buffer_or_string_memxpos_to_bytexpos (obj, pos), pos);
+#ifdef DEBUG_XEMACS
+  if (debug_soe)
+    stderr_out ("Moving SOE from %ld (memxpos %ld) to %ld (memxpos %ld)\n",
+		soe->pos < 0 ? soe->pos :
+		buffer_or_string_memxpos_to_bytexpos (obj, soe->pos), soe->pos,
+		buffer_or_string_memxpos_to_bytexpos (obj, pos), pos);
 #endif
   if (soe->pos < pos)
     {
@@ -1670,8 +1670,9 @@
     }
   else
     {
-#ifdef SOE_DEBUG
-      puts ("(not needed)\n");
+#ifdef DEBUG_XEMACS
+      if (debug_soe)
+	stderr_out ("(not needed)\n\n");
 #endif
       return;
     }
@@ -1756,9 +1757,12 @@
   }
 
   soe->pos = pos;
-#ifdef SOE_DEBUG
-  puts ("SOE afterwards is:");
-  soe_dump (obj);
+#ifdef DEBUG_XEMACS
+  if (debug_soe)
+    {
+      stderr_out ("SOE afterwards is:\n");
+      soe_dump (obj);
+    }
 #endif
 }
 
@@ -3200,10 +3204,10 @@
 	      Lisp_Object function = extent_initial_redisplay_function (e);
 	      Lisp_Object obj;
 
-	      /* printf ("initial redisplay function called!\n "); */
-
-	      /* print_extent_2 (e);
-	         printf ("\n"); */
+	      /* stderr_out ("initial redisplay function called!\n "); */
+
+	      /* debug_print (wrap_extent (e));
+	         stderr_out ("\n"); */
 
 	      /* FIXME: One should probably inhibit the displaying of
 		 this extent to reduce flicker */
@@ -3288,8 +3292,6 @@
       if (NILP (v)) continue;
       write_fmt_string_lisp (printcharfun, "%S ", 1, XCAR (tail));
     }
-
-  write_fmt_string (printcharfun, "0x%lx", (long) ext);
 }
 
 static void
@@ -3333,10 +3335,11 @@
       if (print_readably)
 	{
 	  if (!EXTENT_LIVE_P (XEXTENT (obj)))
-	    printing_unreadable_object_fmt ("#<destroyed extent>");
+	    printing_unreadable_object_fmt ("#<destroyed extent 0x%x>",
+					    LISP_OBJECT_UID (obj));
 	  else
-	    printing_unreadable_object_fmt ("#<extent 0x%lx>",
-		   (long) XEXTENT (obj));
+	    printing_unreadable_object_fmt ("#<extent 0x%x>",
+					    LISP_OBJECT_UID (obj));
 	}
 
       if (!EXTENT_LIVE_P (XEXTENT (obj)))
@@ -3346,17 +3349,19 @@
 	  write_ascstring (printcharfun, "#<extent ");
 	  print_extent_1 (obj, printcharfun, escapeflag);
 	  write_ascstring (printcharfun, extent_detached_p (XEXTENT (obj))
-			  ? " from " : " in ");
+			  ? "from " : "in ");
 	  write_fmt_string (printcharfun, "%s%s%s", title, name, posttitle);
 	}
     }
   else
     {
       if (print_readably)
-	printing_unreadable_object_fmt ("#<extent>");
+	printing_unreadable_object_fmt ("#<extent 0x%x>",
+					LISP_OBJECT_UID (obj));
       write_ascstring (printcharfun, "#<extent");
     }
-  write_ascstring (printcharfun, ">");
+
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static int
@@ -7560,6 +7565,15 @@
 void
 vars_of_extents (void)
 {
+#ifdef DEBUG_XEMACS 
+  DEFVAR_BOOL ("debug-soe", &debug_soe /*
+If non-nil, display debugging information about the SOE ("stack of extents").
+The SOE is a cache of extents overlapping a specified region, used to
+speed up `map-extents' and certain other functions.
+*/ );
+  debug_soe = 0;
+#endif /* DEBUG_XEMACS */
+
   DEFVAR_INT ("mouse-highlight-priority", &mouse_highlight_priority /*
 The priority to use for the mouse-highlighting pseudo-extent
 that is used to highlight extents with the `mouse-face' attribute set.
--- a/src/frame.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/frame.c	Mon Mar 15 16:35:38 2010 -0500
@@ -642,7 +642,7 @@
   write_fmt_string (printcharfun, "#<%s-frame ", !FRAME_LIVE_P (frm) ? "dead" :
 		    FRAME_TYPE_NAME (frm));
   print_internal (frm->name, printcharfun, 1);
-  write_fmt_string (printcharfun, " 0x%x>", NORMAL_LISP_OBJECT_UID (frm));
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 DEFINE_NODUMP_LISP_OBJECT ("frame", frame,
--- a/src/free-hook.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/free-hook.c	Mon Mar 15 16:35:38 2010 -0500
@@ -1,4 +1,5 @@
-/* This file is part of XEmacs.
+/* Copyright (C) 2010 Ben Wing.
+This file is part of XEmacs.
 
 XEmacs is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
@@ -26,7 +27,7 @@
    * Trying to free a pointer not returned by malloc.
    * Trying to realloc a pointer not returned by malloc.
 
-   In addition, every word of every block freed is set to 0xdeadbeef
+   In addition, every word of every block freed is set to 0xDEADBEEF
    (-559038737).  This causes many uses of freed storage to be trapped or
    recognized.
 
@@ -43,10 +44,10 @@
    return addresses.
 
    If UNMAPPED_FREE is defined, instead of setting every word of freed
-   storage to 0xdeadbeef, every call to malloc goes on its own page(s).
+   storage to 0xDEADBEEF, every call to malloc goes on its own page(s).
    When free() is called, the block is read and write protected.  This
    is very useful when debugging, since it usually generates a bus error
-   when the deadbeef hack might only cause some garbage to be printed.
+   when the DEADBEEF hack might only cause some garbage to be printed.
    However, this is too slow for everyday use, since it takes an enormous
    number of pages.
 
@@ -170,7 +171,7 @@
       if (strict_free_check)
 	mprotect (ptr, rounded_up_size, PROT_NONE);
 #else
-      /* Set every word in the block to 0xdeadbeef */
+      /* Set every word in the block to 0xDEADBEEF */
       if (strict_free_check)
 	{
 	  unsigned long long_length = (size + (sizeof (long) - 1))
@@ -180,7 +181,7 @@
           /* Not using the DEADBEEF_CONSTANT #define, since we don't know
            * that allocation sizes will be multiples of eight. */
 	  for (i = 0; i < long_length; i++)
-	    ((unsigned long *) ptr)[i] = 0xdeadbeef;
+	    ((unsigned long *) ptr)[i] = 0xDEADBEEF;
 	}
 #endif
       free_queue[current_free].address = ptr;
--- a/src/glyphs.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/glyphs.c	Mon Mar 15 16:35:38 2010 -0500
@@ -1108,7 +1108,7 @@
 
   MAYBE_DEVMETH (DOMAIN_XDEVICE (ii->domain), print_image_instance,
 		 (ii, printcharfun, escapeflag));
-  write_fmt_string (printcharfun, " 0x%x>", NORMAL_LISP_OBJECT_UID (ii));
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static void
@@ -3711,7 +3711,7 @@
 
   write_fmt_string_lisp (printcharfun, "#<glyph (%s", 1, Fglyph_type (obj));
   write_fmt_string_lisp (printcharfun, ") %S", 1, glyph->image);
-  write_fmt_string (printcharfun, "0x%x>", NORMAL_LISP_OBJECT_UID (glyph));
+  write_fmt_string (printcharfun, "0x%x>", LISP_OBJECT_UID (obj));
 }
 
 /* Glyphs are equal if all of their display attributes are equal.  We
--- a/src/gui.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/gui.c	Mon Mar 15 16:35:38 2010 -0500
@@ -1,6 +1,6 @@
 /* Generic GUI code. (menubars, scrollbars, toolbars, dialogs)
    Copyright (C) 1995 Board of Trustees, University of Illinois.
-   Copyright (C) 1995, 1996, 2000, 2001, 2002, 2003 Ben Wing.
+   Copyright (C) 1995, 1996, 2000, 2001, 2002, 2003, 2010 Ben Wing.
    Copyright (C) 1995 Sun Microsystems, Inc.
    Copyright (C) 1998 Free Software Foundation, Inc.
 
@@ -686,18 +686,6 @@
   return 1;
 }
 
-static void
-print_gui_item (Lisp_Object obj, Lisp_Object printcharfun,
-		int UNUSED (escapeflag))
-{
-  Lisp_Gui_Item *g = XGUI_ITEM (obj);
-
-  if (print_readably)
-    printing_unreadable_lisp_object (obj, 0);
-
-  write_fmt_string (printcharfun, "#<gui-item 0x%x>", NORMAL_LISP_OBJECT_UID (g));
-}
-
 Lisp_Object
 copy_gui_item (Lisp_Object gui_item)
 {
@@ -804,7 +792,7 @@
 }
 
 DEFINE_NODUMP_LISP_OBJECT ("gui-item", gui_item,
-			   mark_gui_item, print_gui_item,
+			   mark_gui_item, external_object_printer,
 			   0, gui_item_equal,
 			   gui_item_hash,
 			   gui_item_description,
--- a/src/hash.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/hash.c	Mon Mar 15 16:35:38 2010 -0500
@@ -1,6 +1,6 @@
 /* Hash tables.
    Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
-   Copyright (C) 2003, 2004 Ben Wing.
+   Copyright (C) 2003, 2004, 2010 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -28,7 +28,7 @@
 #include "lisp.h"
 #include "hash.h"
 
-#define NULL_ENTRY ((void *) 0xdeadbeef) /* -559038737 base 10 */
+#define NULL_ENTRY ((void *) 0xDEADBEEF) /* -559038737 base 10 */
 
 #define COMFORTABLE_SIZE(size) (21 * (size) / 16)
 
--- a/src/keymap.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/keymap.c	Mon Mar 15 16:35:38 2010 -0500
@@ -291,7 +291,8 @@
       write_fmt_string_lisp (printcharfun, "%S ", 1, keymap->name);
     }
   write_fmt_string (printcharfun, "size %ld 0x%x>",
-		    (long) XINT (Fkeymap_fullness (obj)), NORMAL_LISP_OBJECT_UID (keymap));
+		    (long) XINT (Fkeymap_fullness (obj)),
+		    LISP_OBJECT_UID (obj));
 }
 
 static const struct memory_description keymap_description[] = {
--- a/src/lisp.h	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/lisp.h	Mon Mar 15 16:35:38 2010 -0500
@@ -4757,6 +4757,7 @@
 MODULE_API EXFUN (Fmake_vector, 2);
 MODULE_API EXFUN (Fvector, MANY);
 
+void deadbeef_memory (void *ptr, Bytecount size);
 #ifndef NEW_GC
 void release_breathing_space (void);
 #endif /* not NEW_GC */
--- a/src/lrecord.h	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/lrecord.h	Mon Mar 15 16:35:38 2010 -0500
@@ -187,7 +187,6 @@
 #define NORMAL_LISP_OBJECT_HEADER struct lrecord_header
 #define FROB_BLOCK_LISP_OBJECT_HEADER struct lrecord_header
 #define LISP_OBJECT_FROB_BLOCK_P(obj) 0
-#define NORMAL_LISP_OBJECT_UID(obj) ((obj)->header.uid)
 #else /* not NEW_GC */
 #define ALLOC_NORMAL_LISP_OBJECT(type) alloc_automanaged_lcrecord (&lrecord_##type)
 #define ALLOC_SIZED_LISP_OBJECT(size, type) \
@@ -195,9 +194,10 @@
 #define NORMAL_LISP_OBJECT_HEADER struct old_lcrecord_header
 #define FROB_BLOCK_LISP_OBJECT_HEADER struct lrecord_header
 #define LISP_OBJECT_FROB_BLOCK_P(obj) (XRECORD_LHEADER_IMPLEMENTATION(obj)->frob_block_p)
-#define NORMAL_LISP_OBJECT_UID(obj) ((obj)->header.lheader.uid)
 #endif /* not NEW_GC */
 
+#define LISP_OBJECT_UID(obj) (XRECORD_LHEADER (obj)->uid)
+
 BEGIN_C_DECLS
 
 struct lrecord_header
@@ -256,25 +256,25 @@
 
 struct lrecord_implementation;
 int lrecord_type_index (const struct lrecord_implementation *implementation);
-extern int lrecord_uid_counter;
+extern int lrecord_uid_counter[];
 
 #ifdef NEW_GC
-#define set_lheader_implementation(header,imp) do {	\
-  struct lrecord_header* SLI_header = (header);		\
-  SLI_header->type = (imp)->lrecord_type_index;		\
-  SLI_header->lisp_readonly = 0;			\
-  SLI_header->free = 0;					\
-  SLI_header->uid = lrecord_uid_counter++;		\
+#define set_lheader_implementation(header,imp) do {			\
+  struct lrecord_header* SLI_header = (header);				\
+  SLI_header->type = (imp)->lrecord_type_index;				\
+  SLI_header->lisp_readonly = 0;					\
+  SLI_header->free = 0;							\
+  SLI_header->uid = lrecord_uid_counter[(imp)->lrecord_type_index]++;   \
 } while (0)
 #else /* not NEW_GC */
-#define set_lheader_implementation(header,imp) do {	\
-  struct lrecord_header* SLI_header = (header);		\
-  SLI_header->type = (imp)->lrecord_type_index;		\
-  SLI_header->mark = 0;					\
-  SLI_header->c_readonly = 0;				\
-  SLI_header->lisp_readonly = 0;			\
-  SLI_header->free = 0;					\
-  SLI_header->uid = lrecord_uid_counter++;		\
+#define set_lheader_implementation(header,imp) do {			\
+  struct lrecord_header* SLI_header = (header);				\
+  SLI_header->type = (imp)->lrecord_type_index;				\
+  SLI_header->mark = 0;							\
+  SLI_header->c_readonly = 0;						\
+  SLI_header->lisp_readonly = 0;					\
+  SLI_header->free = 0;							\
+  SLI_header->uid = lrecord_uid_counter[(imp)->lrecord_type_index]++;   \
 } while (0)
 #endif /* not NEW_GC */
 
--- a/src/lstream.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/lstream.c	Mon Mar 15 16:35:38 2010 -0500
@@ -64,8 +64,8 @@
   Lstream *lstr = XLSTREAM (obj);
 
   write_fmt_string (printcharfun,
-		    "#<INTERNAL OBJECT (XEmacs bug?) (%s lstream) 0x%lx>",
-		    lstr->imp->name, (long) lstr);
+		    "#<INTERNAL OBJECT (XEmacs bug?) (%s lstream) 0x%x>",
+		    lstr->imp->name, LISP_OBJECT_UID (obj));
 }
 
 static void
--- a/src/marker.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/marker.c	Mon Mar 15 16:35:38 2010 -0500
@@ -60,7 +60,7 @@
   Lisp_Marker *marker = XMARKER (obj);
 
   if (print_readably)
-    printing_unreadable_object_fmt ("#<marker 0x%lx>", (long) marker);
+    printing_unreadable_object_fmt ("#<marker 0x%x>", LISP_OBJECT_UID (obj));
 
   write_ascstring (printcharfun, GETTEXT ("#<marker "));
   if (!marker->buffer)
@@ -73,7 +73,7 @@
     }
   if (marker->insertion_type)
     write_ascstring (printcharfun, " insertion-type=t");
-  write_fmt_string (printcharfun, " 0x%lx>", (long) marker);
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static int
--- a/src/mc-alloc.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/mc-alloc.c	Mon Mar 15 16:35:38 2010 -0500
@@ -417,20 +417,6 @@
 
 /*--- misc functions ---------------------------------------------------*/
 
-/* moved here from alloc.c */
-#ifdef ERROR_CHECK_GC
-static void
-deadbeef_memory (void *ptr, Bytecount size)
-{
-  UINT_32_BIT *ptr4 = (UINT_32_BIT *) ptr;
-  Bytecount beefs = size >> 2;
-
-  /* In practice, size will always be a multiple of four.  */
-  while (beefs--)
-    (*ptr4++) = 0xDEADBEEF; /* -559038737 base 10 */
-}
-#endif /* ERROR_CHECK_GC */
-
 /* Visits all pages (page_headers) hooked into the used heap pages
    list and executes f with the current page header as
    argument. Needed for sweep.  Returns number of processed pages. */
--- a/src/mule-charset.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/mule-charset.c	Mon Mar 15 16:35:38 2010 -0500
@@ -158,7 +158,7 @@
 		    CHARSET_GRAPHIC (cs),
 		    CHARSET_FINAL (cs));
   print_internal (CHARSET_REGISTRIES (cs), printcharfun, 0);
-  write_fmt_string (printcharfun, " 0x%x>", NORMAL_LISP_OBJECT_UID (cs));
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static const struct memory_description charset_description[] = {
--- a/src/objects.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/objects.c	Mon Mar 15 16:35:38 2010 -0500
@@ -110,7 +110,7 @@
   if (!NILP (c->device)) /* Vthe_null_color_instance */
     MAYBE_DEVMETH (XDEVICE (c->device), print_color_instance,
 		   (c, printcharfun, escapeflag));
-  write_fmt_string (printcharfun, " 0x%x>", NORMAL_LISP_OBJECT_UID (c));
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static void
@@ -328,7 +328,7 @@
 		     (f, printcharfun, escapeflag));
 
     }
-  write_fmt_string (printcharfun, " 0x%x>", NORMAL_LISP_OBJECT_UID (f));
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static void
--- a/src/opaque.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/opaque.c	Mon Mar 15 16:35:38 2010 -0500
@@ -51,8 +51,8 @@
 
   write_fmt_string
     (printcharfun,
-     "#<INTERNAL OBJECT (XEmacs bug?) (opaque, size=%lu) 0x%lx>",
-     (long)(p->size), (unsigned long) p);
+     "#<INTERNAL OBJECT (XEmacs bug?) (opaque, size=%lu) 0x%x>",
+     (long)(p->size), LISP_OBJECT_UID (obj));
 }
 
 inline static Bytecount
@@ -132,8 +132,8 @@
 
   write_fmt_string
     (printcharfun,
-     "#<INTERNAL OBJECT (XEmacs bug?) (opaque-ptr, adr=0x%lx) 0x%lx>",
-     (long)(p->ptr), (unsigned long) p);
+     "#<INTERNAL OBJECT (XEmacs bug?) (opaque-ptr, adr=0x%lx) 0x%x>",
+     (long)(p->ptr), LISP_OBJECT_UID (obj));
 }
 
 static int
--- a/src/print.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/print.c	Mon Mar 15 16:35:38 2010 -0500
@@ -1569,17 +1569,16 @@
 {
   if (print_readably)
     printing_unreadable_object_fmt
-      ("#<INTERNAL OBJECT (XEmacs bug?) (%s) 0x%lx>",
-       XRECORD_LHEADER_IMPLEMENTATION (obj)->name,
-       (unsigned long) XPNTR (obj));
+      ("#<INTERNAL OBJECT (XEmacs bug?) (%s) 0x%x>",
+       XRECORD_LHEADER_IMPLEMENTATION (obj)->name, LISP_OBJECT_UID (obj));
 
   /* Internal objects shouldn't normally escape to the Lisp level;
      that's why we say "XEmacs bug?".  This can happen, however, when
      printing backtraces. */
   write_fmt_string (printcharfun,
-		    "#<INTERNAL OBJECT (XEmacs bug?) (%s) 0x%lx>",
+		    "#<INTERNAL OBJECT (XEmacs bug?) (%s) 0x%x>",
 		    XRECORD_LHEADER_IMPLEMENTATION (obj)->name,
-		    (unsigned long) XPNTR (obj));
+		    LISP_OBJECT_UID (obj));
 }
 
 enum printing_badness
--- a/src/rangetab.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/rangetab.c	Mon Mar 15 16:35:38 2010 -0500
@@ -133,7 +133,7 @@
   if (print_readably)
     write_ascstring (printcharfun, "))");
   else
-    write_fmt_string (printcharfun, " 0x%x>", NORMAL_LISP_OBJECT_UID (rt));
+    write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static int
--- a/src/specifier.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/specifier.c	Mon Mar 15 16:35:38 2010 -0500
@@ -281,7 +281,7 @@
 
   if (print_readably)
     printing_unreadable_object_fmt ("#<%s-specifier 0x%x>",
-				sp->methods->name, NORMAL_LISP_OBJECT_UID (sp));
+				    sp->methods->name, LISP_OBJECT_UID (obj));
 
   write_fmt_string (printcharfun, "#<%s-specifier global=", sp->methods->name);
 #if 0
@@ -302,7 +302,7 @@
       write_fmt_string_lisp (printcharfun, " fallback=%S", 1, sp->fallback);
     }
   unbind_to (count);
-  write_fmt_string (printcharfun, " 0x%x>", NORMAL_LISP_OBJECT_UID (sp));
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 #ifndef NEW_GC
--- a/src/symbols.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/symbols.c	Mon Mar 15 16:35:38 2010 -0500
@@ -1105,10 +1105,10 @@
 			  int UNUSED (escapeflag))
 {
   write_fmt_string (printcharfun,
-		    "#<INTERNAL OBJECT (XEmacs bug?) (%s type %d) 0x%lx>",
+		    "#<INTERNAL OBJECT (XEmacs bug?) (%s type %d) 0x%x>",
 		    XRECORD_LHEADER_IMPLEMENTATION (obj)->name,
 		    XSYMBOL_VALUE_MAGIC_TYPE (obj),
-		    (long) XPNTR (obj));
+		    LISP_OBJECT_UID (obj));
 }
 
 static const struct memory_description symbol_value_forward_description[] = {
--- a/src/tooltalk.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/tooltalk.c	Mon Mar 15 16:35:38 2010 -0500
@@ -1,7 +1,7 @@
 /* Tooltalk support for Emacs.
    Copyright (C) 1993, 1994 Sun Microsystems, Inc.
    Copyright (C) 1995 Free Software Foundation, Inc.
-   Copyright (C) 2002 Ben Wing.
+   Copyright (C) 2002, 2010 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -175,7 +175,7 @@
     printing_unreadable_lisp_object (obj, 0);
 
   write_fmt_string (printcharfun, "#<tooltalk-message id:0x%lx 0x%x>",
-		    (long) (p->m), NORMAL_LISP_OBJECT_UID (p));
+		    (long) (p->m), LISP_OBJECT_UID (obj));
 }
 
 DEFINE_NODUMP_LISP_OBJECT ("tooltalk-message", tooltalk_message,
@@ -250,7 +250,7 @@
     printing_unreadable_lisp_object (obj, 0);
 
   write_fmt_string (printcharfun, "#<tooltalk-pattern id:0x%lx 0x%x>",
-		    (long) (p->p), NORMAL_LISP_OBJECT_UID (p));
+		    (long) (p->p), LISP_OBJECT_UID (obj));
 }
 
 DEFINE_NODUMP_LISP_OBJECT ("tooltalk-pattern", tooltalk_pattern,
--- a/src/window.c	Mon Mar 15 16:15:12 2010 -0500
+++ b/src/window.c	Mon Mar 15 16:35:38 2010 -0500
@@ -321,8 +321,7 @@
       Lisp_Object name = XBUFFER (buf)->name;
       write_fmt_string_lisp (printcharfun, " on %S", 1, name);
     }
-  write_fmt_string (printcharfun, " 0x%x>",
-		    NORMAL_LISP_OBJECT_UID (XWINDOW (obj)));
+  write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
 }
 
 static void
@@ -5407,7 +5406,7 @@
     if (!NILP (buffer) && BUFFERP (buffer))
       stderr_out (" on %s", XSTRING_DATA (XBUFFER (buffer)->name));
   }
-  stderr_out (" 0x%x>", NORMAL_LISP_OBJECT_UID (XWINDOW (window)));
+  stderr_out (" 0x%x>", LISP_OBJECT_UID (window));
 
   while (!NILP (child))
     {