diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2024-06-13 19:41:13 +0200 |
---|---|---|
committer | Andreas Schwab <schwab@linux-m68k.org> | 2024-10-07 21:26:04 +0200 |
commit | 3f30f11f6d577dc4102fe1f996af3ed945b6b144 (patch) | |
tree | 801d2e1de1c65d66046e20caf9e85b91ceaddf59 | |
parent | 11fe8653a97a2d113eb58680021c657a68d5d362 (diff) | |
download | gdb-3f30f11f6d577dc4102fe1f996af3ed945b6b144.zip gdb-3f30f11f6d577dc4102fe1f996af3ed945b6b144.tar.gz gdb-3f30f11f6d577dc4102fe1f996af3ed945b6b144.tar.bz2 |
m68k: Support for jump visualization in disassembly
opcodes/
* m68k-dis.c (m68k_opcode_to_insn_type): Define.
(match_insn_m68k): Call it to set insn_type.
(print_insn_arg) [case 'B']: Set branch target address.
(print_insn_m68k): Set insn_info_valid.
-rw-r--r-- | opcodes/m68k-dis.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/opcodes/m68k-dis.c b/opcodes/m68k-dis.c index bc2f820..7e9b087 100644 --- a/opcodes/m68k-dis.c +++ b/opcodes/m68k-dis.c @@ -991,6 +991,8 @@ print_insn_arg (const char *d, else return PRINT_INSN_ARG_INVALID_OP_TABLE; + info->target = addr + disp; + (*info->print_address_func) (addr + disp, info); break; @@ -1442,6 +1444,27 @@ print_insn_arg (const char *d, return p - p0; } +/* Return the insn type determined from the opcode information. */ + +static enum dis_insn_type +m68k_opcode_to_insn_type (const struct m68k_opcode *opc) +{ + /* All branches have an operand in 'B' format (the 'B' place only comes + with the 'B' format). */ + if (strchr (opc->args, 'B') == NULL) + return dis_nonbranch; + + /* Most branches are conditional branches, detect the ones that aren't + from the opcode name. */ + if (strncmp (opc->name, "bra", 3) == 0) + return dis_branch; + + if (strncmp (opc->name, "bsr", 3) == 0) + return dis_jsr; + + return dis_condbranch; +} + /* Try to match the current instruction to best and if so, return the number of bytes consumed from the instruction stream, else zero. Return -1 on memory error. */ @@ -1573,6 +1596,7 @@ match_insn_m68k (bfd_vma memaddr, p = save_p; info->fprintf_styled_func = save_printer; info->print_address_func = save_print_address; + info->insn_type = m68k_opcode_to_insn_type (best); d = args; @@ -1730,6 +1754,7 @@ print_insn_m68k (bfd_vma memaddr, disassemble_info *info) bfd_byte *buffer = priv.the_buffer; + info->insn_info_valid = 1; info->private_data = & priv; /* Tell objdump to use two bytes per chunk and six bytes per line for displaying raw data. */ @@ -1761,6 +1786,8 @@ print_insn_m68k (bfd_vma memaddr, disassemble_info *info) info->fprintf_styled_func (info->stream, dis_style_text, " "); info->fprintf_styled_func (info->stream, dis_style_immediate, "0x%04x", (buffer[0] << 8) + buffer[1]); + + info->insn_type = dis_noninsn; } return val ? val : 2; |