vscode cppdbg launch json 中的 setupCommands 文档

问题描述 投票:0回答:2

在我的 vscode cppdbg 启动配置中,我使用像这样的 setupCommands

"setupCommands": [
    {
        "description": "Enable pretty-printing for gdb",
        "text": "-enable-pretty-printing",
        "ignoreFailures": true
    }
]

我想添加额外的 gdb 设置命令,例如

set print repeats 0
set print elements 0

进入我的启动配置

我在哪里可以找到有关此的一些文档?

visual-studio-code
2个回答
3
投票

我也找不到详细的文档,但这就是我看到解决方案的方式

你可以像这样修改

launch.json

"setupCommands": [
    {
       "description": "Enable pretty-printing for gdb",
       "text": "-enable-pretty-printing",
       "ignoreFailures": true
    },
    {
       "text": "set print elements 0"
    }
],

或者您可以使用 vscode 调试控制台与 gdb 交互。请参阅下面的示例:


0
投票

https://sourceware.org/gdb/current/onlinedocs/gdb#GDB_002fMI-Variable-Objects列出了GDB/MI变量对象,其中解释了

-enable-pretty-printing

要使用其他 gdb 命令,我在 launch.json 中传递一个配置文件,并将所有 gdb 命令放入该配置文件中。

"miDebuggerArgs": "-x ${workspaceFolder}/gdb.config",

您还可以使用

-ex
将单个命令传递给 gdb。例如

"miDebuggerArgs": "-ex 'set print repeats 0'",

手册页中解释了 gdb 选项 https://man7.org/linux/man-pages/man1/gdb.1.html

© www.soinside.com 2019 - 2024. All rights reserved.