GDB調試opencore源碼

來源:互聯網
上載者:User

1 首先在終端執行:

emulator –show-kernel -memory 1024
開啟模擬器

2 開啟另一個終端,執行:

adb shell

進入模擬器shell,

3 在模擬器shell中執行

ps mediaserver

查看進程mediaserver的PID

4 查看PID後,接著執行:

gdbserver :5039 –attach PID(上面查看的mediaserver的PID)

5 再開啟一個終端,設定模擬器連接埠轉寄:

adb forward tcp:5039 tcp:5039

6 啟動arm-eabi-gdb,

arm-eabi-gdb位於androidsrc/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin下,此檔案夾下存放著android的編譯器等工具

命令格式:

arm-eabi-gdb 可執行檔(在此是mediaserver,別忘了指定路徑)

例: arm-eabi-gdb /androidsrc/out/target/product/generic/symbols/system/bin/mediaserver

這樣就會進入GDB環境

7 設定gdb中的來那個壞境變數:

(gdb) set solib-absolute-prefix /androidsrc/out/target/product/generic/symbols/
(gdb) set solib-search-path /androidsrc/out/target/product/generic/symbols/system/lib/

關於這兩個變數:

solib-absolute-prefix :設定尋找共用庫的首碼,作為尋找so庫路徑的首碼;

If this variable is set, path will be used as a prefix for any absolute shared library paths; many runtime loaders store the absolute paths to the shared library in the target program's memory. If you use `solib-absolute-prefix' to find shared libraries, they need to be laid out in the same way that they are on the target, with e.g. a `/usr/lib' hierarchy under path. You can set the default value of `solib-absolute-prefix' by using the configure-time `--with-sysroot' option.

solib-search-path :設定so庫的尋找路徑,它是在根據solib-absolute-prefix 尋找庫失敗後使用

If this variable is set, path is a colon-separated list of directories to search for shared libraries. `solib-search-path' is used after `solib-absolute-prefix' fails to locate the library, or if the path to the library is relative instead of absolute. If you want to use `solib-search-path' instead of `solib-absolute-prefix', be sure to set `solib-absolute-prefix' to a nonexistant directory to prevent GDB from finding your host's libraries.

 

Connect to the device by issuing the gdb command:

(gdb)target remote :5039

8 進行GDB調試

此時就可以使用GDB來調試源碼了,首先設定斷點:

(gdb) b createPlayer

(gdb) c

然後再到模擬器播放檔案可以了

播放會在斷點處卡住,

(gdb) l

就可以顯示斷點出的源碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.