Thursday, August 22, 2013

bug in compiler generated parameters passed to functions or just gdb' view of it?

Cant figure out why the compiler is passing invalid parameters to the tclib_printf() function. See gdb terminal interaction below. The asm dump looks fine to me

rombios@lenovo:~/PROJECTS/stm32$ arm-linux-gnueabi-gdb ./core_test.out
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-linux-gnueabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
0x200003c8 in ?? ()
JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
JTAG tap: stm32f1x.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x20000108 msp: 0x20005000
Reading symbols from /home/rombios/PROJECTS/stm32/core_test.out...done.

(gdb) l
25    /*
26     **********************************************************************
27     *initialization should start with:
28     *reset control clock registers
29     *general purpose input output registers
30     *universal asynchronous receiver transmitter registers
31     *nested vectored interrupt controller registers
32     **********************************************************************
33     */
34    stm32_rcc_cr_init();
(gdb)
35    stm32_gpio_init();
36    stm32_uart_init();
37    stm32_nvic_init();
38   
39    wdTemp = strSystick.dwSeconds;
40    while(1)
41        {
42        while(wdTemp == strSystick.dwSeconds)
43            ;
44   
(gdb)
45   
46        wdTemp = wdTemp;        /*dummy ins for breakpoint*/
47        tclib_printf("\r%d", wdTemp);
48        wdTemp = strSystick.dwSeconds;
49        }
50   
51    return 0;
52    }
53   
54   
(gdb) b 46
Breakpoint 1 at 0x20000e0a: file apps/core/core_test.c, line 46.
(gdb) load
Loading section .text, size 0xe54 lma 0x20000000
Loading section .data, size 0x130 lma 0x20000e54
Start address 0x20000dd9, load size 3972
Transfer rate: 64 KB/sec, 1986 bytes/write.
(gdb) c
Continuing.

Breakpoint 1, main () at apps/core/core_test.c:46
46        wdTemp = wdTemp;        /*dummy ins for breakpoint*/
(gdb) n
47        tclib_printf("\r%d", wdTemp);
(gdb) p wdTemp
$1 = 0
(gdb) s
tclib_printf (ptrString=0x0, wdValue=536874884) at tclib/IE_tclib.c:140
140    while ((*ptrString) != NULL)
(gdb) p strSystick
$2 = {dwMsTick = 0, dwSeconds = 1, dwMsTotal = 1000, ptrFunc = 0}
(gdb) 





20000e0a:       687b            ldr     r3, [r7, #4]
20000e0c:       607b            str     r3, [r7, #4]
20000e0e:       687b            ldr     r3, [r7, #4]
20000e10:       f640 6050       movw    r0, #3664       ; 0xe50
20000e14:       f2c2 0000       movt    r0, #8192       ; 0x2000
20000e18:       4619            mov     r1, r3
20000e1a:       f7ff f9a3       bl      20000164 <tclib_printf>
 




20000164 <tclib_printf>:
20000164:       b580            push    {r7, lr}
20000166:       b086            sub     sp, #24
20000168:       af00            add     r7, sp, #0
2000016a:       6078            str     r0, [r7, #4]
2000016c:       6039            str     r1, [r7, #0]
 













No comments:

Post a Comment