This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: stack_used() not accurate?
Hi -
On Mon, Jun 02, 2008 at 03:02:07PM -0400, Mike Snitzer wrote:
> [...]
> >> __asm__ __volatile__("andl %%esp,%0" :
> >> "=r" (sp) : "0" (THREAD_SIZE - 1));
>
> whereas the following c-code does _not_ work:
> if (CONTEXT->regs) {
> long sp = REG_SP(CONTEXT->regs) & (THREAD_SIZE - 1);
> [...]
>
> So, given that the calculated "free" is incorrect, this says to me
> that the incorrect value is getting stored in CONTEXT->regs->esp on
> x86 (or the value is stale)?
Why do you think the latter is incorrect? The asm "esp"-related one
should give you the stack pointer at the moment of the probe handler
execution. The CONTEXT->regs->esp value should give the stack pointer
at the moment of the probe hit - displaced in time (earlier) and
potentially in space (different stack). This is the dimension of
imagination. It is an area which we call the twilight zone.
- FChE