小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

用arm-linux-gdb調試ARM上的應用程序

 追逐四葉 2017-09-16

我根據(jù)arm-linux-gdb的調試對象,把調試分為二大類。即底層代碼的調試,如u-boot、裸機程序等;或者應用程序的調試,即elf格式的可執(zhí)行文件。根據(jù)我的經(jīng)驗,應用程序的調試相對要容易很多。下面,詳細闡述調試經(jīng)歷……

 

應用篇:用arm-linux-gdb調試應用程序

開發(fā)機,即我電腦虛擬機中的ubuntu;目標機,即跑有l(wèi)inux系統(tǒng)的arm開發(fā)板。開發(fā)機和目標機通過網(wǎng)線連接在一個局域網(wǎng)內,一個網(wǎng)段,確保相互要ping得通。

在開發(fā)機中,通過minicom、ssh或者telnet登錄開發(fā)板,要能看到開發(fā)板的文件系統(tǒng)。步驟如下:(ubuntuIP192.168.16.200, arm板的IP192.168.16.40,兩者均使用2015端口通信

【1 打開終端,遠程登錄開發(fā)板】

wuxian@ubuntu:~$ ssh  root@192.168.16.40   

root@192.168.16.40's password: 123                

#                                      

 

【2 另啟終端,編譯elf可執(zhí)行文件】

wuxian@ubuntu:~$ touch hello.c

1       #include<stdio.h>

2      

3       intmain(int argc, char *argv[])

4       {

5                for(inti=0; i<100; i++)

6                {

7                          printf("hello,world!\n");

8                }

9                return0;

11 }

wuxian@ubuntu:~$ arm-linux-gcc -g hello.c -o hello --std=c99

 

【3 拷貝文件到目標開發(fā)板】

wuxian@ubuntu:~$ scp ./hello root@192.168.16.40:/root

root@192.168.16.40's password:

hello                                         100%6200     6.1KB/s   00:00

 

【4 上目標機查看拷貝情況】

# ls

hello

# pwd

/root

#

 

【5 在目標機上打開gdbserver】準備為客戶端arm-linux-gdb服務

# gdbserver 192.168.16.200:2015 hello  //192.168.16.200是開發(fā)機的ip2015是監(jiān)聽端口,

Process hello created; pid = 27991      //提示信息

Listening on port 2015

 

【6 在開發(fā)機上打開arm-linux-gdb】準備調試

wuxian@ubuntu:/opt/arm/4.3.2/bin$ ./arm-linux-gdb ~/hello

GNU gdb (Sourcery G++ Lite 2008q3-72)6.8.50.20080821-cvs

Copyright (C) 2008 Free SoftwareFoundation, Inc.

License GPLv3+: GNU GPL version 3 orlater <http:///licenses/gpl.html>

This is free software: you are free tochange and redistribute it.

There is NO WARRANTY, to the extentpermitted by law.  Type "showcopying"

and "show warranty" fordetails.

This GDB was configured as "--host=i686-pc-linux-gnu--target=arm-none-linux-gnueabi".

For bug reporting instructions, pleasesee:

<https://support./GNUToolchain/>...

(gdb) target remote 192.168.16.40:2015

Remote debugging using192.168.16.40:2015

warning: Unable to find dynamic linkerbreakpoint function.

GDB will be unable to debug sharedlibrary initializers

and track explicitly loaded dynamiccode.

0x400cc8c0 in ?? ()

(gdb) l 1

1       #include<stdio.h>

2      

3       intmain(int argc, char *argv[])

4       {

5                for(inti=0; i<100; i++)

6                {

7                          printf("hello,world!\n");

8                }

9      

10              return0;

(gdb)

11     }

(gdb) b main

Breakpoint 1 at 0x8480: file hello.c,line 5.

(gdb) c

Continuing.

Error while mapping shared librarysections:

/lib/libc.so.0: No such file ordirectory.

Error while mapping shared librarysections:

/lib/ld-uClibc.so.0: No such file ordirectory.

 

Breakpoint 1, main (argc=1,argv=0xbe9bad74) at hello.c:5

5                for(inti=0; i<100; i++)

(gdb) n

7                          printf("hello,world!\n");

(gdb) n

5                for(inti=0; i<100; i++)

(gdb)

 

【7 再看看目標機上的反應

# gdbserver 192.168.16.200:2015 hello

Process hello created; pid = 27991

Listening on port 2015

Remote debugging from host 192.168.16.200

hello,world!

 

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多