HI,all:
我在debian下使用jlink+arm-gcc+arm-gdb调试rt-thread程序,板子上是Freescale K60DN512的芯片。原来的工程是在Keil下,我根据k64f12移到Linux GCC环境下开发,现在编译是ok的,但在用gdb调试时,经常出现跑飞的情况,有些代码直接执行不一定运行成功,debug下单步停顿个一秒又好了。下面是我在调试时,经常出现的一个错误:
(gdb) bt
#0 0x00000cae in ?? ()
#1 <signal handler called>
#2 0x1fff270e in rt_strlen (s=0xffffffec "") at /home/blackrose/beyound-k60/rt-thread/src/kservice.c:477
#3 0x1fff2d48 in rt_vsnprintf (buf=0x20000298 <rt_log_buf.5043> "thread:", size=127, fmt=0x1fff5e34 "s stack overflow\n", args=...)
at /home/blackrose/beyound-k60/rt-thread/src/kservice.c:862
#4 0x1fff2faa in rt_kprintf (fmt=0x1fff5e2c "thread:%s stack overflow\n") at /home/blackrose/beyound-k60/rt-thread/src/kservice.c:1119
#5 0x1fff39a2 in _rt_scheduler_stack_check (thread=0xffffffec) at /home/blackrose/beyound-k60/rt-thread/src/scheduler.c:98
#6 0x1fff3ac8 in rt_schedule () at /home/blackrose/beyound-k60/rt-thread/src/scheduler.c:238
#7 0x1fff3c76 in rt_exit_critical () at /home/blackrose/beyound-k60/rt-thread/src/scheduler.c:393
#8 0x1fff1f1e in rt_device_find (name=0x1fff562c "uart0") at /home/blackrose/beyound-k60/rt-thread/src/device.c:129
#9 0x1fff1e74 in rt_device_register (dev=0x200000a0 <serial>, name=0x1fff562c "uart0", flags=323) at /home/blackrose/beyound-k60/rt-thread/src/device.c:50
#10 0x1fff52da in rt_hw_serial_register (serial=0x200000a0 <serial>, name=0x1fff562c "uart0", flag=323, data=0x0)
at /home/blackrose/beyound-k60/rt-thread/components/drivers/serial/serial.c:421
#11 0x1fff0da6 in rt_hw_usart_init (instance=0, name=0x1fff562c "uart0") at board/rtt_serial.c:143
#12 0x1fff1ce4 in rt_hw_board_init () at applications/init_rtos.c:36
#13 0x1fff1d70 in rtthread_startup () at applications/init_rtos.c:97
#14 0x1fff1e38 in main () at applications/main.c:32
上面的gdb里面的信息,rt_strlen()的参数好像是超过内存地址了。编译debug时,我把text和data放在内存中了,linkscript如下:
1 /* Linker script to configure memory regions. */
2 MEMORY
3 {
4 FLASH (rx) : ORIGIN = 0x1fff0000, LENGTH = 0x10000 /* 512k */
5 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 /* 128k */
6 }