Branch: Tag:

2001-09-05

2001-09-05 23:44:32 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

fix for [bug 2167 (#2167)] (can only happen when using Java callbacks I think)

Rev: src/builtin.cmod:1.64
Rev: src/threads.c:1.162

1:   /* -*- c -*- -  * $Id: builtin.cmod,v 1.63 2001/08/15 09:26:02 hubbe Exp $ +  * $Id: builtin.cmod,v 1.64 2001/09/05 23:44:32 hubbe Exp $    */      #include "global.h"
1106:   /*! @endmodule    */    - /*! @decl array(Pike.BacktraceFrame) backtrace() -  *! -  *! FIXME: This documentation is not up to date! -  *! -  *! Get a description of the current call stack. -  *! -  *! The description is returned as an array with one entry for each call -  *! frame on the stack. -  *! -  *! Each entry has this format: -  *! @array -  *! @elem string file -  *! A string with the filename if known, else zero. -  *! @elem int line -  *! An integer containing the linenumber if known, else zero. -  *! @elem function fun -  *! The function that was called at this level. -  *! @elem mixed|void ... args -  *! The arguments that the function was called with. -  *! @endarray -  *! -  *! The current call frame will be last in the array. -  *! -  *! @note -  *! Please note that the frame order may be reversed in a later version -  *! (than 7.1) of Pike to accomodate for deferred backtraces. -  *! -  *! Note that the arguments reported in the backtrace are the current -  *! values of the variables, and not the ones that were at call-time. -  *! This can be used to hide sensitive information from backtraces -  *! (eg passwords). -  *! -  *! @seealso -  *! @[catch()], @[throw()] -  */ - PMOD_EXPORT - PIKEFUN array(mixed) backtrace() -  efun; -  optflags OPT_EXTERNAL_DEPEND; + void low_backtrace(struct Pike_interpreter *i)   {    struct pike_frame *f, *of = 0;    int size = 0;    struct array *res = NULL;    -  for (f = Pike_fp; f; f = f->next) { +  for (f = i->frame_pointer; f; f = f->next) {    size++;    }       res = allocate_array_no_init(size, 0);    push_array(res);    -  for (f = Pike_fp; f && size; f = (of = f)->next) { +  for (f = i->frame_pointer; f && size; f = (of = f)->next) {    struct object *o = low_clone(backtrace_frame_program);    struct backtrace_frame_struct *bf;   
1189:       if (f->locals) {    INT32 numargs = DO_NOT_WARN((INT32) MINIMUM(f->num_args, -  Pike_sp - f->locals)); +  i->stack_pointer - f->locals));    if(of)    /* f->num_args can be too large, so this is necessary for some    * reason. I don't know why. /mast */
1206:    /* NOTE: res has already been pushed on the stack. */   }    + /*! @decl array(Pike.BacktraceFrame) backtrace() +  *! +  *! FIXME: This documentation is not up to date! +  *! +  *! Get a description of the current call stack. +  *! +  *! The description is returned as an array with one entry for each call +  *! frame on the stack. +  *! +  *! Each entry has this format: +  *! @array +  *! @elem string file +  *! A string with the filename if known, else zero. +  *! @elem int line +  *! An integer containing the linenumber if known, else zero. +  *! @elem function fun +  *! The function that was called at this level. +  *! @elem mixed|void ... args +  *! The arguments that the function was called with. +  *! @endarray +  *! +  *! The current call frame will be last in the array. +  *! +  *! @note +  *! Please note that the frame order may be reversed in a later version +  *! (than 7.1) of Pike to accomodate for deferred backtraces. +  *! +  *! Note that the arguments reported in the backtrace are the current +  *! values of the variables, and not the ones that were at call-time. +  *! This can be used to hide sensitive information from backtraces +  *! (eg passwords). +  *! +  *! @seealso +  *! @[catch()], @[throw()] +  */ + PMOD_EXPORT + PIKEFUN array(mixed) backtrace() +  efun; +  optflags OPT_EXTERNAL_DEPEND; + { +  low_backtrace(& Pike_interpreter); + } +    #define INITIAL_BUF_LEN 4096      /*! @module String