简体   繁体   English

如何在 Ceedling 中使用 gdb?

[英]How to use gdb with Ceedling?

I want to debug the C source code under test when use Ceedling.我想在使用 Ceedling 时调试被测的 C 源代码。 I found that the following command could be used, but I could not set breakpoint.我发现可以使用以下命令,但是我无法设置断点。 It seems the symbol information is not generated.似乎没有生成符号信息。 I use the default settings in project.yml and I checked -g option is enabled in defaults.rb config file.我在 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.

Well, I find someway!好吧,我总能找到! In Ceedling project, the executable is located in \build\test\out\test_sample.out在 Ceedling 项目中,可执行文件位于 \build\test\out\test_sample.out

I tried,我试过了,

gdb build\test\out\test_sample.out gdb build\test\out\test_sample.out

Now, all symbols are loaded and I can set breakpoint and step as well.现在,所有符号都已加载,我也可以设置断点和步骤。

This may not be Ceedling way of debugging, but it works for me!!这可能不是 Ceedling 的调试方式,但它对我有用!

Thanks SRAK谢谢斯拉克

FYI, for MacOS, I used仅供参考,对于 MacOS,我使用

lldb build/test/out/test_sample.out

since whichever gdb (installed by home brew) expects a different format.因为无论哪个 gdb(由 home brew 安装)都需要不同的格式。

Cheers,干杯,

Greg格雷格

For those of us using Visual Studio Code with the Ceedling Test Explorer extension, the following launch.json file (put inside the .vscode folder) can be used to debug with GDB:对于我们这些使用带有 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
                }
            ]
        }
    ]
}

This will conveniently launch whichever test module you click the little bug icon.这将方便地启动您单击小错误图标的任何测试模块。

Derived fromhttps://gist.github.com/bd2357/b2d69ab18849c1e2f70959eef426ff09源自https://gist.github.com/bd2357/b2d69ab18849c1e2f70959eef426ff09

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM