aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorDoug Evans <xdje42@gmail.com>2015-08-14 21:45:54 -0700
committerDoug Evans <xdje42@gmail.com>2015-08-14 21:45:54 -0700
commit6ff0ba5f7b8a2b10642bbb233a32043595c55670 (patch)
treec5292016ff0e4c7a254c227d9a7c9579b05e8ff1 /gdb/mi
parentb56ccc202ab674998baf52a710d736702734f9ab (diff)
downloadgdb-6ff0ba5f7b8a2b10642bbb233a32043595c55670.zip
gdb-6ff0ba5f7b8a2b10642bbb233a32043595c55670.tar.gz
gdb-6ff0ba5f7b8a2b10642bbb233a32043595c55670.tar.bz2
New /s modifier for the disassemble command.
The "source centric" /m option to the disassemble command is often unhelpful, e.g., in the presence of optimized code. This patch adds a /s modifier that is better. For one, /m only prints instructions from the originating source file, leaving out instructions from e.g., inlined functions from other files. gdb/ChangeLog: PR gdb/11833 * NEWS: Document new /s modifier for the disassemble command. * cli/cli-cmds.c (disassemble_command): Add support for /s. (_initialize_cli_cmds): Update online docs of disassemble command. * disasm.c: #include "source.h". (struct deprecated_dis_line_entry): Renamed from dis_line_entry. All uses updated. (dis_line_entry): New struct. (hash_dis_line_entry, eq_dis_line_entry): New functions. (allocate_dis_line_table): New functions. (maybe_add_dis_line_entry, line_has_code_p): New functions. (dump_insns): New arg end_pc. All callers updated. (do_mixed_source_and_assembly_deprecated): Renamed from do_mixed_source_and_assembly. All callers updated. (do_mixed_source_and_assembly): New function. (gdb_disassembly): Handle /s (DISASSEMBLY_SOURCE). * disasm.h (DISASSEMBLY_SOURCE_DEPRECATED): Renamed from DISASSEMBLY_SOURCE. All uses updated. (DISASSEMBLY_SOURCE): New macro. * mi/mi-cmd-disas.c (mi_cmd_disassemble): New modes 4,5. gdb/doc/ChangeLog: * gdb.texinfo (Machine Code): Update docs for mixed source/assembly disassembly. (GDB/MI Data Manipulation): Update docs for new disassembly modes. gdb/testsuite/ChangeLog: * gdb.mi/mi-disassemble.exp: Update. * gdb.base/disasm-optim.S: New file. * gdb.base/disasm-optim.c: New file. * gdb.base/disasm-optim.h: New file. * gdb.base/disasm-optim.exp: New file.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-cmd-disas.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/gdb/mi/mi-cmd-disas.c b/gdb/mi/mi-cmd-disas.c
index 01cad2d..250124d 100644
--- a/gdb/mi/mi-cmd-disas.c
+++ b/gdb/mi/mi-cmd-disas.c
@@ -44,10 +44,11 @@
always required:
MODE: 0 -- disassembly.
- 1 -- disassembly and source.
+ 1 -- disassembly and source (with deprecated source-centric view).
2 -- disassembly and opcodes.
- 3 -- disassembly, source and opcodes.
-*/
+ 3 -- disassembly, source-centric and opcodes.
+ 4 -- disassembly, and source (with pc-centric view).
+ 5 -- disassembly, source (pc-centric) and opcodes. */
void
mi_cmd_disassemble (char *command, char **argv, int argc)
@@ -141,16 +142,34 @@ mi_cmd_disassemble (char *command, char **argv, int argc)
"[-n howmany]] [-s startaddr -e endaddr] [--] mode."));
mode = atoi (argv[0]);
- if (mode < 0 || mode > 3)
- error (_("-data-disassemble: Mode argument must be 0, 1, 2, or 3."));
+ if (mode < 0 || mode > 5)
+ error (_("-data-disassemble: Mode argument must be in the range 0-5."));
/* Convert the mode into a set of disassembly flags. */
- disasm_flags = 0;
- if (mode & 0x1)
- disasm_flags |= DISASSEMBLY_SOURCE;
- if (mode & 0x2)
- disasm_flags |= DISASSEMBLY_RAW_INSN;
+ disasm_flags = 0; /* Initialize here for -Wall. */
+ switch (mode)
+ {
+ case 0:
+ break;
+ case 1:
+ disasm_flags |= DISASSEMBLY_SOURCE_DEPRECATED;
+ break;
+ case 2:
+ disasm_flags |= DISASSEMBLY_RAW_INSN;
+ break;
+ case 3:
+ disasm_flags |= DISASSEMBLY_SOURCE_DEPRECATED | DISASSEMBLY_RAW_INSN;
+ break;
+ case 4:
+ disasm_flags |= DISASSEMBLY_SOURCE;
+ break;
+ case 5:
+ disasm_flags |= DISASSEMBLY_SOURCE | DISASSEMBLY_RAW_INSN;
+ break;
+ default:
+ gdb_assert_not_reached ("bad disassembly mode");
+ }
/* We must get the function beginning and end where line_num is
contained. */