* alpha-tdep.c (alpha_osf_in_sigtramp): New function.
[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.
d734c450 3 Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002
b6ba6518 4 Free Software Foundation, Inc.
c906108c 5
c5aa993b 6 This file is part of GDB.
c906108c 7
c5aa993b
JM
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.
c906108c 12
c5aa993b
JM
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.
c906108c 17
c5aa993b
JM
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., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
c906108c
SS
22
23#ifndef TM_ALPHA_H
24#define TM_ALPHA_H
25
f88e2c52 26#include "regcache.h"
c906108c
SS
27#include "bfd.h"
28#include "coff/sym.h" /* Needed for PDR below. */
29#include "coff/symconst.h"
30
c906108c
SS
31struct frame_info;
32struct type;
33struct value;
34struct symbol;
c906108c
SS
35
36#if !defined (TARGET_BYTE_ORDER)
778eb05e 37#define TARGET_BYTE_ORDER BFD_ENDIAN_LITTLE
c906108c
SS
38#endif
39
40/* Redefine some target bit sizes from the default. */
41
42#define TARGET_LONG_BIT 64
43#define TARGET_LONG_LONG_BIT 64
44#define TARGET_PTR_BIT 64
45
46/* Floating point is IEEE compliant */
7355ddba 47#define IEEE_FLOAT (1)
c906108c
SS
48
49/* Number of traps that happen between exec'ing the shell
50 * to run an inferior, and when we finally get to
51 * the inferior code. This is 2 on most implementations.
52 */
53#define START_INFERIOR_TRAPS_EXPECTED 3
54
55/* Offset from address of function to start of its code.
56 Zero on most machines. */
57
58#define FUNCTION_START_OFFSET 0
59
60/* Advance PC across any function entry prologue instructions
61 to reach some "real" code. */
62
b83266a0 63#define SKIP_PROLOGUE(pc) (alpha_skip_prologue(pc, 0))
a14ed312 64extern CORE_ADDR alpha_skip_prologue (CORE_ADDR addr, int lenient);
c906108c
SS
65
66/* Immediately after a function call, return the saved pc.
67 Can't always go through the frames for this because on some machines
68 the new frame is not set up until the new function executes
69 some instructions. */
70
71#define SAVED_PC_AFTER_CALL(frame) alpha_saved_pc_after_call(frame)
a14ed312 72extern CORE_ADDR alpha_saved_pc_after_call (struct frame_info *);
c906108c
SS
73
74/* Are we currently handling a signal ? */
75
d734c450
JT
76#define IN_SIGTRAMP(pc, name) alpha_osf_in_sigtramp ((pc), (name))
77extern int alpha_osf_in_sigtramp (CORE_ADDR, char *);
c906108c
SS
78
79/* Stack grows downward. */
80
d734c450 81#define INNER_THAN(lhs,rhs) core_addr_lessthan ((lhs), (rhs))
c906108c 82
c5aa993b 83#define BREAKPOINT {0x80, 0, 0, 0} /* call_pal bpt */
c906108c
SS
84
85/* Amount PC must be decremented by after a breakpoint.
86 This is often the number of bytes in BREAKPOINT
87 but not always. */
88
89#ifndef DECR_PC_AFTER_BREAK
90#define DECR_PC_AFTER_BREAK 4
91#endif
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
636a6dfc
JT
103
104/* Return the name of register REGNO. */
105
106#define REGISTER_NAME(regno) alpha_register_name ((regno))
107extern char *alpha_register_name (int);
108
c906108c
SS
109
110/* Register numbers of various important registers.
111 Note that most of these values are "real" register numbers,
112 and correspond to the general registers of the machine,
113 and FP_REGNUM is a "phony" register number which is too large
114 to be an actual register number as far as the user is concerned
115 but serves to get the desired value when passed to read_register. */
116
117#define V0_REGNUM 0 /* Function integer return value */
118#define T7_REGNUM 8 /* Return address register for OSF/1 __add* */
119#define GCC_FP_REGNUM 15 /* Used by gcc as frame register */
120#define A0_REGNUM 16 /* Loc of first arg during a subr call */
121#define T9_REGNUM 23 /* Return address register for OSF/1 __div* */
122#define T12_REGNUM 27 /* Contains start addr of current proc */
123#define SP_REGNUM 30 /* Contains address of top of stack */
124#define RA_REGNUM 26 /* Contains return address value */
125#define ZERO_REGNUM 31 /* Read-only register, always 0 */
c5aa993b
JM
126#define FP0_REGNUM 32 /* Floating point register 0 */
127#define FPA0_REGNUM 48 /* First float arg during a subr call */
7a292a7a 128#define FPCR_REGNUM 63 /* Floating point control register */
c906108c
SS
129#define PC_REGNUM 64 /* Contains program counter */
130#define FP_REGNUM 65 /* Virtual frame pointer */
131
132#define CANNOT_FETCH_REGISTER(regno) \
d734c450
JT
133 alpha_cannot_fetch_register ((regno))
134extern int alpha_cannot_fetch_register (int);
135
c906108c 136#define CANNOT_STORE_REGISTER(regno) \
d734c450
JT
137 alpha_cannot_store_register ((regno))
138extern int alpha_cannot_store_register (int);
c906108c
SS
139
140/* Total amount of space needed to store our copies of the machine's
141 register state, the array `registers'. */
142#define REGISTER_BYTES (NUM_REGS * 8)
143
144/* Index within `registers' of the first byte of the space for
145 register N. */
146
147#define REGISTER_BYTE(N) ((N) * 8)
148
149/* Number of bytes of storage in the actual machine representation
150 for register N. On Alphas, all regs are 8 bytes. */
151
152#define REGISTER_RAW_SIZE(N) 8
153
154/* Number of bytes of storage in the program's representation
155 for register N. On Alphas, all regs are 8 bytes. */
156
157#define REGISTER_VIRTUAL_SIZE(N) 8
158
159/* Largest value REGISTER_RAW_SIZE can have. */
160
161#define MAX_REGISTER_RAW_SIZE 8
162
163/* Largest value REGISTER_VIRTUAL_SIZE can have. */
164
165#define MAX_REGISTER_VIRTUAL_SIZE 8
166
167/* Nonzero if register N requires conversion
168 from raw format to virtual format.
169 The alpha needs a conversion between register and memory format if
170 the register is a floating point register and
c5aa993b 171 memory format is float, as the register format must be double
c906108c 172 or
c5aa993b
JM
173 memory format is an integer with 4 bytes or less, as the representation
174 of integers in floating point registers is different. */
c906108c 175
d734c450
JT
176#define REGISTER_CONVERTIBLE(N) alpha_register_convertible ((N))
177extern int alpha_register_convertible (int);
c906108c
SS
178
179/* Convert data from raw format for register REGNUM in buffer FROM
180 to virtual format with type TYPE in buffer TO. */
181
182#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM, TYPE, FROM, TO) \
183 alpha_register_convert_to_virtual (REGNUM, TYPE, FROM, TO)
184extern void
a14ed312 185alpha_register_convert_to_virtual (int, struct type *, char *, char *);
c906108c
SS
186
187/* Convert data from virtual format with type TYPE in buffer FROM
188 to raw format for register REGNUM in buffer TO. */
189
190#define REGISTER_CONVERT_TO_RAW(TYPE, REGNUM, FROM, TO) \
191 alpha_register_convert_to_raw (TYPE, REGNUM, FROM, TO)
192extern void
a14ed312 193alpha_register_convert_to_raw (struct type *, int, char *, char *);
c906108c
SS
194
195/* Return the GDB type object for the "standard" data type
196 of data in register N. */
197
198#define REGISTER_VIRTUAL_TYPE(N) \
7a292a7a 199 (((N) >= FP0_REGNUM && (N) < FP0_REGNUM+31) \
c906108c
SS
200 ? builtin_type_double : builtin_type_long) \
201
202/* Store the address of the place in which to copy the structure the
203 subroutine will return. Handled by alpha_push_arguments. */
204
c5aa993b
JM
205#define STORE_STRUCT_RETURN(addr, sp)
206/**/
c906108c
SS
207
208/* Extract from an array REGBUF containing the (raw) register state
209 a function return value of type TYPE, and copy that, in virtual format,
210 into VALBUF. */
211
212#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
213 alpha_extract_return_value(TYPE, REGBUF, VALBUF)
a14ed312 214extern void alpha_extract_return_value (struct type *, char *, char *);
c906108c
SS
215
216/* Write into appropriate registers a function return value
217 of type TYPE, given in virtual format. */
218
219#define STORE_RETURN_VALUE(TYPE,VALBUF) \
220 alpha_store_return_value(TYPE, VALBUF)
a14ed312 221extern void alpha_store_return_value (struct type *, char *);
c906108c
SS
222
223/* Extract from an array REGBUF containing the (raw) register state
224 the address in which a function should return its structure value,
225 as a CORE_ADDR (or an expression that can be used as one). */
226/* The address is passed in a0 upon entry to the function, but when
227 the function exits, the compiler has copied the value to v0. This
228 convention is specified by the System V ABI, so I think we can rely
229 on it. */
230
231#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
232 (extract_address (REGBUF + REGISTER_BYTE (V0_REGNUM), \
233 REGISTER_RAW_SIZE (V0_REGNUM)))
234
235/* Structures are returned by ref in extra arg0 */
d734c450
JT
236#define USE_STRUCT_CONVENTION(gcc_p, type) \
237 alpha_use_struct_convention ((gcc_p), (type))
238extern int alpha_use_struct_convention (int, struct type *);
c906108c 239\f
c5aa993b 240
c906108c
SS
241/* Describe the pointer in each stack frame to the previous stack frame
242 (its caller). */
243
244/* FRAME_CHAIN takes a frame's nominal address
245 and produces the frame's chain-pointer. */
246
d734c450 247#define FRAME_CHAIN(thisframe) alpha_frame_chain (thisframe)
a14ed312 248extern CORE_ADDR alpha_frame_chain (struct frame_info *);
c906108c
SS
249
250/* Define other aspects of the stack frame. */
251
252
392a587b
JM
253/* An expression that tells us whether the function invocation represented
254 by FI does not have a frame on the stack associated with it. */
c906108c
SS
255/* We handle this differently for alpha, and maybe we should not */
256
392a587b 257#define FRAMELESS_FUNCTION_INVOCATION(FI) (0)
c906108c
SS
258
259/* Saved Pc. */
260
261#define FRAME_SAVED_PC(FRAME) (alpha_frame_saved_pc(FRAME))
a14ed312 262extern CORE_ADDR alpha_frame_saved_pc (struct frame_info *);
c906108c
SS
263
264/* The alpha has two different virtual pointers for arguments and locals.
265
266 The virtual argument pointer is pointing to the bottom of the argument
267 transfer area, which is located immediately below the virtual frame
268 pointer. Its size is fixed for the native compiler, it is either zero
269 (for the no arguments case) or large enough to hold all argument registers.
270 gcc uses a variable sized argument transfer area. As it has
271 to stay compatible with the native debugging tools it has to use the same
272 virtual argument pointer and adjust the argument offsets accordingly.
273
274 The virtual local pointer is localoff bytes below the virtual frame
275 pointer, the value of localoff is obtained from the PDR. */
276
277#define ALPHA_NUM_ARG_REGS 6
278
279#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame - (ALPHA_NUM_ARG_REGS * 8))
280
281#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame - (fi)->localoff)
282
283/* Return number of args passed to a frame.
284 Can return -1, meaning no way to tell. */
285
392a587b 286#define FRAME_NUM_ARGS(fi) (-1)
c906108c
SS
287
288/* Return number of bytes at start of arglist that are not really args. */
289
290#define FRAME_ARGS_SKIP 0
291
292/* Put here the code to store, into a struct frame_saved_regs,
293 the addresses of the saved registers of frame described by FRAME_INFO.
294 This includes special registers such as pc and fp saved in special
295 ways in the stack frame. sp is even more special:
296 the address we return for it IS the sp for the next frame. */
297
a14ed312 298extern void alpha_find_saved_regs (struct frame_info *);
c906108c
SS
299
300#define FRAME_INIT_SAVED_REGS(frame_info) \
301 do { \
302 if ((frame_info)->saved_regs == NULL) \
303 alpha_find_saved_regs (frame_info); \
304 (frame_info)->saved_regs[SP_REGNUM] = (frame_info)->frame; \
305 } while (0)
c906108c 306\f
c5aa993b 307
c906108c
SS
308/* Things needed for making the inferior call functions. */
309
310#define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
392a587b 311 (alpha_push_arguments((nargs), (args), (sp), (struct_return), (struct_addr)))
c906108c 312extern CORE_ADDR
a14ed312 313alpha_push_arguments (int, struct value **, CORE_ADDR, int, CORE_ADDR);
c906108c
SS
314
315/* Push an empty stack frame, to record the current PC, etc. */
316
317#define PUSH_DUMMY_FRAME alpha_push_dummy_frame()
a14ed312 318extern void alpha_push_dummy_frame (void);
c906108c
SS
319
320/* Discard from the stack the innermost frame, restoring all registers. */
321
322#define POP_FRAME alpha_pop_frame()
a14ed312 323extern void alpha_pop_frame (void);
c906108c
SS
324
325/* Alpha OSF/1 inhibits execution of code on the stack.
326 But there is no need for a dummy on the alpha. PUSH_ARGUMENTS
327 takes care of all argument handling and bp_call_dummy takes care
328 of stopping the dummy. */
329
330#define CALL_DUMMY_LOCATION AT_ENTRY_POINT
331
332/* On the Alpha the call dummy code is never copied to user space,
333 stopping the user call is achieved via a bp_call_dummy breakpoint.
334 But we need a fake CALL_DUMMY definition to enable the proper
335 call_function_by_hand and to avoid zero length array warnings
336 in valops.c */
337
338#define CALL_DUMMY { 0 } /* Content doesn't matter. */
339
340#define CALL_DUMMY_START_OFFSET (0)
341
342#define CALL_DUMMY_BREAKPOINT_OFFSET (0)
343
a14ed312 344extern CORE_ADDR alpha_call_dummy_address (void);
c906108c
SS
345#define CALL_DUMMY_ADDRESS() alpha_call_dummy_address()
346
347/* Insert the specified number of args and function address
348 into a call sequence of the above form stored at DUMMYNAME.
349 We only have to set RA_REGNUM to the dummy breakpoint address
350 and T12_REGNUM (the `procedure value register') to the function address. */
351
352#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
353{ \
354 CORE_ADDR bp_address = CALL_DUMMY_ADDRESS (); \
355 if (bp_address == 0) \
356 error ("no place to put call"); \
357 write_register (RA_REGNUM, bp_address); \
358 write_register (T12_REGNUM, fun); \
359}
360
361/* There's a mess in stack frame creation. See comments in blockframe.c
362 near reference to INIT_FRAME_PC_FIRST. */
363
c5aa993b 364#define INIT_FRAME_PC(fromleaf, prev) /* nada */
c906108c
SS
365
366#define INIT_FRAME_PC_FIRST(fromleaf, prev) \
367 (prev)->pc = ((fromleaf) ? SAVED_PC_AFTER_CALL ((prev)->next) : \
368 (prev)->next ? FRAME_SAVED_PC ((prev)->next) : read_pc ());
369
370/* Special symbol found in blocks associated with routines. We can hang
371 alpha_extra_func_info_t's off of this. */
372
373#define MIPS_EFI_SYMBOL_NAME "__GDB_EFI_INFO__"
a14ed312 374extern void ecoff_relocate_efi (struct symbol *, CORE_ADDR);
c906108c
SS
375
376/* Specific information about a procedure.
377 This overlays the ALPHA's PDR records,
378 alpharead.c (ab)uses this to save memory */
379
c5aa993b
JM
380typedef struct alpha_extra_func_info
381 {
382 long numargs; /* number of args to procedure (was iopt) */
383 PDR pdr; /* Procedure descriptor record */
384 }
385 *alpha_extra_func_info_t;
c906108c
SS
386
387/* Define the extra_func_info that mipsread.c needs.
388 FIXME: We should define our own PDR interface, perhaps in a separate
389 header file. This would get rid of the <bfd.h> inclusion in all sources
390 and would abstract the mips/alpha interface from ecoff. */
391#define mips_extra_func_info alpha_extra_func_info
392#define mips_extra_func_info_t alpha_extra_func_info_t
393
394#define EXTRA_FRAME_INFO \
395 int localoff; \
396 int pc_reg; \
397 alpha_extra_func_info_t proc_desc;
398
399#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci)
a14ed312 400extern void init_extra_frame_info (struct frame_info *);
c906108c
SS
401
402#define PRINT_EXTRA_FRAME_INFO(fi) \
403 { \
404 if (fi && fi->proc_desc && fi->proc_desc->pdr.framereg < NUM_REGS) \
d4f3574e 405 printf_filtered (" frame pointer is at %s+%ld\n", \
c906108c
SS
406 REGISTER_NAME (fi->proc_desc->pdr.framereg), \
407 fi->proc_desc->pdr.frameoffset); \
408 }
409
410/* It takes two values to specify a frame on the ALPHA. Sigh.
411
412 In fact, at the moment, the *PC* is the primary value that sets up
413 a frame. The PC is looked up to see what function it's in; symbol
414 information from that function tells us which register is the frame
415 pointer base, and what offset from there is the "virtual frame pointer".
416 (This is usually an offset from SP.) FIXME -- this should be cleaned
417 up so that the primary value is the SP, and the PC is used to disambiguate
418 multiple functions with the same SP that are at different stack levels. */
419
420#define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv)
a14ed312 421extern struct frame_info *setup_arbitrary_frame (int, CORE_ADDR *);
c906108c
SS
422
423/* This is used by heuristic_proc_start. It should be shot it the head. */
424#ifndef VM_MIN_ADDRESS
425#define VM_MIN_ADDRESS (CORE_ADDR)0x120000000
426#endif
427
428/* If PC is in a shared library trampoline code, return the PC
429 where the function itself actually starts. If not, return 0. */
430#define SKIP_TRAMPOLINE_CODE(pc) find_solib_trampoline_target (pc)
431
432/* If the current gcc for for this target does not produce correct debugging
433 information for float parameters, both prototyped and unprototyped, then
434 define this macro. This forces gdb to always assume that floats are
435 passed as doubles and then converted in the callee.
436
437 For the alpha, it appears that the debug info marks the parameters as
438 floats regardless of whether the function is prototyped, but the actual
439 values are always passed in as doubles. Thus by setting this to 1, both
440 types of calls will work. */
441
b9a8e3bf 442#define COERCE_FLOAT_TO_DOUBLE(formal, actual) (1)
c906108c
SS
443
444/* Return TRUE if procedure descriptor PROC is a procedure descriptor
445 that refers to a dynamically generated sigtramp function.
446
447 OSF/1 doesn't use dynamic sigtramp functions, so this is always
448 FALSE. */
449
450#define PROC_DESC_IS_DYN_SIGTRAMP(proc) (0)
451#define SET_PROC_DESC_IS_DYN_SIGTRAMP(proc)
452
453/* If PC is inside a dynamically generated sigtramp function, return
454 how many bytes the program counter is beyond the start of that
455 function. Otherwise, return a negative value.
456
457 OSF/1 doesn't use dynamic sigtramp functions, so this always
458 returns -1. */
459
460#define DYNAMIC_SIGTRAMP_OFFSET(pc) (-1)
461
462/* Translate a signal handler frame into the address of the sigcontext
463 structure. */
464
465#define SIGCONTEXT_ADDR(frame) \
466 (read_memory_integer ((frame)->next ? frame->next->frame : frame->frame, 8))
467
468/* If FRAME refers to a sigtramp frame, return the address of the next
469 frame. */
470
471#define FRAME_PAST_SIGTRAMP_FRAME(frame, pc) \
472 (alpha_osf_skip_sigtramp_frame (frame, pc))
a14ed312
KB
473extern CORE_ADDR alpha_osf_skip_sigtramp_frame (struct frame_info *,
474 CORE_ADDR);
c906108c 475
ec32e4be
JT
476/* Single step based on where the current instruction will take us. */
477extern void alpha_software_single_step (enum target_signal, int);
478
c906108c 479#endif /* TM_ALPHA_H */
This page took 0.152077 seconds and 4 git commands to generate.