diff options
| author | gingerBill <bill@gingerbill.org> | 2022-11-23 22:48:56 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-11-23 22:48:56 +0000 |
| commit | b7b9a016d31e5738014d5659e126aa2c581b9519 (patch) | |
| tree | 0ffcfbe60b2f5847293128ed430b8049f30f8b0f /src | |
| parent | 708a1b0cd3d05bfc64bad3803854dba824ebe3e4 (diff) | |
| parent | 5ac36b5f25435a495d8516d5c9df06c09d3ca20e (diff) | |
Merge branch 'master' into multiple-return-abi-experiment
Diffstat (limited to 'src')
| -rw-r--r-- | src/llvm_backend_debug.cpp | 59 |
1 files changed, 50 insertions, 9 deletions
diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp index 60978d321..65cefcd39 100644 --- a/src/llvm_backend_debug.cpp +++ b/src/llvm_backend_debug.cpp @@ -569,14 +569,43 @@ LLVMMetadataRef lb_debug_type(lbModule *m, Type *type) { case Type_Struct: case Type_Union: case Type_BitSet: - LLVMMetadataRef temp_forward_decl = LLVMDIBuilderCreateReplaceableCompositeType( - m->debug_builder, tag, name_text, name_len, nullptr, nullptr, 0, 0, size_in_bits, align_in_bits, flags, "", 0 - ); - idt.metadata = temp_forward_decl; + { + LLVMMetadataRef temp_forward_decl = LLVMDIBuilderCreateReplaceableCompositeType( + m->debug_builder, tag, name_text, name_len, nullptr, nullptr, 0, 0, size_in_bits, align_in_bits, flags, "", 0 + ); + idt.metadata = temp_forward_decl; + + array_add(&m->debug_incomplete_types, idt); + lb_set_llvm_metadata(m, type, temp_forward_decl); + + LLVMMetadataRef dummy = nullptr; + switch (bt->kind) { + case Type_Slice: + dummy = lb_debug_type(m, bt->Slice.elem); + dummy = lb_debug_type(m, alloc_type_pointer(bt->Slice.elem)); + dummy = lb_debug_type(m, t_int); + break; + case Type_DynamicArray: + dummy = lb_debug_type(m, bt->DynamicArray.elem); + dummy = lb_debug_type(m, alloc_type_pointer(bt->DynamicArray.elem)); + dummy = lb_debug_type(m, t_int); + dummy = lb_debug_type(m, t_allocator); + break; + case Type_Map: + dummy = lb_debug_type(m, bt->Map.key); + dummy = lb_debug_type(m, bt->Map.value); + dummy = lb_debug_type(m, t_int); + dummy = lb_debug_type(m, t_allocator); + dummy = lb_debug_type(m, t_uintptr); + break; + case Type_BitSet: + if (bt->BitSet.elem) dummy = lb_debug_type(m, bt->BitSet.elem); + if (bt->BitSet.underlying) dummy = lb_debug_type(m, bt->BitSet.underlying); + break; + } - array_add(&m->debug_incomplete_types, idt); - lb_set_llvm_metadata(m, type, temp_forward_decl); - return temp_forward_decl; + return temp_forward_decl; + } } } @@ -659,13 +688,25 @@ void lb_debug_complete_types(lbModule *m) { case Type_Slice: element_count = 2; elements = gb_alloc_array(temporary_allocator(), LLVMMetadataRef, element_count); - elements[0] = lb_debug_struct_field(m, str_lit("data"), alloc_type_pointer(bt->Slice.elem), 0*word_bits); + #if defined(GB_SYSTEM_WINDOWS) + elements[0] = lb_debug_struct_field(m, str_lit("data"), alloc_type_pointer(bt->Slice.elem), 0*word_bits); + #else + // FIX HACK TODO(bill): For some reason this causes a crash in *nix systems due to the reference counting + // of the debug type information + elements[0] = lb_debug_struct_field(m, str_lit("data"), t_rawptr, 0*word_bits); + #endif elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, 1*word_bits); break; case Type_DynamicArray: element_count = 4; elements = gb_alloc_array(temporary_allocator(), LLVMMetadataRef, element_count); - elements[0] = lb_debug_struct_field(m, str_lit("data"), alloc_type_pointer(bt->DynamicArray.elem), 0*word_bits); + #if defined(GB_SYSTEM_WINDOWS) + elements[0] = lb_debug_struct_field(m, str_lit("data"), alloc_type_pointer(bt->DynamicArray.elem), 0*word_bits); + #else + // FIX HACK TODO(bill): For some reason this causes a crash in *nix systems due to the reference counting + // of the debug type information + elements[0] = lb_debug_struct_field(m, str_lit("data"), t_rawptr, 0*word_bits); + #endif elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, 1*word_bits); elements[2] = lb_debug_struct_field(m, str_lit("cap"), t_int, 2*word_bits); elements[3] = lb_debug_struct_field(m, str_lit("allocator"), t_allocator, 3*word_bits); |