Linux环境下安装和调试mono运行时源码

本文 通过 询问 ChatGPT 获得信息。

首先,我们需要获得Mono源码 , 进入Github下载页面点击下载

然后 我们可以在VMware中安装Ubuntu系统,接着将下好的 源码压缩文件拷贝进去,然后解压。

解压完成后,我们 运行 下面的脚本来获得debug版本的mono

./autogen.sh --enable-debug=yes CFLAGS="-g -O0"
make -j$(nproc)

Key flags:

  • --enable-debug=yes → enables debug features
  • -g -O0 → ensures symbols + no optimization (critical)

编译完成后, 我们需要再运行

sudo make install

这会将Mono 安装到/usr/local中。

然后我们用VSCode打开 源码解压的 目录

将下面的json 写入到文件.vscode/launch.json中。

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug Mono Runtime",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceFolder}/mono/mono/mini/mono",
      "args": ["${workspaceFolder}/test.exe"],
      "cwd": "${workspaceFolder}",
      "MIMode": "gdb",
      "stopAtEntry": false,
      "externalConsole": false,
      "setupCommands": [
        {
          "description": "Enable pretty printing",
          "text": "-enable-pretty-printing"
        }
      ]
    }
  ]
}

到这里我们就可以调试mono源码了。

Hybrid debugging (most powerful)

This is the real “expert mode”:

Run Mono under gdb (VS Code)
Enable Mono debugging simultaneously

You can:

Break in C runtime
Step into managed code
Watch transitions (JIT, GC, etc.)

参考

https://www.cnblogs.com/llj098/archive/2010/06/13/compile-debug-mono-with-gdb.html

https://chatgpt.com/

posted @ 2026-04-01 15:45  dewxin  阅读(2)  评论(0)    收藏  举报