在通过Visual Studio代码将gdb命令附加到进程之前运行gdb命令

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

我正在尝试使用Visual Studio Code作为我在Linux上的IDE来逐步了解Postgresql代码。我正在使用附加到launch.json中的进程配置来实现相同目的。以下是launch.json配置:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "attach",
            "program": "/usr/local/pgsql/bin/postgres",
            "processId": 4165,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true,
                }
            ]
        }
    ]
}

当我通过GUI开始调试时,它会附加到进程中。但是无论何时添加断点,都会在调试控制台上打印以下消息:

Program received signal SIGINT, Interrupt.
0x00007ff5d084e31b in epoll_wait () from /lib64/libc.so.6

并且无法添加断点。从Postgres开发人员文档(link)可以明显看出,我们需要通过向gdb发出以下命令来绕过到达gdb的中断:

handle SIGUSR1 noprint pass

我认为gdb中的此命令只能在附加调试过程之前执行。因此,当我通过Visual Studio Code上的调试控制台运行此命令时,出现以下错误:

Unable to perform this action because the process is running.

[通过gdb附加目标进程之前,有没有一种方法可以指示Visual Studio Code进行调试,从而向gdb发出“ handle SIGUSR1 noprint pass”?]

我正在尝试使用Visual Studio Code作为我在Linux上的IDE来逐步了解Postgresql代码。我正在使用附加到launch.json中的进程配置来实现相同目的。以下是launch.json配置:...

postgresql debugging visual-studio-code gdb interrupt
1个回答
0
投票

经过更多研究,我找到了一种使用〜/ .gdbinit文件实现此目标的方法。该文件可以包含将在每次运行gdb时运行的命令。我有以下内容:

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