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.112 2001/04/11 11:54:01 grubba Exp $"); + RCSID("$Id: main.c,v 1.113 2001/05/16 23:34:38 hubbe Exp $");   #include "fdlib.h"   #include "backend.h"   #include "module.h"   #include "object.h"   #include "language.h"   #include "lex.h"   #include "pike_types.h"   #include "builtin_functions.h"   #include "array.h"   #include "stralloc.h"
pike.git/src/main.c:84:      static void time_to_exit(struct callback *cb,void *tmp,void *ignored)   {    if(instructions_left-- < 0)    {    push_int(0);    f_exit(1);    }   }    + #ifdef PROFILING + static unsigned int samples[8200]; + long record; +  + static void sample_stack(struct callback *cb,void *tmp,void *ignored) + { +  long stack_size=( ((char *)&cb) - Pike_interpreter.stack_bottom) * STACK_DIRECTION; +  stack_size>>=10; +  stack_size++; +  if(stack_size<0) stack_size=0; +  if(stack_size >= (long)NELEM(samples)) stack_size=NELEM(samples)-1; +  samples[stack_size]++; + #ifdef PIKE_DEBUG +  if(stack_size > record) +  { +  extern void gdb_break_on_stack_record(long); +  gdb_break_on_stack_record(stack_size); +  record=stack_size; +  } + #endif + } +  + #ifdef PIKE_DEBUG + void gdb_break_on_stack_record(long stack_size) + { +  ; + } + #endif + #endif +    static struct callback_list post_master_callbacks;      PMOD_EXPORT 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);   }      
pike.git/src/main.c:364:       case 't':    if(p[1]>='0' && p[1]<='9')    t_flag+=STRTOL(p+1,&p,10);    else    t_flag++,p++;    default_t_flag = t_flag;    break;       case 'p': +  if(p[1]=='s') +  { + #ifdef PROFILING +  add_to_callback(&evaluator_callbacks, +  sample_stack, +  0,0); +  p+=strlen(p); + #endif +  }else{    if(p[1]>='0' && p[1]<='9')    p_flag+=STRTOL(p+1,&p,10);    else    p_flag++,p++; -  +  }    break;       case 'l':    if(p[1]>='0' && p[1]<='9')    l_flag+=STRTOL(p+1,&p,10);    else    l_flag++,p++;    break;       default:
pike.git/src/main.c:408:    * too unsafe (consider 64-bit systems).    */   #if STACK_DIRECTION < 0    /* Equvivalent with |= 0xffff */    Pike_interpreter.stack_top += (~((size_t)Pike_interpreter.stack_top)) & 0xffff;   #else /* STACK_DIRECTION >= 0 */    /* Equvivalent with &= ~0xffff */    Pike_interpreter.stack_top -= ( ((size_t)Pike_interpreter.stack_top)) & 0xffff;   #endif /* STACK_DIRECTION < 0 */    + #ifdef PROFILING +  Pike_interpreter.stack_bottom=Pike_interpreter.stack_top; + #endif +    #if defined(HAVE_GETRLIMIT) && defined(RLIMIT_STACK)    {    struct rlimit lim;    if(!getrlimit(RLIMIT_STACK, &lim))    {   #ifdef RLIM_INFINITY    if(lim.rlim_cur == RLIM_INFINITY)    lim.rlim_cur=1024*1024*32;   #endif   
pike.git/src/main.c:592:       exit_modules();      #ifdef DEBUG_MALLOC    {    extern void cleanup_memhdrs(void);    cleanup_memhdrs();    }   #endif    + #ifdef PROFILING +  { +  int q; +  for(q=0;q<(long)NELEM(samples);q++) +  if(samples[q]) +  fprintf(stderr,"STACK WAS %4d Kb %12u times\n",q-1,samples[q]); +  } + #endif +     exit(num);   }         void low_init_main(void)   {    init_pike_searching();    init_error();    init_pike_security();    th_init();