On Wed, 2009-10-28 at 19:35 +0100, Martin Schaller wrote:
> On Mi, 2009-10-28 at 18:34 +0100, Danny Backx wrote:
> > On Tue, 2009-10-27, Martin Schaller wrote in private E-mail :
> > > I have encountered a bug when compiling with profiling
> > > support (-pg).
> > > When the first profiled function is called, the program crashes.
> > > Reason is that in src/profile/profile/profile.h, function
> > > _mcount the lr register gets overwritten which is not
> > > expected by the compiler. Instead of returning to the
> > > calling function then _mcount returns to the return address
> > > of mcount_internal, creating an endless loop and finally
> > > crashing when the stack gets out of range.
> > > 
> > > As a fix add lr to the register list in stmdb and ldmia.
> > 
> > This is what you mean ?
> > 
> >     Danny
> > 
> 
> Yes, it is what I originally meant, but it isn't enough.
> The compiler generates this code for a profiling call:
> .data
> LP1
>       .word   0
> .text
>         mov     r12, lr
>         bl      _mcount
>         .word   LP1
> 
> This means _mcount has to:
> Add 4 to the return address to skip the .word LP1
> Use r12 and lr caller addess and pc for profiling
> Restore the lr to r12
> Don't clobber any registers.
> 
> Don't ask me what LP1 is for...
> 
> Attached is a diff.
> Profiling works with it for wm2003 and wm6, but for wm6 there is under
> certain circumstances a strange crash in profil.c, function get_thrpc
> when calling ResumeThread (already in the first loop). The handle is
> valid (it is the same as in SuspendThread). Any idea what might be wrong
> there?

Haven't looked into this in a while, I don't know the answer.

Maybe someone else on the list does ?

Martin, could you send mails to the list please ?

        Danny

-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to