1991-03-29 00:28:29 +08:00
|
|
|
|
/* Print mips instructions for GDB, the GNU debugger.
|
* defs.h: Incorporate param.h. All users changed.
* param-no-tm.h: Change users to define TM_FILE_OVERRIDE instead.
* param.h, param-no-tm.h: Removed.
* Update copyrights in all changed files.
* dbxread.c, dwarfread.c, inflow.c, infrun.c, m2-exp.y, putenv.c,
solib.c, symtab.h, tm-umax.h, valprint.c: Lint.
* tm-convex.h, tm-hp300hpux.h, tm-merlin.h, tm-sparc.h,
xm-merlin.h: Avoid host include files in target descriptions.
* getpagesize.h: Removed, libiberty copes now.
1991-11-22 02:42:05 +08:00
|
|
|
|
Copyright 1989, 1991 Free Software Foundation, Inc.
|
1991-03-29 00:28:29 +08:00
|
|
|
|
Contributed by Nobuyuki Hikichi(hikichi@sra.co.jp)
|
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
1991-06-04 16:31:55 +09:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
1991-03-29 00:28:29 +08:00
|
|
|
|
it under the terms of the GNU General Public License as published by
|
1991-06-04 16:31:55 +09:00
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
1991-03-29 00:28:29 +08:00
|
|
|
|
|
1991-06-04 16:31:55 +09:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
1991-03-29 00:28:29 +08:00
|
|
|
|
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
|
1991-06-04 16:31:55 +09:00
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
1991-03-29 00:28:29 +08:00
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include "symtab.h"
|
|
|
|
|
#include "mips-opcode.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':
|
1991-07-09 11:08:13 +09:00
|
|
|
|
fprintf (stream, "$%s", reg_names[((struct op_r_fmt *) l)->rd]);
|
1991-03-29 00:28:29 +08:00
|
|
|
|
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. */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
print_insn (memaddr, stream)
|
|
|
|
|
CORE_ADDR memaddr;
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
while (*d)
|
|
|
|
|
print_insn_arg (d++, &l, stream, memaddr);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|