Index: dtrace/object-create.d =================================================================== diff -u --- dtrace/object-create.d (revision 0) +++ dtrace/object-create.d (revision 1c4cb273089674161189c6d19deae17fc56334b3) @@ -0,0 +1,8 @@ +/* -*- D -*- + * + * check, if every object is freed. + */ + +nsf*:::object-create { @[copyinstr(arg0)] = sum(1); } +nsf*:::object-free { @[copyinstr(arg0)] = sum(-1); } + Index: generic/nsf.c =================================================================== diff -u -r32b1b0210fbe6c5794d9bfe6def1fda904254ea6 -r1c4cb273089674161189c6d19deae17fc56334b3 --- generic/nsf.c (.../nsf.c) (revision 32b1b0210fbe6c5794d9bfe6def1fda904254ea6) +++ generic/nsf.c (.../nsf.c) (revision 1c4cb273089674161189c6d19deae17fc56334b3) @@ -1006,16 +1006,25 @@ static void NsfCleanupObject_(NsfObject *object) { + NsfObjectRefCountDecr(object); - /*fprintf(stderr, "NsfCleanupObject obj refCount of %p after decr %d\n", object, object->refCount);*/ + /*fprintf(stderr, "NsfCleanupObject obj refCount of %p after decr %d id %p interp %p flags %.6x\n", + object, object->refCount, object->id, object->teardown, object->flags);*/ if (object->refCount <= 0) { /*fprintf(stderr, "NsfCleanupObject %p refcount %d\n", object, object->refCount);*/ assert(object->refCount == 0); assert(object->flags & NSF_DELETED); - MEM_COUNT_FREE("NsfObject/NsfClass", object); + /* + * During FinalObjectDeletion(), object->teardown is NULL, we cannot access + * the object and class names anymore. + */ + if (object->teardown && NSF_DTRACE_OBJECT_FREE_ENABLED()) { + NSF_DTRACE_OBJECT_FREE(ObjectName(object), ClassName(object->cl)); + } + MEM_COUNT_FREE("NsfObject/NsfClass", object); #if defined(NSFOBJ_TRACE) fprintf(stderr, "CKFREE Object %p refcount=%d\n", object, object->refCount); #endif @@ -17413,6 +17422,10 @@ "(possibly parent namespace does not exist)", nameString); } + + if (NSF_DTRACE_OBJECT_CREATE_ENABLED()) { + NSF_DTRACE_OBJECT_CREATE(ObjectName(newObj), ClassName(cl)); + } Tcl_SetObjResult(interp, nameObj); return TCL_OK; @@ -18854,8 +18867,13 @@ assert(object->activationCount == 0); if (object->id) { - /*fprintf(stderr, "cmd dealloc %p final delete refCount %d\n", + /*fprintf(stderr, " ... cmd dealloc %p final delete refCount %d\n", object->id, Tcl_Command_refCount(object->id));*/ + + if (NSF_DTRACE_OBJECT_FREE_ENABLED()) { + NSF_DTRACE_OBJECT_FREE(ObjectName(object), ClassName(object->cl)); + } + Tcl_DeleteCommandFromToken(interp, object->id); } } @@ -18937,9 +18955,10 @@ object = GetObjectFromString(interp, key); if (object && !NsfObjectIsClass(object) && !ObjectHasChildren(object)) { - /*fprintf(stderr, " ... delete object %s %p, class=%s id %p\n", key, object, - ClassName(object->cl), object->id);*/ - + /*if (object->id) { + fprintf(stderr, " ... delete object %s %p, class=%s id %p\n", key, object, + ClassName(object->cl), object->id); + }*/ FreeUnsetTraceVariable(interp, object); if (object->id) FinalObjectDeletion(interp, object); Tcl_DeleteHashEntry(hPtr); Index: generic/nsf.h =================================================================== diff -u -r32b1b0210fbe6c5794d9bfe6def1fda904254ea6 -r1c4cb273089674161189c6d19deae17fc56334b3 --- generic/nsf.h (.../nsf.h) (revision 32b1b0210fbe6c5794d9bfe6def1fda904254ea6) +++ generic/nsf.h (.../nsf.h) (revision 1c4cb273089674161189c6d19deae17fc56334b3) @@ -74,7 +74,6 @@ #define NSF_PROFILE 1 #define NSF_DTRACE 1 */ -//#define NSF_DTRACE 1 /* are we developing? #define NSF_DEVELOPMENT 1 Index: generic/nsfDTrace.d =================================================================== diff -u -r32b1b0210fbe6c5794d9bfe6def1fda904254ea6 -r1c4cb273089674161189c6d19deae17fc56334b3 --- generic/nsfDTrace.d (.../nsfDTrace.d) (revision 32b1b0210fbe6c5794d9bfe6def1fda904254ea6) +++ generic/nsfDTrace.d (.../nsfDTrace.d) (revision 1c4cb273089674161189c6d19deae17fc56334b3) @@ -50,26 +50,19 @@ /***************************** Object probes ******************************/ /* - * nsf*:::object-create-start probe + * nsf*:::object-create probe * triggered when an NSF object creation starts - * arg0: class (string) - * arg1: object (string) + * arg0: object (string) + * arg1: class (string) */ - probe object__create_start(char *class, char *object); - /* - * nsf*:::object-create-end probe - * triggered when an NSF object creation ends - * arg0: class (string) - * arg1: object (string) - */ - probe object__create_end(char *class, char *object); + probe object__create(char *object, char *class); /* - * nsf*:::object-destroy probe - * triggered whean an NSF object is destroyed - * arg0: class (string) - * arg1: object (string) + * nsf*:::object-free probe + * triggered whean an NSF object is freeed + * arg0: object (string) + * arg1: class (string) */ - probe object__destroy(char *class, char *object); + probe object__free(char *object, char *class); /***************************** nsf configure probe ******************************/ /* Index: generic/nsfDTrace.h =================================================================== diff -u -r32b1b0210fbe6c5794d9bfe6def1fda904254ea6 -r1c4cb273089674161189c6d19deae17fc56334b3 --- generic/nsfDTrace.h (.../nsfDTrace.h) (revision 32b1b0210fbe6c5794d9bfe6def1fda904254ea6) +++ generic/nsfDTrace.h (.../nsfDTrace.h) (revision 1c4cb273089674161189c6d19deae17fc56334b3) @@ -39,30 +39,22 @@ } while (0) #define NSF_METHOD_RETURN_ENABLED() \ __dtrace_isenabled$nsf$method__return$v1() -#define NSF_OBJECT_CREATE_END(arg0, arg1) \ +#define NSF_OBJECT_CREATE(arg0, arg1) \ do { \ __asm__ volatile(".reference " NSF_TYPEDEFS); \ - __dtrace_probe$nsf$object__create_end$v1$63686172202a$63686172202a(arg0, arg1); \ + __dtrace_probe$nsf$object__create$v1$63686172202a$63686172202a(arg0, arg1); \ __asm__ volatile(".reference " NSF_STABILITY); \ } while (0) -#define NSF_OBJECT_CREATE_END_ENABLED() \ - __dtrace_isenabled$nsf$object__create_end$v1() -#define NSF_OBJECT_CREATE_START(arg0, arg1) \ +#define NSF_OBJECT_CREATE_ENABLED() \ + __dtrace_isenabled$nsf$object__create$v1() +#define NSF_OBJECT_FREE(arg0, arg1) \ do { \ __asm__ volatile(".reference " NSF_TYPEDEFS); \ - __dtrace_probe$nsf$object__create_start$v1$63686172202a$63686172202a(arg0, arg1); \ + __dtrace_probe$nsf$object__free$v1$63686172202a$63686172202a(arg0, arg1); \ __asm__ volatile(".reference " NSF_STABILITY); \ } while (0) -#define NSF_OBJECT_CREATE_START_ENABLED() \ - __dtrace_isenabled$nsf$object__create_start$v1() -#define NSF_OBJECT_DESTROY(arg0, arg1) \ -do { \ - __asm__ volatile(".reference " NSF_TYPEDEFS); \ - __dtrace_probe$nsf$object__destroy$v1$63686172202a$63686172202a(arg0, arg1); \ - __asm__ volatile(".reference " NSF_STABILITY); \ -} while (0) -#define NSF_OBJECT_DESTROY_ENABLED() \ - __dtrace_isenabled$nsf$object__destroy$v1() +#define NSF_OBJECT_FREE_ENABLED() \ + __dtrace_isenabled$nsf$object__free$v1() extern void __dtrace_probe$nsf$configure__probe$v1$63686172202a$63686172202a(char *, char *); @@ -71,12 +63,10 @@ extern int __dtrace_isenabled$nsf$method__entry$v1(void); extern void __dtrace_probe$nsf$method__return$v1$63686172202a$63686172202a$63686172202a$696e74(char *, char *, char *, int); extern int __dtrace_isenabled$nsf$method__return$v1(void); -extern void __dtrace_probe$nsf$object__create_end$v1$63686172202a$63686172202a(char *, char *); -extern int __dtrace_isenabled$nsf$object__create_end$v1(void); -extern void __dtrace_probe$nsf$object__create_start$v1$63686172202a$63686172202a(char *, char *); -extern int __dtrace_isenabled$nsf$object__create_start$v1(void); -extern void __dtrace_probe$nsf$object__destroy$v1$63686172202a$63686172202a(char *, char *); -extern int __dtrace_isenabled$nsf$object__destroy$v1(void); +extern void __dtrace_probe$nsf$object__create$v1$63686172202a$63686172202a(char *, char *); +extern int __dtrace_isenabled$nsf$object__create$v1(void); +extern void __dtrace_probe$nsf$object__free$v1$63686172202a$63686172202a(char *, char *); +extern int __dtrace_isenabled$nsf$object__free$v1(void); #ifdef __cplusplus } Index: generic/nsfInt.h =================================================================== diff -u -r32b1b0210fbe6c5794d9bfe6def1fda904254ea6 -r1c4cb273089674161189c6d19deae17fc56334b3 --- generic/nsfInt.h (.../nsfInt.h) (revision 32b1b0210fbe6c5794d9bfe6def1fda904254ea6) +++ generic/nsfInt.h (.../nsfInt.h) (revision 1c4cb273089674161189c6d19deae17fc56334b3) @@ -41,16 +41,24 @@ # endif # define NSF_DTRACE_METHOD_ENTRY_ENABLED() unlikely(NSF_METHOD_ENTRY_ENABLED()) # define NSF_DTRACE_METHOD_RETURN_ENABLED() unlikely(NSF_METHOD_RETURN_ENABLED()) +# define NSF_DTRACE_OBJECT_CREATE_ENABLED() unlikely(NSF_OBJECT_CREATE_ENABLED()) +# define NSF_DTRACE_OBJECT_FREE_ENABLED() unlikely(NSF_OBJECT_FREE_ENABLED()) # define NSF_DTRACE_CONFIGURE_PROBE_ENABLED() unlikely(NSF_CONFIGURE_PROBE_ENABLED()) # define NSF_DTRACE_METHOD_ENTRY(a0, a1, a2, a3, a4) NSF_METHOD_ENTRY(a0, a1, a2, a3, a4) # define NSF_DTRACE_METHOD_RETURN(a0, a1, a2, a3) NSF_METHOD_RETURN(a0, a1, a2, a3) +# define NSF_DTRACE_OBJECT_CREATE(a0, a1) NSF_OBJECT_CREATE(a0, a1) +# define NSF_DTRACE_OBJECT_FREE(a0, a1) NSF_OBJECT_FREE(a0, a1) # define NSF_DTRACE_CONFIGURE_PROBE(a0, a1) NSF_CONFIGURE_PROBE(a0, a1) #else # define NSF_DTRACE_METHOD_ENTRY_ENABLED() 0 # define NSF_DTRACE_METHOD_RETURN_ENABLED() 0 +# define NSF_DTRACE_OBJECT_CREATE_ENABLED() 0 +# define NSF_DTRACE_OBJECT_FREE_ENABLED() 0 # define NSF_DTRACE_CONFIGURE_PROBE_ENABLED() 0 # define NSF_DTRACE_METHOD_ENTRY(a0, a1, a2, a3, a4) {} # define NSF_DTRACE_METHOD_RETURN(a0, a1, a2, a3) {} +# define NSF_DTRACE_OBJECT_CREATE(a0, a1) {} +# define NSF_DTRACE_OBJECT_FREE(a0, a1) {} # define NSF_DTRACE_CONFIGURE_PROBE(a0, a1) {} #endif