diff options
author | Yao Qi <yao.qi@linaro.org> | 2017-01-26 14:29:19 +0000 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2017-01-26 14:29:19 +0000 |
commit | e47ad6c0bd7aa388b1bd488f6ef522c20c0b94ed (patch) | |
tree | 4b8aaa68f2fe8da7c061d4d5b46c2e2b0bb74142 /gdb/spu-tdep.c | |
parent | 80d758749a7a679288e6e72b2e849b814413b719 (diff) | |
download | gdb-e47ad6c0bd7aa388b1bd488f6ef522c20c0b94ed.zip gdb-e47ad6c0bd7aa388b1bd488f6ef522c20c0b94ed.tar.gz gdb-e47ad6c0bd7aa388b1bd488f6ef522c20c0b94ed.tar.bz2 |
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.
Diffstat (limited to 'gdb/spu-tdep.c')
-rw-r--r-- | gdb/spu-tdep.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c index 8756256..70d7f6f 100644 --- a/gdb/spu-tdep.c +++ b/gdb/spu-tdep.c @@ -33,6 +33,7 @@ #include "value.h" #include "inferior.h" #include "dis-asm.h" +#include "disasm.h" #include "objfiles.h" #include "language.h" #include "regcache.h" @@ -1693,18 +1694,19 @@ spu_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) /* Disassembler. */ -struct spu_dis_asm_data +struct spu_dis_asm_info : disassemble_info { - struct gdbarch *gdbarch; int id; }; static void spu_dis_asm_print_address (bfd_vma addr, struct disassemble_info *info) { - struct spu_dis_asm_data *data - = (struct spu_dis_asm_data *) info->application_data; - print_address (data->gdbarch, SPUADDR (data->id, addr), + struct spu_dis_asm_info *data = (struct spu_dis_asm_info *) info; + gdb_disassembler *di + = static_cast<gdb_disassembler *>(info->application_data); + + print_address (di->arch (), SPUADDR (data->id, addr), (struct ui_file *) info->stream); } @@ -1714,12 +1716,10 @@ gdb_print_insn_spu (bfd_vma memaddr, struct disassemble_info *info) /* The opcodes disassembler does 18-bit address arithmetic. Make sure the SPU ID encoded in the high bits is added back when we call print_address. */ - struct disassemble_info spu_info = *info; - struct spu_dis_asm_data data; - data.gdbarch = (struct gdbarch *) info->application_data; - data.id = SPUADDR_SPU (memaddr); + struct spu_dis_asm_info spu_info; - spu_info.application_data = &data; + memcpy (&spu_info, info, sizeof (*info)); + spu_info.id = SPUADDR_SPU (memaddr); spu_info.print_address_func = spu_dis_asm_print_address; return print_insn_spu (memaddr, &spu_info); } |