pike.git / src / modules / _Debug / debug.c

version» Context lines:

pike.git/src/modules/_Debug/debug.c:3:   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information.   */      #include "global.h"   #include "module.h"   #include "pike_error.h"   #include "interpret.h"   #include "pike_embed.h"   #include "module_support.h" + #include "pike_security.h"    -  + /*! @decl int(0..) map_all_objects(function(object:void) cb) +  *! @belongs Debug +  *! +  *! Call cb for all objects that currently exist. The callback will +  *! not be called with destructed objects as it's argument. +  *! +  *! Objects might be missed if @[cb] creates new objects or destroys +  *! old ones. +  *! +  *! This function is only intended to be used for debug purposes. +  *! +  *! @returns +  *! The total number of objects +  *! +  *! @seealso +  *! @[next_object()] +  */ + static void f_map_all_objects( INT32 args ) + { +  struct object *o = first_object; +  INT32 total = 0; +  ASSERT_SECURITY_ROOT("map_all_objects"); +  +  if( args!=1 ) +  SIMPLE_WRONG_NUM_ARGS_ERROR("map_all_objects", 1); +  +  while( o ) +  { +  struct object *next = o->next; +  if( o->prog ) +  { +  ref_push_object( o ); +  safe_apply_svalue( Pike_sp-2, 1, 1 ); +  pop_stack(); +  } +  total++; +  o = next; +  } +  pop_stack(); +  push_int(total); + } +    #ifdef PIKE_DEBUG   /* This function is for debugging *ONLY*    * do not document please. /Hubbe    */   PMOD_EXPORT void f__leak(INT32 args)   {    INT32 i;       if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("_leak", 1);
pike.git/src/modules/_Debug/debug.c:142: Inside #if defined(PIKE_DEBUG) and #if defined(YYDEBUG)
   push_int(yydebug);    yydebug = yyd;   }      #endif /* YYDEBUG */      #endif /* PIKE_DEBUG */      PIKE_MODULE_INIT   { +  ADD_FUNCTION("map_all_objects", f_map_all_objects, +  tFunc(tFunction,tIntPos), OPT_EXTERNAL_DEPEND);   #ifdef PIKE_DEBUG    ADD_INT_CONSTANT("HAVE_DEBUG", 1, 0);    ADD_FUNCTION("_leak", f__leak, tFunc(tRef,tInt), OPT_EXTERNAL_DEPEND);    ADD_FUNCTION("debug", f_debug,    tFunc(tIntPos,tIntPos), OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND);    ADD_FUNCTION("optimizer_debug", f_optimizer_debug,    tFunc(tIntPos,tIntPos), OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND);    ADD_FUNCTION("assembler_debug", f_assembler_debug,    tFunc(tInt,tIntPos), OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND);    ADD_FUNCTION("dump_program_tables", f_dump_program_tables,