2019年5月14日 星期二

解決 VS code 中使用 gdb 但找不到某些內建 function 的相關 debug 資訊的情況

若出現

Unable to open 'strcmp.S': File not found (file:///build/glibc-OTsEL5/glibc-2.27/sysdeps/x86_64/strcmp.S).

之錯誤訊息,可參考以下解法:


step 1


sudo git clone https://github.com/jeremie-koenig/glibc /opt/src/glibc

step 2


在launch.json檔案裡面 加入以下資訊

            "sourceFileMap": {
                "/build/glibc-OTsEL5/glibc-2.27/": "/opt/src/glibc/"

            }



參考資料:

https://stackoverflow.com/questions/13978692/strcpy-sse2-unaligned-s-not-found



Step 1 + Step 2

sudo git clone https://github.com/jeremie-koenig/glibc /build/glibc-OTsEL5/glibc-2.27

以下附上我可以成功debug的相關設定

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": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",
            "args": ["<", "D1"],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "Build",
            "sourceFileMap": {
                "/build/glibc-OTsEL5/glibc-2.27/": "/opt/src/glibc/"
            }
        }
    ]
}


tasks.json


{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",
            "type": "shell",
            "command": "make"
        }
    ]
}


2019/11/23 更新


其實好像不用clone
18.04 預設放在
file /lib/x86_64-linux-gnu/libc-2.27.so
裡面


2019/12/20 更新

請到這裡
https://ftp.gnu.org/gnu/glibc/
下載 glibc-2.27 的版本
放到/build/glibc-OTsEL5裡面
才能確保所有功能都正常

沒有留言:

張貼留言