9
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CodeLLDBでSTLの中身が表示されないときの対処法

Last updated at Posted at 2021-10-01

状況

CodeLLDBを用いてC++のデバッグを行う際に、下の画像のようにSTLの中身がうまく表示されない。
スクリーンショット 2021-10-01 23.19.19.png

環境

  • macOS BigSur 11.6
  • lldb 1205.0.27.3
  • gcc (g++) 11.2.0
  • VS Code

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Build C++17 for Debug",
      "type": "shell",
      "command": "g++",
      "args": [
        "-std=c++17",
        "-g",
        "${file}",
        "-o",
        "${fileDirname}/debug",
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "lldb",
      "request": "launch",
      "name": "codeLLDB Debug",
      "program": "${fileDirname}/debug",
      "args": [],
      "cwd": "${workspaceFolder}",
      "externalConsole": true,
      "preLaunchTask": "Build C++17 for Debug",
    }
  ]
}

原因

※正しい原因ではない可能性があります。

LLDBが対応しているデバッグファイルフォーマットがうまく生成されていない?
LLDBの対応フォーマット
デバッグオプションごとの生成フォーマット

対処

コンパイラオプションに明示的にレベル3のdwarfフォーマットを指定する。

変更後のtasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Build C++17 for Debug",
      "type": "shell",
      "command": "g++",
      "args": [
        "-std=c++17",
        "-gdwarf-3",
        "${file}",
        "-o",
        "${fileDirname}/debug",
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

変更後、下記のようにSTLの中身が表示されるようになった。
スクリーンショット 2021-10-01 23.19.48.png

参考

Why lldb pretty printers doesn't work for GNU GCC compiled program on MacOS?

9
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?