Epiphany port - printf prints wrong values of vars argument list

Joel Sherrill joel.sherrill at oarcorp.com
Thu Dec 4 20:09:52 UTC 2014



On December 4, 2014 2:03:13 PM EST, Hesham Moustafa <heshamelmatary at gmail.com> wrote:
>Hi Gedare,
>
>Thanks for your reply.
>
>On Thu, Dec 4, 2014 at 6:51 PM, Gedare Bloom <gedare at rtems.org> wrote:
>> With only a string, printf goes to puts. So it sounds like the printf
>> with arguments is broken. There is a slew of code hiding underneath
>> the printf interface, and tiny problems in register ABI and memory
>> layout easily render printf broken. I would start by modifying hello
>> world to print a formatted string, so that you isolate from any
>> problems due to timers / interrupts. You can then step in printf and
>> see what the register arguments are, and that they correspond to what
>> you might expect. Stepping through printf is a painful, tedious
>> exercise, but hopefully you can find where things are going wrong.
>You
>> might also try to binary search through the call trace, by generating
>> the stack trace and then checking along it to see what the function
>> arguments are, and how they track back to the high-level printf()
>> call.
>>
>I did the exact same debugging technique you said here. I think it's
>something related to a bug that I fixed related to GCC alignment that
>broke down the ABI. I can't revert back the gcc code, because this
>will cause unalignment exception (during initializing data structures)
>and even hello world won't work. I am discussing this issue with
>Epiphany folks currently.

Given your earlier comment about the arguments not being in the registers assembly code expected, I think their is a bug in GCC.

Does it work for epiphany-elf? That would make it something broken in the little bit of RTEMS specific code for gcc

>> -Gedare
>>
>> On Thu, Dec 4, 2014 at 12:46 PM, Hesham Moustafa
>> <heshamelmatary at gmail.com> wrote:
>>> Hi,
>>>
>>> I have a problem with getting printf working correctly. printf is
>>> working totally fine with just one string argument (hello world for
>>> example), however when printf is passed some variable arguments, it
>>> totally prints some garbage strings. Printing time function (in
>>> ticker) is an example for this, even a simple printf("x = %d", x);
>>> where x is defined before to an arbitrary value, output a wrong
>value
>>> for x, although it output the "x =" string right. I made sure that
>the
>>> address of x (or time structure content in case of ticker) is not
>>> overwritten, and from GDB, breaking at this and printing x or
>>> time->seconds for example gets me the right expected values. I think
>>> the problem is with var arg list, any ideas?
>>>
>>> Thanks,
>>> Hesham
>>> _______________________________________________
>>> devel mailing list
>>> devel at rtems.org
>>> http://lists.rtems.org/mailman/listinfo/devel
>_______________________________________________
>devel mailing list
>devel at rtems.org
>http://lists.rtems.org/mailman/listinfo/devel

--joel


More information about the devel mailing list