diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -178,6 +178,14 @@ Changes to the LLVM tools --------------------------------- +* ``llvm-readobj --elf-output-style=JSON`` no longer prefixes each JSON object + with the file name. Previously, each object file's output looked like + ``"main.o":{"FileSummary":{"File":"main.o"},...}`` but is now + ``{"FileSummary":{"File":"main.o"},...}``. This allows each JSON object to be + parsed in the same way, since each object no longer has a unique key. Tools + that consume ``llvm-readobj``'s JSON output should update their parsers + accordingly. + Changes to LLDB --------------------------------- diff --git a/llvm/test/tools/llvm-readobj/ELF/file-summary-json.test b/llvm/test/tools/llvm-readobj/ELF/file-summary-json.test --- a/llvm/test/tools/llvm-readobj/ELF/file-summary-json.test +++ b/llvm/test/tools/llvm-readobj/ELF/file-summary-json.test @@ -11,14 +11,12 @@ # 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": "" -# SINGLE-NEXT: } +# 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": "" # SINGLE-NEXT: } # SINGLE-NEXT: } # SINGLE-NEXT:] @@ -30,25 +28,21 @@ # 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": "" -# MULTI-NEXT: } +# 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": "" # 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": "" -# MULTI-NEXT: } +# 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": "" # MULTI-NEXT: } # MULTI-NEXT: } # MULTI-NEXT:] @@ -62,14 +56,12 @@ # 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": "" -# ARCH-SINGLE-NEXT: } +# 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": "" # ARCH-SINGLE-NEXT: } # ARCH-SINGLE-NEXT: } # ARCH-SINGLE-NEXT:] @@ -83,25 +75,21 @@ # 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": "" -# ARCH-MULTI-NEXT: } +# 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": "" # 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": "" -# ARCH-MULTI-NEXT: } +# 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": "" # ARCH-MULTI-NEXT: } # ARCH-MULTI-NEXT: } # ARCH-MULTI-NEXT:] diff --git a/llvm/test/tools/llvm-readobj/ELF/pretty-print.test b/llvm/test/tools/llvm-readobj/ELF/pretty-print.test --- a/llvm/test/tools/llvm-readobj/ELF/pretty-print.test +++ b/llvm/test/tools/llvm-readobj/ELF/pretty-print.test @@ -9,7 +9,6 @@ # NO-PRETTY:[ # NO-PRETTY-SAME:{ -# NO-PRETTY-SAME:"{{.*}}.pretty":{ # NO-PRETTY-SAME:"FileSummary":{ # NO-PRETTY-SAME:"File":"{{.*}}.pretty", # NO-PRETTY-SAME:"Format":"elf64-x86-64", @@ -18,7 +17,6 @@ # NO-PRETTY-SAME:"LoadName":"" # NO-PRETTY-SAME:} # NO-PRETTY-SAME:} -# NO-PRETTY-SAME:} # NO-PRETTY-SAME:] ## Test JSON with pretty-print on. @@ -28,14 +26,12 @@ # PRETTY:[ # PRETTY-NEXT: { -# PRETTY-NEXT: "{{.*}}.pretty": { -# 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": "" -# 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": "" # PRETTY-NEXT: } # PRETTY-NEXT: } # PRETTY-NEXT:] diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -7508,7 +7508,7 @@ void JSONELFDumper::printFileSummary(StringRef FileStr, ObjectFile &Obj, ArrayRef InputFilenames, const Archive *A) { - FileScope = std::make_unique(this->W, FileStr); + FileScope = std::make_unique(this->W); DictScope D(this->W, "FileSummary"); this->W.printString("File", FileStr); this->W.printString("Format", Obj.getFileFormatName());