【问题标题】:Debugging Perl with Visual Studio Code使用 Visual Studio Code 调试 Perl
【发布时间】:2021-11-26 03:08:31
【问题描述】:

我今天刚开始使用 Perl,安装了ActivePerl 5.24.1,一切顺利。我能够使用简单的print 命令创建我的测试程序testPerl.pl 并通过console 运行它。

现在我想使用 Visual Studio Code 来运行我的 Perl 脚本,所以我用 Visual Studio Code 打开了项目文件夹 [testPerl.pl 位置] 并尝试调试代码。我在编辑器中安装了Perl-Debug 扩展,当我点击 F5 时,Visual Studio Code 要求我选择环境,我选择了 Perl 调试 选项,它实际上为我创建了launch.json 文件,内容如下。

{
    "version": "0.0.2",
    "configurations": [
        {
            "type": "perl",
            "request": "launch",
            "exec": "perl",
            "name": "Perl-Debug",
            "root": "${workspaceRoot}/",
            "program": "${workspaceRoot}/${command.AskForProgramName}",
            "inc": [],
            "stopOnEntry": true
        }
    ]
}

我保留了默认值,当我再次点击 F5 时,它要求我输入默认值 test.pl 的命令。我猜是因为${command.AskForProgramName}。我在命令中输入了我的文件名testPerl.pl,但没有任何反应。它在控制台中没有任何print 的情况下开始和结束。

我如何才能真正配置这个launch.json 文件,或者我需要其他方法吗?

【问题讨论】:

  • this doc 中显示请注意,这些启动配置中可用的属性因调试器而异。您可以使用 IntelliSense 找出特定调试器存在哪些属性。
  • @simbabque 同意,如预期的那样创建自己的自动生成的launch.json文件,根据它自动生成的文件,和我们在命令行中执行的一样..
  • 不幸的是,我无法访问允许我安装 ActivePerl 的 Windows 框,因此我无法尝试。它看起来当然是正确的。有什么方法可以让你的 VSCode 的日志面板显示它正在做什么?
  • 如果它被记录,我希望我能给你详细信息,但不幸的是,编辑器中没有任何记录..

标签: perl visual-studio-code


【解决方案1】:

我尝试使用更新版本的插件:Perl Debug 0.2.0 版。

这是开箱即用的。建议的配置如下:

{
    // 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 local",
            "program": "${workspaceFolder}/${relativeFile}",
            "exec": "perl",
            "execArgs": [],
            "root": "${workspaceRoot}/",
            "inc": [],
            "args": [],
            "env": {},
            "stopOnEntry": true
        },
        {
            "type": "perl",
            "request": "launch",
            "name": "Perl-Debug remote",
            "program": "${workspaceFolder}/${relativeFile}",
            "root": "${workspaceRoot}/",
            "stopOnEntry": true,
            "port": 5000
        }
    ]
}

请注意,我在 Mac 上使用 Visual Studio Code 版本 1.24.0 进行了尝试。

【讨论】:

  • Per-Debug 远程是什么?
  • Perl 调试插件的链接不再有效!
【解决方案2】:

我在 Mac 上运行 Visual Studio Code 并进行了更改

"program": "${workspaceRoot}/${command.AskForProgramName}"

"program": "${file}"

获取当前文件进行调试。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-08-11
    • 2019-10-31
    • 1970-01-01
    • 2015-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多