VSCode 无法打开 libc-start.c

Issue Description

VSCode 调试 stopAtEntry 或者到最后一步报错:

无法打开“libc-start.c”: 无法读取文件'vscode-remote://ssh-remote+<IP>/build/glibc-S7xCS9/glibc-2.27/csu/libc-start.c' (Error: 无法解析不存在的文件"vscode-remote://ssh-remote+<IP>/build/glibc-S7xCS9/glibc-2.27/csu/libc-start.c")。

Root Cause

系统中没有 glibc 源码可供调试

Solution

  1. 安装 glibc 源码

    sudo apt install glibc-source
    cd /usr/src/glibc/
    sudo tar -xvf glibc-2.27.tar.xz
    
  2. launch.json 中添加 sourceFileMap 配置项

    {
       "version": "0.2.0",
       "configurations": [
          {
             "name": "launch after cmake build",
             "type": "cppdbg",
             "request": "launch",
             "program": "${fileDirname}/build/play",
             "args": [],
             "stopAtEntry": false,
             "cwd": "${workspaceFolder}",
             "environment": [],
             "externalConsole": false,
             "MIMode": "gdb",
             "preLaunchTask": "CMake Build",
             "miDebuggerPath": "/usr/bin/gdb",
             "sourceFileMap": {"/build/glibc-S7xCS9": "/usr/src/glibc"}
          }
       ]
    }
    

Reference

https://blog.csdn.net/slc1112/article/details/109686361

posted @ 2021-03-13 10:08  Zijian/TENG  阅读(1716)  评论(2编辑  收藏  举报