如何在-EXEC -RUN点之后运行VSCODE启动调试命令?

发布于 2025-01-19 05:54:32 字数 2360 浏览 1 评论 0 原文

我已经创建了一个VSCODE启动。JSON配置可以调用我的程序,设置一些断点并在主要断点处停止:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(lldb) Launch",    
            "type": "cppdbg",
            "request": "launch",
            "program": "/usr/bin/foo",                                                                                                                                
            "args": ["--debug", "-j", "${fileDirname}/${fileBasenameNoExtension}.xxx"],                                                                               
            "stopAtEntry": true,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb",
            "miDebuggerPath": "/usr/bin/lldb-mi",
            //"logging": {
            //    "trace": true,
            //    "traceResponse": true,
            //    "engineLogging": true
            //},
            "setupCommands": [                                     
                { "text": "-break-insert -f rc_pli_enter_module" },
                { "text": "-break-insert -f print_message" },     
                { "text": "-break-insert -f rc_pli_fatal_error" }           
            ]
        }
    ]
}

我需要通过以下方式到调试器:

process handle -s false -n false -p true SIGSEGV

由于我们的代码具有复杂的SEGV处理程序,因此基本上需要忽略它但是,在调试时,如果我在设置中包含“过程句柄”,我会遇到一个错误:

error: invalid target, create a target using the 'target create' command

我在debug-console log(启用时)中看到所有这些设置在VSCODE将其命令发送给MI Client的命令之前运行的所有这些设置目标实际运行。 IE:

-environment-cd /home/pjoot/...
-file-exec-and-symbols /usr/bin/foo
-exec-arguments --debug -j /home/pjoot/yyy.xxx
-exec-run

如果我尝试将这些目标命令放入我的设置命令中,那么我可以在主断点之后让我的“进程句柄”运行,但是VSCODE然后将尝试自己做到这一点,并且事情变得困惑(它不喜欢线程输出它在其自己的目标创建处理之前返回。)

是否有设置命令之类的东西,我可以用来让vscode在完成“目标创建”处理后发送其他mi命令?

我知道我可以使用以下方式在Debug-console中手动执行此操作:

-exec process handle -s false -n false -p true SIGSEGV

但是不必记住该较长的命令会更好,而是自动运行它(+继续进行我的实际非MAIN断点)。

编辑:我找到了postremoteconnectCommands选项(似乎没有记录,但)。我可以将其用于GDB断点,该断点不起作用,而没有首先在“设置断点”的情况下使用。但是,PoStremoteConnectCommands与vscode一起使用LLDB时,似乎仍在设置目标之前运行。

I've created a VSCode launch.json configuration that can invoke my program, set some breakpoints and stop at the main breakpoint:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(lldb) Launch",    
            "type": "cppdbg",
            "request": "launch",
            "program": "/usr/bin/foo",                                                                                                                                
            "args": ["--debug", "-j", "${fileDirname}/${fileBasenameNoExtension}.xxx"],                                                                               
            "stopAtEntry": true,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb",
            "miDebuggerPath": "/usr/bin/lldb-mi",
            //"logging": {
            //    "trace": true,
            //    "traceResponse": true,
            //    "engineLogging": true
            //},
            "setupCommands": [                                     
                { "text": "-break-insert -f rc_pli_enter_module" },
                { "text": "-break-insert -f print_message" },     
                { "text": "-break-insert -f rc_pli_fatal_error" }           
            ]
        }
    ]
}

I need the pass the following to the debugger:

process handle -s false -n false -p true SIGSEGV

since our code has a complicated SEGV handler that basically needs to be ignored while debugging, however, if I include that 'process handle' in the setupCommands, I get an error:

error: invalid target, create a target using the 'target create' command

I see in the debug-console log (when enabled) that all these setupCommands run before VSCode sends it's commands to the MI client that get the target actually running. i.e.:

-environment-cd /home/pjoot/...
-file-exec-and-symbols /usr/bin/foo
-exec-arguments --debug -j /home/pjoot/yyy.xxx
-exec-run

If I try putting those target commands into my setupCommands then I can get my 'process handle' to run after the main breakpoint, but VSCode will then try to do that itself and things get confused (it doesn't like the threads output that it gets back prior to it's own target-create processing.)

Is there something like setupCommands that I can use to have VSCode send additional MI commands after the 'target create' processing is done?

I know that I can do this manually in the debug-console using:

-exec process handle -s false -n false -p true SIGSEGV

but it would be nicer to not have to remember that long command, and instead run that (+continue to my real non-main breakpoint) automatically.

EDIT: I found the postRemoteConnectCommands option (that doesn't seem to be documented, but is mentioned here). I'm able to use this for gdb breakpoints, which don't work in setupCommands without 'set breakpoints pending on' first. However, postRemoteConnectCommands when used with lldb by vscode, still appears to be run before the target is setup.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文