共2条
1/1 1 跳转至页
Linux,GDB 嵌入式Linux的GDB远程调试的问题--断点没反应
问
我用的是BF531
uClinux
Linux version 2.6.16.11-ADI-2006R1-hhbf (root@server)
(gcc version 3.4.5 (ADI cvs))#11 Tue Jul 18 22:44:05 CST 2006
用HH提供的HHBF531-R1-v1.0.0-060718.tgz这个压缩包里的工具.编译了里面的Hello world程序HHBF531-R1/uClinux-dist/user/hello
编译好以后可以在目标板上运行(通过NFS). 然后再编译里头的gdbserver
/mnt是NFS mount上去的目录
HHBF531>-# /mnt/gdbserver localhost:3652 /mnt/hello
Process /mnt/hello created; pid = 515
code at 0x27ff50 - (nil), data at 0x27ff48
[root@localhost hello]# bfin-uclinux-gdb hello.gdb
GNU gdb 6.3.50_2004-11-25-cvs
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=bfin-uclinux"...
(gdb) target remote 192.168.0.103:3652
Remote debugging using 192.168.0.103:3652
0x00000000 in ?? ()
(gdb) b main
Function Prologue not recognised. pc will point to ENTRY_POINT of the function
Breakpoint 1 at 0x280056: file hello.c, line 9.
(gdb) b 10
Note: breakpoint 1 also set at pc 0x280068.
Breakpoint 2 at 0x280068: file hello.c, line 10.
(gdb) step
CANnot find bounds of current function
(gdb) next
CANnot find bounds of current function
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) n
Program not restarted.
(gdb) c
Continuing.
Program exited normally.
板上的提示信息是:
Remote debugging using localhost:3652
hello world
Child exited with retcode = 0
Child exited with status 0
GDBserver exiting
为什么它会运行到底,不停下来????????不是已经设了断点了吗?难道不是这么设断点?
我在hello.c里加了几行,所以line 9是在main函数的函数体内的.
who CAN tell me why???
答 1: 贴出代码~把 hello.c 贴出来看看。
加 w 命令看看输出 答 2: 代码及操作hello.c:
#include <stdlib.h>
#include "my_sqrt.h"
int main()
{
float m;
m = 2.0;
printf("hello world\n");
printf("sqrt(%f)=%f\n", m, my_sqrt(m));
return 0;
}
my_sqrt.h:
#ifndef MY_SQRT_H
#define MY_SQRT_H
/* just for test */
float my_sqrt(float m);
#endif
my_sqrt.c:
/* just for testing */
#include <math.h>
float my_sqrt(float m) {
return sqrtf(m);
}
Makefile:
CC = bfin-uclinux-gcc
INC_DIRS = # -I/HHBF531-R1/uClinux-dist \
# -I/HHBF531-R1/uClinux-dist/linux-2.6.x/include
LIB_DIRS = # -L/HHBF531-R1/uClinux-dist/lib/libnet \
# link libm.a for sqrtf()
MY_LDLIBS = -lm
CFLAGS = -O2 -Wall -g\
-Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED \
-fno-builtin $(INC_DIRS)
LDFLAGS = -Wl,-elf2flt -g
ARCH=blackfin
CROSS_COMPILE=bfin-uclinux-
EXEC = hello
OBJS = hello.o my_sqrt.o
all: $(EXEC)
$(EXEC): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIB_DIRS) $(MY_LDLIBS) $(LDLIBS$(LDLIBS_$@))
romfs:
$(ROMFSINST) /bin/$(EXEC)
sudo cp -f $(EXEC) /tmp
clean:
-rm -f $(EXEC) *.elf *.gdb *.o
# export PATH=$PATH:/HHBF531-R1/toolchains/gcc-bfin-3.4-uclinux/bin/
# make
bfin-uclinux-gcc -O2 -Wall -g -Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED -fno-builtin -c -o hello.o hello.c
hello.c: In function `main':
hello.c:9: warning: implicit declaration of function `printf'
bfin-uclinux-gcc -O2 -Wall -g -Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED -fno-builtin -c -o my_sqrt.o my_sqrt.c
bfin-uclinux-gcc -Wl,-elf2flt -g -o hello hello.o my_sqrt.o -lm
然后把hello拷到NFS的目录下.
正常运行是这样的:
HHBF531>-# /mnt/hello
hello world
sqrt(2.000000)=1.414214
调试:
HHBF531>-# /mnt/gdbserver 192.168.0.103:3365 /mnt/hello
Process /mnt/hello created; pid = 253
code at 0x2dff4c - (nil), data at 0x2dff44
# bfin-uclinux-gdb hello.gdb
GNU gdb 6.3.50_2004-11-25-cvs
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=bfin-uclinux"...
(gdb) target remote 192.168.0.103:3365
Remote debugging using 192.168.0.103:3365
0x00000000 in ?? ()
(gdb)
HHBF531>-# /mnt/gdbserver 192.168.0.103:3365 /mnt/hello
Process /mnt/hello created; pid = 253
code at 0x2dff4c - (nil), data at 0x2dff44
Remote debugging using 192.168.0.103:3365
(gdb) l
Function Prologue not recognised. pc will point to ENTRY_POINT of the function
1 #include <stdlib.h>
2
3 #include "my_sqrt.h"
4
5 int main()
6 {
7 float m;
8 m = 2.0;
9 printf("hello world\n");
10 printf("sqrt(%f)=%f\n", m, my_sqrt(m));
(gdb) b 9
Breakpoint 1 at 0x2e0050: file hello.c, line 9.
(gdb) w
Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws.
(gdb) b 9
Note: breakpoint 1 also set at pc 0x2e0050.
Breakpoint 2 at 0x2e0050: file hello.c, line 9.
(gdb) w
Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws.
晕了,居然这样了:
Bad page state in process 'gdbserver'
page:0015cc00 flags:0x00080000 mapping:00000000 mapcount:0 count:0
Trying to fix it up, but a reboot is needed
Backtrace:
Hardware Trace:
0 Target : <00004374>{_dump_stack+0x0}
Source : <00022746>{_bad_page+0x4a}
1 Target : <00022746>{_bad_page+0x4a}
Source : <0000b01c>{_printk+0x14}
2 Target : <0000b018>{_printk+0x10}
Source : <0000b006>{_vprintk+0x29e}
3 Target : <0000affa>{_vprintk+0x292}
Source : <0000afe0>{_vprintk+0x278}
4 Target : <0000afe0>{_vprintk+0x278}
Source : <0000ad66>{_release_console_sem+0x1aa}
5 Target : <0000ad60>{_release_console_sem+0x1a4}
Source : <0000ad50>{_release_console_sem+0x194}
6 Target : <0000ad1a>{_release_console_sem+0x15e}
Source : <0000ad12>{_release_console_sem+0x156}
7 Target : <0000ace6>{_release_console_sem+0x12a}
Source : <0000abf0>{_release_console_sem+0x34}
8 Target : <0000abc4>{_release_console_sem+0x8}
Source : <0000ace4>{_release_console_sem+0x128}
9 Target : <0000ace4>{_release_console_sem+0x128}
Source : [<ffa082a2>]
10 Target : [<ffa08240>]
Source : <00006ea2>{return_from_int+0x4e}
11 Target : <00006ea2>{return_from_int+0x4e}
Source : <00006e82>{return_from_int+0x2e}
12 Target : <00006e54>{return_from_int+0x0}
Source : [<ffa0823c>]
13 Target : [<ffa0823a>]
Source : <00004c22>{_asm_do_IRQ+0xe6}
14 Target : <00004c1c>{_asm_do_IRQ+0xe0}
Source : <0000e99a>{___do_softirq+0xa2}
15 Target : <0000e982>{___do_softirq+0x8a}
Source : <0000e960>{___do_softirq+0x68}
Stack from 002b7e14:
00080000 0002274a 0015cc00 00000004 ffa0823a 0028bee4 0015cc00 00000008
00080000 00000000 00000000 00000000 00022a54 00000000 0028bd40 0002811c
00000000 002b5f88 00000000 000110e8 002b5000 002b5034 002b7ed4 00000004
0014a100 002b5f88 002b5f78 00000001 00000000 00000001 002b7e98 002b7e94
0014a104 0015cc00 002dfe74 00001ed8 002ab1c0 0000001a 002ca7d4 002e0070
00000001 002e0070 002b5ff0 002ab1c0 002b6000 00000000 00000004 00000000
Call Trace:
<00011562>{_sys_ptrace+0x56}
<00006d18>{system_call+0x68}
<000038f0>{_sys_mmap+0x0}
<00006d18>{system_call+0x68}
<0001150c>{_sys_ptrace+0x0}
<0000fffe>{_do_proc_dointvec_minmax_conv+0xa}
<00008000>{_scheduler_tick+0x140
不过:
(gdb) c
Continuing.
Program exited normally.
这时候串口终端输出:
hello world
sqrt(2.000000)=1.414214
Child exited with retcode = 0
Child exited with status 0
GDBserver exiting
抛开
Bad page state in process 'gdbserver'这个错误不说,
经楼上的好心人提示,w的输出信息表明, 断点根本就没有设置成功.
怎摸回事呢?
当list的时候,以下这个提示是什么意思呢?
Function Prologue not recognised. pc will point to ENTRY_POINT of the function
当第一次 b 9的时候
(gdb) b 9
Breakpoint 1 at 0x2e0050: file hello.c, line 9.
(gdb) w
Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws.
和第二次b 9不一样.
(gdb) b 9
Note: breakpoint 1 also set at pc 0x2e0050.
Breakpoint 2 at 0x2e0050: file hello.c, line 9.
uclinux官方主页这么教我们的,应该没有错吧.应该是可以用gdbserver来进行远程调试.和HHBF531板的设计有关系???
http://docs.blackfin.uclinux.org/doku.php?id=debuggers 答 3: 敲 where 命令> 8 m = 2.0;
> 9 printf("hello world\n");
> 10 printf("sqrt(%f)=%f\n", m, my_sqrt(m));
> (gdb) b 9
> Breakpoint 1 at 0x2e0050: file hello.c, line 9.
> (gdb) w
敲 where 命令。
> Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws.
> (gdb) b 9
> Note: breakpoint 1 also set at pc 0x2e0050.
> Breakpoint 2 at 0x2e0050: file hello.c, line 9.
> (gdb) w
> Ambiguous command "w": watch, wh, whatis, where, while, while-
uClinux
Linux version 2.6.16.11-ADI-2006R1-hhbf (root@server)
(gcc version 3.4.5 (ADI cvs))#11 Tue Jul 18 22:44:05 CST 2006
用HH提供的HHBF531-R1-v1.0.0-060718.tgz这个压缩包里的工具.编译了里面的Hello world程序HHBF531-R1/uClinux-dist/user/hello
编译好以后可以在目标板上运行(通过NFS). 然后再编译里头的gdbserver
/mnt是NFS mount上去的目录
HHBF531>-# /mnt/gdbserver localhost:3652 /mnt/hello
Process /mnt/hello created; pid = 515
code at 0x27ff50 - (nil), data at 0x27ff48
[root@localhost hello]# bfin-uclinux-gdb hello.gdb
GNU gdb 6.3.50_2004-11-25-cvs
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=bfin-uclinux"...
(gdb) target remote 192.168.0.103:3652
Remote debugging using 192.168.0.103:3652
0x00000000 in ?? ()
(gdb) b main
Function Prologue not recognised. pc will point to ENTRY_POINT of the function
Breakpoint 1 at 0x280056: file hello.c, line 9.
(gdb) b 10
Note: breakpoint 1 also set at pc 0x280068.
Breakpoint 2 at 0x280068: file hello.c, line 10.
(gdb) step
CANnot find bounds of current function
(gdb) next
CANnot find bounds of current function
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) n
Program not restarted.
(gdb) c
Continuing.
Program exited normally.
板上的提示信息是:
Remote debugging using localhost:3652
hello world
Child exited with retcode = 0
Child exited with status 0
GDBserver exiting
为什么它会运行到底,不停下来????????不是已经设了断点了吗?难道不是这么设断点?
我在hello.c里加了几行,所以line 9是在main函数的函数体内的.
who CAN tell me why???
答 1: 贴出代码~把 hello.c 贴出来看看。
加 w 命令看看输出 答 2: 代码及操作hello.c:
#include <stdlib.h>
#include "my_sqrt.h"
int main()
{
float m;
m = 2.0;
printf("hello world\n");
printf("sqrt(%f)=%f\n", m, my_sqrt(m));
return 0;
}
my_sqrt.h:
#ifndef MY_SQRT_H
#define MY_SQRT_H
/* just for test */
float my_sqrt(float m);
#endif
my_sqrt.c:
/* just for testing */
#include <math.h>
float my_sqrt(float m) {
return sqrtf(m);
}
Makefile:
CC = bfin-uclinux-gcc
INC_DIRS = # -I/HHBF531-R1/uClinux-dist \
# -I/HHBF531-R1/uClinux-dist/linux-2.6.x/include
LIB_DIRS = # -L/HHBF531-R1/uClinux-dist/lib/libnet \
# link libm.a for sqrtf()
MY_LDLIBS = -lm
CFLAGS = -O2 -Wall -g\
-Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED \
-fno-builtin $(INC_DIRS)
LDFLAGS = -Wl,-elf2flt -g
ARCH=blackfin
CROSS_COMPILE=bfin-uclinux-
EXEC = hello
OBJS = hello.o my_sqrt.o
all: $(EXEC)
$(EXEC): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIB_DIRS) $(MY_LDLIBS) $(LDLIBS$(LDLIBS_$@))
romfs:
$(ROMFSINST) /bin/$(EXEC)
sudo cp -f $(EXEC) /tmp
clean:
-rm -f $(EXEC) *.elf *.gdb *.o
# export PATH=$PATH:/HHBF531-R1/toolchains/gcc-bfin-3.4-uclinux/bin/
# make
bfin-uclinux-gcc -O2 -Wall -g -Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED -fno-builtin -c -o hello.o hello.c
hello.c: In function `main':
hello.c:9: warning: implicit declaration of function `printf'
bfin-uclinux-gcc -O2 -Wall -g -Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED -fno-builtin -c -o my_sqrt.o my_sqrt.c
bfin-uclinux-gcc -Wl,-elf2flt -g -o hello hello.o my_sqrt.o -lm
然后把hello拷到NFS的目录下.
正常运行是这样的:
HHBF531>-# /mnt/hello
hello world
sqrt(2.000000)=1.414214
调试:
HHBF531>-# /mnt/gdbserver 192.168.0.103:3365 /mnt/hello
Process /mnt/hello created; pid = 253
code at 0x2dff4c - (nil), data at 0x2dff44
# bfin-uclinux-gdb hello.gdb
GNU gdb 6.3.50_2004-11-25-cvs
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=bfin-uclinux"...
(gdb) target remote 192.168.0.103:3365
Remote debugging using 192.168.0.103:3365
0x00000000 in ?? ()
(gdb)
HHBF531>-# /mnt/gdbserver 192.168.0.103:3365 /mnt/hello
Process /mnt/hello created; pid = 253
code at 0x2dff4c - (nil), data at 0x2dff44
Remote debugging using 192.168.0.103:3365
(gdb) l
Function Prologue not recognised. pc will point to ENTRY_POINT of the function
1 #include <stdlib.h>
2
3 #include "my_sqrt.h"
4
5 int main()
6 {
7 float m;
8 m = 2.0;
9 printf("hello world\n");
10 printf("sqrt(%f)=%f\n", m, my_sqrt(m));
(gdb) b 9
Breakpoint 1 at 0x2e0050: file hello.c, line 9.
(gdb) w
Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws.
(gdb) b 9
Note: breakpoint 1 also set at pc 0x2e0050.
Breakpoint 2 at 0x2e0050: file hello.c, line 9.
(gdb) w
Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws.
晕了,居然这样了:
Bad page state in process 'gdbserver'
page:0015cc00 flags:0x00080000 mapping:00000000 mapcount:0 count:0
Trying to fix it up, but a reboot is needed
Backtrace:
Hardware Trace:
0 Target : <00004374>{_dump_stack+0x0}
Source : <00022746>{_bad_page+0x4a}
1 Target : <00022746>{_bad_page+0x4a}
Source : <0000b01c>{_printk+0x14}
2 Target : <0000b018>{_printk+0x10}
Source : <0000b006>{_vprintk+0x29e}
3 Target : <0000affa>{_vprintk+0x292}
Source : <0000afe0>{_vprintk+0x278}
4 Target : <0000afe0>{_vprintk+0x278}
Source : <0000ad66>{_release_console_sem+0x1aa}
5 Target : <0000ad60>{_release_console_sem+0x1a4}
Source : <0000ad50>{_release_console_sem+0x194}
6 Target : <0000ad1a>{_release_console_sem+0x15e}
Source : <0000ad12>{_release_console_sem+0x156}
7 Target : <0000ace6>{_release_console_sem+0x12a}
Source : <0000abf0>{_release_console_sem+0x34}
8 Target : <0000abc4>{_release_console_sem+0x8}
Source : <0000ace4>{_release_console_sem+0x128}
9 Target : <0000ace4>{_release_console_sem+0x128}
Source : [<ffa082a2>]
10 Target : [<ffa08240>]
Source : <00006ea2>{return_from_int+0x4e}
11 Target : <00006ea2>{return_from_int+0x4e}
Source : <00006e82>{return_from_int+0x2e}
12 Target : <00006e54>{return_from_int+0x0}
Source : [<ffa0823c>]
13 Target : [<ffa0823a>]
Source : <00004c22>{_asm_do_IRQ+0xe6}
14 Target : <00004c1c>{_asm_do_IRQ+0xe0}
Source : <0000e99a>{___do_softirq+0xa2}
15 Target : <0000e982>{___do_softirq+0x8a}
Source : <0000e960>{___do_softirq+0x68}
Stack from 002b7e14:
00080000 0002274a 0015cc00 00000004 ffa0823a 0028bee4 0015cc00 00000008
00080000 00000000 00000000 00000000 00022a54 00000000 0028bd40 0002811c
00000000 002b5f88 00000000 000110e8 002b5000 002b5034 002b7ed4 00000004
0014a100 002b5f88 002b5f78 00000001 00000000 00000001 002b7e98 002b7e94
0014a104 0015cc00 002dfe74 00001ed8 002ab1c0 0000001a 002ca7d4 002e0070
00000001 002e0070 002b5ff0 002ab1c0 002b6000 00000000 00000004 00000000
Call Trace:
<00011562>{_sys_ptrace+0x56}
<00006d18>{system_call+0x68}
<000038f0>{_sys_mmap+0x0}
<00006d18>{system_call+0x68}
<0001150c>{_sys_ptrace+0x0}
<0000fffe>{_do_proc_dointvec_minmax_conv+0xa}
<00008000>{_scheduler_tick+0x140
不过:
(gdb) c
Continuing.
Program exited normally.
这时候串口终端输出:
hello world
sqrt(2.000000)=1.414214
Child exited with retcode = 0
Child exited with status 0
GDBserver exiting
抛开
Bad page state in process 'gdbserver'这个错误不说,
经楼上的好心人提示,w的输出信息表明, 断点根本就没有设置成功.
怎摸回事呢?
当list的时候,以下这个提示是什么意思呢?
Function Prologue not recognised. pc will point to ENTRY_POINT of the function
当第一次 b 9的时候
(gdb) b 9
Breakpoint 1 at 0x2e0050: file hello.c, line 9.
(gdb) w
Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws.
和第二次b 9不一样.
(gdb) b 9
Note: breakpoint 1 also set at pc 0x2e0050.
Breakpoint 2 at 0x2e0050: file hello.c, line 9.
uclinux官方主页这么教我们的,应该没有错吧.应该是可以用gdbserver来进行远程调试.和HHBF531板的设计有关系???
http://docs.blackfin.uclinux.org/doku.php?id=debuggers 答 3: 敲 where 命令> 8 m = 2.0;
> 9 printf("hello world\n");
> 10 printf("sqrt(%f)=%f\n", m, my_sqrt(m));
> (gdb) b 9
> Breakpoint 1 at 0x2e0050: file hello.c, line 9.
> (gdb) w
敲 where 命令。
> Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws.
> (gdb) b 9
> Note: breakpoint 1 also set at pc 0x2e0050.
> Breakpoint 2 at 0x2e0050: file hello.c, line 9.
> (gdb) w
> Ambiguous command "w": watch, wh, whatis, where, while, while-
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |