| Issue |
238361
|
| Summary |
[lldb] C11 `_Atomic(T)` does not use formatters from `T`
|
| Labels |
lldb
|
| Assignees |
|
| Reporter |
Nerixyz
|
When using an [`_Atomic(T)`](https://en.cppreference.com/c/language/atomic) in C, data-formatters for `T` don't match. They need to explicitly specify `_Atomic(T)`. This can be unexpected as the value is otherwise formatted like a `T`. I think this should be handled similar to a typedef from `_Atomic(T)` to `T` (so if you disable cascading, it won't show).
**Example**
```console
> cat atomic.c
#include <stdatomic.h>
struct Point {
int x;
int y;
};
int main() {
_Atomic struct Point ap;
struct Point p = {2, 4};
atomic_store(&ap, p);
_Atomic(int) ai = 2;
return 0; // break here
}
> clang -g atomic.c
> lldb a.out -o "break add pattern -- break here" -o r -o 'type summary add Point --summary-string "(${var.x}, ${var.y})"' -o v -o q
(lldb) target create "a.out"
Current executable set to '/home/johannes/dev/playground/lldbfun/a.out' (x86_64).
(lldb) break add pattern -- break here
Breakpoint 1: where = a.out`main + 48 at atomic.c:13:3, address = 0x0000000000400480
(lldb) r
Process 197711 launched: '/home/johannes/dev/playground/lldbfun/a.out' (x86_64)
Process 197711 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000000000400480 a.out`main at atomic.c:13:3
10 struct Point p = {2, 4};
11 atomic_store(&ap, p);
12 _Atomic(int) ai = 2;
-> 13 return 0; // break here
14 }
(lldb) type summary add Point --summary-string "(${var.x}, ${var.y})"
(lldb) v
(_Atomic(Point)) ap = (x = 2, y = 4)
(Point) p = (2, 4)
(_Atomic(int)) ai = 2
(lldb) q
```
Here, I'd expect `ap` to be formatted like `p`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs