1 /* Target-dependent code for the MIPS architecture, for GDB, the GNU Debugger.
3 Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
4 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
6 Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
7 and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
9 This file is part of GDB.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. */
27 #include "gdb_string.h"
28 #include "gdb_assert.h"
40 #include "arch-utils.h"
43 #include "mips-tdep.h"
45 #include "reggroups.h"
46 #include "opcode/mips.h"
50 #include "sim-regno.h"
52 static void set_reg_offset (CORE_ADDR
*saved_regs
, int regnum
, CORE_ADDR off
);
53 static struct type
*mips_register_type (struct gdbarch
*gdbarch
, int regnum
);
55 /* A useful bit in the CP0 status register (PS_REGNUM). */
56 /* This bit is set if we are emulating 32-bit FPRs on a 64-bit chip. */
57 #define ST0_FR (1 << 26)
59 /* The sizes of floating point registers. */
63 MIPS_FPU_SINGLE_REGSIZE
= 4,
64 MIPS_FPU_DOUBLE_REGSIZE
= 8
68 static const char *mips_abi_string
;
70 static const char *mips_abi_strings
[] = {
81 struct frame_extra_info
83 mips_extra_func_info_t proc_desc
;
87 /* Various MIPS ISA options (related to stack analysis) can be
88 overridden dynamically. Establish an enum/array for managing
91 static const char size_auto
[] = "auto";
92 static const char size_32
[] = "32";
93 static const char size_64
[] = "64";
95 static const char *size_enums
[] = {
102 /* Some MIPS boards don't support floating point while others only
103 support single-precision floating-point operations. See also
104 FP_REGISTER_DOUBLE. */
108 MIPS_FPU_DOUBLE
, /* Full double precision floating point. */
109 MIPS_FPU_SINGLE
, /* Single precision floating point (R4650). */
110 MIPS_FPU_NONE
/* No floating point. */
113 #ifndef MIPS_DEFAULT_FPU_TYPE
114 #define MIPS_DEFAULT_FPU_TYPE MIPS_FPU_DOUBLE
116 static int mips_fpu_type_auto
= 1;
117 static enum mips_fpu_type mips_fpu_type
= MIPS_DEFAULT_FPU_TYPE
;
119 static int mips_debug
= 0;
121 /* MIPS specific per-architecture information */
124 /* from the elf header */
128 enum mips_abi mips_abi
;
129 enum mips_abi found_abi
;
130 enum mips_fpu_type mips_fpu_type
;
131 int mips_last_arg_regnum
;
132 int mips_last_fp_arg_regnum
;
133 int mips_default_saved_regsize
;
134 int mips_fp_register_double
;
135 int mips_default_stack_argsize
;
136 int gdb_target_is_mips64
;
137 int default_mask_address_p
;
140 #define MIPS_EABI (gdbarch_tdep (current_gdbarch)->mips_abi == MIPS_ABI_EABI32 \
141 || gdbarch_tdep (current_gdbarch)->mips_abi == MIPS_ABI_EABI64)
143 #define MIPS_LAST_FP_ARG_REGNUM (gdbarch_tdep (current_gdbarch)->mips_last_fp_arg_regnum)
145 #define MIPS_LAST_ARG_REGNUM (gdbarch_tdep (current_gdbarch)->mips_last_arg_regnum)
147 #define MIPS_FPU_TYPE (gdbarch_tdep (current_gdbarch)->mips_fpu_type)
149 /* Return the currently configured (or set) saved register size. */
151 #define MIPS_DEFAULT_SAVED_REGSIZE (gdbarch_tdep (current_gdbarch)->mips_default_saved_regsize)
153 static const char *mips_saved_regsize_string
= size_auto
;
155 #define MIPS_SAVED_REGSIZE (mips_saved_regsize())
157 /* MIPS16 function addresses are odd (bit 0 is set). Here are some
158 functions to test, set, or clear bit 0 of addresses. */
161 is_mips16_addr (CORE_ADDR addr
)
167 make_mips16_addr (CORE_ADDR addr
)
173 unmake_mips16_addr (CORE_ADDR addr
)
175 return ((addr
) & ~1);
178 /* Return the contents of register REGNUM as a signed integer. */
181 read_signed_register (int regnum
)
183 void *buf
= alloca (REGISTER_RAW_SIZE (regnum
));
184 deprecated_read_register_gen (regnum
, buf
);
185 return (extract_signed_integer (buf
, REGISTER_RAW_SIZE (regnum
)));
189 read_signed_register_pid (int regnum
, ptid_t ptid
)
194 if (ptid_equal (ptid
, inferior_ptid
))
195 return read_signed_register (regnum
);
197 save_ptid
= inferior_ptid
;
199 inferior_ptid
= ptid
;
201 retval
= read_signed_register (regnum
);
203 inferior_ptid
= save_ptid
;
208 /* Return the MIPS ABI associated with GDBARCH. */
210 mips_abi (struct gdbarch
*gdbarch
)
212 return gdbarch_tdep (gdbarch
)->mips_abi
;
216 mips_saved_regsize (void)
218 if (mips_saved_regsize_string
== size_auto
)
219 return MIPS_DEFAULT_SAVED_REGSIZE
;
220 else if (mips_saved_regsize_string
== size_64
)
222 else /* if (mips_saved_regsize_string == size_32) */
226 /* Functions for setting and testing a bit in a minimal symbol that
227 marks it as 16-bit function. The MSB of the minimal symbol's
228 "info" field is used for this purpose. This field is already
229 being used to store the symbol size, so the assumption is
230 that the symbol size cannot exceed 2^31.
232 ELF_MAKE_MSYMBOL_SPECIAL tests whether an ELF symbol is "special",
233 i.e. refers to a 16-bit function, and sets a "special" bit in a
234 minimal symbol to mark it as a 16-bit function
236 MSYMBOL_IS_SPECIAL tests the "special" bit in a minimal symbol
237 MSYMBOL_SIZE returns the size of the minimal symbol, i.e.
238 the "info" field with the "special" bit masked out */
241 mips_elf_make_msymbol_special (asymbol
*sym
, struct minimal_symbol
*msym
)
243 if (((elf_symbol_type
*)(sym
))->internal_elf_sym
.st_other
== STO_MIPS16
)
245 MSYMBOL_INFO (msym
) = (char *)
246 (((long) MSYMBOL_INFO (msym
)) | 0x80000000);
247 SYMBOL_VALUE_ADDRESS (msym
) |= 1;
252 msymbol_is_special (struct minimal_symbol
*msym
)
254 return (((long) MSYMBOL_INFO (msym
) & 0x80000000) != 0);
258 msymbol_size (struct minimal_symbol
*msym
)
260 return ((long) MSYMBOL_INFO (msym
) & 0x7fffffff);
263 /* XFER a value from the big/little/left end of the register.
264 Depending on the size of the value it might occupy the entire
265 register or just part of it. Make an allowance for this, aligning
266 things accordingly. */
269 mips_xfer_register (struct regcache
*regcache
, int reg_num
, int length
,
270 enum bfd_endian endian
, bfd_byte
*in
, const bfd_byte
*out
,
273 bfd_byte reg
[MAX_REGISTER_SIZE
];
275 gdb_assert (reg_num
>= NUM_REGS
);
276 /* Need to transfer the left or right part of the register, based on
277 the targets byte order. */
281 reg_offset
= REGISTER_RAW_SIZE (reg_num
) - length
;
283 case BFD_ENDIAN_LITTLE
:
286 case BFD_ENDIAN_UNKNOWN
: /* Indicates no alignment. */
290 internal_error (__FILE__
, __LINE__
, "bad switch");
293 fprintf_unfiltered (gdb_stderr
,
294 "xfer $%d, reg offset %d, buf offset %d, length %d, ",
295 reg_num
, reg_offset
, buf_offset
, length
);
296 if (mips_debug
&& out
!= NULL
)
299 fprintf_unfiltered (gdb_stdlog
, "out ");
300 for (i
= 0; i
< length
; i
++)
301 fprintf_unfiltered (gdb_stdlog
, "%02x", out
[buf_offset
+ i
]);
304 regcache_cooked_read_part (regcache
, reg_num
, reg_offset
, length
, in
+ buf_offset
);
306 regcache_cooked_write_part (regcache
, reg_num
, reg_offset
, length
, out
+ buf_offset
);
307 if (mips_debug
&& in
!= NULL
)
310 fprintf_unfiltered (gdb_stdlog
, "in ");
311 for (i
= 0; i
< length
; i
++)
312 fprintf_unfiltered (gdb_stdlog
, "%02x", in
[buf_offset
+ i
]);
315 fprintf_unfiltered (gdb_stdlog
, "\n");
318 /* Determine if a MIPS3 or later cpu is operating in MIPS{1,2} FPU
319 compatiblity mode. A return value of 1 means that we have
320 physical 64-bit registers, but should treat them as 32-bit registers. */
323 mips2_fp_compat (void)
325 /* MIPS1 and MIPS2 have only 32 bit FPRs, and the FR bit is not
327 if (REGISTER_RAW_SIZE (FP0_REGNUM
) == 4)
331 /* FIXME drow 2002-03-10: This is disabled until we can do it consistently,
332 in all the places we deal with FP registers. PR gdb/413. */
333 /* Otherwise check the FR bit in the status register - it controls
334 the FP compatiblity mode. If it is clear we are in compatibility
336 if ((read_register (PS_REGNUM
) & ST0_FR
) == 0)
343 /* Indicate that the ABI makes use of double-precision registers
344 provided by the FPU (rather than combining pairs of registers to
345 form double-precision values). Do not use "TARGET_IS_MIPS64" to
346 determine if the ABI is using double-precision registers. See also
348 #define FP_REGISTER_DOUBLE (gdbarch_tdep (current_gdbarch)->mips_fp_register_double)
350 /* The amount of space reserved on the stack for registers. This is
351 different to MIPS_SAVED_REGSIZE as it determines the alignment of
352 data allocated after the registers have run out. */
354 #define MIPS_DEFAULT_STACK_ARGSIZE (gdbarch_tdep (current_gdbarch)->mips_default_stack_argsize)
356 #define MIPS_STACK_ARGSIZE (mips_stack_argsize ())
358 static const char *mips_stack_argsize_string
= size_auto
;
361 mips_stack_argsize (void)
363 if (mips_stack_argsize_string
== size_auto
)
364 return MIPS_DEFAULT_STACK_ARGSIZE
;
365 else if (mips_stack_argsize_string
== size_64
)
367 else /* if (mips_stack_argsize_string == size_32) */
371 #define GDB_TARGET_IS_MIPS64 (gdbarch_tdep (current_gdbarch)->gdb_target_is_mips64 + 0)
373 #define MIPS_DEFAULT_MASK_ADDRESS_P (gdbarch_tdep (current_gdbarch)->default_mask_address_p)
375 #define VM_MIN_ADDRESS (CORE_ADDR)0x400000
377 int gdb_print_insn_mips (bfd_vma
, disassemble_info
*);
379 static mips_extra_func_info_t
heuristic_proc_desc (CORE_ADDR
, CORE_ADDR
,
380 struct frame_info
*, int);
382 static CORE_ADDR
heuristic_proc_start (CORE_ADDR
);
384 static CORE_ADDR
read_next_frame_reg (struct frame_info
*, int);
386 static int mips_set_processor_type (char *);
388 static void mips_show_processor_type_command (char *, int);
390 static void reinit_frame_cache_sfunc (char *, int, struct cmd_list_element
*);
392 static mips_extra_func_info_t
find_proc_desc (CORE_ADDR pc
,
393 struct frame_info
*next_frame
,
396 static CORE_ADDR
after_prologue (CORE_ADDR pc
,
397 mips_extra_func_info_t proc_desc
);
399 static struct type
*mips_float_register_type (void);
400 static struct type
*mips_double_register_type (void);
402 /* This value is the model of MIPS in use. It is derived from the value
403 of the PrID register. */
405 char *mips_processor_type
;
407 char *tmp_mips_processor_type
;
409 /* The list of available "set mips " and "show mips " commands */
411 static struct cmd_list_element
*setmipscmdlist
= NULL
;
412 static struct cmd_list_element
*showmipscmdlist
= NULL
;
414 /* A set of original names, to be used when restoring back to generic
415 registers from a specific set. */
416 static char *mips_generic_reg_names
[] = MIPS_REGISTER_NAMES
;
418 /* Integer registers 0 thru 31 are handled explicitly by
419 mips_register_name(). Processor specific registers 32 and above
420 are listed in the sets of register names assigned to
421 mips_processor_reg_names. */
422 static char **mips_processor_reg_names
= mips_generic_reg_names
;
424 /* Return the name of the register corresponding to REGNO. */
426 mips_register_name (int regno
)
428 /* GPR names for all ABIs other than n32/n64. */
429 static char *mips_gpr_names
[] = {
430 "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
431 "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
432 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
433 "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra",
436 /* GPR names for n32 and n64 ABIs. */
437 static char *mips_n32_n64_gpr_names
[] = {
438 "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
439 "a4", "a5", "a6", "a7", "t0", "t1", "t2", "t3",
440 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
441 "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra"
444 enum mips_abi abi
= mips_abi (current_gdbarch
);
446 /* Map [NUM_REGS .. 2*NUM_REGS) onto the raw registers, but then
447 don't make the raw register names visible. */
448 int rawnum
= regno
% NUM_REGS
;
449 if (regno
< NUM_REGS
)
452 /* The MIPS integer registers are always mapped from 0 to 31. The
453 names of the registers (which reflects the conventions regarding
454 register use) vary depending on the ABI. */
455 if (0 <= rawnum
&& rawnum
< 32)
457 if (abi
== MIPS_ABI_N32
|| abi
== MIPS_ABI_N64
)
458 return mips_n32_n64_gpr_names
[rawnum
];
460 return mips_gpr_names
[rawnum
];
462 else if (32 <= rawnum
&& rawnum
< NUM_REGS
)
463 return mips_processor_reg_names
[rawnum
- 32];
465 internal_error (__FILE__
, __LINE__
,
466 "mips_register_name: bad register number %d", rawnum
);
470 /* Names of IDT R3041 registers. */
472 char *mips_r3041_reg_names
[] = {
473 "sr", "lo", "hi", "bad", "cause","pc",
474 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
475 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
476 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
477 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
478 "fsr", "fir", "",/*"fp"*/ "",
479 "", "", "bus", "ccfg", "", "", "", "",
480 "", "", "port", "cmp", "", "", "epc", "prid",
483 /* Names of IDT R3051 registers. */
485 char *mips_r3051_reg_names
[] = {
486 "sr", "lo", "hi", "bad", "cause","pc",
487 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
488 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
489 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
490 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
491 "fsr", "fir", ""/*"fp"*/, "",
492 "inx", "rand", "elo", "", "ctxt", "", "", "",
493 "", "", "ehi", "", "", "", "epc", "prid",
496 /* Names of IDT R3081 registers. */
498 char *mips_r3081_reg_names
[] = {
499 "sr", "lo", "hi", "bad", "cause","pc",
500 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
501 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
502 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
503 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
504 "fsr", "fir", ""/*"fp"*/, "",
505 "inx", "rand", "elo", "cfg", "ctxt", "", "", "",
506 "", "", "ehi", "", "", "", "epc", "prid",
509 /* Names of LSI 33k registers. */
511 char *mips_lsi33k_reg_names
[] = {
512 "epc", "hi", "lo", "sr", "cause","badvaddr",
513 "dcic", "bpc", "bda", "", "", "", "", "",
514 "", "", "", "", "", "", "", "",
515 "", "", "", "", "", "", "", "",
516 "", "", "", "", "", "", "", "",
518 "", "", "", "", "", "", "", "",
519 "", "", "", "", "", "", "", "",
525 } mips_processor_type_table
[] = {
526 { "generic", mips_generic_reg_names
},
527 { "r3041", mips_r3041_reg_names
},
528 { "r3051", mips_r3051_reg_names
},
529 { "r3071", mips_r3081_reg_names
},
530 { "r3081", mips_r3081_reg_names
},
531 { "lsi33k", mips_lsi33k_reg_names
},
536 /* Return the groups that a MIPS register can be categorised into. */
539 mips_register_reggroup_p (struct gdbarch
*gdbarch
, int regnum
,
540 struct reggroup
*reggroup
)
545 int rawnum
= regnum
% NUM_REGS
;
546 int pseudo
= regnum
/ NUM_REGS
;
547 if (reggroup
== all_reggroup
)
549 vector_p
= TYPE_VECTOR (register_type (gdbarch
, regnum
));
550 float_p
= TYPE_CODE (register_type (gdbarch
, regnum
)) == TYPE_CODE_FLT
;
551 /* FIXME: cagney/2003-04-13: Can't yet use gdbarch_num_regs
552 (gdbarch), as not all architectures are multi-arch. */
553 raw_p
= rawnum
< NUM_REGS
;
554 if (REGISTER_NAME (regnum
) == NULL
555 || REGISTER_NAME (regnum
)[0] == '\0')
557 if (reggroup
== float_reggroup
)
558 return float_p
&& pseudo
;
559 if (reggroup
== vector_reggroup
)
560 return vector_p
&& pseudo
;
561 if (reggroup
== general_reggroup
)
562 return (!vector_p
&& !float_p
) && pseudo
;
563 /* Save the pseudo registers. Need to make certain that any code
564 extracting register values from a saved register cache also uses
566 if (reggroup
== save_reggroup
)
567 return raw_p
&& pseudo
;
568 /* Restore the same pseudo register. */
569 if (reggroup
== restore_reggroup
)
570 return raw_p
&& pseudo
;
574 /* Map the symbol table registers which live in the range [1 *
575 NUM_REGS .. 2 * NUM_REGS) back onto the corresponding raw
579 mips_pseudo_register_read (struct gdbarch
*gdbarch
, struct regcache
*regcache
,
580 int cookednum
, void *buf
)
582 gdb_assert (cookednum
>= NUM_REGS
&& cookednum
< 2 * NUM_REGS
);
583 return regcache_raw_read (regcache
, cookednum
% NUM_REGS
, buf
);
587 mips_pseudo_register_write (struct gdbarch
*gdbarch
, struct regcache
*regcache
,
588 int cookednum
, const void *buf
)
590 gdb_assert (cookednum
>= NUM_REGS
&& cookednum
< 2 * NUM_REGS
);
591 return regcache_raw_write (regcache
, cookednum
% NUM_REGS
, buf
);
594 /* Table to translate MIPS16 register field to actual register number. */
595 static int mips16_to_32_reg
[8] =
596 {16, 17, 2, 3, 4, 5, 6, 7};
598 /* Heuristic_proc_start may hunt through the text section for a long
599 time across a 2400 baud serial line. Allows the user to limit this
602 static unsigned int heuristic_fence_post
= 0;
604 #define PROC_LOW_ADDR(proc) ((proc)->pdr.adr) /* least address */
605 #define PROC_HIGH_ADDR(proc) ((proc)->high_addr) /* upper address bound */
606 #define PROC_FRAME_OFFSET(proc) ((proc)->pdr.frameoffset)
607 #define PROC_FRAME_REG(proc) ((proc)->pdr.framereg)
608 #define PROC_FRAME_ADJUST(proc) ((proc)->frame_adjust)
609 #define PROC_REG_MASK(proc) ((proc)->pdr.regmask)
610 #define PROC_FREG_MASK(proc) ((proc)->pdr.fregmask)
611 #define PROC_REG_OFFSET(proc) ((proc)->pdr.regoffset)
612 #define PROC_FREG_OFFSET(proc) ((proc)->pdr.fregoffset)
613 #define PROC_PC_REG(proc) ((proc)->pdr.pcreg)
614 /* FIXME drow/2002-06-10: If a pointer on the host is bigger than a long,
615 this will corrupt pdr.iline. Fortunately we don't use it. */
616 #define PROC_SYMBOL(proc) (*(struct symbol**)&(proc)->pdr.isym)
617 #define _PROC_MAGIC_ 0x0F0F0F0F
618 #define PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym == _PROC_MAGIC_)
619 #define SET_PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym = _PROC_MAGIC_)
621 struct linked_proc_info
623 struct mips_extra_func_info info
;
624 struct linked_proc_info
*next
;
626 *linked_proc_desc_table
= NULL
;
629 mips_print_extra_frame_info (struct frame_info
*fi
)
632 && get_frame_extra_info (fi
)
633 && get_frame_extra_info (fi
)->proc_desc
634 && get_frame_extra_info (fi
)->proc_desc
->pdr
.framereg
< NUM_REGS
)
635 printf_filtered (" frame pointer is at %s+%s\n",
636 REGISTER_NAME (get_frame_extra_info (fi
)->proc_desc
->pdr
.framereg
),
637 paddr_d (get_frame_extra_info (fi
)->proc_desc
->pdr
.frameoffset
));
640 /* Number of bytes of storage in the actual machine representation for
641 register N. NOTE: This indirectly defines the register size
642 transfered by the GDB protocol. */
644 static int mips64_transfers_32bit_regs_p
= 0;
647 mips_register_raw_size (int regnum
)
649 gdb_assert (regnum
>= 0);
650 if (regnum
< NUM_REGS
)
652 /* For compatibility with old code, implemnt the broken register raw
653 size map for the raw registers.
655 NOTE: cagney/2003-06-15: This is so bogus. The register's
656 raw size is changing according to the ABI
657 (FP_REGISTER_DOUBLE). Also, GDB's protocol is defined by a
658 combination of REGISTER_RAW_SIZE and REGISTER_BYTE. */
659 if (mips64_transfers_32bit_regs_p
)
660 return REGISTER_VIRTUAL_SIZE (regnum
);
661 else if (regnum
>= FP0_REGNUM
&& regnum
< FP0_REGNUM
+ 32
662 && FP_REGISTER_DOUBLE
)
663 /* For MIPS_ABI_N32 (for example) we need 8 byte floating point
669 else if (regnum
< 2 * NUM_REGS
)
671 /* For the moment map [NUM_REGS .. 2*NUM_REGS) onto the same raw
672 registers, but always return the virtual size. */
673 int rawnum
= regnum
% NUM_REGS
;
674 return TYPE_LENGTH (gdbarch_register_type (current_gdbarch
, rawnum
));
677 internal_error (__FILE__
, __LINE__
, "Register %d out of range", regnum
);
680 /* Register offset in a buffer for each register.
682 FIXME: cagney/2003-06-15: This is so bogus. Instead REGISTER_TYPE
683 should strictly return the layout of the buffer. Unfortunatly
684 remote.c and the MIPS have come to rely on a custom layout that
685 doesn't 1:1 map onto the register type. */
688 mips_register_byte (int regnum
)
690 gdb_assert (regnum
>= 0);
691 if (regnum
< NUM_REGS
)
692 /* Pick up the relevant per-tm file register byte method. */
693 return MIPS_REGISTER_BYTE (regnum
);
694 else if (regnum
< 2 * NUM_REGS
)
698 /* Start with the end of the raw register buffer - assum that
699 MIPS_REGISTER_BYTE (NUM_REGS) returns that end. */
700 byte
= MIPS_REGISTER_BYTE (NUM_REGS
);
701 /* Add space for all the proceeding registers based on their
703 for (reg
= NUM_REGS
; reg
< regnum
; reg
++)
704 byte
+= TYPE_LENGTH (gdbarch_register_type (current_gdbarch
,
709 internal_error (__FILE__
, __LINE__
, "Register %d out of range", regnum
);
712 /* Convert between RAW and VIRTUAL registers. The RAW register size
713 defines the remote-gdb packet. */
716 mips_register_convertible (int reg_nr
)
718 if (mips64_transfers_32bit_regs_p
)
721 return (REGISTER_RAW_SIZE (reg_nr
) > REGISTER_VIRTUAL_SIZE (reg_nr
));
725 mips_register_convert_to_virtual (int n
, struct type
*virtual_type
,
726 char *raw_buf
, char *virt_buf
)
728 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
730 raw_buf
+ (REGISTER_RAW_SIZE (n
) - TYPE_LENGTH (virtual_type
)),
731 TYPE_LENGTH (virtual_type
));
735 TYPE_LENGTH (virtual_type
));
739 mips_register_convert_to_raw (struct type
*virtual_type
, int n
,
740 const char *virt_buf
, char *raw_buf
)
742 memset (raw_buf
, 0, REGISTER_RAW_SIZE (n
));
743 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
744 memcpy (raw_buf
+ (REGISTER_RAW_SIZE (n
) - TYPE_LENGTH (virtual_type
)),
746 TYPE_LENGTH (virtual_type
));
750 TYPE_LENGTH (virtual_type
));
754 mips_convert_register_p (int regnum
, struct type
*type
)
756 return (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
757 && REGISTER_RAW_SIZE (regnum
) == 4
758 && (regnum
) >= FP0_REGNUM
&& (regnum
) < FP0_REGNUM
+ 32
759 && TYPE_CODE(type
) == TYPE_CODE_FLT
760 && TYPE_LENGTH(type
) == 8);
764 mips_register_to_value (struct frame_info
*frame
, int regnum
,
765 struct type
*type
, void *to
)
767 frame_read_register (frame
, regnum
+ 0, (char *) to
+ 4);
768 frame_read_register (frame
, regnum
+ 1, (char *) to
+ 0);
772 mips_value_to_register (struct frame_info
*frame
, int regnum
,
773 struct type
*type
, const void *from
)
775 put_frame_register (frame
, regnum
+ 0, (const char *) from
+ 4);
776 put_frame_register (frame
, regnum
+ 1, (const char *) from
+ 0);
779 /* Return the GDB type object for the "standard" data type of data in
783 mips_register_type (struct gdbarch
*gdbarch
, int regnum
)
785 /* For moment, map [NUM_REGS .. 2*NUM_REGS) onto the same raw
786 registers. Even return the same type. */
787 int rawnum
= regnum
% NUM_REGS
;
788 gdb_assert (rawnum
>= 0 && rawnum
< NUM_REGS
);
789 #ifdef MIPS_REGISTER_TYPE
790 return MIPS_REGISTER_TYPE (rawnum
);
792 if (FP0_REGNUM
<= rawnum
&& rawnum
< FP0_REGNUM
+ 32)
794 /* Floating point registers... */
795 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
796 return builtin_type_ieee_double_big
;
798 return builtin_type_ieee_double_little
;
800 else if (rawnum
== PS_REGNUM
/* CR */)
801 return builtin_type_uint32
;
802 else if (FCRCS_REGNUM
<= rawnum
&& rawnum
<= LAST_EMBED_REGNUM
)
803 return builtin_type_uint32
;
806 /* Everything else...
807 Return type appropriate for width of register. */
808 if (MIPS_REGSIZE
== TYPE_LENGTH (builtin_type_uint64
))
809 return builtin_type_uint64
;
811 return builtin_type_uint32
;
816 /* TARGET_READ_SP -- Remove useless bits from the stack pointer. */
821 return read_signed_register (SP_REGNUM
);
824 /* Should the upper word of 64-bit addresses be zeroed? */
825 enum auto_boolean mask_address_var
= AUTO_BOOLEAN_AUTO
;
828 mips_mask_address_p (void)
830 switch (mask_address_var
)
832 case AUTO_BOOLEAN_TRUE
:
834 case AUTO_BOOLEAN_FALSE
:
837 case AUTO_BOOLEAN_AUTO
:
838 return MIPS_DEFAULT_MASK_ADDRESS_P
;
840 internal_error (__FILE__
, __LINE__
,
841 "mips_mask_address_p: bad switch");
847 show_mask_address (char *cmd
, int from_tty
, struct cmd_list_element
*c
)
849 switch (mask_address_var
)
851 case AUTO_BOOLEAN_TRUE
:
852 printf_filtered ("The 32 bit mips address mask is enabled\n");
854 case AUTO_BOOLEAN_FALSE
:
855 printf_filtered ("The 32 bit mips address mask is disabled\n");
857 case AUTO_BOOLEAN_AUTO
:
858 printf_filtered ("The 32 bit address mask is set automatically. Currently %s\n",
859 mips_mask_address_p () ? "enabled" : "disabled");
862 internal_error (__FILE__
, __LINE__
,
863 "show_mask_address: bad switch");
868 /* Should call_function allocate stack space for a struct return? */
871 mips_eabi_use_struct_convention (int gcc_p
, struct type
*type
)
873 return (TYPE_LENGTH (type
) > 2 * MIPS_SAVED_REGSIZE
);
877 mips_n32n64_use_struct_convention (int gcc_p
, struct type
*type
)
879 return (TYPE_LENGTH (type
) > 2 * MIPS_SAVED_REGSIZE
);
882 /* Should call_function pass struct by reference?
883 For each architecture, structs are passed either by
884 value or by reference, depending on their size. */
887 mips_eabi_reg_struct_has_addr (int gcc_p
, struct type
*type
)
889 enum type_code typecode
= TYPE_CODE (check_typedef (type
));
890 int len
= TYPE_LENGTH (check_typedef (type
));
892 if (typecode
== TYPE_CODE_STRUCT
|| typecode
== TYPE_CODE_UNION
)
893 return (len
> MIPS_SAVED_REGSIZE
);
899 mips_n32n64_reg_struct_has_addr (int gcc_p
, struct type
*type
)
901 return 0; /* Assumption: N32/N64 never passes struct by ref. */
905 mips_o32_reg_struct_has_addr (int gcc_p
, struct type
*type
)
907 return 0; /* Assumption: O32/O64 never passes struct by ref. */
910 /* Tell if the program counter value in MEMADDR is in a MIPS16 function. */
913 pc_is_mips16 (bfd_vma memaddr
)
915 struct minimal_symbol
*sym
;
917 /* If bit 0 of the address is set, assume this is a MIPS16 address. */
918 if (is_mips16_addr (memaddr
))
921 /* A flag indicating that this is a MIPS16 function is stored by elfread.c in
922 the high bit of the info field. Use this to decide if the function is
923 MIPS16 or normal MIPS. */
924 sym
= lookup_minimal_symbol_by_pc (memaddr
);
926 return msymbol_is_special (sym
);
931 /* MIPS believes that the PC has a sign extended value. Perhaphs the
932 all registers should be sign extended for simplicity? */
935 mips_read_pc (ptid_t ptid
)
937 return read_signed_register_pid (PC_REGNUM
, ptid
);
940 /* This returns the PC of the first inst after the prologue. If we can't
941 find the prologue, then return 0. */
944 after_prologue (CORE_ADDR pc
,
945 mips_extra_func_info_t proc_desc
)
947 struct symtab_and_line sal
;
948 CORE_ADDR func_addr
, func_end
;
950 /* Pass cur_frame == 0 to find_proc_desc. We should not attempt
951 to read the stack pointer from the current machine state, because
952 the current machine state has nothing to do with the information
953 we need from the proc_desc; and the process may or may not exist
956 proc_desc
= find_proc_desc (pc
, NULL
, 0);
960 /* If function is frameless, then we need to do it the hard way. I
961 strongly suspect that frameless always means prologueless... */
962 if (PROC_FRAME_REG (proc_desc
) == SP_REGNUM
963 && PROC_FRAME_OFFSET (proc_desc
) == 0)
967 if (!find_pc_partial_function (pc
, NULL
, &func_addr
, &func_end
))
968 return 0; /* Unknown */
970 sal
= find_pc_line (func_addr
, 0);
972 if (sal
.end
< func_end
)
975 /* The line after the prologue is after the end of the function. In this
976 case, tell the caller to find the prologue the hard way. */
981 /* Decode a MIPS32 instruction that saves a register in the stack, and
982 set the appropriate bit in the general register mask or float register mask
983 to indicate which register is saved. This is a helper function
984 for mips_find_saved_regs. */
987 mips32_decode_reg_save (t_inst inst
, unsigned long *gen_mask
,
988 unsigned long *float_mask
)
992 if ((inst
& 0xffe00000) == 0xafa00000 /* sw reg,n($sp) */
993 || (inst
& 0xffe00000) == 0xafc00000 /* sw reg,n($r30) */
994 || (inst
& 0xffe00000) == 0xffa00000) /* sd reg,n($sp) */
996 /* It might be possible to use the instruction to
997 find the offset, rather than the code below which
998 is based on things being in a certain order in the
999 frame, but figuring out what the instruction's offset
1000 is relative to might be a little tricky. */
1001 reg
= (inst
& 0x001f0000) >> 16;
1002 *gen_mask
|= (1 << reg
);
1004 else if ((inst
& 0xffe00000) == 0xe7a00000 /* swc1 freg,n($sp) */
1005 || (inst
& 0xffe00000) == 0xe7c00000 /* swc1 freg,n($r30) */
1006 || (inst
& 0xffe00000) == 0xf7a00000) /* sdc1 freg,n($sp) */
1009 reg
= ((inst
& 0x001f0000) >> 16);
1010 *float_mask
|= (1 << reg
);
1014 /* Decode a MIPS16 instruction that saves a register in the stack, and
1015 set the appropriate bit in the general register or float register mask
1016 to indicate which register is saved. This is a helper function
1017 for mips_find_saved_regs. */
1020 mips16_decode_reg_save (t_inst inst
, unsigned long *gen_mask
)
1022 if ((inst
& 0xf800) == 0xd000) /* sw reg,n($sp) */
1024 int reg
= mips16_to_32_reg
[(inst
& 0x700) >> 8];
1025 *gen_mask
|= (1 << reg
);
1027 else if ((inst
& 0xff00) == 0xf900) /* sd reg,n($sp) */
1029 int reg
= mips16_to_32_reg
[(inst
& 0xe0) >> 5];
1030 *gen_mask
|= (1 << reg
);
1032 else if ((inst
& 0xff00) == 0x6200 /* sw $ra,n($sp) */
1033 || (inst
& 0xff00) == 0xfa00) /* sd $ra,n($sp) */
1034 *gen_mask
|= (1 << RA_REGNUM
);
1038 /* Fetch and return instruction from the specified location. If the PC
1039 is odd, assume it's a MIPS16 instruction; otherwise MIPS32. */
1042 mips_fetch_instruction (CORE_ADDR addr
)
1044 char buf
[MIPS_INSTLEN
];
1048 if (pc_is_mips16 (addr
))
1050 instlen
= MIPS16_INSTLEN
;
1051 addr
= unmake_mips16_addr (addr
);
1054 instlen
= MIPS_INSTLEN
;
1055 status
= read_memory_nobpt (addr
, buf
, instlen
);
1057 memory_error (status
, addr
);
1058 return extract_unsigned_integer (buf
, instlen
);
1062 /* These the fields of 32 bit mips instructions */
1063 #define mips32_op(x) (x >> 26)
1064 #define itype_op(x) (x >> 26)
1065 #define itype_rs(x) ((x >> 21) & 0x1f)
1066 #define itype_rt(x) ((x >> 16) & 0x1f)
1067 #define itype_immediate(x) (x & 0xffff)
1069 #define jtype_op(x) (x >> 26)
1070 #define jtype_target(x) (x & 0x03ffffff)
1072 #define rtype_op(x) (x >> 26)
1073 #define rtype_rs(x) ((x >> 21) & 0x1f)
1074 #define rtype_rt(x) ((x >> 16) & 0x1f)
1075 #define rtype_rd(x) ((x >> 11) & 0x1f)
1076 #define rtype_shamt(x) ((x >> 6) & 0x1f)
1077 #define rtype_funct(x) (x & 0x3f)
1080 mips32_relative_offset (unsigned long inst
)
1083 x
= itype_immediate (inst
);
1084 if (x
& 0x8000) /* sign bit set */
1086 x
|= 0xffff0000; /* sign extension */
1092 /* Determine whate to set a single step breakpoint while considering
1093 branch prediction */
1095 mips32_next_pc (CORE_ADDR pc
)
1099 inst
= mips_fetch_instruction (pc
);
1100 if ((inst
& 0xe0000000) != 0) /* Not a special, jump or branch instruction */
1102 if (itype_op (inst
) >> 2 == 5)
1103 /* BEQL, BNEL, BLEZL, BGTZL: bits 0101xx */
1105 op
= (itype_op (inst
) & 0x03);
1115 goto greater_branch
;
1120 else if (itype_op (inst
) == 17 && itype_rs (inst
) == 8)
1121 /* BC1F, BC1FL, BC1T, BC1TL: 010001 01000 */
1123 int tf
= itype_rt (inst
) & 0x01;
1124 int cnum
= itype_rt (inst
) >> 2;
1125 int fcrcs
= read_signed_register (FCRCS_REGNUM
);
1126 int cond
= ((fcrcs
>> 24) & 0x0e) | ((fcrcs
>> 23) & 0x01);
1128 if (((cond
>> cnum
) & 0x01) == tf
)
1129 pc
+= mips32_relative_offset (inst
) + 4;
1134 pc
+= 4; /* Not a branch, next instruction is easy */
1137 { /* This gets way messy */
1139 /* Further subdivide into SPECIAL, REGIMM and other */
1140 switch (op
= itype_op (inst
) & 0x07) /* extract bits 28,27,26 */
1142 case 0: /* SPECIAL */
1143 op
= rtype_funct (inst
);
1148 /* Set PC to that address */
1149 pc
= read_signed_register (rtype_rs (inst
));
1155 break; /* end SPECIAL */
1156 case 1: /* REGIMM */
1158 op
= itype_rt (inst
); /* branch condition */
1163 case 16: /* BLTZAL */
1164 case 18: /* BLTZALL */
1166 if (read_signed_register (itype_rs (inst
)) < 0)
1167 pc
+= mips32_relative_offset (inst
) + 4;
1169 pc
+= 8; /* after the delay slot */
1173 case 17: /* BGEZAL */
1174 case 19: /* BGEZALL */
1175 greater_equal_branch
:
1176 if (read_signed_register (itype_rs (inst
)) >= 0)
1177 pc
+= mips32_relative_offset (inst
) + 4;
1179 pc
+= 8; /* after the delay slot */
1181 /* All of the other instructions in the REGIMM category */
1186 break; /* end REGIMM */
1191 reg
= jtype_target (inst
) << 2;
1192 /* Upper four bits get never changed... */
1193 pc
= reg
+ ((pc
+ 4) & 0xf0000000);
1196 /* FIXME case JALX : */
1199 reg
= jtype_target (inst
) << 2;
1200 pc
= reg
+ ((pc
+ 4) & 0xf0000000) + 1; /* yes, +1 */
1201 /* Add 1 to indicate 16 bit mode - Invert ISA mode */
1203 break; /* The new PC will be alternate mode */
1204 case 4: /* BEQ, BEQL */
1206 if (read_signed_register (itype_rs (inst
)) ==
1207 read_signed_register (itype_rt (inst
)))
1208 pc
+= mips32_relative_offset (inst
) + 4;
1212 case 5: /* BNE, BNEL */
1214 if (read_signed_register (itype_rs (inst
)) !=
1215 read_signed_register (itype_rt (inst
)))
1216 pc
+= mips32_relative_offset (inst
) + 4;
1220 case 6: /* BLEZ, BLEZL */
1222 if (read_signed_register (itype_rs (inst
) <= 0))
1223 pc
+= mips32_relative_offset (inst
) + 4;
1229 greater_branch
: /* BGTZ, BGTZL */
1230 if (read_signed_register (itype_rs (inst
) > 0))
1231 pc
+= mips32_relative_offset (inst
) + 4;
1238 } /* mips32_next_pc */
1240 /* Decoding the next place to set a breakpoint is irregular for the
1241 mips 16 variant, but fortunately, there fewer instructions. We have to cope
1242 ith extensions for 16 bit instructions and a pair of actual 32 bit instructions.
1243 We dont want to set a single step instruction on the extend instruction
1247 /* Lots of mips16 instruction formats */
1248 /* Predicting jumps requires itype,ritype,i8type
1249 and their extensions extItype,extritype,extI8type
1251 enum mips16_inst_fmts
1253 itype
, /* 0 immediate 5,10 */
1254 ritype
, /* 1 5,3,8 */
1255 rrtype
, /* 2 5,3,3,5 */
1256 rritype
, /* 3 5,3,3,5 */
1257 rrrtype
, /* 4 5,3,3,3,2 */
1258 rriatype
, /* 5 5,3,3,1,4 */
1259 shifttype
, /* 6 5,3,3,3,2 */
1260 i8type
, /* 7 5,3,8 */
1261 i8movtype
, /* 8 5,3,3,5 */
1262 i8mov32rtype
, /* 9 5,3,5,3 */
1263 i64type
, /* 10 5,3,8 */
1264 ri64type
, /* 11 5,3,3,5 */
1265 jalxtype
, /* 12 5,1,5,5,16 - a 32 bit instruction */
1266 exiItype
, /* 13 5,6,5,5,1,1,1,1,1,1,5 */
1267 extRitype
, /* 14 5,6,5,5,3,1,1,1,5 */
1268 extRRItype
, /* 15 5,5,5,5,3,3,5 */
1269 extRRIAtype
, /* 16 5,7,4,5,3,3,1,4 */
1270 EXTshifttype
, /* 17 5,5,1,1,1,1,1,1,5,3,3,1,1,1,2 */
1271 extI8type
, /* 18 5,6,5,5,3,1,1,1,5 */
1272 extI64type
, /* 19 5,6,5,5,3,1,1,1,5 */
1273 extRi64type
, /* 20 5,6,5,5,3,3,5 */
1274 extshift64type
/* 21 5,5,1,1,1,1,1,1,5,1,1,1,3,5 */
1276 /* I am heaping all the fields of the formats into one structure and
1277 then, only the fields which are involved in instruction extension */
1281 unsigned int regx
; /* Function in i8 type */
1286 /* The EXT-I, EXT-ri nad EXT-I8 instructions all have the same format
1287 for the bits which make up the immediatate extension. */
1290 extended_offset (unsigned int extension
)
1293 value
= (extension
>> 21) & 0x3f; /* * extract 15:11 */
1295 value
|= (extension
>> 16) & 0x1f; /* extrace 10:5 */
1297 value
|= extension
& 0x01f; /* extract 4:0 */
1301 /* Only call this function if you know that this is an extendable
1302 instruction, It wont malfunction, but why make excess remote memory references?
1303 If the immediate operands get sign extended or somthing, do it after
1304 the extension is performed.
1306 /* FIXME: Every one of these cases needs to worry about sign extension
1307 when the offset is to be used in relative addressing */
1311 fetch_mips_16 (CORE_ADDR pc
)
1314 pc
&= 0xfffffffe; /* clear the low order bit */
1315 target_read_memory (pc
, buf
, 2);
1316 return extract_unsigned_integer (buf
, 2);
1320 unpack_mips16 (CORE_ADDR pc
,
1321 unsigned int extension
,
1323 enum mips16_inst_fmts insn_format
,
1324 struct upk_mips16
*upk
)
1329 switch (insn_format
)
1336 value
= extended_offset (extension
);
1337 value
= value
<< 11; /* rom for the original value */
1338 value
|= inst
& 0x7ff; /* eleven bits from instruction */
1342 value
= inst
& 0x7ff;
1343 /* FIXME : Consider sign extension */
1352 { /* A register identifier and an offset */
1353 /* Most of the fields are the same as I type but the
1354 immediate value is of a different length */
1358 value
= extended_offset (extension
);
1359 value
= value
<< 8; /* from the original instruction */
1360 value
|= inst
& 0xff; /* eleven bits from instruction */
1361 regx
= (extension
>> 8) & 0x07; /* or i8 funct */
1362 if (value
& 0x4000) /* test the sign bit , bit 26 */
1364 value
&= ~0x3fff; /* remove the sign bit */
1370 value
= inst
& 0xff; /* 8 bits */
1371 regx
= (inst
>> 8) & 0x07; /* or i8 funct */
1372 /* FIXME: Do sign extension , this format needs it */
1373 if (value
& 0x80) /* THIS CONFUSES ME */
1375 value
&= 0xef; /* remove the sign bit */
1385 unsigned long value
;
1386 unsigned int nexthalf
;
1387 value
= ((inst
& 0x1f) << 5) | ((inst
>> 5) & 0x1f);
1388 value
= value
<< 16;
1389 nexthalf
= mips_fetch_instruction (pc
+ 2); /* low bit still set */
1397 internal_error (__FILE__
, __LINE__
,
1400 upk
->offset
= offset
;
1407 add_offset_16 (CORE_ADDR pc
, int offset
)
1409 return ((offset
<< 2) | ((pc
+ 2) & (0xf0000000)));
1413 extended_mips16_next_pc (CORE_ADDR pc
,
1414 unsigned int extension
,
1417 int op
= (insn
>> 11);
1420 case 2: /* Branch */
1423 struct upk_mips16 upk
;
1424 unpack_mips16 (pc
, extension
, insn
, itype
, &upk
);
1425 offset
= upk
.offset
;
1431 pc
+= (offset
<< 1) + 2;
1434 case 3: /* JAL , JALX - Watch out, these are 32 bit instruction */
1436 struct upk_mips16 upk
;
1437 unpack_mips16 (pc
, extension
, insn
, jalxtype
, &upk
);
1438 pc
= add_offset_16 (pc
, upk
.offset
);
1439 if ((insn
>> 10) & 0x01) /* Exchange mode */
1440 pc
= pc
& ~0x01; /* Clear low bit, indicate 32 bit mode */
1447 struct upk_mips16 upk
;
1449 unpack_mips16 (pc
, extension
, insn
, ritype
, &upk
);
1450 reg
= read_signed_register (upk
.regx
);
1452 pc
+= (upk
.offset
<< 1) + 2;
1459 struct upk_mips16 upk
;
1461 unpack_mips16 (pc
, extension
, insn
, ritype
, &upk
);
1462 reg
= read_signed_register (upk
.regx
);
1464 pc
+= (upk
.offset
<< 1) + 2;
1469 case 12: /* I8 Formats btez btnez */
1471 struct upk_mips16 upk
;
1473 unpack_mips16 (pc
, extension
, insn
, i8type
, &upk
);
1474 /* upk.regx contains the opcode */
1475 reg
= read_signed_register (24); /* Test register is 24 */
1476 if (((upk
.regx
== 0) && (reg
== 0)) /* BTEZ */
1477 || ((upk
.regx
== 1) && (reg
!= 0))) /* BTNEZ */
1478 /* pc = add_offset_16(pc,upk.offset) ; */
1479 pc
+= (upk
.offset
<< 1) + 2;
1484 case 29: /* RR Formats JR, JALR, JALR-RA */
1486 struct upk_mips16 upk
;
1487 /* upk.fmt = rrtype; */
1492 upk
.regx
= (insn
>> 8) & 0x07;
1493 upk
.regy
= (insn
>> 5) & 0x07;
1501 break; /* Function return instruction */
1507 break; /* BOGUS Guess */
1509 pc
= read_signed_register (reg
);
1516 /* This is an instruction extension. Fetch the real instruction
1517 (which follows the extension) and decode things based on
1521 pc
= extended_mips16_next_pc (pc
, insn
, fetch_mips_16 (pc
));
1534 mips16_next_pc (CORE_ADDR pc
)
1536 unsigned int insn
= fetch_mips_16 (pc
);
1537 return extended_mips16_next_pc (pc
, 0, insn
);
1540 /* The mips_next_pc function supports single_step when the remote
1541 target monitor or stub is not developed enough to do a single_step.
1542 It works by decoding the current instruction and predicting where a
1543 branch will go. This isnt hard because all the data is available.
1544 The MIPS32 and MIPS16 variants are quite different */
1546 mips_next_pc (CORE_ADDR pc
)
1549 return mips16_next_pc (pc
);
1551 return mips32_next_pc (pc
);
1554 /* Set up the 'saved_regs' array. This is a data structure containing
1555 the addresses on the stack where each register has been saved, for
1556 each stack frame. Registers that have not been saved will have
1557 zero here. The stack pointer register is special: rather than the
1558 address where the stack register has been saved,
1559 saved_regs[SP_REGNUM] will have the actual value of the previous
1560 frame's stack register. */
1563 mips_find_saved_regs (struct frame_info
*fci
)
1566 /* r0 bit means kernel trap */
1568 /* What registers have been saved? Bitmasks. */
1569 unsigned long gen_mask
, float_mask
;
1570 mips_extra_func_info_t proc_desc
;
1572 CORE_ADDR
*saved_regs
;
1574 if (get_frame_saved_regs (fci
) != NULL
)
1576 saved_regs
= frame_saved_regs_zalloc (fci
);
1578 /* If it is the frame for sigtramp, the saved registers are located
1579 in a sigcontext structure somewhere on the stack. If the stack
1580 layout for sigtramp changes we might have to change these
1581 constants and the companion fixup_sigtramp in mdebugread.c */
1582 #ifndef SIGFRAME_BASE
1583 /* To satisfy alignment restrictions, sigcontext is located 4 bytes
1584 above the sigtramp frame. */
1585 #define SIGFRAME_BASE MIPS_REGSIZE
1586 /* FIXME! Are these correct?? */
1587 #define SIGFRAME_PC_OFF (SIGFRAME_BASE + 2 * MIPS_REGSIZE)
1588 #define SIGFRAME_REGSAVE_OFF (SIGFRAME_BASE + 3 * MIPS_REGSIZE)
1589 #define SIGFRAME_FPREGSAVE_OFF \
1590 (SIGFRAME_REGSAVE_OFF + MIPS_NUMREGS * MIPS_REGSIZE + 3 * MIPS_REGSIZE)
1592 #ifndef SIGFRAME_REG_SIZE
1593 /* FIXME! Is this correct?? */
1594 #define SIGFRAME_REG_SIZE MIPS_REGSIZE
1596 if ((get_frame_type (fci
) == SIGTRAMP_FRAME
))
1598 for (ireg
= 0; ireg
< MIPS_NUMREGS
; ireg
++)
1600 CORE_ADDR reg_position
= (get_frame_base (fci
) + SIGFRAME_REGSAVE_OFF
1601 + ireg
* SIGFRAME_REG_SIZE
);
1602 set_reg_offset (saved_regs
, ireg
, reg_position
);
1604 for (ireg
= 0; ireg
< MIPS_NUMREGS
; ireg
++)
1606 CORE_ADDR reg_position
= (get_frame_base (fci
)
1607 + SIGFRAME_FPREGSAVE_OFF
1608 + ireg
* SIGFRAME_REG_SIZE
);
1609 set_reg_offset (saved_regs
, FP0_REGNUM
+ ireg
, reg_position
);
1612 set_reg_offset (saved_regs
, PC_REGNUM
, get_frame_base (fci
) + SIGFRAME_PC_OFF
);
1613 /* SP_REGNUM, contains the value and not the address. */
1614 set_reg_offset (saved_regs
, SP_REGNUM
, get_frame_base (fci
));
1618 proc_desc
= get_frame_extra_info (fci
)->proc_desc
;
1619 if (proc_desc
== NULL
)
1620 /* I'm not sure how/whether this can happen. Normally when we
1621 can't find a proc_desc, we "synthesize" one using
1622 heuristic_proc_desc and set the saved_regs right away. */
1625 kernel_trap
= PROC_REG_MASK (proc_desc
) & 1;
1626 gen_mask
= kernel_trap
? 0xFFFFFFFF : PROC_REG_MASK (proc_desc
);
1627 float_mask
= kernel_trap
? 0xFFFFFFFF : PROC_FREG_MASK (proc_desc
);
1629 if (/* In any frame other than the innermost or a frame interrupted
1630 by a signal, we assume that all registers have been saved.
1631 This assumes that all register saves in a function happen
1632 before the first function call. */
1633 (get_next_frame (fci
) == NULL
1634 || (get_frame_type (get_next_frame (fci
)) == SIGTRAMP_FRAME
))
1636 /* In a dummy frame we know exactly where things are saved. */
1637 && !PROC_DESC_IS_DUMMY (proc_desc
)
1639 /* Don't bother unless we are inside a function prologue.
1640 Outside the prologue, we know where everything is. */
1642 && in_prologue (get_frame_pc (fci
), PROC_LOW_ADDR (proc_desc
))
1644 /* Not sure exactly what kernel_trap means, but if it means the
1645 kernel saves the registers without a prologue doing it, we
1646 better not examine the prologue to see whether registers
1647 have been saved yet. */
1650 /* We need to figure out whether the registers that the
1651 proc_desc claims are saved have been saved yet. */
1655 /* Bitmasks; set if we have found a save for the register. */
1656 unsigned long gen_save_found
= 0;
1657 unsigned long float_save_found
= 0;
1660 /* If the address is odd, assume this is MIPS16 code. */
1661 addr
= PROC_LOW_ADDR (proc_desc
);
1662 instlen
= pc_is_mips16 (addr
) ? MIPS16_INSTLEN
: MIPS_INSTLEN
;
1664 /* Scan through this function's instructions preceding the
1665 current PC, and look for those that save registers. */
1666 while (addr
< get_frame_pc (fci
))
1668 inst
= mips_fetch_instruction (addr
);
1669 if (pc_is_mips16 (addr
))
1670 mips16_decode_reg_save (inst
, &gen_save_found
);
1672 mips32_decode_reg_save (inst
, &gen_save_found
, &float_save_found
);
1675 gen_mask
= gen_save_found
;
1676 float_mask
= float_save_found
;
1679 /* Fill in the offsets for the registers which gen_mask says were
1682 CORE_ADDR reg_position
= (get_frame_base (fci
)
1683 + PROC_REG_OFFSET (proc_desc
));
1684 for (ireg
= MIPS_NUMREGS
- 1; gen_mask
; --ireg
, gen_mask
<<= 1)
1685 if (gen_mask
& 0x80000000)
1687 set_reg_offset (saved_regs
, ireg
, reg_position
);
1688 reg_position
-= MIPS_SAVED_REGSIZE
;
1692 /* The MIPS16 entry instruction saves $s0 and $s1 in the reverse
1693 order of that normally used by gcc. Therefore, we have to fetch
1694 the first instruction of the function, and if it's an entry
1695 instruction that saves $s0 or $s1, correct their saved addresses. */
1696 if (pc_is_mips16 (PROC_LOW_ADDR (proc_desc
)))
1698 inst
= mips_fetch_instruction (PROC_LOW_ADDR (proc_desc
));
1699 if ((inst
& 0xf81f) == 0xe809 && (inst
& 0x700) != 0x700)
1703 int sreg_count
= (inst
>> 6) & 3;
1705 /* Check if the ra register was pushed on the stack. */
1706 CORE_ADDR reg_position
= (get_frame_base (fci
)
1707 + PROC_REG_OFFSET (proc_desc
));
1709 reg_position
-= MIPS_SAVED_REGSIZE
;
1711 /* Check if the s0 and s1 registers were pushed on the
1713 for (reg
= 16; reg
< sreg_count
+ 16; reg
++)
1715 set_reg_offset (saved_regs
, reg
, reg_position
);
1716 reg_position
-= MIPS_SAVED_REGSIZE
;
1721 /* Fill in the offsets for the registers which float_mask says were
1724 CORE_ADDR reg_position
= (get_frame_base (fci
)
1725 + PROC_FREG_OFFSET (proc_desc
));
1727 /* Fill in the offsets for the float registers which float_mask
1729 for (ireg
= MIPS_NUMREGS
- 1; float_mask
; --ireg
, float_mask
<<= 1)
1730 if (float_mask
& 0x80000000)
1732 if (MIPS_SAVED_REGSIZE
== 4 && TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
1734 /* On a big endian 32 bit ABI, floating point registers
1735 are paired to form doubles such that the most
1736 significant part is in $f[N+1] and the least
1737 significant in $f[N] vis: $f[N+1] ||| $f[N]. The
1738 registers are also spilled as a pair and stored as a
1741 When little-endian the least significant part is
1742 stored first leading to the memory order $f[N] and
1745 Unfortunatly, when big-endian the most significant
1746 part of the double is stored first, and the least
1747 significant is stored second. This leads to the
1748 registers being ordered in memory as firt $f[N+1] and
1751 For the big-endian case make certain that the
1752 addresses point at the correct (swapped) locations
1753 $f[N] and $f[N+1] pair (keep in mind that
1754 reg_position is decremented each time through the
1757 set_reg_offset (saved_regs
, FP0_REGNUM
+ ireg
,
1758 reg_position
- MIPS_SAVED_REGSIZE
);
1760 set_reg_offset (saved_regs
, FP0_REGNUM
+ ireg
,
1761 reg_position
+ MIPS_SAVED_REGSIZE
);
1764 set_reg_offset (saved_regs
, FP0_REGNUM
+ ireg
, reg_position
);
1765 reg_position
-= MIPS_SAVED_REGSIZE
;
1768 set_reg_offset (saved_regs
, PC_REGNUM
, saved_regs
[RA_REGNUM
]);
1771 /* SP_REGNUM, contains the value and not the address. */
1772 set_reg_offset (saved_regs
, SP_REGNUM
, get_frame_base (fci
));
1776 read_next_frame_reg (struct frame_info
*fi
, int regno
)
1778 /* Always a pseudo. */
1779 gdb_assert (regno
>= NUM_REGS
);
1783 regcache_cooked_read_signed (current_regcache
, regno
, &val
);
1786 else if ((regno
% NUM_REGS
) == SP_REGNUM
)
1787 /* The SP_REGNUM is special, its value is stored in saved_regs.
1788 In fact, it is so special that it can even only be fetched
1789 using a raw register number! Once this code as been converted
1790 to frame-unwind the problem goes away. */
1791 return frame_unwind_register_signed (fi
, regno
% NUM_REGS
);
1793 return frame_unwind_register_signed (fi
, regno
);
1797 /* mips_addr_bits_remove - remove useless address bits */
1800 mips_addr_bits_remove (CORE_ADDR addr
)
1802 if (GDB_TARGET_IS_MIPS64
)
1804 if (mips_mask_address_p () && (addr
>> 32 == (CORE_ADDR
) 0xffffffff))
1806 /* This hack is a work-around for existing boards using
1807 PMON, the simulator, and any other 64-bit targets that
1808 doesn't have true 64-bit addressing. On these targets,
1809 the upper 32 bits of addresses are ignored by the
1810 hardware. Thus, the PC or SP are likely to have been
1811 sign extended to all 1s by instruction sequences that
1812 load 32-bit addresses. For example, a typical piece of
1813 code that loads an address is this:
1814 lui $r2, <upper 16 bits>
1815 ori $r2, <lower 16 bits>
1816 But the lui sign-extends the value such that the upper 32
1817 bits may be all 1s. The workaround is simply to mask off
1818 these bits. In the future, gcc may be changed to support
1819 true 64-bit addressing, and this masking will have to be
1821 addr
&= (CORE_ADDR
) 0xffffffff;
1824 else if (mips_mask_address_p ())
1826 /* FIXME: This is wrong! mips_addr_bits_remove() shouldn't be
1827 masking off bits, instead, the actual target should be asking
1828 for the address to be converted to a valid pointer. */
1829 /* Even when GDB is configured for some 32-bit targets
1830 (e.g. mips-elf), BFD is configured to handle 64-bit targets,
1831 so CORE_ADDR is 64 bits. So we still have to mask off
1832 useless bits from addresses. */
1833 addr
&= (CORE_ADDR
) 0xffffffff;
1838 /* mips_software_single_step() is called just before we want to resume
1839 the inferior, if we want to single-step it but there is no hardware
1840 or kernel single-step support (MIPS on GNU/Linux for example). We find
1841 the target of the coming instruction and breakpoint it.
1843 single_step is also called just after the inferior stops. If we had
1844 set up a simulated single-step, we undo our damage. */
1847 mips_software_single_step (enum target_signal sig
, int insert_breakpoints_p
)
1849 static CORE_ADDR next_pc
;
1850 typedef char binsn_quantum
[BREAKPOINT_MAX
];
1851 static binsn_quantum break_mem
;
1854 if (insert_breakpoints_p
)
1856 pc
= read_register (PC_REGNUM
);
1857 next_pc
= mips_next_pc (pc
);
1859 target_insert_breakpoint (next_pc
, break_mem
);
1862 target_remove_breakpoint (next_pc
, break_mem
);
1866 mips_init_frame_pc_first (int fromleaf
, struct frame_info
*prev
)
1871 ? DEPRECATED_SAVED_PC_AFTER_CALL (get_next_frame (prev
))
1872 : get_next_frame (prev
)
1873 ? DEPRECATED_FRAME_SAVED_PC (get_next_frame (prev
))
1875 tmp
= SKIP_TRAMPOLINE_CODE (pc
);
1876 return tmp
? tmp
: pc
;
1881 mips_frame_saved_pc (struct frame_info
*frame
)
1885 if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (frame
), 0, 0))
1888 /* Always unwind the cooked PC register value. */
1889 frame_unwind_signed_register (frame
, NUM_REGS
+ PC_REGNUM
, &tmp
);
1894 mips_extra_func_info_t proc_desc
1895 = get_frame_extra_info (frame
)->proc_desc
;
1896 if (proc_desc
&& PROC_DESC_IS_DUMMY (proc_desc
))
1897 saved_pc
= read_memory_integer (get_frame_base (frame
) - MIPS_SAVED_REGSIZE
, MIPS_SAVED_REGSIZE
);
1900 /* We have to get the saved pc from the sigcontext if it is
1901 a signal handler frame. */
1902 int pcreg
= (get_frame_type (frame
) == SIGTRAMP_FRAME
? PC_REGNUM
1903 : proc_desc
? PROC_PC_REG (proc_desc
) : RA_REGNUM
);
1904 saved_pc
= read_next_frame_reg (frame
, NUM_REGS
+ pcreg
);
1907 return ADDR_BITS_REMOVE (saved_pc
);
1910 static struct mips_extra_func_info temp_proc_desc
;
1912 /* This hack will go away once the get_prev_frame() code has been
1913 modified to set the frame's type first. That is BEFORE init extra
1914 frame info et.al. is called. This is because it will become
1915 possible to skip the init extra info call for sigtramp and dummy
1917 static CORE_ADDR
*temp_saved_regs
;
1919 /* Set a register's saved stack address in temp_saved_regs. If an
1920 address has already been set for this register, do nothing; this
1921 way we will only recognize the first save of a given register in a
1924 For simplicity, save the address in both [0 .. NUM_REGS) and
1925 [NUM_REGS .. 2*NUM_REGS). Strictly speaking, only the second range
1926 is used as it is only second range (the ABI instead of ISA
1927 registers) that comes into play when finding saved registers in a
1931 set_reg_offset (CORE_ADDR
*saved_regs
, int regno
, CORE_ADDR offset
)
1933 if (saved_regs
[regno
] == 0)
1935 saved_regs
[regno
+ 0 * NUM_REGS
] = offset
;
1936 saved_regs
[regno
+ 1 * NUM_REGS
] = offset
;
1941 /* Test whether the PC points to the return instruction at the
1942 end of a function. */
1945 mips_about_to_return (CORE_ADDR pc
)
1947 if (pc_is_mips16 (pc
))
1948 /* This mips16 case isn't necessarily reliable. Sometimes the compiler
1949 generates a "jr $ra"; other times it generates code to load
1950 the return address from the stack to an accessible register (such
1951 as $a3), then a "jr" using that register. This second case
1952 is almost impossible to distinguish from an indirect jump
1953 used for switch statements, so we don't even try. */
1954 return mips_fetch_instruction (pc
) == 0xe820; /* jr $ra */
1956 return mips_fetch_instruction (pc
) == 0x3e00008; /* jr $ra */
1960 /* This fencepost looks highly suspicious to me. Removing it also
1961 seems suspicious as it could affect remote debugging across serial
1965 heuristic_proc_start (CORE_ADDR pc
)
1972 pc
= ADDR_BITS_REMOVE (pc
);
1974 fence
= start_pc
- heuristic_fence_post
;
1978 if (heuristic_fence_post
== UINT_MAX
1979 || fence
< VM_MIN_ADDRESS
)
1980 fence
= VM_MIN_ADDRESS
;
1982 instlen
= pc_is_mips16 (pc
) ? MIPS16_INSTLEN
: MIPS_INSTLEN
;
1984 /* search back for previous return */
1985 for (start_pc
-= instlen
;; start_pc
-= instlen
)
1986 if (start_pc
< fence
)
1988 /* It's not clear to me why we reach this point when
1989 stop_soon, but with this test, at least we
1990 don't print out warnings for every child forked (eg, on
1991 decstation). 22apr93 rich@cygnus.com. */
1992 if (stop_soon
== NO_STOP_QUIETLY
)
1994 static int blurb_printed
= 0;
1996 warning ("Warning: GDB can't find the start of the function at 0x%s.",
2001 /* This actually happens frequently in embedded
2002 development, when you first connect to a board
2003 and your stack pointer and pc are nowhere in
2004 particular. This message needs to give people
2005 in that situation enough information to
2006 determine that it's no big deal. */
2007 printf_filtered ("\n\
2008 GDB is unable to find the start of the function at 0x%s\n\
2009 and thus can't determine the size of that function's stack frame.\n\
2010 This means that GDB may be unable to access that stack frame, or\n\
2011 the frames below it.\n\
2012 This problem is most likely caused by an invalid program counter or\n\
2014 However, if you think GDB should simply search farther back\n\
2015 from 0x%s for code which looks like the beginning of a\n\
2016 function, you can increase the range of the search using the `set\n\
2017 heuristic-fence-post' command.\n",
2018 paddr_nz (pc
), paddr_nz (pc
));
2025 else if (pc_is_mips16 (start_pc
))
2027 unsigned short inst
;
2029 /* On MIPS16, any one of the following is likely to be the
2030 start of a function:
2034 extend -n followed by 'addiu sp,+n' or 'daddiu sp,+n' */
2035 inst
= mips_fetch_instruction (start_pc
);
2036 if (((inst
& 0xf81f) == 0xe809 && (inst
& 0x700) != 0x700) /* entry */
2037 || (inst
& 0xff80) == 0x6380 /* addiu sp,-n */
2038 || (inst
& 0xff80) == 0xfb80 /* daddiu sp,-n */
2039 || ((inst
& 0xf810) == 0xf010 && seen_adjsp
)) /* extend -n */
2041 else if ((inst
& 0xff00) == 0x6300 /* addiu sp */
2042 || (inst
& 0xff00) == 0xfb00) /* daddiu sp */
2047 else if (mips_about_to_return (start_pc
))
2049 start_pc
+= 2 * MIPS_INSTLEN
; /* skip return, and its delay slot */
2056 /* Fetch the immediate value from a MIPS16 instruction.
2057 If the previous instruction was an EXTEND, use it to extend
2058 the upper bits of the immediate value. This is a helper function
2059 for mips16_heuristic_proc_desc. */
2062 mips16_get_imm (unsigned short prev_inst
, /* previous instruction */
2063 unsigned short inst
, /* current instruction */
2064 int nbits
, /* number of bits in imm field */
2065 int scale
, /* scale factor to be applied to imm */
2066 int is_signed
) /* is the imm field signed? */
2070 if ((prev_inst
& 0xf800) == 0xf000) /* prev instruction was EXTEND? */
2072 offset
= ((prev_inst
& 0x1f) << 11) | (prev_inst
& 0x7e0);
2073 if (offset
& 0x8000) /* check for negative extend */
2074 offset
= 0 - (0x10000 - (offset
& 0xffff));
2075 return offset
| (inst
& 0x1f);
2079 int max_imm
= 1 << nbits
;
2080 int mask
= max_imm
- 1;
2081 int sign_bit
= max_imm
>> 1;
2083 offset
= inst
& mask
;
2084 if (is_signed
&& (offset
& sign_bit
))
2085 offset
= 0 - (max_imm
- offset
);
2086 return offset
* scale
;
2091 /* Fill in values in temp_proc_desc based on the MIPS16 instruction
2092 stream from start_pc to limit_pc. */
2095 mips16_heuristic_proc_desc (CORE_ADDR start_pc
, CORE_ADDR limit_pc
,
2096 struct frame_info
*next_frame
, CORE_ADDR sp
)
2099 CORE_ADDR frame_addr
= 0; /* Value of $r17, used as frame pointer */
2100 unsigned short prev_inst
= 0; /* saved copy of previous instruction */
2101 unsigned inst
= 0; /* current instruction */
2102 unsigned entry_inst
= 0; /* the entry instruction */
2105 PROC_FRAME_OFFSET (&temp_proc_desc
) = 0; /* size of stack frame */
2106 PROC_FRAME_ADJUST (&temp_proc_desc
) = 0; /* offset of FP from SP */
2108 for (cur_pc
= start_pc
; cur_pc
< limit_pc
; cur_pc
+= MIPS16_INSTLEN
)
2110 /* Save the previous instruction. If it's an EXTEND, we'll extract
2111 the immediate offset extension from it in mips16_get_imm. */
2114 /* Fetch and decode the instruction. */
2115 inst
= (unsigned short) mips_fetch_instruction (cur_pc
);
2116 if ((inst
& 0xff00) == 0x6300 /* addiu sp */
2117 || (inst
& 0xff00) == 0xfb00) /* daddiu sp */
2119 offset
= mips16_get_imm (prev_inst
, inst
, 8, 8, 1);
2120 if (offset
< 0) /* negative stack adjustment? */
2121 PROC_FRAME_OFFSET (&temp_proc_desc
) -= offset
;
2123 /* Exit loop if a positive stack adjustment is found, which
2124 usually means that the stack cleanup code in the function
2125 epilogue is reached. */
2128 else if ((inst
& 0xf800) == 0xd000) /* sw reg,n($sp) */
2130 offset
= mips16_get_imm (prev_inst
, inst
, 8, 4, 0);
2131 reg
= mips16_to_32_reg
[(inst
& 0x700) >> 8];
2132 PROC_REG_MASK (&temp_proc_desc
) |= (1 << reg
);
2133 set_reg_offset (temp_saved_regs
, reg
, sp
+ offset
);
2135 else if ((inst
& 0xff00) == 0xf900) /* sd reg,n($sp) */
2137 offset
= mips16_get_imm (prev_inst
, inst
, 5, 8, 0);
2138 reg
= mips16_to_32_reg
[(inst
& 0xe0) >> 5];
2139 PROC_REG_MASK (&temp_proc_desc
) |= (1 << reg
);
2140 set_reg_offset (temp_saved_regs
, reg
, sp
+ offset
);
2142 else if ((inst
& 0xff00) == 0x6200) /* sw $ra,n($sp) */
2144 offset
= mips16_get_imm (prev_inst
, inst
, 8, 4, 0);
2145 PROC_REG_MASK (&temp_proc_desc
) |= (1 << RA_REGNUM
);
2146 set_reg_offset (temp_saved_regs
, RA_REGNUM
, sp
+ offset
);
2148 else if ((inst
& 0xff00) == 0xfa00) /* sd $ra,n($sp) */
2150 offset
= mips16_get_imm (prev_inst
, inst
, 8, 8, 0);
2151 PROC_REG_MASK (&temp_proc_desc
) |= (1 << RA_REGNUM
);
2152 set_reg_offset (temp_saved_regs
, RA_REGNUM
, sp
+ offset
);
2154 else if (inst
== 0x673d) /* move $s1, $sp */
2157 PROC_FRAME_REG (&temp_proc_desc
) = 17;
2159 else if ((inst
& 0xff00) == 0x0100) /* addiu $s1,sp,n */
2161 offset
= mips16_get_imm (prev_inst
, inst
, 8, 4, 0);
2162 frame_addr
= sp
+ offset
;
2163 PROC_FRAME_REG (&temp_proc_desc
) = 17;
2164 PROC_FRAME_ADJUST (&temp_proc_desc
) = offset
;
2166 else if ((inst
& 0xFF00) == 0xd900) /* sw reg,offset($s1) */
2168 offset
= mips16_get_imm (prev_inst
, inst
, 5, 4, 0);
2169 reg
= mips16_to_32_reg
[(inst
& 0xe0) >> 5];
2170 PROC_REG_MASK (&temp_proc_desc
) |= 1 << reg
;
2171 set_reg_offset (temp_saved_regs
, reg
, frame_addr
+ offset
);
2173 else if ((inst
& 0xFF00) == 0x7900) /* sd reg,offset($s1) */
2175 offset
= mips16_get_imm (prev_inst
, inst
, 5, 8, 0);
2176 reg
= mips16_to_32_reg
[(inst
& 0xe0) >> 5];
2177 PROC_REG_MASK (&temp_proc_desc
) |= 1 << reg
;
2178 set_reg_offset (temp_saved_regs
, reg
, frame_addr
+ offset
);
2180 else if ((inst
& 0xf81f) == 0xe809 && (inst
& 0x700) != 0x700) /* entry */
2181 entry_inst
= inst
; /* save for later processing */
2182 else if ((inst
& 0xf800) == 0x1800) /* jal(x) */
2183 cur_pc
+= MIPS16_INSTLEN
; /* 32-bit instruction */
2186 /* The entry instruction is typically the first instruction in a function,
2187 and it stores registers at offsets relative to the value of the old SP
2188 (before the prologue). But the value of the sp parameter to this
2189 function is the new SP (after the prologue has been executed). So we
2190 can't calculate those offsets until we've seen the entire prologue,
2191 and can calculate what the old SP must have been. */
2192 if (entry_inst
!= 0)
2194 int areg_count
= (entry_inst
>> 8) & 7;
2195 int sreg_count
= (entry_inst
>> 6) & 3;
2197 /* The entry instruction always subtracts 32 from the SP. */
2198 PROC_FRAME_OFFSET (&temp_proc_desc
) += 32;
2200 /* Now we can calculate what the SP must have been at the
2201 start of the function prologue. */
2202 sp
+= PROC_FRAME_OFFSET (&temp_proc_desc
);
2204 /* Check if a0-a3 were saved in the caller's argument save area. */
2205 for (reg
= 4, offset
= 0; reg
< areg_count
+ 4; reg
++)
2207 PROC_REG_MASK (&temp_proc_desc
) |= 1 << reg
;
2208 set_reg_offset (temp_saved_regs
, reg
, sp
+ offset
);
2209 offset
+= MIPS_SAVED_REGSIZE
;
2212 /* Check if the ra register was pushed on the stack. */
2214 if (entry_inst
& 0x20)
2216 PROC_REG_MASK (&temp_proc_desc
) |= 1 << RA_REGNUM
;
2217 set_reg_offset (temp_saved_regs
, RA_REGNUM
, sp
+ offset
);
2218 offset
-= MIPS_SAVED_REGSIZE
;
2221 /* Check if the s0 and s1 registers were pushed on the stack. */
2222 for (reg
= 16; reg
< sreg_count
+ 16; reg
++)
2224 PROC_REG_MASK (&temp_proc_desc
) |= 1 << reg
;
2225 set_reg_offset (temp_saved_regs
, reg
, sp
+ offset
);
2226 offset
-= MIPS_SAVED_REGSIZE
;
2232 mips32_heuristic_proc_desc (CORE_ADDR start_pc
, CORE_ADDR limit_pc
,
2233 struct frame_info
*next_frame
, CORE_ADDR sp
)
2236 CORE_ADDR frame_addr
= 0; /* Value of $r30. Used by gcc for frame-pointer */
2238 temp_saved_regs
= xrealloc (temp_saved_regs
, SIZEOF_FRAME_SAVED_REGS
);
2239 memset (temp_saved_regs
, '\0', SIZEOF_FRAME_SAVED_REGS
);
2240 PROC_FRAME_OFFSET (&temp_proc_desc
) = 0;
2241 PROC_FRAME_ADJUST (&temp_proc_desc
) = 0; /* offset of FP from SP */
2242 for (cur_pc
= start_pc
; cur_pc
< limit_pc
; cur_pc
+= MIPS_INSTLEN
)
2244 unsigned long inst
, high_word
, low_word
;
2247 /* Fetch the instruction. */
2248 inst
= (unsigned long) mips_fetch_instruction (cur_pc
);
2250 /* Save some code by pre-extracting some useful fields. */
2251 high_word
= (inst
>> 16) & 0xffff;
2252 low_word
= inst
& 0xffff;
2253 reg
= high_word
& 0x1f;
2255 if (high_word
== 0x27bd /* addiu $sp,$sp,-i */
2256 || high_word
== 0x23bd /* addi $sp,$sp,-i */
2257 || high_word
== 0x67bd) /* daddiu $sp,$sp,-i */
2259 if (low_word
& 0x8000) /* negative stack adjustment? */
2260 PROC_FRAME_OFFSET (&temp_proc_desc
) += 0x10000 - low_word
;
2262 /* Exit loop if a positive stack adjustment is found, which
2263 usually means that the stack cleanup code in the function
2264 epilogue is reached. */
2267 else if ((high_word
& 0xFFE0) == 0xafa0) /* sw reg,offset($sp) */
2269 PROC_REG_MASK (&temp_proc_desc
) |= 1 << reg
;
2270 set_reg_offset (temp_saved_regs
, reg
, sp
+ low_word
);
2272 else if ((high_word
& 0xFFE0) == 0xffa0) /* sd reg,offset($sp) */
2274 /* Irix 6.2 N32 ABI uses sd instructions for saving $gp and $ra,
2275 but the register size used is only 32 bits. Make the address
2276 for the saved register point to the lower 32 bits. */
2277 PROC_REG_MASK (&temp_proc_desc
) |= 1 << reg
;
2278 set_reg_offset (temp_saved_regs
, reg
, sp
+ low_word
+ 8 - MIPS_REGSIZE
);
2280 else if (high_word
== 0x27be) /* addiu $30,$sp,size */
2282 /* Old gcc frame, r30 is virtual frame pointer. */
2283 if ((long) low_word
!= PROC_FRAME_OFFSET (&temp_proc_desc
))
2284 frame_addr
= sp
+ low_word
;
2285 else if (PROC_FRAME_REG (&temp_proc_desc
) == SP_REGNUM
)
2287 unsigned alloca_adjust
;
2288 PROC_FRAME_REG (&temp_proc_desc
) = 30;
2289 frame_addr
= read_next_frame_reg (next_frame
, NUM_REGS
+ 30);
2290 alloca_adjust
= (unsigned) (frame_addr
- (sp
+ low_word
));
2291 if (alloca_adjust
> 0)
2293 /* FP > SP + frame_size. This may be because
2294 * of an alloca or somethings similar.
2295 * Fix sp to "pre-alloca" value, and try again.
2297 sp
+= alloca_adjust
;
2302 /* move $30,$sp. With different versions of gas this will be either
2303 `addu $30,$sp,$zero' or `or $30,$sp,$zero' or `daddu 30,sp,$0'.
2304 Accept any one of these. */
2305 else if (inst
== 0x03A0F021 || inst
== 0x03a0f025 || inst
== 0x03a0f02d)
2307 /* New gcc frame, virtual frame pointer is at r30 + frame_size. */
2308 if (PROC_FRAME_REG (&temp_proc_desc
) == SP_REGNUM
)
2310 unsigned alloca_adjust
;
2311 PROC_FRAME_REG (&temp_proc_desc
) = 30;
2312 frame_addr
= read_next_frame_reg (next_frame
, NUM_REGS
+ 30);
2313 alloca_adjust
= (unsigned) (frame_addr
- sp
);
2314 if (alloca_adjust
> 0)
2316 /* FP > SP + frame_size. This may be because
2317 * of an alloca or somethings similar.
2318 * Fix sp to "pre-alloca" value, and try again.
2320 sp
+= alloca_adjust
;
2325 else if ((high_word
& 0xFFE0) == 0xafc0) /* sw reg,offset($30) */
2327 PROC_REG_MASK (&temp_proc_desc
) |= 1 << reg
;
2328 set_reg_offset (temp_saved_regs
, reg
, frame_addr
+ low_word
);
2333 static mips_extra_func_info_t
2334 heuristic_proc_desc (CORE_ADDR start_pc
, CORE_ADDR limit_pc
,
2335 struct frame_info
*next_frame
, int cur_frame
)
2340 sp
= read_next_frame_reg (next_frame
, NUM_REGS
+ SP_REGNUM
);
2346 memset (&temp_proc_desc
, '\0', sizeof (temp_proc_desc
));
2347 temp_saved_regs
= xrealloc (temp_saved_regs
, SIZEOF_FRAME_SAVED_REGS
);
2348 memset (temp_saved_regs
, '\0', SIZEOF_FRAME_SAVED_REGS
);
2349 PROC_LOW_ADDR (&temp_proc_desc
) = start_pc
;
2350 PROC_FRAME_REG (&temp_proc_desc
) = SP_REGNUM
;
2351 PROC_PC_REG (&temp_proc_desc
) = RA_REGNUM
;
2353 if (start_pc
+ 200 < limit_pc
)
2354 limit_pc
= start_pc
+ 200;
2355 if (pc_is_mips16 (start_pc
))
2356 mips16_heuristic_proc_desc (start_pc
, limit_pc
, next_frame
, sp
);
2358 mips32_heuristic_proc_desc (start_pc
, limit_pc
, next_frame
, sp
);
2359 return &temp_proc_desc
;
2362 struct mips_objfile_private
2368 /* Global used to communicate between non_heuristic_proc_desc and
2369 compare_pdr_entries within qsort (). */
2370 static bfd
*the_bfd
;
2373 compare_pdr_entries (const void *a
, const void *b
)
2375 CORE_ADDR lhs
= bfd_get_32 (the_bfd
, (bfd_byte
*) a
);
2376 CORE_ADDR rhs
= bfd_get_32 (the_bfd
, (bfd_byte
*) b
);
2380 else if (lhs
== rhs
)
2386 static mips_extra_func_info_t
2387 non_heuristic_proc_desc (CORE_ADDR pc
, CORE_ADDR
*addrptr
)
2389 CORE_ADDR startaddr
;
2390 mips_extra_func_info_t proc_desc
;
2391 struct block
*b
= block_for_pc (pc
);
2393 struct obj_section
*sec
;
2394 struct mips_objfile_private
*priv
;
2396 if (DEPRECATED_PC_IN_CALL_DUMMY (pc
, 0, 0))
2399 find_pc_partial_function (pc
, NULL
, &startaddr
, NULL
);
2401 *addrptr
= startaddr
;
2405 sec
= find_pc_section (pc
);
2408 priv
= (struct mips_objfile_private
*) sec
->objfile
->obj_private
;
2410 /* Search the ".pdr" section generated by GAS. This includes most of
2411 the information normally found in ECOFF PDRs. */
2413 the_bfd
= sec
->objfile
->obfd
;
2415 && (the_bfd
->format
== bfd_object
2416 && bfd_get_flavour (the_bfd
) == bfd_target_elf_flavour
2417 && elf_elfheader (the_bfd
)->e_ident
[EI_CLASS
] == ELFCLASS64
))
2419 /* Right now GAS only outputs the address as a four-byte sequence.
2420 This means that we should not bother with this method on 64-bit
2421 targets (until that is fixed). */
2423 priv
= obstack_alloc (& sec
->objfile
->psymbol_obstack
,
2424 sizeof (struct mips_objfile_private
));
2426 sec
->objfile
->obj_private
= priv
;
2428 else if (priv
== NULL
)
2432 priv
= obstack_alloc (& sec
->objfile
->psymbol_obstack
,
2433 sizeof (struct mips_objfile_private
));
2435 bfdsec
= bfd_get_section_by_name (sec
->objfile
->obfd
, ".pdr");
2438 priv
->size
= bfd_section_size (sec
->objfile
->obfd
, bfdsec
);
2439 priv
->contents
= obstack_alloc (& sec
->objfile
->psymbol_obstack
,
2441 bfd_get_section_contents (sec
->objfile
->obfd
, bfdsec
,
2442 priv
->contents
, 0, priv
->size
);
2444 /* In general, the .pdr section is sorted. However, in the
2445 presence of multiple code sections (and other corner cases)
2446 it can become unsorted. Sort it so that we can use a faster
2448 qsort (priv
->contents
, priv
->size
/ 32, 32, compare_pdr_entries
);
2453 sec
->objfile
->obj_private
= priv
;
2457 if (priv
->size
!= 0)
2463 high
= priv
->size
/ 32;
2469 mid
= (low
+ high
) / 2;
2471 ptr
= priv
->contents
+ mid
* 32;
2472 pdr_pc
= bfd_get_signed_32 (sec
->objfile
->obfd
, ptr
);
2473 pdr_pc
+= ANOFFSET (sec
->objfile
->section_offsets
,
2474 SECT_OFF_TEXT (sec
->objfile
));
2475 if (pdr_pc
== startaddr
)
2477 if (pdr_pc
> startaddr
)
2482 while (low
!= high
);
2486 struct symbol
*sym
= find_pc_function (pc
);
2488 /* Fill in what we need of the proc_desc. */
2489 proc_desc
= (mips_extra_func_info_t
)
2490 obstack_alloc (&sec
->objfile
->psymbol_obstack
,
2491 sizeof (struct mips_extra_func_info
));
2492 PROC_LOW_ADDR (proc_desc
) = startaddr
;
2494 /* Only used for dummy frames. */
2495 PROC_HIGH_ADDR (proc_desc
) = 0;
2497 PROC_FRAME_OFFSET (proc_desc
)
2498 = bfd_get_32 (sec
->objfile
->obfd
, ptr
+ 20);
2499 PROC_FRAME_REG (proc_desc
) = bfd_get_32 (sec
->objfile
->obfd
,
2501 PROC_FRAME_ADJUST (proc_desc
) = 0;
2502 PROC_REG_MASK (proc_desc
) = bfd_get_32 (sec
->objfile
->obfd
,
2504 PROC_FREG_MASK (proc_desc
) = bfd_get_32 (sec
->objfile
->obfd
,
2506 PROC_REG_OFFSET (proc_desc
) = bfd_get_32 (sec
->objfile
->obfd
,
2508 PROC_FREG_OFFSET (proc_desc
)
2509 = bfd_get_32 (sec
->objfile
->obfd
, ptr
+ 16);
2510 PROC_PC_REG (proc_desc
) = bfd_get_32 (sec
->objfile
->obfd
,
2512 proc_desc
->pdr
.isym
= (long) sym
;
2522 if (startaddr
> BLOCK_START (b
))
2524 /* This is the "pathological" case referred to in a comment in
2525 print_frame_info. It might be better to move this check into
2530 sym
= lookup_symbol (MIPS_EFI_SYMBOL_NAME
, b
, LABEL_DOMAIN
, 0, NULL
);
2532 /* If we never found a PDR for this function in symbol reading, then
2533 examine prologues to find the information. */
2536 proc_desc
= (mips_extra_func_info_t
) SYMBOL_VALUE (sym
);
2537 if (PROC_FRAME_REG (proc_desc
) == -1)
2547 static mips_extra_func_info_t
2548 find_proc_desc (CORE_ADDR pc
, struct frame_info
*next_frame
, int cur_frame
)
2550 mips_extra_func_info_t proc_desc
;
2551 CORE_ADDR startaddr
= 0;
2553 proc_desc
= non_heuristic_proc_desc (pc
, &startaddr
);
2557 /* IF this is the topmost frame AND
2558 * (this proc does not have debugging information OR
2559 * the PC is in the procedure prologue)
2560 * THEN create a "heuristic" proc_desc (by analyzing
2561 * the actual code) to replace the "official" proc_desc.
2563 if (next_frame
== NULL
)
2565 struct symtab_and_line val
;
2566 struct symbol
*proc_symbol
=
2567 PROC_DESC_IS_DUMMY (proc_desc
) ? 0 : PROC_SYMBOL (proc_desc
);
2571 val
= find_pc_line (BLOCK_START
2572 (SYMBOL_BLOCK_VALUE (proc_symbol
)),
2574 val
.pc
= val
.end
? val
.end
: pc
;
2576 if (!proc_symbol
|| pc
< val
.pc
)
2578 mips_extra_func_info_t found_heuristic
=
2579 heuristic_proc_desc (PROC_LOW_ADDR (proc_desc
),
2580 pc
, next_frame
, cur_frame
);
2581 if (found_heuristic
)
2582 proc_desc
= found_heuristic
;
2588 /* Is linked_proc_desc_table really necessary? It only seems to be used
2589 by procedure call dummys. However, the procedures being called ought
2590 to have their own proc_descs, and even if they don't,
2591 heuristic_proc_desc knows how to create them! */
2593 register struct linked_proc_info
*link
;
2595 for (link
= linked_proc_desc_table
; link
; link
= link
->next
)
2596 if (PROC_LOW_ADDR (&link
->info
) <= pc
2597 && PROC_HIGH_ADDR (&link
->info
) > pc
)
2601 startaddr
= heuristic_proc_start (pc
);
2604 heuristic_proc_desc (startaddr
, pc
, next_frame
, cur_frame
);
2610 get_frame_pointer (struct frame_info
*frame
,
2611 mips_extra_func_info_t proc_desc
)
2613 return (read_next_frame_reg (frame
, NUM_REGS
+ PROC_FRAME_REG (proc_desc
))
2614 + PROC_FRAME_OFFSET (proc_desc
)
2615 - PROC_FRAME_ADJUST (proc_desc
));
2618 static mips_extra_func_info_t cached_proc_desc
;
2621 mips_frame_chain (struct frame_info
*frame
)
2623 mips_extra_func_info_t proc_desc
;
2625 CORE_ADDR saved_pc
= DEPRECATED_FRAME_SAVED_PC (frame
);
2627 if (saved_pc
== 0 || inside_entry_file (saved_pc
))
2630 /* Check if the PC is inside a call stub. If it is, fetch the
2631 PC of the caller of that stub. */
2632 if ((tmp
= SKIP_TRAMPOLINE_CODE (saved_pc
)) != 0)
2635 if (DEPRECATED_PC_IN_CALL_DUMMY (saved_pc
, 0, 0))
2637 /* A dummy frame, uses SP not FP. Get the old SP value. If all
2638 is well, frame->frame the bottom of the current frame will
2639 contain that value. */
2640 return get_frame_base (frame
);
2643 /* Look up the procedure descriptor for this PC. */
2644 proc_desc
= find_proc_desc (saved_pc
, frame
, 1);
2648 cached_proc_desc
= proc_desc
;
2650 /* If no frame pointer and frame size is zero, we must be at end
2651 of stack (or otherwise hosed). If we don't check frame size,
2652 we loop forever if we see a zero size frame. */
2653 if (PROC_FRAME_REG (proc_desc
) == SP_REGNUM
2654 && PROC_FRAME_OFFSET (proc_desc
) == 0
2655 /* The previous frame from a sigtramp frame might be frameless
2656 and have frame size zero. */
2657 && !(get_frame_type (frame
) == SIGTRAMP_FRAME
)
2658 /* For a generic dummy frame, let get_frame_pointer() unwind a
2659 register value saved as part of the dummy frame call. */
2660 && !(DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (frame
), 0, 0)))
2663 return get_frame_pointer (frame
, proc_desc
);
2667 mips_init_extra_frame_info (int fromleaf
, struct frame_info
*fci
)
2670 mips_extra_func_info_t proc_desc
;
2672 if (get_frame_type (fci
) == DUMMY_FRAME
)
2675 /* Use proc_desc calculated in frame_chain. When there is no
2676 next frame, i.e, get_next_frame (fci) == NULL, we call
2677 find_proc_desc () to calculate it, passing an explicit
2678 NULL as the frame parameter. */
2680 get_next_frame (fci
)
2682 : find_proc_desc (get_frame_pc (fci
),
2683 NULL
/* i.e, get_next_frame (fci) */,
2686 frame_extra_info_zalloc (fci
, sizeof (struct frame_extra_info
));
2688 deprecated_set_frame_saved_regs_hack (fci
, NULL
);
2689 get_frame_extra_info (fci
)->proc_desc
=
2690 proc_desc
== &temp_proc_desc
? 0 : proc_desc
;
2693 /* Fixup frame-pointer - only needed for top frame */
2694 /* This may not be quite right, if proc has a real frame register.
2695 Get the value of the frame relative sp, procedure might have been
2696 interrupted by a signal at it's very start. */
2697 if (get_frame_pc (fci
) == PROC_LOW_ADDR (proc_desc
)
2698 && !PROC_DESC_IS_DUMMY (proc_desc
))
2699 deprecated_update_frame_base_hack (fci
, read_next_frame_reg (get_next_frame (fci
), NUM_REGS
+ SP_REGNUM
));
2700 else if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fci
), 0, 0))
2701 /* Do not ``fix'' fci->frame. It will have the value of the
2702 generic dummy frame's top-of-stack (since the draft
2703 fci->frame is obtained by returning the unwound stack
2704 pointer) and that is what we want. That way the fci->frame
2705 value will match the top-of-stack value that was saved as
2706 part of the dummy frames data. */
2709 deprecated_update_frame_base_hack (fci
, get_frame_pointer (get_next_frame (fci
), proc_desc
));
2711 if (proc_desc
== &temp_proc_desc
)
2715 /* Do not set the saved registers for a sigtramp frame,
2716 mips_find_saved_registers will do that for us. We can't
2717 use (get_frame_type (fci) == SIGTRAMP_FRAME), it is not
2719 /* FIXME: cagney/2002-11-18: This problem will go away once
2720 frame.c:get_prev_frame() is modified to set the frame's
2721 type before calling functions like this. */
2722 find_pc_partial_function (get_frame_pc (fci
), &name
,
2723 (CORE_ADDR
*) NULL
, (CORE_ADDR
*) NULL
);
2724 if (!PC_IN_SIGTRAMP (get_frame_pc (fci
), name
))
2726 frame_saved_regs_zalloc (fci
);
2727 /* Set value of previous frame's stack pointer.
2728 Remember that saved_regs[SP_REGNUM] is special in
2729 that it contains the value of the stack pointer
2730 register. The other saved_regs values are addresses
2731 (in the inferior) at which a given register's value
2733 set_reg_offset (temp_saved_regs
, SP_REGNUM
,
2734 get_frame_base (fci
));
2735 set_reg_offset (temp_saved_regs
, PC_REGNUM
,
2736 temp_saved_regs
[RA_REGNUM
]);
2737 memcpy (get_frame_saved_regs (fci
), temp_saved_regs
,
2738 SIZEOF_FRAME_SAVED_REGS
);
2742 /* hack: if argument regs are saved, guess these contain args */
2743 /* assume we can't tell how many args for now */
2744 get_frame_extra_info (fci
)->num_args
= -1;
2745 for (regnum
= MIPS_LAST_ARG_REGNUM
; regnum
>= A0_REGNUM
; regnum
--)
2747 if (PROC_REG_MASK (proc_desc
) & (1 << regnum
))
2749 get_frame_extra_info (fci
)->num_args
= regnum
- A0_REGNUM
+ 1;
2756 /* MIPS stack frames are almost impenetrable. When execution stops,
2757 we basically have to look at symbol information for the function
2758 that we stopped in, which tells us *which* register (if any) is
2759 the base of the frame pointer, and what offset from that register
2760 the frame itself is at.
2762 This presents a problem when trying to examine a stack in memory
2763 (that isn't executing at the moment), using the "frame" command. We
2764 don't have a PC, nor do we have any registers except SP.
2766 This routine takes two arguments, SP and PC, and tries to make the
2767 cached frames look as if these two arguments defined a frame on the
2768 cache. This allows the rest of info frame to extract the important
2769 arguments without difficulty. */
2772 setup_arbitrary_frame (int argc
, CORE_ADDR
*argv
)
2775 error ("MIPS frame specifications require two arguments: sp and pc");
2777 return create_new_frame (argv
[0], argv
[1]);
2780 /* According to the current ABI, should the type be passed in a
2781 floating-point register (assuming that there is space)? When there
2782 is no FPU, FP are not even considered as possibile candidates for
2783 FP registers and, consequently this returns false - forces FP
2784 arguments into integer registers. */
2787 fp_register_arg_p (enum type_code typecode
, struct type
*arg_type
)
2789 return ((typecode
== TYPE_CODE_FLT
2791 && (typecode
== TYPE_CODE_STRUCT
|| typecode
== TYPE_CODE_UNION
)
2792 && TYPE_NFIELDS (arg_type
) == 1
2793 && TYPE_CODE (TYPE_FIELD_TYPE (arg_type
, 0)) == TYPE_CODE_FLT
))
2794 && MIPS_FPU_TYPE
!= MIPS_FPU_NONE
);
2797 /* On o32, argument passing in GPRs depends on the alignment of the type being
2798 passed. Return 1 if this type must be aligned to a doubleword boundary. */
2801 mips_type_needs_double_align (struct type
*type
)
2803 enum type_code typecode
= TYPE_CODE (type
);
2805 if (typecode
== TYPE_CODE_FLT
&& TYPE_LENGTH (type
) == 8)
2807 else if (typecode
== TYPE_CODE_STRUCT
)
2809 if (TYPE_NFIELDS (type
) < 1)
2811 return mips_type_needs_double_align (TYPE_FIELD_TYPE (type
, 0));
2813 else if (typecode
== TYPE_CODE_UNION
)
2817 n
= TYPE_NFIELDS (type
);
2818 for (i
= 0; i
< n
; i
++)
2819 if (mips_type_needs_double_align (TYPE_FIELD_TYPE (type
, i
)))
2826 /* Macros to round N up or down to the next A boundary;
2827 A must be a power of two. */
2829 #define ROUND_DOWN(n,a) ((n) & ~((a)-1))
2830 #define ROUND_UP(n,a) (((n)+(a)-1) & ~((a)-1))
2832 /* Adjust the address downward (direction of stack growth) so that it
2833 is correctly aligned for a new stack frame. */
2835 mips_frame_align (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
2837 return ROUND_DOWN (addr
, 16);
2841 mips_eabi_push_dummy_call (struct gdbarch
*gdbarch
, CORE_ADDR func_addr
,
2842 struct regcache
*regcache
, CORE_ADDR bp_addr
, int nargs
,
2843 struct value
**args
, CORE_ADDR sp
, int struct_return
,
2844 CORE_ADDR struct_addr
)
2850 int stack_offset
= 0;
2852 /* For shared libraries, "t9" needs to point at the function
2854 regcache_cooked_write_signed (regcache
, T9_REGNUM
, func_addr
);
2856 /* Set the return address register to point to the entry point of
2857 the program, where a breakpoint lies in wait. */
2858 regcache_cooked_write_signed (regcache
, RA_REGNUM
, bp_addr
);
2860 /* First ensure that the stack and structure return address (if any)
2861 are properly aligned. The stack has to be at least 64-bit
2862 aligned even on 32-bit machines, because doubles must be 64-bit
2863 aligned. For n32 and n64, stack frames need to be 128-bit
2864 aligned, so we round to this widest known alignment. */
2866 sp
= ROUND_DOWN (sp
, 16);
2867 struct_addr
= ROUND_DOWN (struct_addr
, 16);
2869 /* Now make space on the stack for the args. We allocate more
2870 than necessary for EABI, because the first few arguments are
2871 passed in registers, but that's OK. */
2872 for (argnum
= 0; argnum
< nargs
; argnum
++)
2873 len
+= ROUND_UP (TYPE_LENGTH (VALUE_TYPE (args
[argnum
])),
2874 MIPS_STACK_ARGSIZE
);
2875 sp
-= ROUND_UP (len
, 16);
2878 fprintf_unfiltered (gdb_stdlog
,
2879 "mips_eabi_push_dummy_call: sp=0x%s allocated %d\n",
2880 paddr_nz (sp
), ROUND_UP (len
, 16));
2882 /* Initialize the integer and float register pointers. */
2884 float_argreg
= FPA0_REGNUM
;
2886 /* The struct_return pointer occupies the first parameter-passing reg. */
2890 fprintf_unfiltered (gdb_stdlog
,
2891 "mips_eabi_push_dummy_call: struct_return reg=%d 0x%s\n",
2892 argreg
, paddr_nz (struct_addr
));
2893 write_register (argreg
++, struct_addr
);
2896 /* Now load as many as possible of the first arguments into
2897 registers, and push the rest onto the stack. Loop thru args
2898 from first to last. */
2899 for (argnum
= 0; argnum
< nargs
; argnum
++)
2902 char valbuf
[MAX_REGISTER_SIZE
];
2903 struct value
*arg
= args
[argnum
];
2904 struct type
*arg_type
= check_typedef (VALUE_TYPE (arg
));
2905 int len
= TYPE_LENGTH (arg_type
);
2906 enum type_code typecode
= TYPE_CODE (arg_type
);
2909 fprintf_unfiltered (gdb_stdlog
,
2910 "mips_eabi_push_dummy_call: %d len=%d type=%d",
2911 argnum
+ 1, len
, (int) typecode
);
2913 /* The EABI passes structures that do not fit in a register by
2915 if (len
> MIPS_SAVED_REGSIZE
2916 && (typecode
== TYPE_CODE_STRUCT
|| typecode
== TYPE_CODE_UNION
))
2918 store_unsigned_integer (valbuf
, MIPS_SAVED_REGSIZE
, VALUE_ADDRESS (arg
));
2919 typecode
= TYPE_CODE_PTR
;
2920 len
= MIPS_SAVED_REGSIZE
;
2923 fprintf_unfiltered (gdb_stdlog
, " push");
2926 val
= (char *) VALUE_CONTENTS (arg
);
2928 /* 32-bit ABIs always start floating point arguments in an
2929 even-numbered floating point register. Round the FP register
2930 up before the check to see if there are any FP registers
2931 left. Non MIPS_EABI targets also pass the FP in the integer
2932 registers so also round up normal registers. */
2933 if (!FP_REGISTER_DOUBLE
2934 && fp_register_arg_p (typecode
, arg_type
))
2936 if ((float_argreg
& 1))
2940 /* Floating point arguments passed in registers have to be
2941 treated specially. On 32-bit architectures, doubles
2942 are passed in register pairs; the even register gets
2943 the low word, and the odd register gets the high word.
2944 On non-EABI processors, the first two floating point arguments are
2945 also copied to general registers, because MIPS16 functions
2946 don't use float registers for arguments. This duplication of
2947 arguments in general registers can't hurt non-MIPS16 functions
2948 because those registers are normally skipped. */
2949 /* MIPS_EABI squeezes a struct that contains a single floating
2950 point value into an FP register instead of pushing it onto the
2952 if (fp_register_arg_p (typecode
, arg_type
)
2953 && float_argreg
<= MIPS_LAST_FP_ARG_REGNUM
)
2955 if (!FP_REGISTER_DOUBLE
&& len
== 8)
2957 int low_offset
= TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
? 4 : 0;
2958 unsigned long regval
;
2960 /* Write the low word of the double to the even register(s). */
2961 regval
= extract_unsigned_integer (val
+ low_offset
, 4);
2963 fprintf_unfiltered (gdb_stdlog
, " - fpreg=%d val=%s",
2964 float_argreg
, phex (regval
, 4));
2965 write_register (float_argreg
++, regval
);
2967 /* Write the high word of the double to the odd register(s). */
2968 regval
= extract_unsigned_integer (val
+ 4 - low_offset
, 4);
2970 fprintf_unfiltered (gdb_stdlog
, " - fpreg=%d val=%s",
2971 float_argreg
, phex (regval
, 4));
2972 write_register (float_argreg
++, regval
);
2976 /* This is a floating point value that fits entirely
2977 in a single register. */
2978 /* On 32 bit ABI's the float_argreg is further adjusted
2979 above to ensure that it is even register aligned. */
2980 LONGEST regval
= extract_unsigned_integer (val
, len
);
2982 fprintf_unfiltered (gdb_stdlog
, " - fpreg=%d val=%s",
2983 float_argreg
, phex (regval
, len
));
2984 write_register (float_argreg
++, regval
);
2989 /* Copy the argument to general registers or the stack in
2990 register-sized pieces. Large arguments are split between
2991 registers and stack. */
2992 /* Note: structs whose size is not a multiple of MIPS_REGSIZE
2993 are treated specially: Irix cc passes them in registers
2994 where gcc sometimes puts them on the stack. For maximum
2995 compatibility, we will put them in both places. */
2996 int odd_sized_struct
= ((len
> MIPS_SAVED_REGSIZE
) &&
2997 (len
% MIPS_SAVED_REGSIZE
!= 0));
2999 /* Note: Floating-point values that didn't fit into an FP
3000 register are only written to memory. */
3003 /* Remember if the argument was written to the stack. */
3004 int stack_used_p
= 0;
3006 len
< MIPS_SAVED_REGSIZE
? len
: MIPS_SAVED_REGSIZE
;
3009 fprintf_unfiltered (gdb_stdlog
, " -- partial=%d",
3012 /* Write this portion of the argument to the stack. */
3013 if (argreg
> MIPS_LAST_ARG_REGNUM
3015 || fp_register_arg_p (typecode
, arg_type
))
3017 /* Should shorter than int integer values be
3018 promoted to int before being stored? */
3019 int longword_offset
= 0;
3022 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
3024 if (MIPS_STACK_ARGSIZE
== 8 &&
3025 (typecode
== TYPE_CODE_INT
||
3026 typecode
== TYPE_CODE_PTR
||
3027 typecode
== TYPE_CODE_FLT
) && len
<= 4)
3028 longword_offset
= MIPS_STACK_ARGSIZE
- len
;
3029 else if ((typecode
== TYPE_CODE_STRUCT
||
3030 typecode
== TYPE_CODE_UNION
) &&
3031 TYPE_LENGTH (arg_type
) < MIPS_STACK_ARGSIZE
)
3032 longword_offset
= MIPS_STACK_ARGSIZE
- len
;
3037 fprintf_unfiltered (gdb_stdlog
, " - stack_offset=0x%s",
3038 paddr_nz (stack_offset
));
3039 fprintf_unfiltered (gdb_stdlog
, " longword_offset=0x%s",
3040 paddr_nz (longword_offset
));
3043 addr
= sp
+ stack_offset
+ longword_offset
;
3048 fprintf_unfiltered (gdb_stdlog
, " @0x%s ",
3050 for (i
= 0; i
< partial_len
; i
++)
3052 fprintf_unfiltered (gdb_stdlog
, "%02x",
3056 write_memory (addr
, val
, partial_len
);
3059 /* Note!!! This is NOT an else clause. Odd sized
3060 structs may go thru BOTH paths. Floating point
3061 arguments will not. */
3062 /* Write this portion of the argument to a general
3063 purpose register. */
3064 if (argreg
<= MIPS_LAST_ARG_REGNUM
3065 && !fp_register_arg_p (typecode
, arg_type
))
3067 LONGEST regval
= extract_unsigned_integer (val
, partial_len
);
3070 fprintf_filtered (gdb_stdlog
, " - reg=%d val=%s",
3072 phex (regval
, MIPS_SAVED_REGSIZE
));
3073 write_register (argreg
, regval
);
3080 /* Compute the the offset into the stack at which we
3081 will copy the next parameter.
3083 In the new EABI (and the NABI32), the stack_offset
3084 only needs to be adjusted when it has been used. */
3087 stack_offset
+= ROUND_UP (partial_len
, MIPS_STACK_ARGSIZE
);
3091 fprintf_unfiltered (gdb_stdlog
, "\n");
3094 regcache_cooked_write_signed (regcache
, SP_REGNUM
, sp
);
3096 /* Return adjusted stack pointer. */
3100 /* N32/N64 version of push_dummy_call. */
3103 mips_n32n64_push_dummy_call (struct gdbarch
*gdbarch
, CORE_ADDR func_addr
,
3104 struct regcache
*regcache
, CORE_ADDR bp_addr
, int nargs
,
3105 struct value
**args
, CORE_ADDR sp
, int struct_return
,
3106 CORE_ADDR struct_addr
)
3112 int stack_offset
= 0;
3114 /* For shared libraries, "t9" needs to point at the function
3116 regcache_cooked_write_signed (regcache
, T9_REGNUM
, func_addr
);
3118 /* Set the return address register to point to the entry point of
3119 the program, where a breakpoint lies in wait. */
3120 regcache_cooked_write_signed (regcache
, RA_REGNUM
, bp_addr
);
3122 /* First ensure that the stack and structure return address (if any)
3123 are properly aligned. The stack has to be at least 64-bit
3124 aligned even on 32-bit machines, because doubles must be 64-bit
3125 aligned. For n32 and n64, stack frames need to be 128-bit
3126 aligned, so we round to this widest known alignment. */
3128 sp
= ROUND_DOWN (sp
, 16);
3129 struct_addr
= ROUND_DOWN (struct_addr
, 16);
3131 /* Now make space on the stack for the args. */
3132 for (argnum
= 0; argnum
< nargs
; argnum
++)
3133 len
+= ROUND_UP (TYPE_LENGTH (VALUE_TYPE (args
[argnum
])),
3134 MIPS_STACK_ARGSIZE
);
3135 sp
-= ROUND_UP (len
, 16);
3138 fprintf_unfiltered (gdb_stdlog
,
3139 "mips_n32n64_push_dummy_call: sp=0x%s allocated %d\n",
3140 paddr_nz (sp
), ROUND_UP (len
, 16));
3142 /* Initialize the integer and float register pointers. */
3144 float_argreg
= FPA0_REGNUM
;
3146 /* The struct_return pointer occupies the first parameter-passing reg. */
3150 fprintf_unfiltered (gdb_stdlog
,
3151 "mips_n32n64_push_dummy_call: struct_return reg=%d 0x%s\n",
3152 argreg
, paddr_nz (struct_addr
));
3153 write_register (argreg
++, struct_addr
);
3156 /* Now load as many as possible of the first arguments into
3157 registers, and push the rest onto the stack. Loop thru args
3158 from first to last. */
3159 for (argnum
= 0; argnum
< nargs
; argnum
++)
3162 char valbuf
[MAX_REGISTER_SIZE
];
3163 struct value
*arg
= args
[argnum
];
3164 struct type
*arg_type
= check_typedef (VALUE_TYPE (arg
));
3165 int len
= TYPE_LENGTH (arg_type
);
3166 enum type_code typecode
= TYPE_CODE (arg_type
);
3169 fprintf_unfiltered (gdb_stdlog
,
3170 "mips_n32n64_push_dummy_call: %d len=%d type=%d",
3171 argnum
+ 1, len
, (int) typecode
);
3173 val
= (char *) VALUE_CONTENTS (arg
);
3175 if (fp_register_arg_p (typecode
, arg_type
)
3176 && float_argreg
<= MIPS_LAST_FP_ARG_REGNUM
)
3178 /* This is a floating point value that fits entirely
3179 in a single register. */
3180 /* On 32 bit ABI's the float_argreg is further adjusted
3181 above to ensure that it is even register aligned. */
3182 LONGEST regval
= extract_unsigned_integer (val
, len
);
3184 fprintf_unfiltered (gdb_stdlog
, " - fpreg=%d val=%s",
3185 float_argreg
, phex (regval
, len
));
3186 write_register (float_argreg
++, regval
);
3189 fprintf_unfiltered (gdb_stdlog
, " - reg=%d val=%s",
3190 argreg
, phex (regval
, len
));
3191 write_register (argreg
, regval
);
3196 /* Copy the argument to general registers or the stack in
3197 register-sized pieces. Large arguments are split between
3198 registers and stack. */
3199 /* Note: structs whose size is not a multiple of MIPS_REGSIZE
3200 are treated specially: Irix cc passes them in registers
3201 where gcc sometimes puts them on the stack. For maximum
3202 compatibility, we will put them in both places. */
3203 int odd_sized_struct
= ((len
> MIPS_SAVED_REGSIZE
) &&
3204 (len
% MIPS_SAVED_REGSIZE
!= 0));
3205 /* Note: Floating-point values that didn't fit into an FP
3206 register are only written to memory. */
3209 /* Rememer if the argument was written to the stack. */
3210 int stack_used_p
= 0;
3211 int partial_len
= len
< MIPS_SAVED_REGSIZE
?
3212 len
: MIPS_SAVED_REGSIZE
;
3215 fprintf_unfiltered (gdb_stdlog
, " -- partial=%d",
3218 /* Write this portion of the argument to the stack. */
3219 if (argreg
> MIPS_LAST_ARG_REGNUM
3221 || fp_register_arg_p (typecode
, arg_type
))
3223 /* Should shorter than int integer values be
3224 promoted to int before being stored? */
3225 int longword_offset
= 0;
3228 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
3230 if (MIPS_STACK_ARGSIZE
== 8 &&
3231 (typecode
== TYPE_CODE_INT
||
3232 typecode
== TYPE_CODE_PTR
||
3233 typecode
== TYPE_CODE_FLT
) && len
<= 4)
3234 longword_offset
= MIPS_STACK_ARGSIZE
- len
;
3239 fprintf_unfiltered (gdb_stdlog
, " - stack_offset=0x%s",
3240 paddr_nz (stack_offset
));
3241 fprintf_unfiltered (gdb_stdlog
, " longword_offset=0x%s",
3242 paddr_nz (longword_offset
));
3245 addr
= sp
+ stack_offset
+ longword_offset
;
3250 fprintf_unfiltered (gdb_stdlog
, " @0x%s ",
3252 for (i
= 0; i
< partial_len
; i
++)
3254 fprintf_unfiltered (gdb_stdlog
, "%02x",
3258 write_memory (addr
, val
, partial_len
);
3261 /* Note!!! This is NOT an else clause. Odd sized
3262 structs may go thru BOTH paths. Floating point
3263 arguments will not. */
3264 /* Write this portion of the argument to a general
3265 purpose register. */
3266 if (argreg
<= MIPS_LAST_ARG_REGNUM
3267 && !fp_register_arg_p (typecode
, arg_type
))
3269 LONGEST regval
= extract_unsigned_integer (val
, partial_len
);
3271 /* A non-floating-point argument being passed in a
3272 general register. If a struct or union, and if
3273 the remaining length is smaller than the register
3274 size, we have to adjust the register value on
3277 It does not seem to be necessary to do the
3278 same for integral types.
3280 cagney/2001-07-23: gdb/179: Also, GCC, when
3281 outputting LE O32 with sizeof (struct) <
3282 MIPS_SAVED_REGSIZE, generates a left shift as
3283 part of storing the argument in a register a
3284 register (the left shift isn't generated when
3285 sizeof (struct) >= MIPS_SAVED_REGSIZE). Since it
3286 is quite possible that this is GCC contradicting
3287 the LE/O32 ABI, GDB has not been adjusted to
3288 accommodate this. Either someone needs to
3289 demonstrate that the LE/O32 ABI specifies such a
3290 left shift OR this new ABI gets identified as
3291 such and GDB gets tweaked accordingly. */
3293 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
3294 && partial_len
< MIPS_SAVED_REGSIZE
3295 && (typecode
== TYPE_CODE_STRUCT
||
3296 typecode
== TYPE_CODE_UNION
))
3297 regval
<<= ((MIPS_SAVED_REGSIZE
- partial_len
) *
3301 fprintf_filtered (gdb_stdlog
, " - reg=%d val=%s",
3303 phex (regval
, MIPS_SAVED_REGSIZE
));
3304 write_register (argreg
, regval
);
3311 /* Compute the the offset into the stack at which we
3312 will copy the next parameter.
3314 In N32 (N64?), the stack_offset only needs to be
3315 adjusted when it has been used. */
3318 stack_offset
+= ROUND_UP (partial_len
, MIPS_STACK_ARGSIZE
);
3322 fprintf_unfiltered (gdb_stdlog
, "\n");
3325 regcache_cooked_write_signed (regcache
, SP_REGNUM
, sp
);
3327 /* Return adjusted stack pointer. */
3331 /* O32 version of push_dummy_call. */
3334 mips_o32_push_dummy_call (struct gdbarch
*gdbarch
, CORE_ADDR func_addr
,
3335 struct regcache
*regcache
, CORE_ADDR bp_addr
, int nargs
,
3336 struct value
**args
, CORE_ADDR sp
, int struct_return
,
3337 CORE_ADDR struct_addr
)
3343 int stack_offset
= 0;
3345 /* For shared libraries, "t9" needs to point at the function
3347 regcache_cooked_write_signed (regcache
, T9_REGNUM
, func_addr
);
3349 /* Set the return address register to point to the entry point of
3350 the program, where a breakpoint lies in wait. */
3351 regcache_cooked_write_signed (regcache
, RA_REGNUM
, bp_addr
);
3353 /* First ensure that the stack and structure return address (if any)
3354 are properly aligned. The stack has to be at least 64-bit
3355 aligned even on 32-bit machines, because doubles must be 64-bit
3356 aligned. For n32 and n64, stack frames need to be 128-bit
3357 aligned, so we round to this widest known alignment. */
3359 sp
= ROUND_DOWN (sp
, 16);
3360 struct_addr
= ROUND_DOWN (struct_addr
, 16);
3362 /* Now make space on the stack for the args. */
3363 for (argnum
= 0; argnum
< nargs
; argnum
++)
3364 len
+= ROUND_UP (TYPE_LENGTH (VALUE_TYPE (args
[argnum
])),
3365 MIPS_STACK_ARGSIZE
);
3366 sp
-= ROUND_UP (len
, 16);
3369 fprintf_unfiltered (gdb_stdlog
,
3370 "mips_o32_push_dummy_call: sp=0x%s allocated %d\n",
3371 paddr_nz (sp
), ROUND_UP (len
, 16));
3373 /* Initialize the integer and float register pointers. */
3375 float_argreg
= FPA0_REGNUM
;
3377 /* The struct_return pointer occupies the first parameter-passing reg. */
3381 fprintf_unfiltered (gdb_stdlog
,
3382 "mips_o32_push_dummy_call: struct_return reg=%d 0x%s\n",
3383 argreg
, paddr_nz (struct_addr
));
3384 write_register (argreg
++, struct_addr
);
3385 stack_offset
+= MIPS_STACK_ARGSIZE
;
3388 /* Now load as many as possible of the first arguments into
3389 registers, and push the rest onto the stack. Loop thru args
3390 from first to last. */
3391 for (argnum
= 0; argnum
< nargs
; argnum
++)
3394 char valbuf
[MAX_REGISTER_SIZE
];
3395 struct value
*arg
= args
[argnum
];
3396 struct type
*arg_type
= check_typedef (VALUE_TYPE (arg
));
3397 int len
= TYPE_LENGTH (arg_type
);
3398 enum type_code typecode
= TYPE_CODE (arg_type
);
3401 fprintf_unfiltered (gdb_stdlog
,
3402 "mips_o32_push_dummy_call: %d len=%d type=%d",
3403 argnum
+ 1, len
, (int) typecode
);
3405 val
= (char *) VALUE_CONTENTS (arg
);
3407 /* 32-bit ABIs always start floating point arguments in an
3408 even-numbered floating point register. Round the FP register
3409 up before the check to see if there are any FP registers
3410 left. O32/O64 targets also pass the FP in the integer
3411 registers so also round up normal registers. */
3412 if (!FP_REGISTER_DOUBLE
3413 && fp_register_arg_p (typecode
, arg_type
))
3415 if ((float_argreg
& 1))
3419 /* Floating point arguments passed in registers have to be
3420 treated specially. On 32-bit architectures, doubles
3421 are passed in register pairs; the even register gets
3422 the low word, and the odd register gets the high word.
3423 On O32/O64, the first two floating point arguments are
3424 also copied to general registers, because MIPS16 functions
3425 don't use float registers for arguments. This duplication of
3426 arguments in general registers can't hurt non-MIPS16 functions
3427 because those registers are normally skipped. */
3429 if (fp_register_arg_p (typecode
, arg_type
)
3430 && float_argreg
<= MIPS_LAST_FP_ARG_REGNUM
)
3432 if (!FP_REGISTER_DOUBLE
&& len
== 8)
3434 int low_offset
= TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
? 4 : 0;
3435 unsigned long regval
;
3437 /* Write the low word of the double to the even register(s). */
3438 regval
= extract_unsigned_integer (val
+ low_offset
, 4);
3440 fprintf_unfiltered (gdb_stdlog
, " - fpreg=%d val=%s",
3441 float_argreg
, phex (regval
, 4));
3442 write_register (float_argreg
++, regval
);
3444 fprintf_unfiltered (gdb_stdlog
, " - reg=%d val=%s",
3445 argreg
, phex (regval
, 4));
3446 write_register (argreg
++, regval
);
3448 /* Write the high word of the double to the odd register(s). */
3449 regval
= extract_unsigned_integer (val
+ 4 - low_offset
, 4);
3451 fprintf_unfiltered (gdb_stdlog
, " - fpreg=%d val=%s",
3452 float_argreg
, phex (regval
, 4));
3453 write_register (float_argreg
++, regval
);
3456 fprintf_unfiltered (gdb_stdlog
, " - reg=%d val=%s",
3457 argreg
, phex (regval
, 4));
3458 write_register (argreg
++, regval
);
3462 /* This is a floating point value that fits entirely
3463 in a single register. */
3464 /* On 32 bit ABI's the float_argreg is further adjusted
3465 above to ensure that it is even register aligned. */
3466 LONGEST regval
= extract_unsigned_integer (val
, len
);
3468 fprintf_unfiltered (gdb_stdlog
, " - fpreg=%d val=%s",
3469 float_argreg
, phex (regval
, len
));
3470 write_register (float_argreg
++, regval
);
3471 /* CAGNEY: 32 bit MIPS ABI's always reserve two FP
3472 registers for each argument. The below is (my
3473 guess) to ensure that the corresponding integer
3474 register has reserved the same space. */
3476 fprintf_unfiltered (gdb_stdlog
, " - reg=%d val=%s",
3477 argreg
, phex (regval
, len
));
3478 write_register (argreg
, regval
);
3479 argreg
+= FP_REGISTER_DOUBLE
? 1 : 2;
3481 /* Reserve space for the FP register. */
3482 stack_offset
+= ROUND_UP (len
, MIPS_STACK_ARGSIZE
);
3486 /* Copy the argument to general registers or the stack in
3487 register-sized pieces. Large arguments are split between
3488 registers and stack. */
3489 /* Note: structs whose size is not a multiple of MIPS_REGSIZE
3490 are treated specially: Irix cc passes them in registers
3491 where gcc sometimes puts them on the stack. For maximum
3492 compatibility, we will put them in both places. */
3493 int odd_sized_struct
= ((len
> MIPS_SAVED_REGSIZE
) &&
3494 (len
% MIPS_SAVED_REGSIZE
!= 0));
3495 /* Structures should be aligned to eight bytes (even arg registers)
3496 on MIPS_ABI_O32, if their first member has double precision. */
3497 if (MIPS_SAVED_REGSIZE
< 8
3498 && mips_type_needs_double_align (arg_type
))
3503 /* Note: Floating-point values that didn't fit into an FP
3504 register are only written to memory. */
3507 /* Remember if the argument was written to the stack. */
3508 int stack_used_p
= 0;
3510 len
< MIPS_SAVED_REGSIZE
? len
: MIPS_SAVED_REGSIZE
;
3513 fprintf_unfiltered (gdb_stdlog
, " -- partial=%d",
3516 /* Write this portion of the argument to the stack. */
3517 if (argreg
> MIPS_LAST_ARG_REGNUM
3519 || fp_register_arg_p (typecode
, arg_type
))
3521 /* Should shorter than int integer values be
3522 promoted to int before being stored? */
3523 int longword_offset
= 0;
3526 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
3528 if (MIPS_STACK_ARGSIZE
== 8 &&
3529 (typecode
== TYPE_CODE_INT
||
3530 typecode
== TYPE_CODE_PTR
||
3531 typecode
== TYPE_CODE_FLT
) && len
<= 4)
3532 longword_offset
= MIPS_STACK_ARGSIZE
- len
;
3537 fprintf_unfiltered (gdb_stdlog
, " - stack_offset=0x%s",
3538 paddr_nz (stack_offset
));
3539 fprintf_unfiltered (gdb_stdlog
, " longword_offset=0x%s",
3540 paddr_nz (longword_offset
));
3543 addr
= sp
+ stack_offset
+ longword_offset
;
3548 fprintf_unfiltered (gdb_stdlog
, " @0x%s ",
3550 for (i
= 0; i
< partial_len
; i
++)
3552 fprintf_unfiltered (gdb_stdlog
, "%02x",
3556 write_memory (addr
, val
, partial_len
);
3559 /* Note!!! This is NOT an else clause. Odd sized
3560 structs may go thru BOTH paths. Floating point
3561 arguments will not. */
3562 /* Write this portion of the argument to a general
3563 purpose register. */
3564 if (argreg
<= MIPS_LAST_ARG_REGNUM
3565 && !fp_register_arg_p (typecode
, arg_type
))
3567 LONGEST regval
= extract_signed_integer (val
, partial_len
);
3568 /* Value may need to be sign extended, because
3569 MIPS_REGSIZE != MIPS_SAVED_REGSIZE. */
3571 /* A non-floating-point argument being passed in a
3572 general register. If a struct or union, and if
3573 the remaining length is smaller than the register
3574 size, we have to adjust the register value on
3577 It does not seem to be necessary to do the
3578 same for integral types.
3580 Also don't do this adjustment on O64 binaries.
3582 cagney/2001-07-23: gdb/179: Also, GCC, when
3583 outputting LE O32 with sizeof (struct) <
3584 MIPS_SAVED_REGSIZE, generates a left shift as
3585 part of storing the argument in a register a
3586 register (the left shift isn't generated when
3587 sizeof (struct) >= MIPS_SAVED_REGSIZE). Since it
3588 is quite possible that this is GCC contradicting
3589 the LE/O32 ABI, GDB has not been adjusted to
3590 accommodate this. Either someone needs to
3591 demonstrate that the LE/O32 ABI specifies such a
3592 left shift OR this new ABI gets identified as
3593 such and GDB gets tweaked accordingly. */
3595 if (MIPS_SAVED_REGSIZE
< 8
3596 && TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
3597 && partial_len
< MIPS_SAVED_REGSIZE
3598 && (typecode
== TYPE_CODE_STRUCT
||
3599 typecode
== TYPE_CODE_UNION
))
3600 regval
<<= ((MIPS_SAVED_REGSIZE
- partial_len
) *
3604 fprintf_filtered (gdb_stdlog
, " - reg=%d val=%s",
3606 phex (regval
, MIPS_SAVED_REGSIZE
));
3607 write_register (argreg
, regval
);
3610 /* Prevent subsequent floating point arguments from
3611 being passed in floating point registers. */
3612 float_argreg
= MIPS_LAST_FP_ARG_REGNUM
+ 1;
3618 /* Compute the the offset into the stack at which we
3619 will copy the next parameter.
3621 In older ABIs, the caller reserved space for
3622 registers that contained arguments. This was loosely
3623 refered to as their "home". Consequently, space is
3624 always allocated. */
3626 stack_offset
+= ROUND_UP (partial_len
, MIPS_STACK_ARGSIZE
);
3630 fprintf_unfiltered (gdb_stdlog
, "\n");
3633 regcache_cooked_write_signed (regcache
, SP_REGNUM
, sp
);
3635 /* Return adjusted stack pointer. */
3639 /* O64 version of push_dummy_call. */
3642 mips_o64_push_dummy_call (struct gdbarch
*gdbarch
, CORE_ADDR func_addr
,
3643 struct regcache
*regcache
, CORE_ADDR bp_addr
, int nargs
,
3644 struct value
**args
, CORE_ADDR sp
, int struct_return
,
3645 CORE_ADDR struct_addr
)
3651 int stack_offset
= 0;
3653 /* For shared libraries, "t9" needs to point at the function
3655 regcache_cooked_write_signed (regcache
, T9_REGNUM
, func_addr
);
3657 /* Set the return address register to point to the entry point of
3658 the program, where a breakpoint lies in wait. */
3659 regcache_cooked_write_signed (regcache
, RA_REGNUM
, bp_addr
);
3661 /* First ensure that the stack and structure return address (if any)
3662 are properly aligned. The stack has to be at least 64-bit
3663 aligned even on 32-bit machines, because doubles must be 64-bit
3664 aligned. For n32 and n64, stack frames need to be 128-bit
3665 aligned, so we round to this widest known alignment. */
3667 sp
= ROUND_DOWN (sp
, 16);
3668 struct_addr
= ROUND_DOWN (struct_addr
, 16);
3670 /* Now make space on the stack for the args. */
3671 for (argnum
= 0; argnum
< nargs
; argnum
++)
3672 len
+= ROUND_UP (TYPE_LENGTH (VALUE_TYPE (args
[argnum
])),
3673 MIPS_STACK_ARGSIZE
);
3674 sp
-= ROUND_UP (len
, 16);
3677 fprintf_unfiltered (gdb_stdlog
,
3678 "mips_o64_push_dummy_call: sp=0x%s allocated %d\n",
3679 paddr_nz (sp
), ROUND_UP (len
, 16));
3681 /* Initialize the integer and float register pointers. */
3683 float_argreg
= FPA0_REGNUM
;
3685 /* The struct_return pointer occupies the first parameter-passing reg. */
3689 fprintf_unfiltered (gdb_stdlog
,
3690 "mips_o64_push_dummy_call: struct_return reg=%d 0x%s\n",
3691 argreg
, paddr_nz (struct_addr
));
3692 write_register (argreg
++, struct_addr
);
3693 stack_offset
+= MIPS_STACK_ARGSIZE
;
3696 /* Now load as many as possible of the first arguments into
3697 registers, and push the rest onto the stack. Loop thru args
3698 from first to last. */
3699 for (argnum
= 0; argnum
< nargs
; argnum
++)
3702 char valbuf
[MAX_REGISTER_SIZE
];
3703 struct value
*arg
= args
[argnum
];
3704 struct type
*arg_type
= check_typedef (VALUE_TYPE (arg
));
3705 int len
= TYPE_LENGTH (arg_type
);
3706 enum type_code typecode
= TYPE_CODE (arg_type
);
3709 fprintf_unfiltered (gdb_stdlog
,
3710 "mips_o64_push_dummy_call: %d len=%d type=%d",
3711 argnum
+ 1, len
, (int) typecode
);
3713 val
= (char *) VALUE_CONTENTS (arg
);
3715 /* 32-bit ABIs always start floating point arguments in an
3716 even-numbered floating point register. Round the FP register
3717 up before the check to see if there are any FP registers
3718 left. O32/O64 targets also pass the FP in the integer
3719 registers so also round up normal registers. */
3720 if (!FP_REGISTER_DOUBLE
3721 && fp_register_arg_p (typecode
, arg_type
))
3723 if ((float_argreg
& 1))
3727 /* Floating point arguments passed in registers have to be
3728 treated specially. On 32-bit architectures, doubles
3729 are passed in register pairs; the even register gets
3730 the low word, and the odd register gets the high word.
3731 On O32/O64, the first two floating point arguments are
3732 also copied to general registers, because MIPS16 functions
3733 don't use float registers for arguments. This duplication of
3734 arguments in general registers can't hurt non-MIPS16 functions
3735 because those registers are normally skipped. */
3737 if (fp_register_arg_p (typecode
, arg_type
)
3738 && float_argreg
<= MIPS_LAST_FP_ARG_REGNUM
)
3740 if (!FP_REGISTER_DOUBLE
&& len
== 8)
3742 int low_offset
= TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
? 4 : 0;
3743 unsigned long regval
;
3745 /* Write the low word of the double to the even register(s). */
3746 regval
= extract_unsigned_integer (val
+ low_offset
, 4);
3748 fprintf_unfiltered (gdb_stdlog
, " - fpreg=%d val=%s",
3749 float_argreg
, phex (regval
, 4));
3750 write_register (float_argreg
++, regval
);
3752 fprintf_unfiltered (gdb_stdlog
, " - reg=%d val=%s",
3753 argreg
, phex (regval
, 4));
3754 write_register (argreg
++, regval
);
3756 /* Write the high word of the double to the odd register(s). */
3757 regval
= extract_unsigned_integer (val
+ 4 - low_offset
, 4);
3759 fprintf_unfiltered (gdb_stdlog
, " - fpreg=%d val=%s",
3760 float_argreg
, phex (regval
, 4));
3761 write_register (float_argreg
++, regval
);
3764 fprintf_unfiltered (gdb_stdlog
, " - reg=%d val=%s",
3765 argreg
, phex (regval
, 4));
3766 write_register (argreg
++, regval
);
3770 /* This is a floating point value that fits entirely
3771 in a single register. */
3772 /* On 32 bit ABI's the float_argreg is further adjusted
3773 above to ensure that it is even register aligned. */
3774 LONGEST regval
= extract_unsigned_integer (val
, len
);
3776 fprintf_unfiltered (gdb_stdlog
, " - fpreg=%d val=%s",
3777 float_argreg
, phex (regval
, len
));
3778 write_register (float_argreg
++, regval
);
3779 /* CAGNEY: 32 bit MIPS ABI's always reserve two FP
3780 registers for each argument. The below is (my
3781 guess) to ensure that the corresponding integer
3782 register has reserved the same space. */
3784 fprintf_unfiltered (gdb_stdlog
, " - reg=%d val=%s",
3785 argreg
, phex (regval
, len
));
3786 write_register (argreg
, regval
);
3787 argreg
+= FP_REGISTER_DOUBLE
? 1 : 2;
3789 /* Reserve space for the FP register. */
3790 stack_offset
+= ROUND_UP (len
, MIPS_STACK_ARGSIZE
);
3794 /* Copy the argument to general registers or the stack in
3795 register-sized pieces. Large arguments are split between
3796 registers and stack. */
3797 /* Note: structs whose size is not a multiple of MIPS_REGSIZE
3798 are treated specially: Irix cc passes them in registers
3799 where gcc sometimes puts them on the stack. For maximum
3800 compatibility, we will put them in both places. */
3801 int odd_sized_struct
= ((len
> MIPS_SAVED_REGSIZE
) &&
3802 (len
% MIPS_SAVED_REGSIZE
!= 0));
3803 /* Structures should be aligned to eight bytes (even arg registers)
3804 on MIPS_ABI_O32, if their first member has double precision. */
3805 if (MIPS_SAVED_REGSIZE
< 8
3806 && mips_type_needs_double_align (arg_type
))
3811 /* Note: Floating-point values that didn't fit into an FP
3812 register are only written to memory. */
3815 /* Remember if the argument was written to the stack. */
3816 int stack_used_p
= 0;
3818 len
< MIPS_SAVED_REGSIZE
? len
: MIPS_SAVED_REGSIZE
;
3821 fprintf_unfiltered (gdb_stdlog
, " -- partial=%d",
3824 /* Write this portion of the argument to the stack. */
3825 if (argreg
> MIPS_LAST_ARG_REGNUM
3827 || fp_register_arg_p (typecode
, arg_type
))
3829 /* Should shorter than int integer values be
3830 promoted to int before being stored? */
3831 int longword_offset
= 0;
3834 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
3836 if (MIPS_STACK_ARGSIZE
== 8 &&
3837 (typecode
== TYPE_CODE_INT
||
3838 typecode
== TYPE_CODE_PTR
||
3839 typecode
== TYPE_CODE_FLT
) && len
<= 4)
3840 longword_offset
= MIPS_STACK_ARGSIZE
- len
;
3845 fprintf_unfiltered (gdb_stdlog
, " - stack_offset=0x%s",
3846 paddr_nz (stack_offset
));
3847 fprintf_unfiltered (gdb_stdlog
, " longword_offset=0x%s",
3848 paddr_nz (longword_offset
));
3851 addr
= sp
+ stack_offset
+ longword_offset
;
3856 fprintf_unfiltered (gdb_stdlog
, " @0x%s ",
3858 for (i
= 0; i
< partial_len
; i
++)
3860 fprintf_unfiltered (gdb_stdlog
, "%02x",
3864 write_memory (addr
, val
, partial_len
);
3867 /* Note!!! This is NOT an else clause. Odd sized
3868 structs may go thru BOTH paths. Floating point
3869 arguments will not. */
3870 /* Write this portion of the argument to a general
3871 purpose register. */
3872 if (argreg
<= MIPS_LAST_ARG_REGNUM
3873 && !fp_register_arg_p (typecode
, arg_type
))
3875 LONGEST regval
= extract_signed_integer (val
, partial_len
);
3876 /* Value may need to be sign extended, because
3877 MIPS_REGSIZE != MIPS_SAVED_REGSIZE. */
3879 /* A non-floating-point argument being passed in a
3880 general register. If a struct or union, and if
3881 the remaining length is smaller than the register
3882 size, we have to adjust the register value on
3885 It does not seem to be necessary to do the
3886 same for integral types.
3888 Also don't do this adjustment on O64 binaries.
3890 cagney/2001-07-23: gdb/179: Also, GCC, when
3891 outputting LE O32 with sizeof (struct) <
3892 MIPS_SAVED_REGSIZE, generates a left shift as
3893 part of storing the argument in a register a
3894 register (the left shift isn't generated when
3895 sizeof (struct) >= MIPS_SAVED_REGSIZE). Since it
3896 is quite possible that this is GCC contradicting
3897 the LE/O32 ABI, GDB has not been adjusted to
3898 accommodate this. Either someone needs to
3899 demonstrate that the LE/O32 ABI specifies such a
3900 left shift OR this new ABI gets identified as
3901 such and GDB gets tweaked accordingly. */
3903 if (MIPS_SAVED_REGSIZE
< 8
3904 && TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
3905 && partial_len
< MIPS_SAVED_REGSIZE
3906 && (typecode
== TYPE_CODE_STRUCT
||
3907 typecode
== TYPE_CODE_UNION
))
3908 regval
<<= ((MIPS_SAVED_REGSIZE
- partial_len
) *
3912 fprintf_filtered (gdb_stdlog
, " - reg=%d val=%s",
3914 phex (regval
, MIPS_SAVED_REGSIZE
));
3915 write_register (argreg
, regval
);
3918 /* Prevent subsequent floating point arguments from
3919 being passed in floating point registers. */
3920 float_argreg
= MIPS_LAST_FP_ARG_REGNUM
+ 1;
3926 /* Compute the the offset into the stack at which we
3927 will copy the next parameter.
3929 In older ABIs, the caller reserved space for
3930 registers that contained arguments. This was loosely
3931 refered to as their "home". Consequently, space is
3932 always allocated. */
3934 stack_offset
+= ROUND_UP (partial_len
, MIPS_STACK_ARGSIZE
);
3938 fprintf_unfiltered (gdb_stdlog
, "\n");
3941 regcache_cooked_write_signed (regcache
, SP_REGNUM
, sp
);
3943 /* Return adjusted stack pointer. */
3948 mips_pop_frame (void)
3950 register int regnum
;
3951 struct frame_info
*frame
= get_current_frame ();
3952 CORE_ADDR new_sp
= get_frame_base (frame
);
3953 mips_extra_func_info_t proc_desc
;
3955 if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (frame
), 0, 0))
3957 generic_pop_dummy_frame ();
3958 flush_cached_frames ();
3962 proc_desc
= get_frame_extra_info (frame
)->proc_desc
;
3963 write_register (PC_REGNUM
, DEPRECATED_FRAME_SAVED_PC (frame
));
3964 mips_find_saved_regs (frame
);
3965 for (regnum
= 0; regnum
< NUM_REGS
; regnum
++)
3966 if (regnum
!= SP_REGNUM
&& regnum
!= PC_REGNUM
3967 && get_frame_saved_regs (frame
)[regnum
])
3969 /* Floating point registers must not be sign extended,
3970 in case MIPS_SAVED_REGSIZE = 4 but sizeof (FP0_REGNUM) == 8. */
3972 if (FP0_REGNUM
<= regnum
&& regnum
< FP0_REGNUM
+ 32)
3973 write_register (regnum
,
3974 read_memory_unsigned_integer (get_frame_saved_regs (frame
)[regnum
],
3975 MIPS_SAVED_REGSIZE
));
3977 write_register (regnum
,
3978 read_memory_integer (get_frame_saved_regs (frame
)[regnum
],
3979 MIPS_SAVED_REGSIZE
));
3982 write_register (SP_REGNUM
, new_sp
);
3983 flush_cached_frames ();
3985 if (proc_desc
&& PROC_DESC_IS_DUMMY (proc_desc
))
3987 struct linked_proc_info
*pi_ptr
, *prev_ptr
;
3989 for (pi_ptr
= linked_proc_desc_table
, prev_ptr
= NULL
;
3991 prev_ptr
= pi_ptr
, pi_ptr
= pi_ptr
->next
)
3993 if (&pi_ptr
->info
== proc_desc
)
3998 error ("Can't locate dummy extra frame info\n");
4000 if (prev_ptr
!= NULL
)
4001 prev_ptr
->next
= pi_ptr
->next
;
4003 linked_proc_desc_table
= pi_ptr
->next
;
4007 write_register (HI_REGNUM
,
4008 read_memory_integer (new_sp
- 2 * MIPS_SAVED_REGSIZE
,
4009 MIPS_SAVED_REGSIZE
));
4010 write_register (LO_REGNUM
,
4011 read_memory_integer (new_sp
- 3 * MIPS_SAVED_REGSIZE
,
4012 MIPS_SAVED_REGSIZE
));
4013 if (MIPS_FPU_TYPE
!= MIPS_FPU_NONE
)
4014 write_register (FCRCS_REGNUM
,
4015 read_memory_integer (new_sp
- 4 * MIPS_SAVED_REGSIZE
,
4016 MIPS_SAVED_REGSIZE
));
4020 /* Floating point register management.
4022 Background: MIPS1 & 2 fp registers are 32 bits wide. To support
4023 64bit operations, these early MIPS cpus treat fp register pairs
4024 (f0,f1) as a single register (d0). Later MIPS cpu's have 64 bit fp
4025 registers and offer a compatibility mode that emulates the MIPS2 fp
4026 model. When operating in MIPS2 fp compat mode, later cpu's split
4027 double precision floats into two 32-bit chunks and store them in
4028 consecutive fp regs. To display 64-bit floats stored in this
4029 fashion, we have to combine 32 bits from f0 and 32 bits from f1.
4030 Throw in user-configurable endianness and you have a real mess.
4032 The way this works is:
4033 - If we are in 32-bit mode or on a 32-bit processor, then a 64-bit
4034 double-precision value will be split across two logical registers.
4035 The lower-numbered logical register will hold the low-order bits,
4036 regardless of the processor's endianness.
4037 - If we are on a 64-bit processor, and we are looking for a
4038 single-precision value, it will be in the low ordered bits
4039 of a 64-bit GPR (after mfc1, for example) or a 64-bit register
4040 save slot in memory.
4041 - If we are in 64-bit mode, everything is straightforward.
4043 Note that this code only deals with "live" registers at the top of the
4044 stack. We will attempt to deal with saved registers later, when
4045 the raw/cooked register interface is in place. (We need a general
4046 interface that can deal with dynamic saved register sizes -- fp
4047 regs could be 32 bits wide in one frame and 64 on the frame above
4050 static struct type
*
4051 mips_float_register_type (void)
4053 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
4054 return builtin_type_ieee_single_big
;
4056 return builtin_type_ieee_single_little
;
4059 static struct type
*
4060 mips_double_register_type (void)
4062 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
4063 return builtin_type_ieee_double_big
;
4065 return builtin_type_ieee_double_little
;
4068 /* Copy a 32-bit single-precision value from the current frame
4069 into rare_buffer. */
4072 mips_read_fp_register_single (struct frame_info
*frame
, int regno
,
4075 int raw_size
= REGISTER_RAW_SIZE (regno
);
4076 char *raw_buffer
= alloca (raw_size
);
4078 if (!frame_register_read (frame
, regno
, raw_buffer
))
4079 error ("can't read register %d (%s)", regno
, REGISTER_NAME (regno
));
4082 /* We have a 64-bit value for this register. Find the low-order
4086 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
4091 memcpy (rare_buffer
, raw_buffer
+ offset
, 4);
4095 memcpy (rare_buffer
, raw_buffer
, 4);
4099 /* Copy a 64-bit double-precision value from the current frame into
4100 rare_buffer. This may include getting half of it from the next
4104 mips_read_fp_register_double (struct frame_info
*frame
, int regno
,
4107 int raw_size
= REGISTER_RAW_SIZE (regno
);
4109 if (raw_size
== 8 && !mips2_fp_compat ())
4111 /* We have a 64-bit value for this register, and we should use
4113 if (!frame_register_read (frame
, regno
, rare_buffer
))
4114 error ("can't read register %d (%s)", regno
, REGISTER_NAME (regno
));
4118 if ((regno
- FP0_REGNUM
) & 1)
4119 internal_error (__FILE__
, __LINE__
,
4120 "mips_read_fp_register_double: bad access to "
4121 "odd-numbered FP register");
4123 /* mips_read_fp_register_single will find the correct 32 bits from
4125 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
4127 mips_read_fp_register_single (frame
, regno
, rare_buffer
+ 4);
4128 mips_read_fp_register_single (frame
, regno
+ 1, rare_buffer
);
4132 mips_read_fp_register_single (frame
, regno
, rare_buffer
);
4133 mips_read_fp_register_single (frame
, regno
+ 1, rare_buffer
+ 4);
4139 mips_print_fp_register (struct ui_file
*file
, struct frame_info
*frame
,
4141 { /* do values for FP (float) regs */
4143 double doub
, flt1
, flt2
; /* doubles extracted from raw hex data */
4144 int inv1
, inv2
, namelen
;
4146 raw_buffer
= (char *) alloca (2 * REGISTER_RAW_SIZE (FP0_REGNUM
));
4148 fprintf_filtered (file
, "%s:", REGISTER_NAME (regnum
));
4149 fprintf_filtered (file
, "%*s", 4 - (int) strlen (REGISTER_NAME (regnum
)),
4152 if (REGISTER_RAW_SIZE (regnum
) == 4 || mips2_fp_compat ())
4154 /* 4-byte registers: Print hex and floating. Also print even
4155 numbered registers as doubles. */
4156 mips_read_fp_register_single (frame
, regnum
, raw_buffer
);
4157 flt1
= unpack_double (mips_float_register_type (), raw_buffer
, &inv1
);
4159 print_scalar_formatted (raw_buffer
, builtin_type_uint32
, 'x', 'w', file
);
4161 fprintf_filtered (file
, " flt: ");
4163 fprintf_filtered (file
, " <invalid float> ");
4165 fprintf_filtered (file
, "%-17.9g", flt1
);
4167 if (regnum
% 2 == 0)
4169 mips_read_fp_register_double (frame
, regnum
, raw_buffer
);
4170 doub
= unpack_double (mips_double_register_type (), raw_buffer
,
4173 fprintf_filtered (file
, " dbl: ");
4175 fprintf_filtered (file
, "<invalid double>");
4177 fprintf_filtered (file
, "%-24.17g", doub
);
4182 /* Eight byte registers: print each one as hex, float and double. */
4183 mips_read_fp_register_single (frame
, regnum
, raw_buffer
);
4184 flt1
= unpack_double (mips_float_register_type (), raw_buffer
, &inv1
);
4186 mips_read_fp_register_double (frame
, regnum
, raw_buffer
);
4187 doub
= unpack_double (mips_double_register_type (), raw_buffer
, &inv2
);
4190 print_scalar_formatted (raw_buffer
, builtin_type_uint64
, 'x', 'g', file
);
4192 fprintf_filtered (file
, " flt: ");
4194 fprintf_filtered (file
, "<invalid float>");
4196 fprintf_filtered (file
, "%-17.9g", flt1
);
4198 fprintf_filtered (file
, " dbl: ");
4200 fprintf_filtered (file
, "<invalid double>");
4202 fprintf_filtered (file
, "%-24.17g", doub
);
4207 mips_print_register (struct ui_file
*file
, struct frame_info
*frame
,
4208 int regnum
, int all
)
4210 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
4211 char raw_buffer
[MAX_REGISTER_SIZE
];
4214 if (TYPE_CODE (gdbarch_register_type (gdbarch
, regnum
)) == TYPE_CODE_FLT
)
4216 mips_print_fp_register (file
, frame
, regnum
);
4220 /* Get the data in raw format. */
4221 if (!frame_register_read (frame
, regnum
, raw_buffer
))
4223 fprintf_filtered (file
, "%s: [Invalid]", REGISTER_NAME (regnum
));
4227 fputs_filtered (REGISTER_NAME (regnum
), file
);
4229 /* The problem with printing numeric register names (r26, etc.) is that
4230 the user can't use them on input. Probably the best solution is to
4231 fix it so that either the numeric or the funky (a2, etc.) names
4232 are accepted on input. */
4233 if (regnum
< MIPS_NUMREGS
)
4234 fprintf_filtered (file
, "(r%d): ", regnum
);
4236 fprintf_filtered (file
, ": ");
4238 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
4239 offset
= REGISTER_RAW_SIZE (regnum
) - REGISTER_VIRTUAL_SIZE (regnum
);
4243 print_scalar_formatted (raw_buffer
+ offset
, gdbarch_register_type (gdbarch
, regnum
),
4247 /* Replacement for generic do_registers_info.
4248 Print regs in pretty columns. */
4251 print_fp_register_row (struct ui_file
*file
, struct frame_info
*frame
,
4254 fprintf_filtered (file
, " ");
4255 mips_print_fp_register (file
, frame
, regnum
);
4256 fprintf_filtered (file
, "\n");
4261 /* Print a row's worth of GP (int) registers, with name labels above */
4264 print_gp_register_row (struct ui_file
*file
, struct frame_info
*frame
,
4267 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
4268 /* do values for GP (int) regs */
4269 char raw_buffer
[MAX_REGISTER_SIZE
];
4270 int ncols
= (MIPS_REGSIZE
== 8 ? 4 : 8); /* display cols per row */
4274 /* For GP registers, we print a separate row of names above the vals */
4275 fprintf_filtered (file
, " ");
4276 for (col
= 0, regnum
= start_regnum
;
4277 col
< ncols
&& regnum
< NUM_REGS
+ NUM_PSEUDO_REGS
;
4280 if (*REGISTER_NAME (regnum
) == '\0')
4281 continue; /* unused register */
4282 if (TYPE_CODE (gdbarch_register_type (gdbarch
, regnum
)) == TYPE_CODE_FLT
)
4283 break; /* end the row: reached FP register */
4284 fprintf_filtered (file
, MIPS_REGSIZE
== 8 ? "%17s" : "%9s",
4285 REGISTER_NAME (regnum
));
4288 /* print the R0 to R31 names */
4289 if ((start_regnum
% NUM_REGS
) < MIPS_NUMREGS
)
4290 fprintf_filtered (file
, "\n R%-4d", start_regnum
% NUM_REGS
);
4292 fprintf_filtered (file
, "\n ");
4294 /* now print the values in hex, 4 or 8 to the row */
4295 for (col
= 0, regnum
= start_regnum
;
4296 col
< ncols
&& regnum
< NUM_REGS
+ NUM_PSEUDO_REGS
;
4299 if (*REGISTER_NAME (regnum
) == '\0')
4300 continue; /* unused register */
4301 if (TYPE_CODE (gdbarch_register_type (gdbarch
, regnum
)) == TYPE_CODE_FLT
)
4302 break; /* end row: reached FP register */
4303 /* OK: get the data in raw format. */
4304 if (!frame_register_read (frame
, regnum
, raw_buffer
))
4305 error ("can't read register %d (%s)", regnum
, REGISTER_NAME (regnum
));
4306 /* pad small registers */
4307 for (byte
= 0; byte
< (MIPS_REGSIZE
- REGISTER_VIRTUAL_SIZE (regnum
)); byte
++)
4308 printf_filtered (" ");
4309 /* Now print the register value in hex, endian order. */
4310 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
4311 for (byte
= REGISTER_RAW_SIZE (regnum
) - REGISTER_VIRTUAL_SIZE (regnum
);
4312 byte
< REGISTER_RAW_SIZE (regnum
);
4314 fprintf_filtered (file
, "%02x", (unsigned char) raw_buffer
[byte
]);
4316 for (byte
= REGISTER_VIRTUAL_SIZE (regnum
) - 1;
4319 fprintf_filtered (file
, "%02x", (unsigned char) raw_buffer
[byte
]);
4320 fprintf_filtered (file
, " ");
4323 if (col
> 0) /* ie. if we actually printed anything... */
4324 fprintf_filtered (file
, "\n");
4329 /* MIPS_DO_REGISTERS_INFO(): called by "info register" command */
4332 mips_print_registers_info (struct gdbarch
*gdbarch
, struct ui_file
*file
,
4333 struct frame_info
*frame
, int regnum
, int all
)
4335 if (regnum
!= -1) /* do one specified register */
4337 gdb_assert (regnum
>= NUM_REGS
);
4338 if (*(REGISTER_NAME (regnum
)) == '\0')
4339 error ("Not a valid register for the current processor type");
4341 mips_print_register (file
, frame
, regnum
, 0);
4342 fprintf_filtered (file
, "\n");
4345 /* do all (or most) registers */
4348 while (regnum
< NUM_REGS
+ NUM_PSEUDO_REGS
)
4350 if (TYPE_CODE (gdbarch_register_type (gdbarch
, regnum
)) == TYPE_CODE_FLT
)
4352 if (all
) /* true for "INFO ALL-REGISTERS" command */
4353 regnum
= print_fp_register_row (file
, frame
, regnum
);
4355 regnum
+= MIPS_NUMREGS
; /* skip floating point regs */
4358 regnum
= print_gp_register_row (file
, frame
, regnum
);
4363 /* Is this a branch with a delay slot? */
4365 static int is_delayed (unsigned long);
4368 is_delayed (unsigned long insn
)
4371 for (i
= 0; i
< NUMOPCODES
; ++i
)
4372 if (mips_opcodes
[i
].pinfo
!= INSN_MACRO
4373 && (insn
& mips_opcodes
[i
].mask
) == mips_opcodes
[i
].match
)
4375 return (i
< NUMOPCODES
4376 && (mips_opcodes
[i
].pinfo
& (INSN_UNCOND_BRANCH_DELAY
4377 | INSN_COND_BRANCH_DELAY
4378 | INSN_COND_BRANCH_LIKELY
)));
4382 mips_step_skips_delay (CORE_ADDR pc
)
4384 char buf
[MIPS_INSTLEN
];
4386 /* There is no branch delay slot on MIPS16. */
4387 if (pc_is_mips16 (pc
))
4390 if (target_read_memory (pc
, buf
, MIPS_INSTLEN
) != 0)
4391 /* If error reading memory, guess that it is not a delayed branch. */
4393 return is_delayed ((unsigned long) extract_unsigned_integer (buf
, MIPS_INSTLEN
));
4397 /* Skip the PC past function prologue instructions (32-bit version).
4398 This is a helper function for mips_skip_prologue. */
4401 mips32_skip_prologue (CORE_ADDR pc
)
4405 int seen_sp_adjust
= 0;
4406 int load_immediate_bytes
= 0;
4408 /* Skip the typical prologue instructions. These are the stack adjustment
4409 instruction and the instructions that save registers on the stack
4410 or in the gcc frame. */
4411 for (end_pc
= pc
+ 100; pc
< end_pc
; pc
+= MIPS_INSTLEN
)
4413 unsigned long high_word
;
4415 inst
= mips_fetch_instruction (pc
);
4416 high_word
= (inst
>> 16) & 0xffff;
4418 if (high_word
== 0x27bd /* addiu $sp,$sp,offset */
4419 || high_word
== 0x67bd) /* daddiu $sp,$sp,offset */
4421 else if (inst
== 0x03a1e823 || /* subu $sp,$sp,$at */
4422 inst
== 0x03a8e823) /* subu $sp,$sp,$t0 */
4424 else if (((inst
& 0xFFE00000) == 0xAFA00000 /* sw reg,n($sp) */
4425 || (inst
& 0xFFE00000) == 0xFFA00000) /* sd reg,n($sp) */
4426 && (inst
& 0x001F0000)) /* reg != $zero */
4429 else if ((inst
& 0xFFE00000) == 0xE7A00000) /* swc1 freg,n($sp) */
4431 else if ((inst
& 0xF3E00000) == 0xA3C00000 && (inst
& 0x001F0000))
4433 continue; /* reg != $zero */
4435 /* move $s8,$sp. With different versions of gas this will be either
4436 `addu $s8,$sp,$zero' or `or $s8,$sp,$zero' or `daddu s8,sp,$0'.
4437 Accept any one of these. */
4438 else if (inst
== 0x03A0F021 || inst
== 0x03a0f025 || inst
== 0x03a0f02d)
4441 else if ((inst
& 0xFF9F07FF) == 0x00800021) /* move reg,$a0-$a3 */
4443 else if (high_word
== 0x3c1c) /* lui $gp,n */
4445 else if (high_word
== 0x279c) /* addiu $gp,$gp,n */
4447 else if (inst
== 0x0399e021 /* addu $gp,$gp,$t9 */
4448 || inst
== 0x033ce021) /* addu $gp,$t9,$gp */
4450 /* The following instructions load $at or $t0 with an immediate
4451 value in preparation for a stack adjustment via
4452 subu $sp,$sp,[$at,$t0]. These instructions could also initialize
4453 a local variable, so we accept them only before a stack adjustment
4454 instruction was seen. */
4455 else if (!seen_sp_adjust
)
4457 if (high_word
== 0x3c01 || /* lui $at,n */
4458 high_word
== 0x3c08) /* lui $t0,n */
4460 load_immediate_bytes
+= MIPS_INSTLEN
; /* FIXME!! */
4463 else if (high_word
== 0x3421 || /* ori $at,$at,n */
4464 high_word
== 0x3508 || /* ori $t0,$t0,n */
4465 high_word
== 0x3401 || /* ori $at,$zero,n */
4466 high_word
== 0x3408) /* ori $t0,$zero,n */
4468 load_immediate_bytes
+= MIPS_INSTLEN
; /* FIXME!! */
4478 /* In a frameless function, we might have incorrectly
4479 skipped some load immediate instructions. Undo the skipping
4480 if the load immediate was not followed by a stack adjustment. */
4481 if (load_immediate_bytes
&& !seen_sp_adjust
)
4482 pc
-= load_immediate_bytes
;
4486 /* Skip the PC past function prologue instructions (16-bit version).
4487 This is a helper function for mips_skip_prologue. */
4490 mips16_skip_prologue (CORE_ADDR pc
)
4493 int extend_bytes
= 0;
4494 int prev_extend_bytes
;
4496 /* Table of instructions likely to be found in a function prologue. */
4499 unsigned short inst
;
4500 unsigned short mask
;
4507 , /* addiu $sp,offset */
4511 , /* daddiu $sp,offset */
4515 , /* sw reg,n($sp) */
4519 , /* sd reg,n($sp) */
4523 , /* sw $ra,n($sp) */
4527 , /* sd $ra,n($sp) */
4535 , /* sw $a0-$a3,n($s1) */
4539 , /* move reg,$a0-$a3 */
4543 , /* entry pseudo-op */
4547 , /* addiu $s1,$sp,n */
4550 } /* end of table marker */
4553 /* Skip the typical prologue instructions. These are the stack adjustment
4554 instruction and the instructions that save registers on the stack
4555 or in the gcc frame. */
4556 for (end_pc
= pc
+ 100; pc
< end_pc
; pc
+= MIPS16_INSTLEN
)
4558 unsigned short inst
;
4561 inst
= mips_fetch_instruction (pc
);
4563 /* Normally we ignore an extend instruction. However, if it is
4564 not followed by a valid prologue instruction, we must adjust
4565 the pc back over the extend so that it won't be considered
4566 part of the prologue. */
4567 if ((inst
& 0xf800) == 0xf000) /* extend */
4569 extend_bytes
= MIPS16_INSTLEN
;
4572 prev_extend_bytes
= extend_bytes
;
4575 /* Check for other valid prologue instructions besides extend. */
4576 for (i
= 0; table
[i
].mask
!= 0; i
++)
4577 if ((inst
& table
[i
].mask
) == table
[i
].inst
) /* found, get out */
4579 if (table
[i
].mask
!= 0) /* it was in table? */
4580 continue; /* ignore it */
4584 /* Return the current pc, adjusted backwards by 2 if
4585 the previous instruction was an extend. */
4586 return pc
- prev_extend_bytes
;
4592 /* To skip prologues, I use this predicate. Returns either PC itself
4593 if the code at PC does not look like a function prologue; otherwise
4594 returns an address that (if we're lucky) follows the prologue. If
4595 LENIENT, then we must skip everything which is involved in setting
4596 up the frame (it's OK to skip more, just so long as we don't skip
4597 anything which might clobber the registers which are being saved.
4598 We must skip more in the case where part of the prologue is in the
4599 delay slot of a non-prologue instruction). */
4602 mips_skip_prologue (CORE_ADDR pc
)
4604 /* See if we can determine the end of the prologue via the symbol table.
4605 If so, then return either PC, or the PC after the prologue, whichever
4608 CORE_ADDR post_prologue_pc
= after_prologue (pc
, NULL
);
4610 if (post_prologue_pc
!= 0)
4611 return max (pc
, post_prologue_pc
);
4613 /* Can't determine prologue from the symbol table, need to examine
4616 if (pc_is_mips16 (pc
))
4617 return mips16_skip_prologue (pc
);
4619 return mips32_skip_prologue (pc
);
4622 /* Determine how a return value is stored within the MIPS register
4623 file, given the return type `valtype'. */
4625 struct return_value_word
4634 return_value_location (struct type
*valtype
,
4635 struct return_value_word
*hi
,
4636 struct return_value_word
*lo
)
4638 int len
= TYPE_LENGTH (valtype
);
4640 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
4641 && ((MIPS_FPU_TYPE
== MIPS_FPU_DOUBLE
&& (len
== 4 || len
== 8))
4642 || (MIPS_FPU_TYPE
== MIPS_FPU_SINGLE
&& len
== 4)))
4644 if (!FP_REGISTER_DOUBLE
&& len
== 8)
4646 /* We need to break a 64bit float in two 32 bit halves and
4647 spread them across a floating-point register pair. */
4648 lo
->buf_offset
= TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
? 4 : 0;
4649 hi
->buf_offset
= TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
? 0 : 4;
4650 lo
->reg_offset
= ((TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
4651 && REGISTER_RAW_SIZE (FP0_REGNUM
) == 8)
4653 hi
->reg_offset
= lo
->reg_offset
;
4654 lo
->reg
= FP0_REGNUM
+ 0;
4655 hi
->reg
= FP0_REGNUM
+ 1;
4661 /* The floating point value fits in a single floating-point
4663 lo
->reg_offset
= ((TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
4664 && REGISTER_RAW_SIZE (FP0_REGNUM
) == 8
4667 lo
->reg
= FP0_REGNUM
;
4678 /* Locate a result possibly spread across two registers. */
4680 lo
->reg
= regnum
+ 0;
4681 hi
->reg
= regnum
+ 1;
4682 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
4683 && len
< MIPS_SAVED_REGSIZE
)
4685 /* "un-left-justify" the value in the low register */
4686 lo
->reg_offset
= MIPS_SAVED_REGSIZE
- len
;
4691 else if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
4692 && len
> MIPS_SAVED_REGSIZE
/* odd-size structs */
4693 && len
< MIPS_SAVED_REGSIZE
* 2
4694 && (TYPE_CODE (valtype
) == TYPE_CODE_STRUCT
||
4695 TYPE_CODE (valtype
) == TYPE_CODE_UNION
))
4697 /* "un-left-justify" the value spread across two registers. */
4698 lo
->reg_offset
= 2 * MIPS_SAVED_REGSIZE
- len
;
4699 lo
->len
= MIPS_SAVED_REGSIZE
- lo
->reg_offset
;
4701 hi
->len
= len
- lo
->len
;
4705 /* Only perform a partial copy of the second register. */
4708 if (len
> MIPS_SAVED_REGSIZE
)
4710 lo
->len
= MIPS_SAVED_REGSIZE
;
4711 hi
->len
= len
- MIPS_SAVED_REGSIZE
;
4719 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
4720 && REGISTER_RAW_SIZE (regnum
) == 8
4721 && MIPS_SAVED_REGSIZE
== 4)
4723 /* Account for the fact that only the least-signficant part
4724 of the register is being used */
4725 lo
->reg_offset
+= 4;
4726 hi
->reg_offset
+= 4;
4729 hi
->buf_offset
= lo
->len
;
4733 /* Given a return value in `regbuf' with a type `valtype', extract and
4734 copy its value into `valbuf'. */
4737 mips_eabi_extract_return_value (struct type
*valtype
,
4741 struct return_value_word lo
;
4742 struct return_value_word hi
;
4743 return_value_location (valtype
, &hi
, &lo
);
4745 memcpy (valbuf
+ lo
.buf_offset
,
4746 regbuf
+ REGISTER_BYTE (lo
.reg
) + lo
.reg_offset
,
4750 memcpy (valbuf
+ hi
.buf_offset
,
4751 regbuf
+ REGISTER_BYTE (hi
.reg
) + hi
.reg_offset
,
4756 mips_o64_extract_return_value (struct type
*valtype
,
4760 struct return_value_word lo
;
4761 struct return_value_word hi
;
4762 return_value_location (valtype
, &hi
, &lo
);
4764 memcpy (valbuf
+ lo
.buf_offset
,
4765 regbuf
+ REGISTER_BYTE (lo
.reg
) + lo
.reg_offset
,
4769 memcpy (valbuf
+ hi
.buf_offset
,
4770 regbuf
+ REGISTER_BYTE (hi
.reg
) + hi
.reg_offset
,
4774 /* Given a return value in `valbuf' with a type `valtype', write it's
4775 value into the appropriate register. */
4778 mips_eabi_store_return_value (struct type
*valtype
, char *valbuf
)
4780 char raw_buffer
[MAX_REGISTER_SIZE
];
4781 struct return_value_word lo
;
4782 struct return_value_word hi
;
4783 return_value_location (valtype
, &hi
, &lo
);
4785 memset (raw_buffer
, 0, sizeof (raw_buffer
));
4786 memcpy (raw_buffer
+ lo
.reg_offset
, valbuf
+ lo
.buf_offset
, lo
.len
);
4787 deprecated_write_register_bytes (REGISTER_BYTE (lo
.reg
), raw_buffer
,
4788 REGISTER_RAW_SIZE (lo
.reg
));
4792 memset (raw_buffer
, 0, sizeof (raw_buffer
));
4793 memcpy (raw_buffer
+ hi
.reg_offset
, valbuf
+ hi
.buf_offset
, hi
.len
);
4794 deprecated_write_register_bytes (REGISTER_BYTE (hi
.reg
), raw_buffer
,
4795 REGISTER_RAW_SIZE (hi
.reg
));
4800 mips_o64_store_return_value (struct type
*valtype
, char *valbuf
)
4802 char raw_buffer
[MAX_REGISTER_SIZE
];
4803 struct return_value_word lo
;
4804 struct return_value_word hi
;
4805 return_value_location (valtype
, &hi
, &lo
);
4807 memset (raw_buffer
, 0, sizeof (raw_buffer
));
4808 memcpy (raw_buffer
+ lo
.reg_offset
, valbuf
+ lo
.buf_offset
, lo
.len
);
4809 deprecated_write_register_bytes (REGISTER_BYTE (lo
.reg
), raw_buffer
,
4810 REGISTER_RAW_SIZE (lo
.reg
));
4814 memset (raw_buffer
, 0, sizeof (raw_buffer
));
4815 memcpy (raw_buffer
+ hi
.reg_offset
, valbuf
+ hi
.buf_offset
, hi
.len
);
4816 deprecated_write_register_bytes (REGISTER_BYTE (hi
.reg
), raw_buffer
,
4817 REGISTER_RAW_SIZE (hi
.reg
));
4821 /* O32 ABI stuff. */
4824 mips_o32_xfer_return_value (struct type
*type
,
4825 struct regcache
*regcache
,
4826 bfd_byte
*in
, const bfd_byte
*out
)
4828 struct gdbarch_tdep
*tdep
= gdbarch_tdep (current_gdbarch
);
4829 if (TYPE_CODE (type
) == TYPE_CODE_FLT
4830 && TYPE_LENGTH (type
) == 4
4831 && tdep
->mips_fpu_type
!= MIPS_FPU_NONE
)
4833 /* A single-precision floating-point value. It fits in the
4834 least significant part of FP0. */
4836 fprintf_unfiltered (gdb_stderr
, "Return float in $fp0\n");
4837 mips_xfer_register (regcache
, NUM_REGS
+ FP0_REGNUM
, TYPE_LENGTH (type
),
4838 TARGET_BYTE_ORDER
, in
, out
, 0);
4840 else if (TYPE_CODE (type
) == TYPE_CODE_FLT
4841 && TYPE_LENGTH (type
) == 8
4842 && tdep
->mips_fpu_type
!= MIPS_FPU_NONE
)
4844 /* A double-precision floating-point value. The most
4845 significant part goes in FP1, and the least significant in
4848 fprintf_unfiltered (gdb_stderr
, "Return float in $fp1/$fp0\n");
4849 switch (TARGET_BYTE_ORDER
)
4851 case BFD_ENDIAN_LITTLE
:
4852 mips_xfer_register (regcache
, NUM_REGS
+ FP0_REGNUM
+ 0, 4,
4853 TARGET_BYTE_ORDER
, in
, out
, 0);
4854 mips_xfer_register (regcache
, NUM_REGS
+ FP0_REGNUM
+ 1, 4,
4855 TARGET_BYTE_ORDER
, in
, out
, 4);
4857 case BFD_ENDIAN_BIG
:
4858 mips_xfer_register (regcache
, NUM_REGS
+ FP0_REGNUM
+ 1, 4,
4859 TARGET_BYTE_ORDER
, in
, out
, 0);
4860 mips_xfer_register (regcache
, NUM_REGS
+ FP0_REGNUM
+ 0, 4,
4861 TARGET_BYTE_ORDER
, in
, out
, 4);
4864 internal_error (__FILE__
, __LINE__
, "bad switch");
4868 else if (TYPE_CODE (type
) == TYPE_CODE_STRUCT
4869 && TYPE_NFIELDS (type
) <= 2
4870 && TYPE_NFIELDS (type
) >= 1
4871 && ((TYPE_NFIELDS (type
) == 1
4872 && (TYPE_CODE (TYPE_FIELD_TYPE (type
, 0))
4874 || (TYPE_NFIELDS (type
) == 2
4875 && (TYPE_CODE (TYPE_FIELD_TYPE (type
, 0))
4877 && (TYPE_CODE (TYPE_FIELD_TYPE (type
, 1))
4879 && tdep
->mips_fpu_type
!= MIPS_FPU_NONE
)
4881 /* A struct that contains one or two floats. Each value is part
4882 in the least significant part of their floating point
4884 bfd_byte reg
[MAX_REGISTER_SIZE
];
4887 for (field
= 0, regnum
= FP0_REGNUM
;
4888 field
< TYPE_NFIELDS (type
);
4889 field
++, regnum
+= 2)
4891 int offset
= (FIELD_BITPOS (TYPE_FIELDS (type
)[field
])
4894 fprintf_unfiltered (gdb_stderr
, "Return float struct+%d\n", offset
);
4895 mips_xfer_register (regcache
, NUM_REGS
+ regnum
,
4896 TYPE_LENGTH (TYPE_FIELD_TYPE (type
, field
)),
4897 TARGET_BYTE_ORDER
, in
, out
, offset
);
4902 else if (TYPE_CODE (type
) == TYPE_CODE_STRUCT
4903 || TYPE_CODE (type
) == TYPE_CODE_UNION
)
4905 /* A structure or union. Extract the left justified value,
4906 regardless of the byte order. I.e. DO NOT USE
4910 for (offset
= 0, regnum
= V0_REGNUM
;
4911 offset
< TYPE_LENGTH (type
);
4912 offset
+= REGISTER_RAW_SIZE (regnum
), regnum
++)
4914 int xfer
= REGISTER_RAW_SIZE (regnum
);
4915 if (offset
+ xfer
> TYPE_LENGTH (type
))
4916 xfer
= TYPE_LENGTH (type
) - offset
;
4918 fprintf_unfiltered (gdb_stderr
, "Return struct+%d:%d in $%d\n",
4919 offset
, xfer
, regnum
);
4920 mips_xfer_register (regcache
, NUM_REGS
+ regnum
, xfer
,
4921 BFD_ENDIAN_UNKNOWN
, in
, out
, offset
);
4927 /* A scalar extract each part but least-significant-byte
4928 justified. o32 thinks registers are 4 byte, regardless of
4929 the ISA. mips_stack_argsize controls this. */
4932 for (offset
= 0, regnum
= V0_REGNUM
;
4933 offset
< TYPE_LENGTH (type
);
4934 offset
+= mips_stack_argsize (), regnum
++)
4936 int xfer
= mips_stack_argsize ();
4938 if (offset
+ xfer
> TYPE_LENGTH (type
))
4939 xfer
= TYPE_LENGTH (type
) - offset
;
4941 fprintf_unfiltered (gdb_stderr
, "Return scalar+%d:%d in $%d\n",
4942 offset
, xfer
, regnum
);
4943 mips_xfer_register (regcache
, NUM_REGS
+ regnum
, xfer
,
4944 TARGET_BYTE_ORDER
, in
, out
, offset
);
4950 mips_o32_extract_return_value (struct type
*type
,
4951 struct regcache
*regcache
,
4954 mips_o32_xfer_return_value (type
, regcache
, valbuf
, NULL
);
4958 mips_o32_store_return_value (struct type
*type
, char *valbuf
)
4960 mips_o32_xfer_return_value (type
, current_regcache
, NULL
, valbuf
);
4963 /* N32/N44 ABI stuff. */
4966 mips_n32n64_xfer_return_value (struct type
*type
,
4967 struct regcache
*regcache
,
4968 bfd_byte
*in
, const bfd_byte
*out
)
4970 struct gdbarch_tdep
*tdep
= gdbarch_tdep (current_gdbarch
);
4971 if (TYPE_CODE (type
) == TYPE_CODE_FLT
4972 && tdep
->mips_fpu_type
!= MIPS_FPU_NONE
)
4974 /* A floating-point value belongs in the least significant part
4977 fprintf_unfiltered (gdb_stderr
, "Return float in $fp0\n");
4978 mips_xfer_register (regcache
, NUM_REGS
+ FP0_REGNUM
, TYPE_LENGTH (type
),
4979 TARGET_BYTE_ORDER
, in
, out
, 0);
4981 else if (TYPE_CODE (type
) == TYPE_CODE_STRUCT
4982 && TYPE_NFIELDS (type
) <= 2
4983 && TYPE_NFIELDS (type
) >= 1
4984 && ((TYPE_NFIELDS (type
) == 1
4985 && (TYPE_CODE (TYPE_FIELD_TYPE (type
, 0))
4987 || (TYPE_NFIELDS (type
) == 2
4988 && (TYPE_CODE (TYPE_FIELD_TYPE (type
, 0))
4990 && (TYPE_CODE (TYPE_FIELD_TYPE (type
, 1))
4992 && tdep
->mips_fpu_type
!= MIPS_FPU_NONE
)
4994 /* A struct that contains one or two floats. Each value is part
4995 in the least significant part of their floating point
4997 bfd_byte reg
[MAX_REGISTER_SIZE
];
5000 for (field
= 0, regnum
= FP0_REGNUM
;
5001 field
< TYPE_NFIELDS (type
);
5002 field
++, regnum
+= 2)
5004 int offset
= (FIELD_BITPOS (TYPE_FIELDS (type
)[field
])
5007 fprintf_unfiltered (gdb_stderr
, "Return float struct+%d\n", offset
);
5008 mips_xfer_register (regcache
, NUM_REGS
+ regnum
,
5009 TYPE_LENGTH (TYPE_FIELD_TYPE (type
, field
)),
5010 TARGET_BYTE_ORDER
, in
, out
, offset
);
5013 else if (TYPE_CODE (type
) == TYPE_CODE_STRUCT
5014 || TYPE_CODE (type
) == TYPE_CODE_UNION
)
5016 /* A structure or union. Extract the left justified value,
5017 regardless of the byte order. I.e. DO NOT USE
5021 for (offset
= 0, regnum
= V0_REGNUM
;
5022 offset
< TYPE_LENGTH (type
);
5023 offset
+= REGISTER_RAW_SIZE (regnum
), regnum
++)
5025 int xfer
= REGISTER_RAW_SIZE (regnum
);
5026 if (offset
+ xfer
> TYPE_LENGTH (type
))
5027 xfer
= TYPE_LENGTH (type
) - offset
;
5029 fprintf_unfiltered (gdb_stderr
, "Return struct+%d:%d in $%d\n",
5030 offset
, xfer
, regnum
);
5031 mips_xfer_register (regcache
, NUM_REGS
+ regnum
, xfer
,
5032 BFD_ENDIAN_UNKNOWN
, in
, out
, offset
);
5037 /* A scalar extract each part but least-significant-byte
5041 for (offset
= 0, regnum
= V0_REGNUM
;
5042 offset
< TYPE_LENGTH (type
);
5043 offset
+= REGISTER_RAW_SIZE (regnum
), regnum
++)
5045 int xfer
= REGISTER_RAW_SIZE (regnum
);
5047 if (offset
+ xfer
> TYPE_LENGTH (type
))
5048 xfer
= TYPE_LENGTH (type
) - offset
;
5050 fprintf_unfiltered (gdb_stderr
, "Return scalar+%d:%d in $%d\n",
5051 offset
, xfer
, regnum
);
5052 mips_xfer_register (regcache
, NUM_REGS
+ regnum
, xfer
,
5053 TARGET_BYTE_ORDER
, in
, out
, offset
);
5059 mips_n32n64_extract_return_value (struct type
*type
,
5060 struct regcache
*regcache
,
5063 mips_n32n64_xfer_return_value (type
, regcache
, valbuf
, NULL
);
5067 mips_n32n64_store_return_value (struct type
*type
, char *valbuf
)
5069 mips_n32n64_xfer_return_value (type
, current_regcache
, NULL
, valbuf
);
5073 mips_extract_struct_value_address (struct regcache
*regcache
)
5075 /* FIXME: This will only work at random. The caller passes the
5076 struct_return address in V0, but it is not preserved. It may
5077 still be there, or this may be a random value. */
5080 regcache_cooked_read_signed (regcache
, V0_REGNUM
, &val
);
5084 /* Exported procedure: Is PC in the signal trampoline code */
5087 mips_pc_in_sigtramp (CORE_ADDR pc
, char *ignore
)
5089 if (sigtramp_address
== 0)
5091 return (pc
>= sigtramp_address
&& pc
< sigtramp_end
);
5094 /* Root of all "set mips "/"show mips " commands. This will eventually be
5095 used for all MIPS-specific commands. */
5098 show_mips_command (char *args
, int from_tty
)
5100 help_list (showmipscmdlist
, "show mips ", all_commands
, gdb_stdout
);
5104 set_mips_command (char *args
, int from_tty
)
5106 printf_unfiltered ("\"set mips\" must be followed by an appropriate subcommand.\n");
5107 help_list (setmipscmdlist
, "set mips ", all_commands
, gdb_stdout
);
5110 /* Commands to show/set the MIPS FPU type. */
5113 show_mipsfpu_command (char *args
, int from_tty
)
5116 switch (MIPS_FPU_TYPE
)
5118 case MIPS_FPU_SINGLE
:
5119 fpu
= "single-precision";
5121 case MIPS_FPU_DOUBLE
:
5122 fpu
= "double-precision";
5125 fpu
= "absent (none)";
5128 internal_error (__FILE__
, __LINE__
, "bad switch");
5130 if (mips_fpu_type_auto
)
5131 printf_unfiltered ("The MIPS floating-point coprocessor is set automatically (currently %s)\n",
5134 printf_unfiltered ("The MIPS floating-point coprocessor is assumed to be %s\n",
5140 set_mipsfpu_command (char *args
, int from_tty
)
5142 printf_unfiltered ("\"set mipsfpu\" must be followed by \"double\", \"single\",\"none\" or \"auto\".\n");
5143 show_mipsfpu_command (args
, from_tty
);
5147 set_mipsfpu_single_command (char *args
, int from_tty
)
5149 mips_fpu_type
= MIPS_FPU_SINGLE
;
5150 mips_fpu_type_auto
= 0;
5151 gdbarch_tdep (current_gdbarch
)->mips_fpu_type
= MIPS_FPU_SINGLE
;
5155 set_mipsfpu_double_command (char *args
, int from_tty
)
5157 mips_fpu_type
= MIPS_FPU_DOUBLE
;
5158 mips_fpu_type_auto
= 0;
5159 gdbarch_tdep (current_gdbarch
)->mips_fpu_type
= MIPS_FPU_DOUBLE
;
5163 set_mipsfpu_none_command (char *args
, int from_tty
)
5165 mips_fpu_type
= MIPS_FPU_NONE
;
5166 mips_fpu_type_auto
= 0;
5167 gdbarch_tdep (current_gdbarch
)->mips_fpu_type
= MIPS_FPU_NONE
;
5171 set_mipsfpu_auto_command (char *args
, int from_tty
)
5173 mips_fpu_type_auto
= 1;
5176 /* Command to set the processor type. */
5179 mips_set_processor_type_command (char *args
, int from_tty
)
5183 if (tmp_mips_processor_type
== NULL
|| *tmp_mips_processor_type
== '\0')
5185 printf_unfiltered ("The known MIPS processor types are as follows:\n\n");
5186 for (i
= 0; mips_processor_type_table
[i
].name
!= NULL
; ++i
)
5187 printf_unfiltered ("%s\n", mips_processor_type_table
[i
].name
);
5189 /* Restore the value. */
5190 tmp_mips_processor_type
= xstrdup (mips_processor_type
);
5195 if (!mips_set_processor_type (tmp_mips_processor_type
))
5197 error ("Unknown processor type `%s'.", tmp_mips_processor_type
);
5198 /* Restore its value. */
5199 tmp_mips_processor_type
= xstrdup (mips_processor_type
);
5204 mips_show_processor_type_command (char *args
, int from_tty
)
5208 /* Modify the actual processor type. */
5211 mips_set_processor_type (char *str
)
5218 for (i
= 0; mips_processor_type_table
[i
].name
!= NULL
; ++i
)
5220 if (strcasecmp (str
, mips_processor_type_table
[i
].name
) == 0)
5222 mips_processor_type
= str
;
5223 mips_processor_reg_names
= mips_processor_type_table
[i
].regnames
;
5225 /* FIXME tweak fpu flag too */
5232 /* Attempt to identify the particular processor model by reading the
5236 mips_read_processor_type (void)
5240 prid
= read_register (PRID_REGNUM
);
5242 if ((prid
& ~0xf) == 0x700)
5243 return savestring ("r3041", strlen ("r3041"));
5248 /* Just like reinit_frame_cache, but with the right arguments to be
5249 callable as an sfunc. */
5252 reinit_frame_cache_sfunc (char *args
, int from_tty
,
5253 struct cmd_list_element
*c
)
5255 reinit_frame_cache ();
5259 gdb_print_insn_mips (bfd_vma memaddr
, disassemble_info
*info
)
5261 mips_extra_func_info_t proc_desc
;
5263 /* Search for the function containing this address. Set the low bit
5264 of the address when searching, in case we were given an even address
5265 that is the start of a 16-bit function. If we didn't do this,
5266 the search would fail because the symbol table says the function
5267 starts at an odd address, i.e. 1 byte past the given address. */
5268 memaddr
= ADDR_BITS_REMOVE (memaddr
);
5269 proc_desc
= non_heuristic_proc_desc (make_mips16_addr (memaddr
), NULL
);
5271 /* Make an attempt to determine if this is a 16-bit function. If
5272 the procedure descriptor exists and the address therein is odd,
5273 it's definitely a 16-bit function. Otherwise, we have to just
5274 guess that if the address passed in is odd, it's 16-bits. */
5275 /* FIXME: cagney/2003-06-26: Is this even necessary? The
5276 disassembler needs to be able to locally determine the ISA, and
5277 not rely on GDB. Otherwize the stand-alone 'objdump -d' will not
5281 if (pc_is_mips16 (PROC_LOW_ADDR (proc_desc
)))
5282 info
->mach
= bfd_mach_mips16
;
5286 if (pc_is_mips16 (memaddr
))
5287 info
->mach
= bfd_mach_mips16
;
5290 /* Round down the instruction address to the appropriate boundary. */
5291 memaddr
&= (info
->mach
== bfd_mach_mips16
? ~1 : ~3);
5293 /* Call the appropriate disassembler based on the target endian-ness. */
5294 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
5295 return print_insn_big_mips (memaddr
, info
);
5297 return print_insn_little_mips (memaddr
, info
);
5300 /* This function implements the BREAKPOINT_FROM_PC macro. It uses the program
5301 counter value to determine whether a 16- or 32-bit breakpoint should be
5302 used. It returns a pointer to a string of bytes that encode a breakpoint
5303 instruction, stores the length of the string to *lenptr, and adjusts pc
5304 (if necessary) to point to the actual memory location where the
5305 breakpoint should be inserted. */
5307 static const unsigned char *
5308 mips_breakpoint_from_pc (CORE_ADDR
* pcptr
, int *lenptr
)
5310 if (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
)
5312 if (pc_is_mips16 (*pcptr
))
5314 static unsigned char mips16_big_breakpoint
[] = {0xe8, 0xa5};
5315 *pcptr
= unmake_mips16_addr (*pcptr
);
5316 *lenptr
= sizeof (mips16_big_breakpoint
);
5317 return mips16_big_breakpoint
;
5321 /* The IDT board uses an unusual breakpoint value, and
5322 sometimes gets confused when it sees the usual MIPS
5323 breakpoint instruction. */
5324 static unsigned char big_breakpoint
[] = {0, 0x5, 0, 0xd};
5325 static unsigned char pmon_big_breakpoint
[] = {0, 0, 0, 0xd};
5326 static unsigned char idt_big_breakpoint
[] = {0, 0, 0x0a, 0xd};
5328 *lenptr
= sizeof (big_breakpoint
);
5330 if (strcmp (target_shortname
, "mips") == 0)
5331 return idt_big_breakpoint
;
5332 else if (strcmp (target_shortname
, "ddb") == 0
5333 || strcmp (target_shortname
, "pmon") == 0
5334 || strcmp (target_shortname
, "lsi") == 0)
5335 return pmon_big_breakpoint
;
5337 return big_breakpoint
;
5342 if (pc_is_mips16 (*pcptr
))
5344 static unsigned char mips16_little_breakpoint
[] = {0xa5, 0xe8};
5345 *pcptr
= unmake_mips16_addr (*pcptr
);
5346 *lenptr
= sizeof (mips16_little_breakpoint
);
5347 return mips16_little_breakpoint
;
5351 static unsigned char little_breakpoint
[] = {0xd, 0, 0x5, 0};
5352 static unsigned char pmon_little_breakpoint
[] = {0xd, 0, 0, 0};
5353 static unsigned char idt_little_breakpoint
[] = {0xd, 0x0a, 0, 0};
5355 *lenptr
= sizeof (little_breakpoint
);
5357 if (strcmp (target_shortname
, "mips") == 0)
5358 return idt_little_breakpoint
;
5359 else if (strcmp (target_shortname
, "ddb") == 0
5360 || strcmp (target_shortname
, "pmon") == 0
5361 || strcmp (target_shortname
, "lsi") == 0)
5362 return pmon_little_breakpoint
;
5364 return little_breakpoint
;
5369 /* If PC is in a mips16 call or return stub, return the address of the target
5370 PC, which is either the callee or the caller. There are several
5371 cases which must be handled:
5373 * If the PC is in __mips16_ret_{d,s}f, this is a return stub and the
5374 target PC is in $31 ($ra).
5375 * If the PC is in __mips16_call_stub_{1..10}, this is a call stub
5376 and the target PC is in $2.
5377 * If the PC at the start of __mips16_call_stub_{s,d}f_{0..10}, i.e.
5378 before the jal instruction, this is effectively a call stub
5379 and the the target PC is in $2. Otherwise this is effectively
5380 a return stub and the target PC is in $18.
5382 See the source code for the stubs in gcc/config/mips/mips16.S for
5385 This function implements the SKIP_TRAMPOLINE_CODE macro.
5389 mips_skip_stub (CORE_ADDR pc
)
5392 CORE_ADDR start_addr
;
5394 /* Find the starting address and name of the function containing the PC. */
5395 if (find_pc_partial_function (pc
, &name
, &start_addr
, NULL
) == 0)
5398 /* If the PC is in __mips16_ret_{d,s}f, this is a return stub and the
5399 target PC is in $31 ($ra). */
5400 if (strcmp (name
, "__mips16_ret_sf") == 0
5401 || strcmp (name
, "__mips16_ret_df") == 0)
5402 return read_signed_register (RA_REGNUM
);
5404 if (strncmp (name
, "__mips16_call_stub_", 19) == 0)
5406 /* If the PC is in __mips16_call_stub_{1..10}, this is a call stub
5407 and the target PC is in $2. */
5408 if (name
[19] >= '0' && name
[19] <= '9')
5409 return read_signed_register (2);
5411 /* If the PC at the start of __mips16_call_stub_{s,d}f_{0..10}, i.e.
5412 before the jal instruction, this is effectively a call stub
5413 and the the target PC is in $2. Otherwise this is effectively
5414 a return stub and the target PC is in $18. */
5415 else if (name
[19] == 's' || name
[19] == 'd')
5417 if (pc
== start_addr
)
5419 /* Check if the target of the stub is a compiler-generated
5420 stub. Such a stub for a function bar might have a name
5421 like __fn_stub_bar, and might look like this:
5426 la $1,bar (becomes a lui/addiu pair)
5428 So scan down to the lui/addi and extract the target
5429 address from those two instructions. */
5431 CORE_ADDR target_pc
= read_signed_register (2);
5435 /* See if the name of the target function is __fn_stub_*. */
5436 if (find_pc_partial_function (target_pc
, &name
, NULL
, NULL
) == 0)
5438 if (strncmp (name
, "__fn_stub_", 10) != 0
5439 && strcmp (name
, "etext") != 0
5440 && strcmp (name
, "_etext") != 0)
5443 /* Scan through this _fn_stub_ code for the lui/addiu pair.
5444 The limit on the search is arbitrarily set to 20
5445 instructions. FIXME. */
5446 for (i
= 0, pc
= 0; i
< 20; i
++, target_pc
+= MIPS_INSTLEN
)
5448 inst
= mips_fetch_instruction (target_pc
);
5449 if ((inst
& 0xffff0000) == 0x3c010000) /* lui $at */
5450 pc
= (inst
<< 16) & 0xffff0000; /* high word */
5451 else if ((inst
& 0xffff0000) == 0x24210000) /* addiu $at */
5452 return pc
| (inst
& 0xffff); /* low word */
5455 /* Couldn't find the lui/addui pair, so return stub address. */
5459 /* This is the 'return' part of a call stub. The return
5460 address is in $r18. */
5461 return read_signed_register (18);
5464 return 0; /* not a stub */
5468 /* Return non-zero if the PC is inside a call thunk (aka stub or trampoline).
5469 This implements the IN_SOLIB_CALL_TRAMPOLINE macro. */
5472 mips_in_call_stub (CORE_ADDR pc
, char *name
)
5474 CORE_ADDR start_addr
;
5476 /* Find the starting address of the function containing the PC. If the
5477 caller didn't give us a name, look it up at the same time. */
5478 if (find_pc_partial_function (pc
, name
? NULL
: &name
, &start_addr
, NULL
) == 0)
5481 if (strncmp (name
, "__mips16_call_stub_", 19) == 0)
5483 /* If the PC is in __mips16_call_stub_{1..10}, this is a call stub. */
5484 if (name
[19] >= '0' && name
[19] <= '9')
5486 /* If the PC at the start of __mips16_call_stub_{s,d}f_{0..10}, i.e.
5487 before the jal instruction, this is effectively a call stub. */
5488 else if (name
[19] == 's' || name
[19] == 'd')
5489 return pc
== start_addr
;
5492 return 0; /* not a stub */
5496 /* Return non-zero if the PC is inside a return thunk (aka stub or trampoline).
5497 This implements the IN_SOLIB_RETURN_TRAMPOLINE macro. */
5500 mips_in_return_stub (CORE_ADDR pc
, char *name
)
5502 CORE_ADDR start_addr
;
5504 /* Find the starting address of the function containing the PC. */
5505 if (find_pc_partial_function (pc
, NULL
, &start_addr
, NULL
) == 0)
5508 /* If the PC is in __mips16_ret_{d,s}f, this is a return stub. */
5509 if (strcmp (name
, "__mips16_ret_sf") == 0
5510 || strcmp (name
, "__mips16_ret_df") == 0)
5513 /* If the PC is in __mips16_call_stub_{s,d}f_{0..10} but not at the start,
5514 i.e. after the jal instruction, this is effectively a return stub. */
5515 if (strncmp (name
, "__mips16_call_stub_", 19) == 0
5516 && (name
[19] == 's' || name
[19] == 'd')
5517 && pc
!= start_addr
)
5520 return 0; /* not a stub */
5524 /* Return non-zero if the PC is in a library helper function that should
5525 be ignored. This implements the IGNORE_HELPER_CALL macro. */
5528 mips_ignore_helper (CORE_ADDR pc
)
5532 /* Find the starting address and name of the function containing the PC. */
5533 if (find_pc_partial_function (pc
, &name
, NULL
, NULL
) == 0)
5536 /* If the PC is in __mips16_ret_{d,s}f, this is a library helper function
5537 that we want to ignore. */
5538 return (strcmp (name
, "__mips16_ret_sf") == 0
5539 || strcmp (name
, "__mips16_ret_df") == 0);
5543 /* Return a location where we can set a breakpoint that will be hit
5544 when an inferior function call returns. This is normally the
5545 program's entry point. Executables that don't have an entry
5546 point (e.g. programs in ROM) should define a symbol __CALL_DUMMY_ADDRESS
5547 whose address is the location where the breakpoint should be placed. */
5550 mips_call_dummy_address (void)
5552 struct minimal_symbol
*sym
;
5554 sym
= lookup_minimal_symbol ("__CALL_DUMMY_ADDRESS", NULL
, NULL
);
5556 return SYMBOL_VALUE_ADDRESS (sym
);
5558 return entry_point_address ();
5562 /* When debugging a 64 MIPS target running a 32 bit ABI, the size of
5563 the register stored on the stack (32) is different to its real raw
5564 size (64). The below ensures that registers are fetched from the
5565 stack using their ABI size and then stored into the RAW_BUFFER
5566 using their raw size.
5568 The alternative to adding this function would be to add an ABI
5569 macro - REGISTER_STACK_SIZE(). */
5572 mips_get_saved_register (char *raw_buffer
,
5575 struct frame_info
*frame
,
5577 enum lval_type
*lvalp
)
5580 enum lval_type lvalx
;
5584 /* Always a pseudo. */
5585 gdb_assert (regnum
>= NUM_REGS
);
5587 /* Make certain that all needed parameters are present. */
5592 if (optimizedp
== NULL
)
5593 optimizedp
= &optimizedx
;
5595 if ((regnum
% NUM_REGS
) == SP_REGNUM
)
5596 /* The SP_REGNUM is special, its value is stored in saved_regs.
5597 In fact, it is so special that it can even only be fetched
5598 using a raw register number! Once this code as been converted
5599 to frame-unwind the problem goes away. */
5600 frame_register_unwind (deprecated_get_next_frame_hack (frame
),
5601 regnum
% NUM_REGS
, optimizedp
, lvalp
, addrp
,
5602 &realnumx
, raw_buffer
);
5604 /* Get it from the next frame. */
5605 frame_register_unwind (deprecated_get_next_frame_hack (frame
),
5606 regnum
, optimizedp
, lvalp
, addrp
,
5607 &realnumx
, raw_buffer
);
5610 /* Immediately after a function call, return the saved pc.
5611 Can't always go through the frames for this because on some machines
5612 the new frame is not set up until the new function executes
5613 some instructions. */
5616 mips_saved_pc_after_call (struct frame_info
*frame
)
5618 return read_signed_register (RA_REGNUM
);
5622 /* Convert a dbx stab register number (from `r' declaration) to a GDB
5623 [1 * NUM_REGS .. 2 * NUM_REGS) REGNUM. */
5626 mips_stab_reg_to_regnum (int num
)
5629 if (num
>= 0 && num
< 32)
5631 else if (num
>= 38 && num
< 70)
5632 regnum
= num
+ FP0_REGNUM
- 38;
5638 /* This will hopefully (eventually) provoke a warning. Should
5639 we be calling complaint() here? */
5640 return NUM_REGS
+ NUM_PSEUDO_REGS
;
5641 return NUM_REGS
+ regnum
;
5645 /* Convert a dwarf, dwarf2, or ecoff register number to a GDB [1 *
5646 NUM_REGS .. 2 * NUM_REGS) REGNUM. */
5649 mips_dwarf_dwarf2_ecoff_reg_to_regnum (int num
)
5652 if (num
>= 0 && num
< 32)
5654 else if (num
>= 32 && num
< 64)
5655 regnum
= num
+ FP0_REGNUM
- 32;
5661 /* This will hopefully (eventually) provoke a warning. Should we
5662 be calling complaint() here? */
5663 return NUM_REGS
+ NUM_PSEUDO_REGS
;
5664 return NUM_REGS
+ regnum
;
5668 mips_register_sim_regno (int regnum
)
5670 /* Only makes sense to supply raw registers. */
5671 gdb_assert (regnum
>= 0 && regnum
< NUM_REGS
);
5672 /* FIXME: cagney/2002-05-13: Need to look at the pseudo register to
5673 decide if it is valid. Should instead define a standard sim/gdb
5674 register numbering scheme. */
5675 if (REGISTER_NAME (NUM_REGS
+ regnum
) != NULL
5676 && REGISTER_NAME (NUM_REGS
+ regnum
)[0] != '\0')
5679 return LEGACY_SIM_REGNO_IGNORE
;
5683 /* Convert an integer into an address. By first converting the value
5684 into a pointer and then extracting it signed, the address is
5685 guarenteed to be correctly sign extended. */
5688 mips_integer_to_address (struct type
*type
, void *buf
)
5690 char *tmp
= alloca (TYPE_LENGTH (builtin_type_void_data_ptr
));
5691 LONGEST val
= unpack_long (type
, buf
);
5692 store_signed_integer (tmp
, TYPE_LENGTH (builtin_type_void_data_ptr
), val
);
5693 return extract_signed_integer (tmp
,
5694 TYPE_LENGTH (builtin_type_void_data_ptr
));
5698 mips_find_abi_section (bfd
*abfd
, asection
*sect
, void *obj
)
5700 enum mips_abi
*abip
= (enum mips_abi
*) obj
;
5701 const char *name
= bfd_get_section_name (abfd
, sect
);
5703 if (*abip
!= MIPS_ABI_UNKNOWN
)
5706 if (strncmp (name
, ".mdebug.", 8) != 0)
5709 if (strcmp (name
, ".mdebug.abi32") == 0)
5710 *abip
= MIPS_ABI_O32
;
5711 else if (strcmp (name
, ".mdebug.abiN32") == 0)
5712 *abip
= MIPS_ABI_N32
;
5713 else if (strcmp (name
, ".mdebug.abi64") == 0)
5714 *abip
= MIPS_ABI_N64
;
5715 else if (strcmp (name
, ".mdebug.abiO64") == 0)
5716 *abip
= MIPS_ABI_O64
;
5717 else if (strcmp (name
, ".mdebug.eabi32") == 0)
5718 *abip
= MIPS_ABI_EABI32
;
5719 else if (strcmp (name
, ".mdebug.eabi64") == 0)
5720 *abip
= MIPS_ABI_EABI64
;
5722 warning ("unsupported ABI %s.", name
+ 8);
5725 static enum mips_abi
5726 global_mips_abi (void)
5730 for (i
= 0; mips_abi_strings
[i
] != NULL
; i
++)
5731 if (mips_abi_strings
[i
] == mips_abi_string
)
5732 return (enum mips_abi
) i
;
5734 internal_error (__FILE__
, __LINE__
,
5735 "unknown ABI string");
5738 static struct gdbarch
*
5739 mips_gdbarch_init (struct gdbarch_info info
,
5740 struct gdbarch_list
*arches
)
5742 struct gdbarch
*gdbarch
;
5743 struct gdbarch_tdep
*tdep
;
5745 enum mips_abi mips_abi
, found_abi
, wanted_abi
;
5748 /* Reset the disassembly info, in case it was set to something
5750 deprecated_tm_print_insn_info
.flavour
= bfd_target_unknown_flavour
;
5751 deprecated_tm_print_insn_info
.arch
= bfd_arch_unknown
;
5752 deprecated_tm_print_insn_info
.mach
= 0;
5758 /* First of all, extract the elf_flags, if available. */
5759 if (bfd_get_flavour (info
.abfd
) == bfd_target_elf_flavour
)
5760 elf_flags
= elf_elfheader (info
.abfd
)->e_flags
;
5763 /* Check ELF_FLAGS to see if it specifies the ABI being used. */
5764 switch ((elf_flags
& EF_MIPS_ABI
))
5766 case E_MIPS_ABI_O32
:
5767 mips_abi
= MIPS_ABI_O32
;
5769 case E_MIPS_ABI_O64
:
5770 mips_abi
= MIPS_ABI_O64
;
5772 case E_MIPS_ABI_EABI32
:
5773 mips_abi
= MIPS_ABI_EABI32
;
5775 case E_MIPS_ABI_EABI64
:
5776 mips_abi
= MIPS_ABI_EABI64
;
5779 if ((elf_flags
& EF_MIPS_ABI2
))
5780 mips_abi
= MIPS_ABI_N32
;
5782 mips_abi
= MIPS_ABI_UNKNOWN
;
5786 /* GCC creates a pseudo-section whose name describes the ABI. */
5787 if (mips_abi
== MIPS_ABI_UNKNOWN
&& info
.abfd
!= NULL
)
5788 bfd_map_over_sections (info
.abfd
, mips_find_abi_section
, &mips_abi
);
5790 /* If we have no bfd, then mips_abi will still be MIPS_ABI_UNKNOWN.
5791 Use the ABI from the last architecture if there is one. */
5792 if (info
.abfd
== NULL
&& arches
!= NULL
)
5793 mips_abi
= gdbarch_tdep (arches
->gdbarch
)->found_abi
;
5795 /* Try the architecture for any hint of the correct ABI. */
5796 if (mips_abi
== MIPS_ABI_UNKNOWN
5797 && info
.bfd_arch_info
!= NULL
5798 && info
.bfd_arch_info
->arch
== bfd_arch_mips
)
5800 switch (info
.bfd_arch_info
->mach
)
5802 case bfd_mach_mips3900
:
5803 mips_abi
= MIPS_ABI_EABI32
;
5805 case bfd_mach_mips4100
:
5806 case bfd_mach_mips5000
:
5807 mips_abi
= MIPS_ABI_EABI64
;
5809 case bfd_mach_mips8000
:
5810 case bfd_mach_mips10000
:
5811 /* On Irix, ELF64 executables use the N64 ABI. The
5812 pseudo-sections which describe the ABI aren't present
5813 on IRIX. (Even for executables created by gcc.) */
5814 if (bfd_get_flavour (info
.abfd
) == bfd_target_elf_flavour
5815 && elf_elfheader (info
.abfd
)->e_ident
[EI_CLASS
] == ELFCLASS64
)
5816 mips_abi
= MIPS_ABI_N64
;
5818 mips_abi
= MIPS_ABI_N32
;
5823 if (mips_abi
== MIPS_ABI_UNKNOWN
)
5824 mips_abi
= MIPS_ABI_O32
;
5826 /* Now that we have found what the ABI for this binary would be,
5827 check whether the user is overriding it. */
5828 found_abi
= mips_abi
;
5829 wanted_abi
= global_mips_abi ();
5830 if (wanted_abi
!= MIPS_ABI_UNKNOWN
)
5831 mips_abi
= wanted_abi
;
5833 /* We have to set deprecated_tm_print_insn_info before looking for a
5834 pre-existing architecture, otherwise we may return before we get
5835 a chance to set it up. */
5836 if (mips_abi
== MIPS_ABI_N32
|| mips_abi
== MIPS_ABI_N64
)
5838 /* Set up the disassembler info, so that we get the right
5839 register names from libopcodes. */
5840 if (mips_abi
== MIPS_ABI_N32
)
5841 deprecated_tm_print_insn_info
.disassembler_options
= "gpr-names=n32";
5843 deprecated_tm_print_insn_info
.disassembler_options
= "gpr-names=64";
5844 deprecated_tm_print_insn_info
.flavour
= bfd_target_elf_flavour
;
5845 deprecated_tm_print_insn_info
.arch
= bfd_arch_mips
;
5846 if (info
.bfd_arch_info
!= NULL
5847 && info
.bfd_arch_info
->arch
== bfd_arch_mips
5848 && info
.bfd_arch_info
->mach
)
5849 deprecated_tm_print_insn_info
.mach
= info
.bfd_arch_info
->mach
;
5851 deprecated_tm_print_insn_info
.mach
= bfd_mach_mips8000
;
5854 /* This string is not recognized explicitly by the disassembler,
5855 but it tells the disassembler to not try to guess the ABI from
5856 the bfd elf headers, such that, if the user overrides the ABI
5857 of a program linked as NewABI, the disassembly will follow the
5858 register naming conventions specified by the user. */
5859 deprecated_tm_print_insn_info
.disassembler_options
= "gpr-names=32";
5863 fprintf_unfiltered (gdb_stdlog
,
5864 "mips_gdbarch_init: elf_flags = 0x%08x\n",
5866 fprintf_unfiltered (gdb_stdlog
,
5867 "mips_gdbarch_init: mips_abi = %d\n",
5869 fprintf_unfiltered (gdb_stdlog
,
5870 "mips_gdbarch_init: found_mips_abi = %d\n",
5874 /* try to find a pre-existing architecture */
5875 for (arches
= gdbarch_list_lookup_by_info (arches
, &info
);
5877 arches
= gdbarch_list_lookup_by_info (arches
->next
, &info
))
5879 /* MIPS needs to be pedantic about which ABI the object is
5881 if (gdbarch_tdep (arches
->gdbarch
)->elf_flags
!= elf_flags
)
5883 if (gdbarch_tdep (arches
->gdbarch
)->mips_abi
!= mips_abi
)
5885 return arches
->gdbarch
;
5888 /* Need a new architecture. Fill in a target specific vector. */
5889 tdep
= (struct gdbarch_tdep
*) xmalloc (sizeof (struct gdbarch_tdep
));
5890 gdbarch
= gdbarch_alloc (&info
, tdep
);
5891 tdep
->elf_flags
= elf_flags
;
5893 /* Initially set everything according to the default ABI/ISA. */
5894 set_gdbarch_short_bit (gdbarch
, 16);
5895 set_gdbarch_int_bit (gdbarch
, 32);
5896 set_gdbarch_float_bit (gdbarch
, 32);
5897 set_gdbarch_double_bit (gdbarch
, 64);
5898 set_gdbarch_long_double_bit (gdbarch
, 64);
5899 set_gdbarch_deprecated_register_raw_size (gdbarch
, mips_register_raw_size
);
5900 set_gdbarch_deprecated_register_byte (gdbarch
, mips_register_byte
);
5901 set_gdbarch_register_reggroup_p (gdbarch
, mips_register_reggroup_p
);
5902 set_gdbarch_pseudo_register_read (gdbarch
, mips_pseudo_register_read
);
5903 set_gdbarch_pseudo_register_write (gdbarch
, mips_pseudo_register_write
);
5904 tdep
->found_abi
= found_abi
;
5905 tdep
->mips_abi
= mips_abi
;
5907 set_gdbarch_elf_make_msymbol_special (gdbarch
,
5908 mips_elf_make_msymbol_special
);
5911 if (info
.osabi
== GDB_OSABI_IRIX
)
5915 set_gdbarch_num_regs (gdbarch
, num_regs
);
5916 set_gdbarch_num_pseudo_regs (gdbarch
, num_regs
);
5921 set_gdbarch_push_dummy_call (gdbarch
, mips_o32_push_dummy_call
);
5922 set_gdbarch_deprecated_store_return_value (gdbarch
, mips_o32_store_return_value
);
5923 set_gdbarch_extract_return_value (gdbarch
, mips_o32_extract_return_value
);
5924 tdep
->mips_default_saved_regsize
= 4;
5925 tdep
->mips_default_stack_argsize
= 4;
5926 tdep
->mips_fp_register_double
= 0;
5927 tdep
->mips_last_arg_regnum
= A0_REGNUM
+ 4 - 1;
5928 tdep
->mips_last_fp_arg_regnum
= FPA0_REGNUM
+ 4 - 1;
5929 tdep
->gdb_target_is_mips64
= 0;
5930 tdep
->default_mask_address_p
= 0;
5931 set_gdbarch_long_bit (gdbarch
, 32);
5932 set_gdbarch_ptr_bit (gdbarch
, 32);
5933 set_gdbarch_long_long_bit (gdbarch
, 64);
5934 set_gdbarch_reg_struct_has_addr (gdbarch
,
5935 mips_o32_reg_struct_has_addr
);
5936 set_gdbarch_use_struct_convention (gdbarch
,
5937 always_use_struct_convention
);
5940 set_gdbarch_push_dummy_call (gdbarch
, mips_o64_push_dummy_call
);
5941 set_gdbarch_deprecated_store_return_value (gdbarch
, mips_o64_store_return_value
);
5942 set_gdbarch_deprecated_extract_return_value (gdbarch
, mips_o64_extract_return_value
);
5943 tdep
->mips_default_saved_regsize
= 8;
5944 tdep
->mips_default_stack_argsize
= 8;
5945 tdep
->mips_fp_register_double
= 1;
5946 tdep
->mips_last_arg_regnum
= A0_REGNUM
+ 4 - 1;
5947 tdep
->mips_last_fp_arg_regnum
= FPA0_REGNUM
+ 4 - 1;
5948 tdep
->gdb_target_is_mips64
= 1;
5949 tdep
->default_mask_address_p
= 0;
5950 set_gdbarch_long_bit (gdbarch
, 32);
5951 set_gdbarch_ptr_bit (gdbarch
, 32);
5952 set_gdbarch_long_long_bit (gdbarch
, 64);
5953 set_gdbarch_reg_struct_has_addr (gdbarch
,
5954 mips_o32_reg_struct_has_addr
);
5955 set_gdbarch_use_struct_convention (gdbarch
, always_use_struct_convention
);
5957 case MIPS_ABI_EABI32
:
5958 set_gdbarch_push_dummy_call (gdbarch
, mips_eabi_push_dummy_call
);
5959 set_gdbarch_deprecated_store_return_value (gdbarch
, mips_eabi_store_return_value
);
5960 set_gdbarch_deprecated_extract_return_value (gdbarch
, mips_eabi_extract_return_value
);
5961 tdep
->mips_default_saved_regsize
= 4;
5962 tdep
->mips_default_stack_argsize
= 4;
5963 tdep
->mips_fp_register_double
= 0;
5964 tdep
->mips_last_arg_regnum
= A0_REGNUM
+ 8 - 1;
5965 tdep
->mips_last_fp_arg_regnum
= FPA0_REGNUM
+ 8 - 1;
5966 tdep
->gdb_target_is_mips64
= 0;
5967 tdep
->default_mask_address_p
= 0;
5968 set_gdbarch_long_bit (gdbarch
, 32);
5969 set_gdbarch_ptr_bit (gdbarch
, 32);
5970 set_gdbarch_long_long_bit (gdbarch
, 64);
5971 set_gdbarch_reg_struct_has_addr (gdbarch
,
5972 mips_eabi_reg_struct_has_addr
);
5973 set_gdbarch_use_struct_convention (gdbarch
,
5974 mips_eabi_use_struct_convention
);
5976 case MIPS_ABI_EABI64
:
5977 set_gdbarch_push_dummy_call (gdbarch
, mips_eabi_push_dummy_call
);
5978 set_gdbarch_deprecated_store_return_value (gdbarch
, mips_eabi_store_return_value
);
5979 set_gdbarch_deprecated_extract_return_value (gdbarch
, mips_eabi_extract_return_value
);
5980 tdep
->mips_default_saved_regsize
= 8;
5981 tdep
->mips_default_stack_argsize
= 8;
5982 tdep
->mips_fp_register_double
= 1;
5983 tdep
->mips_last_arg_regnum
= A0_REGNUM
+ 8 - 1;
5984 tdep
->mips_last_fp_arg_regnum
= FPA0_REGNUM
+ 8 - 1;
5985 tdep
->gdb_target_is_mips64
= 1;
5986 tdep
->default_mask_address_p
= 0;
5987 set_gdbarch_long_bit (gdbarch
, 64);
5988 set_gdbarch_ptr_bit (gdbarch
, 64);
5989 set_gdbarch_long_long_bit (gdbarch
, 64);
5990 set_gdbarch_reg_struct_has_addr (gdbarch
,
5991 mips_eabi_reg_struct_has_addr
);
5992 set_gdbarch_use_struct_convention (gdbarch
,
5993 mips_eabi_use_struct_convention
);
5996 set_gdbarch_push_dummy_call (gdbarch
, mips_n32n64_push_dummy_call
);
5997 set_gdbarch_deprecated_store_return_value (gdbarch
, mips_n32n64_store_return_value
);
5998 set_gdbarch_extract_return_value (gdbarch
, mips_n32n64_extract_return_value
);
5999 tdep
->mips_default_saved_regsize
= 8;
6000 tdep
->mips_default_stack_argsize
= 8;
6001 tdep
->mips_fp_register_double
= 1;
6002 tdep
->mips_last_arg_regnum
= A0_REGNUM
+ 8 - 1;
6003 tdep
->mips_last_fp_arg_regnum
= FPA0_REGNUM
+ 8 - 1;
6004 tdep
->gdb_target_is_mips64
= 1;
6005 tdep
->default_mask_address_p
= 0;
6006 set_gdbarch_long_bit (gdbarch
, 32);
6007 set_gdbarch_ptr_bit (gdbarch
, 32);
6008 set_gdbarch_long_long_bit (gdbarch
, 64);
6009 set_gdbarch_use_struct_convention (gdbarch
,
6010 mips_n32n64_use_struct_convention
);
6011 set_gdbarch_reg_struct_has_addr (gdbarch
,
6012 mips_n32n64_reg_struct_has_addr
);
6015 set_gdbarch_push_dummy_call (gdbarch
, mips_n32n64_push_dummy_call
);
6016 set_gdbarch_deprecated_store_return_value (gdbarch
, mips_n32n64_store_return_value
);
6017 set_gdbarch_extract_return_value (gdbarch
, mips_n32n64_extract_return_value
);
6018 tdep
->mips_default_saved_regsize
= 8;
6019 tdep
->mips_default_stack_argsize
= 8;
6020 tdep
->mips_fp_register_double
= 1;
6021 tdep
->mips_last_arg_regnum
= A0_REGNUM
+ 8 - 1;
6022 tdep
->mips_last_fp_arg_regnum
= FPA0_REGNUM
+ 8 - 1;
6023 tdep
->gdb_target_is_mips64
= 1;
6024 tdep
->default_mask_address_p
= 0;
6025 set_gdbarch_long_bit (gdbarch
, 64);
6026 set_gdbarch_ptr_bit (gdbarch
, 64);
6027 set_gdbarch_long_long_bit (gdbarch
, 64);
6028 set_gdbarch_use_struct_convention (gdbarch
,
6029 mips_n32n64_use_struct_convention
);
6030 set_gdbarch_reg_struct_has_addr (gdbarch
,
6031 mips_n32n64_reg_struct_has_addr
);
6034 internal_error (__FILE__
, __LINE__
,
6035 "unknown ABI in switch");
6038 /* FIXME: jlarmour/2000-04-07: There *is* a flag EF_MIPS_32BIT_MODE
6039 that could indicate -gp32 BUT gas/config/tc-mips.c contains the
6042 ``We deliberately don't allow "-gp32" to set the MIPS_32BITMODE
6043 flag in object files because to do so would make it impossible to
6044 link with libraries compiled without "-gp32". This is
6045 unnecessarily restrictive.
6047 We could solve this problem by adding "-gp32" multilibs to gcc,
6048 but to set this flag before gcc is built with such multilibs will
6049 break too many systems.''
6051 But even more unhelpfully, the default linker output target for
6052 mips64-elf is elf32-bigmips, and has EF_MIPS_32BIT_MODE set, even
6053 for 64-bit programs - you need to change the ABI to change this,
6054 and not all gcc targets support that currently. Therefore using
6055 this flag to detect 32-bit mode would do the wrong thing given
6056 the current gcc - it would make GDB treat these 64-bit programs
6057 as 32-bit programs by default. */
6059 /* enable/disable the MIPS FPU */
6060 if (!mips_fpu_type_auto
)
6061 tdep
->mips_fpu_type
= mips_fpu_type
;
6062 else if (info
.bfd_arch_info
!= NULL
6063 && info
.bfd_arch_info
->arch
== bfd_arch_mips
)
6064 switch (info
.bfd_arch_info
->mach
)
6066 case bfd_mach_mips3900
:
6067 case bfd_mach_mips4100
:
6068 case bfd_mach_mips4111
:
6069 tdep
->mips_fpu_type
= MIPS_FPU_NONE
;
6071 case bfd_mach_mips4650
:
6072 tdep
->mips_fpu_type
= MIPS_FPU_SINGLE
;
6075 tdep
->mips_fpu_type
= MIPS_FPU_DOUBLE
;
6079 tdep
->mips_fpu_type
= MIPS_FPU_DOUBLE
;
6081 /* MIPS version of register names. NOTE: At present the MIPS
6082 register name management is part way between the old -
6083 #undef/#define REGISTER_NAMES and the new REGISTER_NAME(nr).
6084 Further work on it is required. */
6085 /* NOTE: many targets (esp. embedded) do not go thru the
6086 gdbarch_register_name vector at all, instead bypassing it
6087 by defining REGISTER_NAMES. */
6088 set_gdbarch_register_name (gdbarch
, mips_register_name
);
6089 set_gdbarch_read_pc (gdbarch
, mips_read_pc
);
6090 set_gdbarch_write_pc (gdbarch
, generic_target_write_pc
);
6091 set_gdbarch_deprecated_target_read_fp (gdbarch
, mips_read_sp
); /* Draft FRAME base. */
6092 set_gdbarch_read_sp (gdbarch
, mips_read_sp
);
6094 /* Add/remove bits from an address. The MIPS needs be careful to
6095 ensure that all 32 bit addresses are sign extended to 64 bits. */
6096 set_gdbarch_addr_bits_remove (gdbarch
, mips_addr_bits_remove
);
6098 /* There's a mess in stack frame creation. See comments in
6099 blockframe.c near reference to DEPRECATED_INIT_FRAME_PC_FIRST. */
6100 set_gdbarch_deprecated_init_frame_pc_first (gdbarch
, mips_init_frame_pc_first
);
6101 set_gdbarch_deprecated_init_frame_pc (gdbarch
, init_frame_pc_noop
);
6103 /* Map debug register numbers onto internal register numbers. */
6104 set_gdbarch_stab_reg_to_regnum (gdbarch
, mips_stab_reg_to_regnum
);
6105 set_gdbarch_ecoff_reg_to_regnum (gdbarch
, mips_dwarf_dwarf2_ecoff_reg_to_regnum
);
6106 set_gdbarch_dwarf_reg_to_regnum (gdbarch
, mips_dwarf_dwarf2_ecoff_reg_to_regnum
);
6107 set_gdbarch_dwarf2_reg_to_regnum (gdbarch
, mips_dwarf_dwarf2_ecoff_reg_to_regnum
);
6108 set_gdbarch_register_sim_regno (gdbarch
, mips_register_sim_regno
);
6110 /* Initialize a frame */
6111 set_gdbarch_deprecated_frame_init_saved_regs (gdbarch
, mips_find_saved_regs
);
6112 set_gdbarch_deprecated_init_extra_frame_info (gdbarch
, mips_init_extra_frame_info
);
6114 /* MIPS version of CALL_DUMMY */
6116 set_gdbarch_call_dummy_address (gdbarch
, mips_call_dummy_address
);
6117 set_gdbarch_deprecated_pop_frame (gdbarch
, mips_pop_frame
);
6118 set_gdbarch_frame_align (gdbarch
, mips_frame_align
);
6119 set_gdbarch_deprecated_save_dummy_frame_tos (gdbarch
, generic_save_dummy_frame_tos
);
6120 set_gdbarch_deprecated_register_convertible (gdbarch
, mips_register_convertible
);
6121 set_gdbarch_deprecated_register_convert_to_virtual (gdbarch
, mips_register_convert_to_virtual
);
6122 set_gdbarch_deprecated_register_convert_to_raw (gdbarch
, mips_register_convert_to_raw
);
6124 set_gdbarch_deprecated_frame_chain (gdbarch
, mips_frame_chain
);
6125 set_gdbarch_frameless_function_invocation (gdbarch
,
6126 generic_frameless_function_invocation_not
);
6127 set_gdbarch_deprecated_frame_saved_pc (gdbarch
, mips_frame_saved_pc
);
6128 set_gdbarch_frame_args_skip (gdbarch
, 0);
6130 set_gdbarch_deprecated_get_saved_register (gdbarch
, mips_get_saved_register
);
6132 set_gdbarch_inner_than (gdbarch
, core_addr_lessthan
);
6133 set_gdbarch_breakpoint_from_pc (gdbarch
, mips_breakpoint_from_pc
);
6134 set_gdbarch_decr_pc_after_break (gdbarch
, 0);
6136 set_gdbarch_skip_prologue (gdbarch
, mips_skip_prologue
);
6137 set_gdbarch_deprecated_saved_pc_after_call (gdbarch
, mips_saved_pc_after_call
);
6139 set_gdbarch_pointer_to_address (gdbarch
, signed_pointer_to_address
);
6140 set_gdbarch_address_to_pointer (gdbarch
, address_to_signed_pointer
);
6141 set_gdbarch_integer_to_address (gdbarch
, mips_integer_to_address
);
6143 set_gdbarch_function_start_offset (gdbarch
, 0);
6145 set_gdbarch_register_type (gdbarch
, mips_register_type
);
6147 set_gdbarch_print_registers_info (gdbarch
, mips_print_registers_info
);
6148 set_gdbarch_pc_in_sigtramp (gdbarch
, mips_pc_in_sigtramp
);
6150 /* Hook in OS ABI-specific overrides, if they have been registered. */
6151 gdbarch_init_osabi (info
, gdbarch
);
6153 set_gdbarch_extract_struct_value_address (gdbarch
,
6154 mips_extract_struct_value_address
);
6156 set_gdbarch_skip_trampoline_code (gdbarch
, mips_skip_stub
);
6158 set_gdbarch_in_solib_call_trampoline (gdbarch
, mips_in_call_stub
);
6159 set_gdbarch_in_solib_return_trampoline (gdbarch
, mips_in_return_stub
);
6165 mips_abi_update (char *ignore_args
, int from_tty
,
6166 struct cmd_list_element
*c
)
6168 struct gdbarch_info info
;
6170 /* Force the architecture to update, and (if it's a MIPS architecture)
6171 mips_gdbarch_init will take care of the rest. */
6172 gdbarch_info_init (&info
);
6173 gdbarch_update_p (info
);
6176 /* Print out which MIPS ABI is in use. */
6179 show_mips_abi (char *ignore_args
, int from_tty
)
6181 if (gdbarch_bfd_arch_info (current_gdbarch
)->arch
!= bfd_arch_mips
)
6183 "The MIPS ABI is unknown because the current architecture is not MIPS.\n");
6186 enum mips_abi global_abi
= global_mips_abi ();
6187 enum mips_abi actual_abi
= mips_abi (current_gdbarch
);
6188 const char *actual_abi_str
= mips_abi_strings
[actual_abi
];
6190 if (global_abi
== MIPS_ABI_UNKNOWN
)
6191 printf_filtered ("The MIPS ABI is set automatically (currently \"%s\").\n",
6193 else if (global_abi
== actual_abi
)
6195 "The MIPS ABI is assumed to be \"%s\" (due to user setting).\n",
6199 /* Probably shouldn't happen... */
6201 "The (auto detected) MIPS ABI \"%s\" is in use even though the user setting was \"%s\".\n",
6203 mips_abi_strings
[global_abi
]);
6209 mips_dump_tdep (struct gdbarch
*current_gdbarch
, struct ui_file
*file
)
6211 struct gdbarch_tdep
*tdep
= gdbarch_tdep (current_gdbarch
);
6215 int ef_mips_32bitmode
;
6216 /* determine the ISA */
6217 switch (tdep
->elf_flags
& EF_MIPS_ARCH
)
6235 /* determine the size of a pointer */
6236 ef_mips_32bitmode
= (tdep
->elf_flags
& EF_MIPS_32BITMODE
);
6237 fprintf_unfiltered (file
,
6238 "mips_dump_tdep: tdep->elf_flags = 0x%x\n",
6240 fprintf_unfiltered (file
,
6241 "mips_dump_tdep: ef_mips_32bitmode = %d\n",
6243 fprintf_unfiltered (file
,
6244 "mips_dump_tdep: ef_mips_arch = %d\n",
6246 fprintf_unfiltered (file
,
6247 "mips_dump_tdep: tdep->mips_abi = %d (%s)\n",
6249 mips_abi_strings
[tdep
->mips_abi
]);
6250 fprintf_unfiltered (file
,
6251 "mips_dump_tdep: mips_mask_address_p() %d (default %d)\n",
6252 mips_mask_address_p (),
6253 tdep
->default_mask_address_p
);
6255 fprintf_unfiltered (file
,
6256 "mips_dump_tdep: FP_REGISTER_DOUBLE = %d\n",
6257 FP_REGISTER_DOUBLE
);
6258 fprintf_unfiltered (file
,
6259 "mips_dump_tdep: MIPS_DEFAULT_FPU_TYPE = %d (%s)\n",
6260 MIPS_DEFAULT_FPU_TYPE
,
6261 (MIPS_DEFAULT_FPU_TYPE
== MIPS_FPU_NONE
? "none"
6262 : MIPS_DEFAULT_FPU_TYPE
== MIPS_FPU_SINGLE
? "single"
6263 : MIPS_DEFAULT_FPU_TYPE
== MIPS_FPU_DOUBLE
? "double"
6265 fprintf_unfiltered (file
,
6266 "mips_dump_tdep: MIPS_EABI = %d\n",
6268 fprintf_unfiltered (file
,
6269 "mips_dump_tdep: MIPS_LAST_FP_ARG_REGNUM = %d (%d regs)\n",
6270 MIPS_LAST_FP_ARG_REGNUM
,
6271 MIPS_LAST_FP_ARG_REGNUM
- FPA0_REGNUM
+ 1);
6272 fprintf_unfiltered (file
,
6273 "mips_dump_tdep: MIPS_FPU_TYPE = %d (%s)\n",
6275 (MIPS_FPU_TYPE
== MIPS_FPU_NONE
? "none"
6276 : MIPS_FPU_TYPE
== MIPS_FPU_SINGLE
? "single"
6277 : MIPS_FPU_TYPE
== MIPS_FPU_DOUBLE
? "double"
6279 fprintf_unfiltered (file
,
6280 "mips_dump_tdep: MIPS_DEFAULT_SAVED_REGSIZE = %d\n",
6281 MIPS_DEFAULT_SAVED_REGSIZE
);
6282 fprintf_unfiltered (file
,
6283 "mips_dump_tdep: FP_REGISTER_DOUBLE = %d\n",
6284 FP_REGISTER_DOUBLE
);
6285 fprintf_unfiltered (file
,
6286 "mips_dump_tdep: MIPS_DEFAULT_STACK_ARGSIZE = %d\n",
6287 MIPS_DEFAULT_STACK_ARGSIZE
);
6288 fprintf_unfiltered (file
,
6289 "mips_dump_tdep: MIPS_STACK_ARGSIZE = %d\n",
6290 MIPS_STACK_ARGSIZE
);
6291 fprintf_unfiltered (file
,
6292 "mips_dump_tdep: MIPS_REGSIZE = %d\n",
6294 fprintf_unfiltered (file
,
6295 "mips_dump_tdep: A0_REGNUM = %d\n",
6297 fprintf_unfiltered (file
,
6298 "mips_dump_tdep: ADDR_BITS_REMOVE # %s\n",
6299 XSTRING (ADDR_BITS_REMOVE(ADDR
)));
6300 fprintf_unfiltered (file
,
6301 "mips_dump_tdep: ATTACH_DETACH # %s\n",
6302 XSTRING (ATTACH_DETACH
));
6303 fprintf_unfiltered (file
,
6304 "mips_dump_tdep: BADVADDR_REGNUM = %d\n",
6306 fprintf_unfiltered (file
,
6307 "mips_dump_tdep: CAUSE_REGNUM = %d\n",
6309 fprintf_unfiltered (file
,
6310 "mips_dump_tdep: DWARF_REG_TO_REGNUM # %s\n",
6311 XSTRING (DWARF_REG_TO_REGNUM (REGNUM
)));
6312 fprintf_unfiltered (file
,
6313 "mips_dump_tdep: ECOFF_REG_TO_REGNUM # %s\n",
6314 XSTRING (ECOFF_REG_TO_REGNUM (REGNUM
)));
6315 fprintf_unfiltered (file
,
6316 "mips_dump_tdep: FCRCS_REGNUM = %d\n",
6318 fprintf_unfiltered (file
,
6319 "mips_dump_tdep: FCRIR_REGNUM = %d\n",
6321 fprintf_unfiltered (file
,
6322 "mips_dump_tdep: FIRST_EMBED_REGNUM = %d\n",
6323 FIRST_EMBED_REGNUM
);
6324 fprintf_unfiltered (file
,
6325 "mips_dump_tdep: FPA0_REGNUM = %d\n",
6327 fprintf_unfiltered (file
,
6328 "mips_dump_tdep: GDB_TARGET_IS_MIPS64 = %d\n",
6329 GDB_TARGET_IS_MIPS64
);
6330 fprintf_unfiltered (file
,
6331 "mips_dump_tdep: HAVE_NONSTEPPABLE_WATCHPOINT # %s\n",
6332 XSTRING (HAVE_NONSTEPPABLE_WATCHPOINT
));
6333 fprintf_unfiltered (file
,
6334 "mips_dump_tdep: HI_REGNUM = %d\n",
6336 fprintf_unfiltered (file
,
6337 "mips_dump_tdep: IGNORE_HELPER_CALL # %s\n",
6338 XSTRING (IGNORE_HELPER_CALL (PC
)));
6339 fprintf_unfiltered (file
,
6340 "mips_dump_tdep: IN_SOLIB_CALL_TRAMPOLINE # %s\n",
6341 XSTRING (IN_SOLIB_CALL_TRAMPOLINE (PC
, NAME
)));
6342 fprintf_unfiltered (file
,
6343 "mips_dump_tdep: IN_SOLIB_RETURN_TRAMPOLINE # %s\n",
6344 XSTRING (IN_SOLIB_RETURN_TRAMPOLINE (PC
, NAME
)));
6345 fprintf_unfiltered (file
,
6346 "mips_dump_tdep: LAST_EMBED_REGNUM = %d\n",
6348 fprintf_unfiltered (file
,
6349 "mips_dump_tdep: LO_REGNUM = %d\n",
6351 #ifdef MACHINE_CPROC_FP_OFFSET
6352 fprintf_unfiltered (file
,
6353 "mips_dump_tdep: MACHINE_CPROC_FP_OFFSET = %d\n",
6354 MACHINE_CPROC_FP_OFFSET
);
6356 #ifdef MACHINE_CPROC_PC_OFFSET
6357 fprintf_unfiltered (file
,
6358 "mips_dump_tdep: MACHINE_CPROC_PC_OFFSET = %d\n",
6359 MACHINE_CPROC_PC_OFFSET
);
6361 #ifdef MACHINE_CPROC_SP_OFFSET
6362 fprintf_unfiltered (file
,
6363 "mips_dump_tdep: MACHINE_CPROC_SP_OFFSET = %d\n",
6364 MACHINE_CPROC_SP_OFFSET
);
6366 fprintf_unfiltered (file
,
6367 "mips_dump_tdep: MIPS16_INSTLEN = %d\n",
6369 fprintf_unfiltered (file
,
6370 "mips_dump_tdep: MIPS_DEFAULT_ABI = FIXME!\n");
6371 fprintf_unfiltered (file
,
6372 "mips_dump_tdep: MIPS_EFI_SYMBOL_NAME = multi-arch!!\n");
6373 fprintf_unfiltered (file
,
6374 "mips_dump_tdep: MIPS_INSTLEN = %d\n",
6376 fprintf_unfiltered (file
,
6377 "mips_dump_tdep: MIPS_LAST_ARG_REGNUM = %d (%d regs)\n",
6378 MIPS_LAST_ARG_REGNUM
,
6379 MIPS_LAST_ARG_REGNUM
- A0_REGNUM
+ 1);
6380 fprintf_unfiltered (file
,
6381 "mips_dump_tdep: MIPS_NUMREGS = %d\n",
6383 fprintf_unfiltered (file
,
6384 "mips_dump_tdep: MIPS_REGISTER_NAMES = delete?\n");
6385 fprintf_unfiltered (file
,
6386 "mips_dump_tdep: MIPS_SAVED_REGSIZE = %d\n",
6387 MIPS_SAVED_REGSIZE
);
6388 fprintf_unfiltered (file
,
6389 "mips_dump_tdep: OP_LDFPR = used?\n");
6390 fprintf_unfiltered (file
,
6391 "mips_dump_tdep: OP_LDGPR = used?\n");
6392 fprintf_unfiltered (file
,
6393 "mips_dump_tdep: PRID_REGNUM = %d\n",
6395 fprintf_unfiltered (file
,
6396 "mips_dump_tdep: PRINT_EXTRA_FRAME_INFO # %s\n",
6397 XSTRING (PRINT_EXTRA_FRAME_INFO (FRAME
)));
6398 fprintf_unfiltered (file
,
6399 "mips_dump_tdep: PROC_DESC_IS_DUMMY = function?\n");
6400 fprintf_unfiltered (file
,
6401 "mips_dump_tdep: PROC_FRAME_ADJUST = function?\n");
6402 fprintf_unfiltered (file
,
6403 "mips_dump_tdep: PROC_FRAME_OFFSET = function?\n");
6404 fprintf_unfiltered (file
,
6405 "mips_dump_tdep: PROC_FRAME_REG = function?\n");
6406 fprintf_unfiltered (file
,
6407 "mips_dump_tdep: PROC_FREG_MASK = function?\n");
6408 fprintf_unfiltered (file
,
6409 "mips_dump_tdep: PROC_FREG_OFFSET = function?\n");
6410 fprintf_unfiltered (file
,
6411 "mips_dump_tdep: PROC_HIGH_ADDR = function?\n");
6412 fprintf_unfiltered (file
,
6413 "mips_dump_tdep: PROC_LOW_ADDR = function?\n");
6414 fprintf_unfiltered (file
,
6415 "mips_dump_tdep: PROC_PC_REG = function?\n");
6416 fprintf_unfiltered (file
,
6417 "mips_dump_tdep: PROC_REG_MASK = function?\n");
6418 fprintf_unfiltered (file
,
6419 "mips_dump_tdep: PROC_REG_OFFSET = function?\n");
6420 fprintf_unfiltered (file
,
6421 "mips_dump_tdep: PROC_SYMBOL = function?\n");
6422 fprintf_unfiltered (file
,
6423 "mips_dump_tdep: PS_REGNUM = %d\n",
6425 fprintf_unfiltered (file
,
6426 "mips_dump_tdep: RA_REGNUM = %d\n",
6428 fprintf_unfiltered (file
,
6429 "mips_dump_tdep: REGISTER_NAMES = delete?\n");
6430 fprintf_unfiltered (file
,
6431 "mips_dump_tdep: ROUND_DOWN = function?\n");
6432 fprintf_unfiltered (file
,
6433 "mips_dump_tdep: ROUND_UP = function?\n");
6435 fprintf_unfiltered (file
,
6436 "mips_dump_tdep: SAVED_BYTES = %d\n",
6440 fprintf_unfiltered (file
,
6441 "mips_dump_tdep: SAVED_FP = %d\n",
6445 fprintf_unfiltered (file
,
6446 "mips_dump_tdep: SAVED_PC = %d\n",
6449 fprintf_unfiltered (file
,
6450 "mips_dump_tdep: SETUP_ARBITRARY_FRAME # %s\n",
6451 XSTRING (SETUP_ARBITRARY_FRAME (NUMARGS
, ARGS
)));
6452 fprintf_unfiltered (file
,
6453 "mips_dump_tdep: SET_PROC_DESC_IS_DUMMY = function?\n");
6454 fprintf_unfiltered (file
,
6455 "mips_dump_tdep: SIGFRAME_BASE = %d\n",
6457 fprintf_unfiltered (file
,
6458 "mips_dump_tdep: SIGFRAME_FPREGSAVE_OFF = %d\n",
6459 SIGFRAME_FPREGSAVE_OFF
);
6460 fprintf_unfiltered (file
,
6461 "mips_dump_tdep: SIGFRAME_PC_OFF = %d\n",
6463 fprintf_unfiltered (file
,
6464 "mips_dump_tdep: SIGFRAME_REGSAVE_OFF = %d\n",
6465 SIGFRAME_REGSAVE_OFF
);
6466 fprintf_unfiltered (file
,
6467 "mips_dump_tdep: SIGFRAME_REG_SIZE = %d\n",
6469 fprintf_unfiltered (file
,
6470 "mips_dump_tdep: SKIP_TRAMPOLINE_CODE # %s\n",
6471 XSTRING (SKIP_TRAMPOLINE_CODE (PC
)));
6472 fprintf_unfiltered (file
,
6473 "mips_dump_tdep: SOFTWARE_SINGLE_STEP # %s\n",
6474 XSTRING (SOFTWARE_SINGLE_STEP (SIG
, BP_P
)));
6475 fprintf_unfiltered (file
,
6476 "mips_dump_tdep: SOFTWARE_SINGLE_STEP_P () = %d\n",
6477 SOFTWARE_SINGLE_STEP_P ());
6478 fprintf_unfiltered (file
,
6479 "mips_dump_tdep: STAB_REG_TO_REGNUM # %s\n",
6480 XSTRING (STAB_REG_TO_REGNUM (REGNUM
)));
6481 #ifdef STACK_END_ADDR
6482 fprintf_unfiltered (file
,
6483 "mips_dump_tdep: STACK_END_ADDR = %d\n",
6486 fprintf_unfiltered (file
,
6487 "mips_dump_tdep: STEP_SKIPS_DELAY # %s\n",
6488 XSTRING (STEP_SKIPS_DELAY (PC
)));
6489 fprintf_unfiltered (file
,
6490 "mips_dump_tdep: STEP_SKIPS_DELAY_P = %d\n",
6491 STEP_SKIPS_DELAY_P
);
6492 fprintf_unfiltered (file
,
6493 "mips_dump_tdep: STOPPED_BY_WATCHPOINT # %s\n",
6494 XSTRING (STOPPED_BY_WATCHPOINT (WS
)));
6495 fprintf_unfiltered (file
,
6496 "mips_dump_tdep: T9_REGNUM = %d\n",
6498 fprintf_unfiltered (file
,
6499 "mips_dump_tdep: TABULAR_REGISTER_OUTPUT = used?\n");
6500 fprintf_unfiltered (file
,
6501 "mips_dump_tdep: TARGET_CAN_USE_HARDWARE_WATCHPOINT # %s\n",
6502 XSTRING (TARGET_CAN_USE_HARDWARE_WATCHPOINT (TYPE
,CNT
,OTHERTYPE
)));
6503 fprintf_unfiltered (file
,
6504 "mips_dump_tdep: TARGET_HAS_HARDWARE_WATCHPOINTS # %s\n",
6505 XSTRING (TARGET_HAS_HARDWARE_WATCHPOINTS
));
6507 fprintf_unfiltered (file
,
6508 "mips_dump_tdep: TRACE_CLEAR # %s\n",
6509 XSTRING (TRACE_CLEAR (THREAD
, STATE
)));
6512 fprintf_unfiltered (file
,
6513 "mips_dump_tdep: TRACE_FLAVOR = %d\n",
6516 #ifdef TRACE_FLAVOR_SIZE
6517 fprintf_unfiltered (file
,
6518 "mips_dump_tdep: TRACE_FLAVOR_SIZE = %d\n",
6522 fprintf_unfiltered (file
,
6523 "mips_dump_tdep: TRACE_SET # %s\n",
6524 XSTRING (TRACE_SET (X
,STATE
)));
6526 #ifdef UNUSED_REGNUM
6527 fprintf_unfiltered (file
,
6528 "mips_dump_tdep: UNUSED_REGNUM = %d\n",
6531 fprintf_unfiltered (file
,
6532 "mips_dump_tdep: V0_REGNUM = %d\n",
6534 fprintf_unfiltered (file
,
6535 "mips_dump_tdep: VM_MIN_ADDRESS = %ld\n",
6536 (long) VM_MIN_ADDRESS
);
6538 fprintf_unfiltered (file
,
6539 "mips_dump_tdep: VX_NUM_REGS = %d (used?)\n",
6542 fprintf_unfiltered (file
,
6543 "mips_dump_tdep: ZERO_REGNUM = %d\n",
6545 fprintf_unfiltered (file
,
6546 "mips_dump_tdep: _PROC_MAGIC_ = %d\n",
6550 extern initialize_file_ftype _initialize_mips_tdep
; /* -Wmissing-prototypes */
6553 _initialize_mips_tdep (void)
6555 static struct cmd_list_element
*mipsfpulist
= NULL
;
6556 struct cmd_list_element
*c
;
6558 mips_abi_string
= mips_abi_strings
[MIPS_ABI_UNKNOWN
];
6559 if (MIPS_ABI_LAST
+ 1
6560 != sizeof (mips_abi_strings
) / sizeof (mips_abi_strings
[0]))
6561 internal_error (__FILE__
, __LINE__
, "mips_abi_strings out of sync");
6563 gdbarch_register (bfd_arch_mips
, mips_gdbarch_init
, mips_dump_tdep
);
6564 if (!deprecated_tm_print_insn
) /* Someone may have already set it */
6565 deprecated_tm_print_insn
= gdb_print_insn_mips
;
6567 /* Add root prefix command for all "set mips"/"show mips" commands */
6568 add_prefix_cmd ("mips", no_class
, set_mips_command
,
6569 "Various MIPS specific commands.",
6570 &setmipscmdlist
, "set mips ", 0, &setlist
);
6572 add_prefix_cmd ("mips", no_class
, show_mips_command
,
6573 "Various MIPS specific commands.",
6574 &showmipscmdlist
, "show mips ", 0, &showlist
);
6576 /* Allow the user to override the saved register size. */
6577 add_show_from_set (add_set_enum_cmd ("saved-gpreg-size",
6580 &mips_saved_regsize_string
, "\
6581 Set size of general purpose registers saved on the stack.\n\
6582 This option can be set to one of:\n\
6583 32 - Force GDB to treat saved GP registers as 32-bit\n\
6584 64 - Force GDB to treat saved GP registers as 64-bit\n\
6585 auto - Allow GDB to use the target's default setting or autodetect the\n\
6586 saved GP register size from information contained in the executable.\n\
6591 /* Allow the user to override the argument stack size. */
6592 add_show_from_set (add_set_enum_cmd ("stack-arg-size",
6595 &mips_stack_argsize_string
, "\
6596 Set the amount of stack space reserved for each argument.\n\
6597 This option can be set to one of:\n\
6598 32 - Force GDB to allocate 32-bit chunks per argument\n\
6599 64 - Force GDB to allocate 64-bit chunks per argument\n\
6600 auto - Allow GDB to determine the correct setting from the current\n\
6601 target and executable (default)",
6605 /* Allow the user to override the ABI. */
6606 c
= add_set_enum_cmd
6607 ("abi", class_obscure
, mips_abi_strings
, &mips_abi_string
,
6608 "Set the ABI used by this program.\n"
6609 "This option can be set to one of:\n"
6610 " auto - the default ABI associated with the current binary\n"
6618 set_cmd_sfunc (c
, mips_abi_update
);
6619 add_cmd ("abi", class_obscure
, show_mips_abi
,
6620 "Show ABI in use by MIPS target", &showmipscmdlist
);
6622 /* Let the user turn off floating point and set the fence post for
6623 heuristic_proc_start. */
6625 add_prefix_cmd ("mipsfpu", class_support
, set_mipsfpu_command
,
6626 "Set use of MIPS floating-point coprocessor.",
6627 &mipsfpulist
, "set mipsfpu ", 0, &setlist
);
6628 add_cmd ("single", class_support
, set_mipsfpu_single_command
,
6629 "Select single-precision MIPS floating-point coprocessor.",
6631 add_cmd ("double", class_support
, set_mipsfpu_double_command
,
6632 "Select double-precision MIPS floating-point coprocessor.",
6634 add_alias_cmd ("on", "double", class_support
, 1, &mipsfpulist
);
6635 add_alias_cmd ("yes", "double", class_support
, 1, &mipsfpulist
);
6636 add_alias_cmd ("1", "double", class_support
, 1, &mipsfpulist
);
6637 add_cmd ("none", class_support
, set_mipsfpu_none_command
,
6638 "Select no MIPS floating-point coprocessor.",
6640 add_alias_cmd ("off", "none", class_support
, 1, &mipsfpulist
);
6641 add_alias_cmd ("no", "none", class_support
, 1, &mipsfpulist
);
6642 add_alias_cmd ("0", "none", class_support
, 1, &mipsfpulist
);
6643 add_cmd ("auto", class_support
, set_mipsfpu_auto_command
,
6644 "Select MIPS floating-point coprocessor automatically.",
6646 add_cmd ("mipsfpu", class_support
, show_mipsfpu_command
,
6647 "Show current use of MIPS floating-point coprocessor target.",
6650 /* We really would like to have both "0" and "unlimited" work, but
6651 command.c doesn't deal with that. So make it a var_zinteger
6652 because the user can always use "999999" or some such for unlimited. */
6653 c
= add_set_cmd ("heuristic-fence-post", class_support
, var_zinteger
,
6654 (char *) &heuristic_fence_post
,
6656 Set the distance searched for the start of a function.\n\
6657 If you are debugging a stripped executable, GDB needs to search through the\n\
6658 program for the start of a function. This command sets the distance of the\n\
6659 search. The only need to set it is when debugging a stripped executable.",
6661 /* We need to throw away the frame cache when we set this, since it
6662 might change our ability to get backtraces. */
6663 set_cmd_sfunc (c
, reinit_frame_cache_sfunc
);
6664 add_show_from_set (c
, &showlist
);
6666 /* Allow the user to control whether the upper bits of 64-bit
6667 addresses should be zeroed. */
6668 add_setshow_auto_boolean_cmd ("mask-address", no_class
, &mask_address_var
, "\
6669 Set zeroing of upper 32 bits of 64-bit addresses.\n\
6670 Use \"on\" to enable the masking, \"off\" to disable it and \"auto\" to \n\
6671 allow GDB to determine the correct value.\n", "\
6672 Show zeroing of upper 32 bits of 64-bit addresses.",
6673 NULL
, show_mask_address
,
6674 &setmipscmdlist
, &showmipscmdlist
);
6676 /* Allow the user to control the size of 32 bit registers within the
6677 raw remote packet. */
6678 add_show_from_set (add_set_cmd ("remote-mips64-transfers-32bit-regs",
6681 (char *)&mips64_transfers_32bit_regs_p
, "\
6682 Set compatibility with MIPS targets that transfers 32 and 64 bit quantities.\n\
6683 Use \"on\" to enable backward compatibility with older MIPS 64 GDB+target\n\
6684 that would transfer 32 bits for some registers (e.g. SR, FSR) and\n\
6685 64 bits for others. Use \"off\" to disable compatibility mode",
6689 /* Debug this files internals. */
6690 add_show_from_set (add_set_cmd ("mips", class_maintenance
, var_zinteger
,
6691 &mips_debug
, "Set mips debugging.\n\
6692 When non-zero, mips specific debugging is enabled.", &setdebuglist
),