microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.42k stars 1.52k forks source link

[FEATURE REQUEST] Support debugging for YACC #4942

Open rvanlaar opened 4 years ago

rvanlaar commented 4 years ago

Type: Debugger

Can't DEBUG YACC files.

I wrote a short yacc file which had a problem. I wasn't able to attach a debugger to the main function.

I would like to see the following:

To Reproduce I made a short version of a yacc file to highlight the problems. This yacc file is not supposed to work, it's supposed to highlight the problems with the debugger. All the files are in this gist: https://gist.github.com/rvanlaar/000c06347ef6fd6bfb5e7ddb8e17f0aa

The y.tab.c is generated with debug options enabled: yacc -t --debug --verbose hoc1.y

Steps to reproduce the behavior:

  1. Open the files in VSCode
  2. Set a breakpoint on line y.tab.c: 1458
  3. compile with: cc -g y.tab.c -o hoc1
  4. run the debugger
  5. See it doesn't hit the breakpoint while executing

Additional context https://gist.github.com/rvanlaar/000c06347ef6fd6bfb5e7ddb8e17f0aa#file-full-debug-log If applicable, please include logging by adding "logging": { "engineLogging": true, "trace": true, "traceResponse": true } in your launch.json Add any other context about the problem here including log or error messages in your Debug Console or Output windows.

pieandcakes commented 4 years ago

You can add the support by changing the installed extension's package.json. You would need to add a block such as:

    "contributes": {
        "languages": [{
            "id": "yacc",
            "extensions": [".yacc"],
            "aliases": [ "YACC", "yacc" ]
        }],

and then add in the breakpoint section:

"language": "yacc"

This will tell VSCode that breakpoints set in your file should go to our extension. If we get enough upvotes we can look at adding it as part of the official extension.

pieandcakes commented 4 years ago

There should be a make support issue already if you want to go upvote that one.

rvanlaar commented 4 years ago

Hi @pieandcakes thank you for your response.

This is great. It works. One note: the extension for bison/yacc is .y.

The contributes part in the package.json looks like:

    "contributes": {
        "languages": [{
            "id": "yacc",
            "extensions": [".y"],
            "aliases": [ "YACC", "yacc" ]
        }],
rvanlaar commented 4 years ago

I tried searching for a make support issue, but couldn't find it. If there is one that you know of, could you point me to it?

bobbrow commented 4 years ago

Integrated support for make is something we've seen requested in our survey results, but I don't think an issue was ever opened on GitHub requesting this. If you wouldn't mind opening an issue for others to find and upvote, we would appreciate it.