[RFC PATCH 1/2] gdb, opcodes: Add non-enum disassembler options
Tsukasa OI
research_trasio@irq.a4lg.com
Sat Feb 5 10:24:10 GMT 2022
This commit makes `NULL' value of disasm_option_arg_t.values which
allows arbitrary (non-enum) disassembler options.
gdb/ChangeLog:
* gdb/disasm.c (set_disassembler_options): Add arbitrary non-
enum disassembler options.
(show_disassembler_options_sfunc): Add support for arbitrary
non-enum disassembler options.
include/ChangeLog:
* dis-asm.h (disasm_option_arg_t): Update comment of `values'
to allow arbitrary non-enum disassembler options.
opcodes/ChangeLog:
* riscv-dis.c (print_riscv_disassembler_options): Support
arbitrary non-enum disassembler options on printing help string.
* arc-dis.c (print_arc_disassembler_options): Likewise.
* mips-dis.c (print_mips_disassembler_options): Likewise.
---
gdb/disasm.c | 4 ++++
include/dis-asm.h | 3 ++-
opcodes/arc-dis.c | 2 ++
opcodes/mips-dis.c | 2 ++
opcodes/riscv-dis.c | 2 ++
5 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 5cd1f5adbd2..eb7e2fec9fe 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -1009,6 +1009,8 @@ set_disassembler_options (const char *prospective_options)
if (memcmp (opt, valid_options->name[i], len) != 0)
continue;
arg = opt + len;
+ if (valid_options->arg[i]->values == NULL)
+ break;
for (j = 0; valid_options->arg[i]->values[j] != NULL; j++)
if (disassembler_options_cmp
(arg, valid_options->arg[i]->values[j]) == 0)
@@ -1130,6 +1132,8 @@ The following disassembler options are supported for use with the\n\
for (i = 0; valid_args[i].name != NULL; i++)
{
+ if (valid_args[i].values == NULL)
+ continue;
fprintf_filtered (file, _("\n\
For the options above, the following values are supported for \"%s\":\n "),
valid_args[i].name);
diff --git a/include/dis-asm.h b/include/dis-asm.h
index 317592448a2..1826fe97ba7 100644
--- a/include/dis-asm.h
+++ b/include/dis-asm.h
@@ -239,7 +239,8 @@ typedef struct
/* Option argument name to use in descriptions. */
const char *name;
- /* Vector of acceptable option argument values, NULL-terminated. */
+ /* Vector of acceptable option argument values, NULL-terminated.
+ NULL if any values are accepted. */
const char **values;
} disasm_option_arg_t;
diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c
index 771f786d18e..41371967c3b 100644
--- a/opcodes/arc-dis.c
+++ b/opcodes/arc-dis.c
@@ -1555,6 +1555,8 @@ print_arc_disassembler_options (FILE *stream)
for (i = 0; args[i].name != NULL; ++i)
{
size_t len = 3;
+ if (args[i].values == NULL)
+ continue;
fprintf (stream, _("\n\
For the options above, the following values are supported for \"%s\":\n "),
args[i].name);
diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c
index 9db604ffb39..faeebccfc3b 100644
--- a/opcodes/mips-dis.c
+++ b/opcodes/mips-dis.c
@@ -2809,6 +2809,8 @@ with the -M switch (multiple options should be separated by commas):\n\n"));
for (i = 0; args[i].name != NULL; i++)
{
+ if (args[i].values == NULL)
+ continue;
fprintf (stream, _("\n\
For the options above, the following values are supported for \"%s\":\n "),
args[i].name);
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 34724d4aec5..13ddff01c52 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -1132,6 +1132,8 @@ with the -M switch (multiple options should be separated by commas):\n"));
for (i = 0; args[i].name != NULL; i++)
{
+ if (args[i].values == NULL)
+ continue;
fprintf (stream, _("\n\
For the options above, the following values are supported for \"%s\":\n "),
args[i].name);
--
2.32.0
More information about the Binutils
mailing list