swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: probing static/global variables?


From: Manor Askenazi
Subject: Re: probing static/global variables?
Date: Thu, 20 Mar 1997 10:06:22 -0800

This is the third time I've read requests for GlobalVarProbes...

Barry's solutions will work, especially the one that encapsulates
globals in a single GlobalVarHolder object (where the vars are
public, so poke-able directly by anybody and consequently 'almost'
global --> they aren't completely because access to them still
requires one level of indirection).

Another solution would be to provide a class 'GlobalVarProbe'
which would treat global vars as variables with an offset from
address 0... The main problem with this idea is that unlike
variables defined within the @interface construct, I don't know
of a way to get the typing of a global var at runtime using its
address or its name (compile-time constructs a-la GCC typeof()
don't seem to be relevant, but who knows there may be something
there...). In fact, someone who knows the GCC ObjC compilation
strategy intimately may be able to think up a way to do this.
Maybe even build-in a way to do it... [Scott Christley would be
a good reference with regard to these questions]. I'm not sure
its worth the effort though, global vars are, after all, evil :)
Some languages don't even support them (e.g. Java).

Having said that, if the swarm-programmer is willing to type in
an extra word or two, along the lines of:

  // Some global vars...

  float g_float ;
  id g_obj ;

  // Some global var probes...

  probe1 = [GlobalVarProbe create: aZone varPointer: &g_float type: FLOAT] ;
  probe2 = [GlobalVarProbe create: aZone varPointer: &g_obj type: ID] ;

... this could be made to work. It seems inelegant, but it would do the job.

Regards,

Manor.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]