richterger / Perl-LanguageServer

Language Server for Perl
Other
225 stars 52 forks source link

Can't set breakpoints in perl modules located in subdirectories of workspace #206

Open J0EK3R opened 9 months ago

J0EK3R commented 9 months ago

Hi @richterger, dear Gerald, many thanks for your great work!

Currently I'm running VSCode with Win11 and Perl in WSL und a proper und current installation of your VSCode extension and your LanguageServer.

In my very simply example I'm setting a first breakpoint in start.pl wich works and stops the debugger as expected. Then I would like to set a second breakpoint within the function "something" in the module "test.pm" wich is located in the subdirectory "Modules" in the workspace.

When I start debugging the first breakpoint works as expected and the debugger stops. The second breakpoint-Dot in VSCode is getting gray und the debugger didn't stop.

Here is my example:

Workspace: ~/projects/test/ containing file start.pl and the subdirectory Modules/ containing test.pm

content of ~/projects/test/start.pl

#!/usr/bin/perl

package main;

use strict;
use warnings;

use lib '.';

# include file test.pm in subdirectoty "Modules"
use Modules::test;

# first working breakpoint in the following line
print "something\n";

# call function "something" in Modules/test.pm
Modules::test->something();

content of ~/projects/test/Modules/test.pm

package Modules::test;

use strict;
use warnings;

sub something 
{
    # I want to set the Breakpoint in the following line
    print "something\n";
}

return 1;

content of ~/projects/test/.vscode/settings.json

{
    "perl.enable": true,
    "perl.perlInc": [
        "~/projects/test/",
        "~/projects/test/Modules/",
    ],
    "perl.useTaintForSyntaxCheck": false,
    "perl.logLevel": 2,
    "perl.disableCache": false,
}

content of ~/projects/test/.vscode/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": [
        {
            "type": "perl",
            "request": "launch",
            "name": "Perl-Debug",
            "program": "${workspaceFolder}/start.pl",
            "stopOnEntry": true,
            "reloadModules": true
        }
    ]
}

Here is some logging from the Perl Language Server:

The first working breakpoint in start.pl

DA: ---> Request: {
   "command" : "breakpointLocations",
   "type" : "request",
   "seq" : 3,
   "arguments" : {
      "line" : 14,
      "source" : {
         "path" : "/home/jochen/projects/test/start.pl",
         "name" : "start.pl"
      }
   }
}

DAI: <--- To debuggee: {
   "jsonrpc" : "2.0",
   "filename" : "/home/jochen/projects/test/start.pl",
   "command" : "can_break",
   "seq" : 1000000000,
   "end_line" : null,
   "line" : 14
}

DAI: ---> From debuggee: {
   "command" : "di_response",
   "seq" : 1000000000,
   "arguments" : {
      "breakpoints" : [
         {
            "line" : 14
         }
      ]
   },
   "type" : "dbgint"
}

DA: <--- Response: {
   "command" : "breakpointLocations",
   "request_seq" : 3,
   "type" : "response",
   "body" : {
      "breakpoints" : [
         {
            "line" : 14
         }
      ]
   },
   "seq" : 3,
   "success" : true
}

DA: ---> Request: {
   "command" : "setBreakpoints",
   "arguments" : {
      "lines" : [
         14
      ],
      "source" : {
         "path" : "/home/jochen/projects/test/start.pl",
         "name" : "start.pl"
      },
      "breakpoints" : [
         {
            "line" : 14
         }
      ],
      "sourceModified" : false
   },
   "seq" : 5,
   "type" : "request"
}

DA: <--- Response: {
   "body" : {
      "breakpoints" : [
         {
            "verified" : true,
            "line" : 14,
            "message" : null,
            "id" : 0,
            "source" : {
               "path" : "/home/jochen/projects/test/start.pl"
            }
         }
      ]
   },
   "type" : "response",
   "seq" : 5,
   "success" : true,
   "command" : "setBreakpoints",
   "request_seq" : 5
}

The second non-working breakpoint in Modules/test.pm

DA: ---> Request: {
   "command" : "setBreakpoints",
   "arguments" : {
      "breakpoints" : [
         {
            "line" : 9
         }
      ],
      "sourceModified" : false,
      "lines" : [
         9
      ],
      "source" : {
         "path" : "/home/jochen/projects/test/Modules/test.pm",
         "name" : "test.pm"
      }
   },
   "seq" : 6,
   "type" : "request"
}

