microsoft / microsoft/vscode-cpptools

[OSX] lldb cannot read bitfield dwarf debug info generated by -mmacosx-version-min=10.11

Open
#2,823 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug debugger
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Type: Debugger

Describe the bug

  • OS and Version: MacOSX 10.4.1
  • VS Code Version: 1.29.0
  • C/C++ Extension Version: 0.20.1
  • A clear and concise description of what the bug is.

Starting from MacOSX target 10.11, clang tunes it's debug information for lldb. This causes the version of lldb embedded in the cpptools extension to misreport bitfield values.

To Reproduce

#include <stdio.h>

int main() {
    struct Test {
        unsigned short a;
        unsigned short b : 1;
        unsigned short c: 15;
    };

    Test x = {0};
    x.a = 5;
    printf("%hu", x.b);
    return 0;
}
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(lldb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "lldb"
        }
    ]
}

Steps to reproduce the behavior:

  1. Run clang++ test.cc -mmacosx-version-min=10.11 -g
  2. Place a breakpoint at line 10: x.a = 5
  3. Launch debugger
  4. Step over x.a = 5 and see that x.b or x.c changes value (lldb cannot find the right addresses for the bitfields.

Additional context
Compilation where older lldb works:

  1. clang++ -c test.cc -mmacosx-version-min=10.10 -g
  2. clang++ -c test.cc -mmacosx-version-min=10.11 -ggdb

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the minimal test.cc case with clang++ using -mmacosx-version-min=10.10 and 10.11, then launch it with the provided .vscode/launch.json configuration. Compare how the debugger reports x.b and x.c after stepping over x.a = 5; done means bitfield values remain correct for the 10.11 target.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.