www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Stack info

Is is possible to add to Phobos standard functions (intrinsics, if necessary)
that give some information about the C stack? Things like:

- Available space left on the stack (for a thread)
- Total size of the stack at program start
- The direction of stack growth (see for example
http://www.devx.com/tips/Tip/37412 ).
- Starting address of the stack

Probably on some systems/situations such information is not available, for
example the stack can be implemented on a heap, so the function that tells the
direction of stack growth can return an enum with three values: UP, DOWN,
UNKNOWN.

Similar information can be used for low-level programming.

I am not expert about this, so maybe this can't be done.

For example I've added a small enhancement request for performance that can get
better if it knows the available free stack space left (but this is not an
usage case, because it's meant to be a feature implemented by the compiler):
http://d.puremagic.com/issues/show_bug.cgi?id=4357

Bye,
bearophile
Jun 21 2010