This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: stack_used() not accurate?


On Tue, 2008-06-03 at 11:01 -0400, Masami Hiramatsu wrote:
> Hi Jim,
> 
> Jim Keniston wrote:
> > Sorry, I haven't been following this thread for a while, so maybe this
> > has already been mentioned.  But keep in mind that on i386, when your
> > breakpoint trap happens in kernel code, esp and ss aren't saved on the
> > stack.  So regs->esp and regs->ss contain the top of the pre-trap stack,
> > and the pre-trap stack pointer is &regs->esp, not regs->esp.
> 
> That's right. However, if so, REG_SP(CONTEXT->regs) on x86 should
> return &CONTEXT->regs->esp, because the macro means "return the value
> of the stack pointer register".

That's certainly a reasonable interpretation of what REG_SP is supposed
to mean.  Another reasonable interpretation is "the stack-pointer member
of pt_regs."  The latter interpretation actually has more subscribers in
the SystemTap source, as indicated by the use of &REG_SP(regs) in
stack-*.c.

Of course, REG_SP isn't used much at all (and as far as I know it's not
documented anywhere), so it shouldn't be hard to clear this up.  The
&REG_SP(regs) uses are in arch-specific code, so they could be changed
to &regs->something.

Anybody object to adopting Masami's interpretation?

Jim



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]