From cb173f45df703d3fefdae724846b87d41e9ed4f0 Mon Sep 17 00:00:00 2001 From: Jim Kingdon Date: Mon, 29 Apr 1991 05:28:45 +0000 Subject: [PATCH] Initial revision --- gdb/tahoe-opcode.h | 213 +++++++++++++++++++++++++++++ gdb/tahoe-pinsn.c | 223 ++++++++++++++++++++++++++++++ gdb/tm-tahoe.h | 334 +++++++++++++++++++++++++++++++++++++++++++++ gdb/xm-tahoe.h | 147 ++++++++++++++++++++ 4 files changed, 917 insertions(+) create mode 100755 gdb/tahoe-opcode.h create mode 100644 gdb/tahoe-pinsn.c create mode 100644 gdb/tm-tahoe.h create mode 100644 gdb/xm-tahoe.h diff --git a/gdb/tahoe-opcode.h b/gdb/tahoe-opcode.h new file mode 100755 index 0000000000..b5cee249ee --- /dev/null +++ b/gdb/tahoe-opcode.h @@ -0,0 +1,213 @@ +/* + * Ported by the State University of New York at Buffalo by the Distributed + * Computer Systems Lab, Department of Computer Science, 1991. + */ + +#ifndef tahoe_opcodeT +#define tahoe_opcodeT int +#endif /* no tahoe_opcodeT */ + +struct vot_wot /* tahoe opcode table: wot to do with this */ + /* particular opcode */ +{ + char * args; /* how to compile said opcode */ + tahoe_opcodeT code; /* op-code (may be > 8 bits!) */ +}; + +struct vot /* tahoe opcode text */ +{ + char * name; /* opcode name: lowercase string [key] */ + struct vot_wot detail; /* rest of opcode table [datum] */ +}; + +#define vot_how args +#define vot_code code +#define vot_detail detail +#define vot_name name + +static struct vot +votstrs[] = +{ +{ "halt", {"", 0x00 } }, +{ "sinf", {"", 0x05 } }, +{ "ldf", {"rl", 0x06 } }, +{ "ldd", {"rq", 0x07 } }, +{ "addb2", {"rbmb", 0x08 } }, +{ "movb", {"rbwb", 0x09 } }, +{ "addw2", {"rwmw", 0x0a } }, +{ "movw", {"rwww", 0x0b } }, +{ "addl2", {"rlml", 0x0c } }, +{ "movl", {"rlwl", 0x0d } }, +{ "bbs", {"rlvlbw", 0x0e } }, +{ "nop", {"", 0x10 } }, +{ "brb", {"bb", 0x11 } }, +{ "brw", {"bw", 0x13 } }, +{ "cosf", {"", 0x15 } }, +{ "lnf", {"rl", 0x16 } }, +{ "lnd", {"rq", 0x17 } }, +{ "addb3", {"rbrbwb", 0x18 } }, +{ "cmpb", {"rbwb", 0x19 } }, +{ "addw3", {"rwrwww", 0x1a } }, +{ "cmpw", {"rwww", 0x1b } }, +{ "addl3", {"rlrlwl", 0x1c } }, +{ "cmpl", {"rlwl", 0x1d } }, +{ "bbc", {"rlvlbw", 0x1e } }, +{ "rei", {"", 0x20 } }, +{ "bneq", {"bb", 0x21 } }, +{ "bnequ", {"bb", 0x21 } }, +{ "cvtwl", {"rwwl", 0x23 } }, +{ "stf", {"wl", 0x26 } }, +{ "std", {"wq", 0x27 } }, +{ "subb2", {"rbmb", 0x28 } }, +{ "mcomb", {"rbwb", 0x29 } }, +{ "subw2", {"rwmw", 0x2a } }, +{ "mcomw", {"rwww", 0x2b } }, +{ "subl2", {"rlml", 0x2c } }, +{ "mcoml", {"rlwl", 0x2d } }, +{ "emul", {"rlrlrlwq", 0x2e } }, +{ "aoblss", {"rlmlbw", 0x2f } }, +{ "bpt", {"", 0x30 } }, +{ "beql", {"bb", 0x31 } }, +{ "beqlu", {"bb", 0x31 } }, +{ "cvtwb", {"rwwb", 0x33 } }, +{ "logf", {"", 0x35 } }, +{ "cmpf", {"rl", 0x36 } }, +{ "cmpd", {"rq", 0x37 } }, +{ "subb3", {"rbrbwb", 0x38 } }, +{ "bitb", {"rbrb", 0x39 } }, +{ "subw3", {"rwrwww", 0x3a } }, +{ "bitw", {"rwrw", 0x3b } }, +{ "subl3", {"rlrlwl", 0x3c } }, +{ "bitl", {"rlrl", 0x3d } }, +{ "ediv", {"rlrqwlwl", 0x3e } }, +{ "aobleq", {"rlmlbw", 0x3f } }, +{ "ret", {"", 0x40 } }, +{ "bgtr", {"bb", 0x41 } }, +{ "sqrtf", {"", 0x45 } }, +{ "cmpf2", {"rl", 0x46 } }, +{ "cmpd2", {"rqrq", 0x47 } }, +{ "shll", {"rbrlwl", 0x48 } }, +{ "clrb", {"wb", 0x49 } }, +{ "shlq", {"rbrqwq", 0x4a } }, +{ "clrw", {"ww", 0x4b } }, +{ "mull2", {"rlml", 0x4c } }, +{ "clrl", {"wl", 0x4d } }, +{ "shal", {"rbrlwl", 0x4e } }, +{ "bleq", {"bb", 0x51 } }, +{ "expf", {"", 0x55 } }, +{ "tstf", {"", 0x56 } }, +{ "tstd", {"", 0x57 } }, +{ "shrl", {"rbrlwl", 0x58 } }, +{ "tstb", {"rb", 0x59 } }, +{ "shrq", {"rbrqwq", 0x5a } }, +{ "tstw", {"rw", 0x5b } }, +{ "mull3", {"rlrlwl", 0x5c } }, +{ "tstl", {"rl", 0x5d } }, +{ "shar", {"rbrlwl", 0x5e } }, +{ "bbssi", {"rlmlbw", 0x5f } }, +{ "ldpctx", {"", 0x60 } }, +{ "pushd", {"", 0x67 } }, +{ "incb", {"mb", 0x69 } }, +{ "incw", {"mw", 0x6b } }, +{ "divl2", {"rlml", 0x6c } }, +{ "incl", {"ml", 0x6d } }, +{ "cvtlb", {"rlwb", 0x6f } }, +{ "svpctx", {"", 0x70 } }, +{ "jmp", {"ab", 0x71 } }, +{ "cvlf", {"rl", 0x76 } }, +{ "cvld", {"rl", 0x77 } }, +{ "decb", {"mb", 0x79 } }, +{ "decw", {"mw", 0x7b } }, +{ "divl3", {"rlrlwl", 0x7c } }, +{ "decl", {"ml", 0x7d } }, +{ "cvtlw", {"rlww", 0x7f } }, +{ "bgeq", {"bb", 0x81 } }, +{ "movs2", {"abab", 0x82 } }, +{ "cvfl", {"wl", 0x86 } }, +{ "cvdl", {"wl", 0x87 } }, +{ "orb2", {"rbmb", 0x88 } }, +{ "cvtbl", {"rbwl", 0x89 } }, +{ "orw2", {"rwmw", 0x8a } }, +{ "bispsw", {"rw", 0x8b } }, +{ "orl2", {"rlml", 0x8c } }, +{ "adwc", {"rlml", 0x8d } }, +{ "adda", {"rlml", 0x8e } }, +{ "blss", {"bb", 0x91 } }, +{ "cmps2", {"abab", 0x92 } }, +{ "ldfd", {"rl", 0x97 } }, +{ "orb3", {"rbrbwb", 0x98 } }, +{ "cvtbw", {"rbww", 0x99 } }, +{ "orw3", {"rwrwww", 0x9a } }, +{ "bicpsw", {"rw", 0x9b } }, +{ "orl3", {"rlrlwl", 0x9c } }, +{ "sbwc", {"rlml", 0x9d } }, +{ "suba", {"rlml", 0x9e } }, +{ "bgtru", {"bb", 0xa1 } }, +{ "cvdf", {"", 0xa6 } }, +{ "andb2", {"rbmb", 0xa8 } }, +{ "movzbl", {"rbwl", 0xa9 } }, +{ "andw2", {"rwmw", 0xaa } }, +{ "loadr", {"rwal", 0xab } }, +{ "andl2", {"rlml", 0xac } }, +{ "mtpr", {"rlrl", 0xad } }, +{ "ffs", {"rlwl", 0xae } }, +{ "blequ", {"bb", 0xb1 } }, +{ "negf", {"", 0xb6 } }, +{ "negd", {"", 0xb7 } }, +{ "andb3", {"rbrbwb", 0xb8 } }, +{ "movzbw", {"rbww", 0xb9 } }, +{ "andw3", {"rwrwww", 0xba } }, +{ "storer", {"rwal", 0xbb } }, +{ "andl3", {"rlrlwl", 0xbc } }, +{ "mfpr", {"rlwl", 0xbd } }, +{ "ffc", {"rlwl", 0xbe } }, +{ "calls", {"rbab", 0xbf } }, +{ "prober", {"rbabrl", 0xc0 } }, +{ "bvc", {"bb", 0xc1 } }, +{ "movs3", {"ababrw", 0xc2 } }, +{ "movzwl", {"rwwl", 0xc3 } }, +{ "addf", {"rl", 0xc6 } }, +{ "addd", {"rq", 0xc7 } }, +{ "xorb2", {"rbmb", 0xc8 } }, +{ "movob", {"rbwb", 0xc9 } }, +{ "xorw2", {"rwmw", 0xca } }, +{ "movow", {"rwww", 0xcb } }, +{ "xorl2", {"rlml", 0xcc } }, +{ "movpsl", {"wl", 0xcd } }, +{ "kcall", {"rw", 0xcf } }, +{ "probew", {"rbabrl", 0xd0 } }, +{ "bvs", {"bb", 0xd1 } }, +{ "cmps3", {"ababrw", 0xd2 } }, +{ "subf", {"rq", 0xd6 } }, +{ "subd", {"rq", 0xd7 } }, +{ "xorb3", {"rbrbwb", 0xd8 } }, +{ "pushb", {"rb", 0xd9 } }, +{ "xorw3", {"rwrwww", 0xda } }, +{ "pushw", {"rw", 0xdb } }, +{ "xorl3", {"rlrlwl", 0xdc } }, +{ "pushl", {"rl", 0xdd } }, +{ "insque", {"abab", 0xe0 } }, +{ "bcs", {"bb", 0xe1 } }, +{ "bgequ", {"bb", 0xe1 } }, +{ "mulf", {"rq", 0xe6 } }, +{ "muld", {"rq", 0xe7 } }, +{ "mnegb", {"rbwb", 0xe8 } }, +{ "movab", {"abwl", 0xe9 } }, +{ "mnegw", {"rwww", 0xea } }, +{ "movaw", {"awwl", 0xeb } }, +{ "mnegl", {"rlwl", 0xec } }, +{ "moval", {"alwl", 0xed } }, +{ "remque", {"ab", 0xf0 } }, +{ "bcc", {"bb", 0xf1 } }, +{ "blssu", {"bb", 0xf1 } }, +{ "divf", {"rq", 0xf6 } }, +{ "divd", {"rq", 0xf7 } }, +{ "movblk", {"alalrw", 0xf8 } }, +{ "pushab", {"ab", 0xf9 } }, +{ "pushaw", {"aw", 0xfb } }, +{ "casel", {"rlrlrl", 0xfc } }, +{ "pushal", {"al", 0xfd } }, +{ "callf", {"rbab", 0xfe } }, +{ "" , "" } /* empty is end sentinel */ + +}; diff --git a/gdb/tahoe-pinsn.c b/gdb/tahoe-pinsn.c new file mode 100644 index 0000000000..32796da568 --- /dev/null +++ b/gdb/tahoe-pinsn.c @@ -0,0 +1,223 @@ +/* + * Ported by the State University of New York at Buffalo by the Distributed + * Computer Systems Lab, Department of Computer Science, 1991. + */ + +#include + +#include "defs.h" +#include "param.h" +#include "symtab.h" +#include "opcode.h" + +/* Tahoe instructions are never longer than this. */ +#define MAXLEN 62 + +/* Number of elements in the opcode table. */ +#define NOPCODES (sizeof votstrs / sizeof votstrs[0]) + +extern char *reg_names[]; + +static unsigned char *print_insn_arg (); + +/* Print the Tahoe instruction at address MEMADDR in debugged memory, + on STREAM. Returns length of the instruction, in bytes. */ + +int +print_insn (memaddr, stream) + CORE_ADDR memaddr; + FILE *stream; +{ + unsigned char buffer[MAXLEN]; + register int i; + register unsigned char *p; + register char *d; + + read_memory (memaddr, buffer, MAXLEN); + + for (i = 0; i < NOPCODES; i++) + if (votstrs[i].detail.code == buffer[0] + || votstrs[i].detail.code == *(unsigned short *)buffer) + break; + + /* Handle undefined instructions. */ + if (i == NOPCODES) + { + fprintf (stream, "0%o", buffer[0]); + return 1; + } + + fprintf (stream, "%s", votstrs[i].name); + + /* Point at first byte of argument data, + and at descriptor for first argument. */ + p = buffer + 1 + (votstrs[i].detail.code >= 0x100); + d = votstrs[i].detail.args; + + if (*d) + fputc ('\t', stream); + + while (*d) + { + p = print_insn_arg (d, p, memaddr + (p - buffer), stream); + d += 2; + if (*d) + fprintf (stream, ","); + } + return p - buffer; +} +/*******************************************************************/ +static unsigned char * +print_insn_arg (d, p, addr, stream) + char *d; + register char *p; + CORE_ADDR addr; + FILE *stream; +{ + int temp1 = 0; + register int regnum = *p & 0xf; + float floatlitbuf; + + if (*d == 'b') + { + if (d[1] == 'b') + fprintf (stream, "0x%x", addr + *p++ + 1); + else + { + + temp1 = *p; + temp1 <<= 8; + temp1 |= *(p + 1); + fprintf (stream, "0x%x", addr + temp1 + 2); + p += 2; + } + } + else + switch ((*p++ >> 4) & 0xf) + { + case 0: + case 1: + case 2: + case 3: /* Liter>al(short immediate byte) mode */ + if (d[1] == 'd' || d[1] == 'f' || d[1] == 'g' || d[1] == 'h') + { + *(int *)&floatlitbuf = 0x4000 + ((p[-1] & 0x3f) << 4); + fprintf (stream, "$%f", floatlitbuf); + } + else + fprintf (stream, "$%d", p[-1] & 0x3f); + break; + + case 4: /* Indexed */ + p = (char *) print_insn_arg (d, p, addr + 1, stream); + fprintf (stream, "[%s]", reg_names[regnum]); + break; + + case 5: /* Register */ + fprintf (stream, reg_names[regnum]); + break; + + case 7: /* Autodecrement */ + fputc ('-', stream); + case 6: /* Register deferred */ + fprintf (stream, "(%s)", reg_names[regnum]); + break; + + case 9: /* Absolute Address & Autoincrement deferred */ + fputc ('*', stream); + if (regnum == PC_REGNUM) + { + temp1 = *p; + temp1 <<= 8; + temp1 |= *(p +1); + + fputc ('$', stream); + print_address (temp1, stream); + p += 4; + break; + } + case 8: /*Immediate & Autoincrement SP */ + if (regnum == 8) /*88 is Immediate Byte Mode*/ + fprintf (stream, "$%d", *p++); + + else if (regnum == 9) /*89 is Immediate Word Mode*/ + { + temp1 = *p; + temp1 <<= 8; + temp1 |= *(p +1); + fprintf (stream, "$%d", temp1); + p += 2; + } + + else if (regnum == PC_REGNUM) /*8F is Immediate Long Mode*/ + { + temp1 = *p; + temp1 <<=8; + temp1 |= *(p +1); + temp1 <<=8; + temp1 |= *(p +2); + temp1 <<= 8; + temp1 |= *(p +3); + fprintf (stream, "$%d", temp1); + p += 4; + } + + else /*8E is Autoincrement SP Mode*/ + fprintf (stream, "(%s)+", reg_names[regnum]); + break; + + case 11: /* Register + Byte Displacement Deferred Mode*/ + fputc ('*', stream); + case 10: /* Register + Byte Displacement Mode*/ + if (regnum == PC_REGNUM) + print_address (addr + *p + 2, stream); + else + fprintf (stream, "%d(%s)", *p, reg_names[regnum]); + p += 1; + break; + + case 13: /* Register + Word Displacement Deferred Mode*/ + fputc ('*', stream); + case 12: /* Register + Word Displacement Mode*/ + temp1 = *p; + temp1 <<= 8; + temp1 |= *(p +1); + if (regnum == PC_REGNUM) + print_address (addr + temp1 + 3, stream); + else + fprintf (stream, "%d(%s)", temp1, reg_names[regnum]); + p += 2; + break; + + case 15: /* Register + Long Displacement Deferred Mode*/ + fputc ('*', stream); + case 14: /* Register + Long Displacement Mode*/ + temp1 = *p; + temp1 <<= 8; + temp1 |= *(p +1); + temp1 <<= 8; + temp1 |= *(p +2); + temp1 <<= 8; + temp1 |= *(p +3); + if (regnum == PC_REGNUM) + print_address (addr + temp1 + 5, stream); + else + fprintf (stream, "%d(%s)", temp1, reg_names[regnum]); + p += 4; + } + + return (unsigned char *) p; +} + + + + + + + + + + + + + diff --git a/gdb/tm-tahoe.h b/gdb/tm-tahoe.h new file mode 100644 index 0000000000..fddfb84a9e --- /dev/null +++ b/gdb/tm-tahoe.h @@ -0,0 +1,334 @@ +/* Definitions to make GDB target for a tahoe running 4.3-Reno. + Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. + +This file is part of GDB. + +GDB is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GDB is distributed in the hope that it will be useful, +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 +along with GDB; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* + * Ported by the State University of New York at Buffalo by the Distributed + * Computer Systems Lab, Department of Computer Science, 1991. + */ + +#define TARGET_BYTE_ORDER BIG_ENDIAN +#define BITS_BIG_ENDIAN 0 + +/* Define this if the C compiler puts an underscore at the front + of external names before giving them to the linker. */ + +#define NAMES_HAVE_UNDERSCORE + +/* Debugger information will be in DBX format. */ + +#define READ_DBX_FORMAT + +/* Offset from address of function to start of its code. + Zero on most machines. */ + +#define FUNCTION_START_OFFSET 2 + +/* Advance PC across any function entry prologue instructions + to reach some "real" code. */ + +#define SKIP_PROLOGUE(pc) \ +{ register int op = (unsigned char) read_memory_integer (pc, 1); \ + if (op == 0x11) pc += 2; /* skip brb */ \ + if (op == 0x13) pc += 3; /* skip brw */ \ + if (op == 0x2c && \ + ((unsigned char) read_memory_integer (pc+2, 1)) == 0x5e) \ + pc += 3; /* skip subl2 */ \ + if (op == 0xe9 && \ + ((unsigned char) read_memory_integer (pc+1, 1)) == 0xae && \ + ((unsigned char) read_memory_integer(pc+3, 1)) == 0x5e) \ + pc += 4; /* skip movab */ \ + if (op == 0xe9 && \ + ((unsigned char) read_memory_integer (pc+1, 1)) == 0xce && \ + ((unsigned char) read_memory_integer(pc+4, 1)) == 0x5e) \ + pc += 5; /* skip movab */ \ + if (op == 0xe9 && \ + ((unsigned char) read_memory_integer (pc+1, 1)) == 0xee && \ + ((unsigned char) read_memory_integer(pc+6, 1)) == 0x5e) \ + pc += 7; /* skip movab */ \ +} + +/* Immediately after a function call, return the saved pc. + Can't always go through the frames for this because on some machines + the new frame is not set up until the new function executes + some instructions. */ + +#define SAVED_PC_AFTER_CALL(frame) FRAME_SAVED_PC(frame) + +/* Wrong for cross-debugging. I don't know the real values. */ +#define TARGET_UPAGES UPAGES +#define TARGET_NBPG NBPG + +/* This is the amount to subtract from u.u_ar0 + to get the offset in the core file of the register values. */ + +#define KERNEL_U_ADDR (0xc0000000 - (TARGET_UPAGES * TARGET_NBPG)) + +/* Address of end of stack space. */ + +#define STACK_END_ADDR (0xc0000000 - (TARGET_UPAGES * TARGET_NBPG)) + +/* On BSD, sigtramp is in the u area. Can't check the exact + addresses because for cross-debugging we don't have target include + files around. This should be close enough. */ +#define IN_SIGTRAMP(pc, name) ((pc) >= STACK_END_ADDR && (pc < 0xc0000000)) + +/* Stack grows downward. */ + +#define INNER_THAN < + +/* Sequence of bytes for breakpoint instruction. */ + +#define BREAKPOINT {0x30} + +/* Amount PC must be decremented by after a breakpoint. + This is often the number of bytes in BREAKPOINT + but not always. */ + +#define DECR_PC_AFTER_BREAK 0 + +/* Nonzero if instruction at PC is a return instruction. */ + +#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x40) + +/* Return 1 if P points to an invalid floating point value. + LEN is the length in bytes -- not relevant on the Tahoe. */ + +#define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000) + +/* Say how long (ordinary) registers are. */ + +#define REGISTER_TYPE long + +/* Number of machine registers */ + +#define NUM_REGS 19 + +/* Initializer for an array of names of registers. + There should be NUM_REGS strings in this initializer. */ + +#define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "fp", "sp", "pc", "ps", "al", "ah"} + +#define FP_REGNUM 13 /* Contains address of executing stack frame */ +#define SP_REGNUM 14 /* Contains address of top of stack */ +#define PC_REGNUM 15 /* Contains program counter */ +#define PS_REGNUM 16 /* Contains processor status */ + +#define AL_REGNUM 17 /* Contains accumulator */ +#define AH_REGNUM 18 + +/* Total amount of space needed to store our copies of the machine's + register state, the array `registers'. */ + +#define REGISTER_BYTES (19*4) + +/* Index within `registers' of the first byte of the space for + register N. */ + +#define REGISTER_BYTE(N) ((N) * 4) + +/* Number of bytes of storage in the actual machine representation + for register N. On the tahoe, all regs are 4 bytes. */ + +#define REGISTER_RAW_SIZE(N) 4 + +/* Number of bytes of storage in the program's representation + for register N. On the tahoe, all regs are 4 bytes. */ + +#define REGISTER_VIRTUAL_SIZE(N) 4 + +/* Largest value REGISTER_RAW_SIZE can have. */ + +#define MAX_REGISTER_RAW_SIZE 4 + +/* Largest value REGISTER_VIRTUAL_SIZE can have. */ + +#define MAX_REGISTER_VIRTUAL_SIZE 4 + +/* Nonzero if register N requires conversion + from raw format to virtual format. */ + +#define REGISTER_CONVERTIBLE(N) 0 + +/* Convert data from raw format for register REGNUM + to virtual format for register REGNUM. */ + +#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ + bcopy ((FROM), (TO), 4); + +/* Convert data from virtual format for register REGNUM + to raw format for register REGNUM. */ + +#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ + bcopy ((FROM), (TO), 4); + +/* Return the GDB type object for the "standard" data type + of data in register N. */ + +#define REGISTER_VIRTUAL_TYPE(N) builtin_type_int + +/* Store the address of the place in which to copy the structure the + subroutine will return. This is called from call_function. */ + +#define STORE_STRUCT_RETURN(ADDR, SP) \ + { write_register (1, (ADDR)); } + +/* Extract from an array REGBUF containing the (raw) register state + a function return value of type TYPE, and copy that, in virtual format, + into VALBUF. */ + +#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ + bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) + +/* Write into appropriate registers a function return value + of type TYPE, given in virtual format. */ + +#define STORE_RETURN_VALUE(TYPE,VALBUF) \ + write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) + +/* Extract from an array REGBUF containing the (raw) register state + the address in which a function should return its structure value, + as a CORE_ADDR (or an expression that can be used as one). */ + +#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) + +/* Describe the pointer in each stack frame to the previous stack frame + (its caller). + + FRAME_CHAIN takes a frame's nominal address + and produces the frame's chain-pointer. + + FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address + and produces the nominal address of the caller frame. + + However, if FRAME_CHAIN_VALID returns zero, + it means the given frame is the outermost one and has no caller. + In that case, FRAME_CHAIN_COMBINE is not used. */ + +/* In the case of the Tahoe, the frame's nominal address is the FP value, + and it points to the old FP */ + +#define FRAME_CHAIN(thisframe) \ + (outside_startup_file ((thisframe)->pc) ? \ + read_memory_integer ((thisframe)->frame, 4) :\ + 0) + +#define FRAME_CHAIN_VALID(chain, thisframe) \ + (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) + +#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) + +/* Define other aspects of the stack frame. */ + +/* Saved PC */ + +#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame - 8, 4)) + +/* In most of GDB, getting the args address is too important to + just say "I don't know". */ + +#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame+4) + +/* Address to use as an anchor for finding local variables */ + +#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) + +/* Return number of args passed to a frame. + Can return -1, meaning no way to tell. */ + +#define FRAME_NUM_ARGS(numargs, fi) \ +{ numargs = ((0xffff & read_memory_integer(((fi)->frame-4),4)) - 4) >> 2; } + +/* Return number of bytes at start of arglist that are not really args. */ + +#define FRAME_ARGS_SKIP 0 + +/* Put here the code to store, into a struct frame_saved_regs, + the addresses of the saved registers of frame described by FRAME_INFO. + This includes special registers such as pc and fp saved in special + ways in the stack frame. sp is even more special: + the address we return for it IS the sp for the next frame. */ + +#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ +{ register int regnum; \ + register int rmask = read_memory_integer ((frame_info)->frame-4, 4) >> 16;\ + register CORE_ADDR next_addr; \ + bzero (&frame_saved_regs, sizeof frame_saved_regs); \ + next_addr = (frame_info)->frame - 8; \ + for (regnum = 12; regnum >= 0; regnum--, rmask <<= 1) \ + (frame_saved_regs).regs[regnum] = (rmask & 0x1000) ? (next_addr -= 4) : 0;\ + (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4; \ + (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame - 8; \ + (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ +} + +/* Things needed for making the inferior call functions. */ + +/* Push an empty stack frame, to record the current PC, etc. */ + +#define PUSH_DUMMY_FRAME \ +{ register CORE_ADDR sp = read_register (SP_REGNUM); \ + register int regnum; \ +printf("PUSH_DUMMY_FRAME\n"); \ + sp = push_word (sp, read_register (FP_REGNUM)); \ + write_register (FP_REGNUM, sp); \ + sp = push_word (sp, 0x1fff0004); /*SAVE MASK*/ \ + sp = push_word (sp, read_register (PC_REGNUM)); \ + for (regnum = 12; regnum >= 0; regnum--) \ + sp = push_word (sp, read_register (regnum)); \ + write_register (SP_REGNUM, sp); \ +} + +/* Discard from the stack the innermost frame, restoring all registers. */ + +#define POP_FRAME \ +{ register CORE_ADDR fp = read_register (FP_REGNUM); \ + register int regnum; \ + register int regmask = read_memory_integer (fp-4, 4); \ +printf("POP_FRAME\n"); \ + regmask >>= 16; \ + write_register (SP_REGNUM, fp+4); \ + write_register (PC_REGNUM, read_memory_integer(fp-8, 4)); \ + write_register (FP_REGNUM, read_memory_integer(fp, 4)); \ + fp -= 8; \ + for (regnum = 12; regnum >= 0; regnum--, regmask <<= 1) \ + if (regmask & 0x1000) \ + write_register (regnum, read_memory_integer (fp-=4, 4)); \ + flush_cached_frames (); \ + set_current_frame (create_new_frame (read_register (FP_REGNUM), \ + read_pc ())); } + +/* This sequence of words is the instructions + calls #69, @#32323232 + bpt + Note this is 8 bytes. */ + +#define CALL_DUMMY {0xbf699f32, 0x32323230} + +/* Start execution at beginning of dummy */ + +#define CALL_DUMMY_START_OFFSET 0 + +/* Insert the specified number of args and function address + into a call sequence of the above form stored at DUMMYNAME. */ + +#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ +{ int temp = (int) fun; \ + *((char *) dummyname + 1) = nargs; \ + bcopy(&temp,(char *)dummyname+3,4); } + diff --git a/gdb/xm-tahoe.h b/gdb/xm-tahoe.h new file mode 100644 index 0000000000..924fffa83f --- /dev/null +++ b/gdb/xm-tahoe.h @@ -0,0 +1,147 @@ +/* Definitions to make GDB hosted on a tahoe running 4.3-Reno + Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. + +This file is part of GDB. + +GDB is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GDB is distributed in the hope that it will be useful, +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 +along with GDB; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* + * Ported by the State University of New York at Buffalo by the Distributed + * Computer Systems Lab, Department of Computer Science, 1991. + */ + +/* + * These first two are kludges to get this thing to compile under Reno (or + * at least the Reno running on okeeffe). It seems there are a few problems + * with the include files. + */ + +/* to compile infrun.c - + don't allow sys/dir.h to be included, it gets redefined and + by ufs/dir.h and screws up my life! */ +#define _DIRENT_ + +/* to compile remote.c - + when sys/ioctl.h get's called we need USE_OLD_TTY defined + so that ioctl_compat.h will be included. latter, sgtty.h + tries to define USE_OLD_TTY and call sys/ioctl.h but it's + too late */ +#define USE_OLD_TTY + +/* Get rid of any system-imposed stack limit if possible. */ + +#define SET_STACK_LIMIT_HUGE + +#define REGISTER_U_ADDR(addr, blockend, regno) \ +{ addr = blockend - 100 + regno * 4; \ + if (regno == PC_REGNUM) addr = blockend - 8; \ + if (regno == PS_REGNUM) addr = blockend - 4; \ + if (regno == FP_REGNUM) addr = blockend - 40; \ + if (regno == SP_REGNUM) addr = blockend - 36; \ + if (regno == AL_REGNUM) addr = blockend - 20; \ + if (regno == AH_REGNUM) addr = blockend - 24;} + +/* Interface definitions for kernel debugger KDB. */ + +/* Map machine fault codes into signal numbers. + First subtract 0, divide by 4, then index in a table. + Faults for which the entry in this table is 0 + are not handled by KDB; the program's own trap handler + gets to handle then. */ + +#define FAULT_CODE_ORIGIN 0 +#define FAULT_CODE_UNITS 4 +#define FAULT_TABLE \ +{ 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ + 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0} + +/* Start running with a stack stretching from BEG to END. + BEG and END should be symbols meaningful to the assembler. + This is used only for kdb. */ + +#define INIT_STACK(beg, end) \ +{ asm (".globl end"); \ + asm ("movl $ end, sp"); \ + asm ("clrl fp"); } + +/* Push the frame pointer register on the stack. */ + +#define PUSH_FRAME_PTR \ + asm ("pushl fp"); + +/* Copy the top-of-stack to the frame pointer register. */ + +#define POP_FRAME_PTR \ + asm ("movl (sp), fp"); + +/* After KDB is entered by a fault, push all registers + that GDB thinks about (all NUM_REGS of them), + so that they appear in order of ascending GDB register number. + The fault code will be on the stack beyond the last register. */ + +#define PUSH_REGISTERS \ +{ asm ("pushl 8(sp)"); \ + asm ("pushl 8(sp)"); \ + asm ("pushal 0x41(sp)"); \ + asm ("pushl r0" ); \ + asm ("pushl r1" ); \ + asm ("pushl r2" ); \ + asm ("pushl r3" ); \ + asm ("pushl r4" ); \ + asm ("pushl r5" ); \ + asm ("pushl r6" ); \ + asm ("pushl r7" ); \ + asm ("pushl r8" ); \ + asm ("pushl r9" ); \ + asm ("pushl r10" ); \ + asm ("pushl r11" ); \ + asm ("pushl r12" ); \ + asm ("pushl fp" ); \ + asm ("pushl sp" ); \ + asm ("pushl pc" ); \ + asm ("pushl ps" ); \ + asm ("pushl aclo" ); \ + asm ("pushl achi" ); \ +} + +/* Assuming the registers (including processor status) have been + pushed on the stack in order of ascending GDB register number, + restore them and return to the address in the saved PC register. */ + +#define POP_REGISTERS \ +{ \ + asm ("movl (sp)+, achi"); \ + asm ("movl (sp)+, aclo"); \ + asm ("movl (sp)+, ps"); \ + asm ("movl (sp)+, pc"); \ + asm ("movl (sp)+, sp"); \ + asm ("movl (sp)+, fp"); \ + asm ("movl (sp)+, r12"); \ + asm ("movl (sp)+, r11"); \ + asm ("movl (sp)+, r10"); \ + asm ("movl (sp)+, r9"); \ + asm ("movl (sp)+, r8"); \ + asm ("movl (sp)+, r7"); \ + asm ("movl (sp)+, r6"); \ + asm ("movl (sp)+, r5"); \ + asm ("movl (sp)+, r4"); \ + asm ("movl (sp)+, r3"); \ + asm ("movl (sp)+, r2"); \ + asm ("movl (sp)+, r1"); \ + asm ("movl (sp)+, r0"); \ + asm ("subl2 $8,(sp)"); \ + asm ("movl (sp),sp"); \ + asm ("rei"); } -- 2.34.1