diff options
Diffstat (limited to 'test/tools/dsymutil')
-rwxr-xr-x | test/tools/dsymutil/Inputs/basic-archive.macho.x86_64 | bin | 0 -> 9352 bytes | |||
-rwxr-xr-x | test/tools/dsymutil/Inputs/basic-lto.macho.x86_64 | bin | 0 -> 8912 bytes | |||
-rw-r--r-- | test/tools/dsymutil/Inputs/basic-lto.macho.x86_64.o | bin | 0 -> 4516 bytes | |||
-rwxr-xr-x | test/tools/dsymutil/Inputs/basic.macho.x86_64 | bin | 0 -> 9320 bytes | |||
-rw-r--r-- | test/tools/dsymutil/Inputs/basic1.c | 28 | ||||
-rw-r--r-- | test/tools/dsymutil/Inputs/basic1.macho.x86_64.o | bin | 0 -> 2376 bytes | |||
-rw-r--r-- | test/tools/dsymutil/Inputs/basic2.c | 22 | ||||
-rw-r--r-- | test/tools/dsymutil/Inputs/basic2.macho.x86_64.o | bin | 0 -> 3472 bytes | |||
-rw-r--r-- | test/tools/dsymutil/Inputs/basic3.c | 20 | ||||
-rw-r--r-- | test/tools/dsymutil/Inputs/basic3.macho.x86_64.o | bin | 0 -> 3008 bytes | |||
-rw-r--r-- | test/tools/dsymutil/Inputs/libbasic.a | bin | 0 -> 6840 bytes | |||
-rw-r--r-- | test/tools/dsymutil/basic-linking.test | 149 | ||||
-rw-r--r-- | test/tools/dsymutil/debug-map-parsing.test | 79 |
13 files changed, 298 insertions, 0 deletions
diff --git a/test/tools/dsymutil/Inputs/basic-archive.macho.x86_64 b/test/tools/dsymutil/Inputs/basic-archive.macho.x86_64 Binary files differnew file mode 100755 index 0000000..abffb06 --- /dev/null +++ b/test/tools/dsymutil/Inputs/basic-archive.macho.x86_64 diff --git a/test/tools/dsymutil/Inputs/basic-lto.macho.x86_64 b/test/tools/dsymutil/Inputs/basic-lto.macho.x86_64 Binary files differnew file mode 100755 index 0000000..b5ffb03 --- /dev/null +++ b/test/tools/dsymutil/Inputs/basic-lto.macho.x86_64 diff --git a/test/tools/dsymutil/Inputs/basic-lto.macho.x86_64.o b/test/tools/dsymutil/Inputs/basic-lto.macho.x86_64.o Binary files differnew file mode 100644 index 0000000..c68e15a --- /dev/null +++ b/test/tools/dsymutil/Inputs/basic-lto.macho.x86_64.o diff --git a/test/tools/dsymutil/Inputs/basic.macho.x86_64 b/test/tools/dsymutil/Inputs/basic.macho.x86_64 Binary files differnew file mode 100755 index 0000000..8b3a34a --- /dev/null +++ b/test/tools/dsymutil/Inputs/basic.macho.x86_64 diff --git a/test/tools/dsymutil/Inputs/basic1.c b/test/tools/dsymutil/Inputs/basic1.c new file mode 100644 index 0000000..cedf83a --- /dev/null +++ b/test/tools/dsymutil/Inputs/basic1.c @@ -0,0 +1,28 @@ +/* This is the main file used to produce the basic* objects that are + used for the dsymutil tests. + + These are compiled in a couple of different ways (always on a + Darwin system): + Basic compilation: + for FILE in basic1.c basic2.c basic3.c; do + clang -g -c $FILE -o ${FILE%.c}.macho.x86_64.o + done + clang basic1.macho.x86_64.o basic2.macho.x86_64.o basic3.macho.x86_64.o -o basic.macho.x86_64 -Wl,-dead_strip + + LTO compilation: + for FILE in basic1.c basic2.c basic3.c; do + clang -g -c -flto $FILE -o ${FILE%.c}-lto.o + done + clang basic1-lto.o basic2-lto.o basic3-lto.o -o basic-lto.macho.x86_64 -Wl,-object_path_lto,$PWD/basic-lto.macho.x86_64.o -Wl,-dead_strip + rm basic1-lto.o basic2-lto.o basic3-lto.o + + Archive compilation (after basic compilation): + ar -q libbasic.a basic2.macho.x86_64.o basic3.macho.x86_64.o + clang basic1.macho.x86_64.o -lbasic -o basic-archive.macho.x86_64 -Wl,-dead_strip -L. +*/ + +int foo(int); + +int main(int argc, const char *argv[]) { + return foo(argc); +} diff --git a/test/tools/dsymutil/Inputs/basic1.macho.x86_64.o b/test/tools/dsymutil/Inputs/basic1.macho.x86_64.o Binary files differnew file mode 100644 index 0000000..d7b5000 --- /dev/null +++ b/test/tools/dsymutil/Inputs/basic1.macho.x86_64.o diff --git a/test/tools/dsymutil/Inputs/basic2.c b/test/tools/dsymutil/Inputs/basic2.c new file mode 100644 index 0000000..13c6d07 --- /dev/null +++ b/test/tools/dsymutil/Inputs/basic2.c @@ -0,0 +1,22 @@ +/* For compilation instructions see basic1.c. */ + +static int baz = 42; +static int private_int; +extern volatile int val; +int unused_data = 1; + +int bar(int); + +void unused1() { + bar(baz); +} + +static int inc() { + return ++private_int; +} + +__attribute__((noinline)) +int foo(int arg) { + return bar(arg+val) + inc() + baz++; +} + diff --git a/test/tools/dsymutil/Inputs/basic2.macho.x86_64.o b/test/tools/dsymutil/Inputs/basic2.macho.x86_64.o Binary files differnew file mode 100644 index 0000000..bdd8225 --- /dev/null +++ b/test/tools/dsymutil/Inputs/basic2.macho.x86_64.o diff --git a/test/tools/dsymutil/Inputs/basic3.c b/test/tools/dsymutil/Inputs/basic3.c new file mode 100644 index 0000000..f20998a --- /dev/null +++ b/test/tools/dsymutil/Inputs/basic3.c @@ -0,0 +1,20 @@ +/* For compilation instructions see basic1.c. */ + +volatile int val; + +extern int foo(int); + +int unused2() { + return foo(val); +} + +static int inc() { + return ++val; +} + +__attribute__((noinline)) +int bar(int arg) { + if (arg > 42) + return inc(); + return foo(val + arg); +} diff --git a/test/tools/dsymutil/Inputs/basic3.macho.x86_64.o b/test/tools/dsymutil/Inputs/basic3.macho.x86_64.o Binary files differnew file mode 100644 index 0000000..3c1c639 --- /dev/null +++ b/test/tools/dsymutil/Inputs/basic3.macho.x86_64.o diff --git a/test/tools/dsymutil/Inputs/libbasic.a b/test/tools/dsymutil/Inputs/libbasic.a Binary files differnew file mode 100644 index 0000000..9657e78 --- /dev/null +++ b/test/tools/dsymutil/Inputs/libbasic.a diff --git a/test/tools/dsymutil/basic-linking.test b/test/tools/dsymutil/basic-linking.test new file mode 100644 index 0000000..5de6c13 --- /dev/null +++ b/test/tools/dsymutil/basic-linking.test @@ -0,0 +1,149 @@ +RUN: llvm-dsymutil -v -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s +RUN: llvm-dsymutil -v -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO +RUN: llvm-dsymutil -v -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefix=CHECK-ARCHIVE + +This test check the basic Dwarf linking process through the debug dumps. + +================================= Simple link ================================ +CHECK: DEBUG MAP OBJECT: {{.*}}basic1.macho.x86_64.o +CHECK: Input compilation unit: +CHECK-NEXT: TAG_compile_unit +CHECK-NOT: TAG +CHECK: AT_name {{.*}}basic1.c +CHECK-NOT: Found valid debug map entry +CHECK: Found valid debug map entry: _main 0000000000000000 => 0000000100000ea0 +CHECK-NEXT: DW_TAG_subprogram +CHECK-NEXT: DW_AT_name{{.*}}"main" + +CHECK: DEBUG MAP OBJECT: {{.*}}basic2.macho.x86_64.o +CHECK: Input compilation unit: +CHECK-NEXT: TAG_compile_unit +CHECK-NOT: TAG +CHECK: AT_name {{.*}}basic2.c +CHECK-NOT: Found valid debug map entry +CHECK: Found valid debug map entry: _private_int 0000000000000560 => 0000000100001008 +CHECK-NEXT: DW_TAG_variable +CHECK-NEXT: DW_AT_name {{.*}}"private_int" +CHECK-NOT: Found valid debug map entry +CHECK: Found valid debug map entry: _baz 0000000000000310 => 0000000100001000 +CHECK-NEXT: DW_TAG_variable +CHECK-NEXT: DW_AT_name {{.*}}"baz" +CHECK-NOT: Found valid debug map entry +CHECK: Found valid debug map entry: _foo 0000000000000020 => 0000000100000ed0 +CHECK-NEXT: DW_TAG_subprogram +CHECK-NEXT: DW_AT_name {{.*}}"foo" +CHECK-NOT: Found valid debug map entry +CHECK: Found valid debug map entry: _inc 0000000000000070 => 0000000100000f20 +CHECK-NEXT: DW_TAG_subprogram +CHECK-NEXT: DW_AT_name {{.*}}"inc" + +CHECK: DEBUG MAP OBJECT: {{.*}}basic3.macho.x86_64.o +CHECK: Input compilation unit: +CHECK-NEXT: TAG_compile_unit +CHECK-NOT: TAG +CHECK: AT_name {{.*}}basic3.c +CHECK-NOT: Found valid debug map entry +CHECK: Found valid debug map entry: _val 0000000000000004 => 0000000100001004 +CHECK-NEXT: DW_TAG_variable +CHECK-NEXT: DW_AT_name {{.*}}"val" +CHECK-NOT: Found valid debug map entry +CHECK: Found valid debug map entry: _bar 0000000000000020 => 0000000100000f40 +CHECK-NEXT: DW_TAG_subprogram +CHECK-NEXT: DW_AT_name {{.*}}"bar" +CHECK-NOT: Found valid debug map entry +CHECK: Found valid debug map entry: _inc 0000000000000070 => 0000000100000f90 +CHECK-NEXT: DW_TAG_subprogram +CHECK-NEXT: DW_AT_name {{.*}}"inc") + + +================================= LTO link ================================ +CHECK-LTO: DEBUG MAP OBJECT: {{.*}}basic-lto.macho.x86_64.o +CHECK-LTO: Input compilation unit: +CHECK-LTO-NEXT: TAG_compile_unit +CHECK-LTO-NOT: TAG +CHECK-LTO: AT_name {{.*}}basic1.c +CHECK-LTO: Input compilation unit: +CHECK-LTO-NEXT: TAG_compile_unit +CHECK-LTO-NOT: TAG +CHECK-LTO: AT_name {{.*}}basic2.c +CHECK-LTO: Input compilation unit: +CHECK-LTO-NEXT: TAG_compile_unit +CHECK-LTO-NOT: TAG +CHECK-LTO: AT_name {{.*}}basic3.c + +CHECK-LTO-NOT: Found valid debug map entry +CHECK-LTO: Found valid debug map entry: _main 0000000000000000 => 0000000100000f40 +CHECK-LTO-NEXT: DW_TAG_subprogram +CHECK-LTO-NEXT: DW_AT_name {{.*}}"main" +CHECK-LTO-NOT: Found valid debug map entry +CHECK-LTO: Found valid debug map entry: _private_int 00000000000008e8 => 0000000100001008 +CHECK-LTO-NEXT: DW_TAG_variable +CHECK-LTO-NEXT: DW_AT_name {{.*}}"private_int" +CHECK-LTO-NOT: Found valid debug map entry +CHECK-LTO: Found valid debug map entry: _baz 0000000000000658 => 0000000100001000 +CHECK-LTO-NEXT: DW_TAG_variable +CHECK-LTO-NEXT: DW_AT_name {{.*}} "baz" +CHECK-LTO-NOT: Found valid debug map entry +CHECK-LTO: Found valid debug map entry: _foo 0000000000000010 => 0000000100000f50 +CHECK-LTO-NEXT: DW_TAG_subprogram +CHECK-LTO-NEXT: DW_AT_name {{.*}}"foo" +CHECK-LTO-NOT: Found valid debug map entry +CHECK-LTO: Found valid debug map entry: _val 00000000000008ec => 0000000100001004 +CHECK-LTO-NEXT: DW_TAG_variable +CHECK-LTO-NEXT: DW_AT_name {{.*}}"val" +CHECK-LTO-NOT: Found valid debug map entry +CHECK-LTO: Found valid debug map entry: _bar 0000000000000050 => 0000000100000f90 +CHECK-LTO-NEXT: DW_TAG_subprogram +CHECK-LTO-NEXT: DW_AT_name {{.*}}"bar" + + +================================= Archive link ================================ +CHECK-ARCHIVE: DEBUG MAP OBJECT: {{.*}}basic1.macho.x86_64.o +CHECK-ARCHIVE: Input compilation unit: +CHECK-ARCHIVE-NEXT: TAG_compile_unit +CHECK-ARCHIVE-NOT: TAG +CHECK-ARCHIVE: AT_name {{.*}}basic1.c +CHECK-ARCHIVE-NOT: Found valid debug map entry +CHECK-ARCHIVE: Found valid debug map entry: _main 0000000000000000 => 0000000100000ea0 +CHECK-ARCHIVE-NEXT: DW_TAG_subprogram +CHECK-ARCHIVE-NEXT: DW_AT_name{{.*}}"main" + +CHECK-ARCHIVE: DEBUG MAP OBJECT: {{.*}}libbasic.a(basic2.macho.x86_64.o) +CHECK-ARCHIVE: Input compilation unit: +CHECK-ARCHIVE-NEXT: TAG_compile_unit +CHECK-ARCHIVE-NOT: TAG +CHECK-ARCHIVE: AT_name {{.*}}basic2.c +CHECK-ARCHIVE-NOT: Found valid debug map entry +CHECK-ARCHIVE: Found valid debug map entry: _private_int 0000000000000560 => 0000000100001004 +CHECK-ARCHIVE-NEXT: DW_TAG_variable +CHECK-ARCHIVE-NEXT: DW_AT_name {{.*}}"private_int" +CHECK-ARCHIVE-NOT: Found valid debug map entry +CHECK-ARCHIVE: Found valid debug map entry: _baz 0000000000000310 => 0000000100001000 +CHECK-ARCHIVE-NEXT: DW_TAG_variable +CHECK-ARCHIVE-NEXT: DW_AT_name {{.*}}"baz" +CHECK-ARCHIVE-NOT: Found valid debug map entry +CHECK-ARCHIVE: Found valid debug map entry: _foo 0000000000000020 => 0000000100000ed0 +CHECK-ARCHIVE-NEXT: DW_TAG_subprogram +CHECK-ARCHIVE-NEXT: DW_AT_name {{.*}}"foo" +CHECK-ARCHIVE-NOT: Found valid debug map entry +CHECK-ARCHIVE: Found valid debug map entry: _inc 0000000000000070 => 0000000100000f20 +CHECK-ARCHIVE-NEXT: DW_TAG_subprogram +CHECK-ARCHIVE-NEXT: DW_AT_name {{.*}}"inc" + +CHECK-ARCHIVE: DEBUG MAP OBJECT: {{.*}}libbasic.a(basic3.macho.x86_64.o) +CHECK-ARCHIVE: Input compilation unit: +CHECK-ARCHIVE-NEXT: TAG_compile_unit +CHECK-ARCHIVE-NOT: TAG +CHECK-ARCHIVE: AT_name {{.*}}basic3.c +CHECK-ARCHIVE-NOT: Found valid debug map entry +CHECK-ARCHIVE: Found valid debug map entry: _val 0000000000000004 => 0000000100001008 +CHECK-ARCHIVE-NEXT: DW_TAG_variable +CHECK-ARCHIVE-NEXT: DW_AT_name {{.*}}"val" +CHECK-ARCHIVE-NOT: Found valid debug map entry +CHECK-ARCHIVE: Found valid debug map entry: _bar 0000000000000020 => 0000000100000f40 +CHECK-ARCHIVE-NEXT: DW_TAG_subprogram +CHECK-ARCHIVE-NEXT: DW_AT_name {{.*}}"bar" +CHECK-ARCHIVE-NOT: Found valid debug map entry +CHECK-ARCHIVE: Found valid debug map entry: _inc 0000000000000070 => 0000000100000f90 +CHECK-ARCHIVE-NEXT: DW_TAG_subprogram +CHECK-ARCHIVE-NEXT: DW_AT_name {{.*}}"inc") diff --git a/test/tools/dsymutil/debug-map-parsing.test b/test/tools/dsymutil/debug-map-parsing.test new file mode 100644 index 0000000..b64ad9f --- /dev/null +++ b/test/tools/dsymutil/debug-map-parsing.test @@ -0,0 +1,79 @@ +RUN: llvm-dsymutil -v -parse-only -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s +RUN: llvm-dsymutil -v -parse-only -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO +RUN: llvm-dsymutil -v -parse-only -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefix=CHECK-ARCHIVE +RUN: llvm-dsymutil -v -parse-only %p/Inputs/basic.macho.x86_64 2>&1 | FileCheck %s --check-prefix=NOT-FOUND +RUN: not llvm-dsymutil -v -parse-only %p/Inputs/inexistant 2>&1 | FileCheck %s --check-prefix=NO-EXECUTABLE + + +Check that We can parse the debug map of the basic executable. + +CHECK-NOT: error +CHECK: DEBUG MAP: x86_64-unknown-unknown-macho +CHECK: /Inputs/basic1.macho.x86_64.o: +CHECK: 0000000000000000 => 0000000100000ea0 _main +CHECK: /Inputs/basic2.macho.x86_64.o: +CHECK: 0000000000000310 => 0000000100001000 _baz +CHECK: 0000000000000020 => 0000000100000ed0 _foo +CHECK: 0000000000000070 => 0000000100000f20 _inc +CHECK: 0000000000000560 => 0000000100001008 _private_int +CHECK: /Inputs/basic3.macho.x86_64.o: +CHECK: 0000000000000020 => 0000000100000f40 _bar +CHECK: 0000000000000070 => 0000000100000f90 _inc +CHECK: 0000000000000004 => 0000000100001004 _val +CHECK: END DEBUG MAP + + +Check that we can parse the debug-map of the basic-lto executable + +CHECK-LTO-NOT: error +CHECK-LTO: DEBUG MAP: x86_64-unknown-unknown-macho +CHECK-LTO: /Inputs/basic-lto.macho.x86_64.o: +CHECK-LTO: 0000000000000050 => 0000000100000f90 _bar +CHECK-LTO: 0000000000000658 => 0000000100001000 _baz +CHECK-LTO: 0000000000000010 => 0000000100000f50 _foo +CHECK-LTO: 0000000000000000 => 0000000100000f40 _main +CHECK-LTO: 00000000000008e8 => 0000000100001008 _private_int +CHECK-LTO: 00000000000008ec => 0000000100001004 _val +CHECK-LTO: END DEBUG MAP + +Check thet we correctly handle debug maps with archive members (including only +opening the archive once if mulitple of its members are used). + +CHECK-ARCHIVE: trying to open {{.*}}basic-archive.macho.x86_64' +CHECK-ARCHIVE-NEXT: loaded file. +CHECK-ARCHIVE-NEXT: trying to open {{.*}}/Inputs/basic1.macho.x86_64.o' +CHECK-ARCHIVE-NEXT: loaded file. +CHECK-ARCHIVE-NEXT: trying to open {{.*}}/libbasic.a(basic2.macho.x86_64.o)' +CHECK-ARCHIVE-NEXT: opened new archive {{.*}}/libbasic.a' +CHECK-ARCHIVE-NEXT: found member in current archive. +CHECK-ARCHIVE-NEXT: trying to open {{.*}}/libbasic.a(basic3.macho.x86_64.o)' +CHECK-ARCHIVE-NEXT: found member in current archive. +CHECK-ARCHIVE: DEBUG MAP: x86_64-unknown-unknown-macho +CHECK-ARCHIVE: object addr => executable addr symbol name +CHECK-ARCHIVE: /Inputs/basic1.macho.x86_64.o: +CHECK-ARCHIVE: 0000000000000000 => 0000000100000ea0 _main +CHECK-ARCHIVE: /Inputs/./libbasic.a(basic2.macho.x86_64.o): +CHECK-ARCHIVE: 0000000000000310 => 0000000100001000 _baz +CHECK-ARCHIVE: 0000000000000020 => 0000000100000ed0 _foo +CHECK-ARCHIVE: 0000000000000070 => 0000000100000f20 _inc +CHECK-ARCHIVE: 0000000000000560 => 0000000100001004 _private_int +CHECK-ARCHIVE: /Inputs/./libbasic.a(basic3.macho.x86_64.o): +CHECK-ARCHIVE: 0000000000000020 => 0000000100000f40 _bar +CHECK-ARCHIVE: 0000000000000070 => 0000000100000f90 _inc +CHECK-ARCHIVE: 0000000000000004 => 0000000100001008 _val +CHECK-ARCHIVE: END DEBUG MAP + +Check that we warn about missing object files (this presumes that the files aren't +present in the machine's /Inputs/ folder, which should be a pretty safe bet). + +NOT-FOUND: cannot open{{.*}}"/Inputs/basic1.macho.x86_64.o": {{[Nn]o}} such file +NOT-FOUND: cannot open{{.*}}"/Inputs/basic2.macho.x86_64.o": {{[Nn]o}} such file +NOT-FOUND: cannot open{{.*}}"/Inputs/basic3.macho.x86_64.o": {{[Nn]o}} such file +NOT-FOUND: DEBUG MAP: +NOT-FOUND-NEXT: object addr => executable addr symbol name +NOT-FOUND-NEXT: END DEBUG MAP + +Check that we correctly error out on invalid executatble. + +NO-EXECUTABLE: cannot parse{{.*}}/inexistant": {{[Nn]o}} such file +NO-EXECUTABLE-NOT: DEBUG MAP |