summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2016-10-26 01:42:59 +0000
committerDean Michael Berris <dberris@google.com>2016-10-26 01:42:59 +0000
commitd21e0a7ba74da20bb06b7ad3366d9299bb33feed (patch)
tree96d865d14cb053462ca1a2e12c063bdb35115b82 /llvm/test
parenteb1bf312d5a7896184f12b1cba10e90cccfba181 (diff)
downloadbcm5719-llvm-d21e0a7ba74da20bb06b7ad3366d9299bb33feed.tar.gz
bcm5719-llvm-d21e0a7ba74da20bb06b7ad3366d9299bb33feed.zip
[XRay] Implement `llvm-xray extract`, start of the llvm-xray tool
Usage: llvm-xray extract <object file> [-o <filename or '-'>] The tool gets the XRay instrumentation map from an object file and turns it into YAML. We first support ELF64 sleds on x86_64 binaries, with provision for supporting other supported platforms and formats later. This is the first of a many-part change to fully implement the `llvm-xray` tool. We also define a subcommand registration and dispatch mechanism to be used by other further subcommand implementations for llvm-xray. llvm-svn: 285155
Diffstat (limited to 'llvm/test')
-rwxr-xr-xllvm/test/tools/llvm-xray/X86/Inputs/elf32-noxray.binbin0 -> 7294 bytes
-rwxr-xr-xllvm/test/tools/llvm-xray/X86/Inputs/elf64-badentrysizes.binbin0 -> 469664 bytes
-rwxr-xr-xllvm/test/tools/llvm-xray/X86/Inputs/elf64-example.binbin0 -> 469664 bytes
-rwxr-xr-xllvm/test/tools/llvm-xray/X86/Inputs/elf64-noinstr-map.binbin0 -> 8479 bytes
-rw-r--r--llvm/test/tools/llvm-xray/X86/Inputs/empty-file.bin0
-rw-r--r--llvm/test/tools/llvm-xray/X86/bad-instrmap-sizes.bin3
-rw-r--r--llvm/test/tools/llvm-xray/X86/empty.txt4
-rw-r--r--llvm/test/tools/llvm-xray/X86/extract-instrmap.ll15
-rw-r--r--llvm/test/tools/llvm-xray/X86/lit.local.cfg1
-rw-r--r--llvm/test/tools/llvm-xray/X86/no-instr-map.txt4
-rw-r--r--llvm/test/tools/llvm-xray/X86/no-such-file.txt4
-rw-r--r--llvm/test/tools/llvm-xray/X86/unsupported-elf32.txt3
12 files changed, 34 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-xray/X86/Inputs/elf32-noxray.bin b/llvm/test/tools/llvm-xray/X86/Inputs/elf32-noxray.bin
new file mode 100755
index 00000000000..06446e71a87
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/X86/Inputs/elf32-noxray.bin
Binary files differ
diff --git a/llvm/test/tools/llvm-xray/X86/Inputs/elf64-badentrysizes.bin b/llvm/test/tools/llvm-xray/X86/Inputs/elf64-badentrysizes.bin
new file mode 100755
index 00000000000..702ea1484df
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/X86/Inputs/elf64-badentrysizes.bin
Binary files differ
diff --git a/llvm/test/tools/llvm-xray/X86/Inputs/elf64-example.bin b/llvm/test/tools/llvm-xray/X86/Inputs/elf64-example.bin
new file mode 100755
index 00000000000..a6e6d3d6468
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/X86/Inputs/elf64-example.bin
Binary files differ
diff --git a/llvm/test/tools/llvm-xray/X86/Inputs/elf64-noinstr-map.bin b/llvm/test/tools/llvm-xray/X86/Inputs/elf64-noinstr-map.bin
new file mode 100755
index 00000000000..6f2d9d21f2e
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/X86/Inputs/elf64-noinstr-map.bin
Binary files differ
diff --git a/llvm/test/tools/llvm-xray/X86/Inputs/empty-file.bin b/llvm/test/tools/llvm-xray/X86/Inputs/empty-file.bin
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/X86/Inputs/empty-file.bin
diff --git a/llvm/test/tools/llvm-xray/X86/bad-instrmap-sizes.bin b/llvm/test/tools/llvm-xray/X86/bad-instrmap-sizes.bin
new file mode 100644
index 00000000000..4ea33510e5d
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/X86/bad-instrmap-sizes.bin
@@ -0,0 +1,3 @@
+; RUN: not llvm-xray extract %S/Inputs/elf64-badentrysizes.bin 2>&1 | FileCheck %s
+; CHECK: llvm-xray: Cannot extract instrumentation map from '{{.*}}elf64-badentrysizes.bin'.
+; CHECK-NEXT: Instrumentation map entries not evenly divisible by size of an XRay sled entry in ELF64.
diff --git a/llvm/test/tools/llvm-xray/X86/empty.txt b/llvm/test/tools/llvm-xray/X86/empty.txt
new file mode 100644
index 00000000000..65dd2b747dd
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/X86/empty.txt
@@ -0,0 +1,4 @@
+; RUN: not llvm-xray extract %S/Inputs/empty-file.bin 2>&1 | FileCheck %s
+
+; CHECK: llvm-xray: Cannot extract instrumentation map from '{{.*}}empty-file.bin'.
+; CHECK-NEXT: The file was not recognized as a valid object file
diff --git a/llvm/test/tools/llvm-xray/X86/extract-instrmap.ll b/llvm/test/tools/llvm-xray/X86/extract-instrmap.ll
new file mode 100644
index 00000000000..8155d57f814
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/X86/extract-instrmap.ll
@@ -0,0 +1,15 @@
+; This test makes sure we can extract the instrumentation map from an
+; XRay-instrumented object file.
+;
+; RUN: llvm-xray extract %S/Inputs/elf64-example.bin | FileCheck %s
+
+; CHECK: ---
+; CHECK-NEXT: - { id: 1, address: 0x000000000041C900, function: 0x000000000041C900, kind: function-enter,
+; CHECK-NEXT: always-instrument: true }
+; CHECK-NEXT: - { id: 1, address: 0x000000000041C912, function: 0x000000000041C900, kind: function-exit,
+; CHECK-NEXT: always-instrument: true }
+; CHECK-NEXT: - { id: 2, address: 0x000000000041C930, function: 0x000000000041C930, kind: function-enter,
+; CHECK-NEXT: always-instrument: true }
+; CHECK-NEXT: - { id: 2, address: 0x000000000041C946, function: 0x000000000041C930, kind: function-exit,
+; CHECK-NEXT: always-instrument: true }
+; CHECK-NEXT: ...
diff --git a/llvm/test/tools/llvm-xray/X86/lit.local.cfg b/llvm/test/tools/llvm-xray/X86/lit.local.cfg
new file mode 100644
index 00000000000..4f00369e13d
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/X86/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.yaml', '.ll', '.txt']
diff --git a/llvm/test/tools/llvm-xray/X86/no-instr-map.txt b/llvm/test/tools/llvm-xray/X86/no-instr-map.txt
new file mode 100644
index 00000000000..c256c071376
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/X86/no-instr-map.txt
@@ -0,0 +1,4 @@
+; RUN: not llvm-xray extract %S/Inputs/elf64-noinstr-map.bin 2>&1 | FileCheck %s
+
+; CHECK: llvm-xray: Cannot extract instrumentation map from '{{.*}}elf64-noinstr-map.bin'.
+; CHECK-NEXT: Failed to find XRay instrumentation map.
diff --git a/llvm/test/tools/llvm-xray/X86/no-such-file.txt b/llvm/test/tools/llvm-xray/X86/no-such-file.txt
new file mode 100644
index 00000000000..0bc0b5b946a
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/X86/no-such-file.txt
@@ -0,0 +1,4 @@
+; RUN: not llvm-xray extract no-such-file 2>&1 | FileCheck %s
+
+; CHECK: llvm-xray: Cannot extract instrumentation map from 'no-such-file'.
+; CHECK-NEXT: No such file or directory
diff --git a/llvm/test/tools/llvm-xray/X86/unsupported-elf32.txt b/llvm/test/tools/llvm-xray/X86/unsupported-elf32.txt
new file mode 100644
index 00000000000..1dde47327dc
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/X86/unsupported-elf32.txt
@@ -0,0 +1,3 @@
+; RUN: not llvm-xray extract %S/Inputs/elf32-noxray.bin 2>&1 | FileCheck %s
+; CHECK: llvm-xray: Cannot extract instrumentation map from '{{.*}}elf32-noxray.bin'.
+; CHECK-NEXT: File format not supported (only does ELF little endian 64-bit).
OpenPOWER on IntegriCloud