# HG changeset patch # User Ben Wing # Date 1263885699 21600 # Node ID 714f7c9fabb145e96757137bb510104e404eb510 # Parent 77e3b19bd2453b618b0f7360bdeb1624f2e1ed42 make it easier to debug staticpro crashes. Add functions to print out the variable names saved during calls to staticpro(), and change the order of enumerating staticpros to start from 0 to make it easier to get a count to pass to the new functions. diff -r 77e3b19bd245 -r 714f7c9fabb1 src/alloc.c --- a/src/alloc.c Sun Jan 24 22:06:20 2010 -0600 +++ b/src/alloc.c Tue Jan 19 01:21:39 2010 -0600 @@ -3281,6 +3281,13 @@ dump_add_root_lisp_object (varaddress); } +/* External debugging function: Return the name of the variable at offset + COUNT. */ +char * +staticpro_name (int count) +{ + return Dynarr_at (staticpro_names, count); +} Lisp_Object_ptr_dynarr *staticpros_nodump; char_ptr_dynarr *staticpro_nodump_names; @@ -3294,6 +3301,14 @@ Dynarr_add (staticpro_nodump_names, varname); } +/* External debugging function: Return the name of the variable at offset + COUNT. */ +char * +staticpro_nodump_name (int count) +{ + return Dynarr_at (staticpro_nodump_names, count); +} + #ifdef HAVE_SHLIB /* Stop treating the Lisp_Object at non-heap VARADDRESS as a root object for garbage collection, but not for dumping. */ @@ -3418,6 +3433,14 @@ Dynarr_add (mcpro_names, varname); } +/* External debugging function: Return the name of the variable at offset + COUNT. */ +char * +mcpro_name (int count) +{ + return Dynarr_at (mcpro_names, count); +} + #else /* not DEBUG_XEMACS */ Lisp_Object_dynarr *mcpros; diff -r 77e3b19bd245 -r 714f7c9fabb1 src/gc.c --- a/src/gc.c Sun Jan 24 22:06:20 2010 -0600 +++ b/src/gc.c Tue Jan 19 01:21:39 2010 -0600 @@ -1,5 +1,6 @@ /* New incremental garbage collector for XEmacs. Copyright (C) 2005 Marcus Crestani. + Copyright (C) 2010 Ben Wing. This file is part of XEmacs. @@ -1624,8 +1625,9 @@ { /* staticpro() */ Lisp_Object **p = Dynarr_begin (staticpros); + Elemcount len = Dynarr_length (staticpros); Elemcount count; - for (count = Dynarr_length (staticpros); count; count--, p++) + for (count = 0; count < len; count++, p++) /* Need to check if the pointer in the staticpro array is not NULL. A gc can occur after variable is added to the staticpro array and _before_ it is correctly initialized. In this case @@ -1636,8 +1638,9 @@ { /* staticpro_nodump() */ Lisp_Object **p = Dynarr_begin (staticpros_nodump); + Elemcount len = Dynarr_length (staticpros_nodump); Elemcount count; - for (count = Dynarr_length (staticpros_nodump); count; count--, p++) + for (count = 0; count < len; count++, p++) /* Need to check if the pointer in the staticpro array is not NULL. A gc can occur after variable is added to the staticpro array and _before_ it is correctly initialized. In this case @@ -1649,9 +1652,10 @@ #ifdef NEW_GC { /* mcpro () */ Lisp_Object *p = Dynarr_begin (mcpros); + Elemcount len = Dynarr_length (mcpros); Elemcount count; - for (count = Dynarr_length (mcpros); count; count--) - mark_object (*p++); + for (count = 0; count < len; count++, p++) + mark_object (*p); } #endif /* NEW_GC */