Branch: Tag:

1998-01-25

1998-01-25 08:28:45 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

jumbopatch! (DEBUG_MALLOC + parent feature fix)

Rev: src/ChangeLog:1.130
Rev: src/acconfig.h:1.15
Rev: src/array.c:1.22
Rev: src/array.h:1.6
Rev: src/builtin_functions.c:1.62
Rev: src/builtin_functions.h:1.6
Rev: src/cpp.c:1.14
Rev: src/dmalloc.h:1.1
Rev: src/docode.c:1.25
Rev: src/dynamic_buffer.c:1.6
Rev: src/dynamic_buffer.h:1.4
Rev: src/error.c:1.10
Rev: src/error.h:1.9
Rev: src/fdlib.c:1.9
Rev: src/gc.c:1.27
Rev: src/global.h:1.13
Rev: src/interpret.c:1.61
Rev: src/language.yacc:1.54
Rev: src/las.c:1.43
Rev: src/las.h:1.11
Rev: src/lex.c:1.40
Rev: src/lex.h:1.9
Rev: src/main.c:1.35
Rev: src/main.h:1.4
Rev: src/mapping.c:1.27
Rev: src/mapping.h:1.7
Rev: src/module.c:1.7
Rev: src/modules/Image/colortable.c:1.36
Rev: src/modules/Image/encodings/gif.c:1.30
Rev: src/modules/Image/encodings/png.c:1.2
Rev: src/modules/Image/encodings/pnm.c:1.12
Rev: src/modules/Image/encodings/x.c:1.5
Rev: src/modules/Yp/yp.c:1.10
Rev: src/modules/files/efuns.c:1.44
Rev: src/modules/files/file.c:1.69
Rev: src/modules/files/socket.c:1.25
Rev: src/modules/files/socktest.pike:1.7
Rev: src/modules/spider/accesseddb.c:1.13
Rev: src/modules/spider/dumudp.c:1.32
Rev: src/modules/spider/spider.c:1.51
Rev: src/modules/system/system.c:1.39
Rev: src/multiset.c:1.9
Rev: src/object.c:1.33
Rev: src/peep.c:1.17
Rev: src/pike_memory.c:1.4
Rev: src/pike_memory.h:1.2
Rev: src/pike_types.c:1.29
Rev: src/pike_types.h:1.7
Rev: src/program.c:1.54
Rev: src/program.h:1.27
Rev: src/stralloc.c:1.24
Rev: src/stralloc.h:1.12
Rev: src/testsuite.in:1.68
Rev: src/threads.c:1.53

4:   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: main.c,v 1.34 1998/01/16 22:33:06 grubba Exp $"); + RCSID("$Id: main.c,v 1.35 1998/01/25 08:25:10 hubbe Exp $");   #include "fdlib.h"   #include "backend.h"   #include "module.h"
22:   #include "threads.h"   #include "dynamic_load.h"   #include "gc.h" + #include "multiset.h"   #include "mapping.h"   #include "cpp.h"   
58:   }       + static struct callback_list exit_callbacks; +  + struct callback *add_exit_callback(callback_func call, +  void *arg, +  callback_func free_func) + { +  return add_to_callback(&exit_callbacks, call, arg, free_func); + } +    int main(int argc, char **argv)   {    JMP_BUF back; -  int e, num; +  int e, num, do_backend;    char *p;    struct array *a;   #ifdef DECLARE_ENVIRON
268:       if(SETJMP(back))    { +  if(throw_severity == THROW_EXIT) +  { +  num=throw_value.u.integer; +  }else{    ONERROR tmp;    SET_ONERROR(tmp,exit_on_error,"Error in handle_error in master object!");    assign_svalue_no_free(sp, & throw_value);
275:    APPLY_MASTER("handle_error", 1);    pop_stack();    UNSET_ONERROR(tmp); -  exit(10); +  num=10;    } -  +  }else{ +  back.severity=THROW_EXIT;       apply(master(),"_main",2);    pop_stack();    -  +  backend(); +  num=0; +  }    UNSETJMP(back);    -  backend(); +  do_exit(num); + }    -  push_int(0); -  f_exit(1); + void do_exit(int num) + { +  call_callback(&exit_callbacks, (void *)0); +  free_callback(&exit_callbacks);    -  /* NOT REACHED */ -  return(-1); /* To avoid warnings. */ +  exit_modules(); +  +  exit(num);   }      
315:    void cleanup_added_efuns(void);    void cleanup_pike_types(void);    void cleanup_program(void); +  void cleanup_compiler(void);       th_cleanup();    exit_dynamic_load();
325:    cleanup_added_efuns();    cleanup_pike_types();    cleanup_program(); +  cleanup_compiler();       do_gc();       cleanup_callbacks(); -  + #if defined(DEBUG) && defined(DEBUG_MALLOC) +  if(verbose_debug_exit) +  { +  INT32 num,size,recount=0; +  +  count_memory_in_arrays(&num, &size); +  if(num || size) +  { +  recount++; +  fprintf(stderr,"Arrays left: %d (%d bytes) (zapped)\n",num,size); +  } +     zap_all_arrays(); -  +  +  count_memory_in_mappings(&num, &size); +  if(num || size) +  { +  recount++; +  fprintf(stderr,"Mappings left: %d (%d bytes) (zapped)\n",num,size); +  } +     zap_all_mappings();    -  +  count_memory_in_multisets(&num, &size); +  if(num || size) +  fprintf(stderr,"Multisets left: %d (%d bytes)\n",num,size); +  +  +  if(recount) +  { +  fprintf(stderr,"Garbage collecting..\n"); +  do_gc(); +  +  count_memory_in_arrays(&num, &size); +  fprintf(stderr,"Arrays left: %d (%d bytes)\n",num,size); +  count_memory_in_mappings(&num, &size); +  fprintf(stderr,"Mappings left: %d (%d bytes)\n",num,size); +  count_memory_in_multisets(&num, &size); +  fprintf(stderr,"Multisets left: %d (%d bytes)\n",num,size); +  } +  +  +  count_memory_in_programs(&num, &size); +  if(num || size) +  fprintf(stderr,"Programs left: %d (%d bytes)\n",num,size); +  +  { +  struct program *p; +  for(p=first_program;p;p=p->next) +  { +  describe_something(p, T_PROGRAM); +  } +  } +  +  +  count_memory_in_objects(&num, &size); +  if(num || size) +  fprintf(stderr,"Objects left: %d (%d bytes)\n",num,size); +  +  count_memory_in_strings(&num, &size); +  if(num || size) +  fprintf(stderr,"Strings left: %d (%d bytes) (zapped)\n",num,size); +     cleanup_shared_string_table();    } -  + #else    -  +  zap_all_arrays(); +  zap_all_mappings(); +  +  cleanup_shared_string_table(); + #endif + } +