[llvm-objdump] Support arg grouping for -j and -M (e.g. llvm-objdump -sj.foo -dMreg-names-raw)

Summary:
r354375 added support for most objdump groupings, but didn't add support for -j|--sections, because that wasn't possible.
r354870 added --disassembler options, but grouping still wasn't available.
r355185 supported values for grouped options.

This just puts the three of them together. This supports -j in modes like `-s -j .foo`, `-sj .foo`, `-sj=.foo`, or `-sj.foo`, and similar for `-M`.

Reviewers: ormris, jhenderson, ikudrin

Reviewed By: jhenderson, ikudrin

Subscribers: javed.absar, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59618

llvm-svn: 356697
This commit is contained in:
Jordan Rupprecht 2019-03-21 18:45:44 +00:00
parent 06a9c72d3d
commit 360c997b66
3 changed files with 42 additions and 6 deletions

View File

@ -12,6 +12,24 @@
@ RUN: | FileCheck -check-prefix=ERR %s
@ ERR: Unrecognized disassembler option: unknown
@ Test that the -M alias can be used flexibly. Create a baseline and ensure
@ all other combinations are identical.
@ RUN: llvm-objdump -d --disassembler-options=reg-names-raw %t > %t.raw
@ RUN: llvm-objdump -d -M reg-names-raw %t > %t.1
@ RUN: llvm-objdump -d -Mreg-names-raw %t > %t.2
@ RUN: llvm-objdump -d -Mreg-names-std -Mreg-names-raw %t > %t.3
@ RUN: llvm-objdump -d -Mreg-names-std,reg-names-raw %t > %t.4
@ RUN: llvm-objdump -dM reg-names-std,reg-names-raw %t > %t.5
@ RUN: llvm-objdump -dMreg-names-std,reg-names-raw %t > %t.6
@ RUN: llvm-objdump -dMreg-names-std -Mreg-names-raw %t > %t.7
@ RUN: cmp %t.raw %t.1
@ RUN: cmp %t.raw %t.2
@ RUN: cmp %t.raw %t.3
@ RUN: cmp %t.raw %t.4
@ RUN: cmp %t.raw %t.5
@ RUN: cmp %t.raw %t.6
@ RUN: cmp %t.raw %t.7
.text
add r13, r14, r15
@ STD: add sp, lr, pc

View File

@ -1,7 +1,24 @@
// This test checks that --section works correctly
// This test checks that --section works correctly.
// RUN: llvm-objdump -h %p/Inputs/section-filter.obj -j=.text \
// RUN: --section=.bss | FileCheck %s
# CHECK: .text
# CHECK-NOT: .data
# CHECK: .bss
// CHECK: .text
// CHECK-NOT: .data
// CHECK: .bss
// Test that the -j alias can be used flexibly. Create a baseline and ensure
// all other combinations are identical.
// RUN: llvm-objdump %p/Inputs/section-filter.obj -h -s --section .symtab > %t.full
// RUN: llvm-objdump %p/Inputs/section-filter.obj -h -s -j .symtab > %t.1
// RUN: llvm-objdump %p/Inputs/section-filter.obj -h -s -j=.symtab > %t.2
// RUN: llvm-objdump %p/Inputs/section-filter.obj -h -s -j.symtab > %t.3
// RUN: llvm-objdump %p/Inputs/section-filter.obj -hsj .symtab > %t.4
// RUN: llvm-objdump %p/Inputs/section-filter.obj -hsj=.symtab > %t.5
// RUN: llvm-objdump %p/Inputs/section-filter.obj -hsj.symtab > %t.6
// RUN: cmp %t.full %t.1
// RUN: cmp %t.full %t.2
// RUN: cmp %t.full %t.3
// RUN: cmp %t.full %t.4
// RUN: cmp %t.full %t.5
// RUN: cmp %t.full %t.6

View File

@ -197,7 +197,7 @@ cl::list<std::string>
llvm::FilterSections("section", cl::desc("Operate on the specified sections only. "
"With -macho dump segment,section"));
cl::alias static FilterSectionsj("j", cl::desc("Alias for --section"),
cl::NotHidden,
cl::NotHidden, cl::Grouping, cl::Prefix,
cl::aliasopt(llvm::FilterSections));
cl::list<std::string>
@ -299,7 +299,8 @@ static cl::list<std::string>
cl::value_desc("options"), cl::CommaSeparated);
static cl::alias
DisassemblerOptionsShort("M", cl::desc("Alias for --disassembler-options"),
cl::NotHidden, cl::Prefix, cl::CommaSeparated,
cl::NotHidden, cl::Grouping, cl::Prefix,
cl::CommaSeparated,
cl::aliasopt(DisassemblerOptions));
static StringRef ToolName;