linux gdb模式下无反应,Linux,GDB 嵌入式Linux的GDB远程调试的问题--断点没反应
院士
2006-12-22 22:43:00????評分
2樓
問
我用的是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
#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
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
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 : []
10 Target : []
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 : []
13 Target : []
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-
總結
以上是生活随笔為你收集整理的linux gdb模式下无反应,Linux,GDB 嵌入式Linux的GDB远程调试的问题--断点没反应的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 支持ie8的时分秒的html,兼容ie8
- 下一篇: linux 压缩为多个文件,在Linux