pike.git / src / interpret.c

version» Context lines:

pike.git/src/interpret.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: interpret.c,v 1.336 2003/10/20 14:59:42 marcus Exp $ + || $Id: interpret.c,v 1.337 2003/11/09 01:10:13 mast Exp $   */      #include "global.h" - RCSID("$Id: interpret.c,v 1.336 2003/10/20 14:59:42 marcus Exp $"); + RCSID("$Id: interpret.c,v 1.337 2003/11/09 01:10:13 mast Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"   #include "svalue.h"   #include "array.h"   #include "mapping.h"   #include "pike_error.h"   #include "language.h"   #include "stralloc.h"   #include "constants.h"
pike.git/src/interpret.c:95:   #endif         /* Pike_sp points to first unused value on stack    * (much simpler than letting it point at the last used value.)    */   PMOD_EXPORT struct Pike_interpreter Pike_interpreter;   PMOD_EXPORT int Pike_stack_size = EVALUATOR_STACK_SIZE;      static void trace_return_value(void); - static void do_trace_call(INT32); + static void do_trace_call(INT32 args, dynamic_buffer *old_buf);      void gdb_stop_here(void)   {    ;   }         void push_sp_mark(void)   {    if(Pike_mark_sp == Pike_interpreter.mark_stack + Pike_stack_size)
pike.git/src/interpret.c:676:    p ? ID_FROM_INT(p,loc->parent_identifier)->name->str : "N/A"    ));   }      #ifdef PIKE_DEBUG   void print_return_value(void)   {    if(Pike_interpreter.trace_level>3)    {    char *s; +  dynamic_buffer save_buf;    -  init_buf(); +  init_buf(&save_buf);    describe_svalue(Pike_sp-1,0,0); -  s=simple_free_buf(); +  s=simple_free_buf(&save_buf);    if((size_t)strlen(s) > (size_t)TRACE_LEN)    {    s[TRACE_LEN]=0;    s[TRACE_LEN-1]='.';    s[TRACE_LEN-2]='.';    s[TRACE_LEN-3]='.';    }    fprintf(stderr,"- value: %s\n",s);    free(s);    }
pike.git/src/interpret.c:1339:   #else   #include "interpreter.h"   #endif         #endif /* PIKE_USE_MACHINE_CODE */      static void trace_return_value(void)   {    char *s; +  dynamic_buffer save_buf;    -  init_buf(); +  init_buf(&save_buf);    my_strcat("Return: ");    describe_svalue(Pike_sp-1,0,0); -  s=simple_free_buf(); +  s=simple_free_buf(&save_buf);    if((size_t)strlen(s) > (size_t)TRACE_LEN)    {    s[TRACE_LEN]=0;    s[TRACE_LEN-1]='.';    s[TRACE_LEN-2]='.';    s[TRACE_LEN-2]='.';    }    fprintf(stderr,"%-*s%s\n",4,"-",s);    free(s);   }    - static void do_trace_call(INT32 args) + static void do_trace_call(INT32 args, dynamic_buffer *old_buf)   {    struct pike_string *filep = NULL;    char *file, *s;    INT32 linep,e;    my_strcat("(");    for(e=0;e<args;e++)    {    if(e) my_strcat(",");    describe_svalue(Pike_sp-args+e,0,0);    }    my_strcat(")"); -  s=simple_free_buf(); +  s=simple_free_buf(old_buf);    if((size_t)strlen(s) > (size_t)TRACE_LEN)    {    s[TRACE_LEN]=0;    s[TRACE_LEN-1]='.';    s[TRACE_LEN-2]='.';    s[TRACE_LEN-2]='.';    }    if(Pike_fp && Pike_fp->pc)    {    char *f;
pike.git/src/interpret.c:1536:    Pike_error("Call to non-function value type:%s.\n",    get_name_of_type(s->type));       case T_FUNCTION:    if(s->subtype == FUNCTION_BUILTIN)    {   #ifdef PIKE_DEBUG    struct svalue *expected_stack = Pike_sp-args;    if(Pike_interpreter.trace_level>1)    { -  init_buf(); +  dynamic_buffer save_buf; +  init_buf(&save_buf);    describe_svalue(s,0,0); -  do_trace_call(args); +  do_trace_call(args, &save_buf);    }   #endif    check_threads_etc();    (*(s->u.efun->function))(args);      #ifdef PIKE_DEBUG    s->u.efun->runs++;    if(Pike_sp != expected_stack + !s->u.efun->may_return_void)    {    if(Pike_sp < expected_stack)
pike.git/src/interpret.c:1584:    }    fun=s->subtype;    goto apply_low;    }    break;       case T_ARRAY:   #ifdef PIKE_DEBUG    if(Pike_interpreter.trace_level>1)    { -  init_buf(); +  dynamic_buffer save_buf; +  init_buf(&save_buf);    describe_svalue(s,0,0); -  do_trace_call(args); +  do_trace_call(args, &save_buf);    }   #endif    apply_array(s->u.array,args);    break;       case T_PROGRAM:   #ifdef PIKE_DEBUG    if(Pike_interpreter.trace_level>1)    { -  init_buf(); +  dynamic_buffer save_buf; +  init_buf(&save_buf);    describe_svalue(s,0,0); -  do_trace_call(args); +  do_trace_call(args, &save_buf);    }   #endif    push_object(clone_object(s->u.program,args));    break;       case T_OBJECT:    o=s->u.object;    if(o->prog == pike_trampoline_program)    {    fun=((struct pike_trampoline *)(o->storage))->func;
pike.git/src/interpret.c:1941:    dmalloc_touch_svalue(Pike_sp-1);    throw_value.type=T_INT;       if (get_master()) { /* May return NULL at odd times. */    ONERROR tmp;    SET_ONERROR(tmp,exit_on_error,"Error in handle_error in master object!");    APPLY_MASTER("handle_error", 1);    UNSET_ONERROR(tmp);    }    else { +  dynamic_buffer save_buf;    char *s;    fprintf (stderr, "There's no master to handle the error. Dumping it raw:\n"); -  init_buf(); +  init_buf(&save_buf);    describe_svalue (Pike_sp - 1, 0, 0); -  s=simple_free_buf(); +  s=simple_free_buf(&save_buf);    fprintf(stderr,"%s\n",s);    free(s);    }       pop_stack();    Pike_interpreter.svalue_stack_margin = SVALUE_STACK_MARGIN;    Pike_interpreter.c_stack_margin = C_STACK_MARGIN;    Pike_interpreter.trace_level = old_t_flag;    }