GDB未能设置控制终端,操作不允许在附加的Visual Studio Docker上进行。

3

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

GDB: Failed to set controlling terminal: Operation not permitted

在我的终端中,那个警告出现和消失得非常快。我已经查看了一些stackoverflow的问题,但由于我正在运行附加到我的docker的visual studio(远程容器),因此我无法应用一些建议。
当我在我的代码中尝试断点时,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
1个回答

0

检查您的代码是否确实已经使用调试模式构建。从经验来看(在Linux中),如果您没有任何符号,GDB可能会在VS Code会话期间引发此错误。即在所有编译和链接语句中添加-g命令行选项。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接