diff options
-rw-r--r-- | gdb/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/cli/cli-cmds.c | 97 | ||||
-rw-r--r-- | gdb/printcmd.c | 120 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.asm/asm-source.exp | 2 |
5 files changed, 112 insertions, 120 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 19d51bc..b3e3b88 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2002-11-07 Fernando Nasser <fnasser@redhat.com> + + * printcmd.c (disassemble_command): Remove obsolete function. + (_initialize_printcmd): Do not create disassemble command here. + * cli/cli-cmds.c (disassemble_command): New function. Implements + disassemble command. + (init_cli_cmds): Create disassemble command here instead. + 2002-11-07 Andrew Cagney <ac131313@redhat.com> * MAINTAINERS: Add Daniel Jacobowitz to global maintainers list. diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index c44975a..9d58291 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -27,10 +27,13 @@ #include "gdb_string.h" #include "linespec.h" #include "expression.h" +#include "frame.h" +#include "value.h" #include "language.h" #include "filenames.h" /* for DOSish file names */ #include "objfiles.h" #include "source.h" +#include "disasm.h" #include "ui-out.h" @@ -819,6 +822,92 @@ list_command (char *arg, int from_tty) 0); } +/* Dump a specified section of assembly code. With no command line + arguments, this command will dump the assembly code for the + function surrounding the pc value in the selected frame. With one + argument, it will dump the assembly code surrounding that pc value. + Two arguments are interpeted as bounds within which to dump + assembly. */ + +/* ARGSUSED */ +static void +disassemble_command (char *arg, int from_tty) +{ + CORE_ADDR low, high; + char *name; + CORE_ADDR pc, pc_masked; + char *space_index; +#if 0 + asection *section; +#endif + + name = NULL; + if (!arg) + { + if (!selected_frame) + error ("No frame selected.\n"); + + pc = get_frame_pc (selected_frame); + if (find_pc_partial_function (pc, &name, &low, &high) == 0) + error ("No function contains program counter for selected frame.\n"); +#if defined(TUI) + else if (tui_version) + low = tuiGetLowDisassemblyAddress (low, pc); +#endif + low += FUNCTION_START_OFFSET; + } + else if (!(space_index = (char *) strchr (arg, ' '))) + { + /* One argument. */ + pc = parse_and_eval_address (arg); + if (find_pc_partial_function (pc, &name, &low, &high) == 0) + error ("No function contains specified address.\n"); +#if defined(TUI) + else if (tui_version) + low = tuiGetLowDisassemblyAddress (low, pc); +#endif + low += FUNCTION_START_OFFSET; + } + else + { + /* Two arguments. */ + *space_index = '\0'; + low = parse_and_eval_address (arg); + high = parse_and_eval_address (space_index + 1); + } + +#if defined(TUI) + if (!tui_is_window_visible (DISASSEM_WIN)) +#endif + { + printf_filtered ("Dump of assembler code "); + if (name != NULL) + { + printf_filtered ("for function %s:\n", name); + } + else + { + printf_filtered ("from "); + print_address_numeric (low, 1, gdb_stdout); + printf_filtered (" to "); + print_address_numeric (high, 1, gdb_stdout); + printf_filtered (":\n"); + } + + /* Dump the specified range. */ + gdb_disassembly (uiout, 0, 0, 0, -1, low, high); + + printf_filtered ("End of assembler dump.\n"); + gdb_flush (gdb_stdout); + } +#if defined(TUI) + else + { + tui_show_assembly (low); + } +#endif +} + static void make_command (char *arg, int from_tty) { @@ -1157,6 +1246,14 @@ With two args if one is empty it stands for ten lines away from the other arg.", if (dbx_commands) add_com_alias ("file", "list", class_files, 1); + c = add_com ("disassemble", class_vars, disassemble_command, + "Disassemble a specified section of memory.\n\ +Default is the function surrounding the pc of the selected frame.\n\ +With a single argument, the function surrounding that address is dumped.\n\ +Two arguments are taken as a range of memory to dump."); + set_cmd_completer (c, location_completer); + if (xdb_commands) + add_com_alias ("va", "disassemble", class_xdb, 0); /* NOTE: cagney/2000-03-20: Being able to enter ``(gdb) !ls'' would be a really useful feature. Unfortunately, the below wont do diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 28697f2..f1a7fdd 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -41,6 +41,7 @@ #include "completer.h" /* for completion functions */ #include "ui-out.h" #include "gdb_assert.h" +#include "disasm.h" extern int asm_demangle; /* Whether to demangle syms in asm printouts */ extern int addressprint; /* Whether to print hex addresses in HLL " */ @@ -136,8 +137,6 @@ static void enable_display (char *, int); static void disable_display_command (char *, int); -static void disassemble_command (char *, int); - static void printf_command (char *, int); static void print_frame_nameless_args (struct frame_info *, long, @@ -2270,114 +2269,6 @@ printf_command (char *arg, int from_tty) } do_cleanups (old_cleanups); } - -/* Dump a specified section of assembly code. With no command line - arguments, this command will dump the assembly code for the - function surrounding the pc value in the selected frame. With one - argument, it will dump the assembly code surrounding that pc value. - Two arguments are interpeted as bounds within which to dump - assembly. */ - -/* ARGSUSED */ -static void -disassemble_command (char *arg, int from_tty) -{ - CORE_ADDR low, high; - char *name; - CORE_ADDR pc, pc_masked; - char *space_index; -#if 0 - asection *section; -#endif - - name = NULL; - if (!arg) - { - if (!selected_frame) - error ("No frame selected.\n"); - - pc = get_frame_pc (selected_frame); - if (find_pc_partial_function (pc, &name, &low, &high) == 0) - error ("No function contains program counter for selected frame.\n"); -#if defined(TUI) - else if (tui_version) - low = tuiGetLowDisassemblyAddress (low, pc); -#endif - low += FUNCTION_START_OFFSET; - } - else if (!(space_index = (char *) strchr (arg, ' '))) - { - /* One argument. */ - pc = parse_and_eval_address (arg); - if (find_pc_partial_function (pc, &name, &low, &high) == 0) - error ("No function contains specified address.\n"); -#if defined(TUI) - else if (tui_version) - low = tuiGetLowDisassemblyAddress (low, pc); -#endif - low += FUNCTION_START_OFFSET; - } - else - { - /* Two arguments. */ - *space_index = '\0'; - low = parse_and_eval_address (arg); - high = parse_and_eval_address (space_index + 1); - } - -#if defined(TUI) - if (!tui_is_window_visible (DISASSEM_WIN)) -#endif - { - printf_filtered ("Dump of assembler code "); - if (name != NULL) - { - printf_filtered ("for function %s:\n", name); - } - else - { - printf_filtered ("from "); - print_address_numeric (low, 1, gdb_stdout); - printf_filtered (" to "); - print_address_numeric (high, 1, gdb_stdout); - printf_filtered (":\n"); - } - - /* Dump the specified range. */ - pc = low; - -#ifdef GDB_TARGET_MASK_DISAS_PC - pc_masked = GDB_TARGET_MASK_DISAS_PC (pc); -#else - pc_masked = pc; -#endif - - while (pc_masked < high) - { - QUIT; - print_address (pc_masked, gdb_stdout); - printf_filtered (":\t"); - /* We often wrap here if there are long symbolic names. */ - wrap_here (" "); - pc += print_insn (pc, gdb_stdout); - printf_filtered ("\n"); - -#ifdef GDB_TARGET_MASK_DISAS_PC - pc_masked = GDB_TARGET_MASK_DISAS_PC (pc); -#else - pc_masked = pc; -#endif - } - printf_filtered ("End of assembler dump.\n"); - gdb_flush (gdb_stdout); - } -#if defined(TUI) - else - { - tui_show_assembly (low); - } -#endif -} /* Print the instruction at address MEMADDR in debugged memory, on STREAM. Returns length of the instruction, in bytes. */ @@ -2427,15 +2318,6 @@ Defaults for format and size letters are those previously used.\n\ Default count is 1. Default address is following last thing printed\n\ with this command or \"print\".", NULL)); - c = add_com ("disassemble", class_vars, disassemble_command, - "Disassemble a specified section of memory.\n\ -Default is the function surrounding the pc of the selected frame.\n\ -With a single argument, the function surrounding that address is dumped.\n\ -Two arguments are taken as a range of memory to dump."); - set_cmd_completer (c, location_completer); - if (xdb_commands) - add_com_alias ("va", "disassemble", class_xdb, 0); - #if 0 add_com ("whereis", class_vars, whereis_command, "Print line number and file of definition of variable."); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 41018c7..6c8f779 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2002-09-18 Fernando Nasser <fnasser@redhat.com> + + * gdb.asm/asm-source.exp: Adjust patter to new disassembler routine + which explicitly prints the zero offset as "+0". + 2002-10-22 Daniel Jacobowitz <drow@mvista.com> * gdb.threads/schedlock.c (args): Make unsigned. diff --git a/gdb/testsuite/gdb.asm/asm-source.exp b/gdb/testsuite/gdb.asm/asm-source.exp index deb4b5f..641a7c1 100644 --- a/gdb/testsuite/gdb.asm/asm-source.exp +++ b/gdb/testsuite/gdb.asm/asm-source.exp @@ -289,7 +289,7 @@ gdb_test "print globalvar" ".* = 11" "look at global variable" gdb_test "print staticvar" ".* = 5" "look at static variable" # See if we can look at a static function -gdb_test "disassem foostatic" ".*<foostatic>:.*End of assembler dump." \ +gdb_test "disassem foostatic" ".*<foostatic\\+0>:.*End of assembler dump." \ "look at static function" remote_exec build "rm -f ${subdir}/arch.inc" |