1 /* Target-dependent code for the MIPS architecture, for GDB, the GNU Debugger.
2 Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995
3 Free Software Foundation, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
35 #include "opcode/mips.h"
37 #define VM_MIN_ADDRESS (unsigned)0x400000
39 /* FIXME: Put this declaration in frame.h. */
40 extern struct obstack frame_cache_obstack;
43 static int mips_in_lenient_prologue PARAMS ((CORE_ADDR, CORE_ADDR));
46 static void mips_set_fpu_command PARAMS ((char *, int,
47 struct cmd_list_element *));
49 static void mips_show_fpu_command PARAMS ((char *, int,
50 struct cmd_list_element *));
52 void mips_set_processor_type_command PARAMS ((char *, int));
54 int mips_set_processor_type PARAMS ((char *));
56 static void mips_show_processor_type_command PARAMS ((char *, int));
58 static void reinit_frame_cache_sfunc PARAMS ((char *, int,
59 struct cmd_list_element *));
61 /* This value is the model of MIPS in use. It is derived from the value
62 of the PrID register. */
64 char *mips_processor_type;
66 char *tmp_mips_processor_type;
68 /* Some MIPS boards don't support floating point, so we permit the
69 user to turn it off. */
71 enum mips_fpu_type mips_fpu;
73 static char *mips_fpu_string;
75 /* A set of original names, to be used when restoring back to generic
76 registers from a specific set. */
78 char *mips_generic_reg_names[] = REGISTER_NAMES;
80 /* Names of IDT R3041 registers. */
82 char *mips_r3041_reg_names[] = {
83 "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
84 "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
85 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
86 "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra",
87 "sr", "lo", "hi", "bad", "cause","pc",
88 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
89 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
90 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
91 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
92 "fsr", "fir", "fp", "",
93 "", "", "bus", "ccfg", "", "", "", "",
94 "", "", "port", "cmp", "", "", "epc", "prid",
97 /* Names of IDT R3051 registers. */
99 char *mips_r3051_reg_names[] = {
100 "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
101 "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
102 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
103 "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra",
104 "sr", "lo", "hi", "bad", "cause","pc",
105 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
106 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
107 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
108 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
109 "fsr", "fir", "fp", "",
110 "inx", "rand", "elo", "", "ctxt", "", "", "",
111 "", "", "ehi", "", "", "", "epc", "prid",
114 /* Names of IDT R3081 registers. */
116 char *mips_r3081_reg_names[] = {
117 "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
118 "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
119 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
120 "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra",
121 "sr", "lo", "hi", "bad", "cause","pc",
122 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
123 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
124 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
125 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
126 "fsr", "fir", "fp", "",
127 "inx", "rand", "elo", "cfg", "ctxt", "", "", "",
128 "", "", "ehi", "", "", "", "epc", "prid",
131 /* Names of LSI 33k registers. */
133 char *mips_lsi33k_reg_names[] = {
134 "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
135 "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
136 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
137 "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra",
138 "epc", "hi", "lo", "sr", "cause","badvaddr",
139 "dcic", "bpc", "bda", "", "", "", "", "",
140 "", "", "", "", "", "", "", "",
141 "", "", "", "", "", "", "", "",
142 "", "", "", "", "", "", "", "",
144 "", "", "", "", "", "", "", "",
145 "", "", "", "", "", "", "", "",
151 } mips_processor_type_table[] = {
152 { "generic", mips_generic_reg_names },
153 { "r3041", mips_r3041_reg_names },
154 { "r3051", mips_r3051_reg_names },
155 { "r3071", mips_r3081_reg_names },
156 { "r3081", mips_r3081_reg_names },
157 { "lsi33k", mips_lsi33k_reg_names },
161 /* Heuristic_proc_start may hunt through the text section for a long
162 time across a 2400 baud serial line. Allows the user to limit this
165 static unsigned int heuristic_fence_post = 0;
167 #define PROC_LOW_ADDR(proc) ((proc)->pdr.adr) /* least address */
168 #define PROC_HIGH_ADDR(proc) ((proc)->pdr.iline) /* upper address bound */
169 #define PROC_FRAME_OFFSET(proc) ((proc)->pdr.frameoffset)
170 #define PROC_FRAME_REG(proc) ((proc)->pdr.framereg)
171 #define PROC_REG_MASK(proc) ((proc)->pdr.regmask)
172 #define PROC_FREG_MASK(proc) ((proc)->pdr.fregmask)
173 #define PROC_REG_OFFSET(proc) ((proc)->pdr.regoffset)
174 #define PROC_FREG_OFFSET(proc) ((proc)->pdr.fregoffset)
175 #define PROC_PC_REG(proc) ((proc)->pdr.pcreg)
176 #define PROC_SYMBOL(proc) (*(struct symbol**)&(proc)->pdr.isym)
177 #define _PROC_MAGIC_ 0x0F0F0F0F
178 #define PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym == _PROC_MAGIC_)
179 #define SET_PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym = _PROC_MAGIC_)
181 struct linked_proc_info
183 struct mips_extra_func_info info;
184 struct linked_proc_info *next;
185 } *linked_proc_desc_table = NULL;
188 /* Guaranteed to set fci->saved_regs to some values (it never leaves it
192 mips_find_saved_regs (fci)
193 struct frame_info *fci;
196 CORE_ADDR reg_position;
197 /* r0 bit means kernel trap */
199 /* What registers have been saved? Bitmasks. */
200 unsigned long gen_mask, float_mask;
201 mips_extra_func_info_t proc_desc;
203 fci->saved_regs = (struct frame_saved_regs *)
204 obstack_alloc (&frame_cache_obstack, sizeof(struct frame_saved_regs));
205 memset (fci->saved_regs, 0, sizeof (struct frame_saved_regs));
207 /* If it is the frame for sigtramp, the saved registers are located
208 in a sigcontext structure somewhere on the stack.
209 If the stack layout for sigtramp changes we might have to change these
210 constants and the companion fixup_sigtramp in mdebugread.c */
211 #ifndef SIGFRAME_BASE
212 /* To satisfy alignment restrictions, sigcontext is located 4 bytes
213 above the sigtramp frame. */
214 #define SIGFRAME_BASE 4
215 #define SIGFRAME_PC_OFF (SIGFRAME_BASE + 2 * 4)
216 #define SIGFRAME_REGSAVE_OFF (SIGFRAME_BASE + 3 * 4)
217 #define SIGFRAME_FPREGSAVE_OFF (SIGFRAME_REGSAVE_OFF + 32 * 4 + 3 * 4)
219 #ifndef SIGFRAME_REG_SIZE
220 #define SIGFRAME_REG_SIZE 4
222 if (fci->signal_handler_caller)
224 for (ireg = 0; ireg < 32; ireg++)
226 reg_position = fci->frame + SIGFRAME_REGSAVE_OFF
227 + ireg * SIGFRAME_REG_SIZE;
228 fci->saved_regs->regs[ireg] = reg_position;
230 for (ireg = 0; ireg < 32; ireg++)
232 reg_position = fci->frame + SIGFRAME_FPREGSAVE_OFF
233 + ireg * SIGFRAME_REG_SIZE;
234 fci->saved_regs->regs[FP0_REGNUM + ireg] = reg_position;
236 fci->saved_regs->regs[PC_REGNUM] = fci->frame + SIGFRAME_PC_OFF;
240 proc_desc = fci->proc_desc;
241 if (proc_desc == NULL)
242 /* I'm not sure how/whether this can happen. Normally when we can't
243 find a proc_desc, we "synthesize" one using heuristic_proc_desc
244 and set the saved_regs right away. */
247 kernel_trap = PROC_REG_MASK(proc_desc) & 1;
248 gen_mask = kernel_trap ? 0xFFFFFFFF : PROC_REG_MASK(proc_desc);
249 float_mask = kernel_trap ? 0xFFFFFFFF : PROC_FREG_MASK(proc_desc);
251 if (/* In any frame other than the innermost, we assume that all
252 registers have been saved. This assumes that all register
253 saves in a function happen before the first function
257 /* In a dummy frame we know exactly where things are saved. */
258 && !PROC_DESC_IS_DUMMY (proc_desc)
260 /* Not sure exactly what kernel_trap means, but if it means
261 the kernel saves the registers without a prologue doing it,
262 we better not examine the prologue to see whether registers
263 have been saved yet. */
266 /* We need to figure out whether the registers that the proc_desc
267 claims are saved have been saved yet. */
274 /* Bitmasks; set if we have found a save for the register. */
275 unsigned long gen_save_found = 0;
276 unsigned long float_save_found = 0;
278 for (addr = PROC_LOW_ADDR (proc_desc);
279 addr < fci->pc /*&& (gen_mask != gen_save_found
280 || float_mask != float_save_found)*/;
283 status = read_memory_nobpt (addr, buf, 4);
285 memory_error (status, addr);
286 inst = extract_unsigned_integer (buf, 4);
287 if (/* sw reg,n($sp) */
288 (inst & 0xffe00000) == 0xafa00000
291 || (inst & 0xffe00000) == 0xafc00000
294 || (inst & 0xffe00000) == 0xffa00000)
296 /* It might be possible to use the instruction to
297 find the offset, rather than the code below which
298 is based on things being in a certain order in the
299 frame, but figuring out what the instruction's offset
300 is relative to might be a little tricky. */
301 int reg = (inst & 0x001f0000) >> 16;
302 gen_save_found |= (1 << reg);
304 else if (/* swc1 freg,n($sp) */
305 (inst & 0xffe00000) == 0xe7a00000
307 /* swc1 freg,n($r30) */
308 || (inst & 0xffe00000) == 0xe7c00000
310 /* sdc1 freg,n($sp) */
311 || (inst & 0xffe00000) == 0xf7a00000)
314 int reg = ((inst & 0x001f0000) >> 16);
315 float_save_found |= (1 << reg);
318 gen_mask = gen_save_found;
319 float_mask = float_save_found;
322 /* Fill in the offsets for the registers which gen_mask says
324 reg_position = fci->frame + PROC_REG_OFFSET (proc_desc);
325 for (ireg= 31; gen_mask; --ireg, gen_mask <<= 1)
326 if (gen_mask & 0x80000000)
328 fci->saved_regs->regs[ireg] = reg_position;
329 reg_position -= MIPS_REGSIZE;
331 /* Fill in the offsets for the registers which float_mask says
333 reg_position = fci->frame + PROC_FREG_OFFSET (proc_desc);
335 /* The freg_offset points to where the first *double* register
336 is saved. So skip to the high-order word. */
338 for (ireg = 31; float_mask; --ireg, float_mask <<= 1)
339 if (float_mask & 0x80000000)
341 fci->saved_regs->regs[FP0_REGNUM+ireg] = reg_position;
342 reg_position -= MIPS_REGSIZE;
345 fci->saved_regs->regs[PC_REGNUM] = fci->saved_regs->regs[RA_REGNUM];
349 read_next_frame_reg(fi, regno)
350 struct frame_info *fi;
353 for (; fi; fi = fi->next)
355 /* We have to get the saved sp from the sigcontext
356 if it is a signal handler frame. */
357 if (regno == SP_REGNUM && !fi->signal_handler_caller)
361 if (fi->saved_regs == NULL)
362 mips_find_saved_regs (fi);
363 if (fi->saved_regs->regs[regno])
364 return read_memory_integer(fi->saved_regs->regs[regno], MIPS_REGSIZE);
367 return read_register (regno);
371 mips_frame_saved_pc(frame)
372 struct frame_info *frame;
374 mips_extra_func_info_t proc_desc = frame->proc_desc;
375 /* We have to get the saved pc from the sigcontext
376 if it is a signal handler frame. */
377 int pcreg = frame->signal_handler_caller ? PC_REGNUM
378 : (proc_desc ? PROC_PC_REG(proc_desc) : RA_REGNUM);
380 if (proc_desc && PROC_DESC_IS_DUMMY(proc_desc))
381 return read_memory_integer(frame->frame - 4, 4);
383 return read_next_frame_reg(frame, pcreg);
386 static struct mips_extra_func_info temp_proc_desc;
387 static struct frame_saved_regs temp_saved_regs;
389 /* This fencepost looks highly suspicious to me. Removing it also
390 seems suspicious as it could affect remote debugging across serial
394 heuristic_proc_start(pc)
397 CORE_ADDR start_pc = pc;
398 CORE_ADDR fence = start_pc - heuristic_fence_post;
400 if (start_pc == 0) return 0;
402 if (heuristic_fence_post == UINT_MAX
403 || fence < VM_MIN_ADDRESS)
404 fence = VM_MIN_ADDRESS;
406 /* search back for previous return */
407 for (start_pc -= 4; ; start_pc -= 4)
408 if (start_pc < fence)
410 /* It's not clear to me why we reach this point when
411 stop_soon_quietly, but with this test, at least we
412 don't print out warnings for every child forked (eg, on
414 if (!stop_soon_quietly)
416 static int blurb_printed = 0;
418 if (fence == VM_MIN_ADDRESS)
419 warning("Hit beginning of text section without finding");
421 warning("Hit heuristic-fence-post without finding");
423 warning("enclosing function for address 0x%x", pc);
427 This warning occurs if you are debugging a function without any symbols\n\
428 (for example, in a stripped executable). In that case, you may wish to\n\
429 increase the size of the search with the `set heuristic-fence-post' command.\n\
431 Otherwise, you told GDB there was a function where there isn't one, or\n\
432 (more likely) you have encountered a bug in GDB.\n");
439 else if (ABOUT_TO_RETURN(start_pc))
442 start_pc += 8; /* skip return, and its delay slot */
444 /* skip nops (usually 1) 0 - is this */
445 while (start_pc < pc && read_memory_integer (start_pc, 4) == 0)
451 static mips_extra_func_info_t
452 heuristic_proc_desc(start_pc, limit_pc, next_frame)
453 CORE_ADDR start_pc, limit_pc;
454 struct frame_info *next_frame;
456 CORE_ADDR sp = read_next_frame_reg (next_frame, SP_REGNUM);
459 int has_frame_reg = 0;
460 int reg30 = 0; /* Value of $r30. Used by gcc for frame-pointer */
461 unsigned long reg_mask = 0;
463 if (start_pc == 0) return NULL;
464 memset (&temp_proc_desc, '\0', sizeof(temp_proc_desc));
465 memset (&temp_saved_regs, '\0', sizeof(struct frame_saved_regs));
466 PROC_LOW_ADDR (&temp_proc_desc) = start_pc;
468 if (start_pc + 200 < limit_pc)
469 limit_pc = start_pc + 200;
472 for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += 4) {
477 status = read_memory_nobpt (cur_pc, buf, 4);
478 if (status) memory_error (status, cur_pc);
479 word = extract_unsigned_integer (buf, 4);
481 if ((word & 0xFFFF0000) == 0x27bd0000) /* addiu $sp,$sp,-i */
482 frame_size += (-word) & 0xFFFF;
483 else if ((word & 0xFFFF0000) == 0x23bd0000) /* addu $sp,$sp,-i */
484 frame_size += (-word) & 0xFFFF;
485 else if ((word & 0xFFE00000) == 0xafa00000) { /* sw reg,offset($sp) */
486 int reg = (word & 0x001F0000) >> 16;
487 reg_mask |= 1 << reg;
488 temp_saved_regs.regs[reg] = sp + (word & 0xffff);
490 else if ((word & 0xFFFF0000) == 0x27be0000) { /* addiu $30,$sp,size */
491 if ((word & 0xffff) != frame_size)
492 reg30 = sp + (word & 0xffff);
493 else if (!has_frame_reg) {
496 reg30 = read_next_frame_reg(next_frame, 30);
497 alloca_adjust = reg30 - (sp + (word & 0xffff));
498 if (alloca_adjust > 0) {
499 /* FP > SP + frame_size. This may be because
500 * of an alloca or somethings similar.
501 * Fix sp to "pre-alloca" value, and try again.
508 else if ((word & 0xFFE00000) == 0xafc00000) { /* sw reg,offset($30) */
509 int reg = (word & 0x001F0000) >> 16;
510 reg_mask |= 1 << reg;
511 temp_saved_regs.regs[reg] = reg30 + (word & 0xffff);
515 PROC_FRAME_REG(&temp_proc_desc) = 30;
516 PROC_FRAME_OFFSET(&temp_proc_desc) = 0;
519 PROC_FRAME_REG(&temp_proc_desc) = SP_REGNUM;
520 PROC_FRAME_OFFSET(&temp_proc_desc) = frame_size;
522 PROC_REG_MASK(&temp_proc_desc) = reg_mask;
523 PROC_PC_REG(&temp_proc_desc) = RA_REGNUM;
524 return &temp_proc_desc;
527 static mips_extra_func_info_t
528 find_proc_desc (pc, next_frame)
530 struct frame_info *next_frame;
532 mips_extra_func_info_t proc_desc;
533 struct block *b = block_for_pc(pc);
537 find_pc_partial_function (pc, NULL, &startaddr, NULL);
542 if (startaddr > BLOCK_START (b))
543 /* This is the "pathological" case referred to in a comment in
544 print_frame_info. It might be better to move this check into
548 sym = lookup_symbol (MIPS_EFI_SYMBOL_NAME, b, LABEL_NAMESPACE,
552 /* If we never found a PDR for this function in symbol reading, then
553 examine prologues to find the information. */
554 if (sym && ((mips_extra_func_info_t) SYMBOL_VALUE (sym))->pdr.framereg == -1)
559 /* IF this is the topmost frame AND
560 * (this proc does not have debugging information OR
561 * the PC is in the procedure prologue)
562 * THEN create a "heuristic" proc_desc (by analyzing
563 * the actual code) to replace the "official" proc_desc.
565 proc_desc = (mips_extra_func_info_t) SYMBOL_VALUE (sym);
566 if (next_frame == NULL) {
567 struct symtab_and_line val;
568 struct symbol *proc_symbol =
569 PROC_DESC_IS_DUMMY(proc_desc) ? 0 : PROC_SYMBOL(proc_desc);
572 val = find_pc_line (BLOCK_START
573 (SYMBOL_BLOCK_VALUE(proc_symbol)),
575 val.pc = val.end ? val.end : pc;
577 if (!proc_symbol || pc < val.pc) {
578 mips_extra_func_info_t found_heuristic =
579 heuristic_proc_desc (PROC_LOW_ADDR (proc_desc),
582 proc_desc = found_heuristic;
588 /* Is linked_proc_desc_table really necessary? It only seems to be used
589 by procedure call dummys. However, the procedures being called ought
590 to have their own proc_descs, and even if they don't,
591 heuristic_proc_desc knows how to create them! */
593 register struct linked_proc_info *link;
595 for (link = linked_proc_desc_table; link; link = link->next)
596 if (PROC_LOW_ADDR(&link->info) <= pc
597 && PROC_HIGH_ADDR(&link->info) > pc)
601 startaddr = heuristic_proc_start (pc);
604 heuristic_proc_desc (startaddr, pc, next_frame);
609 mips_extra_func_info_t cached_proc_desc;
612 mips_frame_chain(frame)
613 struct frame_info *frame;
615 mips_extra_func_info_t proc_desc;
616 CORE_ADDR saved_pc = FRAME_SAVED_PC(frame);
618 if (saved_pc == 0 || inside_entry_file (saved_pc))
621 proc_desc = find_proc_desc(saved_pc, frame);
625 cached_proc_desc = proc_desc;
627 /* If no frame pointer and frame size is zero, we must be at end
628 of stack (or otherwise hosed). If we don't check frame size,
629 we loop forever if we see a zero size frame. */
630 if (PROC_FRAME_REG (proc_desc) == SP_REGNUM
631 && PROC_FRAME_OFFSET (proc_desc) == 0
632 /* The previous frame from a sigtramp frame might be frameless
633 and have frame size zero. */
634 && !frame->signal_handler_caller)
637 return read_next_frame_reg(frame, PROC_FRAME_REG(proc_desc))
638 + PROC_FRAME_OFFSET(proc_desc);
642 init_extra_frame_info(fci)
643 struct frame_info *fci;
645 /* Use proc_desc calculated in frame_chain */
646 mips_extra_func_info_t proc_desc =
647 fci->next ? cached_proc_desc : find_proc_desc(fci->pc, fci->next);
649 fci->saved_regs = NULL;
651 proc_desc == &temp_proc_desc ? 0 : proc_desc;
654 /* Fixup frame-pointer - only needed for top frame */
655 /* This may not be quite right, if proc has a real frame register.
656 Get the value of the frame relative sp, procedure might have been
657 interrupted by a signal at it's very start. */
658 if (fci->pc == PROC_LOW_ADDR (proc_desc)
659 && !PROC_DESC_IS_DUMMY (proc_desc))
660 fci->frame = read_next_frame_reg (fci->next, SP_REGNUM);
663 read_next_frame_reg (fci->next, PROC_FRAME_REG (proc_desc))
664 + PROC_FRAME_OFFSET (proc_desc);
666 if (proc_desc == &temp_proc_desc)
668 fci->saved_regs = (struct frame_saved_regs*)
669 obstack_alloc (&frame_cache_obstack,
670 sizeof (struct frame_saved_regs));
671 *fci->saved_regs = temp_saved_regs;
672 fci->saved_regs->regs[PC_REGNUM] = fci->saved_regs->regs[RA_REGNUM];
675 /* hack: if argument regs are saved, guess these contain args */
676 if ((PROC_REG_MASK(proc_desc) & 0xF0) == 0) fci->num_args = -1;
677 else if ((PROC_REG_MASK(proc_desc) & 0x80) == 0) fci->num_args = 4;
678 else if ((PROC_REG_MASK(proc_desc) & 0x40) == 0) fci->num_args = 3;
679 else if ((PROC_REG_MASK(proc_desc) & 0x20) == 0) fci->num_args = 2;
680 else if ((PROC_REG_MASK(proc_desc) & 0x10) == 0) fci->num_args = 1;
684 /* MIPS stack frames are almost impenetrable. When execution stops,
685 we basically have to look at symbol information for the function
686 that we stopped in, which tells us *which* register (if any) is
687 the base of the frame pointer, and what offset from that register
688 the frame itself is at.
690 This presents a problem when trying to examine a stack in memory
691 (that isn't executing at the moment), using the "frame" command. We
692 don't have a PC, nor do we have any registers except SP.
694 This routine takes two arguments, SP and PC, and tries to make the
695 cached frames look as if these two arguments defined a frame on the
696 cache. This allows the rest of info frame to extract the important
697 arguments without difficulty. */
700 setup_arbitrary_frame (argc, argv)
705 error ("MIPS frame specifications require two arguments: sp and pc");
707 return create_new_frame (argv[0], argv[1]);
712 mips_push_arguments(nargs, args, sp, struct_return, struct_addr)
717 CORE_ADDR struct_addr;
720 int accumulate_size = struct_return ? MIPS_REGSIZE : 0;
721 struct mips_arg { char *contents; int len; int offset; };
722 struct mips_arg *mips_args =
723 (struct mips_arg*)alloca((nargs + 4) * sizeof(struct mips_arg));
724 register struct mips_arg *m_arg;
727 for (i = 0, m_arg = mips_args; i < nargs; i++, m_arg++) {
728 value_ptr arg = args[i];
729 m_arg->len = TYPE_LENGTH (VALUE_TYPE (arg));
730 /* This entire mips-specific routine is because doubles must be aligned
731 * on 8-byte boundaries. It still isn't quite right, because MIPS decided
732 * to align 'struct {int a, b}' on 4-byte boundaries (even though this
733 * breaks their varargs implementation...). A correct solution
734 * requires an simulation of gcc's 'alignof' (and use of 'alignof'
735 * in stdarg.h/varargs.h).
736 * On the 64 bit r4000 we always pass the first four arguments
737 * using eight bytes each, so that we can load them up correctly
741 accumulate_size = (accumulate_size + 7) & -8;
742 m_arg->offset = accumulate_size;
743 m_arg->contents = VALUE_CONTENTS(arg);
744 if (! GDB_TARGET_IS_MIPS64)
745 accumulate_size = (accumulate_size + m_arg->len + 3) & -4;
748 if (accumulate_size >= 4 * MIPS_REGSIZE)
749 accumulate_size = (accumulate_size + m_arg->len + 3) &~ 4;
752 static char zeroes[8] = { 0 };
753 int len = m_arg->len;
757 if (TARGET_BYTE_ORDER == BIG_ENDIAN)
758 m_arg->offset += 8 - len;
760 m_arg->len = 8 - len;
761 m_arg->contents = zeroes;
762 if (TARGET_BYTE_ORDER == BIG_ENDIAN)
763 m_arg->offset = accumulate_size;
765 m_arg->offset = accumulate_size + len;
768 accumulate_size = (accumulate_size + len + 7) & ~8;
772 accumulate_size = (accumulate_size + 7) & (-8);
773 if (accumulate_size < 4 * MIPS_REGSIZE)
774 accumulate_size = 4 * MIPS_REGSIZE;
775 sp -= accumulate_size;
776 for (i = nargs + fake_args; m_arg--, --i >= 0; )
777 write_memory(sp + m_arg->offset, m_arg->contents, m_arg->len);
780 char buf[TARGET_PTR_BIT / HOST_CHAR_BIT];
782 store_address (buf, sizeof buf, struct_addr);
783 write_memory (sp, buf, sizeof buf);
788 /* MASK(i,j) == (1<<i) + (1<<(i+1)) + ... + (1<<j)). Assume i<=j<31. */
789 #define MASK(i,j) (((1 << ((j)+1))-1) ^ ((1 << (i))-1))
792 mips_push_dummy_frame()
794 char buffer[MAX_REGISTER_RAW_SIZE];
796 struct linked_proc_info *link = (struct linked_proc_info*)
797 xmalloc(sizeof(struct linked_proc_info));
798 mips_extra_func_info_t proc_desc = &link->info;
799 CORE_ADDR sp = read_register (SP_REGNUM);
800 CORE_ADDR save_address;
801 link->next = linked_proc_desc_table;
802 linked_proc_desc_table = link;
803 #define PUSH_FP_REGNUM 16 /* must be a register preserved across calls */
804 #define GEN_REG_SAVE_MASK MASK(1,16)|MASK(24,28)|(1<<31)
805 #define GEN_REG_SAVE_COUNT 22
806 #define FLOAT_REG_SAVE_MASK MASK(0,19)
807 #define FLOAT_REG_SAVE_COUNT 20
808 #define FLOAT_SINGLE_REG_SAVE_MASK \
809 ((1<<18)|(1<<16)|(1<<14)|(1<<12)|(1<<10)|(1<<8)|(1<<6)|(1<<4)|(1<<2)|(1<<0))
810 #define FLOAT_SINGLE_REG_SAVE_COUNT 10
811 #define SPECIAL_REG_SAVE_COUNT 4
813 * The registers we must save are all those not preserved across
814 * procedure calls. Dest_Reg (see tm-mips.h) must also be saved.
815 * In addition, we must save the PC, and PUSH_FP_REGNUM.
816 * (Ideally, we should also save MDLO/-HI and FP Control/Status reg.)
818 * Dummy frame layout:
821 * Saved MMHI, MMLO, FPC_CSR
826 * Saved D18 (i.e. F19, F18)
828 * Saved D0 (i.e. F1, F0)
829 * CALL_DUMMY (subroutine stub; see tm-mips.h)
830 * Parameter build area (not yet implemented)
833 PROC_REG_MASK(proc_desc) = GEN_REG_SAVE_MASK;
836 case MIPS_FPU_DOUBLE:
837 PROC_FREG_MASK(proc_desc) = FLOAT_REG_SAVE_MASK;
839 case MIPS_FPU_SINGLE:
840 PROC_FREG_MASK(proc_desc) = FLOAT_SINGLE_REG_SAVE_MASK;
843 PROC_FREG_MASK(proc_desc) = 0;
846 PROC_REG_OFFSET(proc_desc) = /* offset of (Saved R31) from FP */
847 -sizeof(long) - 4 * SPECIAL_REG_SAVE_COUNT;
848 PROC_FREG_OFFSET(proc_desc) = /* offset of (Saved D18) from FP */
849 -sizeof(double) - 4 * (SPECIAL_REG_SAVE_COUNT + GEN_REG_SAVE_COUNT);
850 /* save general registers */
851 save_address = sp + PROC_REG_OFFSET(proc_desc);
852 for (ireg = 32; --ireg >= 0; )
853 if (PROC_REG_MASK(proc_desc) & (1 << ireg))
855 read_register_gen (ireg, buffer);
857 /* Need to fix the save_address decrement below, and also make sure
858 that we don't run into problems with the size of the dummy frame
859 or any of the offsets within it. */
860 if (REGISTER_RAW_SIZE (ireg) > 4)
861 error ("Cannot call functions on mips64");
863 write_memory (save_address, buffer, REGISTER_RAW_SIZE (ireg));
866 /* save floating-points registers starting with high order word */
867 save_address = sp + PROC_FREG_OFFSET(proc_desc) + 4;
868 for (ireg = 32; --ireg >= 0; )
869 if (PROC_FREG_MASK(proc_desc) & (1 << ireg))
871 read_register_gen (ireg + FP0_REGNUM, buffer);
873 if (REGISTER_RAW_SIZE (ireg + FP0_REGNUM) > 4)
874 error ("Cannot call functions on mips64");
876 write_memory (save_address, buffer,
877 REGISTER_RAW_SIZE (ireg + FP0_REGNUM));
880 write_register (PUSH_FP_REGNUM, sp);
881 PROC_FRAME_REG(proc_desc) = PUSH_FP_REGNUM;
882 PROC_FRAME_OFFSET(proc_desc) = 0;
883 read_register_gen (PC_REGNUM, buffer);
884 write_memory (sp - 4, buffer, REGISTER_RAW_SIZE (PC_REGNUM));
885 read_register_gen (HI_REGNUM, buffer);
886 write_memory (sp - 8, buffer, REGISTER_RAW_SIZE (HI_REGNUM));
887 read_register_gen (LO_REGNUM, buffer);
888 write_memory (sp - 12, buffer, REGISTER_RAW_SIZE (LO_REGNUM));
889 if (mips_fpu != MIPS_FPU_NONE)
890 read_register_gen (FCRCS_REGNUM, buffer);
892 memset (buffer, 0, REGISTER_RAW_SIZE (FCRCS_REGNUM));
893 write_memory (sp - 16, buffer, REGISTER_RAW_SIZE (FCRCS_REGNUM));
894 sp -= 4 * (GEN_REG_SAVE_COUNT + SPECIAL_REG_SAVE_COUNT);
895 if (mips_fpu == MIPS_FPU_DOUBLE)
896 sp -= 4 * FLOAT_REG_SAVE_COUNT;
897 else if (mips_fpu == MIPS_FPU_SINGLE)
898 sp -= 4 * FLOAT_SINGLE_REG_SAVE_COUNT;
899 write_register (SP_REGNUM, sp);
900 PROC_LOW_ADDR(proc_desc) = sp - CALL_DUMMY_SIZE + CALL_DUMMY_START_OFFSET;
901 PROC_HIGH_ADDR(proc_desc) = sp;
902 SET_PROC_DESC_IS_DUMMY(proc_desc);
903 PROC_PC_REG(proc_desc) = RA_REGNUM;
910 struct frame_info *frame = get_current_frame ();
911 CORE_ADDR new_sp = FRAME_FP (frame);
913 mips_extra_func_info_t proc_desc = frame->proc_desc;
915 write_register (PC_REGNUM, FRAME_SAVED_PC(frame));
916 if (frame->saved_regs == NULL)
917 mips_find_saved_regs (frame);
920 for (regnum = 32; --regnum >= 0; )
921 if (PROC_REG_MASK(proc_desc) & (1 << regnum))
922 write_register (regnum,
923 read_memory_integer (frame->saved_regs->regs[regnum],
925 for (regnum = 32; --regnum >= 0; )
926 if (PROC_FREG_MASK(proc_desc) & (1 << regnum))
927 write_register (regnum + FP0_REGNUM,
928 read_memory_integer (frame->saved_regs->regs[regnum + FP0_REGNUM], 4));
930 write_register (SP_REGNUM, new_sp);
931 flush_cached_frames ();
933 if (proc_desc && PROC_DESC_IS_DUMMY(proc_desc))
935 struct linked_proc_info *pi_ptr, *prev_ptr;
937 for (pi_ptr = linked_proc_desc_table, prev_ptr = NULL;
939 prev_ptr = pi_ptr, pi_ptr = pi_ptr->next)
941 if (&pi_ptr->info == proc_desc)
946 error ("Can't locate dummy extra frame info\n");
948 if (prev_ptr != NULL)
949 prev_ptr->next = pi_ptr->next;
951 linked_proc_desc_table = pi_ptr->next;
955 write_register (HI_REGNUM, read_memory_integer(new_sp - 8, 4));
956 write_register (LO_REGNUM, read_memory_integer(new_sp - 12, 4));
957 if (mips_fpu != MIPS_FPU_NONE)
958 write_register (FCRCS_REGNUM, read_memory_integer(new_sp - 16, 4));
963 mips_print_register (regnum, all)
966 char raw_buffer[MAX_REGISTER_RAW_SIZE];
968 /* Get the data in raw format. */
969 if (read_relative_register_raw_bytes (regnum, raw_buffer))
971 printf_filtered ("%s: [Invalid]", reg_names[regnum]);
975 /* If an even floating pointer register, also print as double. */
976 if (regnum >= FP0_REGNUM && regnum < FP0_REGNUM+32
977 && !((regnum-FP0_REGNUM) & 1))
979 char dbuffer[MAX_REGISTER_RAW_SIZE];
981 read_relative_register_raw_bytes (regnum, dbuffer);
982 read_relative_register_raw_bytes (regnum+1, dbuffer+4);
983 #ifdef REGISTER_CONVERT_TO_TYPE
984 REGISTER_CONVERT_TO_TYPE(regnum, builtin_type_double, dbuffer);
986 printf_filtered ("(d%d: ", regnum-FP0_REGNUM);
987 val_print (builtin_type_double, dbuffer, 0,
988 gdb_stdout, 0, 1, 0, Val_pretty_default);
989 printf_filtered ("); ");
991 fputs_filtered (reg_names[regnum], gdb_stdout);
993 /* The problem with printing numeric register names (r26, etc.) is that
994 the user can't use them on input. Probably the best solution is to
995 fix it so that either the numeric or the funky (a2, etc.) names
996 are accepted on input. */
998 printf_filtered ("(r%d): ", regnum);
1000 printf_filtered (": ");
1002 /* If virtual format is floating, print it that way. */
1003 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT)
1004 val_print (REGISTER_VIRTUAL_TYPE (regnum), raw_buffer, 0,
1005 gdb_stdout, 0, 1, 0, Val_pretty_default);
1006 /* Else print as integer in hex. */
1008 print_scalar_formatted (raw_buffer, REGISTER_VIRTUAL_TYPE (regnum),
1009 'x', 0, gdb_stdout);
1012 /* Replacement for generic do_registers_info. */
1015 mips_do_registers_info (regnum, fpregs)
1021 if (*(reg_names[regnum]) == '\0')
1022 error ("Not a valid register for the current processor type");
1024 mips_print_register (regnum, 0);
1025 printf_filtered ("\n");
1031 for (regnum = 0; regnum < NUM_REGS; )
1033 if (((!fpregs) && regnum >= FP0_REGNUM && regnum <= FCRIR_REGNUM)
1034 || *(reg_names[regnum]) == '\0')
1039 mips_print_register (regnum, 1);
1041 printf_filtered ("; ");
1043 if ((regnum & 3) == 0)
1045 printf_filtered ("\n");
1050 printf_filtered ("\n");
1054 /* Return number of args passed to a frame. described by FIP.
1055 Can return -1, meaning no way to tell. */
1058 mips_frame_num_args (frame)
1059 struct frame_info *frame;
1061 #if 0 /* FIXME Use or lose this! */
1062 struct chain_info_t *p;
1064 p = mips_find_cached_frame (FRAME_FP (frame));
1066 return p->the_info.numargs;
1071 /* Is this a branch with a delay slot? */
1073 static int is_delayed PARAMS ((unsigned long));
1080 for (i = 0; i < NUMOPCODES; ++i)
1081 if (mips_opcodes[i].pinfo != INSN_MACRO
1082 && (insn & mips_opcodes[i].mask) == mips_opcodes[i].match)
1084 return (i < NUMOPCODES
1085 && (mips_opcodes[i].pinfo & (INSN_UNCOND_BRANCH_DELAY
1086 | INSN_COND_BRANCH_DELAY
1087 | INSN_COND_BRANCH_LIKELY)));
1091 mips_step_skips_delay (pc)
1096 if (target_read_memory (pc, buf, 4) != 0)
1097 /* If error reading memory, guess that it is not a delayed branch. */
1099 return is_delayed (extract_unsigned_integer (buf, 4));
1102 /* To skip prologues, I use this predicate. Returns either PC itself
1103 if the code at PC does not look like a function prologue; otherwise
1104 returns an address that (if we're lucky) follows the prologue. If
1105 LENIENT, then we must skip everything which is involved in setting
1106 up the frame (it's OK to skip more, just so long as we don't skip
1107 anything which might clobber the registers which are being saved.
1108 We must skip more in the case where part of the prologue is in the
1109 delay slot of a non-prologue instruction). */
1112 mips_skip_prologue (pc, lenient)
1118 int seen_sp_adjust = 0;
1119 int load_immediate_bytes = 0;
1121 /* Skip the typical prologue instructions. These are the stack adjustment
1122 instruction and the instructions that save registers on the stack
1123 or in the gcc frame. */
1124 for (offset = 0; offset < 100; offset += 4)
1129 status = read_memory_nobpt (pc + offset, buf, 4);
1131 memory_error (status, pc + offset);
1132 inst = extract_unsigned_integer (buf, 4);
1135 if (lenient && is_delayed (inst))
1139 if ((inst & 0xffff0000) == 0x27bd0000) /* addiu $sp,$sp,offset */
1141 else if (inst == 0x03a1e823 || /* subu $sp,$sp,$at */
1142 inst == 0x03a8e823) /* subu $sp,$sp,$t0 */
1144 else if ((inst & 0xFFE00000) == 0xAFA00000 && (inst & 0x001F0000))
1145 continue; /* sw reg,n($sp) */
1147 else if ((inst & 0xFFE00000) == 0xE7A00000) /* swc1 freg,n($sp) */
1149 else if ((inst & 0xF3E00000) == 0xA3C00000 && (inst & 0x001F0000))
1151 continue; /* reg != $zero */
1153 /* move $s8,$sp. With different versions of gas this will be either
1154 `addu $s8,$sp,$zero' or `or $s8,$sp,$zero'. Accept either. */
1155 else if (inst == 0x03A0F021 || inst == 0x03a0f025)
1158 else if ((inst & 0xFF9F07FF) == 0x00800021) /* move reg,$a0-$a3 */
1160 else if ((inst & 0xffff0000) == 0x3c1c0000) /* lui $gp,n */
1162 else if ((inst & 0xffff0000) == 0x279c0000) /* addiu $gp,$gp,n */
1164 else if (inst == 0x0399e021 /* addu $gp,$gp,$t9 */
1165 || inst == 0x033ce021) /* addu $gp,$t9,$gp */
1167 /* The following instructions load $at or $t0 with an immediate
1168 value in preparation for a stack adjustment via
1169 subu $sp,$sp,[$at,$t0]. These instructions could also initialize
1170 a local variable, so we accept them only before a stack adjustment
1171 instruction was seen. */
1172 else if (!seen_sp_adjust)
1174 if ((inst & 0xffff0000) == 0x3c010000 || /* lui $at,n */
1175 (inst & 0xffff0000) == 0x3c080000) /* lui $t0,n */
1177 load_immediate_bytes += 4;
1180 else if ((inst & 0xffff0000) == 0x34210000 || /* ori $at,$at,n */
1181 (inst & 0xffff0000) == 0x35080000 || /* ori $t0,$t0,n */
1182 (inst & 0xffff0000) == 0x34010000 || /* ori $at,$zero,n */
1183 (inst & 0xffff0000) == 0x34080000) /* ori $t0,$zero,n */
1185 load_immediate_bytes += 4;
1195 /* In a frameless function, we might have incorrectly
1196 skipped some load immediate instructions. Undo the skipping
1197 if the load immediate was not followed by a stack adjustment. */
1198 if (load_immediate_bytes && !seen_sp_adjust)
1199 offset -= load_immediate_bytes;
1204 /* The lenient prologue stuff should be superceded by the code in
1205 init_extra_frame_info which looks to see whether the stores mentioned
1206 in the proc_desc have actually taken place. */
1208 /* Is address PC in the prologue (loosely defined) for function at
1212 mips_in_lenient_prologue (startaddr, pc)
1213 CORE_ADDR startaddr;
1216 CORE_ADDR end_prologue = mips_skip_prologue (startaddr, 1);
1217 return pc >= startaddr && pc < end_prologue;
1221 /* Given a return value in `regbuf' with a type `valtype',
1222 extract and copy its value into `valbuf'. */
1224 mips_extract_return_value (valtype, regbuf, valbuf)
1225 struct type *valtype;
1226 char regbuf[REGISTER_BYTES];
1232 if (TYPE_CODE (valtype) == TYPE_CODE_FLT
1233 && (mips_fpu == MIPS_FPU_DOUBLE
1234 || (mips_fpu == MIPS_FPU_SINGLE && TYPE_LENGTH (valtype) <= 4)))
1235 regnum = FP0_REGNUM;
1237 memcpy (valbuf, regbuf + REGISTER_BYTE (regnum), TYPE_LENGTH (valtype));
1238 #ifdef REGISTER_CONVERT_TO_TYPE
1239 REGISTER_CONVERT_TO_TYPE(regnum, valtype, valbuf);
1243 /* Given a return value in `regbuf' with a type `valtype',
1244 write it's value into the appropriate register. */
1246 mips_store_return_value (valtype, valbuf)
1247 struct type *valtype;
1251 char raw_buffer[MAX_REGISTER_RAW_SIZE];
1254 if (TYPE_CODE (valtype) == TYPE_CODE_FLT
1255 && (mips_fpu == MIPS_FPU_DOUBLE
1256 || (mips_fpu == MIPS_FPU_SINGLE && TYPE_LENGTH (valtype) <= 4)))
1257 regnum = FP0_REGNUM;
1259 memcpy(raw_buffer, valbuf, TYPE_LENGTH (valtype));
1261 #ifdef REGISTER_CONVERT_FROM_TYPE
1262 REGISTER_CONVERT_FROM_TYPE(regnum, valtype, raw_buffer);
1265 write_register_bytes(REGISTER_BYTE (regnum), raw_buffer, TYPE_LENGTH (valtype));
1268 /* These exist in mdebugread.c. */
1269 extern CORE_ADDR sigtramp_address, sigtramp_end;
1270 extern void fixup_sigtramp PARAMS ((void));
1272 /* Exported procedure: Is PC in the signal trampoline code */
1275 in_sigtramp (pc, ignore)
1277 char *ignore; /* function name */
1279 if (sigtramp_address == 0)
1281 return (pc >= sigtramp_address && pc < sigtramp_end);
1284 /* Command to set FPU type. mips_fpu_string will have been set to the
1285 user's argument. Set mips_fpu based on mips_fpu_string, and then
1286 canonicalize mips_fpu_string. */
1290 mips_set_fpu_command (args, from_tty, c)
1293 struct cmd_list_element *c;
1297 if (mips_fpu_string == NULL || *mips_fpu_string == '\0')
1298 mips_fpu = MIPS_FPU_DOUBLE;
1299 else if (strcasecmp (mips_fpu_string, "double") == 0
1300 || strcasecmp (mips_fpu_string, "on") == 0
1301 || strcasecmp (mips_fpu_string, "1") == 0
1302 || strcasecmp (mips_fpu_string, "yes") == 0)
1303 mips_fpu = MIPS_FPU_DOUBLE;
1304 else if (strcasecmp (mips_fpu_string, "none") == 0
1305 || strcasecmp (mips_fpu_string, "off") == 0
1306 || strcasecmp (mips_fpu_string, "0") == 0
1307 || strcasecmp (mips_fpu_string, "no") == 0)
1308 mips_fpu = MIPS_FPU_NONE;
1309 else if (strcasecmp (mips_fpu_string, "single") == 0)
1310 mips_fpu = MIPS_FPU_SINGLE;
1312 err = strsave (mips_fpu_string);
1314 if (mips_fpu_string != NULL)
1315 free (mips_fpu_string);
1319 case MIPS_FPU_DOUBLE:
1320 mips_fpu_string = strsave ("double");
1322 case MIPS_FPU_SINGLE:
1323 mips_fpu_string = strsave ("single");
1326 mips_fpu_string = strsave ("none");
1332 struct cleanup *cleanups = make_cleanup (free, err);
1333 error ("Unknown FPU type `%s'. Use `double', `none', or `single'.",
1335 do_cleanups (cleanups);
1340 mips_show_fpu_command (args, from_tty, c)
1343 struct cmd_list_element *c;
1347 /* Command to set the processor type. */
1350 mips_set_processor_type_command (args, from_tty)
1356 if (tmp_mips_processor_type == NULL || *tmp_mips_processor_type == '\0')
1358 printf_unfiltered ("The known MIPS processor types are as follows:\n\n");
1359 for (i = 0; mips_processor_type_table[i].name != NULL; ++i)
1360 printf_unfiltered ("%s\n", mips_processor_type_table[i].name);
1362 /* Restore the value. */
1363 tmp_mips_processor_type = strsave (mips_processor_type);
1368 if (!mips_set_processor_type (tmp_mips_processor_type))
1370 error ("Unknown processor type `%s'.", tmp_mips_processor_type);
1371 /* Restore its value. */
1372 tmp_mips_processor_type = strsave (mips_processor_type);
1377 mips_show_processor_type_command (args, from_tty)
1383 /* Modify the actual processor type. */
1386 mips_set_processor_type (str)
1394 for (i = 0; mips_processor_type_table[i].name != NULL; ++i)
1396 if (strcasecmp (str, mips_processor_type_table[i].name) == 0)
1398 mips_processor_type = str;
1400 for (j = 0; j < NUM_REGS; ++j)
1401 reg_names[j] = mips_processor_type_table[i].regnames[j];
1405 /* FIXME tweak fpu flag too */
1412 /* Attempt to identify the particular processor model by reading the
1416 mips_read_processor_type ()
1420 prid = read_register (PRID_REGNUM);
1422 if (prid & ~0xf == 0x700)
1423 return savestring ("r3041", strlen("r3041"));
1428 /* Just like reinit_frame_cache, but with the right arguments to be
1429 callable as an sfunc. */
1432 reinit_frame_cache_sfunc (args, from_tty, c)
1435 struct cmd_list_element *c;
1437 reinit_frame_cache ();
1441 gdb_print_insn_mips (memaddr, info)
1443 disassemble_info *info;
1445 if (TARGET_BYTE_ORDER == BIG_ENDIAN)
1446 return print_insn_big_mips (memaddr, info);
1448 return print_insn_little_mips (memaddr, info);
1452 _initialize_mips_tdep ()
1454 struct cmd_list_element *c;
1456 tm_print_insn = gdb_print_insn_mips;
1458 /* Let the user turn off floating point and set the fence post for
1459 heuristic_proc_start. */
1461 c = add_set_cmd ("mipsfpu", class_support, var_string_noescape,
1462 (char *) &mips_fpu_string,
1463 "Set use of floating point coprocessor.\n\
1464 Set to `none' to avoid using floating point instructions when calling\n\
1465 functions or dealing with return values. Set to `single' to use only\n\
1466 single precision floating point as on the R4650. Set to `double' for\n\
1467 normal floating point support.",
1469 c->function.sfunc = mips_set_fpu_command;
1470 c = add_show_from_set (c, &showlist);
1471 c->function.sfunc = mips_show_fpu_command;
1473 mips_fpu = MIPS_FPU_DOUBLE;
1474 mips_fpu_string = strsave ("double");
1476 c = add_set_cmd ("processor", class_support, var_string_noescape,
1477 (char *) &tmp_mips_processor_type,
1478 "Set the type of MIPS processor in use.\n\
1479 Set this to be able to access processor-type-specific registers.\n\
1482 c->function.cfunc = mips_set_processor_type_command;
1483 c = add_show_from_set (c, &showlist);
1484 c->function.cfunc = mips_show_processor_type_command;
1486 tmp_mips_processor_type = strsave (DEFAULT_MIPS_TYPE);
1487 mips_set_processor_type_command (strsave (DEFAULT_MIPS_TYPE), 0);
1489 /* We really would like to have both "0" and "unlimited" work, but
1490 command.c doesn't deal with that. So make it a var_zinteger
1491 because the user can always use "999999" or some such for unlimited. */
1492 c = add_set_cmd ("heuristic-fence-post", class_support, var_zinteger,
1493 (char *) &heuristic_fence_post,
1495 Set the distance searched for the start of a function.\n\
1496 If you are debugging a stripped executable, GDB needs to search through the\n\
1497 program for the start of a function. This command sets the distance of the\n\
1498 search. The only need to set it is when debugging a stripped executable.",
1500 /* We need to throw away the frame cache when we set this, since it
1501 might change our ability to get backtraces. */
1502 c->function.sfunc = reinit_frame_cache_sfunc;
1503 add_show_from_set (c, &showlist);