home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / gnu / gdb-4.12-src.lha / gdb-4.12 / gdb / config / i386 / tm-symmetry.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-03  |  12.0 KB  |  398 lines

  1. /* Target machine definitions for GDB on a Sequent Symmetry under dynix 3.0,
  2.    with Weitek 1167 and i387 support.
  3.    Copyright 1986, 1987, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
  4.    Symmetry version by Jay Vosburgh (fubar@sequent.com).
  5.  
  6. This file is part of GDB.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program; if not, write to the Free Software
  20. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  21.  
  22. /* I don't know if this will work for cross-debugging, even if you do get
  23.    a copy of the right include file.  */
  24. #ifdef _SEQUENT_
  25. /* ptx */
  26. #include <sys/reg.h>
  27. #else
  28. /* dynix */
  29. #include <machine/reg.h>
  30. #endif
  31.  
  32. #ifdef _SEQUENT_
  33. /* ptx, not dynix */
  34. #define SDB_REG_TO_REGNUM(value) ptx_coff_regno_to_gdb(value)
  35. extern int ptx_coff_regno_to_gdb();
  36. #endif /* _SEQUENT_ */
  37.  
  38. #define START_INFERIOR_TRAPS_EXPECTED 2
  39.  
  40. /* Amount PC must be decremented by after a breakpoint.
  41.    This is often the number of bytes in BREAKPOINT
  42.    but not always.  */
  43.  
  44. #define DECR_PC_AFTER_BREAK 0
  45.  
  46. #include "i386/tm-i386v.h"
  47.  
  48. /* Nonzero if instruction at PC is a return instruction.  */
  49. /* For Symmetry, this is really the 'leave' instruction, which */
  50. /* is right before the ret */
  51.  
  52. #undef
  53. #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc9)
  54.  
  55. #if 0
  56.  --- this code can't be used unless we know we are running native,
  57.      since it uses host specific ptrace calls.
  58. /* code for 80387 fpu.  Functions are from i386-dep.c, copied into
  59.  * symm-dep.c.
  60.  */
  61. #define FLOAT_INFO { i386_float_info(); }
  62. #endif
  63.  
  64. /* Number of machine registers */
  65. #undef NUM_REGS
  66. #define NUM_REGS 49
  67.  
  68. /* Initializer for an array of names of registers.
  69.    There should be NUM_REGS strings in this initializer.  */
  70.  
  71. /* Symmetry registers are in this weird order to match the register
  72.    numbers in the symbol table entries.  If you change the order,
  73.    things will probably break mysteriously for no apparent reason.
  74.    Also note that the st(0)...st(7) 387 registers are represented as
  75.    st0...st7.  */
  76.  
  77. #undef REGISTER_NAMES
  78. #define REGISTER_NAMES { "eax", "edx", "ecx", "st0", "st1", \
  79.                  "ebx", "esi", "edi", "st2", "st3", \
  80.                  "st4", "st5", "st6", "st7", "esp", \
  81.                  "ebp", "eip", "eflags", "fp1", "fp2", \
  82.                  "fp3", "fp4", "fp5", "fp6", "fp7", \
  83.                  "fp8", "fp9", "fp10", "fp11", "fp12", \
  84.                  "fp13", "fp14", "fp15", "fp16", "fp17", \
  85.                  "fp18", "fp19", "fp20", "fp21", "fp22", \
  86.                  "fp23", "fp24", "fp25", "fp26", "fp27", \
  87.                  "fp28", "fp29", "fp30", "fp31" }
  88.  
  89. /* Register numbers of various important registers.
  90.    Note that some of these values are "real" register numbers,
  91.    and correspond to the general registers of the machine,
  92.    and some are "phony" register numbers which are too large
  93.    to be actual register numbers as far as the user is concerned
  94.    but do serve to get the desired values when passed to read_register.  */
  95.  
  96. #define EAX_REGNUM    0
  97. #define EDX_REGNUM    1
  98. #define ECX_REGNUM    2
  99. #define ST0_REGNUM    3
  100. #define ST1_REGNUM    4
  101. #define EBX_REGNUM    5
  102. #define ESI_REGNUM    6
  103. #define EDI_REGNUM    7
  104. #define ST2_REGNUM    8
  105. #define ST3_REGNUM    9
  106.  
  107. #define ST4_REGNUM    10
  108. #define ST5_REGNUM    11
  109. #define ST6_REGNUM    12
  110. #define ST7_REGNUM    13
  111.  
  112. #define FP1_REGNUM 18        /* first 1167 register */
  113. /* Get %fp2 - %fp31 by addition, since they are contiguous */
  114.  
  115. #undef SP_REGNUM
  116. #define SP_REGNUM 14        /* Contains address of top of stack */
  117. #undef FP_REGNUM
  118. #define FP_REGNUM 15        /* Contains address of executing stack frame */
  119. #undef PC_REGNUM
  120. #define PC_REGNUM 16        /* Contains program counter */
  121. #undef PS_REGNUM
  122. #define PS_REGNUM 17        /* Contains processor status */
  123.  
  124. #ifndef _SEQUENT_
  125. /* dynix, not ptx.  For ptx, see register_addr in symm-tdep.c */
  126.  
  127. /* The magic numbers below are offsets into u_ar0 in the user struct.
  128.  * They live in <machine/reg.h>.  Gdb calls this macro with blockend
  129.  * holding u.u_ar0 - KERNEL_U_ADDR.  Only the registers listed are
  130.  * saved in the u area (along with a few others that aren't useful
  131.  * here.  See <machine/reg.h>).
  132.  */
  133.  
  134. #define REGISTER_U_ADDR(addr, blockend, regno) \
  135. { struct user foo;    /* needed for finding fpu regs */ \
  136. switch (regno) { \
  137.     case 0: \
  138.       addr = blockend + EAX * sizeof(int); break; \
  139.   case 1: \
  140.       addr = blockend + EDX * sizeof(int); break; \
  141.   case 2: \
  142.       addr = blockend + ECX * sizeof(int); break; \
  143.   case 3:            /* st(0) */ \
  144.       addr = blockend - \
  145.       ((int)&foo.u_fpusave.fpu_stack[0][0] - (int)&foo); \
  146.       break; \
  147.   case 4:            /* st(1) */ \
  148.       addr = blockend - \
  149.       ((int) &foo.u_fpusave.fpu_stack[1][0] - (int)&foo); \
  150.       break; \
  151.   case 5: \
  152.       addr = blockend + EBX * sizeof(int); break; \
  153.   case 6: \
  154.       addr = blockend + ESI * sizeof(int); break; \
  155.   case 7: \
  156.       addr = blockend + EDI * sizeof(int); break; \
  157.   case 8:            /* st(2) */ \
  158.       addr = blockend - \
  159.       ((int) &foo.u_fpusave.fpu_stack[2][0] - (int)&foo); \
  160.       break; \
  161.   case 9:            /* st(3) */ \
  162.       addr = blockend - \
  163.       ((int) &foo.u_fpusave.fpu_stack[3][0] - (int)&foo); \
  164.       break; \
  165.   case 10:            /* st(4) */ \
  166.       addr = blockend - \
  167.       ((int) &foo.u_fpusave.fpu_stack[4][0] - (int)&foo); \
  168.       break; \
  169.   case 11:            /* st(5) */ \
  170.       addr = blockend - \
  171.       ((int) &foo.u_fpusave.fpu_stack[5][0] - (int)&foo); \
  172.       break; \
  173.   case 12:            /* st(6) */ \
  174.       addr = blockend - \
  175.       ((int) &foo.u_fpusave.fpu_stack[6][0] - (int)&foo); \
  176.       break; \
  177.   case 13:            /* st(7) */ \
  178.       addr = blockend - \
  179.       ((int) &foo.u_fpusave.fpu_stack[7][0] - (int)&foo); \
  180.       break; \
  181.   case 14: \
  182.       addr = blockend + ESP * sizeof(int); break; \
  183.   case 15: \
  184.       addr = blockend + EBP * sizeof(int); break; \
  185.   case 16: \
  186.       addr = blockend + EIP * sizeof(int); break; \
  187.   case 17: \
  188.       addr = blockend + FLAGS * sizeof(int); break; \
  189.   case 18:            /* fp1 */ \
  190.   case 19:            /* fp2 */ \
  191.   case 20:            /* fp3 */ \
  192.   case 21:            /* fp4 */ \
  193.   case 22:            /* fp5 */ \
  194.   case 23:            /* fp6 */ \
  195.   case 24:            /* fp7 */ \
  196.   case 25:            /* fp8 */ \
  197.   case 26:            /* fp9 */ \
  198.   case 27:            /* fp10 */ \
  199.   case 28:            /* fp11 */ \
  200.   case 29:            /* fp12 */ \
  201.   case 30:            /* fp13 */ \
  202.   case 31:            /* fp14 */ \
  203.   case 32:            /* fp15 */ \
  204.   case 33:            /* fp16 */ \
  205.   case 34:            /* fp17 */ \
  206.   case 35:            /* fp18 */ \
  207.   case 36:            /* fp19 */ \
  208.   case 37:            /* fp20 */ \
  209.   case 38:            /* fp21 */ \
  210.   case 39:            /* fp22 */ \
  211.   case 40:            /* fp23 */ \
  212.   case 41:            /* fp24 */ \
  213.   case 42:            /* fp25 */ \
  214.   case 43:            /* fp26 */ \
  215.   case 44:            /* fp27 */ \
  216.   case 45:            /* fp28 */ \
  217.   case 46:            /* fp29 */ \
  218.   case 47:            /* fp30 */ \
  219.   case 48:            /* fp31 */ \
  220.      addr = blockend - \
  221.      ((int) &foo.u_fpasave.fpa_regs[(regno)-18] - (int)&foo); \
  222.   } \
  223. }
  224. #endif /* _SEQUENT_ */
  225.  
  226. /* Total amount of space needed to store our copies of the machine's
  227.    register state, the array `registers'.  */
  228. /* 10 i386 registers, 8 i387 registers, and 31 Weitek 1167 registers */
  229. #undef REGISTER_BYTES
  230. #define REGISTER_BYTES ((10 * 4) + (8 * 10) + (31 * 4))
  231.  
  232. /* Index within `registers' of the first byte of the space for
  233.    register N.  */
  234.  
  235. #undef REGISTER_BYTE
  236. #define REGISTER_BYTE(N)         \
  237. ((N < 3) ? (N * 4) :            \
  238. (N < 5) ? (((N - 2) * 10) + 2) :    \
  239. (N < 8) ? (((N - 5) * 4) + 32) :    \
  240. (N < 14) ? (((N - 8) * 10) + 44) :    \
  241.     (((N - 14) * 4) + 104))
  242.  
  243. /* Number of bytes of storage in the actual machine representation
  244.  * for register N.  All registers are 4 bytes, except 387 st(0) - st(7),
  245.  * which are 80 bits each. 
  246.  */
  247.  
  248. #undef REGISTER_RAW_SIZE
  249. #define REGISTER_RAW_SIZE(N) \
  250. ((N < 3) ? 4 :    \
  251. (N < 5) ? 10 :    \
  252. (N < 8) ? 4 :    \
  253. (N < 14) ? 10 :    \
  254.     4)
  255.  
  256. /* Largest value REGISTER_RAW_SIZE can have.  */
  257.  
  258. #undef MAX_REGISTER_RAW_SIZE
  259. #define MAX_REGISTER_RAW_SIZE 10
  260.  
  261. /* Nonzero if register N requires conversion
  262.    from raw format to virtual format.  */
  263.  
  264. #undef REGISTER_CONVERTIBLE
  265. #define REGISTER_CONVERTIBLE(N) \
  266. ((N < 3) ? 0 : \
  267. (N < 5) ? 1  : \
  268. (N < 8) ? 0  : \
  269. (N < 14) ? 1 : \
  270.     0)
  271.  
  272. /* Convert data from raw format for register REGNUM in buffer FROM
  273.    to virtual format with type TYPE in buffer TO.  */
  274.  
  275. #undef REGISTER_CONVERT_TO_VIRTUAL
  276. #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
  277. { \
  278.   double val; \
  279.   i387_to_double ((FROM), (char *)&val); \
  280.   store_floating ((TO), TYPE_LENGTH (TYPE), val); \
  281. }
  282. extern void
  283. i387_to_double PARAMS ((char *, char *));
  284.  
  285. /* Convert data from virtual format with type TYPE in buffer FROM
  286.    to raw format for register REGNUM in buffer TO.  */
  287.  
  288. #undef REGISTER_CONVERT_TO_RAW
  289. #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
  290. { \
  291.   double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
  292.   double_to_i387((char *)&val, (TO)))
  293. }
  294. extern void
  295. double_to_i387 PARAMS ((char *, char *));
  296.  
  297. /* Return the GDB type object for the "standard" data type
  298.    of data in register N.  */
  299.  
  300. #undef REGISTER_VIRTUAL_TYPE
  301. #define REGISTER_VIRTUAL_TYPE(N) \
  302. ((N < 3) ? builtin_type_int : \
  303. (N < 5) ? builtin_type_double : \
  304. (N < 8) ? builtin_type_int : \
  305. (N < 14) ? builtin_type_double : \
  306.     builtin_type_int)
  307.  
  308. /* from m-i386.h (now known as tm-i386v.h).  */
  309. /* Store the address of the place in which to copy the structure the
  310.    subroutine will return.  This is called from call_function.  FIXME:
  311.    Why is it writing register 0?  Is the symmetry different from tm-i386v.h,
  312.    or is it some sort of artifact?  FIXME.  */
  313.  
  314. #undef STORE_STRUCT_RETURN
  315. #define STORE_STRUCT_RETURN(ADDR, SP) \
  316.   { (SP) -= sizeof (ADDR);        \
  317.     write_memory ((SP), &(ADDR), sizeof (ADDR)); \
  318.     write_register(0, (ADDR)); }
  319.  
  320. /* Extract from an array REGBUF containing the (raw) register state
  321.    a function return value of type TYPE, and copy that, in virtual format,
  322.    into VALBUF.  */
  323.  
  324. #undef EXTRACT_RETURN_VALUE
  325. #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
  326.   symmetry_extract_return_value(TYPE, REGBUF, VALBUF)
  327.  
  328.  
  329. /* Things needed for making the inferior call functions.  FIXME: Merge
  330.    this with the main 386 stuff.  */
  331.  
  332. #define PUSH_DUMMY_FRAME \
  333. {  CORE_ADDR sp = read_register (SP_REGNUM); \
  334.   int regnum; \
  335.   sp = push_word (sp, read_register (PC_REGNUM)); \
  336.   sp = push_word (sp, read_register (FP_REGNUM)); \
  337.   write_register (FP_REGNUM, sp); \
  338.   for (regnum = 0; regnum < NUM_REGS; regnum++) \
  339.     sp = push_word (sp, read_register (regnum)); \
  340.   write_register (SP_REGNUM, sp); \
  341. }
  342.  
  343. #define POP_FRAME  \
  344. { \
  345.   FRAME frame = get_current_frame (); \
  346.   CORE_ADDR fp; \
  347.   int regnum; \
  348.   struct frame_saved_regs fsr; \
  349.   struct frame_info *fi; \
  350.   fi = get_frame_info (frame); \
  351.   fp = fi->frame; \
  352.   get_frame_saved_regs (fi, &fsr); \
  353.   for (regnum = 0; regnum < NUM_REGS; regnum++) { \
  354.       CORE_ADDR adr; \
  355.       adr = fsr.regs[regnum]; \
  356.       if (adr) \
  357.     write_register (regnum, read_memory_integer (adr, 4)); \
  358.   } \
  359.   write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
  360.   write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
  361.   write_register (SP_REGNUM, fp + 8); \
  362.   flush_cached_frames (); \
  363.   set_current_frame ( create_new_frame (read_register (FP_REGNUM), \
  364.                     read_pc ())); \
  365. }
  366.  
  367. /* from i386-dep.c, worked better than my original... */
  368. /* This sequence of words is the instructions
  369.  * call (32-bit offset)
  370.  * int 3
  371.  * This is 6 bytes.
  372.  */
  373.  
  374. #define CALL_DUMMY { 0x223344e8, 0xcc11 }
  375.  
  376. #define CALL_DUMMY_LENGTH 8
  377.  
  378. #define CALL_DUMMY_START_OFFSET 0  /* Start execution at beginning of dummy */
  379.  
  380. /* Insert the specified number of args and function address
  381.    into a call sequence of the above form stored at DUMMYNAME.  */
  382.  
  383. #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p)   \
  384. { \
  385.     int from, to, delta, loc; \
  386.     loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \
  387.     from = loc + 5; \
  388.     to = (int)(fun); \
  389.     delta = to - from; \
  390.     *(int *)((char *)(dummyname) + 1) = delta; \
  391. }
  392.  
  393. extern void
  394. print_387_control_word PARAMS ((unsigned int));
  395.  
  396. extern void
  397. print_387_status_word PARAMS ((unsigned int));
  398.