This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: stack_used() not accurate?
On Mon, Jun 2, 2008 at 4:29 PM, Frank Ch. Eigler <fche@redhat.com> wrote:
> 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.
I understand that CONTEXT->regs->esp has the properties you described;
completely explains why it is so important to use CONTEXT->regs. But
the problem, on x86, is that if I use CONTEXT->regs->esp I get a
negative values for "free" or <100 Bytes free. I know that not to be
the case...
Mike