[英]How to use gdb with Ceedling?
我想在使用 Ceedling 時調試被測的 C 源代碼。 我發現可以使用以下命令,但是我無法設置斷點。 似乎沒有生成符號信息。 我在 project.yml 中使用默認設置,並在 defaults.rb 配置文件中檢查了 -g 選項是否啟用。
gdb --args -S rake test:sample_program
GNU gdb (GDB) (Cygwin 7.10.1-1) 7.10.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
Reading symbols from ruby...(no debugging symbols found)...done.
好吧,我總能找到! 在 Ceedling 項目中,可執行文件位於 \build\test\out\test_sample.out
我試過了,
gdb build\test\out\test_sample.out
現在,所有符號都已加載,我也可以設置斷點和步驟。
這可能不是 Ceedling 的調試方式,但它對我有用!
謝謝斯拉克
僅供參考,對於 MacOS,我使用
lldb build/test/out/test_sample.out
因為無論哪個 gdb(由 home brew 安裝)都需要不同的格式。
干杯,
格雷格
對於我們這些使用帶有 Ceedling Test Explorer 擴展的 Visual Studio Code 的人來說,以下launch.json
文件(放在.vscode
文件夾中)可用於使用 GDB 進行調試:
{
"version": "0.2.0",
"configurations": [
{
// Use the following for the Ceedling Explorer Debug Configuration
"name": "ceedling_gdb",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/test/out/${command:ceedlingExplorer.debugTestExecutable}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
// May omit the following if gdb is on the PATH
"miDebuggerPath": "<path to gdb executable>",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
這將方便地啟動您單擊小錯誤圖標的任何測試模塊。
源自https://gist.github.com/bd2357/b2d69ab18849c1e2f70959eef426ff09
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.