From: Peter Schauer Date: Wed, 30 Mar 1994 10:00:00 +0000 (+0000) Subject: * config/i386/tm-symmetry.h: Clean up, it is now only used for Dynix. X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=8a19fe21884872da39f245395a5684e4f73c79c5;p=deliverable%2Fbinutils-gdb.git * config/i386/tm-symmetry.h: Clean up, it is now only used for Dynix. Remove all conditionals and definitions for ptx. I386_REGNO_TO_SYMMETRY moved to here from symm-tdep.c. Fix addresses of floating point registers in REGISTER_U_ADDR. STORE_STRUCT_RETURN now handles cc and gcc conventions. FRAME_CHAIN, FRAMELESS_FUNCTION_INVOCATION, FRAME_SAVED_PC, IN_SIGTRAMP, SIGCONTEXT_PC_OFFSET defined to make backtracing through signal trampoline code work. * config/i386/xm-symmetry.h: Clean up, it is now only used for Dynix. Remove all conditionals and definitions for ptx. Remove KDB definitions. --- diff --git a/gdb/config/i386/tm-symmetry.h b/gdb/config/i386/tm-symmetry.h index 34e03b1532..9440057078 100644 --- a/gdb/config/i386/tm-symmetry.h +++ b/gdb/config/i386/tm-symmetry.h @@ -1,6 +1,7 @@ /* Target machine definitions for GDB on a Sequent Symmetry under dynix 3.0, with Weitek 1167 and i387 support. - Copyright 1986, 1987, 1989, 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994 + Free Software Foundation, Inc. Symmetry version by Jay Vosburgh (fubar@sequent.com). This file is part of GDB. @@ -21,20 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* I don't know if this will work for cross-debugging, even if you do get a copy of the right include file. */ -#ifdef _SEQUENT_ -/* ptx */ -#include -#else -/* dynix */ #include -#endif - -#ifdef _SEQUENT_ -/* ptx, not dynix */ -#define SDB_REG_TO_REGNUM(value) ptx_coff_regno_to_gdb(value) -extern int ptx_coff_regno_to_gdb(); - -#endif /* _SEQUENT_ */ #define START_INFERIOR_TRAPS_EXPECTED 2 @@ -46,13 +34,6 @@ extern int ptx_coff_regno_to_gdb(); #include "i386/tm-i386v.h" -/* Nonzero if instruction at PC is a return instruction. */ -/* For Symmetry, this is really the 'leave' instruction, which */ -/* is right before the ret */ - -#undef ABOUT_TO_RETURN -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc9) - #if 0 /* --- this code can't be used unless we know we are running native, since it uses host specific ptrace calls. */ @@ -126,8 +107,17 @@ extern int ptx_coff_regno_to_gdb(); #define PS_REGNUM 17 /* eflags--Contains processor status */ #define EFLAGS_REGNUM 17 -#ifndef _SEQUENT_ -/* dynix, not ptx. For ptx, see register_addr in symm-tdep.c */ +/* + * Following macro translates i386 opcode register numbers to Symmetry + * register numbers. This is used by i386_frame_find_saved_regs. + * + * %eax %ecx %edx %ebx %esp %ebp %esi %edi + * i386 0 1 2 3 4 5 6 7 + * Symmetry 0 2 1 5 14 15 6 7 + * + */ +#define I386_REGNO_TO_SYMMETRY(n) \ +((n)==0?0 :(n)==1?2 :(n)==2?1 :(n)==3?5 :(n)==4?14 :(n)==5?15 :(n)) /* The magic numbers below are offsets into u_ar0 in the user struct. * They live in . Gdb calls this macro with blockend @@ -146,12 +136,10 @@ switch (regno) { \ case 2: \ addr = blockend + ECX * sizeof(int); break; \ case 3: /* st(0) */ \ - addr = blockend - \ - ((int)&foo.u_fpusave.fpu_stack[0][0] - (int)&foo); \ + addr = ((int)&foo.u_fpusave.fpu_stack[0][0] - (int)&foo); \ break; \ case 4: /* st(1) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[1][0] - (int)&foo); \ + addr = ((int) &foo.u_fpusave.fpu_stack[1][0] - (int)&foo); \ break; \ case 5: \ addr = blockend + EBX * sizeof(int); break; \ @@ -160,28 +148,22 @@ switch (regno) { \ case 7: \ addr = blockend + EDI * sizeof(int); break; \ case 8: /* st(2) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[2][0] - (int)&foo); \ + addr = ((int) &foo.u_fpusave.fpu_stack[2][0] - (int)&foo); \ break; \ case 9: /* st(3) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[3][0] - (int)&foo); \ + addr = ((int) &foo.u_fpusave.fpu_stack[3][0] - (int)&foo); \ break; \ case 10: /* st(4) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[4][0] - (int)&foo); \ + addr = ((int) &foo.u_fpusave.fpu_stack[4][0] - (int)&foo); \ break; \ case 11: /* st(5) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[5][0] - (int)&foo); \ + addr = ((int) &foo.u_fpusave.fpu_stack[5][0] - (int)&foo); \ break; \ case 12: /* st(6) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[6][0] - (int)&foo); \ + addr = ((int) &foo.u_fpusave.fpu_stack[6][0] - (int)&foo); \ break; \ case 13: /* st(7) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[7][0] - (int)&foo); \ + addr = ((int) &foo.u_fpusave.fpu_stack[7][0] - (int)&foo); \ break; \ case 14: \ addr = blockend + ESP * sizeof(int); break; \ @@ -222,126 +204,9 @@ switch (regno) { \ case 46: /* fp29 */ \ case 47: /* fp30 */ \ case 48: /* fp31 */ \ - addr = blockend - \ - ((int) &foo.u_fpasave.fpa_regs[(regno)-18] - (int)&foo); \ - } \ -} -#endif /* not _SEQUENT_ */ - -#ifdef _SEQUENT_ -/* ptx. For Dynix, see above */ - -/* - * For ptx, this is a little bit bizarre, since the register block - * is below the u area in memory. This means that blockend here ends - * up being negative (for the call from coredep.c) since the value in - * u.u_ar0 will be less than KERNEL_U_ADDR (and coredep.c passes us - * u.u_ar0 - KERNEL_U_ADDR in blockend). Since we also define - * FETCH_INFERIOR_REGISTERS (and supply our own functions for that), - * the core file case will be the only use of this function. - */ - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ struct user foo; /* needed for finding fpu regs */ \ -switch (regno) { \ - case 0: \ - addr = blockend + (NBPG * UPAGES) - sizeof(struct user) + (EAX * sizeof(int)); break; \ - case 1: \ - addr = blockend + (NBPG * UPAGES) - sizeof(struct user) + (EDX * sizeof(int)); break; \ - case 2: \ - addr = blockend + (NBPG * UPAGES) - sizeof(struct user) + (ECX * sizeof(int)); break; \ - case 3: /* st(0) */ \ - addr = blockend - KERNEL_U_ADDR + \ - ((int)&foo.u_fpusave.fpu_stack[0][0] - (int)&foo); \ - break; \ - case 4: /* st(1) */ \ - addr = blockend - KERNEL_U_ADDR + \ - ((int) &foo.u_fpusave.fpu_stack[1][0] - (int)&foo); \ - break; \ - case 5: \ - addr = blockend + (NBPG * UPAGES) - sizeof(struct user) + (EBX * sizeof(int)); break; \ - case 6: \ - addr = blockend + (NBPG * UPAGES) - sizeof(struct user) + (ESI * sizeof(int)); break; \ - case 7: \ - addr = blockend + (NBPG * UPAGES) - sizeof(struct user) + (EDI * sizeof(int)); break; \ - case 8: /* st(2) */ \ - addr = blockend - KERNEL_U_ADDR + \ - ((int) &foo.u_fpusave.fpu_stack[2][0] - (int)&foo); \ - break; \ - case 9: /* st(3) */ \ - addr = blockend - KERNEL_U_ADDR + \ - ((int) &foo.u_fpusave.fpu_stack[3][0] - (int)&foo); \ - break; \ - case 10: /* st(4) */ \ - addr = blockend - KERNEL_U_ADDR + \ - ((int) &foo.u_fpusave.fpu_stack[4][0] - (int)&foo); \ - break; \ - case 11: /* st(5) */ \ - addr = blockend - KERNEL_U_ADDR + \ - ((int) &foo.u_fpusave.fpu_stack[5][0] - (int)&foo); \ - break; \ - case 12: /* st(6) */ \ - addr = blockend - KERNEL_U_ADDR + \ - ((int) &foo.u_fpusave.fpu_stack[6][0] - (int)&foo); \ - break; \ - case 13: /* st(7) */ \ - addr = blockend - KERNEL_U_ADDR + \ - ((int) &foo.u_fpusave.fpu_stack[7][0] - (int)&foo); \ - break; \ - case 14: \ - addr = blockend + (NBPG * UPAGES) - sizeof(struct user) + (ESP * sizeof(int)); break; \ - case 15: \ - addr = blockend + (NBPG * UPAGES) - sizeof(struct user) + (EBP * sizeof(int)); break; \ - case 16: \ - addr = blockend + (NBPG * UPAGES) - sizeof(struct user) + (EIP * sizeof(int)); break; \ - case 17: \ - addr = blockend + (NBPG * UPAGES) - sizeof(struct user) + (FLAGS * sizeof(int)); break; \ - case 18: /* fp1 */ \ - case 19: /* fp2 */ \ - case 20: /* fp3 */ \ - case 21: /* fp4 */ \ - case 22: /* fp5 */ \ - case 23: /* fp6 */ \ - case 24: /* fp7 */ \ - case 25: /* fp8 */ \ - case 26: /* fp9 */ \ - case 27: /* fp10 */ \ - case 28: /* fp11 */ \ - case 29: /* fp12 */ \ - case 30: /* fp13 */ \ - case 31: /* fp14 */ \ - case 32: /* fp15 */ \ - case 33: /* fp16 */ \ - case 34: /* fp17 */ \ - case 35: /* fp18 */ \ - case 36: /* fp19 */ \ - case 37: /* fp20 */ \ - case 38: /* fp21 */ \ - case 39: /* fp22 */ \ - case 40: /* fp23 */ \ - case 41: /* fp24 */ \ - case 42: /* fp25 */ \ - case 43: /* fp26 */ \ - case 44: /* fp27 */ \ - case 45: /* fp28 */ \ - case 46: /* fp29 */ \ - case 47: /* fp30 */ \ - case 48: /* fp31 */ \ - addr = blockend - KERNEL_U_ADDR + \ - ((int) &foo.u_fpasave.fpa_regs[(regno)-18] - (int)&foo); \ + addr = ((int) &foo.u_fpasave.fpa_regs[(regno)-18] - (int)&foo); \ } \ } -#endif /* _SEQUENT_ */ - -#undef FRAME_CHAIN -#define FRAME_CHAIN(thisframe) ((thisframe)->pc == 0 ? \ - 0 : read_memory_integer((thisframe)->frame, 4)) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - ((chain) != 0) - -#undef FRAME_ARGS_SKIP -#define FRAME_ARGS_SKIP 0 /* Total amount of space needed to store our copies of the machine's register state, the array `registers'. */ @@ -389,6 +254,8 @@ switch (regno) { \ (N < 14) ? 1 : \ 0) +#include "floatformat.h" + /* Convert data from raw format for register REGNUM in buffer FROM to virtual format with type TYPE in buffer TO. */ @@ -396,11 +263,9 @@ switch (regno) { \ #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \ { \ double val; \ - i387_to_double ((FROM), (char *)&val); \ + floatformat_to_double (&floatformat_i387_ext, (FROM), &val); \ store_floating ((TO), TYPE_LENGTH (TYPE), val); \ } -extern void -i387_to_double PARAMS ((char *, char *)); /* Convert data from virtual format with type TYPE in buffer FROM to raw format for register REGNUM in buffer TO. */ @@ -409,10 +274,8 @@ i387_to_double PARAMS ((char *, char *)); #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \ { \ double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \ - double_to_i387((char *)&val, (TO)); \ + floatformat_from_double (&floatformat_i387_ext, &val, (TO)); \ } -extern void -double_to_i387 PARAMS ((char *, char *)); /* Return the GDB type object for the "standard" data type of data in register N. */ @@ -425,17 +288,14 @@ double_to_i387 PARAMS ((char *, char *)); (N < 14) ? builtin_type_double : \ builtin_type_int) -/* from m-i386.h (now known as tm-i386v.h). */ /* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. FIXME: - Why is it writing register 0? Is the symmetry different from tm-i386v.h, - or is it some sort of artifact? FIXME. */ + subroutine will return. This is called from call_function. + Native cc passes the address in eax, gcc (up to version 2.5.8) + passes it on the stack. gcc should be fixed in future versions to + adopt native cc conventions. */ #undef STORE_STRUCT_RETURN -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { (SP) -= sizeof (ADDR); \ - write_memory ((SP), (char *) &(ADDR), sizeof (ADDR)); \ - write_register(0, (ADDR)); } +#define STORE_STRUCT_RETURN(ADDR, SP) write_register(0, (ADDR)) /* Extract from an array REGBUF containing the (raw) register state a function return value of type TYPE, and copy that, in virtual format, @@ -451,3 +311,46 @@ print_387_control_word PARAMS ((unsigned int)); extern void print_387_status_word PARAMS ((unsigned int)); + +/* The following redefines make backtracing through sigtramp work. + They manufacture a fake sigtramp frame and obtain the saved pc in sigtramp + from the sigcontext structure which is pushed by the kernel on the + user stack, along with a pointer to it. */ + +#define IN_SIGTRAMP(pc, name) ((name) && STREQ ("_sigcode", name)) + +/* Offset to saved PC in sigcontext, from . */ +#define SIGCONTEXT_PC_OFFSET 16 + +/* FRAME_CHAIN takes a frame's nominal address and produces the frame's + chain-pointer. + In the case of the i386, the frame's nominal address + is the address of a 4-byte word containing the calling frame's address. */ +#undef FRAME_CHAIN +#define FRAME_CHAIN(thisframe) \ + (thisframe->signal_handler_caller \ + ? thisframe->frame \ + : (!inside_entry_file ((thisframe)->pc) \ + ? read_memory_integer ((thisframe)->frame, 4) \ + : 0)) + +/* A macro that tells us whether the function invocation represented + by FI does not have a frame on the stack associated with it. If it + does not, FRAMELESS is set to 1, else 0. */ +#undef FRAMELESS_FUNCTION_INVOCATION +#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ + do { \ + if ((FI)->signal_handler_caller) \ + (FRAMELESS) = 0; \ + else \ + (FRAMELESS) = frameless_look_for_prologue(FI); \ + } while (0) + +/* Saved Pc. Get it from sigcontext if within sigtramp. */ + +#undef FRAME_SAVED_PC +#define FRAME_SAVED_PC(FRAME) \ + (((FRAME)->signal_handler_caller \ + ? sigtramp_saved_pc (FRAME) \ + : read_memory_integer ((FRAME)->frame + 4, 4)) \ + ) diff --git a/gdb/config/i386/xm-symmetry.h b/gdb/config/i386/xm-symmetry.h index 1d0d42d479..a810fdfbda 100644 --- a/gdb/config/i386/xm-symmetry.h +++ b/gdb/config/i386/xm-symmetry.h @@ -1,6 +1,6 @@ /* Definitions to make GDB run on a Sequent Symmetry under - dynix 3.1 and ptx 1.3, with Weitek 1167 and i387 support. - Copyright 1986, 1987, 1989, 1992, 1993 Free Software Foundation, Inc. + dynix 3.1, with Weitek 1167 and i387 support. + Copyright 1986, 1987, 1989, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of GDB. @@ -25,136 +25,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define HAVE_WAIT_STRUCT -#ifdef _SEQUENT_ -/* ptx */ -#define HAVE_TERMIOS -#define USG - -#define MEM_FNS_DECLARED - -#define NEED_POSIX_SETPGID - -#define USE_O_NOCTTY - -#else -/* dynix */ - /* Get rid of any system-imposed stack limit if possible. */ #define SET_STACK_LIMIT_HUGE -#endif - -/* XPT_DEBUG doesn't work yet under Dynix 3.0.12, but UNDEBUG does... */ -/* #define PTRACE_ATTACH XPT_DEBUG -#define PTRACE_DETACH XPT_UNDEBUG -#define ATTACH_DETACH */ - -#ifdef _SEQUENT_ -/* ptx does attach as of ptx version 2.1 */ -#define ATTACH_DETACH 1 -#endif - #define HOST_BYTE_ORDER LITTLE_ENDIAN /* We must fetch all the regs before storing, since we store all at once. */ #define CHILD_PREPARE_TO_STORE() read_register_bytes (0, NULL, REGISTER_BYTES) - -/* Interface definitions for kernel debugger KDB. */ -/* This doesn't work... */ -/* 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, %esp"); \ - asm ("movl %ebp, $0"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("pushl %ebp"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (%esp), %ebp"); - -/* 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("pushad"); } -/* -{ asm("pushl %eax"); \ - asm("pushl %edx"); \ - asm("pushl %ecx"); \ - asm("pushl %st(0)"); \ - asm("pushl %st(1)"); \ - asm("pushl %ebx"); \ - asm("pushl %esi"); \ - asm("pushl %edi"); \ - asm("pushl %st(2)"); \ - asm("pushl %st(3)"); \ - asm("pushl %st(4)"); \ - asm("pushl %st(5)"); \ - asm("pushl %st(6)"); \ - asm("pushl %st(7)"); \ - asm("pushl %esp"); \ - asm("pushl %ebp"); \ - asm("pushl %eip"); \ - asm("pushl %eflags"); \ - asm("pushl %fp1"); \ - asm("pushl %fp2"); \ - asm("pushl %fp3"); \ - asm("pushl %fp4"); \ - asm("pushl %fp5"); \ - asm("pushl %fp6"); \ - asm("pushl %fp7"); \ - asm("pushl %fp8"); \ - asm("pushl %fp9"); \ - asm("pushl %fp10"); \ - asm("pushl %fp11"); \ - asm("pushl %fp12"); \ - asm("pushl %fp13"); \ - asm("pushl %fp14"); \ - asm("pushl %fp15"); \ - asm("pushl %fp16"); \ - asm("pushl %fp17"); \ - asm("pushl %fp18"); \ - asm("pushl %fp19"); \ - asm("pushl %fp20"); \ - asm("pushl %fp21"); \ - asm("pushl %fp22"); \ - asm("pushl %fp23"); \ - asm("pushl %fp24"); \ - asm("pushl %fp25"); \ - asm("pushl %fp26"); \ - asm("pushl %fp27"); \ - asm("pushl %fp28"); \ - asm("pushl %fp29"); \ - asm("pushl %fp30"); \ - asm("pushl %fp31"); \ -} -*/ -/* 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 ("popad"); }