pike.git/
src/
modules/
_Debug/
debug.c
Branch:
Tag:
Non-build tags
All tags
No tags
2015-03-08
2015-03-08 02:32:27 by Martin Nilsson <nilsson@opera.com>
34a67941043b3831aa99652d7f8462aacd3c7173 (
46
lines) (+
46
/-
0
)
[
Show
|
Annotate
]
Branch:
8.1
Moved map_all_objects
10:
#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
149:
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);