分享到plurk 分享到twitter 分享到facebook

版本 b244f66432c8167878d769b135d2eec44a63fcbe

Lab33: GDB + FreeRTOS

預期目標

  • 學習使用 GDB
  • 追蹤和分析 FreeRTOS 運作

GDB

  • GDB Rocks!<http://www.slideshare.net/chenkaie/gdb-rocks-16951548>_
  • 作業系統之前的程式 for stm32f4discovery:打造 Linux 開發環境<http://descent-incoming.blogspot.tw/2013/04/for-stm32f4discovery-0-linux.html>_

QEMU + GDB 操作

  • 假設 Lab-32</embedded/Lab32>_ 所使用 QEMU 的目錄已放在 workspace 目錄

.. code-block:: prettyprint

cd workspace
file qemu_stm32
cd freertos-plus
make qemudbg
  • 研究 tool/gdbscript 檔案內容
  • (gdb) 畫面中敲入以下指令,觀察相關輸出
    • info registers
    • list
    • next
    • info registers
    • info breakpoints
    • print serial_rx_queue
  • 注意: 使用 Ubuntu 64-bit 版本時,需要另外安裝 lib32ncurses5
    • sudo apt-get install lib32ncurses5

小提示

  • 若遇到 Linux 輸入法系統 ibus 一直干擾終端機,可用 pkill -9 ibus 強制結束輸入法

參考作業提案

  • 修改 tool/gdbscript 檔案內容,使得 make qemudbg 時,shell 會自動執行 test 一類的指令
  • 承上,使 FreeRTOS + QEMU 透過 semihosting,將 test 結果保存在 host 端檔案

繳交作業

  • 截止日期:
    • Oct 11, 2014 (含) 之前
  • 更新作業提案到共筆網站: Lab 33 / 作業共筆<https://embedded2014.hackpad.com/2014q3-Week-3-rR0cpeJsDcp>_,需要標注自己的 ID
    • 將符合作業提案的程式碼,提交到自行 fork 的 repository freertos-plus<https://github.com/embedded2014/freertos-plus>_ (設定與 Lab 32</embedded/Lab32>_ 相同)
    • 可搭配 GDB 完成 Lab 32</embedded/Lab32>_ 提案中的開發工作

參考資訊

  • debugger 和 software emulator
    • http://opencsl.openfoundry.org/Lab05_debugger.rst.html
  • GDB 筆記
    • http://loda.hala01.com/2012/04/gdb%E7%AD%86%E8%A8%98/
  • 以 GDB 重新學習 C 語言程式設計
    • http://www.slideshare.net/jserv/clang-usinggdb
  • GDB Manual
    • http://sourceware.org/gdb/current/onlinedocs/gdb/
    • Commands, Remote Debugging, Extending GDB
  • Lab 27: GDB Automation<https://embedded2014.hackpad.com/Lab-27-GDB-Automation-L1ohwuTnRMw>_