code-debug icon indicating copy to clipboard operation
code-debug copied to clipboard

Integration of mago concord extension with cppvsdbg

Open rainers opened this issue 4 years ago • 9 comments

Hi,

as of cpptools-1.4, it is possible to load concord extensions into the cppvsdbg debug engine of VS Code. This allows adding the D expression evaluation of mago to the native C++ debugger for Windows, see https://github.com/microsoft/vscode-cpptools/issues/2932#issuecomment-853774543

The existing MagoNatCC.dll already works with it, it's just a matter of adding two configuration files for vsdbg to find it, plus a tiny addition to some package.json.

Are you interested in adding this to this debug extension? I think it would be better to have it all in one VS Code extension than to add another one.

rainers avatar Jun 13 '21 06:06 rainers

I wanted to add the mago part as part of code-d or completely separate extension, I think that makes more sense. Code-D also ships with pretty-printers for GDB and LLDB using Native Debug, CodeLLDB and C/C++ Debuggers + a NatVis file for vscppdbg so it makes sense to add other extensions to there too.

Otherwise this is completely unrelated to Native Debug anyway.

WebFreak001 avatar Jun 14 '21 08:06 WebFreak001

I was a bit confused what packages are actually the ones installed and how the dependencies are. If Code-D is the one that also installs mago-mi.exe or vscppdbg natvis files, that would probably be a good fit for MagoNatCC.dll, too. Should we move the issue over to code-d, then?

I'll add the required config file and a short description to the mago repository.

rainers avatar Jun 14 '21 16:06 rainers

I'll add the required config file and a short description to the mago repository.

Committed it now, see here for how to install it in VS Code: https://github.com/rainers/mago/blob/master/ReadMe.txt#L50

rainers avatar Jun 15 '21 05:06 rainers

hm got the MagoNatCC.dll and the 2 other files copied into one folder and in the vscppdbg log it says it loads extensions from my specified link folder, but I don't think anything has changed. What features does adding mago introduce that I can check for?

WebFreak001 avatar Jun 16 '21 06:06 WebFreak001

For starters, a string is displayed as text. An associative array shows keys and elements. You can evaluate a single element of an AA in the watch window. Mago can also execute functions, which is used for display customization: https://rainers.github.io/visuald/visuald/Debugging.html#customization

You also get most of this with mago-mi.exe, but that doesn't integrate well with C++. Also, other features of the native C++ debugger are not implemented by mago-mi, e.g. conditional breakpoints.

BTW: You have to build the D code with -g, not -gc, so the correct source language is embedded in the debug information.

rainers avatar Jun 16 '21 16:06 rainers

hm that stuff does not work for me (using LDC or DMD)

WebFreak001 avatar Jun 16 '21 20:06 WebFreak001

Hmm, here's a shot from my test session for a file compiled with dmd (LDC doesn't emit enough debug information for function calls): image

launch.json doesn't look too fancy, but maybe there is something important missing in your version. This is mine:

{
    // 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": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "C:/Users/Rainer/source/repos/WindowsApp3/x64/Debug/WindowsApp3.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "console": "externalTerminal"
        }
    ]
}

BTW: OMF is not supported, so compile with -m64 or -32mscoff, not -m32.

rainers avatar Jun 17 '21 17:06 rainers

got the configuration like that and put a link file with absolute path to the folder containing the MagoNatCC.dll/MagoNatCC.vsdconfig/vsdbg-config.json as content (no trailing new line) inside ~/.cppvsdbg/extensions/code-d-mago.link correct?

Also tried with dub --arch=x86_64 but still no functionality.

grafik

grafik

(note: tried renaming the vsdconfigxml to vsdconfig but both don't work)

Your readme said to copy MagoNatCC.vcdconfig but that file doesn't exist anywhere in source code or in the appveyor release so I assumed it must be this xml.

grafik

WebFreak001 avatar Jun 17 '21 19:06 WebFreak001

Your readme said to copy MagoNatCC.vcdconfig but that file doesn't exist anywhere in source code or in the appveyor release so I assumed it must be this xml.

Ah, that might be the issue: MagoNatCC.vsdconfig is built from the xml file and is part of the installation via Visual D. I have now added the file to the artifacts of the mago build on Appveyor: https://ci.appveyor.com/project/rainers/mago/builds/39653568/artifacts

rainers avatar Jun 18 '21 06:06 rainers