New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debug info: f128 values do not display correctly in debuggers #2086
Comments
This bug also exists when using __float128 with gcc or clang, and this source file, compiled with -O0 -g, on amd64:
Sometimes lldb or gdb give both are incorrect |
That's good to know. In the original issue description, I assumed the gdb/clang output for So now we need to file an upstream bug against LLVM or maybe one against gdb. |
I did a quick review of the lldb source code. It seems like there is lack of support for float128: many switches don't even have a float128 case. |
This is not surprising. types in C are weird, because of legacy considerations. |
confirming this affects stage2 as well test {
var x = @bitCast(f128, @as(u128, 0x40042eab345678439abcdefea5678234));
@breakpoint();
_ = x;
}
|
did some digging:
!2368 = !DICompositeType(tag: DW_TAG_union_type, name: "z2.main__union_3484", size: 128, align: 128, elements: !2369)
!2369 = !{!2370, !2372, !2374}
!2370 = !DIDerivedType(tag: DW_TAG_member, name: "u", scope: !2368, baseType: !2371, size: 128, align: 64)
!2371 = !DIBasicType(name: "u128", size: 128, encoding: DW_ATE_unsigned)
!2372 = !DIDerivedType(tag: DW_TAG_member, name: "f", scope: !2368, baseType: !2373, size: 128, align: 128)
!2373 = !DIBasicType(name: "f128", size: 128, encoding: DW_ATE_float) on a potential hack would be for zig to emit *** a 2024-02-20 18:47:59.757925875 -0500
--- b 2024-02-20 18:48:15.887751324 -0500
***************
*** 1 ****
! !2373 = !DIBasicType(name: "f128", size: 128, encoding: DW_ATE_float)
--- 1 ----
! !2373 = !DIBasicType(name: "__float128", size: 128, encoding: DW_ATE_float) -- useful test sources... main.c#include <stdint.h>
int main(void) {
typedef union {
unsigned __int128 u;
__float128 f;
struct {
uint64_t lo;
uint64_t hi;
} aggregate;
} value;
value num;
num.aggregate.lo = 0x9abcdefea5678234;
num.aggregate.hi = 0x40042eab34567843;
char *p = 0;
*p = 0;
} main.zigpub fn main() void {
@setRuntimeSafety(false);
var value: union {
u: u128,
f: f128,
aggregate: struct {
lo: u64,
hi: u64,
},
} = undefined;
value.u = 0x40042eab345678439abcdefea5678234;
@breakpoint();
} debug sessions
|
Expected behavior:
Actual behavior:
Here's where the debug info for floats is set:
zig/src/codegen.cpp
Line 7106 in b5cc92f
The text was updated successfully, but these errors were encountered: