Adds JSONScopedPrinter to llvm-readelf. It includes an empty JSONELFDumper class which will be used to override any LLVMELFDumper methods which utilize startLine() which JSONScopedPrinter cannot provide. This introduces a change where calls to llvm-readelf with non-ELF object files that specify --elf-output-style=GNU will now print file summary information where it previously didn't. Fixes previous Windows test failure which occured due to JSON escaping of '\' by not relying on LIT substitution. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D114225
115 lines
4.0 KiB
Plaintext
115 lines
4.0 KiB
Plaintext
## Test how we output JSON file summaries.
|
|
|
|
# RUN: rm -rf %t.dir
|
|
# RUN: mkdir -p %t.dir
|
|
# RUN: yaml2obj %s -o %t.dir/obj
|
|
|
|
## Test outputting file summary for a single file.
|
|
# RUN: llvm-readobj --elf-output-style=JSON --pretty-print %t.dir/obj | \
|
|
# RUN: FileCheck %s --check-prefix=SINGLE \
|
|
# RUN: --match-full-lines --strict-whitespace --implicit-check-not={{.}}
|
|
|
|
# SINGLE:[
|
|
# SINGLE-NEXT: {
|
|
# SINGLE-NEXT: "{{.*}}/obj": {
|
|
# SINGLE-NEXT: "FileSummary": {
|
|
# SINGLE-NEXT: "File": "{{.*}}/obj",
|
|
# SINGLE-NEXT: "Format": "elf64-x86-64",
|
|
# SINGLE-NEXT: "Arch": "x86_64",
|
|
# SINGLE-NEXT: "AddressSize": "64bit",
|
|
# SINGLE-NEXT: "LoadName": "<Not found>"
|
|
# SINGLE-NEXT: }
|
|
# SINGLE-NEXT: }
|
|
# SINGLE-NEXT: }
|
|
# SINGLE-NEXT:]
|
|
|
|
## Test outputting file summary for multiple files.
|
|
# RUN: llvm-readobj --elf-output-style=JSON --pretty-print %t.dir/obj %t.dir/obj | \
|
|
# RUN: FileCheck %s --check-prefix=MULTI \
|
|
# RUN: --match-full-lines --strict-whitespace --implicit-check-not={{.}}
|
|
|
|
# MULTI:[
|
|
# MULTI-NEXT: {
|
|
# MULTI-NEXT: "{{.*}}/obj": {
|
|
# MULTI-NEXT: "FileSummary": {
|
|
# MULTI-NEXT: "File": "{{.*}}/obj",
|
|
# MULTI-NEXT: "Format": "elf64-x86-64",
|
|
# MULTI-NEXT: "Arch": "x86_64",
|
|
# MULTI-NEXT: "AddressSize": "64bit",
|
|
# MULTI-NEXT: "LoadName": "<Not found>"
|
|
# MULTI-NEXT: }
|
|
# MULTI-NEXT: }
|
|
# MULTI-NEXT: },
|
|
# MULTI-NEXT: {
|
|
# MULTI-NEXT: "{{.*}}/obj": {
|
|
# MULTI-NEXT: "FileSummary": {
|
|
# MULTI-NEXT: "File": "{{.*}}/obj",
|
|
# MULTI-NEXT: "Format": "elf64-x86-64",
|
|
# MULTI-NEXT: "Arch": "x86_64",
|
|
# MULTI-NEXT: "AddressSize": "64bit",
|
|
# MULTI-NEXT: "LoadName": "<Not found>"
|
|
# MULTI-NEXT: }
|
|
# MULTI-NEXT: }
|
|
# MULTI-NEXT: }
|
|
# MULTI-NEXT:]
|
|
|
|
## Test outputting file summary for an archive with a single file.
|
|
# RUN: rm -f %t.archive-single
|
|
# RUN: llvm-ar rc %t.archive-single %t.dir/obj
|
|
# RUN: llvm-readobj --elf-output-style=JSON --pretty-print %t.archive-single | \
|
|
# RUN: FileCheck %s --check-prefix=ARCH-SINGLE \
|
|
# RUN: --match-full-lines --strict-whitespace --implicit-check-not={{.}}
|
|
|
|
# ARCH-SINGLE:[
|
|
# ARCH-SINGLE-NEXT: {
|
|
# ARCH-SINGLE-NEXT: "{{.*}}.archive-single(obj)": {
|
|
# ARCH-SINGLE-NEXT: "FileSummary": {
|
|
# ARCH-SINGLE-NEXT: "File": "{{.*}}.archive-single(obj)",
|
|
# ARCH-SINGLE-NEXT: "Format": "elf64-x86-64",
|
|
# ARCH-SINGLE-NEXT: "Arch": "x86_64",
|
|
# ARCH-SINGLE-NEXT: "AddressSize": "64bit",
|
|
# ARCH-SINGLE-NEXT: "LoadName": "<Not found>"
|
|
# ARCH-SINGLE-NEXT: }
|
|
# ARCH-SINGLE-NEXT: }
|
|
# ARCH-SINGLE-NEXT: }
|
|
# ARCH-SINGLE-NEXT:]
|
|
|
|
## Test outputting file summary for an archive with multiple files.
|
|
# RUN: rm -f %t.archive-multiple
|
|
# RUN: llvm-ar rc %t.archive-multiple %t.dir/obj %t.dir/obj
|
|
# RUN: llvm-readobj --elf-output-style=JSON --pretty-print %t.archive-multiple | \
|
|
# RUN: FileCheck %s --check-prefix=ARCH-MULTI \
|
|
# RUN: --match-full-lines --strict-whitespace --implicit-check-not={{.}}
|
|
|
|
# ARCH-MULTI:[
|
|
# ARCH-MULTI-NEXT: {
|
|
# ARCH-MULTI-NEXT: "{{.*}}.archive-multiple(obj)": {
|
|
# ARCH-MULTI-NEXT: "FileSummary": {
|
|
# ARCH-MULTI-NEXT: "File": "{{.*}}.archive-multiple(obj)",
|
|
# ARCH-MULTI-NEXT: "Format": "elf64-x86-64",
|
|
# ARCH-MULTI-NEXT: "Arch": "x86_64",
|
|
# ARCH-MULTI-NEXT: "AddressSize": "64bit",
|
|
# ARCH-MULTI-NEXT: "LoadName": "<Not found>"
|
|
# ARCH-MULTI-NEXT: }
|
|
# ARCH-MULTI-NEXT: }
|
|
# ARCH-MULTI-NEXT: },
|
|
# ARCH-MULTI-NEXT: {
|
|
# ARCH-MULTI-NEXT: "{{.*}}.archive-multiple(obj)": {
|
|
# ARCH-MULTI-NEXT: "FileSummary": {
|
|
# ARCH-MULTI-NEXT: "File": "{{.*}}.archive-multiple(obj)",
|
|
# ARCH-MULTI-NEXT: "Format": "elf64-x86-64",
|
|
# ARCH-MULTI-NEXT: "Arch": "x86_64",
|
|
# ARCH-MULTI-NEXT: "AddressSize": "64bit",
|
|
# ARCH-MULTI-NEXT: "LoadName": "<Not found>"
|
|
# ARCH-MULTI-NEXT: }
|
|
# ARCH-MULTI-NEXT: }
|
|
# ARCH-MULTI-NEXT: }
|
|
# ARCH-MULTI-NEXT:]
|
|
|
|
--- !ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_REL
|
|
Machine: EM_X86_64
|