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 / alpha / tm-alpha.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-04  |  15.4 KB  |  432 lines

  1. /* Definitions to make GDB run on an Alpha box under OSF1.  This is
  2.    also used by the Alpha/Netware target.
  3.    Copyright 1993 Free Software Foundation, Inc.
  4.  
  5. This file is part of GDB.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #ifndef TM_ALPHA_H
  22. #define TM_ALPHA_H
  23.  
  24. #include "bfd.h"
  25. #include "coff/sym.h"        /* Needed for PDR below.  */
  26. #include "coff/symconst.h"
  27.  
  28. #if !defined (TARGET_BYTE_ORDER)
  29. #define TARGET_BYTE_ORDER LITTLE_ENDIAN
  30. #endif
  31.  
  32. /* Redefine some target bit sizes from the default.  */
  33.  
  34. #define TARGET_LONG_BIT 64
  35. #define TARGET_LONG_LONG_BIT 64
  36. #define TARGET_PTR_BIT 64
  37.  
  38. /* Floating point is IEEE compliant */
  39. #define IEEE_FLOAT
  40.  
  41. /* Number of traps that happen between exec'ing the shell 
  42.  * to run an inferior, and when we finally get to 
  43.  * the inferior code.  This is 2 on most implementations.
  44.  */
  45. #define START_INFERIOR_TRAPS_EXPECTED 3
  46.  
  47. /* Offset from address of function to start of its code.
  48.    Zero on most machines.  */
  49.  
  50. #define FUNCTION_START_OFFSET 0
  51.  
  52. /* Advance PC across any function entry prologue instructions
  53.    to reach some "real" code.  */
  54.  
  55. #define SKIP_PROLOGUE(pc)    pc = alpha_skip_prologue(pc, 0)
  56. extern CORE_ADDR alpha_skip_prologue PARAMS ((CORE_ADDR addr, int lenient));
  57.  
  58. /* Immediately after a function call, return the saved pc.
  59.    Can't always go through the frames for this because on some machines
  60.    the new frame is not set up until the new function executes
  61.    some instructions.  */
  62.  
  63. #define SAVED_PC_AFTER_CALL(frame)    alpha_saved_pc_after_call(frame)
  64. #ifdef __STDC__
  65. struct frame_info;
  66. #endif
  67. extern CORE_ADDR
  68. alpha_saved_pc_after_call PARAMS ((struct frame_info *));
  69.  
  70. /* Are we currently handling a signal ?  */
  71.  
  72. #define IN_SIGTRAMP(pc, name)    ((name) && STREQ ("__sigtramp", (name)))
  73.  
  74. /* Stack grows downward.  */
  75.  
  76. #define INNER_THAN <
  77.  
  78. #define BREAKPOINT {0x80, 0, 0, 0} /* call_pal bpt */
  79.  
  80. /* Amount PC must be decremented by after a breakpoint.
  81.    This is often the number of bytes in BREAKPOINT
  82.    but not always.  */
  83.  
  84. #ifndef DECR_PC_AFTER_BREAK
  85. #define DECR_PC_AFTER_BREAK 4
  86. #endif
  87.  
  88. /* Nonzero if instruction at PC is a return instruction.
  89.    "ret $zero,($ra),1" on alpha. */
  90.  
  91. #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0x6bfa8001)
  92.  
  93. /* Say how long (ordinary) registers are.  This is a piece of bogosity
  94.    used in push_word and a few other places; REGISTER_RAW_SIZE is the
  95.    real way to know how big a register is.  */
  96.  
  97. #define REGISTER_SIZE 8
  98.  
  99. /* Number of machine registers */
  100.  
  101. #define NUM_REGS 66
  102.  
  103. /* Initializer for an array of names of registers.
  104.    There should be NUM_REGS strings in this initializer.  */
  105.  
  106. #define REGISTER_NAMES     \
  107.     {    "v0",    "t0",    "t1",    "t2",    "t3",    "t4",    "t5",    "t6", \
  108.     "t7",    "s0",    "s1",    "s2",    "s3",    "s4",    "s5",    "fp", \
  109.     "a0",    "a1",    "a2",    "a3",    "a4",    "a5",    "t8",    "t9", \
  110.     "t10",    "t11",    "ra",    "t12",    "at",    "gp",    "sp",    "zero", \
  111.     "f0",   "f1",   "f2",   "f3",   "f4",   "f5",   "f6",   "f7", \
  112.     "f8",   "f9",   "f10",  "f11",  "f12",  "f13",  "f14",  "f15", \
  113.     "f16",  "f17",  "f18",  "f19",  "f20",  "f21",  "f22",  "f23",\
  114.     "f24",  "f25",  "f26",  "f27",  "f28",  "f29",  "f30",  "f31",\
  115.     "pc",    "vfp",                        \
  116.     }
  117.  
  118. /* Register numbers of various important registers.
  119.    Note that most of these values are "real" register numbers,
  120.    and correspond to the general registers of the machine,
  121.    and FP_REGNUM is a "phony" register number which is too large
  122.    to be an actual register number as far as the user is concerned
  123.    but serves to get the desired value when passed to read_register.  */
  124.  
  125. #define V0_REGNUM 0        /* Function integer return value */
  126. #define GCC_FP_REGNUM 15    /* Used by gcc as frame register */
  127. #define A0_REGNUM 16        /* Loc of first arg during a subr call */
  128. #define T12_REGNUM 27        /* Contains start addr of current proc */
  129. #define SP_REGNUM 30        /* Contains address of top of stack */
  130. #define RA_REGNUM 26        /* Contains return address value */
  131. #define ZERO_REGNUM 31        /* Read-only register, always 0 */
  132. #define FP0_REGNUM 32           /* Floating point register 0 */
  133. #define FPA0_REGNUM 48          /* First float arg during a subr call */
  134. #define PC_REGNUM 64        /* Contains program counter */
  135. #define FP_REGNUM 65        /* Virtual frame pointer */
  136.  
  137. #define CANNOT_FETCH_REGISTER(regno) \
  138.   ((regno) == FP_REGNUM || (regno) == ZERO_REGNUM)
  139. #define CANNOT_STORE_REGISTER(regno) \
  140.   ((regno) == FP_REGNUM || (regno) == ZERO_REGNUM)
  141.  
  142. /* Total amount of space needed to store our copies of the machine's
  143.    register state, the array `registers'.  */
  144. #define REGISTER_BYTES (NUM_REGS * 8)
  145.  
  146. /* Index within `registers' of the first byte of the space for
  147.    register N.  */
  148.  
  149. #define REGISTER_BYTE(N) ((N) * 8)
  150.  
  151. /* Number of bytes of storage in the actual machine representation
  152.    for register N.  On Alphas, all regs are 8 bytes.  */
  153.  
  154. #define REGISTER_RAW_SIZE(N) 8
  155.  
  156. /* Number of bytes of storage in the program's representation
  157.    for register N.  On Alphas, all regs are 8 bytes.  */
  158.  
  159. #define REGISTER_VIRTUAL_SIZE(N) 8
  160.  
  161. /* Largest value REGISTER_RAW_SIZE can have.  */
  162.  
  163. #define MAX_REGISTER_RAW_SIZE 8
  164.  
  165. /* Largest value REGISTER_VIRTUAL_SIZE can have.  */
  166.  
  167. #define MAX_REGISTER_VIRTUAL_SIZE 8
  168.  
  169. /* Nonzero if register N requires conversion
  170.    from raw format to virtual format.
  171.    The alpha needs a conversion between register and memory format if
  172.    the register is a floating point register and
  173.       memory format is float, as the register format must be double
  174.    or
  175.       memory format is an integer with 4 bytes or less, as the representation
  176.       of integers in floating point registers is different. */
  177.  
  178. #define REGISTER_CONVERTIBLE(N) ((N) >= FP0_REGNUM && (N) < FP0_REGNUM + 32)
  179.  
  180. /* Convert data from raw format for register REGNUM in buffer FROM
  181.    to virtual format with type TYPE in buffer TO.  */
  182.  
  183. #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM, TYPE, FROM, TO) \
  184.   alpha_register_convert_to_virtual (REGNUM, TYPE, FROM, TO)
  185. #ifdef __STDC__
  186. struct type;
  187. #endif
  188. extern void
  189. alpha_register_convert_to_virtual PARAMS ((int, struct type *, char *, char *));
  190.  
  191. /* Convert data from virtual format with type TYPE in buffer FROM
  192.    to raw format for register REGNUM in buffer TO.  */
  193.  
  194. #define REGISTER_CONVERT_TO_RAW(TYPE, REGNUM, FROM, TO)    \
  195.   alpha_register_convert_to_raw (TYPE, REGNUM, FROM, TO)
  196. extern void
  197. alpha_register_convert_to_raw PARAMS ((struct type *, int, char *, char *));
  198.  
  199. /* Return the GDB type object for the "standard" data type
  200.    of data in register N.  */
  201.  
  202. #define REGISTER_VIRTUAL_TYPE(N) \
  203.     (((N) >= FP0_REGNUM && (N) < FP0_REGNUM+32)  \
  204.      ? builtin_type_double : builtin_type_long) \
  205.  
  206. /* Store the address of the place in which to copy the structure the
  207.    subroutine will return.  Handled by alpha_push_arguments.  */
  208.  
  209. #define STORE_STRUCT_RETURN(addr, sp)    /**/
  210.  
  211. /* Extract from an array REGBUF containing the (raw) register state
  212.    a function return value of type TYPE, and copy that, in virtual format,
  213.    into VALBUF.  */
  214.  
  215. #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
  216.   alpha_extract_return_value(TYPE, REGBUF, VALBUF)
  217. extern void
  218. alpha_extract_return_value PARAMS ((struct type *, char *, char *));
  219.  
  220. /* Write into appropriate registers a function return value
  221.    of type TYPE, given in virtual format.  */
  222.  
  223. #define STORE_RETURN_VALUE(TYPE,VALBUF) \
  224.   alpha_store_return_value(TYPE, VALBUF)
  225. extern void
  226. alpha_store_return_value PARAMS ((struct type *, char *));
  227.  
  228. /* Extract from an array REGBUF containing the (raw) register state
  229.    the address in which a function should return its structure value,
  230.    as a CORE_ADDR (or an expression that can be used as one).  */
  231. /* The address is passed in a0 upon entry to the function, but when
  232.    the function exits, the compiler has copied the value to v0.  This
  233.    convention is specified by the System V ABI, so I think we can rely
  234.    on it.  */
  235.  
  236. #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
  237.   (extract_address (REGBUF + REGISTER_BYTE (V0_REGNUM), \
  238.             REGISTER_RAW_SIZE (V0_REGNUM)))
  239.  
  240. /* Structures are returned by ref in extra arg0 */
  241. #define USE_STRUCT_CONVENTION(gcc_p, type)    1
  242.  
  243.  
  244. /* Describe the pointer in each stack frame to the previous stack frame
  245.    (its caller).  */
  246.  
  247. /* FRAME_CHAIN takes a frame's nominal address
  248.    and produces the frame's chain-pointer. */
  249.  
  250. #define FRAME_CHAIN(thisframe) (CORE_ADDR) alpha_frame_chain (thisframe)
  251. extern CORE_ADDR alpha_frame_chain PARAMS ((struct frame_info *));
  252.  
  253. /* Define other aspects of the stack frame.  */
  254.  
  255.  
  256. /* A macro that tells us whether the function invocation represented
  257.    by FI does not have a frame on the stack associated with it.  If it
  258.    does not, FRAMELESS is set to 1, else 0.  */
  259. /* We handle this differently for alpha, and maybe we should not */
  260.  
  261. #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS)  {(FRAMELESS) = 0;}
  262.  
  263. /* Saved Pc.  */
  264.  
  265. #define FRAME_SAVED_PC(FRAME)    (alpha_frame_saved_pc(FRAME))
  266. extern CORE_ADDR
  267. alpha_frame_saved_pc PARAMS ((struct frame_info *));
  268.  
  269. /* The alpha has two different virtual pointers for arguments and locals.
  270.  
  271.    The virtual argument pointer is pointing to the bottom of the argument
  272.    transfer area, which is located immediately below the virtual frame
  273.    pointer. Its size is fixed for the native compiler, it is either zero
  274.    (for the no arguments case) or large enough to hold all argument registers.
  275.    gcc uses a variable sized argument transfer area. As it has
  276.    to stay compatible with the native debugging tools it has to use the same
  277.    virtual argument pointer and adjust the argument offsets accordingly.
  278.  
  279.    The virtual local pointer is localoff bytes below the virtual frame
  280.    pointer, the value of localoff is obtained from the PDR.  */
  281.  
  282. #define ALPHA_NUM_ARG_REGS    6
  283.  
  284. #define FRAME_ARGS_ADDRESS(fi)    ((fi)->frame - (ALPHA_NUM_ARG_REGS * 8))
  285.  
  286. #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame - (fi)->localoff)
  287.  
  288. /* Return number of args passed to a frame.
  289.    Can return -1, meaning no way to tell.  */
  290.  
  291. #define FRAME_NUM_ARGS(num, fi)    ((num) = -1)
  292.  
  293. /* Return number of bytes at start of arglist that are not really args.  */
  294.  
  295. #define FRAME_ARGS_SKIP 0
  296.  
  297. /* Put here the code to store, into a struct frame_saved_regs,
  298.    the addresses of the saved registers of frame described by FRAME_INFO.
  299.    This includes special registers such as pc and fp saved in special
  300.    ways in the stack frame.  sp is even more special:
  301.    the address we return for it IS the sp for the next frame.  */
  302.  
  303. #define FRAME_FIND_SAVED_REGS(fi, frame_saved_regs) ( \
  304.   (frame_saved_regs) = *(fi)->saved_regs, \
  305.   (frame_saved_regs).regs[SP_REGNUM] = (fi)->frame)
  306.  
  307.  
  308. /* Things needed for making the inferior call functions.  */
  309.  
  310. #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
  311.     sp = alpha_push_arguments(nargs, args, sp, struct_return, struct_addr)
  312. #ifdef __STDC__
  313. struct value;
  314. #endif
  315. extern CORE_ADDR
  316. alpha_push_arguments PARAMS ((int, struct value **, CORE_ADDR, int, CORE_ADDR));
  317.  
  318. /* Push an empty stack frame, to record the current PC, etc.  */
  319.  
  320. #define PUSH_DUMMY_FRAME     alpha_push_dummy_frame()
  321. extern void
  322. alpha_push_dummy_frame PARAMS ((void));
  323.  
  324. /* Discard from the stack the innermost frame, restoring all registers.  */
  325.  
  326. #define POP_FRAME        alpha_pop_frame()
  327. extern void
  328. alpha_pop_frame PARAMS ((void));
  329.  
  330. /* Alpha OSF/1 inhibits execution of code on the stack.
  331.    But there is no need for a dummy on the alpha. PUSH_ARGUMENTS
  332.    takes care of all argument handling and bp_call_dummy takes care
  333.    of stopping the dummy.  */
  334.  
  335. #define CALL_DUMMY_LOCATION AT_ENTRY_POINT
  336.  
  337. /* On the Alpha the call dummy code is never copied to user space,
  338.    stopping the user call is achieved via a bp_call_dummy breakpoint.
  339.    But we need a fake CALL_DUMMY definition to enable the proper
  340.    call_function_by_hand and to avoid zero length array warnings
  341.    in valops.c  */
  342.  
  343. #define CALL_DUMMY { 0 }    /* Content doesn't matter. */
  344.  
  345. #define CALL_DUMMY_START_OFFSET (0)
  346.  
  347. #define CALL_DUMMY_BREAKPOINT_OFFSET (0)
  348.  
  349. extern CORE_ADDR alpha_call_dummy_address PARAMS ((void));
  350. #define CALL_DUMMY_ADDRESS() alpha_call_dummy_address()
  351.  
  352. /* Insert the specified number of args and function address
  353.    into a call sequence of the above form stored at DUMMYNAME.
  354.    We only have to set RA_REGNUM to the dummy breakpoint address
  355.    and T12_REGNUM (the `procedure value register') to the function address.  */
  356.  
  357. #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p)    \
  358. {                                    \
  359.   CORE_ADDR bp_address = CALL_DUMMY_ADDRESS ();            \
  360.   if (bp_address == 0)                            \
  361.     error ("no place to put call");                    \
  362.   write_register (RA_REGNUM, bp_address);                \
  363.   write_register (T12_REGNUM, fun);                    \
  364. }
  365.  
  366. /* There's a mess in stack frame creation.  See comments in blockframe.c
  367.    near reference to INIT_FRAME_PC_FIRST.  */
  368.  
  369. #define    INIT_FRAME_PC(fromleaf, prev) /* nada */
  370.  
  371. #define INIT_FRAME_PC_FIRST(fromleaf, prev) \
  372.   (prev)->pc = ((fromleaf) ? SAVED_PC_AFTER_CALL ((prev)->next) : \
  373.           (prev)->next ? FRAME_SAVED_PC ((prev)->next) : read_pc ());
  374.  
  375. /* Special symbol found in blocks associated with routines.  We can hang
  376.    alpha_extra_func_info_t's off of this.  */
  377.  
  378. #define MIPS_EFI_SYMBOL_NAME "__GDB_EFI_INFO__"
  379.  
  380. /* Specific information about a procedure.
  381.    This overlays the ALPHA's PDR records, 
  382.    alpharead.c (ab)uses this to save memory */
  383.  
  384. typedef struct alpha_extra_func_info {
  385.     long    numargs;    /* number of args to procedure (was iopt) */
  386.     PDR    pdr;        /* Procedure descriptor record */
  387. } *alpha_extra_func_info_t;
  388.  
  389. /* Define the extra_func_info that mipsread.c needs.
  390.    FIXME: We should define our own PDR interface, perhaps in a separate
  391.    header file. This would get rid of the <bfd.h> inclusion in all sources
  392.    and would abstract the mips/alpha interface from ecoff.  */
  393. #define mips_extra_func_info alpha_extra_func_info
  394. #define mips_extra_func_info_t alpha_extra_func_info_t
  395.  
  396. #define EXTRA_FRAME_INFO \
  397.   int localoff; \
  398.   alpha_extra_func_info_t proc_desc; \
  399.   struct frame_saved_regs *saved_regs;
  400.  
  401. #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci)
  402. extern void
  403. init_extra_frame_info PARAMS ((struct frame_info *));
  404.  
  405. #define    PRINT_EXTRA_FRAME_INFO(fi) \
  406.   { \
  407.     if (fi && fi->proc_desc && fi->proc_desc->pdr.framereg < NUM_REGS) \
  408.       printf_filtered (" frame pointer is at %s+%d\n", \
  409.                        reg_names[fi->proc_desc->pdr.framereg], \
  410.                                  fi->proc_desc->pdr.frameoffset); \
  411.   }
  412.  
  413. /* It takes two values to specify a frame on the ALPHA.  Sigh.
  414.  
  415.    In fact, at the moment, the *PC* is the primary value that sets up
  416.    a frame.  The PC is looked up to see what function it's in; symbol
  417.    information from that function tells us which register is the frame
  418.    pointer base, and what offset from there is the "virtual frame pointer".
  419.    (This is usually an offset from SP.)  FIXME -- this should be cleaned
  420.    up so that the primary value is the SP, and the PC is used to disambiguate
  421.    multiple functions with the same SP that are at different stack levels. */
  422.  
  423. #define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv)
  424. extern struct frame_info *setup_arbitrary_frame PARAMS ((int, CORE_ADDR *));
  425.  
  426. /* This is used by heuristic_proc_start.  It should be shot it the head.  */
  427. #ifndef VM_MIN_ADDRESS
  428. #define VM_MIN_ADDRESS (CORE_ADDR)0x120000000
  429. #endif
  430.  
  431. #endif /* TM_ALPHA_H */
  432.