Paul Kirth aa123b8c09 [llvm-readobj] Improve JSON output
The current implementation outputs JSON in the following way:

[{'<filename>':{'FileSummary':{},...}}]

Using the filename as a key makes processing the JSON data awkward, and
should be avoided. This patch removes that outer key, since the
'FileSummary' data also includes a 'File' field, and so we lose no data.

Reviewed By: jhenderson, leonardchan

Differential Revision: https://reviews.llvm.org/D134843
2022-10-17 16:42:57 +00:00

45 lines
1.3 KiB
Plaintext

## Test the JSON pretty-print flag.
#
# RUN: yaml2obj %s -o %t.pretty
## Test JSON with pretty-print off.
# RUN: llvm-readobj --elf-output-style=JSON %t.pretty | \
# RUN: FileCheck %s --check-prefix=NO-PRETTY \
# RUN: --strict-whitespace --implicit-check-not={{.}}
# NO-PRETTY:[
# NO-PRETTY-SAME:{
# NO-PRETTY-SAME:"FileSummary":{
# NO-PRETTY-SAME:"File":"{{.*}}.pretty",
# NO-PRETTY-SAME:"Format":"elf64-x86-64",
# NO-PRETTY-SAME:"Arch":"x86_64",
# NO-PRETTY-SAME:"AddressSize":"64bit",
# NO-PRETTY-SAME:"LoadName":"<Not found>"
# NO-PRETTY-SAME:}
# NO-PRETTY-SAME:}
# NO-PRETTY-SAME:]
## Test JSON with pretty-print on.
# RUN: llvm-readobj --elf-output-style=JSON --pretty-print %t.pretty | \
# RUN: FileCheck %s --check-prefix=PRETTY \
# RUN: --match-full-lines --strict-whitespace --implicit-check-not={{.}}
# PRETTY:[
# PRETTY-NEXT: {
# PRETTY-NEXT: "FileSummary": {
# PRETTY-NEXT: "File": "{{.*}}.pretty",
# PRETTY-NEXT: "Format": "elf64-x86-64",
# PRETTY-NEXT: "Arch": "x86_64",
# PRETTY-NEXT: "AddressSize": "64bit",
# PRETTY-NEXT: "LoadName": "<Not found>"
# PRETTY-NEXT: }
# PRETTY-NEXT: }
# PRETTY-NEXT:]
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64