1 year ago

#379474

test-img

Peeter Joot

How to run VSCode launch debug commands after the -exec-run point?

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.

visual-studio-code

lldb

0 Answers

Your Answer

Accepted video resources