[SCM] strace branch, master, updated. v4.6-115-g102ec49

Dmitry V. Levin ldv at altlinux.org
Wed Aug 31 12:25:17 UTC 2011


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 <dvlasenk at redhat.com>
> > > 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20110831/9cd3e8b5/attachment.bin>


More information about the Strace-devel mailing list