On Wed, Aug 31, 2011 at 02:04:52PM +0200, Denys Vlasenko wrote: > On Tue, 2011-08-30 at 20:20 +0400, Dmitry V. Levin wrote: > > On Wed, Aug 24, 2011 at 11:41:10PM +0000, Denys Vlasenko wrote: > > > commit 102ec4935440ff52a7fa3566154a84cc2473f16a > > > Author: Denys Vlasenko <[email protected]> > > > Date: Thu Aug 25 01:27:59 2011 +0200 > > > > > > Optimize tabto() > > > > > > tabto is used in many lines of strace output. > > > On glibc, tprintf("%*s", col - curcol, "") is noticeably slow > > > compared to tprintf(" "). Use the latter. > > > Observed ~15% reduction of time spent in userspace. > > > > > > * defs.h: Drop extern declaration of acolumn. Make tabto() > > > take no parameters. > > > * process.c (sys_exit): Call tabto() with no parameters. > > > * syscall.c (trace_syscall_exiting): Call tabto() with no parameters. > > > * strace.c: Make acolumn static, add static char *acolumn_spaces. > > > (main): Allocate acolumn_spaces as a string of spaces. > > > (printleader): Call tabto() with no parameters. > > > (tabto): Use simpler method to print lots of spaces. > > [...] > > > void > > > -tabto(int col) > > > +tabto(void) > > > { > > > - if (curcol < col) > > > - tprintf("%*s", col - curcol, ""); > > > + if (curcol < acolumn) > > > + tprintf(acolumn_spaces + curcol); > > > } > > > > The new statement yields a warning: > > > > strace.c: In function 'tabto': > > strace.c:2701:3: warning: format not a string literal and no format > > arguments > > Pity, my toolchain doesn't emit that... I can't detect these warnings.
My toolchain enables -Wformat-security by default. We can get it enabled
by default in strace by adding gl_WARN_ADD([-Wformat-security]) to
configure.ac
> > Maybe we could use
> > tprintf("%s", acolumn_spaces + curcol);
> > instead without performance degradation?
>
> There will be some performance degradation.
> Is there a way to suppress this warning on a case-by-case basis?
I'm not aware of such a way. If the performance degradation is
noticeable, a straightforward function tprint_str(const char *str) could
be added to do exactly that. The implementation could use fputs() instead
of vfprintf(), and that would speedup things even more than now. ;)
--
ldv
pgp6Zvtsfx1Nw.pgp
Description: PGP signature
------------------------------------------------------------------------------ Special Offer -- Download ArcSight Logger for FREE! Finally, a world-class log management solution at an even better price-free! And you'll get a free "Love Thy Logs" t-shirt when you download Logger. Secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________ Strace-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/strace-devel
