Branch: Tag:

2019-02-26

2019-02-26 12:15:30 by Henrik Grubbström (Grubba) <grubba@grubba.org>

EFUNs: backtrace() now takes an optional argument.

Calling backtrace() with an argument of 1 now causes
it to return an array(LiveBacktraceFrame) instead of
an array(BacktraceFrame).

2861:   /*! @class Thread    */    - /*! @decl array(mixed) backtrace() + /*! @decl array(mixed) backtrace(int|void flags)    *!    *! Returns the current call stack for the thread.    *! -  +  *! @param flags +  *! +  *! A bit mask of flags affecting generation of the backtrace. +  *! +  *! Currently a single flag is defined: +  *! @int +  *! @value 1 +  *! Return @[LiveBacktraceFrame]s. This flag causes the frame +  *! objects to track changes (as long as they are in use), and +  *! makes eg local variables for functions available for +  *! inspection or change. +  *! +  *! Note that since these values are "live", they may change or +  *! dissapear at any time unless the corresponding thread has +  *! been halted or similar. +  *! @endint +  *!    *! @returns    *! The result has the same format as for @[predef::backtrace()].    *!
2874:   void f_thread_backtrace(INT32 args)   {    struct thread_state *foo = THIS_THREAD; +  int flags = 0;    -  pop_n_elems(args); -  +     if(foo == Pike_interpreter.thread_state)    { -  f_backtrace(0); +  f_backtrace(args); +  +  return;    } -  else if(foo->state.stack_pointer) +  +  get_all_args("backtrace", args, ".d", &flags); +  +  pop_n_elems(args); +  +  if(foo->state.stack_pointer)    { -  low_backtrace(& foo->state); +  low_backtrace(& foo->state, flags);    }    else    { -  push_int(0); -  f_allocate(1); +  ref_push_array(&empty_array);    }   }