[clang] [DebugInfo] Add bit size to _BitInt name in debug info (PR #165583)
Michael Buch via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 30 02:02:13 PDT 2025
Michael137 wrote:
> FWIW LLDB support seems limited currently as the type is printed as `short` and `a`'s value displayed as `32639` rather than `-129` (I don't think it's taking into account the DW_AT_bit_size here).
>
> ```c
> $ cat test.c -n
> 1 #include <string.h>
> 2
> 3 int main() {
> 4 _BitInt(15) a;
> 5 memset(&a, 0x7f, 2);
> 6 return 0; // GDB: b 6, p a
> 7 }
> ```
>
> ```c
> * thread #1, name = 'test.elf', stop reason = breakpoint 1.1
> frame #0: 0x0000555555555162 test.elf`main at test.c:6:3
> 3 int main() {
> 4 _BitInt(15) a;
> 5 memset(&a, 0x7f, 2);
> -> 6 return 0; // GDB: b 6, p a
> 7 }
> (lldb) p a
> (short) 32639
> (lldb) im lookup -t _BitInt(15)
> Best match found in /home/och/scratch/test.elf:
> id = {0x00000042}, name = "_BitInt(15)", qualified = "short", byte-size = 2, compiler_type = "short"
> ```
>
> If there's any LLDB testing I can do on my side please let me know
Yea the way that LLDB determines types for builtins is here: https://github.com/llvm/llvm-project/blob/44f5ae3eeca65661794f82cd5caa291ff8d6baf3/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp#L907
So `_BitInt` makes that a bit awkward, because not only does it have a non-fixed name (after this PR), but it also doesn't have a single size (i.e., multiple BitInt's can have different bit sizes). With the DWARFv6 new precise integer encoding that'll be slightly easier maybe. So I think what we'll have to do is add a case that checks for the `_BitInt` prefix and then just create a `BitIntType`. So we *probably* don't need the bitness in the DW_AT_name, but it also doesn't hurt. Let me play around with that, but regardless, LGTM!
https://github.com/llvm/llvm-project/pull/165583
More information about the cfe-commits
mailing list