1 /* Definitions to make GDB run on an Alpha box under OSF1. This is
2 also used by the Alpha/Netware and Alpha GNU/Linux targets.
4 Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002 Free
5 Software Foundation, Inc.
7 This file is part of GDB.
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.
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.
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., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
29 #include "coff/sym.h" /* Needed for PDR below. */
30 #include "coff/symconst.h"
37 /* Redefine some target bit sizes from the default. */
39 #define TARGET_LONG_BIT 64
40 #define TARGET_LONG_LONG_BIT 64
41 #define TARGET_PTR_BIT 64
43 /* Number of traps that happen between exec'ing the shell
44 * to run an inferior, and when we finally get to
45 * the inferior code. This is 2 on most implementations.
47 #define START_INFERIOR_TRAPS_EXPECTED 3
49 /* Offset from address of function to start of its code.
50 Zero on most machines. */
52 #define FUNCTION_START_OFFSET 0
54 /* Advance PC across any function entry prologue instructions
55 to reach some "real" code. */
57 #define SKIP_PROLOGUE(pc) alpha_skip_prologue((pc))
58 extern CORE_ADDR
alpha_skip_prologue (CORE_ADDR addr
);
60 /* Immediately after a function call, return the saved pc.
61 Can't always go through the frames for this because on some machines
62 the new frame is not set up until the new function executes
65 #define SAVED_PC_AFTER_CALL(frame) alpha_saved_pc_after_call(frame)
66 extern CORE_ADDR
alpha_saved_pc_after_call (struct frame_info
*);
68 /* Are we currently handling a signal ? */
70 #define IN_SIGTRAMP(pc, name) alpha_osf_in_sigtramp ((pc), (name))
71 extern int alpha_osf_in_sigtramp (CORE_ADDR
, char *);
73 /* Stack grows downward. */
75 #define INNER_THAN(lhs,rhs) core_addr_lessthan ((lhs), (rhs))
77 #define BREAKPOINT {0x80, 0, 0, 0} /* call_pal bpt */
79 /* Amount PC must be decremented by after a breakpoint.
80 This is often the number of bytes in BREAKPOINT
83 #ifndef DECR_PC_AFTER_BREAK
84 #define DECR_PC_AFTER_BREAK 4
87 /* Say how long (ordinary) registers are. This is a piece of bogosity
88 used in push_word and a few other places; REGISTER_RAW_SIZE is the
89 real way to know how big a register is. */
91 #define REGISTER_SIZE 8
93 /* Number of machine registers */
98 /* Return the name of register REGNO. */
100 #define REGISTER_NAME(regno) alpha_register_name ((regno))
101 extern char *alpha_register_name (int);
104 /* Register numbers of various important registers.
105 Note that most of these values are "real" register numbers,
106 and correspond to the general registers of the machine,
107 and FP_REGNUM is a "phony" register number which is too large
108 to be an actual register number as far as the user is concerned
109 but serves to get the desired value when passed to read_register. */
111 #define V0_REGNUM 0 /* Function integer return value */
112 #define T7_REGNUM 8 /* Return address register for OSF/1 __add* */
113 #define GCC_FP_REGNUM 15 /* Used by gcc as frame register */
114 #define A0_REGNUM 16 /* Loc of first arg during a subr call */
115 #define T9_REGNUM 23 /* Return address register for OSF/1 __div* */
116 #define T12_REGNUM 27 /* Contains start addr of current proc */
117 #define SP_REGNUM 30 /* Contains address of top of stack */
118 #define RA_REGNUM 26 /* Contains return address value */
119 #define ZERO_REGNUM 31 /* Read-only register, always 0 */
120 #define FP0_REGNUM 32 /* Floating point register 0 */
121 #define FPA0_REGNUM 48 /* First float arg during a subr call */
122 #define FPCR_REGNUM 63 /* Floating point control register */
123 #define PC_REGNUM 64 /* Contains program counter */
124 #define FP_REGNUM 65 /* Virtual frame pointer */
126 #define CANNOT_FETCH_REGISTER(regno) \
127 alpha_cannot_fetch_register ((regno))
128 extern int alpha_cannot_fetch_register (int);
130 #define CANNOT_STORE_REGISTER(regno) \
131 alpha_cannot_store_register ((regno))
132 extern int alpha_cannot_store_register (int);
134 /* Total amount of space needed to store our copies of the machine's
135 register state, the array `registers'. */
136 #define REGISTER_BYTES (NUM_REGS * 8)
138 /* Index within `registers' of the first byte of the space for
141 #define REGISTER_BYTE(N) alpha_register_byte ((N))
142 extern int alpha_register_byte (int);
144 /* Number of bytes of storage in the actual machine representation
145 for register N. On Alphas, all regs are 8 bytes. */
147 #define REGISTER_RAW_SIZE(N) alpha_register_raw_size ((N))
148 extern int alpha_register_raw_size (int);
150 /* Number of bytes of storage in the program's representation
151 for register N. On Alphas, all regs are 8 bytes. */
153 #define REGISTER_VIRTUAL_SIZE(N) alpha_register_virtual_size ((N))
154 extern int alpha_register_virtual_size (int);
156 /* Largest value REGISTER_RAW_SIZE can have. */
158 #define MAX_REGISTER_RAW_SIZE 8
160 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
162 #define MAX_REGISTER_VIRTUAL_SIZE 8
164 /* Nonzero if register N requires conversion
165 from raw format to virtual format.
166 The alpha needs a conversion between register and memory format if
167 the register is a floating point register and
168 memory format is float, as the register format must be double
170 memory format is an integer with 4 bytes or less, as the representation
171 of integers in floating point registers is different. */
173 #define REGISTER_CONVERTIBLE(N) alpha_register_convertible ((N))
174 extern int alpha_register_convertible (int);
176 /* Convert data from raw format for register REGNUM in buffer FROM
177 to virtual format with type TYPE in buffer TO. */
179 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM, TYPE, FROM, TO) \
180 alpha_register_convert_to_virtual (REGNUM, TYPE, FROM, TO)
182 alpha_register_convert_to_virtual (int, struct type
*, char *, char *);
184 /* Convert data from virtual format with type TYPE in buffer FROM
185 to raw format for register REGNUM in buffer TO. */
187 #define REGISTER_CONVERT_TO_RAW(TYPE, REGNUM, FROM, TO) \
188 alpha_register_convert_to_raw (TYPE, REGNUM, FROM, TO)
190 alpha_register_convert_to_raw (struct type
*, int, char *, char *);
192 /* Return the GDB type object for the "standard" data type
193 of data in register N. */
195 #define REGISTER_VIRTUAL_TYPE(N) alpha_register_virtual_type ((N))
196 extern struct type
* alpha_register_virtual_type (int);
198 /* Store the address of the place in which to copy the structure the
199 subroutine will return. Handled by alpha_push_arguments. */
201 #define STORE_STRUCT_RETURN(addr, sp) \
202 alpha_store_struct_return ((addr), (sp))
203 extern void alpha_store_struct_return (CORE_ADDR
, CORE_ADDR
);
206 /* Extract from an array REGBUF containing the (raw) register state
207 a function return value of type TYPE, and copy that, in virtual format,
210 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
211 alpha_extract_return_value(TYPE, REGBUF, VALBUF)
212 extern void alpha_extract_return_value (struct type
*, char *, char *);
214 /* Write into appropriate registers a function return value
215 of type TYPE, given in virtual format. */
217 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
218 alpha_store_return_value(TYPE, VALBUF)
219 extern void alpha_store_return_value (struct type
*, char *);
221 /* Extract from an array REGBUF containing the (raw) register state
222 the address in which a function should return its structure value,
223 as a CORE_ADDR (or an expression that can be used as one). */
224 /* The address is passed in a0 upon entry to the function, but when
225 the function exits, the compiler has copied the value to v0. This
226 convention is specified by the System V ABI, so I think we can rely
229 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
230 alpha_extract_struct_value_address (REGBUF)
231 extern CORE_ADDR
alpha_extract_struct_value_address (char *);
233 /* Structures are returned by ref in extra arg0 */
234 #define USE_STRUCT_CONVENTION(gcc_p, type) \
235 alpha_use_struct_convention ((gcc_p), (type))
236 extern int alpha_use_struct_convention (int, struct type
*);
239 /* Describe the pointer in each stack frame to the previous stack frame
242 /* FRAME_CHAIN takes a frame's nominal address
243 and produces the frame's chain-pointer. */
245 #define FRAME_CHAIN(thisframe) alpha_frame_chain (thisframe)
246 extern CORE_ADDR
alpha_frame_chain (struct frame_info
*);
248 /* Define other aspects of the stack frame. */
251 /* An expression that tells us whether the function invocation represented
252 by FI does not have a frame on the stack associated with it. */
253 /* We handle this differently for alpha, and maybe we should not */
255 #define FRAMELESS_FUNCTION_INVOCATION(FI) \
256 generic_frameless_function_invocation_not ((FI))
260 #define FRAME_SAVED_PC(FRAME) alpha_frame_saved_pc(FRAME)
261 extern CORE_ADDR
alpha_frame_saved_pc (struct frame_info
*);
263 /* The alpha has two different virtual pointers for arguments and locals.
265 The virtual argument pointer is pointing to the bottom of the argument
266 transfer area, which is located immediately below the virtual frame
267 pointer. Its size is fixed for the native compiler, it is either zero
268 (for the no arguments case) or large enough to hold all argument registers.
269 gcc uses a variable sized argument transfer area. As it has
270 to stay compatible with the native debugging tools it has to use the same
271 virtual argument pointer and adjust the argument offsets accordingly.
273 The virtual local pointer is localoff bytes below the virtual frame
274 pointer, the value of localoff is obtained from the PDR. */
276 #define ALPHA_NUM_ARG_REGS 6
278 #define FRAME_ARGS_ADDRESS(fi) alpha_frame_args_address ((fi))
279 extern CORE_ADDR
alpha_frame_args_address (struct frame_info
*);
281 #define FRAME_LOCALS_ADDRESS(fi) alpha_frame_locals_address ((fi))
282 extern CORE_ADDR
alpha_frame_locals_address (struct frame_info
*);
284 /* Return number of args passed to a frame.
285 Can return -1, meaning no way to tell. */
287 #define FRAME_NUM_ARGS(fi) frame_num_args_unknown ((fi))
289 /* Return number of bytes at start of arglist that are not really args. */
291 #define FRAME_ARGS_SKIP 0
293 /* Put here the code to store, into a struct frame_saved_regs,
294 the addresses of the saved registers of frame described by FRAME_INFO.
295 This includes special registers such as pc and fp saved in special
296 ways in the stack frame. sp is even more special:
297 the address we return for it IS the sp for the next frame. */
299 #define FRAME_INIT_SAVED_REGS(frame_info) \
300 alpha_frame_init_saved_regs (frame_info)
301 extern void alpha_frame_init_saved_regs (struct frame_info
*);
304 /* Things needed for making the inferior call functions. */
306 #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
307 (alpha_push_arguments((nargs), (args), (sp), (struct_return), (struct_addr)))
309 alpha_push_arguments (int, struct value
**, CORE_ADDR
, int, CORE_ADDR
);
311 /* Push an empty stack frame, to record the current PC, etc. */
313 #define PUSH_DUMMY_FRAME alpha_push_dummy_frame()
314 extern void alpha_push_dummy_frame (void);
316 /* Discard from the stack the innermost frame, restoring all registers. */
318 #define POP_FRAME alpha_pop_frame()
319 extern void alpha_pop_frame (void);
321 /* Alpha OSF/1 inhibits execution of code on the stack.
322 But there is no need for a dummy on the alpha. PUSH_ARGUMENTS
323 takes care of all argument handling and bp_call_dummy takes care
324 of stopping the dummy. */
326 #define CALL_DUMMY_LOCATION AT_ENTRY_POINT
328 /* On the Alpha the call dummy code is never copied to user space,
329 stopping the user call is achieved via a bp_call_dummy breakpoint.
330 But we need a fake CALL_DUMMY definition to enable the proper
331 call_function_by_hand and to avoid zero length array warnings
334 #define CALL_DUMMY_P (1)
336 #define CALL_DUMMY_WORDS alpha_call_dummy_words
337 extern LONGEST alpha_call_dummy_words
[];
339 #define SIZEOF_CALL_DUMMY_WORDS 0
341 #define CALL_DUMMY_START_OFFSET (0)
343 #define CALL_DUMMY_BREAKPOINT_OFFSET (0)
345 #define CALL_DUMMY_ADDRESS() alpha_call_dummy_address()
346 extern CORE_ADDR
alpha_call_dummy_address (void);
348 /* Insert the specified number of args and function address
349 into a call sequence of the above form stored at DUMMYNAME.
350 We only have to set RA_REGNUM to the dummy breakpoint address
351 and T12_REGNUM (the `procedure value register') to the function address. */
353 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
354 alpha_fix_call_dummy ((dummyname), (pc), (fun), (nargs), (args), \
356 extern void alpha_fix_call_dummy (char *, CORE_ADDR
, CORE_ADDR
, int,
357 struct value
**, struct type
*, int);
359 /* There's a mess in stack frame creation. See comments in blockframe.c
360 near reference to INIT_FRAME_PC_FIRST. */
362 #define INIT_FRAME_PC(fromleaf, prev) init_frame_pc_noop ((fromleaf), (prev))
364 #define INIT_FRAME_PC_FIRST(fromleaf, prev) \
365 alpha_init_frame_pc_first ((fromleaf), (prev))
366 extern void alpha_init_frame_pc_first (int, struct frame_info
*);
368 /* Special symbol found in blocks associated with routines. We can hang
369 alpha_extra_func_info_t's off of this. */
371 #define MIPS_EFI_SYMBOL_NAME "__GDB_EFI_INFO__"
372 extern void ecoff_relocate_efi (struct symbol
*, CORE_ADDR
);
374 /* Specific information about a procedure.
375 This overlays the ALPHA's PDR records,
376 alpharead.c (ab)uses this to save memory */
378 typedef struct alpha_extra_func_info
380 long numargs
; /* number of args to procedure (was iopt) */
381 PDR pdr
; /* Procedure descriptor record */
383 *alpha_extra_func_info_t
;
385 /* Define the extra_func_info that mipsread.c needs.
386 FIXME: We should define our own PDR interface, perhaps in a separate
387 header file. This would get rid of the <bfd.h> inclusion in all sources
388 and would abstract the mips/alpha interface from ecoff. */
389 #define mips_extra_func_info alpha_extra_func_info
390 #define mips_extra_func_info_t alpha_extra_func_info_t
393 #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) \
394 alpha_init_extra_frame_info(fromleaf, fci)
395 extern void alpha_init_extra_frame_info (int, struct frame_info
*);
397 #define PRINT_EXTRA_FRAME_INFO(fi) alpha_print_extra_frame_info ((fi))
398 extern void alpha_print_extra_frame_info (struct frame_info
*);
401 /* It takes two values to specify a frame on the ALPHA. Sigh.
403 In fact, at the moment, the *PC* is the primary value that sets up
404 a frame. The PC is looked up to see what function it's in; symbol
405 information from that function tells us which register is the frame
406 pointer base, and what offset from there is the "virtual frame pointer".
407 (This is usually an offset from SP.) FIXME -- this should be cleaned
408 up so that the primary value is the SP, and the PC is used to disambiguate
409 multiple functions with the same SP that are at different stack levels. */
411 #define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv)
412 extern struct frame_info
*setup_arbitrary_frame (int, CORE_ADDR
*);
414 /* This is used by heuristic_proc_start. It should be shot it the head. */
415 #ifndef VM_MIN_ADDRESS
416 #define VM_MIN_ADDRESS (CORE_ADDR)0x120000000
419 /* If PC is in a shared library trampoline code, return the PC
420 where the function itself actually starts. If not, return 0. */
421 #define SKIP_TRAMPOLINE_CODE(pc) find_solib_trampoline_target (pc)
423 /* If the current gcc for for this target does not produce correct debugging
424 information for float parameters, both prototyped and unprototyped, then
425 define this macro. This forces gdb to always assume that floats are
426 passed as doubles and then converted in the callee.
428 For the alpha, it appears that the debug info marks the parameters as
429 floats regardless of whether the function is prototyped, but the actual
430 values are always passed in as doubles. Thus by setting this to 1, both
431 types of calls will work. */
433 #define COERCE_FLOAT_TO_DOUBLE(formal, actual) \
434 standard_coerce_float_to_double ((formal), (actual))
436 /* Return TRUE if procedure descriptor PROC is a procedure descriptor
437 that refers to a dynamically generated sigtramp function.
439 OSF/1 doesn't use dynamic sigtramp functions, so this is always
442 #define PROC_DESC_IS_DYN_SIGTRAMP(proc) (0)
443 #define SET_PROC_DESC_IS_DYN_SIGTRAMP(proc)
445 /* If PC is inside a dynamically generated sigtramp function, return
446 how many bytes the program counter is beyond the start of that
447 function. Otherwise, return a negative value.
449 OSF/1 doesn't use dynamic sigtramp functions, so this always
452 #define DYNAMIC_SIGTRAMP_OFFSET(pc) (-1)
454 /* Translate a signal handler frame into the address of the sigcontext
457 #define SIGCONTEXT_ADDR(frame) \
458 (read_memory_integer ((frame)->next ? frame->next->frame : frame->frame, 8))
460 /* If FRAME refers to a sigtramp frame, return the address of the next
463 #define FRAME_PAST_SIGTRAMP_FRAME(frame, pc) \
464 (alpha_osf_skip_sigtramp_frame (frame, pc))
465 extern CORE_ADDR
alpha_osf_skip_sigtramp_frame (struct frame_info
*,
468 /* Single step based on where the current instruction will take us. */
469 extern void alpha_software_single_step (enum target_signal
, int);
471 #endif /* TM_ALPHA_H */