|
Message
From: rcc@j...
Date: Thu, 11 Sep 2003 09:50:46 +0200
Subject: Re: [openrisc] SIGBUS when using eCos diag_printf
Hi Marko,
This occurs when using -O2 optimisation flag, but doesn't occur if I
don't specify optimisation (i.e. no -O flag at all), so I have solved the
immediate problem but it does make the code considerably larger :-(
Initial inspection seems to suggest that either the stack is getting
corrupted or register misuse is occurring in the optimised code, as the
exception occurs shortly after returning from the modulo call and
appears to be due to dereferencing a bad address in a register:
820c: 04 00 0a 16 l.jal aa64 <___umoddi3>
8210: d7 e2 97 a4 l.sw 0xffffffa4(r2),r18
8214: 84 d2 00 04 l.lwz r6,0x4(r18)
In the above, r18 has a bad address in. The unoptimised version looks
like this, i.e. no instruction in the delay slot.
1410: 04 00 25 95 l.jal aa64 <___umoddi3>
1414: 15 00 00 00 l.nop 0x0
1418: 84 ab 00 00 l.lwz r5,0x0(r11)
It would be nice to get to the bottom of why this occurs; if I have some
spare time (I wish) I will try to unravel it a bit more.
Robert
----- Original Message -----
From: Marko Mlinar <markom@o... >
To: openrisc@o...
Date: Thu, 11 Sep 2003 08:09:19 +0200
Subject: Re: [openrisc] SIGBUS when using eCos diag_printf
>
>
> Robert,
>
> my guess would be that pointers for string decoding in libc are not
> set-up
> correctly or get messed-up. Usually libc libraries detect whether
> your string
> has something to replace e.g. % characters, also usually it has
> some last
> used combination cached. If there is something to replace it
> allocates new
> string or uses some static (more often) space, where it works. I am
> not
> familiar with library you are using, so I unfortunately cannot be
> more
> specific.
>
> hope it helps anyway,
>
> Marko
>
> On Wednesday 10 September 2003 19:19, Robert Cragie wrote:
> > This is a bit of a long shot posting here, but I was wondering
> if anyone
> > else has experienced this problem. I am getting a SIGBUS (bus
> error)
> > exception when trying to call the printf supplied with eCos.
> This is
> > generic code and works fine on all other eCos platforms, so
> the problem
> > must be something to do with the OpenRISC environment.
> >
> > If I do:
> >
> > diag_printf("Just a string\n");
> >
> > it seems to work OK.
> >
> > However, if I do:
> >
> > diag_printf("Print an integer %d\n", integer);
> >
> > it bombs out of GDB with something like this:
> >
> > Program received signal SIGBUS, Bus error.
> > 0x00007f9c in _cvt(unsigned long long, char*, long, char*)
> (val=1987,
> > buf=0xcc0c "", radix=10, digits=0x1116c "0123456789")
> > at
> /home/rcc/ecos-sr/ecos/packages/infra/current/src/diag.cxx:273
> > 273 *cp++ = digits[val % radix];
> > Current language: auto; currently c++
> >
> > I am using GDB 5.3 and GCC 3.2.3 from the OpenCores CVS
> server.
> >
> > Anyone seen this, or any ideas what might be going on? My
> feeling is it's
> > something to do with the 'val % radix' expression - 'val'
> being unsigned
> > long long etc and the associated math library. I will continue
> to
> > investigate further and see if I can spot anything odd.
> >
> > Robert Cragie, Design Engineer
> >
>
_____________________________________________________________
__
> > Jennic Ltd, Furnival Street, Sheffield, S1 4QT, UK
> > http://www.jennic.com Tel: +44 (0) 114 281 2655
> >
>
_____________________________________________________________
__
>
|
 |