如何在 VSCode 中调试 FreePascal

发布于 01-16 05:01 字数 4231 浏览 5 评论 0原文

当我使用 VSCode 为 Pascal 语言编写代码时,我安装了一些扩展来调试我的程序。我使用 Native Debug 进行调试。我在网上查阅了一些教程,但没有成功。告诉我这里有什么错误。

在此处输入图像描述

我的 json 文件:

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "gdb",
            "request": "launch",
            "name": "Debug",
            "target": "${fileBasenameNoExtension}",
            "cwd": "${workspaceFolder}",
            // "terminal": "",
            "valuesFormatting": "parseText",
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\FPC\\3.2.2\\bin\\i386-win32\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "fpc: Build Debug",
            "postDebugTask": "fpc: Clean Files"
        },
    ]
}

和 < strong>tasks.json

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    { // shortcut: cmd+shift+B (run build task)
      "label"  : "fpc: Build Debug",
      "type"   : "shell",
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "command": "fpc",
      "args": [
        "${file}",      // source code file
        "-Px86_64",     // target platform 64-bit
        "-Mobjfpc",     // object pascal mode
        "-S2cahi",      // pascal syntax setting
        "-Croti",       // generated code setting
        "-O1",          // code optimization setting
        "-glpsw3",      // debug info setting
        "-godwarfcpp",  // dwarf mode setting
        "-v"            // verbose message
      ],
      "problemMatcher": []
    },
    { // shortcut: none
      "label"  : "fpc: Build Release",
      "type"   : "shell",
      "group"  : "build",
      "command": "fpc",
      "args": [
        "${file}",      // source code file
        "-Px86_64",     // target platform 64-bit
        "-Mobjfpc",     // object pascal mode
        "-S2cahi",      // pascal syntax setting
        "-Croti",       // generated code setting
        "-O3",          // code optimization setting
        "-XXs",         // executable setting
        "-v"            // verbose message
      ],
      "problemMatcher": []
    },
    { // shortcut: none
      "label": "fpc: Syntax Check",
      "type": "shell",
      "group": "build",
      "command": "fpc",
      "args": [
        "${file}",      // source code file
        "-Px86_64",     // target platform 64-bit
        "-Mobjfpc",     // object pascal mode
        "-S2cahi",      // pascal syntax setting
        "-s",           // syntax check mode
        "-v"            // verbose message
      ],
      "problemMatcher": []
    },
    { // shortcut: cmd+shift+R (run test task)
      "label": "fpc: Execute Binary",
      "type": "shell",
      "group": {
        "kind": "test",
        "isDefault": true
      },
      "command": "${fileBasenameNoExtension}",
      "args": [],
      "problemMatcher": []
    },
    { // shortcut: none
      "label": "fpc: Clean Files",
      "type": "shell",
      "command": "rm",
      "args": [
        "${fileBasenameNoExtension}",  // executable file
        "${fileDirname}/*.a",          // generated linker file
        "${fileDirname}/*.o",          // generated object file
        "${fileDirname}/*.exe",
        "${fileDirname}/*.s",          // generated assembler file
        "${fileDirname}/*.ppu",        // generated unit file
        "${fileDirname}/*.dwarf",      // generated dwarf debug file
        "*.res",                       // generated resource file
        "ppas.bat",                    // generated build script file
      ],
      "problemMatcher": []
    }
  ]
}

我使用的是 Windows 操作系统。帮我。

As I use VSCode to code for Pascal language and I have installed some extensions to debug my program. I use Native Debug for debugging. I have consulted several tutorials on the net but with no success. Tell me what is the error here.

enter image description here

My json files:

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "gdb",
            "request": "launch",
            "name": "Debug",
            "target": "${fileBasenameNoExtension}",
            "cwd": "${workspaceFolder}",
            // "terminal": "",
            "valuesFormatting": "parseText",
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\FPC\\3.2.2\\bin\\i386-win32\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "fpc: Build Debug",
            "postDebugTask": "fpc: Clean Files"
        },
    ]
}

and tasks.json

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    { // shortcut: cmd+shift+B (run build task)
      "label"  : "fpc: Build Debug",
      "type"   : "shell",
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "command": "fpc",
      "args": [
        "${file}",      // source code file
        "-Px86_64",     // target platform 64-bit
        "-Mobjfpc",     // object pascal mode
        "-S2cahi",      // pascal syntax setting
        "-Croti",       // generated code setting
        "-O1",          // code optimization setting
        "-glpsw3",      // debug info setting
        "-godwarfcpp",  // dwarf mode setting
        "-v"            // verbose message
      ],
      "problemMatcher": []
    },
    { // shortcut: none
      "label"  : "fpc: Build Release",
      "type"   : "shell",
      "group"  : "build",
      "command": "fpc",
      "args": [
        "${file}",      // source code file
        "-Px86_64",     // target platform 64-bit
        "-Mobjfpc",     // object pascal mode
        "-S2cahi",      // pascal syntax setting
        "-Croti",       // generated code setting
        "-O3",          // code optimization setting
        "-XXs",         // executable setting
        "-v"            // verbose message
      ],
      "problemMatcher": []
    },
    { // shortcut: none
      "label": "fpc: Syntax Check",
      "type": "shell",
      "group": "build",
      "command": "fpc",
      "args": [
        "${file}",      // source code file
        "-Px86_64",     // target platform 64-bit
        "-Mobjfpc",     // object pascal mode
        "-S2cahi",      // pascal syntax setting
        "-s",           // syntax check mode
        "-v"            // verbose message
      ],
      "problemMatcher": []
    },
    { // shortcut: cmd+shift+R (run test task)
      "label": "fpc: Execute Binary",
      "type": "shell",
      "group": {
        "kind": "test",
        "isDefault": true
      },
      "command": "${fileBasenameNoExtension}",
      "args": [],
      "problemMatcher": []
    },
    { // shortcut: none
      "label": "fpc: Clean Files",
      "type": "shell",
      "command": "rm",
      "args": [
        "${fileBasenameNoExtension}",  // executable file
        "${fileDirname}/*.a",          // generated linker file
        "${fileDirname}/*.o",          // generated object file
        "${fileDirname}/*.exe",
        "${fileDirname}/*.s",          // generated assembler file
        "${fileDirname}/*.ppu",        // generated unit file
        "${fileDirname}/*.dwarf",      // generated dwarf debug file
        "*.res",                       // generated resource file
        "ppas.bat",                    // generated build script file
      ],
      "problemMatcher": []
    }
  ]
}

I am using windows operating system. help me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太傻旳人生2025-01-23 05:01:36

我的猜测是,您使用 64 位 FPC(目标),但 VSCode 中仅安装了 32 位 GDB(请参阅 launch.json 中的 miDebuggerPath)。看看是否可以将 nativedebug 指向 64 位 GDB。

如果需要,您可以在此处找到与 Lazarus 一起使用的 64 位 gdb:https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/Alternative%20GDB/

My guess is that you use a 64-bit FPC (target), but only have a 32-bit GDB (see miDebuggerPath in launch.json) installed in your VSCode. See if you can point nativedebug to a 64-bit GDB.

If needed, you can find 64-bit gdb's for use with Lazarus here: https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/Alternative%20GDB/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文