X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fmips-pinsn.c;h=fff36d83c3faa7d70b0fdda2bc655af5c6ad7c1d;hb=8ed0509162c9a6f44d174b2ff3b59134815496f3;hp=39c82ffec0c76ab46d4a05ec70f5bb653226fed9;hpb=d747e0af3d41f19815ab972f6fc9527fbf52804a;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/mips-pinsn.c b/gdb/mips-pinsn.c index 39c82ffec0..fff36d83c3 100644 --- a/gdb/mips-pinsn.c +++ b/gdb/mips-pinsn.c @@ -1,6 +1,5 @@ /* Print mips instructions for GDB, the GNU debugger. - Copyright 1989, 1991 Free Software Foundation, Inc. - Contributed by Nobuyuki Hikichi(hikichi@sra.co.jp) + Copyright 1989, 1991, 1992, 1993 Free Software Foundation, Inc. This file is part of GDB. @@ -19,87 +18,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" -#include "symtab.h" -#include "opcode/mips.h" +#include "dis-asm.h" -/* Mips instructions are never longer than this many bytes. */ -#define MAXLEN 4 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof mips_opcodes / sizeof mips_opcodes[0]) - -#define MKLONG(p) *(unsigned long*)p - -extern char *reg_names[]; - - -/* subroutine */ -static unsigned char * -print_insn_arg (d, l, stream, pc) - char *d; - register unsigned long int *l; - FILE *stream; - CORE_ADDR pc; -{ - switch (*d) - { - case ',': - case '(': - case ')': - fputc (*d, stream); - break; - - case 's': - fprintf (stream, "$%s", reg_names[((struct op_i_fmt *) l)->rs]); - break; - - case 't': - fprintf (stream, "$%s", reg_names[((struct op_i_fmt *) l)->rt]); - break; - - case 'i': - fprintf (stream, "%d", ((struct op_i_fmt *) l)->immediate); - break; - - case 'j': /* same as i, but sign-extended */ - fprintf (stream, "%d", ((struct op_b_fmt *) l)->delta); - break; - - case 'a': - print_address ((pc & 0xF0000000) | (((struct op_j_fmt *)l)->target << 2), - stream); - break; - - case 'b': - print_address ((((struct op_b_fmt *) l)->delta << 2) + pc + 4, stream); - break; - - case 'd': - fprintf (stream, "$%s", reg_names[((struct op_r_fmt *) l)->rd]); - break; - - case 'h': - fprintf (stream, "0x%x", ((struct op_r_fmt *) l)->shamt); - break; - - case 'S': - fprintf (stream, "$f%d", ((struct fop_r_fmt *) l)->fs); - break; - - case 'T': - fprintf (stream, "$f%d", ((struct fop_r_fmt *) l)->ft); - break; - - case 'D': - fprintf (stream, "$f%d", ((struct fop_r_fmt *) l)->fd); - break; - - default: - fprintf (stream, "# internal error, undefined modifier(%c)", *d); - break; - } -} - /* Print the mips instruction at address MEMADDR in debugged memory, on STREAM. Returns length of the instruction, in bytes, which is always 4. */ @@ -107,40 +27,15 @@ print_insn_arg (d, l, stream, pc) int print_insn (memaddr, stream) CORE_ADDR memaddr; - FILE *stream; + GDB_FILE *stream; { - unsigned char buffer[MAXLEN]; - register int i; - register char *d; - unsigned long int l; - - read_memory (memaddr, buffer, MAXLEN); - - for (i = 0; i < NOPCODES; i++) - { - register unsigned int opcode = mips_opcodes[i].opcode; - register unsigned int match = mips_opcodes[i].match; - if ((*(unsigned int*)buffer & match) == opcode) - break; - } - - l = MKLONG (buffer); - /* Handle undefined instructions. */ - if (i == NOPCODES) - { - fprintf (stream, "0x%x",l); - return 4; - } - - fprintf (stream, "%s", mips_opcodes[i].name); - - if (!(d = mips_opcodes[i].args)) - return 4; - - fputc (' ', stream); + disassemble_info info; - while (*d) - print_insn_arg (d++, &l, stream, memaddr); + GDB_INIT_DISASSEMBLE_INFO(info, stream); - return 4; + /* print_insn_mips is in opcodes/mips-dis.c. */ + if (TARGET_BYTE_ORDER == BIG_ENDIAN) + return print_insn_big_mips ((bfd_vma) memaddr, &info); + else + return print_insn_little_mips ((bfd_vma) memaddr, &info); }