# RUN: yaml2obj %s -o %t.o # RUN: echo '---' > %t2.map # RUN: echo "triple: 'x86_64-apple-darwin'" >> %t2.map # RUN: echo 'objects:' >> %t2.map # RUN: echo " - filename: '%t.o'" >> %t2.map # RUN: echo ' symbols:' >> %t2.map # RUN: echo ' - { sym: __Z3foov, objAddr: 0x0, binAddr: 0x10000, size: 0x10 }' >> %t2.map # RUN: echo '...' >> %t2.map # RUN: dsymutil --linker classic -f -y %t2.map -o - | llvm-dwarfdump --debug-info - | FileCheck %s # RUN: dsymutil --linker parallel -f -y %t2.map -o - | llvm-dwarfdump --debug-info - | FileCheck --check-prefix=PARALLEL %s ## Test that dsymutil correctly resolves simple template names to types that use ## non-simple (fully qualified) template names. This simulates a situation where ## part of the program is compiled without -gsimple-template-names linking with ## code that does. ## ## CU1: defines MyTemplate and MyTemplate with full ## names in DW_AT_name. ## ## CU2: defines MyTemplate using a simple template name ## ("MyTemplate") with DW_TAG_template_type_parameter children. # CHECK: .debug_info contents: # CHECK: DW_TAG_compile_unit # CHECK-NOT: DW_TAG # CHECK: DW_AT_name{{.*}}"CU1" # CHECK: 0x[[TMPL_INT:[0-9a-f]*]]: DW_TAG_class_type # CHECK-NEXT: DW_AT_name{{.*}}"MyTemplate" # CHECK: 0x[[TMPL_FLOAT:[0-9a-f]*]]: DW_TAG_class_type # CHECK-NEXT: DW_AT_name{{.*}}"MyTemplate" # CHECK: DW_TAG_variable # CHECK: DW_AT_name{{.*}}"var1" # CHECK: DW_AT_type{{.*}}0x00000000[[TMPL_INT]] "MyTemplate" # CHECK: DW_TAG_variable # CHECK: DW_AT_name{{.*}}"var2" # CHECK: DW_AT_type{{.*}}0x00000000[[TMPL_FLOAT]] "MyTemplate" # CHECK: DW_TAG_compile_unit # CHECK-NOT: DW_TAG # CHECK: DW_AT_name{{.*}}"CU2" # CHECK: DW_TAG_variable # CHECK: DW_AT_name{{.*}}"var3" # CHECK: DW_AT_type{{.*}}0x00000000[[TMPL_FLOAT]] "MyTemplate" ## Parallel linker: types go to artificial type CU. The parallel linker does ## not currently unify across simple/non-simple template name representations. # PARALLEL: .debug_info contents: # PARALLEL: DW_TAG_compile_unit # PARALLEL: DW_AT_name{{.*}}"__artificial_type_unit" # PARALLEL: 0x[[TMPL_FLOAT_S:[0-9a-f]*]]: DW_TAG_class_type # PARALLEL: DW_AT_name{{.*}}"MyTemplate" # PARALLEL: DW_TAG_template_type_parameter # PARALLEL: DW_AT_type{{.*}}"float" # PARALLEL: 0x[[TMPL_FLOAT_F:[0-9a-f]*]]: DW_TAG_class_type # PARALLEL: DW_AT_name{{.*}}"MyTemplate" # PARALLEL: 0x[[TMPL_INT:[0-9a-f]*]]: DW_TAG_class_type # PARALLEL: DW_AT_name{{.*}}"MyTemplate" # PARALLEL: DW_TAG_compile_unit # PARALLEL: DW_AT_name{{.*}}"CU1" # PARALLEL: DW_TAG_variable # PARALLEL: DW_AT_name{{.*}}"var1" # PARALLEL: DW_AT_type{{.*}}0x00000000[[TMPL_INT]] # PARALLEL: DW_TAG_variable # PARALLEL: DW_AT_name{{.*}}"var2" # PARALLEL: DW_AT_type{{.*}}0x00000000[[TMPL_FLOAT_F]] # PARALLEL: DW_TAG_compile_unit # PARALLEL: DW_AT_name{{.*}}"CU2" # PARALLEL: DW_TAG_variable # PARALLEL: DW_AT_name{{.*}}"var3" # PARALLEL: DW_AT_type{{.*}}0x00000000[[TMPL_FLOAT_S]] ## ---- Mach-O + DWARF definition ---- ## ## CU1 debug_info layout (old compiler, no simple template names): ## 0x00: CU header (11 bytes) ## 0x0b: DW_TAG_compile_unit ## 0x1a: DW_TAG_class_type "MyTemplate" (no children) ## 0x2c: DW_TAG_class_type "MyTemplate" (no children) ## 0x40: DW_TAG_base_type "int" ## 0x45: DW_TAG_base_type "float" ## 0x4c: DW_TAG_subprogram "foo" (low_pc at section offset 0x51) ## 0x5d: DW_TAG_variable "var1" (type -> 0x1a) ## 0x6b: DW_TAG_variable "var2" (type -> 0x2c) ## 0x7b: end CU1 ## ## CU2 debug_info layout (new compiler, simple template names): ## 0x7b: CU header (11 bytes) ## 0x86: DW_TAG_compile_unit ## 0x95: DW_TAG_class_type "MyTemplate" (children: template param T -> float) ## 0xa2: DW_TAG_template_type_parameter (type -> 0xaf) ## 0xaa: DW_TAG_base_type "int" ## 0xaf: DW_TAG_base_type "float" ## 0xb6: DW_TAG_subprogram "foo" (low_pc at section offset 0xbb) ## 0xc7: DW_TAG_variable "var3" (type -> 0x95) ## 0xd7: end CU2 --- !mach-o FileHeader: magic: 0xFEEDFACF cputype: 0x01000007 cpusubtype: 0x00000003 filetype: 0x00000001 ncmds: 2 sizeofcmds: 376 flags: 0x00002000 reserved: 0x00000000 LoadCommands: - cmd: LC_SEGMENT_64 cmdsize: 232 segname: '' vmaddr: 0x00 vmsize: 0x300 fileoff: 0x300 filesize: 0x300 maxprot: 7 initprot: 7 nsects: 2 flags: 0 Sections: - sectname: __debug_abbrev segname: __DWARF addr: 0x000000000000000F size: 0x6d offset: 0x00000380 align: 0 reloff: 0x00000000 nreloc: 0 flags: 0x02000000 reserved1: 0x00000000 reserved2: 0x00000000 reserved3: 0x00000000 - sectname: __debug_info segname: __DWARF addr: 0x000000000000100 size: 0xD7 offset: 0x000003ED align: 0 reloff: 0x00000600 nreloc: 2 flags: 0x02000000 reserved1: 0x00000000 reserved2: 0x00000000 reserved3: 0x00000000 relocations: - address: 0x51 symbolnum: 0 pcrel: false length: 3 extern: true type: 0 scattered: false value: 0 - address: 0xBB symbolnum: 0 pcrel: false length: 3 extern: true type: 0 scattered: false value: 0 - cmd: LC_SYMTAB cmdsize: 24 symoff: 0x700 nsyms: 1 stroff: 0x710 strsize: 10 LinkEditData: NameList: - n_strx: 1 n_type: 0x0F n_sect: 1 n_desc: 0 n_value: 0 StringTable: - '' - '__Z3foov' - '' DWARF: debug_abbrev: - Table: ## CU1 abbreviations (old compiler, no template parameter children) - Tag: DW_TAG_compile_unit Children: DW_CHILDREN_yes Attributes: - Attribute: DW_AT_producer Form: DW_FORM_string - Attribute: DW_AT_language Form: DW_FORM_data2 - Attribute: DW_AT_name Form: DW_FORM_string - Tag: DW_TAG_class_type Children: DW_CHILDREN_no Attributes: - Attribute: DW_AT_name Form: DW_FORM_string - Attribute: DW_AT_byte_size Form: DW_FORM_data1 - Tag: DW_TAG_base_type Children: DW_CHILDREN_no Attributes: - Attribute: DW_AT_name Form: DW_FORM_string - Tag: DW_TAG_subprogram Children: DW_CHILDREN_yes Attributes: - Attribute: DW_AT_name Form: DW_FORM_string - Attribute: DW_AT_low_pc Form: DW_FORM_addr - Attribute: DW_AT_high_pc Form: DW_FORM_data4 - Tag: DW_TAG_variable Children: DW_CHILDREN_no Attributes: - Attribute: DW_AT_name Form: DW_FORM_string - Attribute: DW_AT_const_value Form: DW_FORM_data4 - Attribute: DW_AT_type Form: DW_FORM_ref_addr - Table: ## CU2 abbreviations (new compiler, simple template names) - Tag: DW_TAG_compile_unit Children: DW_CHILDREN_yes Attributes: - Attribute: DW_AT_producer Form: DW_FORM_string - Attribute: DW_AT_language Form: DW_FORM_data2 - Attribute: DW_AT_name Form: DW_FORM_string - Tag: DW_TAG_class_type Children: DW_CHILDREN_yes Attributes: - Attribute: DW_AT_name Form: DW_FORM_string - Attribute: DW_AT_byte_size Form: DW_FORM_data1 - Tag: DW_TAG_template_type_parameter Children: DW_CHILDREN_no Attributes: - Attribute: DW_AT_type Form: DW_FORM_ref_addr - Attribute: DW_AT_name Form: DW_FORM_string - Tag: DW_TAG_base_type Children: DW_CHILDREN_no Attributes: - Attribute: DW_AT_name Form: DW_FORM_string - Tag: DW_TAG_subprogram Children: DW_CHILDREN_yes Attributes: - Attribute: DW_AT_name Form: DW_FORM_string - Attribute: DW_AT_low_pc Form: DW_FORM_addr - Attribute: DW_AT_high_pc Form: DW_FORM_data4 - Tag: DW_TAG_variable Children: DW_CHILDREN_no Attributes: - Attribute: DW_AT_name Form: DW_FORM_string - Attribute: DW_AT_const_value Form: DW_FORM_data4 - Attribute: DW_AT_type Form: DW_FORM_ref_addr debug_info: - Version: 4 Entries: - AbbrCode: 1 Values: - CStr: by_hand - Value: 0x04 - CStr: CU1 ## 0x1a: MyTemplate (full name, no children) - AbbrCode: 2 Values: - CStr: "MyTemplate" - Value: 0x04 ## 0x2c: MyTemplate (full name, no children) - AbbrCode: 2 Values: - CStr: "MyTemplate" - Value: 0x04 ## 0x40: base types - AbbrCode: 3 Values: - CStr: int - AbbrCode: 3 Values: - CStr: float ## 0x4c: subprogram (low_pc at section offset 0x51) - AbbrCode: 4 Values: - CStr: foo - Value: 0x0000000000000000 - Value: 0x00000010 - AbbrCode: 5 Values: - CStr: var1 - Value: 0x00000000 - Value: 0x0000001a - AbbrCode: 5 Values: - CStr: var2 - Value: 0x00000000 - Value: 0x0000002c - AbbrCode: 0 - AbbrCode: 0 - Version: 4 Entries: - AbbrCode: 1 Values: - CStr: by_hand - Value: 0x04 - CStr: CU2 ## 0x95: MyTemplate (simple template name) - AbbrCode: 2 Values: - CStr: MyTemplate - Value: 0x04 - AbbrCode: 3 Values: - Value: 0x000000af - CStr: T - AbbrCode: 0 ## base types - AbbrCode: 4 Values: - CStr: int - AbbrCode: 4 Values: - CStr: float ## 0xb6: subprogram (low_pc at section offset 0xbb) - AbbrCode: 5 Values: - CStr: foo - Value: 0x0000000000000000 - Value: 0x00000010 - AbbrCode: 6 Values: - CStr: var3 - Value: 0x00000000 - Value: 0x00000095 - AbbrCode: 0 - AbbrCode: 0 ...