Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Jul 2008 18:01:12 +0400 (MSD)
From:      Dmitry Morozovsky <marck@rinet.ru>
To:        Peter Jeremy <peterjeremy@optushome.com.au>
Cc:        kan@freebsd.org, freebsd-hackers@freebsd.org, oleg@rinet.ru
Subject:   Re: profiling broken on RELENG_7/i386
Message-ID:  <20080713175927.R58331@woozle.rinet.ru>
In-Reply-To: <20080713105548.GA55221@server.vk2pj.dyndns.org>
References:  <20080704121833.J35668@woozle.rinet.ru> <20080713105548.GA55221@server.vk2pj.dyndns.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 13 Jul 2008, Peter Jeremy wrote:

PJ> On 2008-Jul-04 13:01:11 +0400, Dmitry Morozovsky <marck@rinet.ru> wrote:
PJ> >It seems we step on a bug in gcc in RELENG_7/i386
PJ> >
PJ> >It is triggered at least by profiling program which uses getopt(3):
PJ> 
PJ> I think it's actually in the profiling initialisation code.  If
PJ> you try to run sample code under gdb, you can see that .mcount()
PJ> is not preserving %ecx, though main() assumes it does.

I see.  However, I'm afraid we need knowledge of some gcc guru to bring the fix 
in.

Alexander, could you please comment?


PJ> 
PJ> (gdb) disas $eip
PJ> Dump of assembler code for function main:
PJ> 0x080481d0 <main+0>:    lea    0x4(%esp),%ecx
PJ> 0x080481d4 <main+4>:    and    $0xfffffff0,%esp
PJ> 0x080481d7 <main+7>:    pushl  0xfffffffc(%ecx)
PJ> 0x080481da <main+10>:   push   %ebp
PJ> 0x080481db <main+11>:   mov    %esp,%ebp
PJ> 0x080481dd <main+13>:   push   %ecx
PJ> 0x080481de <main+14>:   sub    $0x14,%esp
PJ> 0x080481e1 <main+17>:   call   0x8051b50 <.mcount>
PJ> 0x080481e6 <main+22>:   mov    0x4(%ecx),%eax
PJ> 0x080481e9 <main+25>:   mov    (%eax),%eax
PJ> 0x080481eb <main+27>:   mov    %eax,0x8(%esp)
PJ> 0x080481ef <main+31>:   mov    (%ecx),%eax
PJ> 0x080481f1 <main+33>:   mov    %eax,0x4(%esp)
PJ> 0x080481f5 <main+37>:   movl   $0x8066b0a,(%esp)
PJ> 0x080481fc <main+44>:   call   0x8051b00 <printf>
PJ> 0x08048201 <main+49>:   mov    $0x0,%eax
PJ> 0x08048206 <main+54>:   add    $0x14,%esp
PJ> 0x08048209 <main+57>:   pop    %ecx
PJ> 0x0804820a <main+58>:   pop    %ebp
PJ> 0x0804820b <main+59>:   lea    0xfffffffc(%ecx),%esp
PJ> 0x0804820e <main+62>:   ret    
PJ> End of assembler dump.
PJ> (gdb)  x/10x $esp
PJ> 0xbfbfeadc:     0x0804815f      0x00000001      0xbfbfeb08      0xbfbfeb10
PJ> 0xbfbfeaec:     0x00000000      0x00000000      0x00000000      0x00000000
PJ> 0xbfbfeafc:     0x00000000      0x00000000
PJ> (gdb) info regi
PJ> eax            0xbfbfeb08       -1077941496
PJ> ecx            0x1e968  125288
PJ> edx            0x8051d1a        134552858
PJ> ebx            0x1      1
PJ> esp            0xbfbfeadc       0xbfbfeadc
PJ> ebp            0xbfbfeb00       0xbfbfeb00
PJ> esi            0xbfbfeb10       -1077941488
PJ> edi            0x0      0
PJ> eip            0x80481d0        0x80481d0
PJ> eflags         0x282    642
PJ> cs             0x33     51
PJ> ss             0x3b     59
PJ> ds             0x3b     59
PJ> es             0x3b     59
PJ> fs             0x3b     59
PJ> gs             0x1b     27
PJ> ...
PJ> [step through .mcount]
PJ> ...
PJ> (gdb) stepi
PJ> main (argc=Error accessing memory address 0x1b: Bad address.
PJ> ) at x.c:4
PJ> 4           printf("Hello %d %s\n", argc, argv[0]);
PJ> (gdb) info regi
PJ> eax            0x1      1
PJ> ecx            0x1b     27
PJ> edx            0x804815f        134512991
PJ> ebx            0x1      1
PJ> esp            0xbfbfeab0       0xbfbfeab0
PJ> ebp            0xbfbfeac8       0xbfbfeac8
PJ> esi            0xbfbfeb10       -1077941488
PJ> edi            0x0      0
PJ> eip            0x80481e6        0x80481e6
PJ> eflags         0x246    582
PJ> cs             0x33     51
PJ> ss             0x3b     59
PJ> ds             0x3b     59
PJ> es             0x3b     59
PJ> fs             0x3b     59
PJ> gs             0x1b     27
PJ> 
PJ> -- 
PJ> Peter Jeremy
PJ> Please excuse any delays as the result of my ISP's inability to implement
PJ> an MTA that is either RFC2821-compliant or matches their claimed behaviour.
PJ> 

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080713175927.R58331>