pike.git / src / main.c

version» Context lines:

pike.git/src/main.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| 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"   #include "object.h"   #include "lex.h"   #include "pike_types.h"   #include "builtin_functions.h"   #include "array.h"   #include "stralloc.h"   #include "interpret.h"   #include "error.h"   #include "pike_macros.h"   #include "callback.h"   #include "signal_handler.h"   #include "threads.h"   #include "dynamic_load.h"   #include "gc.h" -  + #include "multiset.h"   #include "mapping.h"   #include "cpp.h"      #include <errno.h>      #ifdef HAVE_LOCALE_H   #include <locale.h>   #endif      #include "time_stuff.h"
pike.git/src/main.c:51:   static struct callback_list post_master_callbacks;      struct callback *add_post_master_callback(callback_func call,    void *arg,    callback_func free_func)   {    return add_to_callback(&post_master_callbacks, call, arg, free_func);   }       + 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    extern char **environ;   #endif       ARGV=argv;       fd_init();   
pike.git/src/main.c:261:    a=allocate_array_no_init(num,0);    for(num=0;environ[num];num++)    {    ITEM(a)[num].u.string=make_shared_string(environ[num]);    ITEM(a)[num].type=T_STRING;    }    push_array(a);       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);    sp++;    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);   }         void low_init_main(void)   {    th_init();    init_builtin_efuns();    init_signals();    init_dynamic_load();   }
pike.git/src/main.c:308:      void init_main(void)   {   }      void low_exit_main(void)   {    void cleanup_added_efuns(void);    void cleanup_pike_types(void);    void cleanup_program(void); +  void cleanup_compiler(void);       th_cleanup();    exit_dynamic_load();    exit_signals();    exit_lex();    exit_cpp();    cleanup_interpret();    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 + } +