Compiler projects using llvm
REQUIRES: system-darwin

RUN: dsymutil --symbol-map %p/../Inputs/obfuscated.map %p/../Inputs/obfuscated.arm64 -f -o - \
RUN:     | llvm-dwarfdump -v - \
RUN:     | FileCheck %s

RUN: dsymutil --accelerator=Pub --symbol-map %p/../Inputs/obfuscated.map %p/../Inputs/obfuscated.arm64 -f -o - \
RUN:     | llvm-dwarfdump -v - \
RUN:     | FileCheck --check-prefix=PUB %s

RUN: dsymutil --symbol-map %p/../Inputs/obfuscated.map %p/../Inputs/obfuscated.arm64 -f -o - \
RUN:     | llvm-dwarfdump -v - \
RUN:     | FileCheck --check-prefix=NOHIDDEN %s

RUN: dsymutil --symbol-map %p/../Inputs/obfuscated.2.map %p/../Inputs/obfuscated.2.arm64 -f -o - \
RUN:     | llvm-dwarfdump -v - \
RUN:     | FileCheck --check-prefix=NOHIDDEN %s

// Run with plist and make sure dsymutil finds it.
RUN: mkdir -p %t.dSYM/Contents/Resources/DWARF/
RUN: mkdir -p %t.mapdir
RUN: cp %p/../Inputs/obfuscated.arm64 %t.dSYM/Contents/Resources/DWARF/
RUN: cp %p/../Inputs/E828A486-8433-3A5E-B6DB-A6294D28133D.plist %t.dSYM/Contents/Resources/
RUN: cp %p/../Inputs/obfuscated.map %t.mapdir/506AA50A-6B26-3B37-86D2-DC6EBD57B720.bcsymbolmap
RUN: dsymutil --symbol-map %t.mapdir %t.dSYM 2>&1 | FileCheck --check-prefix=OBFUSCATING %s

// Run without plist and make sure dsymutil doesn't crash.
RUN: rm %t.dSYM/Contents/Resources/E828A486-8433-3A5E-B6DB-A6294D28133D.plist
RUN: dsymutil --symbol-map %t.mapdir %t.dSYM 2>&1 | FileCheck --check-prefix=NOTOBFUSCATING %s

OBFUSCATING-NOT: not unobfuscating

NOTOBFUSCATING: not unobfuscating

NOHIDDEN-NOT: __hidden#

CHECK: .debug_info contents:

CHECK: DW_TAG_compile_unit [1] *
CHECK:    DW_AT_producer [DW_FORM_strp]    ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)")
CHECK:    DW_AT_name [DW_FORM_strp]        ( {{.*}} "main.c")
CHECK:    DW_AT_comp_dir [DW_FORM_strp]    ( {{.*}} "/Users/steven/dev/alpena/tests/src")
CHECK:    DW_TAG_subprogram [2]
CHECK:      DW_AT_name [DW_FORM_strp]      ( {{.*}} "main")

CHECK:  DW_TAG_compile_unit [1] *
CHECK:    DW_AT_producer [DW_FORM_strp]    ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)")
CHECK:    DW_AT_name [DW_FORM_strp]        ( {{.*}} "one.c")
CHECK:    DW_AT_comp_dir [DW_FORM_strp]    ( {{.*}} "/Users/steven/dev/alpena/tests/src")
CHECK:    DW_TAG_subprogram [2]
CHECK:      DW_AT_name [DW_FORM_strp]      ( {{.*}} "one")

CHECK:  DW_TAG_compile_unit [1] *
CHECK:    DW_AT_producer [DW_FORM_strp]    ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)")
CHECK:    DW_AT_name [DW_FORM_strp]        ( {{.*}} "two.c")
CHECK:    DW_AT_comp_dir [DW_FORM_strp]    ( {{.*}} "/Users/steven/dev/alpena/tests/src")
CHECK:    DW_TAG_subprogram [2]
CHECK:      DW_AT_name [DW_FORM_strp]      ( {{.*}} "two")

CHECK:  DW_TAG_compile_unit [1] *
CHECK:    DW_AT_producer [DW_FORM_strp]    ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)")
CHECK:    DW_AT_name [DW_FORM_strp]        ( {{.*}} "three.c")
CHECK:    DW_AT_comp_dir [DW_FORM_strp]    ( {{.*}} "/Users/steven/dev/alpena/tests/src")
CHECK:    DW_TAG_subprogram [2]
CHECK:      DW_AT_name [DW_FORM_strp]      ( {{.*}} "three")

CHECK:  DW_TAG_compile_unit [1] *
CHECK:    DW_AT_producer [DW_FORM_strp]    ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)")
CHECK:    DW_AT_name [DW_FORM_strp]        ( {{.*}} "four.c")
CHECK:    DW_AT_stmt_list [DW_FORM_data4]  (0x0000011e)
CHECK:    DW_AT_comp_dir [DW_FORM_strp]    ( {{.*}} "/Users/steven/dev/alpena/tests/src")
CHECK:    DW_TAG_subprogram [2]
CHECK:      DW_AT_name [DW_FORM_strp]      ( {{.*}} "four")

CHECK:  DW_TAG_compile_unit [1] *
CHECK:    DW_AT_producer [DW_FORM_strp]    ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)")
CHECK:    DW_AT_name [DW_FORM_strp]        ( {{.*}} "five.c")
CHECK:    DW_AT_comp_dir [DW_FORM_strp]    ( {{.*}} "/Users/steven/dev/alpena/tests/src")
CHECK:    DW_TAG_subprogram [2]
CHECK:      DW_AT_name [DW_FORM_strp]      ( {{.*}} "five")

CHECK:  DW_TAG_compile_unit [1] *
CHECK:    DW_AT_producer [DW_FORM_strp]    ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)")
CHECK:    DW_AT_name [DW_FORM_strp]        ( {{.*}} "six.c")
CHECK:    DW_AT_comp_dir [DW_FORM_strp]    ( {{.*}} "/Users/steven/dev/alpena/tests/src")
CHECK:    DW_TAG_subprogram [2]
CHECK:      DW_AT_name [DW_FORM_strp]      ( {{.*}} "six")

CHECK: .debug_line contents:
CHECK: file_names[  1]:
CHECK:            name: "main.c"
CHECK:       dir_index: 0
CHECK:        mod_time: 0x00000000
CHECK: file_names[  1]:
CHECK:            name: "one.c"
CHECK:       dir_index: 0
CHECK:        mod_time: 0x00000000
CHECK:          length: 0x00000000
CHECK: file_names[  1]:
CHECK:            name: "two.c"
CHECK:       dir_index: 0
CHECK:        mod_time: 0x00000000
CHECK:          length: 0x00000000
CHECK: file_names[  1]:
CHECK:            name: "three.c"
CHECK:       dir_index: 0
CHECK:        mod_time: 0x00000000
CHECK:          length: 0x00000000
CHECK: file_names[  1]:
CHECK:            name: "four.c"
CHECK:       dir_index: 0
CHECK:        mod_time: 0x00000000
CHECK:          length: 0x00000000
CHECK: file_names[  1]:
CHECK:            name: "five.c"
CHECK:       dir_index: 0
CHECK:        mod_time: 0x00000000
CHECK:          length: 0x00000000
CHECK: file_names[  1]:
CHECK:            name: "six.c"
CHECK:       dir_index: 0
CHECK:        mod_time: 0x00000000
CHECK:          length: 0x00000000

PUB: .debug_pubnames contents:
PUB: length = 0x00000017, format = DWARF32, version = 0x0002, unit_offset = 0x00000000, unit_size = 0x00000044
PUB: 0x0000002e "main"
PUB: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000044, unit_size = 0x00000044
PUB: 0x0000002e "one"
PUB: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000088, unit_size = 0x00000044
PUB: 0x0000002e "two"
PUB: length = 0x00000018, format = DWARF32, version = 0x0002, unit_offset = 0x000000cc, unit_size = 0x00000044
PUB: 0x0000002e "three"
PUB: length = 0x00000017, format = DWARF32, version = 0x0002, unit_offset = 0x00000110, unit_size = 0x00000044
PUB: 0x0000002e "four"
PUB: length = 0x00000017, format = DWARF32, version = 0x0002, unit_offset = 0x00000154, unit_size = 0x00000044
PUB: 0x0000002e "five"
PUB: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000198, unit_size = 0x00000044
PUB: 0x0000002e "six"

CHECK: .apple_names contents:

CHECK: String: 0x00000091 "five"
CHECK-NEXT: Data 0 [
CHECK-NEXT:   Atom[0]: 0x00000182
CHECK-NEXT: ]
CHECK: String: 0x0000009c "six"
CHECK-NEXT: Data 0 [
CHECK-NEXT:   Atom[0]: 0x000001c6
CHECK-NEXT: ]
CHECK: String: 0x00000078 "three"
CHECK-NEXT: Data 0 [
CHECK-NEXT:   Atom[0]: 0x000000fa
CHECK-NEXT: ]
CHECK: String: 0x0000006c "two"
CHECK-NEXT: Data 0 [
CHECK-NEXT:   Atom[0]: 0x000000b6
CHECK-NEXT: ]
CHECK: String: 0x00000057 "main"
CHECK-NEXT: Data 0 [
CHECK-NEXT:   Atom[0]: 0x0000002e
CHECK-NEXT: ]
CHECK: String: 0x00000085 "four"
CHECK-NEXT: Data 0 [
CHECK-NEXT:   Atom[0]: 0x0000013e
CHECK-NEXT: ]
CHECK: String: 0x00000062 "one"
CHECK-NEXT: Data 0 [
CHECK-NEXT:   Atom[0]: 0x00000072
CHECK-NEXT: ]