profiling broken on RELENG_7/i386

Dmitry Morozovsky marck at rinet.ru
Sun Jul 13 15:23:36 UTC 2008


On Sun, 13 Jul 2008, Bruce Cran wrote:

BC> > PJ> On 2008-Jul-04 13:01:11 +0400, Dmitry Morozovsky <marck at rinet.ru>
BC> > PJ> wrote:
BC> > PJ> >It seems we step on a bug in gcc in RELENG_7/i386
BC> > PJ> >
BC> > PJ> >It is triggered at least by profiling program which uses
BC> > PJ> >getopt(3):
BC> > PJ> 
BC> > PJ> I think it's actually in the profiling initialisation code.  If
BC> > PJ> you try to run sample code under gdb, you can see that .mcount()
BC> > PJ> is not preserving %ecx, though main() assumes it does.
BC> > 
BC> > I see.  However, I'm afraid we need knowledge of some gcc guru to
BC> > bring the fix in.
BC> > 
BC> 
BC> This is a known bug in 7.x and has apparently been fixed in -CURRENT. 
BC> See http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/119709 for more
BC> details.

It seems it is not, at least on cluster reference -CURRENT i386 machine:

Thu Jul  3 21:52:15 UTC 2008

marck at ref8-i386:~/tmp/gprof> ./test 
Segmentation fault (core dumped)


Profiling program does not always dump core, but .mcount definitely clobbers 
one of the registers:

marck at ref8-i386:~/tmp/gprof> cat test-x.c
#include <stdio.h>

int
main(int argc, char *argv[])
{
        printf("Hello, world!\n"); 
        printf("argc=%d, argv=%p\n", argc, argv);
        return (0);
}

w/o -pg:
marck at ref8-i386:~/tmp/gprof> ./test
Hello, world!
argc=1, argv=0xbf7febf8

with -pg:
marck at ref8-i386:~/tmp/gprof> ./test
Hello, world!
argc=0, argv=0x0


Sincerely,
D.Marck                                     [DM5020, MCK-RIPE, DM3-RIPN]
[ FreeBSD committer:                                 marck at FreeBSD.org ]
------------------------------------------------------------------------
*** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck at rinet.ru ***
------------------------------------------------------------------------


More information about the freebsd-hackers mailing list