1 // OBSOLETE /* Target-dependent code for the Mitsubishi m32r for GDB, the GNU debugger.
3 // OBSOLETE Copyright 1996, 1998, 1999, 2000, 2001, 2003 Free Software
4 // OBSOLETE Foundation, Inc.
6 // OBSOLETE This file is part of GDB.
8 // OBSOLETE This program is free software; you can redistribute it and/or modify
9 // OBSOLETE it under the terms of the GNU General Public License as published by
10 // OBSOLETE the Free Software Foundation; either version 2 of the License, or
11 // OBSOLETE (at your option) any later version.
13 // OBSOLETE This program is distributed in the hope that it will be useful,
14 // OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // OBSOLETE GNU General Public License for more details.
18 // OBSOLETE You should have received a copy of the GNU General Public License
19 // OBSOLETE along with this program; if not, write to the Free Software
20 // OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330,
21 // OBSOLETE Boston, MA 02111-1307, USA. */
23 // OBSOLETE #include "defs.h"
24 // OBSOLETE #include "frame.h"
25 // OBSOLETE #include "inferior.h"
26 // OBSOLETE #include "target.h"
27 // OBSOLETE #include "value.h"
28 // OBSOLETE #include "bfd.h"
29 // OBSOLETE #include "gdb_string.h"
30 // OBSOLETE #include "gdbcore.h"
31 // OBSOLETE #include "symfile.h"
32 // OBSOLETE #include "regcache.h"
34 // OBSOLETE /* Function: m32r_use_struct_convention
35 // OBSOLETE Return nonzero if call_function should allocate stack space for a
36 // OBSOLETE struct return? */
38 // OBSOLETE m32r_use_struct_convention (int gcc_p, struct type *type)
40 // OBSOLETE return (TYPE_LENGTH (type) > 8);
43 // OBSOLETE /* Function: frame_find_saved_regs
44 // OBSOLETE Return the frame_saved_regs structure for the frame.
45 // OBSOLETE Doesn't really work for dummy frames, but it does pass back
46 // OBSOLETE an empty frame_saved_regs, so I guess that's better than total failure */
49 // OBSOLETE m32r_frame_find_saved_regs (struct frame_info *fi,
50 // OBSOLETE struct frame_saved_regs *regaddr)
52 // OBSOLETE memcpy (regaddr, &fi->fsr, sizeof (struct frame_saved_regs));
55 // OBSOLETE /* Turn this on if you want to see just how much instruction decoding
56 // OBSOLETE if being done, its quite a lot
59 // OBSOLETE static void
60 // OBSOLETE dump_insn (char *commnt, CORE_ADDR pc, int insn)
62 // OBSOLETE printf_filtered (" %s %08x %08x ",
63 // OBSOLETE commnt, (unsigned int) pc, (unsigned int) insn);
64 // OBSOLETE TARGET_PRINT_INSN (pc, &tm_print_insn_info);
65 // OBSOLETE printf_filtered ("\n");
67 // OBSOLETE #define insn_debug(args) { printf_filtered args; }
69 // OBSOLETE #define dump_insn(a,b,c) {}
70 // OBSOLETE #define insn_debug(args) {}
73 // OBSOLETE #define DEFAULT_SEARCH_LIMIT 44
75 // OBSOLETE /* Function: scan_prologue
76 // OBSOLETE This function decodes the target function prologue to determine
77 // OBSOLETE 1) the size of the stack frame, and 2) which registers are saved on it.
78 // OBSOLETE It saves the offsets of saved regs in the frame_saved_regs argument,
79 // OBSOLETE and returns the frame size. */
82 // OBSOLETE The sequence it currently generates is:
84 // OBSOLETE if (varargs function) { ddi sp,#n }
85 // OBSOLETE push registers
86 // OBSOLETE if (additional stack <= 256) { addi sp,#-stack }
87 // OBSOLETE else if (additional stack < 65k) { add3 sp,sp,#-stack
89 // OBSOLETE } else if (additional stack) {
90 // OBSOLETE seth sp,#(stack & 0xffff0000)
91 // OBSOLETE or3 sp,sp,#(stack & 0x0000ffff)
94 // OBSOLETE if (frame pointer) {
98 // OBSOLETE These instructions are scheduled like everything else, so you should stop at
99 // OBSOLETE the first branch instruction.
103 // OBSOLETE /* This is required by skip prologue and by m32r_init_extra_frame_info.
104 // OBSOLETE The results of decoding a prologue should be cached because this
105 // OBSOLETE thrashing is getting nuts.
106 // OBSOLETE I am thinking of making a container class with two indexes, name and
107 // OBSOLETE address. It may be better to extend the symbol table.
110 // OBSOLETE static void
111 // OBSOLETE decode_prologue (CORE_ADDR start_pc, CORE_ADDR scan_limit, CORE_ADDR *pl_endptr, /* var parameter */
112 // OBSOLETE unsigned long *framelength, struct frame_info *fi,
113 // OBSOLETE struct frame_saved_regs *fsr)
115 // OBSOLETE unsigned long framesize;
116 // OBSOLETE int insn;
118 // OBSOLETE int maybe_one_more = 0;
119 // OBSOLETE CORE_ADDR after_prologue = 0;
120 // OBSOLETE CORE_ADDR after_stack_adjust = 0;
121 // OBSOLETE CORE_ADDR current_pc;
124 // OBSOLETE framesize = 0;
125 // OBSOLETE after_prologue = 0;
126 // OBSOLETE insn_debug (("rd prolog l(%d)\n", scan_limit - current_pc));
128 // OBSOLETE for (current_pc = start_pc; current_pc < scan_limit; current_pc += 2)
131 // OBSOLETE insn = read_memory_unsigned_integer (current_pc, 2);
132 // OBSOLETE dump_insn ("insn-1", current_pc, insn); /* MTZ */
134 // OBSOLETE /* If this is a 32 bit instruction, we dont want to examine its
135 // OBSOLETE immediate data as though it were an instruction */
136 // OBSOLETE if (current_pc & 0x02)
137 // OBSOLETE { /* Clear the parallel execution bit from 16 bit instruction */
138 // OBSOLETE if (maybe_one_more)
139 // OBSOLETE { /* The last instruction was a branch, usually terminates
140 // OBSOLETE the series, but if this is a parallel instruction,
141 // OBSOLETE it may be a stack framing instruction */
142 // OBSOLETE if (!(insn & 0x8000))
144 // OBSOLETE insn_debug (("Really done"));
145 // OBSOLETE break; /* nope, we are really done */
148 // OBSOLETE insn &= 0x7fff; /* decode this instruction further */
152 // OBSOLETE if (maybe_one_more)
153 // OBSOLETE break; /* This isnt the one more */
154 // OBSOLETE if (insn & 0x8000)
156 // OBSOLETE insn_debug (("32 bit insn\n"));
157 // OBSOLETE if (current_pc == scan_limit)
158 // OBSOLETE scan_limit += 2; /* extend the search */
159 // OBSOLETE current_pc += 2; /* skip the immediate data */
160 // OBSOLETE if (insn == 0x8faf) /* add3 sp, sp, xxxx */
161 // OBSOLETE /* add 16 bit sign-extended offset */
163 // OBSOLETE insn_debug (("stack increment\n"));
164 // OBSOLETE framesize += -((short) read_memory_unsigned_integer (current_pc, 2));
168 // OBSOLETE if (((insn >> 8) == 0xe4) && /* ld24 r4, xxxxxx; sub sp, r4 */
169 // OBSOLETE read_memory_unsigned_integer (current_pc + 2, 2) == 0x0f24)
170 // OBSOLETE { /* subtract 24 bit sign-extended negative-offset */
171 // OBSOLETE dump_insn ("insn-2", current_pc + 2, insn);
172 // OBSOLETE insn = read_memory_unsigned_integer (current_pc - 2, 4);
173 // OBSOLETE dump_insn ("insn-3(l4)", current_pc - 2, insn);
174 // OBSOLETE if (insn & 0x00800000) /* sign extend */
175 // OBSOLETE insn |= 0xff000000; /* negative */
177 // OBSOLETE insn &= 0x00ffffff; /* positive */
178 // OBSOLETE framesize += insn;
181 // OBSOLETE after_prologue = current_pc;
182 // OBSOLETE continue;
185 // OBSOLETE op1 = insn & 0xf000; /* isolate just the first nibble */
187 // OBSOLETE if ((insn & 0xf0ff) == 0x207f)
188 // OBSOLETE { /* st reg, @-sp */
189 // OBSOLETE int regno;
190 // OBSOLETE insn_debug (("push\n"));
191 // OBSOLETE #if 0 /* No, PUSH FP is not an indication that we will use a frame pointer. */
192 // OBSOLETE if (((insn & 0xffff) == 0x2d7f) && fi)
193 // OBSOLETE fi->using_frame_pointer = 1;
195 // OBSOLETE framesize += 4;
197 // OBSOLETE /* Why should we increase the scan limit, just because we did a push?
198 // OBSOLETE And if there is a reason, surely we would only want to do it if we
199 // OBSOLETE had already reached the scan limit... */
200 // OBSOLETE if (current_pc == scan_limit)
201 // OBSOLETE scan_limit += 2;
203 // OBSOLETE regno = ((insn >> 8) & 0xf);
204 // OBSOLETE if (fsr) /* save_regs offset */
205 // OBSOLETE fsr->regs[regno] = framesize;
206 // OBSOLETE after_prologue = 0;
207 // OBSOLETE continue;
209 // OBSOLETE if ((insn >> 8) == 0x4f) /* addi sp, xx */
210 // OBSOLETE /* add 8 bit sign-extended offset */
212 // OBSOLETE int stack_adjust = (char) (insn & 0xff);
214 // OBSOLETE /* there are probably two of these stack adjustments:
215 // OBSOLETE 1) A negative one in the prologue, and
216 // OBSOLETE 2) A positive one in the epilogue.
217 // OBSOLETE We are only interested in the first one. */
219 // OBSOLETE if (stack_adjust < 0)
221 // OBSOLETE framesize -= stack_adjust;
222 // OBSOLETE after_prologue = 0;
223 // OBSOLETE /* A frameless function may have no "mv fp, sp".
224 // OBSOLETE In that case, this is the end of the prologue. */
225 // OBSOLETE after_stack_adjust = current_pc + 2;
227 // OBSOLETE continue;
229 // OBSOLETE if (insn == 0x1d8f)
230 // OBSOLETE { /* mv fp, sp */
232 // OBSOLETE fi->using_frame_pointer = 1; /* fp is now valid */
233 // OBSOLETE insn_debug (("done fp found\n"));
234 // OBSOLETE after_prologue = current_pc + 2;
235 // OBSOLETE break; /* end of stack adjustments */
237 // OBSOLETE if (insn == 0x7000) /* Nop looks like a branch, continue explicitly */
239 // OBSOLETE insn_debug (("nop\n"));
240 // OBSOLETE after_prologue = current_pc + 2;
241 // OBSOLETE continue; /* nop occurs between pushes */
243 // OBSOLETE /* End of prolog if any of these are branch instructions */
244 // OBSOLETE if ((op1 == 0x7000)
245 // OBSOLETE || (op1 == 0xb000)
246 // OBSOLETE || (op1 == 0xf000))
248 // OBSOLETE after_prologue = current_pc;
249 // OBSOLETE insn_debug (("Done: branch\n"));
250 // OBSOLETE maybe_one_more = 1;
251 // OBSOLETE continue;
253 // OBSOLETE /* Some of the branch instructions are mixed with other types */
254 // OBSOLETE if (op1 == 0x1000)
256 // OBSOLETE int subop = insn & 0x0ff0;
257 // OBSOLETE if ((subop == 0x0ec0) || (subop == 0x0fc0))
259 // OBSOLETE insn_debug (("done: jmp\n"));
260 // OBSOLETE after_prologue = current_pc;
261 // OBSOLETE maybe_one_more = 1;
262 // OBSOLETE continue; /* jmp , jl */
267 // OBSOLETE if (current_pc >= scan_limit)
269 // OBSOLETE if (pl_endptr)
272 // OBSOLETE if (after_stack_adjust != 0)
273 // OBSOLETE /* We did not find a "mv fp,sp", but we DID find
274 // OBSOLETE a stack_adjust. Is it safe to use that as the
275 // OBSOLETE end of the prologue? I just don't know. */
277 // OBSOLETE *pl_endptr = after_stack_adjust;
278 // OBSOLETE if (framelength)
279 // OBSOLETE *framelength = framesize;
283 // OBSOLETE /* We reached the end of the loop without finding the end
284 // OBSOLETE of the prologue. No way to win -- we should report failure.
285 // OBSOLETE The way we do that is to return the original start_pc.
286 // OBSOLETE GDB will set a breakpoint at the start of the function (etc.) */
287 // OBSOLETE *pl_endptr = start_pc;
291 // OBSOLETE if (after_prologue == 0)
292 // OBSOLETE after_prologue = current_pc;
294 // OBSOLETE insn_debug ((" framesize %d, firstline %08x\n", framesize, after_prologue));
295 // OBSOLETE if (framelength)
296 // OBSOLETE *framelength = framesize;
297 // OBSOLETE if (pl_endptr)
298 // OBSOLETE *pl_endptr = after_prologue;
299 // OBSOLETE } /* decode_prologue */
301 // OBSOLETE /* Function: skip_prologue
302 // OBSOLETE Find end of function prologue */
304 // OBSOLETE CORE_ADDR
305 // OBSOLETE m32r_skip_prologue (CORE_ADDR pc)
307 // OBSOLETE CORE_ADDR func_addr, func_end;
308 // OBSOLETE struct symtab_and_line sal;
310 // OBSOLETE /* See what the symbol table says */
312 // OBSOLETE if (find_pc_partial_function (pc, NULL, &func_addr, &func_end))
314 // OBSOLETE sal = find_pc_line (func_addr, 0);
316 // OBSOLETE if (sal.line != 0 && sal.end <= func_end)
319 // OBSOLETE insn_debug (("BP after prologue %08x\n", sal.end));
320 // OBSOLETE func_end = sal.end;
323 // OBSOLETE /* Either there's no line info, or the line after the prologue is after
324 // OBSOLETE the end of the function. In this case, there probably isn't a
325 // OBSOLETE prologue. */
327 // OBSOLETE insn_debug (("No line info, line(%x) sal_end(%x) funcend(%x)\n",
328 // OBSOLETE sal.line, sal.end, func_end));
329 // OBSOLETE func_end = min (func_end, func_addr + DEFAULT_SEARCH_LIMIT);
333 // OBSOLETE func_end = pc + DEFAULT_SEARCH_LIMIT;
334 // OBSOLETE decode_prologue (pc, func_end, &sal.end, 0, 0, 0);
335 // OBSOLETE return sal.end;
338 // OBSOLETE static unsigned long
339 // OBSOLETE m32r_scan_prologue (struct frame_info *fi, struct frame_saved_regs *fsr)
341 // OBSOLETE struct symtab_and_line sal;
342 // OBSOLETE CORE_ADDR prologue_start, prologue_end, current_pc;
343 // OBSOLETE unsigned long framesize = 0;
345 // OBSOLETE /* this code essentially duplicates skip_prologue,
346 // OBSOLETE but we need the start address below. */
348 // OBSOLETE if (find_pc_partial_function (fi->pc, NULL, &prologue_start, &prologue_end))
350 // OBSOLETE sal = find_pc_line (prologue_start, 0);
352 // OBSOLETE if (sal.line == 0) /* no line info, use current PC */
353 // OBSOLETE if (prologue_start == entry_point_address ())
354 // OBSOLETE return 0;
358 // OBSOLETE prologue_start = fi->pc;
359 // OBSOLETE prologue_end = prologue_start + 48; /* We're in the boondocks:
360 // OBSOLETE allow for 16 pushes, an add,
361 // OBSOLETE and "mv fp,sp" */
364 // OBSOLETE prologue_end = min (prologue_end, fi->pc);
366 // OBSOLETE insn_debug (("fipc(%08x) start(%08x) end(%08x)\n",
367 // OBSOLETE fi->pc, prologue_start, prologue_end));
368 // OBSOLETE prologue_end = min (prologue_end, prologue_start + DEFAULT_SEARCH_LIMIT);
369 // OBSOLETE decode_prologue (prologue_start, prologue_end, &prologue_end, &framesize,
370 // OBSOLETE fi, fsr);
371 // OBSOLETE return framesize;
374 // OBSOLETE /* Function: init_extra_frame_info
375 // OBSOLETE This function actually figures out the frame address for a given pc and
376 // OBSOLETE sp. This is tricky on the m32r because we sometimes don't use an explicit
377 // OBSOLETE frame pointer, and the previous stack pointer isn't necessarily recorded
378 // OBSOLETE on the stack. The only reliable way to get this info is to
379 // OBSOLETE examine the prologue. */
382 // OBSOLETE m32r_init_extra_frame_info (struct frame_info *fi)
386 // OBSOLETE if (fi->next)
387 // OBSOLETE fi->pc = FRAME_SAVED_PC (fi->next);
389 // OBSOLETE memset (fi->fsr.regs, '\000', sizeof fi->fsr.regs);
391 // OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
393 // OBSOLETE /* We need to setup fi->frame here because run_stack_dummy gets it wrong
394 // OBSOLETE by assuming it's always FP. */
395 // OBSOLETE fi->frame = deprecated_read_register_dummy (fi->pc, fi->frame,
396 // OBSOLETE SP_REGNUM);
397 // OBSOLETE fi->framesize = 0;
402 // OBSOLETE fi->using_frame_pointer = 0;
403 // OBSOLETE fi->framesize = m32r_scan_prologue (fi, &fi->fsr);
405 // OBSOLETE if (!fi->next)
406 // OBSOLETE if (fi->using_frame_pointer)
408 // OBSOLETE fi->frame = read_register (FP_REGNUM);
411 // OBSOLETE fi->frame = read_register (SP_REGNUM);
413 // OBSOLETE /* fi->next means this is not the innermost frame */ if (fi->using_frame_pointer)
414 // OBSOLETE /* we have an FP */
415 // OBSOLETE if (fi->next->fsr.regs[FP_REGNUM] != 0) /* caller saved our FP */
416 // OBSOLETE fi->frame = read_memory_integer (fi->next->fsr.regs[FP_REGNUM], 4);
417 // OBSOLETE for (reg = 0; reg < NUM_REGS; reg++)
418 // OBSOLETE if (fi->fsr.regs[reg] != 0)
419 // OBSOLETE fi->fsr.regs[reg] = fi->frame + fi->framesize - fi->fsr.regs[reg];
423 // OBSOLETE /* Function: m32r_virtual_frame_pointer
424 // OBSOLETE Return the register that the function uses for a frame pointer,
425 // OBSOLETE plus any necessary offset to be applied to the register before
426 // OBSOLETE any frame pointer offsets. */
429 // OBSOLETE m32r_virtual_frame_pointer (CORE_ADDR pc, long *reg, long *offset)
431 // OBSOLETE struct frame_info *fi = deprecated_frame_xmalloc ();
432 // OBSOLETE struct cleanup *old_chain = make_cleanup (xfree, fi);
434 // OBSOLETE /* Set up a dummy frame_info. */
435 // OBSOLETE fi->next = NULL;
436 // OBSOLETE fi->prev = NULL;
437 // OBSOLETE fi->frame = 0;
438 // OBSOLETE fi->pc = pc;
440 // OBSOLETE /* Analyze the prolog and fill in the extra info. */
441 // OBSOLETE m32r_init_extra_frame_info (fi);
443 // OBSOLETE /* Results will tell us which type of frame it uses. */
444 // OBSOLETE if (fi->using_frame_pointer)
446 // OBSOLETE *reg = FP_REGNUM;
447 // OBSOLETE *offset = 0;
451 // OBSOLETE *reg = SP_REGNUM;
452 // OBSOLETE *offset = 0;
454 // OBSOLETE do_cleanups (old_chain);
457 // OBSOLETE /* Function: find_callers_reg
458 // OBSOLETE Find REGNUM on the stack. Otherwise, it's in an active register. One thing
459 // OBSOLETE we might want to do here is to check REGNUM against the clobber mask, and
460 // OBSOLETE somehow flag it as invalid if it isn't saved on the stack somewhere. This
461 // OBSOLETE would provide a graceful failure mode when trying to get the value of
462 // OBSOLETE caller-saves registers for an inner frame. */
464 // OBSOLETE CORE_ADDR
465 // OBSOLETE m32r_find_callers_reg (struct frame_info *fi, int regnum)
467 // OBSOLETE for (; fi; fi = fi->next)
468 // OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
469 // OBSOLETE return deprecated_read_register_dummy (fi->pc, fi->frame, regnum);
470 // OBSOLETE else if (fi->fsr.regs[regnum] != 0)
471 // OBSOLETE return read_memory_integer (fi->fsr.regs[regnum],
472 // OBSOLETE REGISTER_RAW_SIZE (regnum));
473 // OBSOLETE return read_register (regnum);
476 // OBSOLETE /* Function: frame_chain Given a GDB frame, determine the address of
477 // OBSOLETE the calling function's frame. This will be used to create a new
478 // OBSOLETE GDB frame struct, and then INIT_EXTRA_FRAME_INFO and
479 // OBSOLETE DEPRECATED_INIT_FRAME_PC will be called for the new frame. For
480 // OBSOLETE m32r, we save the frame size when we initialize the frame_info. */
482 // OBSOLETE CORE_ADDR
483 // OBSOLETE m32r_frame_chain (struct frame_info *fi)
485 // OBSOLETE CORE_ADDR fn_start, callers_pc, fp;
487 // OBSOLETE /* is this a dummy frame? */
488 // OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
489 // OBSOLETE return fi->frame; /* dummy frame same as caller's frame */
491 // OBSOLETE /* is caller-of-this a dummy frame? */
492 // OBSOLETE callers_pc = FRAME_SAVED_PC (fi); /* find out who called us: */
493 // OBSOLETE fp = m32r_find_callers_reg (fi, FP_REGNUM);
494 // OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (callers_pc, fp, fp))
495 // OBSOLETE return fp; /* dummy frame's frame may bear no relation to ours */
497 // OBSOLETE if (find_pc_partial_function (fi->pc, 0, &fn_start, 0))
498 // OBSOLETE if (fn_start == entry_point_address ())
499 // OBSOLETE return 0; /* in _start fn, don't chain further */
500 // OBSOLETE if (fi->framesize == 0)
502 // OBSOLETE printf_filtered ("cannot determine frame size @ %s , pc(%s)\n",
503 // OBSOLETE paddr (fi->frame),
504 // OBSOLETE paddr (fi->pc));
505 // OBSOLETE return 0;
507 // OBSOLETE insn_debug (("m32rx frame %08x\n", fi->frame + fi->framesize));
508 // OBSOLETE return fi->frame + fi->framesize;
511 // OBSOLETE /* Function: push_return_address (pc)
512 // OBSOLETE Set up the return address for the inferior function call.
513 // OBSOLETE Necessary for targets that don't actually execute a JSR/BSR instruction
514 // OBSOLETE (ie. when using an empty CALL_DUMMY) */
516 // OBSOLETE CORE_ADDR
517 // OBSOLETE m32r_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
519 // OBSOLETE write_register (RP_REGNUM, CALL_DUMMY_ADDRESS ());
520 // OBSOLETE return sp;
524 // OBSOLETE /* Function: pop_frame
525 // OBSOLETE Discard from the stack the innermost frame,
526 // OBSOLETE restoring all saved registers. */
528 // OBSOLETE struct frame_info *
529 // OBSOLETE m32r_pop_frame (struct frame_info *frame)
531 // OBSOLETE int regnum;
533 // OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
534 // OBSOLETE generic_pop_dummy_frame ();
537 // OBSOLETE for (regnum = 0; regnum < NUM_REGS; regnum++)
538 // OBSOLETE if (frame->fsr.regs[regnum] != 0)
539 // OBSOLETE write_register (regnum,
540 // OBSOLETE read_memory_integer (frame->fsr.regs[regnum], 4));
542 // OBSOLETE write_register (PC_REGNUM, FRAME_SAVED_PC (frame));
543 // OBSOLETE write_register (SP_REGNUM, read_register (FP_REGNUM));
544 // OBSOLETE if (read_register (PSW_REGNUM) & 0x80)
545 // OBSOLETE write_register (SPU_REGNUM, read_register (SP_REGNUM));
547 // OBSOLETE write_register (SPI_REGNUM, read_register (SP_REGNUM));
549 // OBSOLETE flush_cached_frames ();
550 // OBSOLETE return NULL;
553 // OBSOLETE /* Function: frame_saved_pc
554 // OBSOLETE Find the caller of this frame. We do this by seeing if RP_REGNUM is saved
555 // OBSOLETE in the stack anywhere, otherwise we get it from the registers. */
557 // OBSOLETE CORE_ADDR
558 // OBSOLETE m32r_frame_saved_pc (struct frame_info *fi)
560 // OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
561 // OBSOLETE return deprecated_read_register_dummy (fi->pc, fi->frame, PC_REGNUM);
563 // OBSOLETE return m32r_find_callers_reg (fi, RP_REGNUM);
566 // OBSOLETE /* Function: push_arguments
567 // OBSOLETE Setup the function arguments for calling a function in the inferior.
569 // OBSOLETE On the Mitsubishi M32R architecture, there are four registers (R0 to R3)
570 // OBSOLETE which are dedicated for passing function arguments. Up to the first
571 // OBSOLETE four arguments (depending on size) may go into these registers.
572 // OBSOLETE The rest go on the stack.
574 // OBSOLETE Arguments that are smaller than 4 bytes will still take up a whole
575 // OBSOLETE register or a whole 32-bit word on the stack, and will be
576 // OBSOLETE right-justified in the register or the stack word. This includes
577 // OBSOLETE chars, shorts, and small aggregate types.
579 // OBSOLETE Arguments of 8 bytes size are split between two registers, if
580 // OBSOLETE available. If only one register is available, the argument will
581 // OBSOLETE be split between the register and the stack. Otherwise it is
582 // OBSOLETE passed entirely on the stack. Aggregate types with sizes between
583 // OBSOLETE 4 and 8 bytes are passed entirely on the stack, and are left-justified
584 // OBSOLETE within the double-word (as opposed to aggregates smaller than 4 bytes
585 // OBSOLETE which are right-justified).
587 // OBSOLETE Aggregates of greater than 8 bytes are first copied onto the stack,
588 // OBSOLETE and then a pointer to the copy is passed in the place of the normal
589 // OBSOLETE argument (either in a register if available, or on the stack).
591 // OBSOLETE Functions that must return an aggregate type can return it in the
592 // OBSOLETE normal return value registers (R0 and R1) if its size is 8 bytes or
593 // OBSOLETE less. For larger return values, the caller must allocate space for
594 // OBSOLETE the callee to copy the return value to. A pointer to this space is
595 // OBSOLETE passed as an implicit first argument, always in R0. */
597 // OBSOLETE CORE_ADDR
598 // OBSOLETE m32r_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
599 // OBSOLETE unsigned char struct_return, CORE_ADDR struct_addr)
601 // OBSOLETE int stack_offset, stack_alloc;
602 // OBSOLETE int argreg;
603 // OBSOLETE int argnum;
604 // OBSOLETE struct type *type;
605 // OBSOLETE CORE_ADDR regval;
606 // OBSOLETE char *val;
607 // OBSOLETE char valbuf[4];
609 // OBSOLETE int odd_sized_struct;
611 // OBSOLETE /* first force sp to a 4-byte alignment */
612 // OBSOLETE sp = sp & ~3;
614 // OBSOLETE argreg = ARG0_REGNUM;
615 // OBSOLETE /* The "struct return pointer" pseudo-argument goes in R0 */
616 // OBSOLETE if (struct_return)
617 // OBSOLETE write_register (argreg++, struct_addr);
619 // OBSOLETE /* Now make sure there's space on the stack */
620 // OBSOLETE for (argnum = 0, stack_alloc = 0;
621 // OBSOLETE argnum < nargs; argnum++)
622 // OBSOLETE stack_alloc += ((TYPE_LENGTH (VALUE_TYPE (args[argnum])) + 3) & ~3);
623 // OBSOLETE sp -= stack_alloc; /* make room on stack for args */
626 // OBSOLETE /* Now load as many as possible of the first arguments into
627 // OBSOLETE registers, and push the rest onto the stack. There are 16 bytes
628 // OBSOLETE in four registers available. Loop thru args from first to last. */
630 // OBSOLETE argreg = ARG0_REGNUM;
631 // OBSOLETE for (argnum = 0, stack_offset = 0; argnum < nargs; argnum++)
633 // OBSOLETE type = VALUE_TYPE (args[argnum]);
634 // OBSOLETE len = TYPE_LENGTH (type);
635 // OBSOLETE memset (valbuf, 0, sizeof (valbuf));
636 // OBSOLETE if (len < 4)
637 // OBSOLETE { /* value gets right-justified in the register or stack word */
638 // OBSOLETE memcpy (valbuf + (4 - len),
639 // OBSOLETE (char *) VALUE_CONTENTS (args[argnum]), len);
640 // OBSOLETE val = valbuf;
643 // OBSOLETE val = (char *) VALUE_CONTENTS (args[argnum]);
645 // OBSOLETE if (len > 4 && (len & 3) != 0)
646 // OBSOLETE odd_sized_struct = 1; /* such structs go entirely on stack */
648 // OBSOLETE odd_sized_struct = 0;
649 // OBSOLETE while (len > 0)
651 // OBSOLETE if (argreg > ARGLAST_REGNUM || odd_sized_struct)
652 // OBSOLETE { /* must go on the stack */
653 // OBSOLETE write_memory (sp + stack_offset, val, 4);
654 // OBSOLETE stack_offset += 4;
656 // OBSOLETE /* NOTE WELL!!!!! This is not an "else if" clause!!!
657 // OBSOLETE That's because some *&^%$ things get passed on the stack
658 // OBSOLETE AND in the registers! */
659 // OBSOLETE if (argreg <= ARGLAST_REGNUM)
660 // OBSOLETE { /* there's room in a register */
661 // OBSOLETE regval = extract_address (val, REGISTER_RAW_SIZE (argreg));
662 // OBSOLETE write_register (argreg++, regval);
664 // OBSOLETE /* Store the value 4 bytes at a time. This means that things
665 // OBSOLETE larger than 4 bytes may go partly in registers and partly
666 // OBSOLETE on the stack. */
667 // OBSOLETE len -= REGISTER_RAW_SIZE (argreg);
668 // OBSOLETE val += REGISTER_RAW_SIZE (argreg);
671 // OBSOLETE return sp;
674 // OBSOLETE /* Function: fix_call_dummy
675 // OBSOLETE If there is real CALL_DUMMY code (eg. on the stack), this function
676 // OBSOLETE has the responsability to insert the address of the actual code that
677 // OBSOLETE is the target of the target function call. */
680 // OBSOLETE m32r_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs,
681 // OBSOLETE struct value **args, struct type *type, int gcc_p)
683 // OBSOLETE /* ld24 r8, <(imm24) fun> */
684 // OBSOLETE *(unsigned long *) (dummy) = (fun & 0x00ffffff) | 0xe8000000;
688 // OBSOLETE /* Function: m32r_write_sp
689 // OBSOLETE Because SP is really a read-only register that mirrors either SPU or SPI,
690 // OBSOLETE we must actually write one of those two as well, depending on PSW. */
693 // OBSOLETE m32r_write_sp (CORE_ADDR val)
695 // OBSOLETE unsigned long psw = read_register (PSW_REGNUM);
697 // OBSOLETE if (psw & 0x80) /* stack mode: user or interrupt */
698 // OBSOLETE write_register (SPU_REGNUM, val);
700 // OBSOLETE write_register (SPI_REGNUM, val);
701 // OBSOLETE write_register (SP_REGNUM, val);
705 // OBSOLETE _initialize_m32r_tdep (void)
707 // OBSOLETE tm_print_insn = print_insn_m32r;
This page took 0.044984 seconds and 4 git commands to generate.