Skip to content

Commit ae672b4

Browse files
committed
[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
1 parent c2e4405 commit ae672b4

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

llvm/test/tools/llvm-objdump/ARM/reg-names.s

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@
1212
@ RUN: | FileCheck -check-prefix=ERR %s
1313
@ ERR: Unrecognized disassembler option: unknown
1414

15+
@ Test that the -M alias can be used flexibly. Create a baseline and ensure
16+
@ all other combinations are identical.
17+
@ RUN: llvm-objdump -d --disassembler-options=reg-names-raw %t > %t.raw
18+
@ RUN: llvm-objdump -d -M reg-names-raw %t > %t.1
19+
@ RUN: llvm-objdump -d -Mreg-names-raw %t > %t.2
20+
@ RUN: llvm-objdump -d -Mreg-names-std -Mreg-names-raw %t > %t.3
21+
@ RUN: llvm-objdump -d -Mreg-names-std,reg-names-raw %t > %t.4
22+
@ RUN: llvm-objdump -dM reg-names-std,reg-names-raw %t > %t.5
23+
@ RUN: llvm-objdump -dMreg-names-std,reg-names-raw %t > %t.6
24+
@ RUN: llvm-objdump -dMreg-names-std -Mreg-names-raw %t > %t.7
25+
@ RUN: cmp %t.raw %t.1
26+
@ RUN: cmp %t.raw %t.2
27+
@ RUN: cmp %t.raw %t.3
28+
@ RUN: cmp %t.raw %t.4
29+
@ RUN: cmp %t.raw %t.5
30+
@ RUN: cmp %t.raw %t.6
31+
@ RUN: cmp %t.raw %t.7
32+
1533
.text
1634
add r13, r14, r15
1735
@ STD: add sp, lr, pc
Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1-
// This test checks that --section works correctly
1+
// This test checks that --section works correctly.
22
// RUN: llvm-objdump -h %p/Inputs/section-filter.obj -j=.text \
33
// RUN: --section=.bss | FileCheck %s
44

5-
# CHECK: .text
6-
# CHECK-NOT: .data
7-
# CHECK: .bss
5+
// CHECK: .text
6+
// CHECK-NOT: .data
7+
// CHECK: .bss
8+
9+
// Test that the -j alias can be used flexibly. Create a baseline and ensure
10+
// all other combinations are identical.
11+
// RUN: llvm-objdump %p/Inputs/section-filter.obj -h -s --section .symtab > %t.full
12+
// RUN: llvm-objdump %p/Inputs/section-filter.obj -h -s -j .symtab > %t.1
13+
// RUN: llvm-objdump %p/Inputs/section-filter.obj -h -s -j=.symtab > %t.2
14+
// RUN: llvm-objdump %p/Inputs/section-filter.obj -h -s -j.symtab > %t.3
15+
// RUN: llvm-objdump %p/Inputs/section-filter.obj -hsj .symtab > %t.4
16+
// RUN: llvm-objdump %p/Inputs/section-filter.obj -hsj=.symtab > %t.5
17+
// RUN: llvm-objdump %p/Inputs/section-filter.obj -hsj.symtab > %t.6
18+
19+
// RUN: cmp %t.full %t.1
20+
// RUN: cmp %t.full %t.2
21+
// RUN: cmp %t.full %t.3
22+
// RUN: cmp %t.full %t.4
23+
// RUN: cmp %t.full %t.5
24+
// RUN: cmp %t.full %t.6

llvm/tools/llvm-objdump/llvm-objdump.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ cl::list<std::string>
197197
llvm::FilterSections("section", cl::desc("Operate on the specified sections only. "
198198
"With -macho dump segment,section"));
199199
cl::alias static FilterSectionsj("j", cl::desc("Alias for --section"),
200-
cl::NotHidden,
200+
cl::NotHidden, cl::Grouping, cl::Prefix,
201201
cl::aliasopt(llvm::FilterSections));
202202

203203
cl::list<std::string>
@@ -299,7 +299,8 @@ static cl::list<std::string>
299299
cl::value_desc("options"), cl::CommaSeparated);
300300
static cl::alias
301301
DisassemblerOptionsShort("M", cl::desc("Alias for --disassembler-options"),
302-
cl::NotHidden, cl::Prefix, cl::CommaSeparated,
302+
cl::NotHidden, cl::Grouping, cl::Prefix,
303+
cl::CommaSeparated,
303304
cl::aliasopt(DisassemblerOptions));
304305

305306
static StringRef ToolName;

0 commit comments

Comments
 (0)