anza-xyz / move

Move compiler targeting llvm supported backends
https://discord.gg/wFgfjG9J
Apache License 2.0
109 stars 34 forks source link

Adding dwarf for struct #395

Closed jcivlin closed 9 months ago

jcivlin commented 10 months ago

expect

; ModuleID = '0x100__M.dbg_info'
source_filename = "/home/sol/work/git/move-100623/language/tools/move-mv-llvm-compiler/tests/dwarf-tests/dwarf-struct.move"

!llvm.dbg.cu = !{!0}
!struct.M__EmptyStruct = !{!2}
!struct.M__U64Struct = !{!8}
!struct.M__Combined = !{!14}
!struct.M__MyStruct = !{!20}

!0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, producer: "move-mv-llvm-compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, sysroot: "/")
!1 = !DIFile(filename: "dwarf-struct.move", directory: "/home/sol/work/git/move-100623/language/tools/move-mv-llvm-compiler/tests/dwarf-tests")
!2 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "struct.M__EmptyStruct__ptr", baseType: !3, size: 64, align: 64, dwarfAddressSpace: 0)
!3 = !DICompositeType(tag: DW_TAG_structure_type, name: "struct.M__EmptyStruct", scope: !4, file: !1, line: 10, size: 8, align: 8, flags: DIFlagObjcClassComplete, elements: !5)
!4 = !DINamespace(name: "struct.M__EmptyStruct", scope: !1)
!5 = !{!6}
!6 = !DIDerivedType(tag: DW_TAG_member, name: "dummy_field", scope: !4, file: !1, line: 10, baseType: !7, size: 1, align: 8)
!7 = !DIBasicType(name: "bool", size: 8)
!8 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "struct.M__U64Struct__ptr", baseType: !9, size: 64, align: 64, dwarfAddressSpace: 0)
!9 = !DICompositeType(tag: DW_TAG_structure_type, name: "struct.M__U64Struct", scope: !10, file: !1, line: 12, size: 64, align: 8, flags: DIFlagObjcClassComplete, elements: !11)
!10 = !DINamespace(name: "struct.M__U64Struct", scope: !1)
!11 = !{!12}
!12 = !DIDerivedType(tag: DW_TAG_member, name: "field_u64", scope: !10, file: !1, line: 12, baseType: !13, size: 64, align: 64)
!13 = !DIBasicType(name: "u64", size: 64)
!14 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "struct.M__Combined__ptr", baseType: !15, size: 64, align: 64, dwarfAddressSpace: 0)
!15 = !DICompositeType(tag: DW_TAG_structure_type, name: "struct.M__Combined", scope: !16, file: !1, line: 14, size: 128, align: 8, flags: DIFlagObjcClassComplete, elements: !17)
!16 = !DINamespace(name: "struct.M__Combined", scope: !1)
!17 = !{!18, !19}
!18 = !DIDerivedType(tag: DW_TAG_member, name: "field_combined_bool", scope: !16, file: !1, line: 14, baseType: !7, size: 1, align: 8)
!19 = !DIDerivedType(tag: DW_TAG_member, name: "field_combined_u64_struct", scope: !16, file: !1, line: 15, baseType: !9, size: 64, align: 64, offset: 8)
!20 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "struct.M__MyStruct__ptr", baseType: !21, size: 64, align: 64, dwarfAddressSpace: 0)
!21 = !DICompositeType(tag: DW_TAG_structure_type, name: "struct.M__MyStruct", scope: !22, file: !1, line: 2, size: 192, align: 8, flags: DIFlagObjcClassComplete, elements: !23)
!22 = !DINamespace(name: "struct.M__MyStruct", scope: !1)
!23 = !{!24, !26, !27, !28, !30}
!24 = !DIDerivedType(tag: DW_TAG_member, name: "field1_u32", scope: !22, file: !1, line: 2, baseType: !25, size: 32, align: 32)
!25 = !DIBasicType(name: "u32", size: 32)
!26 = !DIDerivedType(tag: DW_TAG_member, name: "field2_bool", scope: !22, file: !1, line: 3, baseType: !7, size: 1, align: 8, offset: 32)
!27 = !DIDerivedType(tag: DW_TAG_member, name: "field3_empty", scope: !22, file: !1, line: 4, baseType: !3, size: 8, align: 8, offset: 40)
!28 = !DIDerivedType(tag: DW_TAG_member, name: "field4_u8", scope: !22, file: !1, line: 5, baseType: !29, size: 8, align: 8, offset: 48)
!29 = !DIBasicType(name: "u8", size: 8)
!30 = !DIDerivedType(tag: DW_TAG_member, name: "field6_combined", scope: !22, file: !1, line: 6, baseType: !15, size: 128, align: 64, offset: 56)

Keep in mind for a struct with the fields defined (as struct) in another module it will not produce the correct type info. I'm working on this in the next PR.

dmakarov commented 10 months ago

Is this still a WIP? A suggestion: in the future instead of creating a PR with a title with a strange prefix WIP]], create a Draft Pull Request, then later change its status to the 'Ready for review', when it's ready for review. image

jcivlin commented 10 months ago

Is this still a WIP?

It is ready for review. Some things may change later when I add dwarf for struct with elements from other modules, but it will be in another PR.

jcivlin commented 9 months ago

Close due to #402