binutils-gdb/gdb/disasm.h

150 lines
4.5 KiB
C
Raw Normal View History

/* Disassemble support for GDB.
Copyright (C) 2002-2017 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef DISASM_H
#define DISASM_H
Add Guile as an extension language. * NEWS: Mention Guile scripting. * Makefile.in (SUBDIR_GUILE_OBS): New variable. (SUBDIR_GUILE_SRCS, SUBDIR_GUILE_DEPS): New variables (SUBDIR_GUILE_LDFLAGS, SUBDIR_GUILE_CFLAGS): New variables. (INTERNAL_CPPFLAGS): Add GUILE_CPPFLAGS. (CLIBS): Add GUILE_LIBS. (install-guile): New rule. (guile.o): New rule. (scm-arch.o, scm-auto-load.o, scm-block.o): New rules. (scm-breakpoint.o, scm-disasm.o, scm-exception.o): New rules. (scm-frame.o, scm-iterator.o, scm-lazy-string.o): New rules. (scm-math.o, scm-objfile.o, scm-ports.o): New rules. (scm-pretty-print.o, scm-safe-call.o, scm-gsmob.o): New rules. (scm-string.o, scm-symbol.o, scm-symtab.o): New rules. (scm-type.o, scm-utils.o, scm-value.o): New rules. * configure.ac: New option --with-guile. * configure: Regenerate. * config.in: Regenerate. * auto-load.c: Remove #include "python/python.h". Add #include "gdb/section-scripts.h". (source_section_scripts): Handle Guile scripts. (_initialize_auto_load): Add name of Guile objfile script to scripts-directory help text. * breakpoint.c (condition_command): Tweak comment to include Scheme. * breakpoint.h (gdbscm_breakpoint_object): Add forward decl. (struct breakpoint): New member scm_bp_object. * defs.h (enum command_control_type): New value guile_control. * cli/cli-cmds.c: Remove #include "python/python.h". Add #include "extension.h". (show_user): Update comment. (_initialize_cli_cmds): Update help text for "show user". Update help text for max-user-call-depth. * cli/cli-script.c: Remove #include "python/python.h". Add #include "extension.h". (multi_line_command_p): Add guile_control. (print_command_lines): Handle guile_control. (execute_control_command, recurse_read_control_structure): Ditto. (process_next_line): Recognize "guile" commands. * disasm.c (gdb_disassemble_info): Make non-static. * disasm.h: #include "dis-asm.h". (struct gdbarch): Add forward decl. (gdb_disassemble_info): Declare. * extension.c: #include "guile/guile.h". (extension_languages): Add guile. (get_ext_lang_defn): Handle EXT_LANG_GDB. * extension.h (enum extension_language): New value EXT_LANG_GUILE. * gdbtypes.c (get_unsigned_type_max): New function. (get_signed_type_minmax): New function. * gdbtypes.h (get_unsigned_type_max): Declare. (get_signed_type_minmax): Declare. * guile/README: New file. * guile/guile-internal.h: New file. * guile/guile.c: New file. * guile/guile.h: New file. * guile/scm-arch.c: New file. * guile/scm-auto-load.c: New file. * guile/scm-block.c: New file. * guile/scm-breakpoint.c: New file. * guile/scm-disasm.c: New file. * guile/scm-exception.c: New file. * guile/scm-frame.c: New file. * guile/scm-gsmob.c: New file. * guile/scm-iterator.c: New file. * guile/scm-lazy-string.c: New file. * guile/scm-math.c: New file. * guile/scm-objfile.c: New file. * guile/scm-ports.c: New file. * guile/scm-pretty-print.c: New file. * guile/scm-safe-call.c: New file. * guile/scm-string.c: New file. * guile/scm-symbol.c: New file. * guile/scm-symtab.c: New file. * guile/scm-type.c: New file. * guile/scm-utils.c: New file. * guile/scm-value.c: New file. * guile/lib/gdb.scm: New file. * guile/lib/gdb/boot.scm: New file. * guile/lib/gdb/experimental.scm: New file. * guile/lib/gdb/init.scm: New file. * guile/lib/gdb/iterator.scm: New file. * guile/lib/gdb/printing.scm: New file. * guile/lib/gdb/types.scm: New file. * data-directory/Makefile.in (GUILE_SRCDIR): New variable. (VPATH): Add $(GUILE_SRCDIR). (GUILE_DIR): New variable. (GUILE_INSTALL_DIR, GUILE_FILES): New variables. (all): Add stamp-guile dependency. (stamp-guile): New rule. (clean-guile, install-guile, uninstall-guile): New rules. (install-only): Add install-guile dependency. (uninstall): Add uninstall-guile dependency. (clean): Add clean-guile dependency. doc/ * Makefile.in (GDB_DOC_FILES): Add guile.texi. * gdb.texinfo (Auto-loading): Add set/show auto-load guile-scripts. (Extending GDB): New menu entries Guile, Multiple Extension Languages. (Guile docs): Include guile.texi. (objfile-gdbdotext file): Add objfile-gdb.scm. (dotdebug_gdb_scripts section): Mention Guile scripts. (Multiple Extension Languages): New node. * guile.texi: New file. testsuite/ * configure.ac (AC_OUTPUT): Add gdb.guile. * configure: Regenerate. * lib/gdb-guile.exp: New file. * lib/gdb.exp (get_target_charset): New function. * gdb.base/help.exp: Update expected output from "apropos apropos". * gdb.guile/Makefile.in: New file. * gdb.guile/guile.exp: New file. * gdb.guile/scm-arch.c: New file. * gdb.guile/scm-arch.exp: New file. * gdb.guile/scm-block.c: New file. * gdb.guile/scm-block.exp: New file. * gdb.guile/scm-breakpoint.c: New file. * gdb.guile/scm-breakpoint.exp: New file. * gdb.guile/scm-disasm.c: New file. * gdb.guile/scm-disasm.exp: New file. * gdb.guile/scm-equal.c: New file. * gdb.guile/scm-equal.exp: New file. * gdb.guile/scm-error.exp: New file. * gdb.guile/scm-error.scm: New file. * gdb.guile/scm-frame-args.c: New file. * gdb.guile/scm-frame-args.exp: New file. * gdb.guile/scm-frame-args.scm: New file. * gdb.guile/scm-frame-inline.c: New file. * gdb.guile/scm-frame-inline.exp: New file. * gdb.guile/scm-frame.c: New file. * gdb.guile/scm-frame.exp: New file. * gdb.guile/scm-generics.exp: New file. * gdb.guile/scm-gsmob.exp: New file. * gdb.guile/scm-iterator.c: New file. * gdb.guile/scm-iterator.exp: New file. * gdb.guile/scm-math.c: New file. * gdb.guile/scm-math.exp: New file. * gdb.guile/scm-objfile-script-gdb.in: New file. * gdb.guile/scm-objfile-script.c: New file. * gdb.guile/scm-objfile-script.exp: New file. * gdb.guile/scm-objfile.c: New file. * gdb.guile/scm-objfile.exp: New file. * gdb.guile/scm-ports.exp: New file. * gdb.guile/scm-pretty-print.c: New file. * gdb.guile/scm-pretty-print.exp: New file. * gdb.guile/scm-pretty-print.scm: New file. * gdb.guile/scm-section-script.c: New file. * gdb.guile/scm-section-script.exp: New file. * gdb.guile/scm-section-script.scm: New file. * gdb.guile/scm-symbol.c: New file. * gdb.guile/scm-symbol.exp: New file. * gdb.guile/scm-symtab-2.c: New file. * gdb.guile/scm-symtab.c: New file. * gdb.guile/scm-symtab.exp: New file. * gdb.guile/scm-type.c: New file. * gdb.guile/scm-type.exp: New file. * gdb.guile/scm-value-cc.cc: New file. * gdb.guile/scm-value-cc.exp: New file. * gdb.guile/scm-value.c: New file. * gdb.guile/scm-value.exp: New file. * gdb.guile/source2.scm: New file. * gdb.guile/types-module.cc: New file. * gdb.guile/types-module.exp: New file.
2014-02-10 04:40:01 +01:00
#include "dis-asm.h"
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.
2015-08-15 06:45:54 +02:00
#define DISASSEMBLY_SOURCE_DEPRECATED (0x1 << 0)
#define DISASSEMBLY_RAW_INSN (0x1 << 1)
#define DISASSEMBLY_OMIT_FNAME (0x1 << 2)
#define DISASSEMBLY_FILENAME (0x1 << 3)
#define DISASSEMBLY_OMIT_PC (0x1 << 4)
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.
2015-08-15 06:45:54 +02:00
#define DISASSEMBLY_SOURCE (0x1 << 5)
disasm: add struct disasm_insn to describe to-be-disassembled instruction The "record instruction-history" command prints for each instruction in addition to the instruction's disassembly: - the instruction number in the recorded execution trace - a '?' before the instruction if it was executed speculatively To allow the "record instruction-history" command to use GDB's disassembly infrastructure, we extend gdb_pretty_print_insn to optionally print those additional fields and export the function. Add a new struct disasm_insn to add additional fields describing the to-be-disassembled instruction. The additional fields are: number an optional instruction number, zero if omitted. is_speculative a predicate saying whether the instruction was executed speculatively. If non-zero, the instruction number is printed first. It will also appear as a new optional field "insn-number" in MI. The field will be present if insn_num is non-zero. If is_speculative is set, speculative execution will be indicated by a "?" following the new instruction number field. Unless the PC is omitted, it will overwrite the first byte of the PC prefix. It will appear as a new optional field "is-speculative" in MI. The field will contain "?" and will be present if is_speculative is set. The speculative execution indication is guarded by a new flag DISASSEMBLY_SPECULATION. Replace the PC parameter of gdb_pretty_print_insn with a pointer to the above struct. GDB's "disassemble" command does not use the new fields. gdb/ * disasm.h (DISASSEMBLY_SPECULATION): New. (struct disasm_insn): New. (gdb_pretty_print_insn): New. * disasm.c (gdb_pretty_print_insn): Replace parameter PC with INSN. Update users. Print instruction number and indicate speculative execution, if requested.
2015-09-11 14:47:08 +02:00
#define DISASSEMBLY_SPECULATIVE (0x1 << 6)
Add Guile as an extension language. * NEWS: Mention Guile scripting. * Makefile.in (SUBDIR_GUILE_OBS): New variable. (SUBDIR_GUILE_SRCS, SUBDIR_GUILE_DEPS): New variables (SUBDIR_GUILE_LDFLAGS, SUBDIR_GUILE_CFLAGS): New variables. (INTERNAL_CPPFLAGS): Add GUILE_CPPFLAGS. (CLIBS): Add GUILE_LIBS. (install-guile): New rule. (guile.o): New rule. (scm-arch.o, scm-auto-load.o, scm-block.o): New rules. (scm-breakpoint.o, scm-disasm.o, scm-exception.o): New rules. (scm-frame.o, scm-iterator.o, scm-lazy-string.o): New rules. (scm-math.o, scm-objfile.o, scm-ports.o): New rules. (scm-pretty-print.o, scm-safe-call.o, scm-gsmob.o): New rules. (scm-string.o, scm-symbol.o, scm-symtab.o): New rules. (scm-type.o, scm-utils.o, scm-value.o): New rules. * configure.ac: New option --with-guile. * configure: Regenerate. * config.in: Regenerate. * auto-load.c: Remove #include "python/python.h". Add #include "gdb/section-scripts.h". (source_section_scripts): Handle Guile scripts. (_initialize_auto_load): Add name of Guile objfile script to scripts-directory help text. * breakpoint.c (condition_command): Tweak comment to include Scheme. * breakpoint.h (gdbscm_breakpoint_object): Add forward decl. (struct breakpoint): New member scm_bp_object. * defs.h (enum command_control_type): New value guile_control. * cli/cli-cmds.c: Remove #include "python/python.h". Add #include "extension.h". (show_user): Update comment. (_initialize_cli_cmds): Update help text for "show user". Update help text for max-user-call-depth. * cli/cli-script.c: Remove #include "python/python.h". Add #include "extension.h". (multi_line_command_p): Add guile_control. (print_command_lines): Handle guile_control. (execute_control_command, recurse_read_control_structure): Ditto. (process_next_line): Recognize "guile" commands. * disasm.c (gdb_disassemble_info): Make non-static. * disasm.h: #include "dis-asm.h". (struct gdbarch): Add forward decl. (gdb_disassemble_info): Declare. * extension.c: #include "guile/guile.h". (extension_languages): Add guile. (get_ext_lang_defn): Handle EXT_LANG_GDB. * extension.h (enum extension_language): New value EXT_LANG_GUILE. * gdbtypes.c (get_unsigned_type_max): New function. (get_signed_type_minmax): New function. * gdbtypes.h (get_unsigned_type_max): Declare. (get_signed_type_minmax): Declare. * guile/README: New file. * guile/guile-internal.h: New file. * guile/guile.c: New file. * guile/guile.h: New file. * guile/scm-arch.c: New file. * guile/scm-auto-load.c: New file. * guile/scm-block.c: New file. * guile/scm-breakpoint.c: New file. * guile/scm-disasm.c: New file. * guile/scm-exception.c: New file. * guile/scm-frame.c: New file. * guile/scm-gsmob.c: New file. * guile/scm-iterator.c: New file. * guile/scm-lazy-string.c: New file. * guile/scm-math.c: New file. * guile/scm-objfile.c: New file. * guile/scm-ports.c: New file. * guile/scm-pretty-print.c: New file. * guile/scm-safe-call.c: New file. * guile/scm-string.c: New file. * guile/scm-symbol.c: New file. * guile/scm-symtab.c: New file. * guile/scm-type.c: New file. * guile/scm-utils.c: New file. * guile/scm-value.c: New file. * guile/lib/gdb.scm: New file. * guile/lib/gdb/boot.scm: New file. * guile/lib/gdb/experimental.scm: New file. * guile/lib/gdb/init.scm: New file. * guile/lib/gdb/iterator.scm: New file. * guile/lib/gdb/printing.scm: New file. * guile/lib/gdb/types.scm: New file. * data-directory/Makefile.in (GUILE_SRCDIR): New variable. (VPATH): Add $(GUILE_SRCDIR). (GUILE_DIR): New variable. (GUILE_INSTALL_DIR, GUILE_FILES): New variables. (all): Add stamp-guile dependency. (stamp-guile): New rule. (clean-guile, install-guile, uninstall-guile): New rules. (install-only): Add install-guile dependency. (uninstall): Add uninstall-guile dependency. (clean): Add clean-guile dependency. doc/ * Makefile.in (GDB_DOC_FILES): Add guile.texi. * gdb.texinfo (Auto-loading): Add set/show auto-load guile-scripts. (Extending GDB): New menu entries Guile, Multiple Extension Languages. (Guile docs): Include guile.texi. (objfile-gdbdotext file): Add objfile-gdb.scm. (dotdebug_gdb_scripts section): Mention Guile scripts. (Multiple Extension Languages): New node. * guile.texi: New file. testsuite/ * configure.ac (AC_OUTPUT): Add gdb.guile. * configure: Regenerate. * lib/gdb-guile.exp: New file. * lib/gdb.exp (get_target_charset): New function. * gdb.base/help.exp: Update expected output from "apropos apropos". * gdb.guile/Makefile.in: New file. * gdb.guile/guile.exp: New file. * gdb.guile/scm-arch.c: New file. * gdb.guile/scm-arch.exp: New file. * gdb.guile/scm-block.c: New file. * gdb.guile/scm-block.exp: New file. * gdb.guile/scm-breakpoint.c: New file. * gdb.guile/scm-breakpoint.exp: New file. * gdb.guile/scm-disasm.c: New file. * gdb.guile/scm-disasm.exp: New file. * gdb.guile/scm-equal.c: New file. * gdb.guile/scm-equal.exp: New file. * gdb.guile/scm-error.exp: New file. * gdb.guile/scm-error.scm: New file. * gdb.guile/scm-frame-args.c: New file. * gdb.guile/scm-frame-args.exp: New file. * gdb.guile/scm-frame-args.scm: New file. * gdb.guile/scm-frame-inline.c: New file. * gdb.guile/scm-frame-inline.exp: New file. * gdb.guile/scm-frame.c: New file. * gdb.guile/scm-frame.exp: New file. * gdb.guile/scm-generics.exp: New file. * gdb.guile/scm-gsmob.exp: New file. * gdb.guile/scm-iterator.c: New file. * gdb.guile/scm-iterator.exp: New file. * gdb.guile/scm-math.c: New file. * gdb.guile/scm-math.exp: New file. * gdb.guile/scm-objfile-script-gdb.in: New file. * gdb.guile/scm-objfile-script.c: New file. * gdb.guile/scm-objfile-script.exp: New file. * gdb.guile/scm-objfile.c: New file. * gdb.guile/scm-objfile.exp: New file. * gdb.guile/scm-ports.exp: New file. * gdb.guile/scm-pretty-print.c: New file. * gdb.guile/scm-pretty-print.exp: New file. * gdb.guile/scm-pretty-print.scm: New file. * gdb.guile/scm-section-script.c: New file. * gdb.guile/scm-section-script.exp: New file. * gdb.guile/scm-section-script.scm: New file. * gdb.guile/scm-symbol.c: New file. * gdb.guile/scm-symbol.exp: New file. * gdb.guile/scm-symtab-2.c: New file. * gdb.guile/scm-symtab.c: New file. * gdb.guile/scm-symtab.exp: New file. * gdb.guile/scm-type.c: New file. * gdb.guile/scm-type.exp: New file. * gdb.guile/scm-value-cc.cc: New file. * gdb.guile/scm-value-cc.exp: New file. * gdb.guile/scm-value.c: New file. * gdb.guile/scm-value.exp: New file. * gdb.guile/source2.scm: New file. * gdb.guile/types-module.cc: New file. * gdb.guile/types-module.exp: New file.
2014-02-10 04:40:01 +01:00
struct gdbarch;
struct ui_out;
struct ui_file;
Refactor disassembly code This patch addes class gdb_disassembler, and refactor code to use it. The gdb_disassembler object is saved in disassember_info.application_data. However, disassember_info.application_data is already used by gdb for arm, mips spu, and scm-disasm. In arm and mips, .application_data is gdbarch, but we can still get gdbarch from gdb_disassember. The use of application_data in spu is a little bit complicated. It creates its own disassemble_info, and save spu_dis_asm_data in .application_data. This will overwrite the pointer to gdb_disassembler, so we need to find another place to save spu_dis_asm_data. I extend disassemble_info, and put "id" there. gdb: 2017-01-26 Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * arm-tdep.c: Include "disasm.h". (gdb_print_insn_arm): Update code to get gdbarch. * disasm.c (dis_asm_read_memory): Change it to gdb_disassembler::dis_asm_read_memory. (dis_asm_memory_error): Likewise. (dis_asm_print_address): Likewise. (gdb_pretty_print_insn): Change it to gdb_disassembler::pretty_print_insn. (dump_insns): Add one argument gdb_disassemlber. All callers updated. (do_mixed_source_and_assembly_deprecated): Likewise. (do_mixed_source_and_assembly): Likewise. (do_assembly_only): Likewise. (gdb_disassembler::gdb_disassembler): New. (gdb_disassembler::print_insn): New. * disasm.h (class gdb_disassembler): New. (gdb_pretty_print_insn): Remove declaration. (gdb_disassemble_info): Likewise. * guile/scm-disasm.c (class gdbscm_disassembler): New. (gdbscm_disasm_read_memory_worker): Update. (gdbscm_disasm_read_memory): Update. (gdbscm_disasm_memory_error): Remove. (gdbscm_disasm_print_address): Remove. (gdbscm_disassembler::gdbscm_disassembler): New. (gdbscm_print_insn_from_port): Update. * mips-tdep.c: Include disasm.h. (gdb_print_insn_mips): Update code to get gdbarch. * record-btrace.c (btrace_insn_history): Update. * spu-tdep.c: Include disasm.h. (struct spu_dis_asm_data): Remove. (struct spu_dis_asm_info): New. (spu_dis_asm_print_address): Use spu_dis_asm_info to get SPU id. (gdb_print_insn_spu): Cast disassemble_info to spu_dis_asm_info.
2017-01-26 15:29:19 +01:00
class gdb_disassembler
{
using di_read_memory_ftype = decltype (disassemble_info::read_memory_func);
public:
gdb_disassembler (struct gdbarch *gdbarch, struct ui_file *file)
: gdb_disassembler (gdbarch, file, dis_asm_read_memory)
{}
int print_insn (CORE_ADDR memaddr, int *branch_delay_insns = NULL);
/* Return the gdbarch of gdb_disassembler. */
struct gdbarch *arch ()
{ return m_gdbarch; }
protected:
gdb_disassembler (struct gdbarch *gdbarch, struct ui_file *file,
di_read_memory_ftype func);
struct ui_file *stream ()
{ return (struct ui_file *) m_di.stream; }
private:
struct gdbarch *m_gdbarch;
/* Stores data required for disassembling instructions in
opcodes. */
struct disassemble_info m_di;
Don't throw exception in dis_asm_memory_error Hi, GDB calls some APIs from opcodes to do disassembly and provide some call backs. This model makes troubles on C++ exception unwinding, because GDB is a C++ program, and opcodes is still compiled as C. As we can see, frame #10 and #12 are C++, while #frame 11 is C, #10 0x0000000000544228 in memory_error (err=TARGET_XFER_E_IO, memaddr=<optimized out>) at ../../binutils-gdb/gdb/corefile.c:237 #11 0x00000000006b0a54 in print_insn_aarch64 (pc=0, info=0xffffffffeeb0) at ../../binutils-gdb/opcodes/aarch64-dis.c:3185 #12 0x0000000000553590 in gdb_pretty_print_insn (gdbarch=gdbarch@entry=0xbbceb0, uiout=uiout@entry=0xbc73d0, di=di@entry=0xffffffffeeb0, insn=0xffffffffed40, insn@entry=0xffffffffed90, flags=flags@entry=0, C++ exception unwinder can't go across frame #11 unless it has unwind table. However, C program on many architectures doesn't have it in default. As a result, GDB aborts, which is described in PR 20939. This is not the first time we see this kind of problem. We've had a commit 89525768cd086a0798a504c81fdf7ebcd4c904e1 "Propagate GDB/C++ exceptions across readline using sj/lj-based TRY/CATCH". We can fix the disassembly bug in a similar way, this is the option one. Since opcodes is built with gdb, we fix this problem in a different way as we did for the same issue with readline. Instead of throwing exception in dis_asm_memory_error, we record the failed memory address, and throw exception when GDB returns from opcodes disassemblers. gdb: 2017-01-26 Yao Qi <yao.qi@linaro.org> Pedro Alves <palves@redhat.com> PR gdb/20939 * disasm.c (gdb_disassembler::dis_asm_memory_error): Don't call memory_error, save memaddr instead. (gdb_disassembler::print_insn): If gdbarch_print_insn returns negative, cal memory_error. * disasm.h (gdb_disassembler) <m_err_memaddr>: New field. gdb/testsuite: 2017-01-26 Yao Qi <yao.qi@linaro.org> * gdb.base/all-architectures.exp.in (do_arch_tests): Test disassemble on address 0.
2017-01-26 15:29:20 +01:00
CORE_ADDR m_err_memaddr;
Refactor disassembly code This patch addes class gdb_disassembler, and refactor code to use it. The gdb_disassembler object is saved in disassember_info.application_data. However, disassember_info.application_data is already used by gdb for arm, mips spu, and scm-disasm. In arm and mips, .application_data is gdbarch, but we can still get gdbarch from gdb_disassember. The use of application_data in spu is a little bit complicated. It creates its own disassemble_info, and save spu_dis_asm_data in .application_data. This will overwrite the pointer to gdb_disassembler, so we need to find another place to save spu_dis_asm_data. I extend disassemble_info, and put "id" there. gdb: 2017-01-26 Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * arm-tdep.c: Include "disasm.h". (gdb_print_insn_arm): Update code to get gdbarch. * disasm.c (dis_asm_read_memory): Change it to gdb_disassembler::dis_asm_read_memory. (dis_asm_memory_error): Likewise. (dis_asm_print_address): Likewise. (gdb_pretty_print_insn): Change it to gdb_disassembler::pretty_print_insn. (dump_insns): Add one argument gdb_disassemlber. All callers updated. (do_mixed_source_and_assembly_deprecated): Likewise. (do_mixed_source_and_assembly): Likewise. (do_assembly_only): Likewise. (gdb_disassembler::gdb_disassembler): New. (gdb_disassembler::print_insn): New. * disasm.h (class gdb_disassembler): New. (gdb_pretty_print_insn): Remove declaration. (gdb_disassemble_info): Likewise. * guile/scm-disasm.c (class gdbscm_disassembler): New. (gdbscm_disasm_read_memory_worker): Update. (gdbscm_disasm_read_memory): Update. (gdbscm_disasm_memory_error): Remove. (gdbscm_disasm_print_address): Remove. (gdbscm_disassembler::gdbscm_disassembler): New. (gdbscm_print_insn_from_port): Update. * mips-tdep.c: Include disasm.h. (gdb_print_insn_mips): Update code to get gdbarch. * record-btrace.c (btrace_insn_history): Update. * spu-tdep.c: Include disasm.h. (struct spu_dis_asm_data): Remove. (struct spu_dis_asm_info): New. (spu_dis_asm_print_address): Use spu_dis_asm_info to get SPU id. (gdb_print_insn_spu): Cast disassemble_info to spu_dis_asm_info.
2017-01-26 15:29:19 +01:00
static int dis_asm_read_memory (bfd_vma memaddr, gdb_byte *myaddr,
unsigned int len,
struct disassemble_info *info);
static void dis_asm_memory_error (int err, bfd_vma memaddr,
struct disassemble_info *info);
static void dis_asm_print_address (bfd_vma addr,
struct disassemble_info *info);
};
disasm: add struct disasm_insn to describe to-be-disassembled instruction The "record instruction-history" command prints for each instruction in addition to the instruction's disassembly: - the instruction number in the recorded execution trace - a '?' before the instruction if it was executed speculatively To allow the "record instruction-history" command to use GDB's disassembly infrastructure, we extend gdb_pretty_print_insn to optionally print those additional fields and export the function. Add a new struct disasm_insn to add additional fields describing the to-be-disassembled instruction. The additional fields are: number an optional instruction number, zero if omitted. is_speculative a predicate saying whether the instruction was executed speculatively. If non-zero, the instruction number is printed first. It will also appear as a new optional field "insn-number" in MI. The field will be present if insn_num is non-zero. If is_speculative is set, speculative execution will be indicated by a "?" following the new instruction number field. Unless the PC is omitted, it will overwrite the first byte of the PC prefix. It will appear as a new optional field "is-speculative" in MI. The field will contain "?" and will be present if is_speculative is set. The speculative execution indication is guarded by a new flag DISASSEMBLY_SPECULATION. Replace the PC parameter of gdb_pretty_print_insn with a pointer to the above struct. GDB's "disassemble" command does not use the new fields. gdb/ * disasm.h (DISASSEMBLY_SPECULATION): New. (struct disasm_insn): New. (gdb_pretty_print_insn): New. * disasm.c (gdb_pretty_print_insn): Replace parameter PC with INSN. Update users. Print instruction number and indicate speculative execution, if requested.
2015-09-11 14:47:08 +02:00
/* An instruction to be disassembled. */
struct disasm_insn
{
/* The address of the memory containing the instruction. */
CORE_ADDR addr;
/* An optional instruction number. If non-zero, it is printed first. */
unsigned int number;
/* True if the instruction was executed speculatively. */
unsigned int is_speculative:1;
};
* disasm.h (gdb_disassembly): Add GDBARCH parameter. (gdb_print_insn): Likewise. * disasm.c (dump_insns): Add GDBARCH parameter. Use it instead of current_gdbarch. (do_mixed_source_and_assembly): Add GDBARCH parameter. Pass to dump_insns. (do_assembly_only): Likewise. (gdb_disassembly): Add GDBARCH parameter. Use it instead of current_gdbarch. Pass to subroutines. (gdb_print_insn): Add GDBARCH parameter. Use it instead of current_gdbarch. * stack.c (struct gdb_disassembly_stub_args): Add GDBARCH member. (gdb_disassembly_stub): Pass architecture to gdb_disassembly. (do_gdb_disassembly): Add GDBARCH argument. Store into args. (print_frame_info): Pass architecture to do_gdb_disassembly. * printcmd.c (print_formatted): Pass architecture to gdb_print_insn. * mi/mi-cmd-disas.c: Include "arch-utils.h" (mi_cmd_disassemble): Pass architecture to gdb_disassembly. * cli/cli-cmds.c: Include "arch-utils.h". (print_disassembly): Add GDBARCH parameter. Pass to gdb_disassembly and tui_show_assembly. (disassemble_current_function): Pass architecture to tui_get_low_disassembly_address and print_disassembly. (disassemble_command): Pass architecture to tui_get_low_disassembly_address and print_disassembly. * tui/tui.c (tui_show_assembly): Add GDBARCH parameter. Pass to tui_update_source_windows_with_addr. * tui/tui-data.h (struct tui_locator_element): Add GDBARCH member. (struct tui_source_info): Likewise. * tui/tui-data.c (tui_clear_win_detail): Clear source_info.gdbarch. * tui/tui-disasm.c (tui_disassemble): Add GDBARCH parameter. Pass to gdb_print_insn. (tui_find_disassembly_address): Add GDBARCH parameter. Pass to tui_disassemble. (tui_set_disassem_content): Add GDBARCH parameter. Install into source_info.gdbarch. Pass to tui_disassemble. (tui_show_disassem): Add GDBARCH parameter. Pass to tui_update_source_window. (tui_show_disassem_and_update_source): Add GDBARCH parameter. Pass to tui_show_disassem and tui_update_source_window. (tui_get_begin_asm_address): Return locator architecture in addition to locator PC value. (tui_get_low_disassembly_address): Add GDBARCH parameter. Pass to tui_get_low_disassembly_address. (tui_vertical_disassem_scroll): Pass architecture to subroutines. * tui/tui-disasm.h (tui_set_disassem_content): Add GDBARCH parameter. (tui_show_disassem): Likewise. (tui_show_disassem_and_update_source): Likewise. (tui_get_begin_asm_address): Return architecture and PC value. * tui/tui.h (tui_get_low_disassembly_address): Add GDBARCH parameter. (tui_show_assembly): Add GDBARCH parameter. * tui/tui-layout.c (extract_display_start_addr): Return current window architecture in addition to current PC value. (tui_set_layout): Update calls to tui_get_low_disassembly_address and extract_display_start_addr. Pass architecture to tui_update_source_windows_with_addr. * tui/tui-source.c: Include "objfiles.h". (tui_set_source_content): Initialize window architecture. (tui_show_symtab_source): Add GDBARCH parameter. Pass to tui_update_source_window_as_is * tui/tui-source.h (tui_show_symtab_source): Add GDBARCH parameter. * tui/tui-stack.c (tui_set_locator_info): Add GDBARCH parameter. Install locator architecture. (tui_set_locator_filename): Update call. (tui_show_frame_info): Pass architecture to tui_set_locator_info and subroutines. * tui/tui-win.c (make_visible_with_new_height): Pass architecture to tui_update_source_window. * tui/tui-winsource.c: Include "objfiles.h". (tui_display_main): Update call to tui_get_begin_asm_address. Pass architecture to tui_update_source_windows_with_addr. (tui_update_source_window): Add GDBARCH parameter. Pass to tui_update_source_window_as_is. (tui_update_source_window_as_is): Add GDBARCH parameter. Pass to tui_set_disassem_content. (tui_update_source_windows_with_addr): Add GDBARCH parameter. Pass to subroutines. (tui_update_source_windows_with_line): Pass objfile architecture to subroutines. (tui_horizontal_source_scroll): Pass architecture to tui_update_source_window_as_is. * tui/tui-winsource.h (tui_update_source_window): Add GDBARCH parameter. (tui_update_source_window_as_is): Likewise. (tui_update_source_windows_with_addr): Likewise.
2009-07-02 19:17:42 +02:00
extern void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
int flags, int how_many,
CORE_ADDR low, CORE_ADDR high);
/* Print the instruction at address MEMADDR in debugged memory,
on STREAM. Returns the length of the instruction, in bytes,
and, if requested, the number of branch delay slot instructions. */
* disasm.h (gdb_disassembly): Add GDBARCH parameter. (gdb_print_insn): Likewise. * disasm.c (dump_insns): Add GDBARCH parameter. Use it instead of current_gdbarch. (do_mixed_source_and_assembly): Add GDBARCH parameter. Pass to dump_insns. (do_assembly_only): Likewise. (gdb_disassembly): Add GDBARCH parameter. Use it instead of current_gdbarch. Pass to subroutines. (gdb_print_insn): Add GDBARCH parameter. Use it instead of current_gdbarch. * stack.c (struct gdb_disassembly_stub_args): Add GDBARCH member. (gdb_disassembly_stub): Pass architecture to gdb_disassembly. (do_gdb_disassembly): Add GDBARCH argument. Store into args. (print_frame_info): Pass architecture to do_gdb_disassembly. * printcmd.c (print_formatted): Pass architecture to gdb_print_insn. * mi/mi-cmd-disas.c: Include "arch-utils.h" (mi_cmd_disassemble): Pass architecture to gdb_disassembly. * cli/cli-cmds.c: Include "arch-utils.h". (print_disassembly): Add GDBARCH parameter. Pass to gdb_disassembly and tui_show_assembly. (disassemble_current_function): Pass architecture to tui_get_low_disassembly_address and print_disassembly. (disassemble_command): Pass architecture to tui_get_low_disassembly_address and print_disassembly. * tui/tui.c (tui_show_assembly): Add GDBARCH parameter. Pass to tui_update_source_windows_with_addr. * tui/tui-data.h (struct tui_locator_element): Add GDBARCH member. (struct tui_source_info): Likewise. * tui/tui-data.c (tui_clear_win_detail): Clear source_info.gdbarch. * tui/tui-disasm.c (tui_disassemble): Add GDBARCH parameter. Pass to gdb_print_insn. (tui_find_disassembly_address): Add GDBARCH parameter. Pass to tui_disassemble. (tui_set_disassem_content): Add GDBARCH parameter. Install into source_info.gdbarch. Pass to tui_disassemble. (tui_show_disassem): Add GDBARCH parameter. Pass to tui_update_source_window. (tui_show_disassem_and_update_source): Add GDBARCH parameter. Pass to tui_show_disassem and tui_update_source_window. (tui_get_begin_asm_address): Return locator architecture in addition to locator PC value. (tui_get_low_disassembly_address): Add GDBARCH parameter. Pass to tui_get_low_disassembly_address. (tui_vertical_disassem_scroll): Pass architecture to subroutines. * tui/tui-disasm.h (tui_set_disassem_content): Add GDBARCH parameter. (tui_show_disassem): Likewise. (tui_show_disassem_and_update_source): Likewise. (tui_get_begin_asm_address): Return architecture and PC value. * tui/tui.h (tui_get_low_disassembly_address): Add GDBARCH parameter. (tui_show_assembly): Add GDBARCH parameter. * tui/tui-layout.c (extract_display_start_addr): Return current window architecture in addition to current PC value. (tui_set_layout): Update calls to tui_get_low_disassembly_address and extract_display_start_addr. Pass architecture to tui_update_source_windows_with_addr. * tui/tui-source.c: Include "objfiles.h". (tui_set_source_content): Initialize window architecture. (tui_show_symtab_source): Add GDBARCH parameter. Pass to tui_update_source_window_as_is * tui/tui-source.h (tui_show_symtab_source): Add GDBARCH parameter. * tui/tui-stack.c (tui_set_locator_info): Add GDBARCH parameter. Install locator architecture. (tui_set_locator_filename): Update call. (tui_show_frame_info): Pass architecture to tui_set_locator_info and subroutines. * tui/tui-win.c (make_visible_with_new_height): Pass architecture to tui_update_source_window. * tui/tui-winsource.c: Include "objfiles.h". (tui_display_main): Update call to tui_get_begin_asm_address. Pass architecture to tui_update_source_windows_with_addr. (tui_update_source_window): Add GDBARCH parameter. Pass to tui_update_source_window_as_is. (tui_update_source_window_as_is): Add GDBARCH parameter. Pass to tui_set_disassem_content. (tui_update_source_windows_with_addr): Add GDBARCH parameter. Pass to subroutines. (tui_update_source_windows_with_line): Pass objfile architecture to subroutines. (tui_horizontal_source_scroll): Pass architecture to tui_update_source_window_as_is. * tui/tui-winsource.h (tui_update_source_window): Add GDBARCH parameter. (tui_update_source_window_as_is): Likewise. (tui_update_source_windows_with_addr): Likewise.
2009-07-02 19:17:42 +02:00
extern int gdb_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
struct ui_file *stream, int *branch_delay_insns);
/* Class used to pretty-print instructions. */
Add back gdb_pretty_print_insn ui_file_rewind is a ui_file method that only really works with mem buffer files, and is a nop on other ui_file types. It'd be desirable to eliminate it from the base ui_file interface, and move it to the "mem_fileopen" subclass of ui_file instead. A following patch does just that. Unfortunately, there are a couple references to ui_file_rewind inside gdb_disassembler::pretty_print_insn that were made harder to eliminate with the recent addition of the gdb_disassembler wrapper. Before the gdb_disassembler wrapper was added, in commit e47ad6c0bd7aa3 ("Refactor disassembly code"), gdb_pretty_print_insn used to be passed a ui_file pointer as argument, and it was simple to adjust that pointer be a "mem_fileopen" ui_file pointer instead, since there's only one gdb_pretty_print_insn caller. That commit made gdb_pretty_print_insn be a method of gdb_disassembler, and removed the method's ui_file parameter at the same time, replaced by referencing the gdb_disassembler's stream instead. The trouble is that a gdb_disassembler can be instantiated with a pointer any kind of ui_file. Casting the gdb_disassembler's stream to a mem_fileopen ui_file inside gdb_disassembler::pretty_print_insn in order to call the reset method would be gross hack. The fix here is to: - make gdb_disassembler::pretty_print_insn a be free function again instead of a method of gdb_disassembler. I.e., bring back gdb_pretty_print_insn. - but, don't add back the ui_file * parameter. Instead, move the mem_fileopen allocation inside. That is a better interface, given that the ui_file is only ever used as temporary scratch buffer as an implementation detail of gdb_pretty_print_insn. The function's real "where to send output" parameter is the ui_out pointer. (A following patch will add back buffer reuse across invocations differently). - don't add back a disassemble_info pointer either. That used to be necessary for this bit: err = m_di.read_memory_func (pc, &data, 1, &m_di); if (err != 0) m_di.memory_error_func (err, pc, &m_di); ... but AFAIK, it's not really necessary. We can replace those three lines with a call to read_code. This seems to fix a regression even, because before commit d8b49cf0c891d0 ("Don't throw exception in dis_asm_memory_error"), that memory_error_func call would throw an error/exception, but now it only records the error in the gdb_disassembler's m_err_memaddr field. (read_code throws on error.) With all these, gdb_pretty_print_insn is completely layered on top of gdb_disassembler only using the latter's public API. gdb/ChangeLog: 2017-02-02 Pedro Alves <palves@redhat.com> * disasm.c (gdb_disassembler::pretty_print_insn): Rename to... (gdb_pretty_print_insn): ... this. Now a free function. Add back a 'gdbarch' parameter. Allocate a mem_fileopen stream here. Adjust to call gdb_print_insn instead of gdb_disassembler::print_insn. (dump_insns, do_mixed_source_and_assembly_deprecated) (do_mixed_source_and_assembly, do_assembly_only): Add back a 'gdbarch' parameter. Remove gdb_disassembler parameter. (gdb_disassembly): Don't allocate a gdb_disassembler here. * disasm.h (gdb_disassembler::pretty_print_insn): Delete declaration. (gdb_pretty_print_insn): Re-add declaration. * record-btrace.c (btrace_insn_history): Don't allocate a gdb_disassembler here. Adjust to call gdb_pretty_print_insn.
2017-02-02 12:11:47 +01:00
class gdb_pretty_print_disassembler
{
public:
explicit gdb_pretty_print_disassembler (struct gdbarch *gdbarch)
: m_di (gdbarch, &m_insn_stb)
{}
/* Prints the instruction INSN into UIOUT and returns the length of
the printed instruction in bytes. */
int pretty_print_insn (struct ui_out *uiout, const struct disasm_insn *insn,
int flags);
private:
/* Returns the architecture used for disassembling. */
struct gdbarch *arch () { return m_di.arch (); }
/* The disassembler used for instruction printing. */
gdb_disassembler m_di;
/* The buffer used to build the instruction string. The
disassembler is initialized with this stream. */
string_file m_insn_stb;
/* The buffer used to build the raw opcodes string. */
string_file m_opcode_stb;
};
Add back gdb_pretty_print_insn ui_file_rewind is a ui_file method that only really works with mem buffer files, and is a nop on other ui_file types. It'd be desirable to eliminate it from the base ui_file interface, and move it to the "mem_fileopen" subclass of ui_file instead. A following patch does just that. Unfortunately, there are a couple references to ui_file_rewind inside gdb_disassembler::pretty_print_insn that were made harder to eliminate with the recent addition of the gdb_disassembler wrapper. Before the gdb_disassembler wrapper was added, in commit e47ad6c0bd7aa3 ("Refactor disassembly code"), gdb_pretty_print_insn used to be passed a ui_file pointer as argument, and it was simple to adjust that pointer be a "mem_fileopen" ui_file pointer instead, since there's only one gdb_pretty_print_insn caller. That commit made gdb_pretty_print_insn be a method of gdb_disassembler, and removed the method's ui_file parameter at the same time, replaced by referencing the gdb_disassembler's stream instead. The trouble is that a gdb_disassembler can be instantiated with a pointer any kind of ui_file. Casting the gdb_disassembler's stream to a mem_fileopen ui_file inside gdb_disassembler::pretty_print_insn in order to call the reset method would be gross hack. The fix here is to: - make gdb_disassembler::pretty_print_insn a be free function again instead of a method of gdb_disassembler. I.e., bring back gdb_pretty_print_insn. - but, don't add back the ui_file * parameter. Instead, move the mem_fileopen allocation inside. That is a better interface, given that the ui_file is only ever used as temporary scratch buffer as an implementation detail of gdb_pretty_print_insn. The function's real "where to send output" parameter is the ui_out pointer. (A following patch will add back buffer reuse across invocations differently). - don't add back a disassemble_info pointer either. That used to be necessary for this bit: err = m_di.read_memory_func (pc, &data, 1, &m_di); if (err != 0) m_di.memory_error_func (err, pc, &m_di); ... but AFAIK, it's not really necessary. We can replace those three lines with a call to read_code. This seems to fix a regression even, because before commit d8b49cf0c891d0 ("Don't throw exception in dis_asm_memory_error"), that memory_error_func call would throw an error/exception, but now it only records the error in the gdb_disassembler's m_err_memaddr field. (read_code throws on error.) With all these, gdb_pretty_print_insn is completely layered on top of gdb_disassembler only using the latter's public API. gdb/ChangeLog: 2017-02-02 Pedro Alves <palves@redhat.com> * disasm.c (gdb_disassembler::pretty_print_insn): Rename to... (gdb_pretty_print_insn): ... this. Now a free function. Add back a 'gdbarch' parameter. Allocate a mem_fileopen stream here. Adjust to call gdb_print_insn instead of gdb_disassembler::print_insn. (dump_insns, do_mixed_source_and_assembly_deprecated) (do_mixed_source_and_assembly, do_assembly_only): Add back a 'gdbarch' parameter. Remove gdb_disassembler parameter. (gdb_disassembly): Don't allocate a gdb_disassembler here. * disasm.h (gdb_disassembler::pretty_print_insn): Delete declaration. (gdb_pretty_print_insn): Re-add declaration. * record-btrace.c (btrace_insn_history): Don't allocate a gdb_disassembler here. Adjust to call gdb_pretty_print_insn.
2017-02-02 12:11:47 +01:00
/* Return the length in bytes of the instruction at address MEMADDR in
debugged memory. */
extern int gdb_insn_length (struct gdbarch *gdbarch, CORE_ADDR memaddr);
/* Return the length in bytes of INSN, originally at MEMADDR. MAX_LEN
is the size of the buffer containing INSN. */
extern int gdb_buffered_insn_length (struct gdbarch *gdbarch,
const gdb_byte *insn, int max_len,
CORE_ADDR memaddr);
GDB: Add support for the new set/show disassembler-options commands. This commit adds support to GDB so that it can modify the disassembler-options value that is passed to the disassembler, similar to objdump's -M option. Currently, the only supported targets are ARM, PowerPC and S/390, but adding support for a new target(s) is not difficult. include/ * dis-asm.h (disasm_options_t): New typedef. (parse_arm_disassembler_option): Remove prototype. (set_arm_regname_option): Likewise. (get_arm_regnames): Likewise. (get_arm_regname_num_options): Likewise. (disassemble_init_s390): New prototype. (disassembler_options_powerpc): Likewise. (disassembler_options_arm): Likewise. (disassembler_options_s390): Likewise. (remove_whitespace_and_extra_commas): Likewise. (disassembler_options_cmp): Likewise. (next_disassembler_option): New inline function. (FOR_EACH_DISASSEMBLER_OPTION): New macro. opcodes/ * disassemble.c Include "safe-ctype.h". (disassemble_init_for_target): Handle s390 init. (remove_whitespace_and_extra_commas): New function. (disassembler_options_cmp): Likewise. * arm-dis.c: Include "libiberty.h". (NUM_ELEM): Delete. (regnames): Use long disassembler style names. Add force-thumb and no-force-thumb options. (NUM_ARM_REGNAMES): Rename from this... (NUM_ARM_OPTIONS): ...to this. Use ARRAY_SIZE. (get_arm_regname_num_options): Delete. (set_arm_regname_option): Likewise. (get_arm_regnames): Likewise. (parse_disassembler_options): Likewise. (parse_arm_disassembler_option): Rename from this... (parse_arm_disassembler_options): ...to this. Make static. Use new FOR_EACH_DISASSEMBLER_OPTION macro to scan over options. (print_insn): Use parse_arm_disassembler_options. (disassembler_options_arm): New function. (print_arm_disassembler_options): Handle updated regnames. * ppc-dis.c: Include "libiberty.h". (ppc_opts): Add "32" and "64" entries. (ppc_parse_cpu): Use ARRAY_SIZE and disassembler_options_cmp. (powerpc_init_dialect): Add break to switch statement. Use new FOR_EACH_DISASSEMBLER_OPTION macro. (disassembler_options_powerpc): New function. (print_ppc_disassembler_options): Use ARRAY_SIZE. Remove printing of "32" and "64". * s390-dis.c: Include "libiberty.h". (init_flag): Remove unneeded variable. (struct s390_options_t): New structure type. (options): New structure. (init_disasm): Rename from this... (disassemble_init_s390): ...to this. Add initializations for current_arch_mask and option_use_insn_len_bits_p. Remove init_flag. (print_insn_s390): Delete call to init_disasm. (disassembler_options_s390): New function. (print_s390_disassembler_options): Print using information from struct 'options'. * po/opcodes.pot: Regenerate. binutils/ * objdump.c (main): Use remove_whitespace_and_extra_commas. gdb/ * NEWS: Mention new set/show disassembler-options commands. * doc/gdb.texinfo: Document new set/show disassembler-options commands. * disasm.c: Include "arch-utils.h", "gdbcmd.h" and "safe-ctype.h". (prospective_options): New static variable. (gdb_disassembler::gdb_disassembler): Initialize m_di.disassembler_options. (gdb_buffered_insn_length_init_dis): Initilize di->disassembler_options. (get_disassembler_options): New function. (set_disassembler_options): Likewise. (set_disassembler_options_sfunc): Likewise. (show_disassembler_options_sfunc): Likewise. (disassembler_options_completer): Likewise. (_initialize_disasm): Likewise. * disasm.h (get_disassembler_options): New prototype. (set_disassembler_options): Likewise. * gdbarch.sh (gdbarch_disassembler_options): New variable. (gdbarch_verify_disassembler_options): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * arm-tdep.c (num_disassembly_options): Delete. (set_disassembly_style): Likewise. (arm_disassembler_options): New static variable. (set_disassembly_style_sfunc): Convert short style name into long option name. Call set_disassembler_options. (show_disassembly_style_sfunc): New function. (arm_gdbarch_init): Call set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. (_initialize_arm_tdep): Delete regnames variable and update callers. (arm_disassembler_options): Initialize. (disasm_options): New variable. (num_disassembly_options): Rename from this... (num_disassembly_styles): ...to this. Compute by scanning through disasm_options. (valid_disassembly_styles): Initialize using disasm_options. Remove calls to parse_arm_disassembler_option, get_arm_regnames and set_arm_regname_option. Pass show_disassembly_style_sfunc to the "disassembler" setshow command. * rs6000-tdep.c (powerpc_disassembler_options): New static variable. (rs6000_gdbarch_init): Call set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. * s390-tdep.c (s390_disassembler_options): New static variable. (s390_gdbarch_init):all set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. gdb/testsuite/ * gdb.arch/powerpc-power.exp: Delete test. * gdb.arch/powerpc-power.s: Likewise. * gdb.disasm/disassembler-options.exp: New test. * gdb.arch/powerpc-altivec.exp: Likewise. * gdb.arch/powerpc-altivec.s: Likewise. * gdb.arch/powerpc-altivec2.exp: Likewise. * gdb.arch/powerpc-altivec2.s: Likewise. * gdb.arch/powerpc-altivec3.exp: Likewise. * gdb.arch/powerpc-altivec3.s: Likewise. * gdb.arch/powerpc-power7.exp: Likewise. * gdb.arch/powerpc-power7.s: Likewise. * gdb.arch/powerpc-power8.exp: Likewise. * gdb.arch/powerpc-power8.s: Likewise. * gdb.arch/powerpc-power9.exp: Likewise. * gdb.arch/powerpc-power9.s: Likewise. * gdb.arch/powerpc-vsx.exp: Likewise. * gdb.arch/powerpc-vsx.s: Likewise. * gdb.arch/powerpc-vsx2.exp: Likewise. * gdb.arch/powerpc-vsx2.s: Likewise. * gdb.arch/powerpc-vsx3.exp: Likewise. * gdb.arch/powerpc-vsx3.s: Likewise. * gdb.arch/arm-disassembler-options.exp: Likewise. * gdb.arch/powerpc-disassembler-options.exp: Likewise. * gdb.arch/s390-disassembler-options.exp: Likewise.
2017-02-28 19:32:07 +01:00
/* Returns GDBARCH's disassembler options. */
extern char *get_disassembler_options (struct gdbarch *gdbarch);
/* Sets the active gdbarch's disassembler options to OPTIONS. */
extern void set_disassembler_options (char *options);
#endif