From 26fb3983d7062c6f6bc43028ae2074cc29d22c7e Mon Sep 17 00:00:00 2001 From: Jan Vrany Date: Tue, 14 Aug 2018 14:13:28 +0100 Subject: MI: Add -a option to the "-data-disassemble" command The CLI "disassemble" command allows specifying a single address - in that case the function surrounding that address is disassembled. This commit adds this feature to the equivalent MI command "-data-disassemble". gdb/ChangeLog: 2018-08-14 Jan Vrany * mi/mi-cmd-disas.c (mi_cmd_disassemble): Add -a option. If used, use find_pc_partial_function to find address range to disassemble. * mi/mi-main.c (mi_cmd_list_features): Report "data-disassemble-a-option" feature. * NEWS: Mention new -data-disassemble option -a. gdb/doc/ChangeLog: 2018-08-14 Jan Vrany * gdb.texinfo (GDB/MI Data Manipulation): Document "-data-disassemble -a addr". (GDB/MI Support Commands): Document "data-disassemble-a-option" feature. gdb/testsuite/ChangeLog: 2018-08-14 Jan Vrany * gdb.mi/mi-disassemble.exp (test_disassembly_only): Add tests for -data-disassemble -a. (test_disassembly_bogus_args): Likewise. --- gdb/mi/mi-cmd-disas.c | 36 ++++++++++++++++++++++++++---------- gdb/mi/mi-main.c | 1 + 2 files changed, 27 insertions(+), 10 deletions(-) (limited to 'gdb/mi') diff --git a/gdb/mi/mi-cmd-disas.c b/gdb/mi/mi-cmd-disas.c index e704e35..f0f2635 100644 --- a/gdb/mi/mi-cmd-disas.c +++ b/gdb/mi/mi-cmd-disas.c @@ -67,6 +67,7 @@ mi_cmd_disassemble (const char *command, char **argv, int argc) int num_seen = 0; int start_seen = 0; int end_seen = 0; + int addr_seen = 0; /* ... and their corresponding value. */ char *file_string = NULL; @@ -74,13 +75,14 @@ mi_cmd_disassemble (const char *command, char **argv, int argc) int how_many = -1; CORE_ADDR low = 0; CORE_ADDR high = 0; + CORE_ADDR addr = 0; /* Options processing stuff. */ int oind = 0; char *oarg; enum opt { - FILE_OPT, LINE_OPT, NUM_OPT, START_OPT, END_OPT + FILE_OPT, LINE_OPT, NUM_OPT, START_OPT, END_OPT, ADDR_OPT }; static const struct mi_opt opts[] = { @@ -89,6 +91,7 @@ mi_cmd_disassemble (const char *command, char **argv, int argc) {"n", NUM_OPT, 1}, {"s", START_OPT, 1}, {"e", END_OPT, 1}, + {"a", ADDR_OPT, 1}, { 0, 0, 0 } }; @@ -122,23 +125,30 @@ mi_cmd_disassemble (const char *command, char **argv, int argc) high = parse_and_eval_address (oarg); end_seen = 1; break; + case ADDR_OPT: + addr = parse_and_eval_address (oarg); + addr_seen = 1; + break; } } argv += oind; argc -= oind; /* Allow only filename + linenum (with how_many which is not - required) OR start_addr + end_addr. */ + required) OR start_addr + end_addr OR addr. */ + + if (!( + ( line_seen && file_seen && !start_seen && !end_seen + && !addr_seen) - if (!((line_seen && file_seen && num_seen && !start_seen && !end_seen) - || (line_seen && file_seen && !num_seen && !start_seen && !end_seen) - || (!line_seen && !file_seen && !num_seen && start_seen && end_seen))) - error (_("-data-disassemble: Usage: ( [-f filename -l linenum [-n " - "howmany]] | [-s startaddr -e endaddr]) [--] mode.")); + || (!line_seen && !file_seen && !num_seen && start_seen && end_seen + && !addr_seen) - if (argc != 1) - error (_("-data-disassemble: Usage: [-f filename -l linenum " - "[-n howmany]] [-s startaddr -e endaddr] [--] mode.")); + || (!line_seen && !file_seen && !num_seen && !start_seen && !end_seen + && addr_seen)) + || argc != 1) + error (_("-data-disassemble: Usage: ( [-f filename -l linenum " + "[-n howmany]] | [-s startaddr -e endaddr] | [-a addr] ) [--] mode.")); mode = atoi (argv[0]); if (mode < 0 || mode > 5) @@ -184,6 +194,12 @@ mi_cmd_disassemble (const char *command, char **argv, int argc) error (_("-data-disassemble: " "No function contains specified address")); } + else if (addr_seen) + { + if (find_pc_partial_function (addr, NULL, &low, &high) == 0) + error (_("-data-disassemble: " + "No function contains specified address")); + } gdb_disassembly (gdbarch, uiout, disasm_flags, diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 2163d42..1e31040 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1683,6 +1683,7 @@ mi_cmd_list_features (const char *command, char **argv, int argc) uiout->field_string (NULL, "info-gdb-mi-command"); uiout->field_string (NULL, "undefined-command-error-code"); uiout->field_string (NULL, "exec-run-start-option"); + uiout->field_string (NULL, "data-disassemble-a-option"); if (ext_lang_initialized_p (get_ext_lang_defn (EXT_LANG_PYTHON))) uiout->field_string (NULL, "python"); -- cgit v1.1