1 # RUN: yaml2obj %s -o %t.dSYM
3 ## Verify that we don't keep merged functions by default
4 # RUN: llvm-gsymutil --convert %t.dSYM --out-file=%t.default.gSYM
5 # RUN: llvm-gsymutil --verify --verbose %t.default.gSYM | FileCheck --check-prefix=CHECK-GSYM-DEFAULT %s
7 ## Verify that we keep merged functions when specyfing --merged-functions
8 # RUN: llvm-gsymutil --convert %t.dSYM --out-file=%t.keep.gSYM --merged-functions
9 # RUN: llvm-gsymutil --verify --verbose %t.keep.gSYM | FileCheck --check-prefix=CHECK-GSYM-KEEP %s
11 ## Note: For identical functions, the dSYM / gSYM cannot be counted on to be deterministic.
12 ## So we can only match the general structure, not exact function names / offsets
15 # CHECK-GSYM-DEFAULT-NOT: Merged FunctionInfos
16 # CHECK-GSYM-DEFAULT: FunctionInfo @ 0x{{[0-9a-fA-F]+}}: [0x{{[0-9a-fA-F]+}} - 0x{{[0-9a-fA-F]+}}) "my_func_0{{[1-3]}}"
19 # CHECK-GSYM-KEEP: Address Table:
20 # CHECK-GSYM-KEEP-NEXT: INDEX OFFSET16 (ADDRESS)
21 # CHECK-GSYM-KEEP-NEXT: ====== ===============================
22 # CHECK-GSYM-KEEP-NEXT: [ 0] 0x{{[0-9a-fA-F]+}}
24 # CHECK-GSYM-KEEP: Address Info Offsets:
25 # CHECK-GSYM-KEEP-NEXT: INDEX Offset
26 # CHECK-GSYM-KEEP-NEXT: ====== ==========
27 # CHECK-GSYM-KEEP-NEXT: [ 0] 0x{{[0-9a-fA-F]+}}
29 # CHECK-GSYM-KEEP: Files:
30 # CHECK-GSYM-KEEP-NEXT: INDEX DIRECTORY BASENAME PATH
31 # CHECK-GSYM-KEEP-NEXT: ====== ========== ========== ==============================
32 # CHECK-GSYM-KEEP-NEXT: [ 0] 0x{{[0-9a-fA-F]+}} 0x{{[0-9a-fA-F]+}}
33 # CHECK-GSYM-KEEP-NEXT: [ 1] 0x{{[0-9a-fA-F]+}} 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp
34 # CHECK-GSYM-KEEP-NEXT: [ 2] 0x{{[0-9a-fA-F]+}} 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp
35 # CHECK-GSYM-KEEP-NEXT: [ 3] 0x{{[0-9a-fA-F]+}} 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp
37 # CHECK-GSYM-KEEP: FunctionInfo @ 0x{{[0-9a-fA-F]+}}: [0x{{[0-9a-fA-F]+}} - 0x{{[0-9a-fA-F]+}}) "my_func_0{{[1-3]}}"
38 # CHECK-GSYM-KEEP-NEXT: LineTable:
39 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:5
40 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:7
41 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:9
42 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:8
43 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:11
44 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:10
45 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:6
46 # CHECK-GSYM-KEEP-NEXT: ++ Merged FunctionInfos[0]:
47 # CHECK-GSYM-KEEP-NEXT: [0x{{[0-9a-fA-F]+}} - 0x{{[0-9a-fA-F]+}}) "my_func_0{{[1-3]}}"
48 # CHECK-GSYM-KEEP-NEXT: LineTable:
49 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:5
50 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:7
51 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:9
52 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:8
53 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:11
54 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:10
55 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:6
56 # CHECK-GSYM-KEEP-NEXT: ++ Merged FunctionInfos[1]:
57 # CHECK-GSYM-KEEP-NEXT: [0x{{[0-9a-fA-F]+}} - 0x{{[0-9a-fA-F]+}}) "my_func_0{{[1-3]}}"
58 # CHECK-GSYM-KEEP-NEXT: LineTable:
59 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:5
60 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:7
61 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:9
62 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:8
63 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:11
64 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:10
65 # CHECK-GSYM-KEEP-NEXT: 0x{{[0-9a-fA-F]+}} /tmp/test_gsym_yaml{{[/\\]}}out/file_0{{[1-3]}}.cpp:6
82 uuid: 4C4C44EA-5555-3144-A15B-1DD428F7F3A2
83 - cmd: LC_BUILD_VERSION
119 content: CFFAEDFE0C000001000000000A000000060000009004000000000000000000001B00000018000000
143 - sectname: __debug_line
155 - sectname: __debug_aranges
167 - sectname: __debug_info
179 - sectname: __debug_frame
191 content: 14000000FFFFFFFF0400080001781E0C1F000000000000001C0000000000000048020000000000002800000000000000440E1000000000001C0000000000000048020000000000002800000000000000440E1000000000001C0000000000000048020000000000002800000000000000440E100000000000
192 - sectname: __debug_abbrev
204 - sectname: __debug_str
216 - sectname: __apple_namespac
228 content: 485341480100000001000000000000000C000000000000000100000001000600FFFFFFFF
229 - sectname: __apple_names
241 content: 485341480100000003000000030000000C00000000000000010000000100060000000000010000000200000038450B6E36450B6E37450B6E440000005400000064000000D200000001000000060100000000000094000000010000002E00000000000000B7000000010000009A00000000000000
242 - sectname: __apple_types
254 content: 48534148010000000100000001000000180000000000000004000000010006000300050005000B0006000600000000003080880B38000000A30000000300000064000000240000A4283A0CD0000000240000A4283A0C3C010000240000A4283A0C00000000
255 - sectname: __apple_objc
267 content: 485341480100000001000000000000000C000000000000000100000001000600FFFFFFFF
294 - 'clang version 20.0.0git (https://github.com/alx32/llvm-project.git cfb92be0a9cdd0f4595100c5add4e2795a44134e)'
297 - '/tmp/test_gsym_yaml'
310 Tag: DW_TAG_compile_unit
311 Children: DW_CHILDREN_yes
313 - Attribute: DW_AT_producer
315 - Attribute: DW_AT_language
317 - Attribute: DW_AT_name
319 - Attribute: DW_AT_LLVM_sysroot
321 - Attribute: DW_AT_stmt_list
322 Form: DW_FORM_sec_offset
323 - Attribute: DW_AT_comp_dir
325 - Attribute: DW_AT_low_pc
327 - Attribute: DW_AT_high_pc
330 Tag: DW_TAG_subprogram
331 Children: DW_CHILDREN_yes
333 - Attribute: DW_AT_low_pc
335 - Attribute: DW_AT_high_pc
337 - Attribute: DW_AT_APPLE_omit_frame_ptr
338 Form: DW_FORM_flag_present
339 - Attribute: DW_AT_frame_base
340 Form: DW_FORM_exprloc
341 - Attribute: DW_AT_name
343 - Attribute: DW_AT_decl_file
345 - Attribute: DW_AT_decl_line
347 - Attribute: DW_AT_type
348 Form: DW_FORM_ref_addr
349 - Attribute: DW_AT_external
350 Form: DW_FORM_flag_present
352 Tag: DW_TAG_formal_parameter
353 Children: DW_CHILDREN_no
355 - Attribute: DW_AT_location
356 Form: DW_FORM_exprloc
357 - Attribute: DW_AT_name
359 - Attribute: DW_AT_decl_file
361 - Attribute: DW_AT_decl_line
363 - Attribute: DW_AT_type
364 Form: DW_FORM_ref_addr
366 Tag: DW_TAG_base_type
367 Children: DW_CHILDREN_no
369 - Attribute: DW_AT_name
371 - Attribute: DW_AT_encoding
373 - Attribute: DW_AT_byte_size
429 BlockData: [ 0x91, 0xC ]
437 BlockData: [ 0x91, 0x8 ]
480 BlockData: [ 0x91, 0xC ]
488 BlockData: [ 0x91, 0x8 ]
531 BlockData: [ 0x91, 0xC ]
539 BlockData: [ 0x91, 0x8 ]
561 StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
570 - Opcode: DW_LNS_extended_op
572 SubOpcode: DW_LNE_set_address
576 - Opcode: DW_LNS_set_column
578 - Opcode: DW_LNS_set_prologue_end
590 - Opcode: DW_LNS_set_column
592 - Opcode: DW_LNS_set_epilogue_begin
596 - Opcode: DW_LNS_advance_pc
598 - Opcode: DW_LNS_extended_op
600 SubOpcode: DW_LNE_end_sequence
611 StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
620 - Opcode: DW_LNS_extended_op
622 SubOpcode: DW_LNE_set_address
626 - Opcode: DW_LNS_set_column
628 - Opcode: DW_LNS_set_prologue_end
640 - Opcode: DW_LNS_set_column
642 - Opcode: DW_LNS_set_epilogue_begin
646 - Opcode: DW_LNS_advance_pc
648 - Opcode: DW_LNS_extended_op
650 SubOpcode: DW_LNE_end_sequence
661 StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
670 - Opcode: DW_LNS_extended_op
672 SubOpcode: DW_LNE_set_address
676 - Opcode: DW_LNS_set_column
678 - Opcode: DW_LNS_set_prologue_end
690 - Opcode: DW_LNS_set_column
692 - Opcode: DW_LNS_set_epilogue_begin
696 - Opcode: DW_LNS_advance_pc
698 - Opcode: DW_LNS_extended_op
700 SubOpcode: DW_LNE_end_sequence
705 ###################################################################################
706 ############################# yaml generation script ##############################
709 # # Global variable for LLVM toolchain path
710 # TOOLCHAIN_PATH=[...]
711 # # Switch to the script directory
712 # cd "$(dirname "$0")"
713 # # Create and clean 'out' directory
716 # # Generate C++ files
717 # for i in {1..3}; do
718 # cat << EOF > out/file_0${i}.cpp
719 # extern "C" int my_func_0${i}(
732 # # Compile to object files with debug info
733 # for i in {1..3}; do
734 # ${TOOLCHAIN_PATH}/bin/clang++ \
735 # -fno-unwind-tables -fno-asynchronous-unwind-tables \
736 # -target arm64-apple-macos -c -g out/file_0${i}.cpp -o out/file_0${i}.o
738 # # Link object files to dylib using lld directly
739 # ${TOOLCHAIN_PATH}/bin/ld64.lld \
742 # -platform_version macos 11.0 11.0 \
743 # -o out/libmyfuncs.dylib \
744 # --icf=all --keep-icf-stabs \
745 # -o out/mydylib out/file_01.o out/file_02.o out/file_03.o
746 # # Create dsym with --flat option
747 # "$TOOLCHAIN_PATH/bin/dsymutil" --flat out/mydylib -o out/mydylib.dSYM
748 # # Convert dsym to yaml
749 # "$TOOLCHAIN_PATH/bin/obj2yaml" out/mydylib.dSYM > out/mydylib.yaml
750 ###################################################################################