ubuntu - GDB 无法设置附加的 Visual Studio docker 上不允许的控制终端操作

标签 ubuntu visual-studio-code gdb remote-debugging vscode-debugger

我正在尝试使用 GDB 调试器运行我的程序。当我运行它时,我收到一个警告:

GDB: Failed to set controlling terminal: Operation not permitted
该警告在我的终端中出现和消失的速度非常快。我已经检查了一些 stackoverflow questions , 但由于我正在运行 Visual Studio 连接到我的 docker (远程容器),我无法应用一些建议。
当我在我的代码中尝试一个刹车点时,GDB 不起作用,程序执行忽略 GDB。
我的 lauch.json 配置:
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/words",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }

    ]
}
我正在运行我的程序的 dockerfile 配置:
FROM ubuntu:18.04

SHELL ["/bin/bash", "-c"]

RUN apt-get -y update
RUN apt-get install -y Linux-headers-generic build-essential gdb

COPY . /ejercicio

最佳答案

检查您的代码是否实际上是使用调试构建的。根据经验(在 Linux 中),如果您没有任何符号,GDB 可能会在 VS Code session 期间导致此错误。即在所有编译和链接语句中添加 -g 命令行选项。

关于ubuntu - GDB 无法设置附加的 Visual Studio docker 上不允许的控制终端操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67285656/

相关文章:

svn - 切换 svn 工作副本以提交到两个不同的服务器

linux - ack 不接受速记字符类?

mysql - 使用pwiz从mysql生成peewee模型时出现AttributeError

c# - 将 Azure IoT Edge EFlow 端口公开给主机 (Windows)

python - 在 Visual Studio Code 中的同一项目文件夹中使用 python 包

html - VSCode Formatter 在我的 django 项目上导致错误

c - 使用 GDB 调试时读取变量 (C)

c++ - gdb (cpp) 中符号使用中断

python - 启动 uWSGI 实例失败,代码为 203

c 程序段错误对我来说没有意义(c 初学者)