diff options
author | Yao Qi <yao.qi@linaro.org> | 2017-05-24 17:23:52 +0100 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2017-05-24 17:23:52 +0100 |
commit | 003ca0fd22863aaf1a9811c8a35a0133a2d27fb1 (patch) | |
tree | e988f36b10ca84252d27167db6d8d32e81f1c831 /opcodes/disassemble.c | |
parent | 60fd657792228e3eb59e87c26fcdeccbfe94d224 (diff) | |
download | gdb-003ca0fd22863aaf1a9811c8a35a0133a2d27fb1.zip gdb-003ca0fd22863aaf1a9811c8a35a0133a2d27fb1.tar.gz gdb-003ca0fd22863aaf1a9811c8a35a0133a2d27fb1.tar.bz2 |
Refactor disassembler selection
Nowadays, opcodes/disassemble.c:disassembler selects the proper
disassembler according to ABFD only. However, it actually
selects disassemblers according to arch, mach, endianess, and
abfd. This patch adds them to the parameters of disassembler,
so that its caller can still select disassemblers in case that
abfd is NULL (a typical case in GDB).
There isn't any functionality change.
binutils:
2017-05-24 Yao Qi <yao.qi@linaro.org>
* objdump.c (disassemble_data): Caller update.
include:
2017-05-24 Yao Qi <yao.qi@linaro.org>
* dis-asm.h (disassembler): Update declaration.
opcodes:
2017-05-24 Yao Qi <yao.qi@linaro.org>
* disassemble.c (disassembler): Add arguments a, big and mach.
Use them.
sim/common:
2017-05-24 Yao Qi <yao.qi@linaro.org>
* sim-trace.c (trace_disasm): Caller update.
Diffstat (limited to 'opcodes/disassemble.c')
-rw-r--r-- | opcodes/disassemble.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/opcodes/disassemble.c b/opcodes/disassemble.c index dd7d3a3..e79b5c7 100644 --- a/opcodes/disassemble.c +++ b/opcodes/disassemble.c @@ -21,6 +21,7 @@ #include "sysdep.h" #include "dis-asm.h" #include "safe-ctype.h" +#include <assert.h> #ifdef ARCH_all #define ARCH_aarch64 @@ -109,11 +110,22 @@ #endif disassembler_ftype -disassembler (bfd *abfd) +disassembler (enum bfd_architecture a, bfd_boolean big, unsigned long mach, + bfd *abfd) { - enum bfd_architecture a = bfd_get_arch (abfd); disassembler_ftype disassemble; + if (abfd != NULL) + { + /* Do some asserts that the first three parameters should equal + to what we can get from ABFD. On the other hand, these + asserts help removing some compiler errors on unused + parameter. */ + assert (a == bfd_get_arch (abfd)); + assert (big == bfd_big_endian (abfd)); + assert (mach == bfd_get_mach (abfd)); + } + switch (a) { /* If you add a case to this table, also add it to the @@ -135,7 +147,7 @@ disassembler (bfd *abfd) #endif #ifdef ARCH_arm case bfd_arch_arm: - if (bfd_big_endian (abfd)) + if (big) disassemble = print_insn_big_arm; else disassemble = print_insn_little_arm; @@ -184,13 +196,12 @@ disassembler (bfd *abfd) #endif #ifdef ARCH_h8300 case bfd_arch_h8300: - if (bfd_get_mach (abfd) == bfd_mach_h8300h - || bfd_get_mach (abfd) == bfd_mach_h8300hn) + if (mach == bfd_mach_h8300h || mach == bfd_mach_h8300hn) disassemble = print_insn_h8300h; - else if (bfd_get_mach (abfd) == bfd_mach_h8300s - || bfd_get_mach (abfd) == bfd_mach_h8300sn - || bfd_get_mach (abfd) == bfd_mach_h8300sx - || bfd_get_mach (abfd) == bfd_mach_h8300sxn) + else if (mach == bfd_mach_h8300s + || mach == bfd_mach_h8300sn + || mach == bfd_mach_h8300sx + || mach == bfd_mach_h8300sxn) disassemble = print_insn_h8300s; else disassemble = print_insn_h8300; @@ -326,7 +337,7 @@ disassembler (bfd *abfd) #endif #ifdef ARCH_mips case bfd_arch_mips: - if (bfd_big_endian (abfd)) + if (big) disassemble = print_insn_big_mips; else disassemble = print_insn_little_mips; @@ -349,7 +360,7 @@ disassembler (bfd *abfd) #endif #ifdef ARCH_nios2 case bfd_arch_nios2: - if (bfd_big_endian (abfd)) + if (big) disassemble = print_insn_big_nios2; else disassemble = print_insn_little_nios2; @@ -372,7 +383,7 @@ disassembler (bfd *abfd) #endif #ifdef ARCH_powerpc case bfd_arch_powerpc: - if (bfd_big_endian (abfd)) + if (big) disassemble = print_insn_big_powerpc; else disassemble = print_insn_little_powerpc; @@ -390,7 +401,7 @@ disassembler (bfd *abfd) #endif #ifdef ARCH_rs6000 case bfd_arch_rs6000: - if (bfd_get_mach (abfd) == bfd_mach_ppc_620) + if (mach == bfd_mach_ppc_620) disassemble = print_insn_big_powerpc; else disassemble = print_insn_rs6000; @@ -413,7 +424,7 @@ disassembler (bfd *abfd) #endif #ifdef ARCH_score case bfd_arch_score: - if (bfd_big_endian (abfd)) + if (big) disassemble = print_insn_big_score; else disassemble = print_insn_little_score; @@ -507,7 +518,7 @@ disassembler (bfd *abfd) #endif #ifdef ARCH_z8k case bfd_arch_z8k: - if (bfd_get_mach(abfd) == bfd_mach_z8001) + if (mach == bfd_mach_z8001) disassemble = print_insn_z8001; else disassemble = print_insn_z8002; |