home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / gdb-4.14-src.lha / gdb-4.14 / gdb / config / sparc / tm-sp64.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-21  |  13.7 KB  |  352 lines

  1. /* Target machine sub-parameters for SPARC64, for GDB, the GNU debugger.
  2.    This is included by other tm-*.h files to define SPARC cpu-related info.
  3.    Copyright 1986, 1987, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
  4.    This is (obviously) based on the SPARC Vn (n<9) port.
  5.    Contributed by Doug Evans (dje@cygnus.com).
  6.  
  7. This file is part of GDB.
  8.  
  9. This program is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2 of the License, or
  12. (at your option) any later version.
  13.  
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  22.  
  23. #include "sparc/tm-sparc.h"
  24.  
  25. /* We have long longs.  */
  26. #define LONG_LONG
  27.  
  28. /* When passing a structure to a function, Sun cc passes the address
  29.    in a register, not the structure itself.  It (under SunOS4) creates
  30.    two symbols, so we get a LOC_ARG saying the address is on the stack
  31.    (a lie, and a serious one since we don't know which register to
  32.    use), and a LOC_REGISTER saying that the struct is in a register
  33.    (sort of a lie, but fixable with REG_STRUCT_HAS_ADDR).  Gcc version
  34.    two (as of 1.92) behaves like sun cc.  REG_STRUCT_HAS_ADDR is smart
  35.    enough to distinguish between Sun cc, gcc version 1 and gcc version 2.
  36.  
  37.    This still doesn't work if the argument is not one passed in a
  38.    register (i.e. it's the 7th or later argument).  */
  39.  
  40. #undef  REG_STRUCT_HAS_ADDR
  41. #define REG_STRUCT_HAS_ADDR(gcc_p) (gcc_p != 1)
  42. #undef  STRUCT_ARG_SYM_GARBAGE
  43. #define STRUCT_ARG_SYM_GARBAGE(gcc_p) (gcc_p != 1)
  44.  
  45. /* Stack has strict alignment.  */
  46.  
  47. #undef  STACK_ALIGN
  48. #define STACK_ALIGN(ADDR) (((ADDR)+15)&-16)
  49.  
  50. /* Nonzero if instruction at PC is a return instruction.  */
  51. /* For SPARC, this is either a "jmpl %o7+8,%g0" or "jmpl %i7+8,%g0".
  52.  
  53.    Note: this does not work for functions returning structures under SunOS.
  54.    This should work for v9, however.  */
  55. #undef  ABOUT_TO_RETURN
  56. #define ABOUT_TO_RETURN(pc) \
  57.   ((read_memory_integer (pc, 4)|0x00040000) == 0x81c7e008)
  58.  
  59. /* Say how long (ordinary) registers are.  */
  60.  
  61. #undef  REGISTER_TYPE
  62. #define REGISTER_TYPE long long
  63.  
  64. /* Number of machine registers */
  65.  
  66. #undef  NUM_REGS
  67. #define NUM_REGS 127
  68.  
  69. /* Initializer for an array of names of registers.
  70.    There should be NUM_REGS strings in this initializer.  */
  71. /* Some of these registers are only accessible from priviledged mode.
  72.    They are here for kernel debuggers, etc.  */
  73. /* FIXME: icc and xcc are currently considered separate registers.
  74.    This may have to change and consider them as just one (ccr).
  75.    Let's postpone this as long as we can.  */
  76. /* FIXME: fcc0-3 are currently separate, even though they are also part of
  77.    fsr.  May have to remove them but let's postpone this as long as
  78.    possible.  */
  79. /* FIXME: cle and tle are new registers that haven't entered the docs yet.
  80.    They stand for "current little endian format" and "trap little endian
  81.    format".  */
  82.  
  83. #undef  REGISTER_NAMES
  84. #define REGISTER_NAMES  \
  85. { "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",    \
  86.   "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7",    \
  87.   "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",    \
  88.   "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7",    \
  89.                                 \
  90.   "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",        \
  91.   "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",        \
  92.   "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",    \
  93.   "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",    \
  94.   "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46",    \
  95.   "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62",    \
  96.                                                                 \
  97.   "ccr", "y", "pc", "npc", "asi", "cle", "tle",            \
  98.   "fsr", "fprs", "ver", "tick", "pil", "pstate", "wstate",    \
  99.   "tba", "tl", "tt", "tpc", "tnpc", "tstate",            \
  100.   "cwp", "cansave", "canrestore", "cleanwin", "otherwin",    \
  101.   "asr16", "asr17", "asr18", "asr19", "asr20", "asr21",        \
  102.   "asr22", "asr23", "asr24", "asr25", "asr26", "asr27",        \
  103.   "asr28", "asr29", "asr30", "asr31",                \
  104.   /* These are here at the end to simplify removing them if we have to.  */ \
  105.   "icc", "xcc", "fcc0", "fcc1", "fcc2", "fcc3"            \
  106. }
  107.  
  108. /* Register numbers of various important registers.
  109.    Note that some of these values are "real" register numbers,
  110.    and correspond to the general registers of the machine,
  111.    and some are "phony" register numbers which are too large
  112.    to be actual register numbers as far as the user is concerned
  113.    but do serve to get the desired values when passed to read_register.  */
  114.  
  115. #if 0 /* defined in tm-sparc.h, replicated for doc purposes */
  116. #define    G0_REGNUM 0             /* %g0 */
  117. #define    G1_REGNUM 1        /* %g1 */
  118. #define O0_REGNUM 8        /* %o0 */
  119. #define    SP_REGNUM 14        /* Contains address of top of stack, \
  120.                    which is also the bottom of the frame.  */
  121. #define    RP_REGNUM 15        /* Contains return address value, *before* \
  122.                    any windows get switched.  */
  123. #define    O7_REGNUM 15        /* Last local reg not saved on stack frame */
  124. #define    L0_REGNUM 16        /* First local reg that's saved on stack frame
  125.                    rather than in machine registers */
  126. #define    I0_REGNUM 24        /* %i0 */
  127. #define    FP_REGNUM 30        /* Contains address of executing stack frame */
  128. #define    I7_REGNUM 31        /* Last local reg saved on stack frame */
  129. #define    FP0_REGNUM 32        /* Floating point register 0 */
  130. #endif
  131.  
  132. #define FP_MAX_REGNUM 80    /* 1 + last fp reg number */
  133.  
  134. /* #undef v8 misc. regs */
  135.  
  136. #undef Y_REGNUM
  137. #undef PS_REGNUM
  138. #undef WIM_REGNUM
  139. #undef TBR_REGNUM
  140. #undef PC_REGNUM
  141. #undef NPC_REGNUM
  142. #undef FPS_REGNUM
  143. #undef CPS_REGNUM
  144.  
  145. /* v9 misc. and priv. regs */
  146.  
  147. #define C0_REGNUM 80                /* Start of control registers */
  148. #define CCR_REGNUM (C0_REGNUM + 0)        /* Condition Code Register (%xcc,%icc) */
  149. #define    Y_REGNUM (C0_REGNUM + 1)        /* Temp register for multiplication, etc.  */
  150. #define PC_REGNUM (C0_REGNUM + 2)        /* floating point condition code reg 2 */
  151. #define NPC_REGNUM (C0_REGNUM + 3)        /* floating point condition code reg 2 */
  152. #define ASI_REGNUM (C0_REGNUM + 4)        /* Alternate Space Identifier */
  153. #define CLE_REGNUM (C0_REGNUM + 5)        /* Current Little Endian format */
  154. #define TLE_REGNUM (C0_REGNUM + 6)        /* Trap Little Endian format */
  155. #define FSR_REGNUM (C0_REGNUM + 7)        /* Floating Point State */
  156. #define FPRS_REGNUM (C0_REGNUM + 8)        /* Floating Point Registers State */
  157. #define VER_REGNUM (C0_REGNUM + 9)        /* Version register */
  158. #define TICK_REGNUM (C0_REGNUM + 10)        /* Tick register */
  159. #define PIL_REGNUM (C0_REGNUM + 11)        /* Processor Interrupt Level */
  160. #define PSTATE_REGNUM (C0_REGNUM + 12)        /* Processor State */
  161. #define WSTATE_REGNUM (C0_REGNUM + 13)        /* Window State */
  162. #define TBA_REGNUM (C0_REGNUM + 14)        /* floating point condition code reg 3 */
  163. #define TL_REGNUM (C0_REGNUM + 15)        /* Trap Level */
  164. #define TT_REGNUM (C0_REGNUM + 16)        /* Trap Type */
  165. #define TPC_REGNUM (C0_REGNUM + 17)        /* Trap pc */
  166. #define TNPC_REGNUM (C0_REGNUM + 18)        /* Trap npc */
  167. #define TSTATE_REGNUM (C0_REGNUM + 19)        /* Trap State */
  168. #define CWP_REGNUM (C0_REGNUM + 20)        /* Current Window Pointer */
  169. #define CANSAVE_REGNUM (C0_REGNUM + 21)        /* Savable Windows */
  170. #define CANRESTORE_REGNUM (C0_REGNUM + 22)    /* Restorable Windows */
  171. #define CLEANWIN_REGNUM (C0_REGNUM + 23)    /* Clean Windows */
  172. #define OTHERWIN_REGNUM (C0_REGNUM + 24)    /* Other Windows */
  173. #define ASR_REGNUM(n) (C0_REGNUM+(25-16)+(n))    /* Ancillary State Register
  174.                            (n = 16...31) */
  175. #define ICC_REGNUM (C0_REGNUM + 41)        /* 32 bit condition codes */
  176. #define XCC_REGNUM (C0_REGNUM + 42)        /* 64 bit condition codes */
  177. #define FCC0_REGNUM (C0_REGNUM + 43)        /* floatpoint condition code reg 0 */
  178. #define FCC1_REGNUM (C0_REGNUM + 44)        /* floating point condition code reg 0 */
  179. #define FCC2_REGNUM (C0_REGNUM + 45)        /* floating point condition code reg 1 */
  180. #define FCC3_REGNUM (C0_REGNUM + 46)        /* floating point condition code reg 2 */
  181.  
  182. /* FIXME: PS_REGNUM, FPS_REGNUM, CPS_REGNUM are for priviledged v8 registers
  183.    which don't exist in v9 (in the same form).  We use bits of sparc-tdep.c
  184.    which requires these, so define them here to be unused ASR regs so
  185.    sparc-tdep.c will compile.  What we really want to do is put some
  186.    conditionals in sparc-tdep.c (run time or compile time) or separate the v8
  187.    stuff out of sparc-tdep.c.  */
  188.  
  189. #define PS_REGNUM (ASR_REGNUM (29))
  190. #define FPS_REGNUM (ASR_REGNUM (30))
  191. #define CPS_REGNUM (ASR_REGNUM (31))
  192.  
  193. /* Total amount of space needed to store our copies of the machine's
  194.    register state, the array `registers'.
  195.    Some of the registers aren't 64 bits, but it's a lot simpler just to assume
  196.    they all are (since most of them are).  */
  197. #undef  REGISTER_BYTES
  198. #define REGISTER_BYTES (32*8+32*8+47*8)
  199.  
  200. /* Index within `registers' of the first byte of the space for
  201.    register N.  */
  202. #undef  REGISTER_BYTE
  203. #define REGISTER_BYTE(N) \
  204.   ((N) < 32 ? (N)*8                \
  205.    : (N) < 64 ? 32*8 + ((N)-32)*4        \
  206.    : (N) < C0_REGNUM ? 32*8 + 32*4 + ((N)-64)*8    \
  207.    : 64*8 + ((N)-C0_REGNUM)*8)
  208.  
  209. /* Number of bytes of storage in the actual machine representation
  210.    for register N.  */
  211.  
  212. #undef  REGISTER_RAW_SIZE
  213. #define REGISTER_RAW_SIZE(N) (8)
  214.  
  215. /* Number of bytes of storage in the program's representation
  216.    for register N.  */
  217.  
  218. #undef  REGISTER_VIRTUAL_SIZE
  219. #define REGISTER_VIRTUAL_SIZE(N) (8)
  220.  
  221. /* Largest value REGISTER_RAW_SIZE can have.  */
  222. /* tm-sparc.h defines this as 8, but play it safe.  */
  223.  
  224. #undef  MAX_REGISTER_RAW_SIZE
  225. #define MAX_REGISTER_RAW_SIZE (8)
  226.  
  227. /* Largest value REGISTER_VIRTUAL_SIZE can have.  */
  228. /* tm-sparc.h defines this as 8, but play it safe.  */
  229.  
  230. #undef  MAX_REGISTER_VIRTUAL_SIZE
  231. #define MAX_REGISTER_VIRTUAL_SIZE (8)
  232.  
  233. /* Convert data from raw format for register REGNUM
  234.    to virtual format for register REGNUM.  */
  235. /* ??? Remove when tm-sparc.h is fixed.  */
  236.  
  237. #undef  REGISTER_CONVERT_TO_VIRTUAL
  238. #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
  239. { memcpy ((TO), (FROM), REGISTER_RAW_SIZE (0)); }
  240.  
  241. /* Convert data from virtual format for register REGNUM
  242.    to raw format for register REGNUM.  */
  243. /* ??? Remove when tm-sparc.h is fixed.  */
  244.  
  245. #undef  REGISTER_CONVERT_TO_RAW
  246. #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO)    \
  247. { memcpy ((TO), (FROM), REGISTER_RAW_SIZE (0)); }
  248.  
  249. /* Return the GDB type object for the "standard" data type
  250.    of data in register N.  */
  251.  
  252. #undef  REGISTER_VIRTUAL_TYPE
  253. #define REGISTER_VIRTUAL_TYPE(N) \
  254.  ((N) < 32 ? builtin_type_long_long : (N) < 80 ? builtin_type_float : \
  255.   builtin_type_long_long)
  256.  
  257. /* We use to support both 32 bit and 64 bit pointers.
  258.    We can't anymore because TARGET_PTR_BIT must now be a constant.  */
  259. #undef  TARGET_PTR_BIT
  260. #define TARGET_PTR_BIT 64
  261.  
  262. /* Store the address of the place in which to copy the structure the
  263.    subroutine will return.  This is called from call_function. */
  264. /* FIXME: V9 uses %o0 for this.  */
  265.  
  266. #undef  STORE_STRUCT_RETURN
  267. #define STORE_STRUCT_RETURN(ADDR, SP) \
  268.   { target_write_memory ((SP)+(16*8), (char *)&(ADDR), 8); }
  269.  
  270. /* Extract from an array REGBUF containing the (raw) register state
  271.    a function return value of type TYPE, and copy that, in virtual format,
  272.    into VALBUF.  */ /* FIXME */
  273.  
  274. #undef  EXTRACT_RETURN_VALUE
  275. #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF)          \
  276.   {                                                                                       \
  277.     if (TYPE_CODE (TYPE) == TYPE_CODE_FLT)                          \
  278.       {                                              \
  279.     memcpy ((VALBUF), ((int *)(REGBUF))+FP0_REGNUM, TYPE_LENGTH(TYPE));\
  280.       }                                              \
  281.     else                                          \
  282.       memcpy ((VALBUF),                                  \
  283.           (char *)(REGBUF) + 8 * 8 +                   \
  284.           (TYPE_LENGTH(TYPE) >= 8 ? 0 : 8 - TYPE_LENGTH(TYPE)),       \
  285.           TYPE_LENGTH(TYPE));                       \
  286.   }
  287.  
  288. /* Extract from an array REGBUF containing the (raw) register state
  289.    the address in which a function should return its structure value,
  290.    as a CORE_ADDR (or an expression that can be used as one).  */
  291.  
  292. #undef  EXTRACT_STRUCT_VALUE_ADDRESS
  293. #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
  294.   (sparc64_extract_struct_value_address (REGBUF))
  295.  
  296. extern CORE_ADDR
  297. sparc64_extract_struct_value_address PARAMS ((char [REGISTER_BYTES]));
  298.  
  299. /* Return number of bytes at start of arglist that are not really args.  */
  300.  
  301. #undef  FRAME_ARGS_SKIP
  302. #define FRAME_ARGS_SKIP 136
  303.  
  304. /* Sparc has no reliable single step ptrace call */
  305.  
  306. #undef  NO_SINGLE_STEP
  307. #define NO_SINGLE_STEP 1
  308. extern void single_step ();
  309.  
  310. /* We need two arguments (in general) to the "info frame" command.
  311.    Note that the definition of this macro implies that there exists a
  312.    function "setup_arbitrary_frame" in sparc-tdep.c */
  313.  
  314. #undef  SETUP_ARBITRARY_FRAME        /*FIXME*/
  315. #undef  FRAME_SPECIFICATION_DYADIC
  316. #define FRAME_SPECIFICATION_DYADIC
  317.  
  318. /* To print every pair of float registers as a double, we use this hook.
  319.    We also print the condition code registers in a readable format
  320.    (FIXME: can expand this to all control regs).  */
  321.  
  322. #undef     PRINT_REGISTER_HOOK
  323. #define    PRINT_REGISTER_HOOK(regno)    \
  324.   sparc_print_register_hook (regno)
  325.  
  326. /* Offsets into jmp_buf.
  327.    FIXME: This was borrowed from the v8 stuff and will probably have to change
  328.    for v9.  */
  329.  
  330. #define JB_ELEMENT_SIZE 8    /* Size of each element in jmp_buf */
  331.  
  332. #define JB_ONSSTACK 0
  333. #define JB_SIGMASK 1
  334. #define JB_SP 2
  335. #define JB_PC 3
  336. #define JB_NPC 4
  337. #define JB_PSR 5
  338. #define JB_G1 6
  339. #define JB_O0 7
  340. #define JB_WBCNT 8
  341.  
  342. /* Figure out where the longjmp will land.  We expect that we have just entered
  343.    longjmp and haven't yet setup the stack frame, so the args are still in the
  344.    output regs.  %o0 (O0_REGNUM) points at the jmp_buf structure from which we
  345.    extract the pc (JB_PC) that we will land at.  The pc is copied into ADDR.
  346.    This routine returns true on success */
  347.  
  348. extern int
  349. get_longjmp_target PARAMS ((CORE_ADDR *));
  350.  
  351. #define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR)
  352.