pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod: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" #include "interpret.h" #include "svalue.h" #include "opcodes.h" #include "pike_macros.h" #include "object.h" #include "program.h" #include "array.h"
pike.git/src/builtin.cmod:1099:
} }; /*! @endclass */ /*! @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; call_c_initializers(o); size--; res->item[size].u.object = o; res->item[size].type = PIKE_T_OBJECT; res->item[size].subtype = 0;
pike.git/src/builtin.cmod:1182:
bf->fun.subtype = f->fun; bf->fun.type = PIKE_T_FUNCTION; } else { bf->fun.u.integer = 0; bf->fun.subtype = NUMBER_DESTRUCTED; bf->fun.type = PIKE_T_INT; } 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 */ numargs = DO_NOT_WARN((INT32)MINIMUM(f->num_args,of->locals - f->locals)); numargs = MAXIMUM(numargs, 0); if (numargs) { bf->args = allocate_array_no_init(numargs, 0); assign_svalues_no_free(bf->args->item, f->locals, numargs, BIT_MIXED); } } } /* 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 */ /*! @class Buffer *! A buffer, used for building strings. It's *! conceptually similar to a string, but you can only @[add] *! strings to it, and you can only @[get] the value from it once. *!