This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: _stp_vsnprintf() broken
- From: Martin Hunt <hunt at redhat dot com>
- To: Quentin Barnes <qbarnes at urbana dot css dot mot dot com>
- Cc: systemtap at sources dot redhat dot com
- Date: Mon, 14 May 2007 08:43:07 -0400
- Subject: Re: _stp_vsnprintf() broken
- Organization: Red Hat Inc.
- References: <20070512174643.GA20500@urbana.css.mot.com>
On Sat, 2007-05-12 at 12:46 -0500, Quentin Barnes wrote:
> In my ARM port, I noticed "_stp_printf("%p ", pc);" calls were
> outputting trashed pointer values rotated and truncated. I tracked
> the problem down to _stp_vsnprintf(). The case for 'p' was doing
> a va_arg(args, int64_t).
That is actually correct. I implemented %p this way because systemtap
only supports strings, 64-bit ints, and stats. So pointers internally
are always cast to int64_t. We can't simply use %lx to print them
because that would result in things like ffffffffc0400e16 on 32-bit
machines.
So use of %p is correct in tapset functions and systemtap scripts.
Unfortunately it started getting used in runtime C code (notably the
stack functions) to print pointers, which coincidentally works on some
architectures.
So I think the thing to do is clearly document this limitation of %p,
review all %p usage in the runtime and fix as appropriate.
I'll clean this up ASAP. Thanks for reporting the problem.
Martin