Branch: Tag:

2004-09-27

2004-09-27 21:37:23 by Martin Stjernholm <mast@lysator.liu.se>

Fixed --with-cleanup-on-exit to work without rtldebug.

Rev: src/array.h:1.64
Rev: src/dmalloc.h:1.53
Rev: src/gc.c:1.259
Rev: src/gc.h:1.116
Rev: src/main.c:1.210
Rev: src/mapping.h:1.58
Rev: src/multiset.h:1.37
Rev: src/object.h:1.87
Rev: src/pike_memory.c:1.156
Rev: src/program.h:1.210
Rev: src/stralloc.c:1.168
Rev: src/stralloc.h:1.82

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: main.c,v 1.209 2004/09/26 15:18:01 marcus Exp $ + || $Id: main.c,v 1.210 2004/09/27 21:37:23 mast Exp $   */      #include "global.h"
928: Inside #if defined(DO_PIKE_CLEANUP)
  #ifdef DO_PIKE_CLEANUP    size_t count;    - #ifdef PIKE_DEBUG -  if (verbose_debug_exit) -  fprintf(stderr,"Exited normally, counting bytes.\n"); - #endif -  +  if (exit_with_cleanup) {    /* Destruct all remaining objects while we have a proper execution    * environment. The downside is that the leak report below will    * always report destructed objects. We use the gc in a special mode
949: Inside #if defined(DO_PIKE_CLEANUP)
   count = new_count;    }    gc_destruct_everything = 0; +  }       /* Unload dynamic modules before static ones. */    exit_dynamic_load();
1000: Inside #if defined(DO_PIKE_CLEANUP)
      do_gc(NULL, 1);    - #ifdef PIKE_DEBUG -  if(verbose_debug_exit) +  if (exit_with_cleanup)    { -  +  int leak_found = 0; +    #ifdef _REENTRANT    if(count_pike_threads()>1)    {    fprintf(stderr,"Byte counting aborted, because all threads have not exited properly.\n"); -  verbose_debug_exit=0; +  exit_with_cleanup = 0;    return;    }   #endif
1026: Inside #if defined(DO_PIKE_CLEANUP)
  #define STATIC_ARRAYS {&empty_array, &weak_empty_array}      #define REPORT_LINKED_LIST_LEAKS(TYPE, START, STATICS, T_TYPE, NAME) do { \ -  size_t num = 0; \ +     struct TYPE *x; \    for (x = START; x; x = x->next) { \    struct marker *m = find_marker (x); \
1044:    if (x == statics[i]) \    is_static = 1; \    if (x->refs != m->refs + is_static) { \ -  num++; \ -  fprintf (stderr, NAME " got %d unaccounted references:\n", \ +  if (!leak_found) { \ +  fputs ("Leak(s) found at exit:\n", stderr); \ +  leak_found = 1; \ +  } \ +  fprintf (stderr, NAME " got %d unaccounted references: ", \    x->refs - (m->refs + is_static)); \ -  describe_something (x, T_TYPE, 2, 2, 0, NULL); \ +  print_short_svalue (stderr, (union anything *) &x, T_TYPE); \ +  fputc ('\n', stderr); \    } \    } \    } \ -  if (num) \ -  fprintf (stderr, NAME "s left: %"PRINTSIZET"d\n", num); \ +     } while (0)       REPORT_LINKED_LIST_LEAKS (array, first_array, STATIC_ARRAYS, T_ARRAY, "Array");
1079:    if (x == statics[i]) \    is_static = 1; \    while (x->refs > m->refs + is_static) { \ -  m->flags |= GC_CLEANUP_FREED; \ +  DO_IF_DEBUG (m->flags |= GC_CLEANUP_FREED); \    PIKE_CONCAT(free_, TYPE) (x); \    } \    } \
1094:      #undef ZAP_LINKED_LIST_LEAKS    + #ifdef PIKE_DEBUG    /* If we stumble on the real refs whose refcounts we've zapped    * above we should try to handle it gracefully. */    gc_external_refs_zapped = 1; -  + #endif       do_gc (NULL, 1);   
1113:    }   #endif    } - #endif +        destruct_objects_to_destruct_cb();