farre / midas

A GDB/MI Visual Studio Code Debug Adapter
MIT License
29 stars 1 forks source link

Fails to add a new Launch Configuration #176

Closed sj-raima closed 8 months ago

sj-raima commented 9 months ago

Background: Launch configurations are normally in the project directory .vscode/launch.json. However, they can also be added to the user settings: .config/Code/User/settings.json like this: { ... "launch":{ "version": "0.2.0", "configurations": [

    // Run a custom app
    {
        "name": "custom (cppdbg)",
        "type": "cppdbg",
        "request": "launch",
        "program": "${command:cmake.launchTargetPath}",
        "args": [
        ],
        "stopAtEntry": false,
        "cwd": "${command:cmake.buildDirectory}",
        "externalConsole": false,
        "presentation": {
            "hidden": false,
            "group": "custom",
            "order": 1
         }
    },

    // Time traveling debugging
    {
        // Run a program like this:
        //
        //    $ rr record ./program args
        //
        // Afterwards it can be replayed in the debugger
        // with the following configuration
        //
        "name": "Replay (midas-rr)",
        "type": "midas-rr",
        "request": "attach",
        "use-dap": true,
        "trace": "Full",
        "setupCommands": [
            "set debuginfod enabled off",
            "set auto-load safe-path /"
        ],
        "gdbPath": "/opt/binutils-gdb/bin/gdb",
        "stopOnEntry": true,
        "presentation": {
            "hidden": false,
            "group": "zcustom",
            "order": 2
        }
    }
    ]
}

}

Above I have shown two of them where the last one is using the Midas extension. I have not tested exactly this configuration. If you have problems reproducing it I can make an example completely from scratch.

The issue reproduced with Midas v0.19.8:

If I select a launch configuration that is in the settings and hit the gear icon to open launch.json it opens settings.json instead. This is OK.

Opening the launch.json manually and then use the button at the bottom right to add a new Launch Configuration does not always work. The list of configurations to select from does not come up.

It may also behave differently depending on whether the first configuration (in the drop-down for the gear icon) is in settings.json or launch.json.

If I disable Midas I believe the list of configurations to select from always come up.

theIDinside commented 9 months ago

Interesting, I had no idea that a launch configuration could be set in the user settings (the global settings.json file) instead of the workspace settings (launch.json).

Just to be clear, is it in the global settings that is exhibiting faulty behaviour or is it inside the launch.json file that something fails, or behaves unintuitive?

When testing locally, this is the behaviour I see:

Could you try and verify if this behaviour is also seen on your machine?

When trying this, be sure to open the developer tools for vscode (Help->Toggle developer tools) - if there is some issue with the Midas extension, one might expect (hopefully) that an exception is being thrown somewhere and not caught which would be displayed in the console.

sj-raima commented 9 months ago

Further investigation seems that this issue is not specific to Midas but is a generic issue not specifically tied to Midas. It may have been a coincidence that this appeared when I added the launch configuration for Midas. However, I have included my investigation below as I was working on reproducing this issue according to your steps in case my assumptions are wrong.

FYI: The global configuration also respects the presentation element and may therefore not appear last.

Now to the issue:

The following launch.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": [
    ]
}

And the following in settings.json:

...
   "launch":{
        "version": "0.2.0",
        "configurations": [

        // Run a custom app
        {
            "name": "custom (cppdbg)",
            "type": "cppdbg",
            "request": "launch",
            "program": "${command:cmake.launchTargetPath}",
            "args": [
            ],
            "stopAtEntry": false,
            "cwd": "${command:cmake.buildDirectory}",
            "externalConsole": false,
            "presentation": {
                "hidden": false,
                "group": "custom",
                "order": 1
             }
        },

        // Time traveling debugging
        {
            // Run a program like this:
            //
            //    $ rr record ./program args
            //
            // Afterwards it can be replayed in the debugger
            // with the following configuration
            //
            "name": "Replay (midas-rr)",
            "type": "midas-rr",
            "request": "attach",
            "use-dap": true,
            "trace": "Full",
            "setupCommands": [
                "set debuginfod enabled off",
                "set auto-load safe-path /"
            ],
            "gdbPath": "/opt/binutils-gdb/bin/gdb",
            "stopOnEntry": true,
            "presentation": {
                "hidden": false,
                "group": "zcustom",
                "order": 2
            }
        }
      ],
    },
...

If I have the tab for settings.json selected in editor, adding a configuration does not work (sometime it might work depending on the order of certain operations). However if the launch.json is selected it always works.

Nothing in the developer console.

Your second bullet point, I were not able to reproduce. However, I have seen it in the past where no "Add configuration" button appear.

I disabled Midas and still were able to reproduce the issue. This makes me believe it has nothing to do with the Midas extension but it is a generic issue.

It seems that if a launch configuration is in the global settings and it sorts first we get this issue.

farre commented 8 months ago

@sj-raima would you be ok if I close this after your most recent findings?

sj-raima commented 8 months ago

@farre Yep, Go ahead.

farre commented 8 months ago

@sj-raima found the error cause of this not to be midas' doing. Closing the issue.