On Thu, Jun 19, 2003, Orna Agmon wrote about "Re: [Haifux] stack size":
> > static inline unsigned long getstack(void)
> > {
> > unsigned long stackaddr;
> >
> > /* I think the constraints are correct, but won't bet on it */
> > asm volatile("movl %%esp,%0\n\t" :"=m" (stackaddr):);
> >
> > return stackaddr;
> > }
This function will also work, without any assembly. But in some cases, it
might be off from the correct address by a few bytes (which doesn't matter
if you're just trying to see the stack grow).
char *getstack(void)
{
char junk;
return &junk-3;
}
> Nadav, I prefer your usual educated answers rather than your "compare to a
> constant" function and condenscending attitude. I know that having
> too-large a structure on the stack is bad, and that those should be
> allocated on the heap. What I needed to know was just how large
> is "too large".
Too bad you feel that way. I tried to tell you that any relatively large
structure doesn't belong on the stack in a recursive, non-trivial,
program. Whether the "too large" is 100 bytes or 1000 bytes, I don't
know, I frankly I still don't understand how a getstack() function is
going to help you in figuring that out - it is the sizeof() operator that
you don't want to hear about (or Muli's disassembly trick) that can help
you in that.
My guess was that your program probably had a *huge* structure allocated on
the stack, e.g., something with a fixed-sized array sized in many thousands
or even millions of bytes, and that was probably what you needed to find...
Either that, or your program was recursing too deeply. If that was the case,
the actual used size of the stack was again not the main issue.
--
Nadav Har'El | Friday, Jun 20 2003, 20 Sivan 5763
[EMAIL PROTECTED] |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Happiness isn't getting what you want,
http://nadav.harel.org.il |it's wanting what you've got.
--------------------------------------------------------------------------
Haifa Linux Club Mailing List (http://www.haifux.org)
To unsub send an empty message to [EMAIL PROTECTED]