* config/mips/tm-mips.h: Undefine BREAKPOINT, replace
[deliverable/binutils-gdb.git] / gdb / config / mips / tm-mips.h
1 /* Definitions to make GDB run on a mips box under 4.3bsd.
2 Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995
3 Free Software Foundation, Inc.
4 Contributed by Per Bothner (bothner@cs.wisc.edu) at U.Wisconsin
5 and by Alessandro Forin (af@cs.cmu.edu) at CMU..
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23 #ifndef TM_MIPS_H
24 #define TM_MIPS_H 1
25
26 #ifdef __STDC__
27 struct frame_info;
28 struct symbol;
29 struct type;
30 struct value;
31 #endif
32
33 #include <bfd.h>
34 #include "coff/sym.h" /* Needed for PDR below. */
35 #include "coff/symconst.h"
36
37 #if !defined (TARGET_BYTE_ORDER)
38 #define TARGET_BYTE_ORDER LITTLE_ENDIAN
39 #endif
40
41 #if !defined (GDB_TARGET_IS_MIPS64)
42 #define GDB_TARGET_IS_MIPS64 0
43 #endif
44
45 #if !defined (MIPS_EABI)
46 #define MIPS_EABI 0
47 #endif
48
49 #if !defined (TARGET_MONITOR_PROMPT)
50 #define TARGET_MONITOR_PROMPT "<IDT>"
51 #endif
52
53 /* Floating point is IEEE compliant */
54 #define IEEE_FLOAT
55
56 /* Some MIPS boards are provided both with and without a floating
57 point coprocessor. The MIPS R4650 chip has only single precision
58 floating point. We provide a user settable variable to tell gdb
59 what type of floating point to use. */
60
61 enum mips_fpu_type
62 {
63 MIPS_FPU_DOUBLE, /* Full double precision floating point. */
64 MIPS_FPU_SINGLE, /* Single precision floating point (R4650). */
65 MIPS_FPU_NONE /* No floating point. */
66 };
67
68 extern enum mips_fpu_type mips_fpu;
69
70 /* The name of the usual type of MIPS processor that is in the target
71 system. */
72
73 #define DEFAULT_MIPS_TYPE "generic"
74
75 /* Remove useless bits from an instruction address. */
76
77 #define ADDR_BITS_REMOVE(addr) mips_addr_bits_remove(addr)
78 CORE_ADDR mips_addr_bits_remove PARAMS ((CORE_ADDR addr));
79
80 /* Remove useless bits from the stack pointer. */
81
82 #define TARGET_READ_SP() ADDR_BITS_REMOVE (read_register (SP_REGNUM))
83
84 /* Offset from address of function to start of its code.
85 Zero on most machines. */
86
87 #define FUNCTION_START_OFFSET 0
88
89 /* Advance PC across any function entry prologue instructions
90 to reach some "real" code. */
91
92 #define SKIP_PROLOGUE(pc) pc = mips_skip_prologue (pc, 0)
93 extern CORE_ADDR mips_skip_prologue PARAMS ((CORE_ADDR addr, int lenient));
94
95 /* Return non-zero if PC points to an instruction which will cause a step
96 to execute both the instruction at PC and an instruction at PC+4. */
97 #define STEP_SKIPS_DELAY(pc) (mips_step_skips_delay (pc))
98 extern int mips_step_skips_delay PARAMS ((CORE_ADDR));
99
100 /* Immediately after a function call, return the saved pc.
101 Can't always go through the frames for this because on some machines
102 the new frame is not set up until the new function executes
103 some instructions. */
104
105 #define SAVED_PC_AFTER_CALL(frame) read_register(RA_REGNUM)
106
107 /* Are we currently handling a signal */
108
109 extern int in_sigtramp PARAMS ((CORE_ADDR, char *));
110 #define IN_SIGTRAMP(pc, name) in_sigtramp(pc, name)
111
112 /* Stack grows downward. */
113
114 #define INNER_THAN <
115
116 #define BIG_ENDIAN 4321
117 #define BIG_BREAKPOINT {0, 0x5, 0, 0xd}
118 #define LITTLE_BREAKPOINT {0xd, 0, 0x5, 0}
119
120 /* Amount PC must be decremented by after a breakpoint.
121 This is often the number of bytes in BREAKPOINT
122 but not always. */
123
124 #define DECR_PC_AFTER_BREAK 0
125
126 /* Nonzero if instruction at PC is a return instruction. "j ra" on mips. */
127
128 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0x3e00008)
129
130 /* Say how long (ordinary) registers are. This is a piece of bogosity
131 used in push_word and a few other places; REGISTER_RAW_SIZE is the
132 real way to know how big a register is. */
133
134 #define REGISTER_SIZE 4
135
136 /* The size of a register. This is predefined in tm-mips64.h. We
137 can't use REGISTER_SIZE because that is used for various other
138 things. */
139
140 #ifndef MIPS_REGSIZE
141 #define MIPS_REGSIZE 4
142 #endif
143
144 /* Number of machine registers */
145
146 #define NUM_REGS 90
147
148 /* Initializer for an array of names of registers.
149 There should be NUM_REGS strings in this initializer. */
150
151 #define REGISTER_NAMES \
152 { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", \
153 "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", \
154 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", \
155 "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra", \
156 "sr", "lo", "hi", "bad", "cause","pc", \
157 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
158 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
159 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",\
160 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",\
161 "fsr", "fir", "fp", "", \
162 "", "", "", "", "", "", "", "", \
163 "", "", "", "", "", "", "", "", \
164 }
165
166 /* Register numbers of various important registers.
167 Note that some of these values are "real" register numbers,
168 and correspond to the general registers of the machine,
169 and some are "phony" register numbers which are too large
170 to be actual register numbers as far as the user is concerned
171 but do serve to get the desired values when passed to read_register. */
172
173 #define ZERO_REGNUM 0 /* read-only register, always 0 */
174 #define V0_REGNUM 2 /* Function integer return value */
175 #define A0_REGNUM 4 /* Loc of first arg during a subr call */
176 #if MIPS_EABI
177 # define MIPS_LAST_ARG_REGNUM 11 /* EABI uses R4 through R11 for args */
178 # define MIPS_NUM_ARG_REGS 8
179 #else
180 # define MIPS_LAST_ARG_REGNUM 7 /* old ABI uses R4 through R7 for args */
181 # define MIPS_NUM_ARG_REGS 4
182 #endif
183 #define T9_REGNUM 25 /* Contains address of callee in PIC */
184 #define SP_REGNUM 29 /* Contains address of top of stack */
185 #define RA_REGNUM 31 /* Contains return address value */
186 #define PS_REGNUM 32 /* Contains processor status */
187 #define HI_REGNUM 34 /* Multiple/divide temp */
188 #define LO_REGNUM 33 /* ... */
189 #define BADVADDR_REGNUM 35 /* bad vaddr for addressing exception */
190 #define CAUSE_REGNUM 36 /* describes last exception */
191 #define PC_REGNUM 37 /* Contains program counter */
192 #define FP0_REGNUM 38 /* Floating point register 0 (single float) */
193 #define FPA0_REGNUM (FP0_REGNUM+12) /* First float argument register */
194 #if MIPS_EABI /* EABI uses F12 through F19 for args */
195 # define MIPS_LAST_FP_ARG_REGNUM (FP0_REGNUM+19)
196 # define MIPS_NUM_FP_ARG_REGS 8
197 #else /* old ABI uses F12 through F15 for args */
198 # define MIPS_LAST_FP_ARG_REGNUM (FP0_REGNUM+15)
199 # define MIPS_NUM_FP_ARG_REGS 4
200 #endif
201 #define FCRCS_REGNUM 70 /* FP control/status */
202 #define FCRIR_REGNUM 71 /* FP implementation/revision */
203 #define FP_REGNUM 72 /* Pseudo register that contains true address of executing stack frame */
204 #define UNUSED_REGNUM 73 /* Never used, FIXME */
205 #define FIRST_EMBED_REGNUM 74 /* First CP0 register for embedded use */
206 #define PRID_REGNUM 89 /* Processor ID */
207 #define LAST_EMBED_REGNUM 89 /* Last one */
208
209 /* Define DO_REGISTERS_INFO() to do machine-specific formatting
210 of register dumps. */
211
212 #define DO_REGISTERS_INFO(_regnum, fp) mips_do_registers_info(_regnum, fp)
213 extern void mips_do_registers_info PARAMS ((int, int));
214
215 /* Total amount of space needed to store our copies of the machine's
216 register state, the array `registers'. */
217
218 #define REGISTER_BYTES (NUM_REGS*MIPS_REGSIZE)
219
220 /* Index within `registers' of the first byte of the space for
221 register N. */
222
223 #define REGISTER_BYTE(N) ((N) * MIPS_REGSIZE)
224
225 /* Number of bytes of storage in the actual machine representation
226 for register N. On mips, all regs are the same size. */
227
228 #define REGISTER_RAW_SIZE(N) MIPS_REGSIZE
229
230 /* Number of bytes of storage in the program's representation
231 for register N. On mips, all regs are the same size. */
232
233 #define REGISTER_VIRTUAL_SIZE(N) MIPS_REGSIZE
234
235 /* Largest value REGISTER_RAW_SIZE can have. */
236
237 #define MAX_REGISTER_RAW_SIZE 8
238
239 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
240
241 #define MAX_REGISTER_VIRTUAL_SIZE 8
242
243 /* Return the GDB type object for the "standard" data type
244 of data in register N. */
245
246 #ifndef REGISTER_VIRTUAL_TYPE
247 #define REGISTER_VIRTUAL_TYPE(N) \
248 (((N) >= FP0_REGNUM && (N) < FP0_REGNUM+32) \
249 ? builtin_type_float : builtin_type_int)
250 #endif
251
252 #if HOST_BYTE_ORDER == BIG_ENDIAN
253 /* All mips targets store doubles in a register pair with the least
254 significant register in the lower numbered register.
255 If the host is big endian, double register values need conversion between
256 memory and register formats. */
257
258 #define REGISTER_CONVERT_TO_TYPE(n, type, buffer) \
259 do {if ((n) >= FP0_REGNUM && (n) < FP0_REGNUM + 32 && \
260 TYPE_CODE(type) == TYPE_CODE_FLT && TYPE_LENGTH(type) == 8) { \
261 char __temp[4]; \
262 memcpy (__temp, ((char *)(buffer))+4, 4); \
263 memcpy (((char *)(buffer))+4, (buffer), 4); \
264 memcpy (((char *)(buffer)), __temp, 4); }} while (0)
265
266 #define REGISTER_CONVERT_FROM_TYPE(n, type, buffer) \
267 do {if ((n) >= FP0_REGNUM && (n) < FP0_REGNUM + 32 && \
268 TYPE_CODE(type) == TYPE_CODE_FLT && TYPE_LENGTH(type) == 8) { \
269 char __temp[4]; \
270 memcpy (__temp, ((char *)(buffer))+4, 4); \
271 memcpy (((char *)(buffer))+4, (buffer), 4); \
272 memcpy (((char *)(buffer)), __temp, 4); }} while (0)
273 #endif
274
275 /* Store the address of the place in which to copy the structure the
276 subroutine will return. Handled by mips_push_arguments. */
277
278 #define STORE_STRUCT_RETURN(addr, sp) /**/
279
280 /* Extract from an array REGBUF containing the (raw) register state
281 a function return value of type TYPE, and copy that, in virtual format,
282 into VALBUF. XXX floats */
283
284 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
285 mips_extract_return_value(TYPE, REGBUF, VALBUF)
286 extern void
287 mips_extract_return_value PARAMS ((struct type *, char [], char *));
288
289 /* Write into appropriate registers a function return value
290 of type TYPE, given in virtual format. */
291
292 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
293 mips_store_return_value(TYPE, VALBUF)
294 extern void mips_store_return_value PARAMS ((struct type *, char *));
295
296 /* Extract from an array REGBUF containing the (raw) register state
297 the address in which a function should return its structure value,
298 as a CORE_ADDR (or an expression that can be used as one). */
299 /* The address is passed in a0 upon entry to the function, but when
300 the function exits, the compiler has copied the value to v0. This
301 convention is specified by the System V ABI, so I think we can rely
302 on it. */
303
304 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
305 (extract_address (REGBUF + REGISTER_BYTE (V0_REGNUM), \
306 REGISTER_RAW_SIZE (V0_REGNUM)))
307
308 /* Structures are returned by ref in extra arg0 */
309 #define USE_STRUCT_CONVENTION(gcc_p, type) 1
310
311 \f
312 /* Describe the pointer in each stack frame to the previous stack frame
313 (its caller). */
314
315 /* FRAME_CHAIN takes a frame's nominal address
316 and produces the frame's chain-pointer. */
317
318 #define FRAME_CHAIN(thisframe) (CORE_ADDR) mips_frame_chain (thisframe)
319 extern CORE_ADDR mips_frame_chain PARAMS ((struct frame_info *));
320
321 /* Define other aspects of the stack frame. */
322
323
324 /* A macro that tells us whether the function invocation represented
325 by FI does not have a frame on the stack associated with it. If it
326 does not, FRAMELESS is set to 1, else 0. */
327 /* We handle this differently for mips, and maybe we should not */
328
329 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) {(FRAMELESS) = 0;}
330
331 /* Saved Pc. */
332
333 #define FRAME_SAVED_PC(FRAME) (mips_frame_saved_pc(FRAME))
334 extern CORE_ADDR mips_frame_saved_pc PARAMS ((struct frame_info *));
335
336 #define FRAME_ARGS_ADDRESS(fi) (fi)->frame
337
338 #define FRAME_LOCALS_ADDRESS(fi) (fi)->frame
339
340 /* Return number of args passed to a frame.
341 Can return -1, meaning no way to tell. */
342
343 #define FRAME_NUM_ARGS(num, fi) (num = mips_frame_num_args(fi))
344 extern int mips_frame_num_args PARAMS ((struct frame_info *));
345
346 /* Return number of bytes at start of arglist that are not really args. */
347
348 #define FRAME_ARGS_SKIP 0
349
350 /* Put here the code to store, into a struct frame_saved_regs,
351 the addresses of the saved registers of frame described by FRAME_INFO.
352 This includes special registers such as pc and fp saved in special
353 ways in the stack frame. sp is even more special:
354 the address we return for it IS the sp for the next frame. */
355
356 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
357 do { \
358 if ((frame_info)->saved_regs == NULL) \
359 mips_find_saved_regs (frame_info); \
360 (frame_saved_regs) = *(frame_info)->saved_regs; \
361 (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame; \
362 } while (0)
363 extern void mips_find_saved_regs PARAMS ((struct frame_info *));
364
365 \f
366 /* Things needed for making the inferior call functions. */
367
368 /* Stack must be aligned on 32-bit boundaries when synthesizing
369 function calls. We don't need STACK_ALIGN, PUSH_ARGUMENTS will
370 handle it. */
371
372 #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
373 sp = mips_push_arguments((nargs), (args), (sp), (struct_return), (struct_addr))
374 extern CORE_ADDR
375 mips_push_arguments PARAMS ((int, struct value **, CORE_ADDR, int, CORE_ADDR));
376
377 /* Push an empty stack frame, to record the current PC, etc. */
378
379 #define PUSH_DUMMY_FRAME mips_push_dummy_frame()
380 extern void mips_push_dummy_frame PARAMS ((void));
381
382 /* Discard from the stack the innermost frame, restoring all registers. */
383
384 #define POP_FRAME mips_pop_frame()
385 extern void mips_pop_frame PARAMS ((void));
386
387 #define CALL_DUMMY { 0 }
388
389 #define CALL_DUMMY_START_OFFSET (0)
390
391 #define CALL_DUMMY_BREAKPOINT_OFFSET (0)
392
393 /* On Irix, $t9 ($25) contains the address of the callee (used for PIC).
394 It doesn't hurt to do this on other systems; $t9 will be ignored. */
395 #define FIX_CALL_DUMMY(dummyname, start_sp, fun, nargs, args, rettype, gcc_p) \
396 write_register(T9_REGNUM, fun)
397
398 #define CALL_DUMMY_LOCATION AT_ENTRY_POINT
399
400 #define CALL_DUMMY_ADDRESS() (entry_point_address ())
401
402 /* There's a mess in stack frame creation. See comments in blockframe.c
403 near reference to INIT_FRAME_PC_FIRST. */
404
405 #define INIT_FRAME_PC(fromleaf, prev) /* nada */
406
407 #define INIT_FRAME_PC_FIRST(fromleaf, prev) \
408 (prev)->pc = ((fromleaf) ? SAVED_PC_AFTER_CALL ((prev)->next) : \
409 (prev)->next ? FRAME_SAVED_PC ((prev)->next) : read_pc ());
410
411 /* Special symbol found in blocks associated with routines. We can hang
412 mips_extra_func_info_t's off of this. */
413
414 #define MIPS_EFI_SYMBOL_NAME "__GDB_EFI_INFO__"
415 extern void ecoff_relocate_efi PARAMS ((struct symbol *, CORE_ADDR));
416
417 /* Specific information about a procedure.
418 This overlays the MIPS's PDR records,
419 mipsread.c (ab)uses this to save memory */
420
421 typedef struct mips_extra_func_info {
422 long numargs; /* number of args to procedure (was iopt) */
423 bfd_vma high_addr; /* upper address bound */
424 PDR pdr; /* Procedure descriptor record */
425 } *mips_extra_func_info_t;
426
427 #define EXTRA_FRAME_INFO \
428 mips_extra_func_info_t proc_desc; \
429 int num_args;\
430 struct frame_saved_regs *saved_regs;
431
432 #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci)
433 extern void init_extra_frame_info PARAMS ((struct frame_info *));
434
435 #define PRINT_EXTRA_FRAME_INFO(fi) \
436 { \
437 if (fi && fi->proc_desc && fi->proc_desc->pdr.framereg < NUM_REGS) \
438 printf_filtered (" frame pointer is at %s+%d\n", \
439 reg_names[fi->proc_desc->pdr.framereg], \
440 fi->proc_desc->pdr.frameoffset); \
441 }
442
443 /* It takes two values to specify a frame on the MIPS.
444
445 In fact, the *PC* is the primary value that sets up a frame. The
446 PC is looked up to see what function it's in; symbol information
447 from that function tells us which register is the frame pointer
448 base, and what offset from there is the "virtual frame pointer".
449 (This is usually an offset from SP.) On most non-MIPS machines,
450 the primary value is the SP, and the PC, if needed, disambiguates
451 multiple functions with the same SP. But on the MIPS we can't do
452 that since the PC is not stored in the same part of the frame every
453 time. This does not seem to be a very clever way to set up frames,
454 but there is nothing we can do about that). */
455
456 #define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv)
457 extern struct frame_info *setup_arbitrary_frame PARAMS ((int, CORE_ADDR *));
458
459 /* Convert a dbx stab register number (from `r' declaration) to a gdb REGNUM */
460
461 #define STAB_REG_TO_REGNUM(num) ((num) < 32 ? (num) : (num)+FP0_REGNUM-38)
462
463 /* Convert a ecoff register number to a gdb REGNUM */
464
465 #define ECOFF_REG_TO_REGNUM(num) ((num) < 32 ? (num) : (num)+FP0_REGNUM-32)
466
467 /* If the current gcc for for this target does not produce correct debugging
468 information for float parameters, both prototyped and unprototyped, then
469 define this macro. This forces gdb to always assume that floats are
470 passed as doubles and then converted in the callee.
471
472 For the mips chip, it appears that the debug info marks the parameters as
473 floats regardless of whether the function is prototyped, but the actual
474 values are passed as doubles for the non-prototyped case and floats for
475 the prototyped case. Thus we choose to make the non-prototyped case work
476 for C and break the prototyped case, since the non-prototyped case is
477 probably much more common. (FIXME). */
478
479 #define COERCE_FLOAT_TO_DOUBLE (current_language -> la_language == language_c)
480
481 /* These are defined in mdebugread.c and are used in mips-tdep.c */
482 extern CORE_ADDR sigtramp_address, sigtramp_end;
483 extern void fixup_sigtramp PARAMS ((void));
484
485 /* Defined in mips-tdep.c and used in remote-mips.c */
486 extern char *mips_read_processor_type PARAMS ((void));
487
488 #ifndef TARGET_MIPS
489 #define TARGET_MIPS
490 #endif
491
492 #endif /* TM_MIPS_H */
This page took 0.054887 seconds and 4 git commands to generate.