+2018-08-14 Jan Vrany <jan.vrany@fit.cvut.cz>
+
+ * 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.
+
2018-08-13 Tom Tromey <tom@tromey.com>
* common/common-defs.h (_FORTIFY_SOURCE): Define.
FLAG arguments allow to control what output to produce and how to handle
errors raised when applying COMMAND to a thread.
+* MI changes
+
+ ** The '-data-disassemble' MI command now accepts an '-a' option to
+ disassemble the whole function surrounding the given program
+ counter value or function name. Support for this feature can be
+ verified by using the "-list-features" command, which should
+ contain "data-disassemble-a-option".
+
* New native configurations
GNU/Linux/RISC-V riscv*-*-linux*
+2018-08-14 Jan Vrany <jan.vrany@fit.cvut.cz>
+
+ * gdb.texinfo (GDB/MI Data Manipulation): Document
+ "-data-disassemble -a addr".
+ (GDB/MI Support Commands): Document "data-disassemble-a-option"
+ feature.
+
2018-08-07 Simon Marchi <simon.marchi@ericsson.com>
* gdb.texinfo (Index Files Speed Up GDB): Add section about
@smallexample
-data-disassemble
[ -s @var{start-addr} -e @var{end-addr} ]
+ | [ -a @var{addr} ]
| [ -f @var{filename} -l @var{linenum} [ -n @var{lines} ] ]
-- @var{mode}
@end smallexample
is the beginning address (or @code{$pc})
@item @var{end-addr}
is the end address
+@item @var{addr}
+is an address anywhere within (or the name of) the function to
+disassemble. If an address is specified, the whole function
+surrounding that address will be disassembled. If a name is
+specified, the whole function with that name will be disassembled.
@item @var{filename}
is the name of the file to disassemble
@item @var{linenum}
@item exec-run-start-option
Indicates that the @code{-exec-run} command supports the @option{--start}
option (@pxref{GDB/MI Program Execution}).
+@item data-disassemble-a-option
+Indicates that the @code{-data-disassemble} command supports the @option{-a}
+option (@pxref{GDB/MI Data Manipulation}).
@end ftable
@subheading The @code{-list-target-features} Command
int num_seen = 0;
int start_seen = 0;
int end_seen = 0;
+ int addr_seen = 0;
/* ... and their corresponding value. */
char *file_string = NULL;
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[] =
{
{"n", NUM_OPT, 1},
{"s", START_OPT, 1},
{"e", END_OPT, 1},
+ {"a", ADDR_OPT, 1},
{ 0, 0, 0 }
};
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)
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,
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");
+2018-08-14 Jan Vrany <jan.vrany@fit.cvut.cz>
+
+ * gdb.mi/mi-disassemble.exp (test_disassembly_only): Add tests for
+ -data-disassemble -a.
+ (test_disassembly_bogus_args): Likewise.
+
2018-08-14 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.mi/list-thread-groups-available.exp: Update test regexp.
# Test disassembly more only for the current function.
# Tests:
# -data-disassemble -s $pc -e "$pc+8" -- 0
+ # -data-disassemble -a $pc -- 0
+ # -data-disassemble -a callee4 -- 0
# -data-disassembly -f basics.c -l $line_main_body -- 0
+
mi_gdb_test "print/x \$pc" "" ""
mi_gdb_test "111-data-disassemble -s \$pc -e \"\$pc + 12\" -- 0" \
"111\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\},\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\]" \
"data-disassemble from pc to pc+12 assembly only"
+ mi_gdb_test "112-data-disassemble -a \$pc -- 0" \
+ "112\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\},\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\]" \
+ "data-disassemble function around pc assembly only"
+
+ mi_gdb_test "113-data-disassemble -a callee4 -- 0" \
+ "113\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"callee4\",offset=\"$decimal\",inst=\".*\"\},\{address=\"$hex\",func-name=\"callee4\",offset=\"$decimal\",inst=\".*\"\}.*\]" \
+ "data-disassemble function callee4 assembly only"
+
mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -- 0" \
"222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \
"data-disassemble file & line, assembly only"
# Tests:
# -data-disassembly -f foo -l abc -n 0 -- 0
# -data-disassembly -s foo -e bar -- 0
+ # -data-disassembly -a foo -- 0
# -data-disassembly -s $pc -f basics.c -- 0
# -data-disassembly -f basics.c -l 32 -- 9
mi_gdb_test "321-data-disassemble -s foo -e bar -- 0" \
"321\\^error,msg=\"No symbol \\\\\"foo\\\\\" in current context.\"" \
- "data-disassemble bogus address"
+ "data-disassemble bogus address, -s -e"
+
+ mi_gdb_test "322-data-disassemble -a foo -- 0" \
+ "322\\^error,msg=\"No symbol \\\\\"foo\\\\\" in current context.\"" \
+ "data-disassemble bogus address, -a"
mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \
- "456\\^error,msg=\"-data-disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr.\\) .--. mode.\"" \
+ "456\\^error,msg=\"-data-disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr. \\| .-a addr. \\) .--. mode.\"" \
"data-disassemble mix different args"
mi_gdb_test "789-data-disassemble -f basics.c -l $line_main_body -- 9" \