import gdb-1999-08-30 snapshot
[deliverable/binutils-gdb.git] / gdb / config / alpha / tm-alpha.h
CommitLineData
c906108c
SS
1/* Definitions to make GDB run on an Alpha box under OSF1. This is
2 also used by the Alpha/Netware and Alpha/Linux targets.
3 Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
4
c5aa993b 5 This file is part of GDB.
c906108c 6
c5aa993b
JM
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.
c906108c 11
c5aa993b
JM
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.
c906108c 16
c5aa993b
JM
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., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
c906108c
SS
21
22#ifndef TM_ALPHA_H
23#define TM_ALPHA_H
24
25#include "bfd.h"
26#include "coff/sym.h" /* Needed for PDR below. */
27#include "coff/symconst.h"
28
c906108c
SS
29struct frame_info;
30struct type;
31struct value;
32struct symbol;
c906108c
SS
33
34#if !defined (TARGET_BYTE_ORDER)
35#define TARGET_BYTE_ORDER LITTLE_ENDIAN
36#endif
37
38/* Redefine some target bit sizes from the default. */
39
40#define TARGET_LONG_BIT 64
41#define TARGET_LONG_LONG_BIT 64
42#define TARGET_PTR_BIT 64
43
44/* Floating point is IEEE compliant */
45#define IEEE_FLOAT
46
47/* Number of traps that happen between exec'ing the shell
48 * to run an inferior, and when we finally get to
49 * the inferior code. This is 2 on most implementations.
50 */
51#define START_INFERIOR_TRAPS_EXPECTED 3
52
53/* Offset from address of function to start of its code.
54 Zero on most machines. */
55
56#define FUNCTION_START_OFFSET 0
57
58/* Advance PC across any function entry prologue instructions
59 to reach some "real" code. */
60
b83266a0 61#define SKIP_PROLOGUE(pc) (alpha_skip_prologue(pc, 0))
c906108c
SS
62extern CORE_ADDR alpha_skip_prologue PARAMS ((CORE_ADDR addr, int lenient));
63
64/* Immediately after a function call, return the saved pc.
65 Can't always go through the frames for this because on some machines
66 the new frame is not set up until the new function executes
67 some instructions. */
68
69#define SAVED_PC_AFTER_CALL(frame) alpha_saved_pc_after_call(frame)
70extern CORE_ADDR
c5aa993b 71 alpha_saved_pc_after_call PARAMS ((struct frame_info *));
c906108c
SS
72
73/* Are we currently handling a signal ? */
74
75#define IN_SIGTRAMP(pc, name) ((name) && STREQ ("__sigtramp", (name)))
76
77/* Stack grows downward. */
78
79#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
80
c5aa993b 81#define BREAKPOINT {0x80, 0, 0, 0} /* call_pal bpt */
c906108c
SS
82
83/* Amount PC must be decremented by after a breakpoint.
84 This is often the number of bytes in BREAKPOINT
85 but not always. */
86
87#ifndef DECR_PC_AFTER_BREAK
88#define DECR_PC_AFTER_BREAK 4
89#endif
90
91/* Say how long (ordinary) registers are. This is a piece of bogosity
92 used in push_word and a few other places; REGISTER_RAW_SIZE is the
93 real way to know how big a register is. */
94
95#define REGISTER_SIZE 8
96
97/* Number of machine registers */
98
99#define NUM_REGS 66
100
101/* Initializer for an array of names of registers.
102 There should be NUM_REGS strings in this initializer. */
103
104#define REGISTER_NAMES \
105 { "v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6", \
106 "t7", "s0", "s1", "s2", "s3", "s4", "s5", "fp", \
107 "a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9", \
108 "t10", "t11", "ra", "t12", "at", "gp", "sp", "zero", \
109 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
110 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
111 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",\
7a292a7a 112 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "fpcr",\
c906108c
SS
113 "pc", "vfp", \
114 }
115
116/* Register numbers of various important registers.
117 Note that most of these values are "real" register numbers,
118 and correspond to the general registers of the machine,
119 and FP_REGNUM is a "phony" register number which is too large
120 to be an actual register number as far as the user is concerned
121 but serves to get the desired value when passed to read_register. */
122
123#define V0_REGNUM 0 /* Function integer return value */
124#define T7_REGNUM 8 /* Return address register for OSF/1 __add* */
125#define GCC_FP_REGNUM 15 /* Used by gcc as frame register */
126#define A0_REGNUM 16 /* Loc of first arg during a subr call */
127#define T9_REGNUM 23 /* Return address register for OSF/1 __div* */
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 */
c5aa993b
JM
132#define FP0_REGNUM 32 /* Floating point register 0 */
133#define FPA0_REGNUM 48 /* First float arg during a subr call */
7a292a7a 134#define FPCR_REGNUM 63 /* Floating point control register */
c906108c
SS
135#define PC_REGNUM 64 /* Contains program counter */
136#define FP_REGNUM 65 /* Virtual frame pointer */
137
138#define CANNOT_FETCH_REGISTER(regno) \
139 ((regno) == FP_REGNUM || (regno) == ZERO_REGNUM)
140#define CANNOT_STORE_REGISTER(regno) \
141 ((regno) == FP_REGNUM || (regno) == ZERO_REGNUM)
142
143/* Total amount of space needed to store our copies of the machine's
144 register state, the array `registers'. */
145#define REGISTER_BYTES (NUM_REGS * 8)
146
147/* Index within `registers' of the first byte of the space for
148 register N. */
149
150#define REGISTER_BYTE(N) ((N) * 8)
151
152/* Number of bytes of storage in the actual machine representation
153 for register N. On Alphas, all regs are 8 bytes. */
154
155#define REGISTER_RAW_SIZE(N) 8
156
157/* Number of bytes of storage in the program's representation
158 for register N. On Alphas, all regs are 8 bytes. */
159
160#define REGISTER_VIRTUAL_SIZE(N) 8
161
162/* Largest value REGISTER_RAW_SIZE can have. */
163
164#define MAX_REGISTER_RAW_SIZE 8
165
166/* Largest value REGISTER_VIRTUAL_SIZE can have. */
167
168#define MAX_REGISTER_VIRTUAL_SIZE 8
169
170/* Nonzero if register N requires conversion
171 from raw format to virtual format.
172 The alpha needs a conversion between register and memory format if
173 the register is a floating point register and
c5aa993b 174 memory format is float, as the register format must be double
c906108c 175 or
c5aa993b
JM
176 memory format is an integer with 4 bytes or less, as the representation
177 of integers in floating point registers is different. */
c906108c 178
7a292a7a 179#define REGISTER_CONVERTIBLE(N) ((N) >= FP0_REGNUM && (N) < FP0_REGNUM + 31)
c906108c
SS
180
181/* Convert data from raw format for register REGNUM in buffer FROM
182 to virtual format with type TYPE in buffer TO. */
183
184#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM, TYPE, FROM, TO) \
185 alpha_register_convert_to_virtual (REGNUM, TYPE, FROM, TO)
186extern void
187alpha_register_convert_to_virtual PARAMS ((int, struct type *, char *, char *));
188
189/* Convert data from virtual format with type TYPE in buffer FROM
190 to raw format for register REGNUM in buffer TO. */
191
192#define REGISTER_CONVERT_TO_RAW(TYPE, REGNUM, FROM, TO) \
193 alpha_register_convert_to_raw (TYPE, REGNUM, FROM, TO)
194extern void
195alpha_register_convert_to_raw PARAMS ((struct type *, int, char *, char *));
196
197/* Return the GDB type object for the "standard" data type
198 of data in register N. */
199
200#define REGISTER_VIRTUAL_TYPE(N) \
7a292a7a 201 (((N) >= FP0_REGNUM && (N) < FP0_REGNUM+31) \
c906108c
SS
202 ? builtin_type_double : builtin_type_long) \
203
204/* Store the address of the place in which to copy the structure the
205 subroutine will return. Handled by alpha_push_arguments. */
206
c5aa993b
JM
207#define STORE_STRUCT_RETURN(addr, sp)
208/**/
c906108c
SS
209
210/* Extract from an array REGBUF containing the (raw) register state
211 a function return value of type TYPE, and copy that, in virtual format,
212 into VALBUF. */
213
214#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
215 alpha_extract_return_value(TYPE, REGBUF, VALBUF)
216extern void
217alpha_extract_return_value PARAMS ((struct type *, char *, char *));
218
219/* Write into appropriate registers a function return value
220 of type TYPE, given in virtual format. */
221
222#define STORE_RETURN_VALUE(TYPE,VALBUF) \
223 alpha_store_return_value(TYPE, VALBUF)
224extern void
225alpha_store_return_value PARAMS ((struct type *, char *));
226
227/* Extract from an array REGBUF containing the (raw) register state
228 the address in which a function should return its structure value,
229 as a CORE_ADDR (or an expression that can be used as one). */
230/* The address is passed in a0 upon entry to the function, but when
231 the function exits, the compiler has copied the value to v0. This
232 convention is specified by the System V ABI, so I think we can rely
233 on it. */
234
235#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
236 (extract_address (REGBUF + REGISTER_BYTE (V0_REGNUM), \
237 REGISTER_RAW_SIZE (V0_REGNUM)))
238
239/* Structures are returned by ref in extra arg0 */
240#define USE_STRUCT_CONVENTION(gcc_p, type) 1
c906108c 241\f
c5aa993b 242
c906108c
SS
243/* Describe the pointer in each stack frame to the previous stack frame
244 (its caller). */
245
246/* FRAME_CHAIN takes a frame's nominal address
247 and produces the frame's chain-pointer. */
248
249#define FRAME_CHAIN(thisframe) (CORE_ADDR) alpha_frame_chain (thisframe)
250extern CORE_ADDR alpha_frame_chain PARAMS ((struct frame_info *));
251
252/* Define other aspects of the stack frame. */
253
254
392a587b
JM
255/* An expression that tells us whether the function invocation represented
256 by FI does not have a frame on the stack associated with it. */
c906108c
SS
257/* We handle this differently for alpha, and maybe we should not */
258
392a587b 259#define FRAMELESS_FUNCTION_INVOCATION(FI) (0)
c906108c
SS
260
261/* Saved Pc. */
262
263#define FRAME_SAVED_PC(FRAME) (alpha_frame_saved_pc(FRAME))
264extern CORE_ADDR
c5aa993b 265 alpha_frame_saved_pc PARAMS ((struct frame_info *));
c906108c
SS
266
267/* The alpha has two different virtual pointers for arguments and locals.
268
269 The virtual argument pointer is pointing to the bottom of the argument
270 transfer area, which is located immediately below the virtual frame
271 pointer. Its size is fixed for the native compiler, it is either zero
272 (for the no arguments case) or large enough to hold all argument registers.
273 gcc uses a variable sized argument transfer area. As it has
274 to stay compatible with the native debugging tools it has to use the same
275 virtual argument pointer and adjust the argument offsets accordingly.
276
277 The virtual local pointer is localoff bytes below the virtual frame
278 pointer, the value of localoff is obtained from the PDR. */
279
280#define ALPHA_NUM_ARG_REGS 6
281
282#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame - (ALPHA_NUM_ARG_REGS * 8))
283
284#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame - (fi)->localoff)
285
286/* Return number of args passed to a frame.
287 Can return -1, meaning no way to tell. */
288
392a587b 289#define FRAME_NUM_ARGS(fi) (-1)
c906108c
SS
290
291/* Return number of bytes at start of arglist that are not really args. */
292
293#define FRAME_ARGS_SKIP 0
294
295/* Put here the code to store, into a struct frame_saved_regs,
296 the addresses of the saved registers of frame described by FRAME_INFO.
297 This includes special registers such as pc and fp saved in special
298 ways in the stack frame. sp is even more special:
299 the address we return for it IS the sp for the next frame. */
300
301extern void alpha_find_saved_regs PARAMS ((struct frame_info *));
302
303#define FRAME_INIT_SAVED_REGS(frame_info) \
304 do { \
305 if ((frame_info)->saved_regs == NULL) \
306 alpha_find_saved_regs (frame_info); \
307 (frame_info)->saved_regs[SP_REGNUM] = (frame_info)->frame; \
308 } while (0)
c906108c 309\f
c5aa993b 310
c906108c
SS
311/* Things needed for making the inferior call functions. */
312
313#define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
392a587b 314 (alpha_push_arguments((nargs), (args), (sp), (struct_return), (struct_addr)))
c906108c 315extern CORE_ADDR
c5aa993b 316 alpha_push_arguments PARAMS ((int, struct value **, CORE_ADDR, int, CORE_ADDR));
c906108c
SS
317
318/* Push an empty stack frame, to record the current PC, etc. */
319
320#define PUSH_DUMMY_FRAME alpha_push_dummy_frame()
321extern void
322alpha_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()
327extern void
328alpha_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
349extern 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
c5aa993b 369#define INIT_FRAME_PC(fromleaf, prev) /* nada */
c906108c
SS
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__"
379extern void ecoff_relocate_efi PARAMS ((struct symbol *, CORE_ADDR));
380
381/* Specific information about a procedure.
382 This overlays the ALPHA's PDR records,
383 alpharead.c (ab)uses this to save memory */
384
c5aa993b
JM
385typedef struct alpha_extra_func_info
386 {
387 long numargs; /* number of args to procedure (was iopt) */
388 PDR pdr; /* Procedure descriptor record */
389 }
390 *alpha_extra_func_info_t;
c906108c
SS
391
392/* Define the extra_func_info that mipsread.c needs.
393 FIXME: We should define our own PDR interface, perhaps in a separate
394 header file. This would get rid of the <bfd.h> inclusion in all sources
395 and would abstract the mips/alpha interface from ecoff. */
396#define mips_extra_func_info alpha_extra_func_info
397#define mips_extra_func_info_t alpha_extra_func_info_t
398
399#define EXTRA_FRAME_INFO \
400 int localoff; \
401 int pc_reg; \
402 alpha_extra_func_info_t proc_desc;
403
404#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci)
405extern void
406init_extra_frame_info PARAMS ((struct frame_info *));
407
408#define PRINT_EXTRA_FRAME_INFO(fi) \
409 { \
410 if (fi && fi->proc_desc && fi->proc_desc->pdr.framereg < NUM_REGS) \
411 printf_filtered (" frame pointer is at %s+%d\n", \
412 REGISTER_NAME (fi->proc_desc->pdr.framereg), \
413 fi->proc_desc->pdr.frameoffset); \
414 }
415
416/* It takes two values to specify a frame on the ALPHA. Sigh.
417
418 In fact, at the moment, the *PC* is the primary value that sets up
419 a frame. The PC is looked up to see what function it's in; symbol
420 information from that function tells us which register is the frame
421 pointer base, and what offset from there is the "virtual frame pointer".
422 (This is usually an offset from SP.) FIXME -- this should be cleaned
423 up so that the primary value is the SP, and the PC is used to disambiguate
424 multiple functions with the same SP that are at different stack levels. */
425
426#define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv)
427extern struct frame_info *setup_arbitrary_frame PARAMS ((int, CORE_ADDR *));
428
429/* This is used by heuristic_proc_start. It should be shot it the head. */
430#ifndef VM_MIN_ADDRESS
431#define VM_MIN_ADDRESS (CORE_ADDR)0x120000000
432#endif
433
434/* If PC is in a shared library trampoline code, return the PC
435 where the function itself actually starts. If not, return 0. */
436#define SKIP_TRAMPOLINE_CODE(pc) find_solib_trampoline_target (pc)
437
438/* If the current gcc for for this target does not produce correct debugging
439 information for float parameters, both prototyped and unprototyped, then
440 define this macro. This forces gdb to always assume that floats are
441 passed as doubles and then converted in the callee.
442
443 For the alpha, it appears that the debug info marks the parameters as
444 floats regardless of whether the function is prototyped, but the actual
445 values are always passed in as doubles. Thus by setting this to 1, both
446 types of calls will work. */
447
448#define COERCE_FLOAT_TO_DOUBLE 1
449
450/* Return TRUE if procedure descriptor PROC is a procedure descriptor
451 that refers to a dynamically generated sigtramp function.
452
453 OSF/1 doesn't use dynamic sigtramp functions, so this is always
454 FALSE. */
455
456#define PROC_DESC_IS_DYN_SIGTRAMP(proc) (0)
457#define SET_PROC_DESC_IS_DYN_SIGTRAMP(proc)
458
459/* If PC is inside a dynamically generated sigtramp function, return
460 how many bytes the program counter is beyond the start of that
461 function. Otherwise, return a negative value.
462
463 OSF/1 doesn't use dynamic sigtramp functions, so this always
464 returns -1. */
465
466#define DYNAMIC_SIGTRAMP_OFFSET(pc) (-1)
467
468/* Translate a signal handler frame into the address of the sigcontext
469 structure. */
470
471#define SIGCONTEXT_ADDR(frame) \
472 (read_memory_integer ((frame)->next ? frame->next->frame : frame->frame, 8))
473
474/* If FRAME refers to a sigtramp frame, return the address of the next
475 frame. */
476
477#define FRAME_PAST_SIGTRAMP_FRAME(frame, pc) \
478 (alpha_osf_skip_sigtramp_frame (frame, pc))
479extern CORE_ADDR alpha_osf_skip_sigtramp_frame PARAMS ((struct frame_info *, CORE_ADDR));
480
481#endif /* TM_ALPHA_H */
This page took 0.12752 seconds and 4 git commands to generate.