From f2c978fd4791b30b07059d056e5e6bdfa3d3454e Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Wed, 10 Apr 2024 11:06:52 -0600 Subject: [PATCH] Fix struct debug info --- bootstrap/backend/llvm.zig | 10 ++++++---- lib/std/std.nat | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bootstrap/backend/llvm.zig b/bootstrap/backend/llvm.zig index 092ea45..6f9233b 100644 --- a/bootstrap/backend/llvm.zig +++ b/bootstrap/backend/llvm.zig @@ -1521,17 +1521,19 @@ pub const LLVM = struct { .field_types = &.{}, .forward_declaration = null, }); + try llvm.debug_type_map.put_no_clobber(context.my_allocator, sema_type_index, struct_type.toType()); var field_types = try UnpinnedArray(*LLVM.DebugInfo.Type).initialize_with_capacity(context.my_allocator, @intCast(fields.len)); bit_size = 0; + for (fields) |struct_field_index| { const struct_field = unit.struct_fields.get(struct_field_index); const struct_field_type = unit.types.get(struct_field.type); const struct_field_bit_size = struct_field_type.getBitSize(unit); const field_type = try llvm.getDebugType(unit, context, struct_field.type); - //TODO: fix + const field_name = unit.getIdentifier(struct_field.name); const alignment = struct_field_bit_size; - const member_type = llvm.debug_info_builder.createMemberType(null, "", "".len, file, 0, struct_field_bit_size, alignment, bit_size, flags, field_type).toType(); + const member_type = llvm.debug_info_builder.createMemberType(null, field_name.ptr, field_name.len, file, 0, struct_field_bit_size, alignment, bit_size, flags, field_type).toType(); field_types.append_with_capacity(member_type); bit_size += struct_field_bit_size; } @@ -1756,8 +1758,8 @@ pub const LLVM = struct { const types = [2]*LLVM.DebugInfo.Type{ pointer_type, len_type }; const member_types = [2]*LLVM.DebugInfo.Type{ - llvm.debug_info_builder.createMemberType(null, "", "".len, null, 0, 64, 3, 0, flags, types[0]).toType(), - llvm.debug_info_builder.createMemberType(null, "", "".len, null, 0, 64, 3, 64, flags, types[1]).toType(), + llvm.debug_info_builder.createMemberType(null, "pointer", "pointer".len, null, 0, 64, 3, 0, flags, types[0]).toType(), + llvm.debug_info_builder.createMemberType(null, "length", "length".len, null, 0, 64, 3, 64, flags, types[1]).toType(), }; const struct_type = llvm.createDebugStructType(.{ .scope = scope, diff --git a/lib/std/std.nat b/lib/std/std.nat index 34a9267..23010cd 100644 --- a/lib/std/std.nat +++ b/lib/std/std.nat @@ -161,5 +161,3 @@ const Target = struct { os: builtin.Os, abi: builtin.Abi, }; - -var page_allocator = PageAllocator{};