[gambit-list] Any procedure/debug way to see what objects reference an object?

Mikael mikael.rcv at gmail.com
Tue Jun 18 14:00:12 EDT 2013


2013/6/18 Marc Feeley <feeley at iro.umontreal.ca>
>
> These functions already exist:
>
> > (##object->encoding (cons 11 22))
> 4562002011
> > (##encoding->object 4562002011)
> (11 . 22)
>
> Of course, this is unsafe...
>

Great!

The container_body is a pointer to the body of the copied object.  So it is
> the new location.
>

Super!


>
> > (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*
>

Ok. Considering the above there's no reason anyhow.


Soo:

The equivalence printing block, I defined now as

fprintf(stderr,"The scanned for object reference %lu was referenced to by
%lu .\n",DEBUG_scanned_for_object_ref,(reference_location == IN_OBJECT) ?
((int*) container_body) : 0);

So if there's a valid object reference, it should be printed out. (The int
typecast here may be a bit dirty but on this 32bit setup it should be
non-destructive)

Run code:

(define a (vector 1 2 3))

(define b (lambda () a)) (define c (vector a)) (define d (list a))

(define r (##object->encoding a)) r


prints 3081924705.

In GDB, I do

set var DEBUG_scanned_for_object_ref=3081924705
cont


and then in Gambit

(##gc)

And Gambit prints:

The scanned for object reference 3081924705 was referenced to by 0 .
The scanned for object reference 3081924705 was referenced to by 3083239844
.
The scanned for object reference 3081924705 was referenced to by 3083239968
.


The 0 should refer to the reference to the object from the global variable
a, so that's fine.

Also, I guess we see here that the lambda refers to the global variable
slot in a general way and not to this variable specifically, so therefore
the lambda doesn't create an object reference.

Then to inspect the objects refering to a:

>  (##encoding->object 3083239844)
-302931863
>  (##encoding->object 3083239968)
-302931832

So something is invalid about doing what I did in the printf above, which
should correspond to

___SCMOBJ newref = (reference_location == IN_OBJECT) ? ((int*)
container_body) : ___FAL;


Em. The ___SCMOBJ *is* the new location, isn't it, so this should have
worked -

What did I miss, how is this done correctly?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20130618/fca46ffb/attachment.htm>


More information about the Gambit-list mailing list