[gambit-list] Any procedure/debug way to see what objects reference an object?
Marc Feeley
feeley at iro.umontreal.ca
Tue Jun 18 13:37:40 EDT 2013
On 2013-06-18, at 10:28 AM, Mikael <mikael.rcv at gmail.com> wrote:
> Great!
>
> So, say that I have an object z that I want to check all refs to:
>
> (define x (vector 1 2 3))
>
> well, and let's create two refs so the environment is completely set up:
>
> (define y (lambda () z)) (define z (vector x))
>
> Scheme object references can be exported and imported using
>
> (define int->scheme-object (c-lambda (unsigned-int64) scheme-object "___result = ___arg1;"))
> (define scheme-object->int (c-lambda (scheme-object) unsigned-int64 "___result = ___arg1;"))
>
These functions already exist:
> (##object->encoding (cons 11 22))
4562002011
> (##encoding->object 4562002011)
(11 . 22)
Of course, this is unsafe...
> so I do
>
> (define r (scheme-object->int x)) r
>
> which shows that this vector has reference number 18446744072497743289 .
>
> To the beginning of mem.c (row 20 and on) I add
>
> ___WORD DEBUG_scanned_for_object_ref = -1;
>
> and in GDB I do
>
> set var DEBUG_scanned_for_object_ref=18446744072497743289
>
> and then to validate_old_obj (or mark_array) I add the equivalence check:
>
> if (obj == DEBUG_scanned_for_object_ref) {
> fprintf(stderr,"The scanned for object reference %lu was referenced to by %lu .\n",DEBUG_scanned_for_object_ref,DEBUG_at_object);
> }
>
> Indeed it trigs as it should!
>
>
> Now, question is just how to extract DEBUG_at_object .
>
> So, presuming reference_location == IN_OBJECT , we have the content of the object containing the reference in container_body , and we can print some debug info about this object using explain_problem .
>
>
> How do I get the ___SCMOBJ that container_body will have after the garbage collection is performed?
The container_body is a pointer to the body of the copied object. So it is the new location.
> (Or alternatively, how do I cancel the garbage collection, and get the ___SCMOBJ for container_body in its present location)
I don't think aborting a GC is safe. *Don't do it*
Marc
More information about the Gambit-list
mailing list