configure --target=armv4l-unknown-linux --enable-shared --prefix=/opt/host/ --without-x --disable-gdbtk --disable-tui --without-included-regex --without-included-gettext
$ make
$ make install
./configure --host=arm-linux --target=arm-linux
make CC=/opt/host/armv4l/bin/armv4l-unknown-linux-gcc
/bin # wget http://192.168.2.88/gdbserver
Connecting to 192.168.2.88[192.168.2.88]:80
gdbserver 100% |*****************************| 104 KB 00:00 ETA
/bin # wget http://192.168.2.88/test.exe
Connecting to 192.168.2.88[192.168.2.88]:80
test.exe 100% |*****************************| 16521 00:00 ETA
/bin # ./gdbserver 192.168.2.222:2345 test.exe
/bin # ./gdbserver 192.168.2.222:2345 test.exe
Process test.exe created; pid = 66
beyes@beyes-groad:/opt/host/armv4l/bin$ ./armv4l-unknown-linux-gdb test.exe
GNU gdb 5.2.1
Copyright 2002 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=armv4l-unknown-linux"...
(gdb) target remote 192.168.2.222:2345
Remote debugging using 192.168.2.222:2345
0x40002a00 in ?? ()
(gdb) l /*列出源代码*/
1 #include <stdio.h>
2 #include <string.h>
3
4 main()
5 {
6 int i;
7 int j = 0;
8 char str[20];
9
10 for (i = 0; i < 3; i++) {
(gdb) l
11 j += i;
12 }
13
14 strcpy (str, "hello world");
15
16 printf ("%s\n", str);
17
18 return (0);
19 }
(gdb) b 6 /*在第 6 行下断*/
Breakpoint 1 at 0x83f8: file test.c, line 6.
(gdb) c /*运行,注意 x86 上的 GDB 的运行命令是 g*/
Continuing.
Breakpoint 1, main () at test.c:7
7 int j = 0;
/*在 GDB 里反汇编查看代码 。
disas 反汇编一段指令。可以带零个、一个或两个参数。第一个参数是反汇编开始地址,第二个参数是反汇编结束地址。如果没有参数,则反汇编当前的函数。*/
(gdb) disas
Dump of assembler code for function main:
0x83e8 <main>: mov r12, sp
0x83ec <main+4>: stmdb sp!, {r11, r12, lr, pc}
0x83f0 <main+8>: sub r11, r12, #4 ; 0x4
0x83f4 <main+12>: sub sp, sp, #28 ; 0x1c
0x83f8 <main+16>: mov r3, #0 ; 0x0
0x83fc <main+20>: str r3, [r11, -#20]
0x8400 <main+24>: mov r3, #0 ; 0x0
0x8404 <main+28>: str r3, [r11, -#16]
0x8408 <main+32>: ldr r3, [r11, -#16]
0x840c <main+36>: cmp r3, #2 ; 0x2
0x8410 <main+40>: ble 0x8418 <main+48>
0x8414 <main+44>: b 0x8438 <main+80>
0x8418 <main+48>: ldr r2, [r11, -#20]
0x841c <main+52>: ldr r3, [r11, -#16]
0x8420 <main+56>: add r3, r2, r3
0x8424 <main+60>: str r3, [r11, -#20]
0x8428 <main+64>: ldr r3, [r11, -#16]
0x842c <main+68>: add r3, r3, #1 ; 0x1
0x8430 <main+72>: str r3, [r11, -#16]
0x8434 <main+76>: b 0x8408 <main+32>
0x8438 <main+80>: sub r3, r11, #40 ; 0x28
0x843c <main+84>: mov r0, r3
---Type <return> to continue, or q <return> to quit---
0x8440 <main+88>: ldr r1, [pc, #28] ; 0x8464 <main+124>
0x8444 <main+92>: bl 0x82d4 <strcpy>
0x8448 <main+96>: sub r3, r11, #40 ; 0x28
0x844c <main+100>: ldr r0, [pc, #20] ; 0x8468 <main+128>
0x8450 <main+104>: mov r1, r3
0x8454 <main+108>: bl 0x82c4 <printf>
0x8458 <main+112>: mov r3, #0 ; 0x0
0x845c <main+116>: mov r0, r3
0x8460 <main+120>: ldmdb r11, {r11, sp, pc}
0x8464 <main+124>: streqh r8, [r0], -r12
0x8468 <main+128>: andeq r8, r0, r8, asr #9
End of assembler dump.
/* Define if you have the <sys/reg.h> header file. */
//#define HAVE_SYS_REG_H 1
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |