253 changes: 172 additions & 81 deletions llvm/test/tools/dsymutil/ARM/dwarf5-str-offsets-base-strx.test

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/ARM/empty-map.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# RUN: dsymutil -f -oso-prepend-path=%p/../Inputs -y %s -o - 2>&1 | FileCheck %s

# RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/../Inputs -y %s -o - 2>&1 | FileCheck %s

---
triple: 'thumbv7-apple-darwin'
...
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/tools/dsymutil/ARM/extern-alias.test
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ $ xcrun --sdk iphoneos clang private_extern.o main.o -target arm64-apple-ios14.0

RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/private_extern/private_extern.out -o %t.dSYM --verbose | FileCheck %s
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/extern/extern.out -o %t.dSYM --verbose | FileCheck %s

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/private_extern/private_extern.out -o %t.dSYM --verbose | FileCheck %s
RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/extern/extern.out -o %t.dSYM --verbose | FileCheck %s

CHECK-NOT: could not find object file symbol for symbol _baz
CHECK: { sym: _baz, objAddr: 0x0, binAddr: 0x100007F58, size: 0x0 }
CHECK: { sym: _foo, objAddr: 0x0, binAddr: 0x100007F58, size: 0x20 }
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/ARM/fat-arch-name.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# RUN: dsymutil -no-output %p/../Inputs/fat-test.arm.dylib -o /dev/null -verbose 2>&1 | FileCheck %s

# RUN: dsymutil --linker llvm -no-output %p/../Inputs/fat-test.arm.dylib -o /dev/null -verbose 2>&1 | FileCheck %s

# We detect thumb triples from the binaries, because those are the only ones
# that are guaranteed to be able to generate a Target instance (for example
# we would detect armv7m-apple-darwin as non-thumb triple, but you can't
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/ARM/fat-arch-not-found.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# RUN: dsymutil -f -oso-prepend-path=%p/../Inputs -y %s -o - 2>&1 | FileCheck %s
#
# RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/../Inputs -y %s -o - 2>&1 | FileCheck %s

---
triple: 'armv7-apple-darwin'
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/tools/dsymutil/ARM/inlined-low_pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ int bar(int a) { return foo(a); }

// RUN: dsymutil -f -y %p/dummy-debug-map-amr64.map -oso-prepend-path %p/../Inputs/inlined-low_pc -o - | llvm-dwarfdump - | FileCheck %s

// RUN: dsymutil --linker llvm -f -y %p/dummy-debug-map-amr64.map \
// RUN: -oso-prepend-path %p/../Inputs/inlined-low_pc -o - | \
// RUN: llvm-dwarfdump - | FileCheck %s

// CHECK: DW_TAG_subprogram
// CHECK: DW_AT_low_pc{{.*}}0x0000000000010000
// CHECK: DW_AT_name{{.*}}"bar"
Expand Down
5 changes: 5 additions & 0 deletions llvm/test/tools/dsymutil/ARM/preload.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ $ xcrun clang -o foo foo.o -g3 -Wl,-preload -nodefaultlibs
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/preload/foo -o %t.dSYM
RUN: llvm-nm %p/../Inputs/private/tmp/preload/foo | FileCheck %s
RUN: llvm-nm %t.dSYM/Contents/Resources/DWARF/foo | FileCheck %s

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/preload/foo -o %t.dSYM
RUN: llvm-nm %p/../Inputs/private/tmp/preload/foo | FileCheck %s
RUN: llvm-nm %t.dSYM/Contents/Resources/DWARF/foo | FileCheck %s

CHECK: start
8 changes: 7 additions & 1 deletion llvm/test/tools/dsymutil/ARM/scattered.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
RUN: dsymutil -y %p/dummy-debug-map.map -oso-prepend-path %p/../Inputs/scattered-reloc/ -f -o - | llvm-dwarfdump -debug-info - | FileCheck %s
RUN: dsymutil -y %p/dummy-debug-map.map -oso-prepend-path \
RUN: %p/../Inputs/scattered-reloc/ -f -o - | \
RUN: llvm-dwarfdump -debug-info - | FileCheck %s

RUN: dsymutil --linker llvm -y %p/dummy-debug-map.map \
RUN: -oso-prepend-path %p/../Inputs/scattered-reloc/ -f -o - \
RUN: | llvm-dwarfdump -debug-info - | FileCheck %s

// See Inputs/scattered-reloc/scattered.s to see how this test
// actually works.
Expand Down
5 changes: 5 additions & 0 deletions llvm/test/tools/dsymutil/ARM/thumb.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// RUN: dsymutil -f -oso-prepend-path=%p/.. %p/../Inputs/thumb.armv7m -o - | llvm-dwarfdump - | FileCheck %s
// RUN: dsymutil -arch armv7m -f -oso-prepend-path=%p/.. %p/../Inputs/thumb.armv7m -o - | llvm-dwarfdump - | FileCheck %s

// RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/.. \
// RUN: %p/../Inputs/thumb.armv7m -o - | llvm-dwarfdump - | FileCheck %s
// RUN: dsymutil --linker llvm -arch armv7m -f -oso-prepend-path=%p/.. \
// RUN: %p/../Inputs/thumb.armv7m -o - | llvm-dwarfdump - | FileCheck %s

/* Compile with:
clang -c thumb.c -arch armv7m -g
clang thumb.o -o thumb.armv7m -arch armv7m -nostdlib -static -Wl,-e,_start
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
RUN: rm -rf %t
RUN: mkdir -p %t/dsymdest
RUN: cat %p/../../Inputs/basic.macho.x86_64 > %t/basic.macho.x86_64

RUN: dsymutil --linker llvm -accelerator=Pub -oso-prepend-path=%p/../.. %t/basic.macho.x86_64

Check that the object file in the bundle exists and is sane:
RUN: llvm-dwarfdump -a %t/basic.macho.x86_64.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 | FileCheck %S/basic-linking-x86.test

Check that we don't create an empty Remarks directory if there are no remarks.
RUN: not ls %t/basic.macho.x86_64.dSYM/Contents/Resources/Remarks

Check that llvm-dwarfdump -a recognizes the bundle as a dSYM:
RUN: llvm-dwarfdump -a %t/basic.macho.x86_64.dSYM | FileCheck %S/basic-linking-x86.test

RUN: FileCheck %s --input-file %t/basic.macho.x86_64.dSYM/Contents/Info.plist

RUN: dsymutil --linker llvm -oso-prepend-path=%p/../.. %t/basic.macho.x86_64 -o %t/dsymdest/basic.macho.x86_64.dSYM
RUN: llvm-dwarfdump -a %t/dsymdest/basic.macho.x86_64.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 | FileCheck %S/basic-linking-x86.test
RUN: FileCheck %s --input-file %t/dsymdest/basic.macho.x86_64.dSYM/Contents/Info.plist

CHECK: <?xml version="1.0" encoding="UTF-8"?>
CHECK-NEXT: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
CHECK-NEXT: <plist version="1.0">
CHECK-NEXT: <dict>
CHECK-NEXT: <key>CFBundleDevelopmentRegion</key>
CHECK-NEXT: <string>English</string>
CHECK-NEXT: <key>CFBundleIdentifier</key>
CHECK-NEXT: <string>com.apple.xcode.dsym.basic.macho.x86_64</string>
CHECK-NEXT: <key>CFBundleInfoDictionaryVersion</key>
CHECK-NEXT: <string>6.0</string>
CHECK-NEXT: <key>CFBundlePackageType</key>
CHECK-NEXT: <string>dSYM</string>
CHECK-NEXT: <key>CFBundleSignature</key>
CHECK-NEXT: <string>????</string>
CHECK-NEXT: <key>CFBundleShortVersionString</key>
CHECK-NEXT: <string>1.0</string>
CHECK-NEXT: <key>CFBundleVersion</key>
CHECK-NEXT: <string>1</string>
CHECK-NEXT: </dict>
CHECK-NEXT: </plist>
Original file line number Diff line number Diff line change
@@ -1,4 +1,190 @@
RUN: cat %p/../../Inputs/basic.macho.x86_64 > %t1
RUN: dsymutil --linker llvm --no-output -accelerator=Pub -f -oso-prepend-path=%p/../.. %t1 2>&1 | FileCheck %s --allow-empty
RUN: dsymutil --linker llvm -accelerator=Pub -f -oso-prepend-path=%p/../.. %t1
RUN: llvm-dwarfdump -a %t1.dwarf | FileCheck %s
RUN: dsymutil --linker llvm -accelerator=Pub -f -o %t2 -oso-prepend-path=%p/../.. %p/../../Inputs/basic.macho.x86_64
RUN: llvm-dwarfdump -a %t2 | FileCheck %s
RUN: dsymutil --linker llvm -accelerator=Pub -f -o - -oso-prepend-path=%p/../.. %p/../../Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,BASIC
RUN: dsymutil --linker llvm -accelerator=Pub -f -o - -oso-prepend-path=%p/../.. %p/../../Inputs/basic-archive.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,ARCHIVE
RUN: dsymutil --linker llvm -accelerator=Pub -dump-debug-map -oso-prepend-path=%p/../.. %p/../../Inputs/basic.macho.x86_64 | dsymutil -accelerator=Pub -f -y -o - - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,BASIC
RUN: dsymutil --linker llvm -accelerator=Pub -dump-debug-map -oso-prepend-path=%p/../.. %p/../../Inputs/basic-archive.macho.x86_64 | dsymutil -accelerator=Pub -f -o - -y - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,ARCHIVE

#CHECK: LLVM parallel dwarflinker is not implemented yet.
CHECK: file format Mach-O 64-bit x86-64

CHECK: debug_info contents

CHECK: Compile Unit:

CHECK: DW_TAG_compile_unit
CHECK: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)")
CHECK: DW_AT_language (DW_LANG_C99)
CHECK: DW_AT_name ("basic1.c")
CHECK: DW_AT_stmt_list (0x00000000)
CHECK: DW_AT_comp_dir ("/Inputs")
CHECK: DW_AT_low_pc (0x0000000100000ea0)
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("main")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c")
CHECK: DW_AT_decl_line (23)
CHECK: DW_AT_prototyped (0x01)
CHECK: DW_AT_type (0x00000063
CHECK: DW_AT_external (0x01)
CHECK: DW_AT_accessibility (DW_ACCESS_public)
CHECK: DW_AT_low_pc (0x0000000100000ea0)
CHECK: DW_AT_high_pc (0x0000000100000ec4)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("argc")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c")
CHECK: DW_AT_decl_line (23)
CHECK: DW_AT_type (0x00000063
CHECK: DW_AT_location (DW_OP_fbreg -8)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("argv")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c")
CHECK: DW_AT_decl_line (23)
CHECK: DW_AT_type (0x0000006a
CHECK: DW_AT_location (DW_OP_fbreg -16)
CHECK: NULL
CHECK: DW_TAG_base_type
CHECK: DW_AT_name ("int")
CHECK: DW_AT_encoding (DW_ATE_signed)
CHECK: DW_AT_byte_size (0x04)
CHECK: DW_TAG_pointer_type
CHECK: DW_AT_type (0x0000006f
CHECK: DW_TAG_pointer_type
CHECK: DW_AT_type (0x00000074
CHECK: DW_TAG_const_type
CHECK: DW_AT_type (0x00000079
CHECK: DW_TAG_base_type
CHECK: DW_AT_name ("char")
CHECK: DW_AT_encoding (DW_ATE_signed_char)
CHECK: DW_AT_byte_size (0x01)
CHECK: NULL

CHECK: Compile Unit:

CHECK: DW_TAG_compile_unit
CHECK: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)")
CHECK: DW_AT_name ("basic2.c")
CHECK: DW_AT_stmt_list (0x0000003f)
CHECK: DW_AT_comp_dir ("/Inputs")
CHECK: DW_AT_low_pc (0x0000000100000ed0)
CHECK: DW_TAG_base_type
CHECK: DW_AT_name ("int")
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("private_int")
CHECK: DW_AT_type (0x000000a7
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c")
BASIC: DW_AT_location (DW_OP_addr 0x100001008)
ARCHIVE: DW_AT_location (DW_OP_addr 0x100001004)
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("baz")
CHECK: DW_AT_type (0x000000a7
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c")
CHECK: DW_AT_location (DW_OP_addr 0x100001000)
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("foo")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c")
CHECK: DW_AT_type (0x000000a7
CHECK: DW_AT_low_pc (0x0000000100000ed0)
CHECK: DW_AT_high_pc (0x0000000100000f19)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("arg")
CHECK: DW_AT_type (0x000000a7
CHECK: DW_AT_location (DW_OP_fbreg -4)
CHECK: NULL
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("inc")
CHECK: DW_AT_type (0x000000a7
CHECK: DW_AT_low_pc (0x0000000100000f20)
CHECK: DW_AT_high_pc (0x0000000100000f37)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: NULL

CHECK: Compile Unit:

CHECK: DW_TAG_compile_unit
CHECK: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)")
CHECK: DW_AT_name ("basic3.c")
CHECK: DW_AT_stmt_list (0x00000093)
CHECK: DW_AT_comp_dir ("/Inputs")
CHECK: DW_AT_low_pc (0x0000000100000f40)
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("val")
CHECK: DW_AT_type (0x00000162
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic3.c")
BASIC: DW_AT_location (DW_OP_addr 0x100001004)
ARCHIVE: DW_AT_location (DW_OP_addr 0x100001008)
CHECK: DW_TAG_volatile_type
CHECK: DW_AT_type (0x00000167
CHECK: DW_TAG_base_type
CHECK: DW_AT_name ("int")
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("bar")
CHECK: DW_AT_type (0x00000167
CHECK: DW_AT_low_pc (0x0000000100000f40)
CHECK: DW_AT_high_pc (0x0000000100000f84)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("arg")
CHECK: DW_AT_type (0x00000167
CHECK: DW_AT_location (DW_OP_fbreg -8)
CHECK: NULL
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("inc")
CHECK: DW_AT_type (0x00000167
CHECK: DW_AT_low_pc (0x0000000100000f90)
CHECK: DW_AT_high_pc (0x0000000100000fa9)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)

CHECK: NULL

CHECK-NOT: .debug_loc contents

CHECK:.debug_aranges contents:
CHECK-NEXT:Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00
CHECK-NEXT:[0x0000000100000ea0, 0x0000000100000ec4)
CHECK-NEXT:Address Range Header: length = 0x0000003c, format = DWARF32, version = 0x0002, cu_offset = 0x00000081, addr_size = 0x08, seg_size = 0x00
CHECK-NEXT:[0x0000000100000ed0, 0x0000000100000f19)
CHECK-NEXT:[0x0000000100000f20, 0x0000000100000f37)
CHECK-NEXT:Address Range Header: length = 0x0000003c, format = DWARF32, version = 0x0002, cu_offset = 0x00000126, addr_size = 0x08, seg_size = 0x00
CHECK-NEXT:[0x0000000100000f40, 0x0000000100000f84)
CHECK-NEXT:[0x0000000100000f90, 0x0000000100000fa9)

CHECK: .debug_line contents:
CHECK: file_names[ 1]:
CHECK-NEXT: name: "basic1.c"
CHECK-NEXT: dir_index: 0
CHECK: Address Line Column File ISA Discriminator OpIndex Flags
CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
CHECK-NEXT: 0x0000000100000ea0 23 0 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000eb6 24 0 1 0 0 0 is_stmt prologue_end
CHECK-NEXT: 0x0000000100000ec4 24 0 1 0 0 0 is_stmt end_sequence

CHECK: file_names[ 1]:
CHECK-NEXT: name: "basic2.c"
CHECK-NEXT: dir_index: 0
CHECK: Address Line Column File ISA Discriminator OpIndex Flags
CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
CHECK-NEXT: 0x0000000100000ed0 19 0 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000ee2 20 0 1 0 0 0 is_stmt prologue_end
CHECK-NEXT: 0x0000000100000f19 20 0 1 0 0 0 is_stmt end_sequence
CHECK-NEXT: 0x0000000100000f20 14 0 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000f24 15 0 1 0 0 0 is_stmt prologue_end
CHECK-NEXT: 0x0000000100000f37 15 0 1 0 0 0 is_stmt end_sequence

CHECK: file_names[ 1]:
CHECK-NEXT: name: "basic3.c"
CHECK-NEXT: dir_index: 0
CHECK: Address Line Column File ISA Discriminator OpIndex Flags
CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
CHECK-NEXT: 0x0000000100000f40 16 0 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000f4b 17 0 1 0 0 0 is_stmt prologue_end
CHECK-NEXT: 0x0000000100000f58 18 0 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000f6c 19 0 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000f7b 20 0 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000f84 20 0 1 0 0 0 is_stmt end_sequence
CHECK-NEXT: 0x0000000100000f90 11 0 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000f9b 12 0 1 0 0 0 is_stmt prologue_end
CHECK-NEXT: 0x0000000100000fa9 12 0 1 0 0 0 is_stmt end_sequence
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
RUN: dsymutil --linker llvm -f -o - -oso-prepend-path=%p/../.. %p/../../Inputs/basic-lto-dw4.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s

CHECK: file format Mach-O 64-bit x86-64

CHECK: debug_info contents

CHECK: Compile Unit: {{.*}} version = 0x0004
CHECK: DW_TAG_compile_unit
CHECK: DW_AT_producer ("clang version 3.7.0 ")
CHECK: DW_AT_language (DW_LANG_C99)
CHECK: DW_AT_name ("basic1.c")
CHECK: DW_AT_stmt_list (0x00000000)
CHECK: DW_AT_comp_dir ("/Inputs")
CHECK: DW_AT_low_pc (0x0000000100000f40)
CHECK: DW_AT_high_pc (0x0000000100000f4b)
CHECK: DW_TAG_subprogram
CHECK: DW_AT_low_pc (0x0000000100000f40)
CHECK: DW_AT_high_pc (0x0000000100000f4b)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_AT_name ("main")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c")
CHECK: DW_AT_prototyped (true)
CHECK: DW_AT_type (0x00000000000000a1
CHECK: DW_AT_external (true)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_location (DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_AT_name ("argc")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c")
CHECK: DW_AT_type (0x00000000000000a1
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_location (DW_OP_reg4 RSI)
CHECK: DW_AT_name ("argv")
CHECK: DW_AT_type (0x00000060
CHECK: NULL
CHECK: DW_TAG_pointer_type
CHECK: DW_AT_type (0x00000065
CHECK: DW_TAG_pointer_type
CHECK: DW_TAG_const_type
CHECK: DW_TAG_base_type
CHECK: DW_AT_name ("char")
CHECK: DW_AT_encoding (DW_ATE_signed_char)
CHECK: DW_AT_byte_size (0x01)
CHECK: NULL

CHECK: Compile Unit:{{.*}} version = 0x0004

CHECK: DW_TAG_compile_unit
CHECK: DW_AT_producer ("clang version 3.7.0 ")
CHECK: DW_AT_language (DW_LANG_C99)
CHECK: DW_AT_name ("basic2.c")
CHECK: DW_AT_stmt_list (0x00000044)
CHECK: DW_AT_low_pc (0x0000000100000f50)
CHECK: DW_AT_high_pc (0x0000000100000f87)
CHECK: DW_TAG_base_type
CHECK: DW_AT_name ("int")
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("baz")
CHECK: DW_AT_location (DW_OP_addr 0x100001000)
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("private_int")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c")
CHECK: DW_AT_location (DW_OP_addr 0x100001008)
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("inc")
CHECK: DW_AT_type (0x000000a1
CHECK: DW_AT_inline (DW_INL_inlined)
CHECK: DW_TAG_subprogram
CHECK: DW_AT_low_pc (0x0000000100000f50)
CHECK: DW_AT_high_pc (0x0000000100000f87)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_AT_name ("foo")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c")
CHECK: DW_AT_prototyped (true)
CHECK: DW_AT_type (0x000000a1
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_location (0x00000000
CHECK: [0x0000000100000f50, 0x0000000100000f5c): DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_AT_name ("arg")
CHECK: DW_AT_type (0x000000a1
CHECK: DW_TAG_inlined_subroutine
CHECK: DW_AT_abstract_origin (0x000000d2 "inc")
CHECK: DW_AT_low_pc (0x0000000100000f61)
CHECK: DW_AT_high_pc (0x0000000100000f70)
CHECK: NULL
CHECK: NULL

CHECK: Compile Unit: {{.*}} version = 0x0004

CHECK: DW_TAG_compile_unit
CHECK: DW_AT_producer ("clang version 3.7.0 ")
CHECK: DW_AT_name ("basic3.c")
CHECK: DW_AT_stmt_list (0x0000009a)
CHECK: DW_AT_low_pc (0x0000000100000f90)
CHECK: DW_AT_high_pc (0x0000000100000fb4)
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("val")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic3.c")
CHECK: DW_AT_location (DW_OP_addr 0x100001004)
CHECK: DW_TAG_volatile_type
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("inc")
CHECK: DW_AT_inline (DW_INL_inlined)
CHECK: DW_TAG_subprogram
CHECK: DW_AT_low_pc (0x0000000100000f90)
CHECK: DW_AT_high_pc (0x0000000100000fb4)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_AT_name ("bar")
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_location (0x00000025
CHECK: [0x0000000100000f90, 0x0000000100000f9f): DW_OP_reg5 RDI, DW_OP_piece 0x4
CHECK: [0x0000000100000fa9, 0x0000000100000fad): DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_AT_name ("arg")
CHECK: DW_TAG_inlined_subroutine
CHECK: DW_AT_abstract_origin (0x0000015f "inc")
CHECK: DW_AT_ranges (0x00000000
CHECK: [0x0000000100000f94, 0x0000000100000f9a)
CHECK: [0x0000000100000f9f, 0x0000000100000fa7))

CHECK: NULL
CHECK: NULL


CHECK: .debug_loc contents:
CHECK-NEXT: 0x00000000:
CHECK-NEXT: (0x0000000000000000, 0x000000000000000c): DW_OP_reg5 RDI, DW_OP_piece 0x4
CHECK-NOT: :
CHECK: 0x00000025:
CHECK-NEXT: (0x0000000000000000, 0x000000000000000f): DW_OP_reg5 RDI, DW_OP_piece 0x4
CHECK-NEXT: (0x0000000000000019, 0x000000000000001d): DW_OP_reg5 RDI, DW_OP_piece 0x4


CHECK: .debug_aranges contents:
CHECK-NEXT: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00
CHECK-NEXT: [0x0000000100000f40, 0x0000000100000f4b)
CHECK-NEXT: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000077, addr_size = 0x08, seg_size = 0x00
CHECK-NEXT: [0x0000000100000f50, 0x0000000100000f87)
CHECK-NEXT: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x0000011b, addr_size = 0x08, seg_size = 0x00
CHECK-NEXT: [0x0000000100000f90, 0x0000000100000fb4)

CHECK: .debug_line contents:
CHECK: file_names[ 1]:
CHECK-NEXT: name: "basic1.c"
CHECK-NEXT: dir_index: 0
CHECK: Address Line Column File ISA Discriminator OpIndex Flags
CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
CHECK-NEXT: 0x0000000100000f40 26 0 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000f44 27 10 1 0 0 0 is_stmt prologue_end
CHECK-NEXT: 0x0000000100000f49 27 3 1 0 0 0
CHECK-NEXT: 0x0000000100000f4b 27 3 1 0 0 0 end_sequence

CHECK: file_names[ 1]:
CHECK-NEXT: name: "basic2.c"
CHECK-NEXT: dir_index: 0
CHECK: Address Line Column File ISA Discriminator OpIndex Flags
CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
CHECK-NEXT: 0x0000000100000f50 19 0 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000f54 20 18 1 0 0 0 is_stmt prologue_end
CHECK-NEXT: 0x0000000100000f5a 20 17 1 0 0 0
CHECK-NEXT: 0x0000000100000f5c 20 10 1 0 0 0
CHECK-NEXT: 0x0000000100000f61 15 10 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000f70 20 23 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000f74 20 36 1 0 0 0
CHECK-NEXT: 0x0000000100000f83 20 31 1 0 0 0
CHECK-NEXT: 0x0000000100000f85 20 3 1 0 0 0
CHECK-NEXT: 0x0000000100000f87 20 3 1 0 0 0 end_sequence

CHECK: file_names[ 1]:
CHECK-NEXT: name: "basic3.c"
CHECK-NEXT: dir_index: 0
CHECK: Address Line Column File ISA Discriminator OpIndex Flags
CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
CHECK-NEXT: 0x0000000100000f90 16 0 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000f94 12 10 1 0 0 0 is_stmt prologue_end
CHECK-NEXT: 0x0000000100000f9a 17 7 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000f9f 12 10 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000fa7 20 1 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000fa9 19 18 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000fab 19 10 1 0 0 0
CHECK-NEXT: 0x0000000100000fb2 20 1 1 0 0 0 is_stmt
CHECK-NEXT: 0x0000000100000fb4 20 1 1 0 0 0 is_stmt end_sequence

CHECK-NOT: .debug_pubnames contents:
CHECK-NOT: .debug_pubtypes contents:
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
RUN: dsymutil --linker llvm -f -o - -oso-prepend-path=%p/../.. %p/../../Inputs/basic-lto.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s
RUN: dsymutil --linker llvm -oso-prepend-path=%p/../.. -dump-debug-map %p/../../Inputs/basic-lto.macho.x86_64 | dsymutil -f -o - -y - | llvm-dwarfdump -a - | FileCheck %s

CHECK: file format Mach-O 64-bit x86-64

CHECK: debug_info contents

CHECK: Compile Unit:

CHECK: DW_TAG_compile_unit
CHECK: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)")
CHECK: DW_AT_language (DW_LANG_C99)
CHECK: DW_AT_name ("basic1.c")
CHECK: DW_AT_stmt_list (0x00000000)
CHECK: DW_AT_comp_dir ("/Inputs")
CHECK: DW_AT_low_pc (0x0000000100000f40)
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("main")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c")
CHECK: DW_AT_decl_line (23)
CHECK: DW_AT_prototyped (0x01)
CHECK: DW_AT_type (0x00000063
CHECK: DW_AT_external (0x01)
CHECK: DW_AT_accessibility (DW_ACCESS_public)
CHECK: DW_AT_low_pc (0x0000000100000f40)
CHECK: DW_AT_high_pc (0x0000000100000f4b)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("argc")
CHECK: DW_AT_type (0x00000063
CHECK: DW_AT_location (DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("argv")
CHECK: DW_AT_type (0x0000006a
CHECK: DW_AT_location (DW_OP_reg4 RSI)
CHECK: NULL
CHECK: DW_TAG_base_type
CHECK: DW_AT_name ("int")
CHECK: DW_AT_encoding (DW_ATE_signed)
CHECK: DW_AT_byte_size (0x04)
CHECK: DW_TAG_pointer_type
CHECK: DW_AT_type (0x0000006f
CHECK: DW_TAG_pointer_type
CHECK: DW_AT_type (0x00000074
CHECK: DW_TAG_const_type
CHECK: DW_AT_type (0x00000079
CHECK: DW_TAG_base_type
CHECK: DW_AT_name ("char")
CHECK: DW_AT_encoding (DW_ATE_signed_char)
CHECK: DW_AT_byte_size (0x01)
CHECK: NULL

CHECK: Compile Unit:

CHECK: DW_TAG_compile_unit
CHECK: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)")
CHECK: DW_AT_name ("basic2.c")
CHECK: DW_AT_stmt_list (0x0000003e)
CHECK: DW_AT_comp_dir ("/Inputs")
CHECK: DW_AT_low_pc (0x0000000100000f50)
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("private_int")
CHECK: DW_AT_type (0x0000000000000063
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c")
CHECK: DW_AT_location (DW_OP_addr 0x100001008)
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("baz")
CHECK: DW_AT_type (0x0000000000000063
CHECK: DW_AT_location (DW_OP_addr 0x100001000)
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("foo")
CHECK: DW_AT_type (0x0000000000000063
CHECK: DW_AT_low_pc (0x0000000100000f50)
CHECK: DW_AT_high_pc (0x0000000100000f89)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("arg")
CHECK: DW_AT_type (0x0000000000000063
CHECK: DW_AT_location (0x00000000
CHECK: [0x0000000100000f50, 0x0000000100000f5e): DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK:[[INC1:0x[0-9a-f]*]]{{.*}}DW_TAG_inlined_subroutine
CHECK: DW_AT_abstract_origin (0x00000128 "inc")
CHECK: DW_AT_low_pc (0x0000000100000f63)
CHECK: DW_AT_high_pc (0x0000000100000f72)
CHECK: DW_AT_call_line (20)
CHECK: NULL
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("inc")
CHECK: DW_AT_type (0x0000000000000063
CHECK: DW_AT_inline (DW_INL_inlined)
CHECK: NULL

CHECK: Compile Unit:

CHECK: DW_TAG_compile_unit
CHECK: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)")
CHECK: DW_AT_name ("basic3.c")
CHECK: DW_AT_stmt_list (0x0000007e)
CHECK: DW_AT_comp_dir ("/Inputs")
CHECK: DW_AT_low_pc (0x0000000100000f90)
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("val")
CHECK: DW_AT_type (0x00000176
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic3.c")
CHECK: DW_AT_location (DW_OP_addr 0x100001004)
CHECK: DW_TAG_volatile_type
CHECK: DW_AT_type (0x0000000000000063
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("bar")
CHECK: DW_AT_type (0x0000000000000063
CHECK: DW_AT_low_pc (0x0000000100000f90)
CHECK: DW_AT_high_pc (0x0000000100000fb4)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("arg")
CHECK: DW_AT_type (0x0000000000000063
CHECK: DW_AT_location (0x00000025
CHECK: [0x0000000100000f90, 0x0000000100000f9f): DW_OP_reg5 RDI, DW_OP_piece 0x4
CHECK: [0x0000000100000fa9, 0x0000000100000fad): DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_TAG_lexical_block
CHECK: DW_AT_low_pc (0x0000000100000f94)
CHECK: DW_AT_high_pc (0x0000000100000fa7)
CHECK:[[INC2:0x[0-9a-f]*]]{{.*}}DW_TAG_inlined_subroutine
CHECK: DW_AT_abstract_origin (0x000001d4 "inc")
CHECK: DW_AT_ranges (0x00000000
CHECK: [0x0000000100000f94, 0x0000000100000f9a)
CHECK: [0x0000000100000f9f, 0x0000000100000fa7))
CHECK: NULL
CHECK: NULL
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("inc")
CHECK: DW_AT_type (0x0000000000000063
CHECK: NULL

CHECK: .debug_loc contents:
CHECK-NEXT: 0x00000000:
CHECK-NEXT: (0x0000000000000000, 0x000000000000000e): DW_OP_reg5 RDI, DW_OP_piece 0x4
CHECK-NOT: :
CHECK: 0x00000025:
CHECK-NEXT: (0x0000000000000000, 0x000000000000000f): DW_OP_reg5 RDI, DW_OP_piece 0x4
CHECK-NEXT: (0x0000000000000019, 0x000000000000001d): DW_OP_reg5 RDI, DW_OP_piece 0x4

CHECK: .debug_aranges contents:
CHECK-NEXT: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00
CHECK-NEXT: [0x0000000100000f40, 0x0000000100000f4b)
CHECK-NEXT: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000081, addr_size = 0x08, seg_size = 0x00
CHECK-NEXT: [0x0000000100000f50, 0x0000000100000f89)
CHECK-NEXT: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x0000013a, addr_size = 0x08, seg_size = 0x00
CHECK-NEXT: [0x0000000100000f90, 0x0000000100000fb4)


CHECK: .debug_line contents
CHECK: file_names[ 1]:
CHECK-NEXT: name: "basic1.c"
CHECK-NEXT: dir_index: 0
CHECK: 0x0000000100000f40 23 0 1 0 0 0 is_stmt
CHECK: 0x0000000100000f44 24 0 1 0 0 0 is_stmt prologue_end
CHECK: 0x0000000100000f4b 24 0 1 0 0 0 is_stmt end_sequence

CHECK: file_names[ 1]:
CHECK-NEXT: name: "basic2.c"
CHECK-NEXT: dir_index: 0
CHECK: 0x0000000100000f50 19 0 1 0 0 0 is_stmt
CHECK: 0x0000000100000f54 20 0 1 0 0 0 is_stmt prologue_end
CHECK: 0x0000000100000f63 15 0 1 0 0 0 is_stmt
CHECK: 0x0000000100000f72 20 0 1 0 0 0 is_stmt
CHECK: 0x0000000100000f89 20 0 1 0 0 0 is_stmt end_sequence

CHECK: file_names[ 1]:
CHECK-NEXT: name: "basic3.c"
CHECK-NEXT: dir_index: 0
CHECK: 0x0000000100000f90 16 0 1 0 0 0 is_stmt
CHECK: 0x0000000100000f94 12 0 1 0 0 0 is_stmt prologue_end
CHECK: 0x0000000100000f9a 17 0 1 0 0 0 is_stmt
CHECK: 0x0000000100000f9f 12 0 1 0 0 0 is_stmt
CHECK: 0x0000000100000fa7 20 0 1 0 0 0 is_stmt
CHECK: 0x0000000100000fa9 19 0 1 0 0 0 is_stmt
CHECK: 0x0000000100000fb2 20 0 1 0 0 0 is_stmt
CHECK: 0x0000000100000fb4 20 0 1 0 0 0 is_stmt end_sequence

CHECK-NOT: .debug_pubnames contents:
CHECK-NOT: .debug_pubtypes contents:
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
RUN: cat %p/../../Inputs/basic-with-libfat-test.macho.x86_64 > %t1
RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/../.. %t1
RUN: llvm-dwarfdump %t1.dwarf | FileCheck %s

The test binary was created by force-linking the libfat-test.a fat archive
with the basic linking test archive, like so:
$ clang -all_load libfat-test.a libbasic.a basic1.macho.x86_64.o -Wl,-dead_strip -u _x86_64_var

CHECK: DW_AT_name{{.*}}"x86_64_var"
CHECK: DW_AT_name{{.*}}"basic2.c"
CHECK: DW_AT_name{{.*}}"basic3.c"
CHECK: DW_AT_name{{.*}}"basic1.c"
53 changes: 53 additions & 0 deletions llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/empty_range.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This test verifies that an empty range list in the .debug_ranges section
# doesn't crash dsymutil. As clang does not produce this kind of debug
# info anymore, we used this hand-crafted assembly file to produce a testcase
# Compile with:
# llvm-mc -triple x86_64-apple-darwin -filetype=obj -o 1.o empty_range.o

# RUN: dsymutil --linker llvm -f -y %p/../dummy-debug-map.map -oso-prepend-path %p/../../Inputs/empty_range -o - | llvm-dwarfdump -debug-info - | FileCheck %s

.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 11
.globl __Z3foov
.align 4, 0x90
__Z3foov: ## @_Z3foov
Lfunc_begin0:
pushq %rbp
movq %rsp, %rbp
popq %rbp
retq
Lfunc_end0:
.section __DWARF,__debug_abbrev,regular,debug
Lsection_abbrev:
.byte 1 ## Abbreviation Code
.byte 17 ## DW_TAG_compile_unit
.byte 1 ## DW_CHILDREN_yes
.byte 0 ## EOM(1)
.byte 0 ## EOM(2)
.byte 2 ## Abbreviation Code
.byte 46 ## DW_TAG_subprogram
.byte 0 ## DW_CHILDREN_no
.byte 17 ## DW_AT_low_pc
.byte 1 ## DW_FORM_addr
.byte 0x55 ## DW_AT_ranges
.byte 6 ## DW_FORM_data4
.byte 0 ## EOM(1)
.byte 0 ## EOM(2)
.byte 0 ## EOM(3)
.section __DWARF,__debug_info,regular,debug
Lsection_info:
.long 22 ## Length of Unit
.short 2 ## DWARF version number
.long 0 ## Offset Into Abbrev. Section
.byte 8 ## Address Size (in bytes)
.byte 1 ## Abbrev [1] DW_TAG_compile_unit
.byte 2 ## Abbrev [2] DW_TAG_subprogram
.quad Lfunc_begin0 ## DW_AT_low_pc
.long 0 ## DW_AT_ranges (pointing at an empty entry)
.byte 0 ## End Of Children Mark
.section __DWARF,__debug_ranges,regular,debug
Ldebug_range:
.long 0
.long 0

# CHECK-NOT: DW_TAG_compile_unit
36 changes: 36 additions & 0 deletions llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/frame-1.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# RUN: rm -rf %t
# RUN: mkdir -p %t
# RUN: llc -filetype=obj %p/../../Inputs/frame-dw2.ll -o %t/frame-dw2.o
# RUN: dsymutil --linker llvm -f -oso-prepend-path=%t -y %s -o - | \
# RUN: llvm-dwarfdump -debug-frame - | FileCheck %s

# This test is meant to verify that identical CIEs will get reused
# in the same file but not inbetween files. For this to happen, we
# link twice the same file using this made-up debug map:

---
triple: 'i386-apple-darwin'
objects:
- filename: frame-dw2.o
symbols:
- { sym: _bar, objAddr: 0x0, binAddr: 0x1000, size: 0x12 }
- { sym: _baz, objAddr: 0x0, binAddr: 0x2000, size: 0x12 }
- filename: frame-dw2.o
symbols:
- { sym: _bar, objAddr: 0x0, binAddr: 0x3000, size: 0x12 }
- { sym: _baz, objAddr: 0x0, binAddr: 0x4000, size: 0x12 }
...

# CHECK: .debug_frame contents:
# CHECK: 00000000 {{[0-9a-f]*}} ffffffff CIE
# CHECK-NOT: FDE
# CHECK: FDE cie=00000000 pc=00001000...00001
# CHECK-NOT: FDE
# CHECK: FDE cie=00000000 pc=00002000...00002
# CHECK: [[CIECU2:[0-9a-f]*]] {{[0-9a-f]*}} ffffffff CIE
# CHECK-NOT: FDE
# CHECK: FDE cie=[[CIECU2]] pc=00003000...00003
# CHECK-NOT: FDE
# CHECK: FDE cie=[[CIECU2]] pc=00004000...00004
# CHECK-NOT: FDE
# CHECK: .eh_frame contents:
46 changes: 46 additions & 0 deletions llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/frame-2.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# RUN: rm -rf %t
# RUN: mkdir -p %t
# RUN: llc -filetype=obj %p/../../Inputs/frame-dw2.ll -o %t/frame-dw2.o
# RUN: llc -filetype=obj %p/../../Inputs/frame-dw4.ll -o %t/frame-dw4.o
# RUN: dsymutil --linker llvm -f -oso-prepend-path=%t -y %s -o - | \
# RUN: llvm-dwarfdump -debug-frame - | FileCheck %s

# Check the handling of multiple different CIEs. To have CIEs that
# appear to be different, use a dwarf2 version of the file along with
# a dwarf 4 version. The CIE header version (and layout) will be different.
---
triple: 'i386-apple-darwin'
objects:
- filename: frame-dw2.o
symbols:
- { sym: _bar, objAddr: 0x0, binAddr: 0x1000, size: 0x12 }
- { sym: _baz, objAddr: 0x0, binAddr: 0x2000, size: 0x12 }
- filename: frame-dw4.o
symbols:
- { sym: _baz, objAddr: 0x0, binAddr: 0x3000, size: 0x12 }
- filename: frame-dw2.o
symbols:
- { sym: _bar, objAddr: 0x0, binAddr: 0x4000, size: 0x12 }
...

# CHECK: .debug_frame contents:
# CHECK: 00000000 {{[0-9a-f]*}} ffffffff CIE
# CHECK-NEXT: Format: DWARF32
# CHECK-NEXT: Version:{{.*}}1
# CHECK-NOT: FDE
# CHECK: FDE cie=00000000 pc=00001000...00001
# CHECK-NOT: FDE
# CHECK: FDE cie=00000000 pc=00002000...00002
# CHECK-NOT: FDE
# CHECK: [[CIEDW4:[0-9a-f]*]] 00000010 ffffffff CIE
# CHECK-NEXT: Format: DWARF32
# CHECK-NEXT: Version:{{.*}}4
# CHECK-NOT: FDE
# CHECK: FDE cie=[[CIEDW4]] pc=00003000...00003
# CHECK: [[CIEDW1_2:[0-9a-f]*]] 00000010 ffffffff CIE
# CHECK-NEXT: Format: DWARF32
# CHECK-NEXT: Version:{{.*}}1
# CHECK-NOT: FDE
# CHECK: FDE cie=[[CIEDW1_2]] pc=00004000...00004
# CHECK-NOT: FDE
# CHECK: .eh_frame contents:
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
RUN: rm -rf %t
RUN: mkdir -p %t

RUN: cat %p/../../Inputs/basic.macho.x86_64 > %t/basic.macho.x86_64
RUN: cat %p/../../Inputs/basic-archive.macho.x86_64 > %t/basic-archive.macho.x86_64
RUN: cat %p/../../Inputs/basic-lto.macho.x86_64 > %t/basic-lto.macho.x86_64
RUN: cat %p/../../Inputs/basic-lto-dw4.macho.x86_64 > %t/basic-lto-dw4.macho.x86_64

# Multiple inputs in flat mode
RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/../.. %t/basic.macho.x86_64 %t/basic-archive.macho.x86_64 %t/basic-lto.macho.x86_64 %t/basic-lto-dw4.macho.x86_64
RUN: llvm-dwarfdump -a %t/basic.macho.x86_64.dwarf \
RUN: | FileCheck %S/basic-linking-x86.test --check-prefixes=CHECK,BASIC
RUN: llvm-dwarfdump -a %t/basic-archive.macho.x86_64.dwarf \
RUN: | FileCheck %S/basic-linking-x86.test --check-prefixes=CHECK,ARCHIVE
RUN: llvm-dwarfdump -a %t/basic-lto.macho.x86_64.dwarf | FileCheck %S/basic-lto-linking-x86.test
RUN: llvm-dwarfdump -a %t/basic-lto-dw4.macho.x86_64.dwarf | FileCheck %S/basic-lto-dw4-linking-x86.test

# Multiple inputs that end up in the same named bundle
RUN: dsymutil --linker llvm -oso-prepend-path=%p/../.. %t/basic.macho.x86_64 %t/basic-archive.macho.x86_64 %t/basic-lto.macho.x86_64 %t/basic-lto-dw4.macho.x86_64 -o %t.dSYM
RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 \
RUN: | FileCheck %S/basic-linking-x86.test --check-prefixes=CHECK,BASIC
RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic-archive.macho.x86_64 \
RUN: | FileCheck %S/basic-linking-x86.test --check-prefixes=CHECK,ARCHIVE
RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic-lto.macho.x86_64 | FileCheck %S/basic-lto-linking-x86.test
RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic-lto-dw4.macho.x86_64 | FileCheck %S/basic-lto-dw4-linking-x86.test

# Multiple inputs in a named bundle in flat mode... impossible.
RUN: not dsymutil --linker llvm -f -oso-prepend-path=%p/../.. %t/basic.macho.x86_64 %t/basic-archive.macho.x86_64 %t/basic-lto.macho.x86_64 %t/basic-lto-dw4.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s

CHECK: error: cannot use -o with multiple inputs in flat mode
4 changes: 4 additions & 0 deletions llvm/test/tools/dsymutil/X86/alias.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/alias \
# RUN: %p/../Inputs/alias/foobar -o - | llvm-dwarfdump - 2>&1 | FileCheck %s

# RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/../Inputs/alias \
# RUN: %p/../Inputs/alias/foobar -o - | llvm-dwarfdump - 2>&1 | FileCheck %s

# CHECK-NOT: could not find object file symbol for symbol
# CHECK: DW_AT_name ("foo.c")
# CHECK: DW_AT_name ("bar.c")
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/tools/dsymutil/X86/call-site-entry-linking.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
RUN: dsymutil -oso-prepend-path=%p %p/Inputs/call-site-entry.macho.x86_64 -o %t.dSYM
RUN: llvm-dwarfdump %t.dSYM | FileCheck %s -implicit-check-not=DW_AT_call_return_pc

RUN: dsymutil --linker llvm -oso-prepend-path=%p %p/Inputs/call-site-entry.macho.x86_64 -o %t.dSYM
RUN: llvm-dwarfdump %t.dSYM | FileCheck %s -implicit-check-not=DW_AT_call_return_pc

CHECK: DW_AT_call_return_pc (0x0000000100000fa4)
3 changes: 3 additions & 0 deletions llvm/test/tools/dsymutil/X86/call-site-entry-reloc.test
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ twice.
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/call_return_pc/call -o %t.dSYM
RUN: llvm-dwarfdump %t.dSYM | FileCheck %s -implicit-check-not=DW_AT_call_return_pc

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/call_return_pc/call -o %t.dSYM
RUN: llvm-dwarfdump %t.dSYM | FileCheck %s -implicit-check-not=DW_AT_call_return_pc

CHECK: DW_AT_call_return_pc (0x0000000100000f72)
CHECK: DW_AT_call_return_pc (0x0000000100000f78)
3 changes: 3 additions & 0 deletions llvm/test/tools/dsymutil/X86/common-sym-multi.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/common/common.x86_64 -f -o - | llvm-dwarfdump -debug-info - | FileCheck %s
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/common/common.x86_64 -dump-debug-map | FileCheck %s --check-prefix DEBUGMAP

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/common/common.x86_64 -f -o - | llvm-dwarfdump -debug-info - | FileCheck %s
RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/common/common.x86_64 -dump-debug-map | FileCheck %s --check-prefix DEBUGMAP

The test was compiled from two source files:
$ cd /private/tmp/common
$ cat common1.c
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/common-sym.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
RUN: dsymutil -oso-prepend-path %p/.. %p/../Inputs/common.macho.x86_64 -f -o - | llvm-dwarfdump -v -debug-info - | FileCheck %s

RUN: dsymutil --linker llvm -oso-prepend-path %p/.. %p/../Inputs/common.macho.x86_64 -f -o - | llvm-dwarfdump -v -debug-info - | FileCheck %s

The test was compiled from a single source:
$ cat common.c
char common[16];
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/custom-line-table.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# RUN: dsymutil -oso-prepend-path %p/../Inputs -y %s -f -o - | llvm-dwarfdump - --debug-line | FileCheck %s
#
# RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs -y %s -f -o - | llvm-dwarfdump - --debug-line | FileCheck %s

# This test runs dsymutil on an object file with non-standard (as far
# as llvm is concerned) line table settings.
Expand Down
7 changes: 7 additions & 0 deletions llvm/test/tools/dsymutil/X86/darwin-bundle.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ RUN: FileCheck %s --input-file %t/dsymdest/basic.macho.x86_64.dSYM/Contents/Info
RUN: dsymutil -oso-prepend-path=%p/.. %t/basic.macho.x86_64 -toolchain "toolchain&and'some<symbols" -o %t/dsymdest/basic.macho.x86_64.dSYM
RUN: FileCheck %s --input-file %t/dsymdest/basic.macho.x86_64.dSYM/Contents/Info.plist --check-prefix=CHECK --check-prefix=TOOLCHAIN

RUN: dsymutil --linker llvm -oso-prepend-path=%p/.. %t/basic.macho.x86_64 -o %t/dsymdest/basic.macho.x86_64.dSYM
RUN: FileCheck %s --input-file %t/dsymdest/basic.macho.x86_64.dSYM/Contents/Info.plist

RUN: dsymutil --linker llvm -oso-prepend-path=%p/.. %t/basic.macho.x86_64 -toolchain "toolchain&and'some<symbols" -o %t/dsymdest/basic.macho.x86_64.dSYM
RUN: FileCheck %s --input-file %t/dsymdest/basic.macho.x86_64.dSYM/Contents/Info.plist --check-prefix=CHECK --check-prefix=TOOLCHAIN


CHECK: <?xml version="1.0" encoding="UTF-8"?>
CHECK-NEXT: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
CHECK-NEXT: <plist version="1.0">
Expand Down
5 changes: 5 additions & 0 deletions llvm/test/tools/dsymutil/X86/dead-stripped.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// RUN: dsymutil -f -y %p/dummy-debug-map.map -oso-prepend-path %p/../Inputs/dead-stripped -o - | llvm-dwarfdump - --debug-info | FileCheck %s --implicit-check-not "{{DW_AT_low_pc|DW_AT_high_pc|DW_AT_location|DW_TAG|NULL}}"

// RUN: dsymutil --linker llvm -f -y %p/dummy-debug-map.map -oso-prepend-path \
// RUN: %p/../Inputs/dead-stripped -o - | llvm-dwarfdump - --debug-info | \
// RUN: FileCheck %s --implicit-check-not \
// RUN: "{{DW_AT_low_pc|DW_AT_high_pc|DW_AT_location|DW_TAG|NULL}}"

// The test was compiled with:
// clang++ -O2 -g -c dead-strip.cpp -o 1.o

Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/debug-loc-base-addr.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/baseaddr/loc1.x86_64 -f -o - | llvm-dwarfdump --debug-info - | FileCheck %s

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/baseaddr/loc1.x86_64 -f -o - | llvm-dwarfdump --debug-info - | FileCheck %s

The test was compiled from a single source:
$ cat loc1.cpp
int f1(int i, int j) {
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/dwarf4-linetable.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/ -y %s -o - | llvm-dwarfdump -debug-line - | FileCheck %s

# RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/../Inputs/ -y %s -o - | llvm-dwarfdump -debug-line - | FileCheck %s

# Source:
# int main() {
# return 0;
Expand Down
11 changes: 11 additions & 0 deletions llvm/test/tools/dsymutil/X86/dwarf5-addrx.test
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ RUN: llvm-dwarfdump --verify %t.dSYM 2>&1 | FileCheck %s

RUN: llvm-dwarfdump --verbose %t.dSYM | FileCheck %s --check-prefix UPDATE-DWARF

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/dwarf5/dwarf5-addrx.out -o %t.dSYM 2>&1 | FileCheck %s --allow-empty
RUN: llvm-dwarfdump --verify %t.dSYM 2>&1 | FileCheck %s

RUN: llvm-dwarfdump --verbose %t.dSYM | FileCheck %s --check-prefix DWARF

RUN: dsymutil --linker llvm --update -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/dwarf5/dwarf5-addrx.out -o %t.dSYM 2>&1 | FileCheck %s --allow-empty
RUN: llvm-dwarfdump --verify %t.dSYM 2>&1 | FileCheck %s

RUN: llvm-dwarfdump --verbose %t.dSYM | FileCheck %s --check-prefix UPDATE-DWARF


CHECK-NOT: error:

DWARF: DW_TAG_compile_unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#RUN: dsymutil -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump %t.dSYM | FileCheck %s -implicit-check-not=DW_AT_call_return_pc

#RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump %t.dSYM | FileCheck %s -implicit-check-not=DW_AT_call_return_pc

#CHECK: DW_AT_call_return_pc (0x0000000100000f72)
#CHECK: DW_AT_call_return_pc (0x0000000100000f78)

Expand Down
8 changes: 8 additions & 0 deletions llvm/test/tools/dsymutil/X86/dwarf5-dw-op-addrx.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix UPD-DWARF-CHECK

#RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix DWARF-CHECK

#RUN: dsymutil --linker llvm --update -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix UPD-DWARF-CHECK

#CHECK: No errors.

#DWARF-CHECK: DW_TAG_compile_unit
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/dwarf5-linetable.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/ -y %s -o - | llvm-dwarfdump -debug-line -debug-line-str --verbose - | FileCheck %s

# RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/../Inputs/ -y %s -o - | llvm-dwarfdump -debug-line -debug-line-str --verbose - | FileCheck %s

# Source:
# int main() {
# return 0;
Expand Down
8 changes: 8 additions & 0 deletions llvm/test/tools/dsymutil/X86/dwarf5-loclists.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix UPD-DWARF-CHECK

#RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix DWARF-CHECK

#RUN: dsymutil --linker llvm --update -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix UPD-DWARF-CHECK

#CHECK: No errors.

#DWARF-CHECK: DW_TAG_formal_parameter
Expand Down
10 changes: 9 additions & 1 deletion llvm/test/tools/dsymutil/X86/dwarf5-rnglists.test
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,19 @@
#RUN: dsymutil -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix DWARF-CHECK
#

#RUN: dsymutil --update -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix UPD-DWARF-CHECK

#RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix DWARF-CHECK

#RUN: dsymutil --linker llvm --update -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix UPD-DWARF-CHECK

#CHECK: No errors.

#DWARF-CHECK: DW_TAG_compile_unit
Expand Down
5 changes: 5 additions & 0 deletions llvm/test/tools/dsymutil/X86/eh_frame.test
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@ RUN: llvm-dwarfdump --verify %t.dSYM
RUN: llvm-otool -s __TEXT __eh_frame %p/../Inputs/private/tmp/eh_frame/eh_frame.out | FileCheck %s
RUN: llvm-otool -s __TEXT __eh_frame %t.dSYM/Contents/Resources/DWARF/eh_frame.out | FileCheck %s

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/eh_frame/eh_frame.out -o %t.dSYM
RUN: llvm-dwarfdump --verify %t.dSYM
RUN: llvm-otool -s __TEXT __eh_frame %p/../Inputs/private/tmp/eh_frame/eh_frame.out | FileCheck %s
RUN: llvm-otool -s __TEXT __eh_frame %t.dSYM/Contents/Resources/DWARF/eh_frame.out | FileCheck %s

CHECK: 14 00 00 00 00 00 00 00 01 7a 52 00 01 78 10 01
CHECK: 10 0c 07 08 90 01 00 00
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/empty-CU.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
RUN: llvm-mc %p/../Inputs/empty-CU.s -filetype obj -triple x86_64-apple-darwin -o %t.o
RUN: dsymutil --update -f %t.o -o - | llvm-dwarfdump -v - -debug-info | FileCheck %s

RUN: dsymutil --linker llvm --update -f %t.o -o - | llvm-dwarfdump -v - -debug-info | FileCheck %s

CHECK: .debug_info contents:
CHECK: 0x00000000: Compile Unit: length = 0x00000008, format = DWARF32, version = 0x0003, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x0000000c)

Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/fat-archive-input-i386.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# RUN: dsymutil -f -oso-prepend-path=%p/../Inputs -y %s -o - | llvm-dwarfdump -debug-info - | FileCheck %s

# RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/../Inputs -y %s -o - | llvm-dwarfdump -debug-info - | FileCheck %s

---
triple: 'i386-apple-darwin'
objects:
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/fat-object-input-x86_64.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# RUN: dsymutil -f -oso-prepend-path=%p/../Inputs -y %s -o - | llvm-dwarfdump -debug-info - | FileCheck %s

# RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/../Inputs -y %s -o - | llvm-dwarfdump -debug-info - | FileCheck %s

---
triple: 'x86_64-apple-darwin'
objects:
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/fat-object-input-x86_64h.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# RUN: dsymutil -f -oso-prepend-path=%p/../Inputs -y %s -o - | llvm-dwarfdump -debug-info - | FileCheck %s

# RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/../Inputs -y %s -o - | llvm-dwarfdump -debug-info - | FileCheck %s

---
triple: 'x86_64h-apple-darwin'
objects:
Expand Down
10 changes: 7 additions & 3 deletions llvm/test/tools/dsymutil/X86/generate-empty-CU.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# RUN: dsymutil -f -o - -oso-prepend-path=%p/.. -y %s | llvm-dwarfdump -v - | FileCheck %s

# RUN: dsymutil --linker llvm -f -o - -oso-prepend-path=%p/.. -y %s | llvm-dwarfdump -v - | FileCheck %s

# This test on links the Dwarf for an LTO binary and on purpose doesn't retain
# any symbol in the second CU out of 3. To be valid DWARF ssymutil must not
# any symbol in the second CU out of 3. To be valid DWARF dsymutil must not
# generate an empty CU but omit it.

---
Expand All @@ -22,10 +24,12 @@ CHECK: DW_AT_name {{.*}} "basic1.c"
CHECK: DW_TAG_subprogram
DW_AT_name {{.*}} "main"

CHECK: 0x00000081: Compile Unit: length = 0x00000089, format = DWARF32, version = 0x0002, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x0000010e)
CHECK: 0x00000081: Compile Unit: length = 0x00000089, format = DWARF32, version = 0x0002, abbr_offset = 0x00{{00|53}}, addr_size = 0x08 (next unit at 0x0000010e)

CHECK: DW_TAG_compile_unit
CHECK: DW_AT_name {{.*}} "basic3.c"

CHECK: DW_TAG_subprogram [7] *
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name {{.*}} = "bar"

CHECK-NOT: DW_TAG_compile_unit
6 changes: 5 additions & 1 deletion llvm/test/tools/dsymutil/X86/global_downgraded_to_static.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// REQUIRES : system-darwin
// RUN: dsymutil -oso-prepend-path %p/.. -dump-debug-map %p/../Inputs/global_downgraded_to_static.x86_64 2>&1 | FileCheck %s
// RUN: dsymutil -oso-prepend-path %p/.. -dump-debug-map \
// RUN: %p/../Inputs/global_downgraded_to_static.x86_64 2>&1 | FileCheck %s
//
// RUN: dsymutil --linker llvm -oso-prepend-path %p/.. -dump-debug-map \
// RUN: %p/../Inputs/global_downgraded_to_static.x86_64 2>&1 | FileCheck %s
//
// To build:
// clang -g -c -DFILE1 global_downgraded_to_static.c -o 1.o
Expand Down
5 changes: 5 additions & 0 deletions llvm/test/tools/dsymutil/X86/inlined-static-variable.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// RUN: dsymutil -f -y %p/dummy-debug-map.map -oso-prepend-path %p/../Inputs/inlined-static-variable -o - | llvm-dwarfdump - | FileCheck %s --implicit-check-not "{{DW_AT_low_pc|DW_AT_high_pc|DW_AT_location|DW_TAG|NULL}}"

// RUN: dsymutil --linker llvm -f -y %p/dummy-debug-map.map -oso-prepend-path \
// RUN: %p/../Inputs/inlined-static-variable -o - | llvm-dwarfdump - | \
// RUN: FileCheck %s --implicit-check-not \
// RUN: "{{DW_AT_low_pc|DW_AT_high_pc|DW_AT_location|DW_TAG|NULL}}"

// clang -g -c inlined-static-variable.cpp -o 4.o

// The functions removed and not_removed are not in the debug map and are
Expand Down
5 changes: 5 additions & 0 deletions llvm/test/tools/dsymutil/X86/keep-func.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/keep_func/
RUN: llvm-dwarfdump %t.omit.dSYM | FileCheck %s --check-prefix OMIT
RUN: llvm-dwarfdump %t.keep.dSYM | FileCheck %s --check-prefix KEEP

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/keep_func/main.out -o %t.omit.dSYM
RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/keep_func/main.out -o %t.keep.dSYM -keep-function-for-static
RUN: llvm-dwarfdump %t.omit.dSYM | FileCheck %s --check-prefix OMIT
RUN: llvm-dwarfdump %t.keep.dSYM | FileCheck %s --check-prefix KEEP

KEEP: DW_AT_name ("MyDummyVar")
KEEP: DW_AT_name ("FOO_VAR_TYPE")
KEEP: DW_AT_name ("x1")
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/label.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# RUN: dsymutil -oso-prepend-path %p/../Inputs -y %s -f -o - | llvm-dwarfdump - --debug-info | FileCheck %s

# RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs -y %s -f -o - | llvm-dwarfdump - --debug-info | FileCheck %s

# Compile with:
# echo -e ".global _foo;\nfoo:\nnop" | clang -x assembler -g - -c -o /tmp/label.o

Expand Down
3 changes: 3 additions & 0 deletions llvm/test/tools/dsymutil/X86/label2.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ $ clang label.o -o label.out
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/label/label.out -o %t.dSYM
RUN: llvm-dwarfdump %t.dSYM | FileCheck %s

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/label/label.out -o %t.dSYM
RUN: llvm-dwarfdump %t.dSYM | FileCheck %s

CHECK: DW_TAG_label
CHECK-NEXT: DW_AT_name ("foobar")
CHECK-NEXT: DW_AT_decl_file ("/tmp/label{{[/\\]}}label.c")
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/tools/dsymutil/X86/lc_build_version.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# RUN: dsymutil -f %p/../Inputs/lc_build_version.x86_64 -o - \
# RUN: -oso-prepend-path=%p/.. | obj2yaml | FileCheck %s

# RUN: dsymutil --linker llvm -f %p/../Inputs/lc_build_version.x86_64 -o - \
# RUN: -oso-prepend-path=%p/.. | obj2yaml | FileCheck %s

CHECK: LoadCommands:
CHECK: - cmd: LC_BUILD_VERSION
CHECK-NEXT: cmdsize: 24
Expand Down
17 changes: 13 additions & 4 deletions llvm/test/tools/dsymutil/X86/location-expression.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# RUN: echo ' - { sym: __Z3foov, objAddr: 0x0, binAddr: 0x10000, size: 0x10 }' >> %t2.map
# RUN: echo '...' >> %t2.map
# RUN: dsymutil -y %t2.map -f -o - | llvm-dwarfdump -a --verbose - | FileCheck %s
# COM: dsymutil --linker llvm -y %t2.map -f -o - | llvm-dwarfdump -a --verbose - | FileCheck %s

# CHECK: file format Mach-O 64-bit x86-64
# CHECK: .debug_info contents:
Expand All @@ -20,11 +21,11 @@
# CHECK: 0x0000001b: DW_TAG_variable
# CHECK: DW_AT_name {{.*}}"var1"
# CHECK: DW_AT_type {{.*}}"class1"
# CHECK: DW_AT_location [DW_FORM_block1] (DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address)
# CHECK: DW_AT_location [DW_FORM_block1] (DW_OP_const8u 0x{{.*}}, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address)
# CHECK: 0x000000ab: DW_TAG_variable
# CHECK: DW_AT_name {{.*}}"var2"
# CHECK: DW_AT_type {{.*}}"class1"
# CHECK: DW_AT_location [DW_FORM_block] (DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address)
# CHECK: DW_AT_location [DW_FORM_block] (DW_OP_const8u 0x{{.*}}, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address, DW_OP_const8u 0x2000, DW_OP_form_tls_address)
# CHECK: 0x00000146: DW_TAG_variable
# CHECK: DW_AT_name {{.*}}"var3"
# CHECK: DW_AT_type {{.*}}"class1"
Expand Down Expand Up @@ -72,13 +73,21 @@ LoadCommands:
offset: 0x00000410
align: 0
reloff: 0x00000600
nreloc: 1
nreloc: 2
flags: 0x02000000
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
relocations:
- address: 0x1FC
- address: 0x30
symbolnum: 1
pcrel: true
length: 3
extern: true
type: 0
scattered: false
value: 0
- address: 0xc2
symbolnum: 1
pcrel: true
length: 3
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/mismatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// RUN: cp %p/../Inputs/mismatch/1.o %t.dir/2.o
// RUN: dsymutil --verbose -f -oso-prepend-path=%t.dir \
// RUN: -y %p/dummy-debug-map.map -o %t.bin 2>&1 | FileCheck %s
// RUN: dsymutil --linker llvm --verbose -f -oso-prepend-path=%t.dir \
// RUN: -y %p/dummy-debug-map.map -o %t.bin 2>&1 | FileCheck %s

@import mismatch;

Expand Down
3 changes: 3 additions & 0 deletions llvm/test/tools/dsymutil/X86/modules-dwarf-version.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// RUN: dsymutil -verify -f -oso-prepend-path=%t.dir \
// RUN: -y %p/dummy-debug-map.map -o - \
// RUN: | llvm-dwarfdump --debug-info - | FileCheck %s
// RUN: dsymutil --linker llvm -verify -f -oso-prepend-path=%t.dir \
// RUN: -y %p/dummy-debug-map.map -o - \
// RUN: | llvm-dwarfdump --debug-info - | FileCheck %s

@import Bar;
int main(int argc, char **argv) {
Expand Down
7 changes: 6 additions & 1 deletion llvm/test/tools/dsymutil/X86/modules-empty.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@

// RUN: rm -rf %t.dir
// RUN: mkdir %t.dir
// RUN: cp %p/../Inputs/modules-empty/1.o %p/../Inputs/modules-empty/Empty.pcm %t.dir
// RUN: cp %p/../Inputs/modules-empty/1.o %p/../Inputs/modules-empty/Empty.pcm \
// RUN: %t.dir
// RUN: dsymutil -f -oso-prepend-path=%t.dir \
// RUN: -verify \
// RUN: -y %p/dummy-debug-map.map -o - \
// RUN: | llvm-dwarfdump --debug-info - | FileCheck %s
// RUN: dsymutil --linker llvm -f -oso-prepend-path=%t.dir \
// RUN: -verify \
// RUN: -y %p/dummy-debug-map.map -o - \
// RUN: | llvm-dwarfdump --debug-info - | FileCheck %s

#include "Empty.h"
int main() {
Expand Down
1 change: 0 additions & 1 deletion llvm/test/tools/dsymutil/X86/multiple-inputs.test
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic-lto-dw4.macho.x86_
RUN: not dsymutil -f -oso-prepend-path=%p/.. %t/basic.macho.x86_64 %t/basic-archive.macho.x86_64 %t/basic-lto.macho.x86_64 %t/basic-lto-dw4.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s

CHECK: error: cannot use -o with multiple inputs in flat mode

5 changes: 5 additions & 0 deletions llvm/test/tools/dsymutil/X86/object-prefix-path.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ RUN: %p/dummy-debug-map.map -o %t \
RUN: -object-prefix-map=/ModuleCache=/ModuleCacheRenamed \
RUN: 2>&1 | FileCheck %s

RUN: dsymutil --linker llvm -verify -f -oso-prepend-path=%t.dir -y \
RUN: %p/dummy-debug-map.map -o %t \
RUN: -object-prefix-map=/ModuleCache=/ModuleCacheRenamed \
RUN: 2>&1 | FileCheck %s

CHECK: warning: {{.*}}Bar.pcm:
CHECK-NOT: warning: {{.*}}Foo.pcm:
10 changes: 9 additions & 1 deletion llvm/test/tools/dsymutil/X86/op-convert-offset.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/op-convert
RUN: llvm-dwarfdump %p/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o 2>&1 | FileCheck %s --check-prefix OBJ
RUN: llvm-dwarfdump %t.dSYM 2>&1 | FileCheck %s --check-prefix DSYM

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs \
RUN: %p/../Inputs/private/tmp/op-convert-offset/op-convert-offset \
RUN: -o %t.dSYM 2>&1
RUN: llvm-dwarfdump \
RUN: %p/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o 2>&1 \
RUN: | FileCheck %s --check-prefix OBJ
RUN: llvm-dwarfdump %t.dSYM 2>&1 | FileCheck %s --check-prefix DSYM

OBJ: 0x0000007d: DW_TAG_base_type
OBJ: DW_AT_name ("DW_ATE_unsigned_1")
OBJ: DW_AT_encoding (DW_ATE_unsigned)
Expand All @@ -42,4 +50,4 @@ DSYM: DW_AT_byte_size (0x01)
DSYM: 0x0000009b: DW_TAG_formal_parameter
DSYM: DW_AT_location (DW_OP_breg2 RCX+0, DW_OP_constu 0xff, DW_OP_and, DW_OP_convert (0x00000084) "DW_ATE_unsigned_1", DW_OP_convert (0x00000088) "DW_ATE_unsigned_8", DW_OP_stack_value)
DSYM: DW_AT_name ("b")
DSYM: DW_AT_type (0x000000b6 "_Bool")
DSYM: DW_AT_type ({{.*}} "_Bool")
3 changes: 3 additions & 0 deletions llvm/test/tools/dsymutil/X86/op-convert.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# RUN: dsymutil -f -o %t --verify -oso-prepend-path=%p/../Inputs -y %s
# RUN: llvm-dwarfdump %t | FileCheck %s

# RUN: dsymutil --linker llvm -f -o %t --verify -oso-prepend-path=%p/../Inputs -y %s
# RUN: llvm-dwarfdump %t | FileCheck %s

---
triple: 'x86_64-apple-darwin'
objects:
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/papertrail-warnings.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
RUN: env RC_DEBUG_OPTIONS=1 dsymutil -f %p/../Inputs/basic.macho.x86_64 -o - | llvm-dwarfdump -v - | FileCheck -DMSG=%errc_ENOENT %s

RUN: env RC_DEBUG_OPTIONS=1 dsymutil --linker llvm -f %p/../Inputs/basic.macho.x86_64 -o - | llvm-dwarfdump -v - | FileCheck -DMSG=%errc_ENOENT %s

CHECK: .debug_info contents:
CHECK: Compile Unit:
CHECK: DW_TAG_compile_unit [1] *
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/tools/dsymutil/X86/reflection-dump.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ RUN: yaml2obj %p/../Inputs/reflection_metadata.yaml -o %t.dir/tmp/reflection_met
RUN: dsymutil -oso-prepend-path=%t.dir %t.dir/main -o %t.dir/main.dSYM
RUN: llvm-objdump -s %t.dir/main.dSYM/Contents/Resources/DWARF/main | FileCheck %s

RUN: dsymutil --linker llvm -oso-prepend-path=%t.dir %t.dir/main -o %t.dir/main.dSYM
RUN: llvm-objdump -s %t.dir/main.dSYM/Contents/Resources/DWARF/main | FileCheck %s

REQUIRES: host-byteorder-little-endian


Expand Down
7 changes: 7 additions & 0 deletions llvm/test/tools/dsymutil/X86/remarks-linking-archive.text
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ RUN: dsymutil -oso-prepend-path=%p/../Inputs -remarks-prepend-path=%p/../Inputs
Check that the remark file in the bundle exists and is sane:
RUN: llvm-bcanalyzer -dump %t/basic.macho.remarks.archive.x86_64.dSYM/Contents/Resources/Remarks/basic.macho.remarks.archive.x86_64 | FileCheck %s

RUN: dsymutil --linker llvm -oso-prepend-path=%p/../Inputs -remarks-prepend-path=%p/../Inputs %t/basic.macho.remarks.archive.x86_64

Check that the remark file in the bundle exists and is sane:
RUN: llvm-bcanalyzer -dump %t/basic.macho.remarks.archive.x86_64.dSYM/Contents/Resources/Remarks/basic.macho.remarks.archive.x86_64 | FileCheck %s

Check that we don't error if we're missing remark files from an archive, but we warn instead.
Instead of creating a new binary, just remove the remarks prepend path.
RUN: dsymutil -oso-prepend-path=%p/../Inputs %t/basic.macho.remarks.archive.x86_64 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING

RUN: dsymutil --linker llvm -oso-prepend-path=%p/../Inputs %t/basic.macho.remarks.archive.x86_64 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING

CHECK: <Meta
CHECK: <Remark Num
CHECK: <Remark Num
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ RUN: dsymutil -oso-prepend-path=%p/../Inputs -remarks-prepend-path=%p/../Inputs

Check that the remark file in the bundle does not exist:
RUN: not cat %t/basic.macho.remarks.empty.x86_64.dSYM/Contents/Resources/Remarks/basic.macho.remarks.empty.x86_64 2>&1

RUN: dsymutil --linker llvm -oso-prepend-path=%p/../Inputs -remarks-prepend-path=%p/../Inputs %t/basic.macho.remarks.empty.x86_64

Check that the remark file in the bundle does not exist:
RUN: not cat %t/basic.macho.remarks.empty.x86_64.dSYM/Contents/Resources/Remarks/basic.macho.remarks.empty.x86_64 2>&1
8 changes: 8 additions & 0 deletions llvm/test/tools/dsymutil/X86/remarks-linking-bundle.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ RUN: dsymutil -oso-prepend-path=%p/../Inputs -remarks-prepend-path=%p/../Inputs
Check that the remark file in the bundle exists and is sane:
RUN: llvm-bcanalyzer -dump %t/basic.macho.remarks.x86_64.dSYM/Contents/Resources/Remarks/basic.macho.remarks.x86_64 | FileCheck %s

RUN: dsymutil --linker llvm -oso-prepend-path=%p/../Inputs -remarks-prepend-path=%p/../Inputs %t/basic.macho.remarks.x86_64

Check that the remark file in the bundle exists and is sane:
RUN: llvm-bcanalyzer -dump %t/basic.macho.remarks.x86_64.dSYM/Contents/Resources/Remarks/basic.macho.remarks.x86_64 | FileCheck %s

Now emit it in a different format: YAML.
RUN: dsymutil -remarks-output-format=yaml -oso-prepend-path=%p/../Inputs -remarks-prepend-path=%p/../Inputs %t/basic.macho.remarks.x86_64
RUN: cat %t/basic.macho.remarks.x86_64.dSYM/Contents/Resources/Remarks/basic.macho.remarks.x86_64 | FileCheck %s --check-prefix=CHECK-YAML

RUN: dsymutil --linker llvm -remarks-output-format=yaml -oso-prepend-path=%p/../Inputs -remarks-prepend-path=%p/../Inputs %t/basic.macho.remarks.x86_64
RUN: cat %t/basic.macho.remarks.x86_64.dSYM/Contents/Resources/Remarks/basic.macho.remarks.x86_64 | FileCheck %s --check-prefix=CHECK-YAML

CHECK: <Meta
CHECK: <Remark Num
CHECK: <Remark Num
Expand Down
7 changes: 7 additions & 0 deletions llvm/test/tools/dsymutil/X86/remarks-linking-fat-bundle.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ RUN: llvm-bcanalyzer -dump %t/fat.macho.remarks.x86.dSYM/Contents/Resources/Rema
RUN: llvm-bcanalyzer -dump %t/fat.macho.remarks.x86.dSYM/Contents/Resources/Remarks/fat.macho.remarks.x86-x86_64 | FileCheck %s
RUN: llvm-bcanalyzer -dump %t/fat.macho.remarks.x86.dSYM/Contents/Resources/Remarks/fat.macho.remarks.x86-i386 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-i386

RUN: dsymutil --linker llvm -oso-prepend-path=%p/../Inputs -remarks-prepend-path=%p/../Inputs %t/fat.macho.remarks.x86

Check that the remark files in the bundle exist and are all sane:
RUN: llvm-bcanalyzer -dump %t/fat.macho.remarks.x86.dSYM/Contents/Resources/Remarks/fat.macho.remarks.x86-x86_64h | FileCheck %s
RUN: llvm-bcanalyzer -dump %t/fat.macho.remarks.x86.dSYM/Contents/Resources/Remarks/fat.macho.remarks.x86-x86_64 | FileCheck %s
RUN: llvm-bcanalyzer -dump %t/fat.macho.remarks.x86.dSYM/Contents/Resources/Remarks/fat.macho.remarks.x86-i386 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-i386

CHECK: <Meta
CHECK: <Remark Num
CHECK: <Remark Num
Expand Down
6 changes: 6 additions & 0 deletions llvm/test/tools/dsymutil/X86/reproducer.test
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@ RUN: llvm-dwarfdump -a %t.generate | FileCheck %s
RUN: rm -rf %t
RUN: not dsymutil -f -o %t.error -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 2>&1 | FileCheck %s --check-prefix=ERROR

RUN: not dsymutil --linker llvm -f -o %t.error -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 2>&1 | FileCheck %s --check-prefix=ERROR

# Use the reproducer.
RUN: dsymutil -use-reproducer %t.repro -f -o - -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s

RUN: dsymutil --linker llvm -use-reproducer %t.repro -f -o - -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s

# Using a reproducer takes precedence.
RUN: dsymutil -gen-reproducer -use-reproducer %t.repro -f -o - -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s

RUN: dsymutil --linker llvm -gen-reproducer -use-reproducer %t.repro -f -o - -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s

CHECK: .debug_info
CHECK: DW_TAG_compile_unit
CHECK-NEXT: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)")
Expand Down
1 change: 1 addition & 0 deletions llvm/test/tools/dsymutil/X86/statistics.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# RUN: dsymutil -statistics -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 %p/../Inputs/basic-archive.macho.x86_64 %p/../Inputs/basic-lto.macho.x86_64 %p/../Inputs/basic-lto-dw4.macho.x86_64 -o %t 2>&1 | FileCheck %s
# RUN: dsymutil --linker llvm -statistics -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 %p/../Inputs/basic-archive.macho.x86_64 %p/../Inputs/basic-lto.macho.x86_64 %p/../Inputs/basic-lto-dw4.macho.x86_64 -o %t 2>&1 | FileCheck %s
#
# CHECK: -------------------------------------------------------------------------------
# CHECK-NEXT: Filename Object dSYM Change
Expand Down
6 changes: 6 additions & 0 deletions llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ RUN: dsymutil -oso-prepend-path %p/.. %p/../Inputs/swift-ast.macho.x86_64 -o %T/
RUN: llvm-readobj --sections --section-data %T/swift-ast.dSYM/Contents/Resources/DWARF/swift-ast.macho.x86_64 | FileCheck %s --check-prefix=READOBJ
RUN: llvm-dwarfdump --show-section-sizes %T/swift-ast.dSYM/Contents/Resources/DWARF/swift-ast.macho.x86_64 | FileCheck %s --check-prefix=DWARFDUMP

RUN: dsymutil --linker llvm -oso-prepend-path %p/.. %p/../Inputs/swift-ast.macho.x86_64 -o %T/swift-ast.dSYM -verbose -no-swiftmodule-timestamp | FileCheck %s --check-prefix=DSYMUTIL
RUN: dsymutil --linker llvm -oso-prepend-path %p/.. %p/../Inputs/swift-ast.macho.x86_64 -o %T/swift-ast.dSYM -verbose | FileCheck %s --check-prefix=DSYMUTIL
RUN: llvm-readobj --sections --section-data %T/swift-ast.dSYM/Contents/Resources/DWARF/swift-ast.macho.x86_64 | FileCheck %s --check-prefix=READOBJ
RUN: llvm-dwarfdump --show-section-sizes %T/swift-ast.dSYM/Contents/Resources/DWARF/swift-ast.macho.x86_64 | FileCheck %s --check-prefix=DWARFDUMP


The tested object file has been created by the dummy Swift code:
let x = 1

Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/swift-dwarf-loc.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/swift-dwarf-loc.macho.x86_64 -no-output -verbose | FileCheck %s

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/swift-dwarf-loc.macho.x86_64 -no-output -verbose | FileCheck %s

This test checks that dsymutil generates a valid dwarf location for a symbol with no flags set.

The following IR was compiled for x86_64-apple:
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/tools/dsymutil/X86/tail-call-linking.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
RUN: dsymutil -oso-prepend-path=%p %p/Inputs/tail-call.macho.x86_64 -o %t.dSYM
RUN: llvm-dwarfdump %t.dSYM | FileCheck %s -implicit-check-not=DW_AT_call_pc

RUN: dsymutil --linker llvm -oso-prepend-path=%p %p/Inputs/tail-call.macho.x86_64 -o %t.dSYM
RUN: llvm-dwarfdump %t.dSYM | FileCheck %s -implicit-check-not=DW_AT_call_pc

CHECK: DW_AT_call_pc (0x0000000100000f95)
3 changes: 3 additions & 0 deletions llvm/test/tools/dsymutil/X86/thinlto.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ $ xcrun clang++ -g -flto=thin -O2 foo.cpp bar.cpp -c
$ xcrun clang++ -flto=thin foo.o bar.o -Xlinker -object_path_lto -Xlinker lto -shared -o foobar.dylib

RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/thinlto/foobar.dylib -o %t.dSYM 2>&1 | FileCheck %s --allow-empty

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/thinlto/foobar.dylib -o %t.dSYM 2>&1 | FileCheck %s --allow-empty

CHECK-NOT: could not find object file symbol for symbol __ZZ9function2vE12magic_static
CHECK-NOT: could not find object file symbol for symbol __ZGVZ9function2vE12magic_static
2 changes: 2 additions & 0 deletions llvm/test/tools/dsymutil/X86/timestamp-mismatch.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ RUN: cp %p/../Inputs/basic2.macho.x86_64.o %t/Inputs
RUN: cp %p/../Inputs/basic3.macho.x86_64.o %t/Inputs
RUN: dsymutil -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s

RUN: dsymutil --linker llvm -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s

CHECK: warning: {{.*}}/Inputs/basic1.macho.x86_64.o: timestamp mismatch between object file ({{.*}}) and debug map ({{.*}})
CHECK: warning: {{.*}}/Inputs/basic2.macho.x86_64.o: timestamp mismatch between object file ({{.*}}) and debug map ({{.*}})
CHECK: warning: {{.*}}/Inputs/basic3.macho.x86_64.o: timestamp mismatch between object file ({{.*}}) and debug map ({{.*}})
1 change: 1 addition & 0 deletions llvm/test/tools/dsymutil/X86/tls-variable.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# RUN: echo ' - { sym: __Z3foov, objAddr: 0x0, binAddr: 0x10000, size: 0x10 }' >> %t2.map
# RUN: echo '...' >> %t2.map
# RUN: dsymutil -y %t2.map --keep-function-for-static -f -o - | llvm-dwarfdump -a - | FileCheck %s
# COM: dsymutil --linker llvm -y %t2.map --keep-function-for-static -f -o - | llvm-dwarfdump -a - | FileCheck %s

# CHECK: file format Mach-O 64-bit x86-64
# CHECK: .debug_info contents:
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/tools/dsymutil/X86/union-fwd-decl.test
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Note that the link order in the last command matters for this test.
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/union/a.out -o %t.dSYM
RUN: llvm-dwarfdump %t.dSYM | FileCheck %s

RUN: dsymutil --linker llvm -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/union/a.out -o %t.dSYM
RUN: llvm-dwarfdump %t.dSYM | FileCheck %s

CHECK: DW_TAG_compile_unit

CHECK: DW_AT_name ("Container_ivars")
Expand Down
19 changes: 19 additions & 0 deletions llvm/test/tools/dsymutil/X86/verify.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@
# QUIET-SUCCESS-NOT: input verification failed
# QUIET-SUCCESS-NOT: output verification failed
# BOGUS: error: invalid verify type specified: 'bogus'
#
# Positive tests in regular and verbose mode.
# RUN: dsymutil --linker llvm -verify -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 %p/../Inputs/basic-archive.macho.x86_64 %p/../Inputs/basic-lto.macho.x86_64 %p/../Inputs/basic-lto-dw4.macho.x86_64 -o %t 2>&1 | FileCheck %s --allow-empty --check-prefix=QUIET-SUCCESS
# RUN: dsymutil --linker llvm -verify -verbose -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 %p/../Inputs/basic-archive.macho.x86_64 %p/../Inputs/basic-lto.macho.x86_64 %p/../Inputs/basic-lto-dw4.macho.x86_64 -o %t 2>&1 | FileCheck %s --check-prefixes=QUIET-SUCCESS,VERBOSE
#
# # Negative output tests in regular and verbose mode.
# (Invalid object generated from ../Inputs/invalid.s by modified the low PC.)
# RUN: not dsymutil --linker llvm -verify -oso-prepend-path=%p/../Inputs -y %s -o %t 2>&1 | FileCheck %s --check-prefix=QUIET-OUTPUT-FAIL
# RUN: not dsymutil --linker llvm -verify-dwarf=output -oso-prepend-path=%p/../Inputs -y %s -o %t 2>&1 | FileCheck %s --check-prefix=QUIET-OUTPUT-FAIL
# RUN: not dsymutil --linker llvm -verify -verbose -oso-prepend-path=%p/../Inputs -y %s -o %t 2>&1 | FileCheck %s --check-prefixes=QUIET-OUTPUT-FAIL,VERBOSE
#
# # Negative input & output tests in regular and verbose mode. Only output failures result in a non-zero exit code.
# RUN: dsymutil --linker llvm -verify-dwarf=input -oso-prepend-path=%p/../Inputs -y %s -o %t 2>&1 | FileCheck %s --check-prefix=QUIET-INPUT-FAIL
# RUN: dsymutil --linker llvm -verify-dwarf=input -verbose -oso-prepend-path=%p/../Inputs -y %s -o %t 2>&1 | FileCheck %s --check-prefix=QUIET-INPUT-FAIL
# RUN: dsymutil --linker llvm -verify-dwarf=none -verbose -oso-prepend-path=%p/../Inputs -y %s -o %t 2>&1 | FileCheck %s --check-prefixes=QUIET-SUCCESS
# RUN: not dsymutil --linker llvm -verify-dwarf=bogus -verbose -oso-prepend-path=%p/../Inputs -y %s -o %t 2>&1 | FileCheck %s --check-prefixes=BOGUS
# RUN: not dsymutil --linker llvm -verify-dwarf=all -oso-prepend-path=%p/../Inputs -y %s -o %t 2>&1 | FileCheck %s --check-prefixes=QUIET-OUTPUT-FAIL,QUIET-INPUT-FAIL
# RUN: not dsymutil --linker llvm -verify-dwarf=all -verbose -oso-prepend-path=%p/../Inputs -y %s -o %t 2>&1 | FileCheck %s --check-prefixes=VERBOSE-INPUT-FAIL


---
triple: 'x86_64-apple-darwin'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
# RUN: llvm-dwarfdump --verify %t1 | FileCheck --check-prefix=VERIFY %s
# RUN: llvm-dwarfdump -a %t1 | FileCheck %s

# RUN: llvm-dwarfutil --linker llvm %t.o %t1
# RUN: llvm-dwarfdump --verify %t1 | FileCheck --check-prefix=VERIFY %s
# RUN: llvm-dwarfdump -a %t1 | FileCheck %s

# VERIFY: No errors.

## Content: "03000201064400020744000400":
Expand Down
17 changes: 13 additions & 4 deletions llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf4-macro.test
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,28 @@
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefix=MACINFO

#RUN: llvm-dwarfutil --linker llvm --garbage-collection %p/Inputs/dwarf4-macro.out %t1
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefix=MACINFO

## Check that macro table preserved during simple copying.
#
#RUN: llvm-dwarfutil --no-garbage-collection %p/Inputs/dwarf4-macro.out %t1
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefix=MACINFO

#RUN: llvm-dwarfutil --linker llvm --no-garbage-collection %p/Inputs/dwarf4-macro.out %t1
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefix=MACINFO

## Check that macro table preserved during updating accelerator tables.
#RUN: llvm-dwarfutil --no-garbage-collection --build-accelerator=DWARF %p/Inputs/dwarf4-macro.out %t1
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefixes=MACINFO,NAMES
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefixes=MACINFO

#RUN: llvm-dwarfutil --linker llvm --no-garbage-collection --build-accelerator=DWARF %p/Inputs/dwarf4-macro.out %t1
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefixes=MACINFO

#CHECK: No errors.

Expand Down Expand Up @@ -2228,6 +2240,3 @@
#MACINFO-NEXT: DW_MACINFO_define - lineno: 0 macro: __STDC_UTF_32__ 1
#MACINFO-NEXT: DW_MACINFO_define - lineno: 0 macro: __GCC_HAVE_DWARF2_CFI_ASM 1


#NAMES: .debug_names contents
#NAMES: Name Index
16 changes: 14 additions & 2 deletions llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-addresses.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@
# RUN: llvm-dwarfutil %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix DWARF-CHECK
#

# RUN: llvm-dwarfutil --linker llvm %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix DWARF-CHECK

# RUN: llvm-dwarfutil --no-garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK
#

# RUN: llvm-dwarfutil --linker llvm --no-garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK

# RUN: llvm-dwarfutil --no-garbage-collection --build-accelerator=DWARF %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK

# RUN: llvm-dwarfutil --linker llvm --no-garbage-collection --build-accelerator=DWARF %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK

#CHECK: No errors.

#DWARF-CHECK: DW_TAG_compile_unit
Expand Down
16 changes: 14 additions & 2 deletions llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-attributes.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@
# RUN: llvm-dwarfutil %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s --check-prefix VERIFY-CHECK
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s
#

# RUN: llvm-dwarfutil --linker llvm %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s --check-prefix VERIFY-CHECK
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s

# RUN: llvm-dwarfutil --no-garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s --check-prefix VERIFY-CHECK
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s
#

# RUN: llvm-dwarfutil --linker llvm --no-garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s --check-prefix VERIFY-CHECK
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s

# RUN: llvm-dwarfutil --no-garbage-collection --build-accelerator=DWARF %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s --check-prefix VERIFY-CHECK
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s

# RUN: llvm-dwarfutil --linker llvm --no-garbage-collection --build-accelerator=DWARF %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s --check-prefix VERIFY-CHECK
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s

#VERIFY-CHECK: No errors.

#CHECK: .debug_abbrev
Expand Down
16 changes: 14 additions & 2 deletions llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-line-str.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@
# RUN: llvm-dwarfutil %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s --check-prefix VERIFY-CHECK
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s
#

# RUN: llvm-dwarfutil --no-garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s --check-prefix VERIFY-CHECK
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s
#

# RUN: llvm-dwarfutil --no-garbage-collection --build-accelerator=DWARF %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s --check-prefix VERIFY-CHECK
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s

# RUN: llvm-dwarfutil --linker llvm %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s --check-prefix VERIFY-CHECK
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s

# RUN: llvm-dwarfutil --linker llvm --no-garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s --check-prefix VERIFY-CHECK
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s

# RUN: llvm-dwarfutil --linker llvm --no-garbage-collection --build-accelerator=DWARF %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s --check-prefix VERIFY-CHECK
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s

#VERIFY-CHECK: No errors.

#CHECK: .debug_info
Expand Down
12 changes: 12 additions & 0 deletions llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-loclists.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK

# RUN: llvm-dwarfutil --linker llvm %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix DWARF-CHECK

# RUN: llvm-dwarfutil --linker llvm --no-garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK

# RUN: llvm-dwarfutil --linker llvm --no-garbage-collection --build-accelerator=DWARF %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK

#CHECK: No errors.

#DWARF-CHECK: DW_TAG_compile_unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# RUN: llvm-dwarfdump --verify %t1 | FileCheck --check-prefix=VERIFY %s
# RUN: llvm-dwarfdump -a %t1 | FileCheck %s

# RUN: llvm-dwarfutil --linker llvm %t.o %t1 2>&1 | FileCheck --check-prefix=ERR %s
# RUN: llvm-dwarfdump --verify %t1 | FileCheck --check-prefix=VERIFY %s
# RUN: llvm-dwarfdump -a %t1 | FileCheck %s

# ERR: error: opcode_operands_table is not supported

# VERIFY: No errors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
# RUN: llvm-dwarfdump --verify %t1 | FileCheck --check-prefix=VERIFY %s
# RUN: llvm-dwarfdump -a %t1 | FileCheck %s

# RUN: llvm-dwarfutil --linker llvm %t.o %t1 2>&1 | FileCheck --check-prefix=WARN %s
# RUN: llvm-dwarfdump --verify %t1 | FileCheck --check-prefix=VERIFY %s
# RUN: llvm-dwarfdump -a %t1 | FileCheck %s

# WARN: warning: DW_MACRO_define_strx unsupported yet. Convert to DW_MACRO_define_strp.
# WARN: warning: DW_MACRO_undef_strx unsupported yet. Convert to DW_MACRO_undef_strp.
# WARN: warning: DW_MACRO_import and DW_MACRO_import_sup are unsupported yet. remove.
Expand Down
17 changes: 13 additions & 4 deletions llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-macro.test
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,28 @@
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefix=MACRO

#RUN: llvm-dwarfutil --linker llvm --garbage-collection %p/Inputs/dwarf5-macro.out %t1
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefix=MACRO

## Check that macro table preserved during simple copying.
#
#RUN: llvm-dwarfutil --no-garbage-collection %p/Inputs/dwarf5-macro.out %t1
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefix=MACRO

#RUN: llvm-dwarfutil --linker llvm --no-garbage-collection %p/Inputs/dwarf5-macro.out %t1
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefix=MACRO

## Check that macro table preserved during updating accelerator tables.
#RUN: llvm-dwarfutil --no-garbage-collection --build-accelerator=DWARF %p/Inputs/dwarf5-macro.out %t1
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefixes=MACRO,NAMES
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefixes=MACRO

#RUN: llvm-dwarfutil --linker llvm --no-garbage-collection --build-accelerator=DWARF %p/Inputs/dwarf5-macro.out %t1
#RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
#RUN: llvm-dwarfdump -a %t1 | FileCheck %s --check-prefixes=MACRO

#CHECK: No errors.

Expand Down Expand Up @@ -2233,6 +2245,3 @@
#MACRO-NEXT: DW_MACRO_define_str{{[px]}} - lineno: 0 macro: __STDC_UTF_16__ 1
#MACRO-NEXT: DW_MACRO_define_str{{[px]}} - lineno: 0 macro: __STDC_UTF_32__ 1
#MACRO-NEXT: DW_MACRO_define_str{{[px]}} - lineno: 0 macro: __GCC_HAVE_DWARF2_CFI_ASM 1

#NAMES: .debug_names contents
#NAMES: Name Index
12 changes: 12 additions & 0 deletions llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-rnglists.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,26 @@
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix DWARF-CHECK

# RUN: llvm-dwarfutil --linker llvm %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix DWARF-CHECK

# RUN: llvm-dwarfutil --no-garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK

# RUN: llvm-dwarfutil --linker llvm --no-garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK

# RUN: llvm-dwarfutil --no-garbage-collection --build-accelerator=DWARF %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK

# RUN: llvm-dwarfutil --linker llvm --no-garbage-collection --build-accelerator=DWARF %t.o %t1
# RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
# RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK

#CHECK: No errors.

#DWARF-CHECK: DW_TAG_compile_unit
Expand Down
6 changes: 6 additions & 0 deletions llvm/test/tools/llvm-dwarfutil/ELF/X86/gc-default.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@

# RUN: llvm-dwarfutil --linker apple %t.o - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,CHECK-GC

# RUN: llvm-dwarfutil --linker llvm %t.o - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,CHECK-GC

# RUN: llvm-dwarfutil --garbage-collection %t.o - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,CHECK-GC

# RUN: llvm-dwarfutil --no-garbage-collection --garbage-collection %t.o - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,CHECK-GC

# RUN: llvm-dwarfutil --garbage-collection --no-garbage-collection %t.o - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,CHECK-NOGC

# RUN: llvm-dwarfutil --linker llvm --garbage-collection --no-garbage-collection %t.o - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,CHECK-NOGC

# RUN: llvm-dwarfutil %t.o --tombstone=universal - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,CHECK-GC

# RUN: llvm-dwarfutil --linker llvm %t.o --tombstone=universal - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,CHECK-GC

# CHECK: DW_TAG_compile_unit
# CHECK: DW_AT_name{{.*}}"CU1"
# CHECK: DW_TAG_class_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -a %t1 | FileCheck %s

# RUN: llvm-dwarfutil --linker llvm --garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -a %t1 | FileCheck %s

# CHECK: DW_TAG_compile_unit
# CHECK: DW_AT_name{{.*}}"CU1"
# CHECK: DW_AT_low_pc{{.*}}0000000000001000
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/tools/llvm-dwarfutil/ELF/X86/gc-maxpc.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# RUN: llvm-dwarfutil --tombstone=maxpc --garbage-collection %t.o - | llvm-dwarfdump -a - | FileCheck %s
# RUN: llvm-dwarfutil --tombstone=universal --garbage-collection %t.o - | llvm-dwarfdump -a - | FileCheck %s

# RUN: llvm-dwarfutil --linker llvm --tombstone=maxpc --garbage-collection %t.o - | llvm-dwarfdump -a - | FileCheck %s
# RUN: llvm-dwarfutil --linker llvm --tombstone=universal --garbage-collection %t.o - | llvm-dwarfdump -a - | FileCheck %s

# CHECK: DW_TAG_compile_unit
# CHECK: DW_AT_name{{.*}}"CU1"
# CHECK: DW_TAG_class_type
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/tools/llvm-dwarfutil/ELF/X86/gc-no-garbage.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# RUN: yaml2obj %s -o %t.o
# RUN: llvm-dwarfutil --tombstone=maxpc --garbage-collection %t.o - | llvm-dwarfdump -a - | FileCheck %s

# RUN: llvm-dwarfutil --linker llvm --tombstone=maxpc --garbage-collection %t.o - | llvm-dwarfdump -a - | FileCheck %s

# CHECK: DW_TAG_compile_unit
# CHECK: DW_AT_name{{.*}}"CU1"
# CHECK: DW_TAG_class_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# RUN: llvm-dwarfutil --garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -a %t1 | FileCheck %s

# RUN: llvm-dwarfutil --linker llvm --garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -a %t1 | FileCheck %s

# CHECK: DW_TAG_compile_unit
# CHECK: DW_AT_name{{.*}}"CU1"
# CHECK: DW_TAG_class_type
Expand Down
5 changes: 5 additions & 0 deletions llvm/test/tools/llvm-dwarfutil/ELF/X86/verify.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@

## Verify resulting debug info after --garbage-collection optimisation.
# RUN: llvm-dwarfutil %t.o %t1 --verify
# RUN: llvm-dwarfutil --linker llvm %t.o %t1 --verify

## Verify separate debug file after --garbage-collection optimisation.
# RUN: llvm-dwarfutil %t.o --separate-debug-file %t1 --verify
# RUN: llvm-dwarfutil --linker llvm %t.o --separate-debug-file %t1 --verify

## Verify not optimised resulting debug info.
# RUN: not llvm-dwarfutil --no-garbage-collection %t.o %t1 --verify 2>&1 | FileCheck %s -DFILE=%t1
# RUN: not llvm-dwarfutil --linker llvm --no-garbage-collection %t.o %t1 --verify 2>&1 | FileCheck %s -DFILE=%t1

## Verify not optimised resulting separate debug file.
# RUN: not llvm-dwarfutil --no-garbage-collection %t.o --separate-debug-file %t1 --verify 2>&1 | FileCheck %s -DFILE=%t1.debug
# RUN: not llvm-dwarfutil --linker llvm --no-garbage-collection %t.o --separate-debug-file %t1 --verify 2>&1 | FileCheck %s -DFILE=%t1.debug

## Check that verification is disabled when destination is stdout.
# RUN: llvm-dwarfutil %t.o - --verify 2>&1 | FileCheck %s --check-prefix=CHECK-STDOUT
# RUN: llvm-dwarfutil --linker llvm %t.o - --verify 2>&1 | FileCheck %s --check-prefix=CHECK-STDOUT

# CHECK: error: '[[FILE]]': output verification failed
# CHECK-STDOUT: warning: verification skipped because writing to stdout
Expand Down
21 changes: 21 additions & 0 deletions llvm/tools/dsymutil/BinaryHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ BinaryHolder::getObjectEntry(StringRef Filename, TimestampTy Timestamp) {
if (isArchive(Filename)) {
StringRef ArchiveFilename = getArchiveAndObjectName(Filename).first;
std::lock_guard<std::mutex> Lock(ArchiveCacheMutex);
ArchiveRefCounter[ArchiveFilename]++;
if (ArchiveCache.count(ArchiveFilename)) {
return ArchiveCache[ArchiveFilename]->getObjectEntry(Filename, Timestamp,
Verbose);
Expand All @@ -258,6 +259,7 @@ BinaryHolder::getObjectEntry(StringRef Filename, TimestampTy Timestamp) {
// If this is an object, we might have it cached. If not we'll have to load
// it from the file system and cache it now.
std::lock_guard<std::mutex> Lock(ObjectCacheMutex);
ObjectRefCounter[Filename]++;
if (!ObjectCache.count(Filename)) {
auto OE = std::make_unique<ObjectEntry>();
auto Err = OE->load(VFS, Filename, Timestamp, Verbose);
Expand All @@ -276,5 +278,24 @@ void BinaryHolder::clear() {
ObjectCache.clear();
}

void BinaryHolder::eraseObjectEntry(StringRef Filename) {
if (Verbose)
WithColor::note() << "erasing '" << Filename << "' from cache\n";

if (isArchive(Filename)) {
StringRef ArchiveFilename = getArchiveAndObjectName(Filename).first;
std::lock_guard<std::mutex> Lock(ArchiveCacheMutex);
ArchiveRefCounter[ArchiveFilename]--;
if (ArchiveRefCounter[ArchiveFilename] == 0)
ArchiveCache.erase(ArchiveFilename);
return;
}

std::lock_guard<std::mutex> Lock(ObjectCacheMutex);
ObjectRefCounter[Filename]--;
if (ObjectRefCounter[Filename] == 0)
ObjectCache.erase(Filename);
}

} // namespace dsymutil
} // namespace llvm
3 changes: 3 additions & 0 deletions llvm/tools/dsymutil/BinaryHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,18 @@ class BinaryHolder {
getObjectEntry(StringRef Filename, TimestampTy Timestamp = TimestampTy());

void clear();
void eraseObjectEntry(StringRef Filename);

private:
/// Cache of static archives. Objects that are part of a static archive are
/// stored under this object, rather than in the map below.
StringMap<std::unique_ptr<ArchiveEntry>> ArchiveCache;
StringMap<uint32_t> ArchiveRefCounter;
std::mutex ArchiveCacheMutex;

/// Object entries for objects that are not in a static archive.
StringMap<std::unique_ptr<ObjectEntry>> ObjectCache;
StringMap<uint32_t> ObjectRefCounter;
std::mutex ObjectCacheMutex;

/// Virtual File System instance.
Expand Down
38 changes: 30 additions & 8 deletions llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,22 @@ static void dumpDIE(const DWARFDie *DIE, bool Verbose) {
/// specific \p DIE related to the warning.
void DwarfLinkerForBinary::reportWarning(Twine Warning, Twine Context,
const DWARFDie *DIE) const {
std::lock_guard<std::mutex> Guard(ErrorHandlerMutex);
warn(Warning, Context);
dumpDIE(DIE, Options.Verbose);
// FIXME: implement warning logging which does not block other threads.
if (ErrorHandlerMutex.try_lock()) {
warn(Warning, Context);
dumpDIE(DIE, Options.Verbose);
ErrorHandlerMutex.unlock();
}
}

void DwarfLinkerForBinary::reportError(Twine Error, Twine Context,
const DWARFDie *DIE) const {
std::lock_guard<std::mutex> Guard(ErrorHandlerMutex);
error(Error, Context);
dumpDIE(DIE, Options.Verbose);
// FIXME: implement error logging which does not block other threads.
if (ErrorHandlerMutex.try_lock()) {
error(Error, Context);
dumpDIE(DIE, Options.Verbose);
ErrorHandlerMutex.unlock();
}
}

ErrorOr<const object::ObjectFile &>
Expand Down Expand Up @@ -233,9 +239,23 @@ DwarfLinkerForBinary::loadObject(const DebugMapObject &Obj,

if (ErrorOrObj) {
Res = std::make_unique<OutDWARFFile>(
Obj.getObjectFilename(), DWARFContext::create(*ErrorOrObj),
Obj.getObjectFilename(),
DWARFContext::create(
*ErrorOrObj, DWARFContext::ProcessDebugRelocations::Process,
nullptr, "",
[&](Error Err) {
handleAllErrors(std::move(Err), [&](ErrorInfoBase &Info) {
reportError(Info.message());
});
},
[&](Error Warning) {
handleAllErrors(std::move(Warning), [&](ErrorInfoBase &Info) {
reportWarning(Info.message());
});
}),
std::make_unique<AddressesMap>(*this, *ErrorOrObj, Obj),
Obj.empty() ? Obj.getWarnings() : EmptyWarnings);
Obj.empty() ? Obj.getWarnings() : EmptyWarnings,
[&](StringRef FileName) { BinHolder.eraseObjectEntry(FileName); });

Error E = RL.link(*ErrorOrObj);
if (Error NewE = handleErrors(
Expand Down Expand Up @@ -1039,8 +1059,10 @@ std::optional<int64_t> DwarfLinkerForBinary::AddressManager<AddressesMapBase>::
default: {
assert(false && "Specified operation does not have address operand");
} break;
case dwarf::DW_OP_const2u:
case dwarf::DW_OP_const4u:
case dwarf::DW_OP_const8u:
case dwarf::DW_OP_const2s:
case dwarf::DW_OP_const4s:
case dwarf::DW_OP_const8s:
case dwarf::DW_OP_addr: {
Expand Down
Loading