DAI: <--- To debuggee: {
   "breakpoints" : [
      [
         9,
         null
      ]
   ],
   "seq" : 1000000003,
   "command" : "breakpoint",
   "filename" : "/home/jochen/projects/test/Modules/test.pm",
   "jsonrpc" : "2.0"
}

DAI: ---> From debuggee: {
   "type" : "dbgint",
   "arguments" : {
      "breakpoints" : [
         [
            9,
            null,
            null,
            null,
            null,
            null,
            1
         ]
      ]
   },
   "seq" : 1000000003,
   "command" : "di_response"
}

DA: <--- Response: {
   "command" : "setBreakpoints",
   "request_seq" : 6,
   "success" : true,
   "seq" : 6,
   "type" : "response",
   "body" : {
      "breakpoints" : [
         {
            "message" : null,
            "id" : 1,
            "source" : {
               "path" : null
            },
            "verified" : false,
            "line" : 0
         }
      ]
   }
}

But - after stopping at the first breakpoint in start.pl: If I step-in (F11) from start.pl into the funtion-call "something", then VSCode opens "Modules/test.pm" in a new readonly page where I'm able to set my desired breakpoint (while debugging) - wich will work.

Noticeable is that the shown path when hovering with the mouse over the pages tab is "Modules/test.pm". When opening the file by double-clicking from within the workspace-Window of VSCode the full path as mouse-over-info is "~/procests/test/Modules/test.pm".

Here is the logging of successfully setting the breakpoint in test.pm:

DA: ---> Request: {
   "command" : "setBreakpoints",
   "type" : "request",
   "seq" : 32,
   "arguments" : {
      "sourceModified" : false,
      "breakpoints" : [
         {
            "line" : 9
         }
      ],
      "source" : {
         "path" : "Modules/test.pm"
      },
      "lines" : [
         9
      ]
   }
}

DAI: <--- To debuggee: {
   "command" : "breakpoint",
   "filename" : "Modules/test.pm",
   "jsonrpc" : "2.0",
   "breakpoints" : [
      [
         9,
         null
      ]
   ],
   "seq" : 1000000025
}

DAI: ---> From debuggee: {
   "command" : "di_response",
   "arguments" : {
      "breakpoints_set" : 1,
      "breakpoints" : [
         [
            9,
            null,
            1,
            null,
            "9",
            "Modules/test.pm"
         ]
      ]
   },
   "seq" : 1000000025,
   "type" : "dbgint"
}

DA: <--- Response: {
   "seq" : 32,
   "success" : true,
   "type" : "response",
   "body" : {
      "breakpoints" : [
         {
            "message" : null,
            "id" : 0,
            "source" : {
               "path" : "Modules/test.pm"
            },
            "verified" : true,
            "line" : 9
         }
      ]
   },
   "request_seq" : 32,
   "command" : "setBreakpoints"
}

DA: ---> Request: {
   "type" : "request",
   "arguments" : {
      "line" : 9,
      "source" : {
         "path" : "Modules/test.pm"
      }
   },
   "seq" : 33,
   "command" : "breakpointLocations"
}

DAI: <--- To debuggee: {
   "seq" : 1000000026,
   "end_line" : null,
   "line" : 9,
   "jsonrpc" : "2.0",
   "filename" : "Modules/test.pm",
   "command" : "can_break"
}

DAI: ---> From debuggee: {
   "arguments" : {
      "breakpoints" : [
         {
            "line" : 9
         }
      ]
   },
   "seq" : 1000000026,
   "type" : "dbgint",
   "command" : "di_response"
}

DA: <--- Response: {
   "request_seq" : 33,
   "command" : "breakpointLocations",
   "type" : "response",
   "body" : {
      "breakpoints" : [
         {
            "line" : 9
         }
      ]
   },
   "seq" : 33,
   "success" : true
}

Bug or feature - or my fault!? ;)

J0EK3R commented 9 months ago

Setting "cwd" in launch.json and changing "perl.perlInc" to absolute paths in settings.json did not help. Is it a problem with Win11 and WSL?