pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:1:   /*   || 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: gc.c,v 1.337 2009/11/28 11:49:47 mast Exp $ + || $Id: gc.c,v 1.338 2009/11/28 13:36:20 mast Exp $   */      #include "global.h"      struct callback *gc_evaluator_callback=0;      #include "array.h"   #include "multiset.h"   #include "mapping.h"   #include "object.h"
pike.git/src/gc.c:986:    putc(']', stderr);    }    putc('\n', stderr);    }    else    fprintf(stderr, "no marker\n");   }      #endif /* PIKE_DEBUG */    - static void debug_gc_fatal_va (void *a, int flags, + static void debug_gc_fatal_va (void *a, int type, int flags,    const char *fmt, va_list args)   {   #ifdef PIKE_DEBUG    struct marker *m;   #endif    int orig_gc_pass = Pike_in_gc;       (void) VFPRINTF(stderr, fmt, args);      #ifdef PIKE_DEBUG    if (a) { -  +  void *inblock;    /* Temporarily jumping out of gc to avoid being caught in debug    * checks in describe(). */    Pike_in_gc = 0; -  describe(a); +  if (type == PIKE_T_UNKNOWN) +  type = attempt_to_identify (a, &inblock); +  describe_something (a, type, 0, 0, 0, inblock);    if (flags & 1) locate_references(a);    Pike_in_gc = orig_gc_pass;    }       if (flags & 2)    fatal_after_gc = "Fatal in garbage collector.\n";    else   #endif    {    d_flag = 0; /* The instruction backlog is never of any use here. */    debug_fatal (NULL);    }   }      void debug_gc_fatal (void *a, int flags, const char *fmt, ...)   {    va_list args;    va_start (args, fmt); -  debug_gc_fatal_va (a, flags, fmt, args); +  debug_gc_fatal_va (a, PIKE_T_UNKNOWN, flags, fmt, args);    va_end (args);   }    -  + void debug_gc_fatal_2 (void *a, int type, int flags, const char *fmt, ...) + { +  va_list args; +  va_start (args, fmt); +  debug_gc_fatal_va (a, type, flags, fmt, args); +  va_end (args); + } +    static void dloc_gc_fatal (const char *file, int line,    void *a, int flags, const char *fmt, ...)   {    va_list args;    fprintf (stderr, "%s:%d: GC fatal:\n", file, line);    va_start (args, fmt); -  debug_gc_fatal_va (a, flags, fmt, args); +  debug_gc_fatal_va (a, PIKE_T_UNKNOWN, flags, fmt, args);    va_end (args);   }      static void rec_stack_fatal (struct gc_rec_frame *err, const char *err_name,    struct gc_rec_frame *p1, const char *p1n,    struct gc_rec_frame *p2, const char *p2n,    const char *file, int line,    const char *fmt, ...)   {    va_list args;
pike.git/src/gc.c:2452:    l->data = a;    l->type = type;    l->next = free_extra_list;    free_extra_list = l;    }       gc_add_extra_ref(a);    m->flags |= GC_GOT_DEAD_REF;   }    - int gc_mark(void *a) + int gc_mark_func(void *a DO_IF_DEBUG (COMMA int type))   {    struct marker *m;      #ifdef PIKE_DEBUG    if (Pike_in_gc == GC_PASS_ZAP_WEAK && !find_marker (a)) -  gc_fatal (a, 0, "gc_mark() called for for thing without marker " +  gc_fatal_2 (a, type, 0, "gc_mark() called for for thing without marker "    "in zap weak pass.\n");   #endif       m = get_marker (a);       /* Note: m->refs and m->xrefs are useless already here due to how    * gc_free_(short_)svalue works. */      #ifdef PIKE_DEBUG    if (gc_is_watching && m && m->flags & GC_WATCHED) {    /* This is useful to set breakpoints on. */    gc_watched_found (m, "gc_mark()");    }    if (!a) Pike_fatal("Got null pointer.\n");    if (Pike_in_gc != GC_PASS_MARK && Pike_in_gc != GC_PASS_ZAP_WEAK)    Pike_fatal("GC mark attempted in invalid pass.\n");    if (!*(INT32 *) a) -  gc_fatal(a, 0, "Marked a thing without refs.\n"); +  gc_fatal_2 (a, type, 1, "Marked a thing without refs.\n");    if (m->weak_refs < 0) -  gc_fatal(a, 0, "Marked a thing scheduled for weak free.\n"); +  gc_fatal_2 (a, type, 1, "Marked a thing scheduled for weak free.\n");   #endif       if (Pike_in_gc == GC_PASS_ZAP_WEAK) {    /* Things are visited in the zap weak pass through the mark    * functions to free refs to internal things that only got weak    * external references. That happens only when a thing also have    * internal cyclic nonweak refs. */   #ifdef PIKE_DEBUG    if (!(m->flags & GC_MARKED)) -  gc_fatal(a, 0, "gc_mark() called for thing in zap weak pass " +  gc_fatal_2 (a, type, 0, "gc_mark() called for thing in zap weak pass "    "that wasn't marked before.\n");   #endif    if (m->flags & GC_FREE_VISITED) {    debug_malloc_touch (a);    return 0;    }    else {    debug_malloc_touch (a);    m->flags |= GC_FREE_VISITED;    return 1;    }    }       else if (m->flags & GC_MARKED) {    debug_malloc_touch (a);   #ifdef PIKE_DEBUG    if (m->weak_refs != 0) -  gc_fatal (a, 0, "weak_refs changed in marker " +  gc_fatal_2 (a, type, 0, "weak_refs changed in marker "    "already visited by gc_mark().\n");   #endif    return 0;    }       else {    debug_malloc_touch (a);    if (m->weak_refs) {    gc_ext_weak_refs -= m->weak_refs;    m->weak_refs = 0;