1 /* Target-dependent code for the Matsushita MN10200 for GDB, the GNU debugger.
2 Copyright 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
27 #include "gdb_string.h"
33 /* Should call_function allocate stack space for a struct return? */
35 mn10200_use_struct_convention (int gcc_p
, struct type
*type
)
37 return (TYPE_NFIELDS (type
) > 1 || TYPE_LENGTH (type
) > 8);
40 /* The main purpose of this file is dealing with prologues to extract
41 information about stack frames and saved registers.
43 For reference here's how prologues look on the mn10200:
49 Register saves for d2, d3, a1, a2 as needed. Saves start
50 at fp - <size> + <outgoing_args_size> and work towards higher
51 addresses. Note that the saves are actually done off the stack
52 pointer in the prologue! This makes for smaller code and easier
53 prologue scanning as the displacement fields will unlikely
56 Without frame pointer:
58 Register saves for d2, d3, a1, a2 as needed. Saves start
59 at sp + <outgoing_args_size> and work towards higher addresses.
62 add <local size>,sp -- optional
64 add <outgoing_size>,sp -- optional
66 The stack pointer remains constant throughout the life of most
67 functions. As a result the compiler will usually omit the
68 frame pointer, so we must handle frame pointerless functions. */
70 /* Analyze the prologue to determine where registers are saved,
71 the end of the prologue, etc etc. Return the end of the prologue
74 We store into FI (if non-null) several tidbits of information:
76 * stack_size -- size of this stack frame. Note that if we stop in
77 certain parts of the prologue/epilogue we may claim the size of the
78 current frame is zero. This happens when the current frame has
79 not been allocated yet or has already been deallocated.
81 * fsr -- Addresses of registers saved in the stack by this frame.
83 * status -- A (relatively) generic status indicator. It's a bitmask
84 with the following bits:
86 MY_FRAME_IN_SP: The base of the current frame is actually in
87 the stack pointer. This can happen for frame pointerless
88 functions, or cases where we're stopped in the prologue/epilogue
89 itself. For these cases mn10200_analyze_prologue will need up
90 update fi->frame before returning or analyzing the register
93 MY_FRAME_IN_FP: The base of the current frame is in the
94 frame pointer register ($a2).
96 CALLER_A2_IN_A0: $a2 from the caller's frame is temporarily
97 in $a0. This can happen if we're stopped in the prologue.
99 NO_MORE_FRAMES: Set this if the current frame is "start" or
100 if the first instruction looks like mov <imm>,sp. This tells
101 frame chain to not bother trying to unwind past this frame. */
107 #define MY_FRAME_IN_SP 0x1
108 #define MY_FRAME_IN_FP 0x2
109 #define CALLER_A2_IN_A0 0x4
110 #define NO_MORE_FRAMES 0x8
113 mn10200_analyze_prologue (struct frame_info
*fi
, CORE_ADDR pc
)
115 CORE_ADDR func_addr
, func_end
, addr
, stop
;
116 CORE_ADDR stack_size
= 0;
117 unsigned char buf
[4];
120 int out_of_line_prologue
= 0;
122 /* Use the PC in the frame if it's provided to look up the
123 start of this function. */
124 pc
= (fi
? get_frame_pc (fi
) : pc
);
126 /* Find the start of this function. */
127 status
= find_pc_partial_function (pc
, &name
, &func_addr
, &func_end
);
129 /* Do nothing if we couldn't find the start of this function or if we're
130 stopped at the first instruction in the prologue. */
134 /* If we're in start, then give up. */
135 if (strcmp (name
, "start") == 0)
138 fi
->status
= NO_MORE_FRAMES
;
142 /* At the start of a function our frame is in the stack pointer. */
144 fi
->status
= MY_FRAME_IN_SP
;
146 /* If we're physically on an RTS instruction, then our frame has already
149 fi->frame is bogus, we need to fix it. */
150 if (fi
&& get_frame_pc (fi
) + 1 == func_end
)
152 status
= target_read_memory (get_frame_pc (fi
), buf
, 1);
155 if (get_next_frame (fi
) == NULL
)
156 deprecated_update_frame_base_hack (fi
, read_sp ());
157 return get_frame_pc (fi
);
162 if (get_next_frame (fi
) == NULL
)
163 deprecated_update_frame_base_hack (fi
, read_sp ());
164 return get_frame_pc (fi
);
168 /* Similarly if we're stopped on the first insn of a prologue as our
169 frame hasn't been allocated yet. */
170 if (fi
&& get_frame_pc (fi
) == func_addr
)
172 if (get_next_frame (fi
) == NULL
)
173 deprecated_update_frame_base_hack (fi
, read_sp ());
174 return get_frame_pc (fi
);
177 /* Figure out where to stop scanning. */
178 stop
= fi
? get_frame_pc (fi
) : func_end
;
180 /* Don't walk off the end of the function. */
181 stop
= stop
> func_end
? func_end
: stop
;
183 /* Start scanning on the first instruction of this function. */
186 status
= target_read_memory (addr
, buf
, 2);
189 if (fi
&& get_next_frame (fi
) == NULL
&& fi
->status
& MY_FRAME_IN_SP
)
190 deprecated_update_frame_base_hack (fi
, read_sp ());
194 /* First see if this insn sets the stack pointer; if so, it's something
195 we won't understand, so quit now. */
197 || (buf
[0] == 0xf4 && buf
[1] == 0x77))
200 fi
->status
= NO_MORE_FRAMES
;
204 /* Now see if we have a frame pointer.
206 Search for mov a2,a0 (0xf278)
207 then mov a3,a2 (0xf27e). */
209 if (buf
[0] == 0xf2 && buf
[1] == 0x78)
211 /* Our caller's $a2 will be found in $a0 now. Note it for
214 fi
->status
|= CALLER_A2_IN_A0
;
218 /* We still haven't allocated our local stack. Handle this
219 as if we stopped on the first or last insn of a function. */
220 if (fi
&& get_next_frame (fi
) == NULL
)
221 deprecated_update_frame_base_hack (fi
, read_sp ());
225 status
= target_read_memory (addr
, buf
, 2);
228 if (fi
&& get_next_frame (fi
) == NULL
)
229 deprecated_update_frame_base_hack (fi
, read_sp ());
232 if (buf
[0] == 0xf2 && buf
[1] == 0x7e)
236 /* Our frame pointer is valid now. */
239 fi
->status
|= MY_FRAME_IN_FP
;
240 fi
->status
&= ~MY_FRAME_IN_SP
;
247 if (fi
&& get_next_frame (fi
) == NULL
)
248 deprecated_update_frame_base_hack (fi
, read_sp ());
253 /* Next we should allocate the local frame.
255 Search for add imm8,a3 (0xd3XX)
256 or add imm16,a3 (0xf70bXXXX)
257 or add imm24,a3 (0xf467XXXXXX).
259 If none of the above was found, then this prologue has
260 no stack, and therefore can't have any register saves,
262 status
= target_read_memory (addr
, buf
, 2);
265 if (fi
&& get_next_frame (fi
) == NULL
&& (fi
->status
& MY_FRAME_IN_SP
))
266 deprecated_update_frame_base_hack (fi
, read_sp ());
271 stack_size
= extract_signed_integer (&buf
[1], 1);
273 fi
->stack_size
= stack_size
;
277 if (fi
&& get_next_frame (fi
) == NULL
&& (fi
->status
& MY_FRAME_IN_SP
))
278 deprecated_update_frame_base_hack (fi
, read_sp () - stack_size
);
282 else if (buf
[0] == 0xf7 && buf
[1] == 0x0b)
284 status
= target_read_memory (addr
+ 2, buf
, 2);
287 if (fi
&& get_next_frame (fi
) == NULL
&& (fi
->status
& MY_FRAME_IN_SP
))
288 deprecated_update_frame_base_hack (fi
, read_sp ());
291 stack_size
= extract_signed_integer (buf
, 2);
293 fi
->stack_size
= stack_size
;
297 if (fi
&& get_next_frame (fi
) == NULL
&& (fi
->status
& MY_FRAME_IN_SP
))
298 deprecated_update_frame_base_hack (fi
, read_sp () - stack_size
);
302 else if (buf
[0] == 0xf4 && buf
[1] == 0x67)
304 status
= target_read_memory (addr
+ 2, buf
, 3);
307 if (fi
&& get_next_frame (fi
) == NULL
&& (fi
->status
& MY_FRAME_IN_SP
))
308 deprecated_update_frame_base_hack (fi
, read_sp ());
311 stack_size
= extract_signed_integer (buf
, 3);
313 fi
->stack_size
= stack_size
;
317 if (fi
&& get_next_frame (fi
) == NULL
&& (fi
->status
& MY_FRAME_IN_SP
))
318 deprecated_update_frame_base_hack (fi
, read_sp () - stack_size
);
323 /* Now see if we have a call to __prologue for an out of line
325 status
= target_read_memory (addr
, buf
, 2);
329 /* First check for 16bit pc-relative call to __prologue. */
333 status
= target_read_memory (addr
+ 1, buf
, 2);
336 if (fi
&& get_next_frame (fi
) == NULL
&& (fi
->status
& MY_FRAME_IN_SP
))
337 deprecated_update_frame_base_hack (fi
, read_sp ());
341 /* Get the PC this instruction will branch to. */
342 temp
= (extract_signed_integer (buf
, 2) + addr
+ 3) & 0xffffff;
344 /* Get the name of the function at the target address. */
345 status
= find_pc_partial_function (temp
, &name
, NULL
, NULL
);
348 if (fi
&& get_next_frame (fi
) == NULL
&& (fi
->status
& MY_FRAME_IN_SP
))
349 deprecated_update_frame_base_hack (fi
, read_sp ());
353 /* Note if it is an out of line prologue. */
354 out_of_line_prologue
= (strcmp (name
, "__prologue") == 0);
356 /* This sucks up 3 bytes of instruction space. */
357 if (out_of_line_prologue
)
362 if (fi
&& get_next_frame (fi
) == NULL
)
364 fi
->stack_size
-= 16;
365 deprecated_update_frame_base_hack (fi
, read_sp () - fi
->stack_size
);
370 /* Now check for the 24bit pc-relative call to __prologue. */
371 else if (buf
[0] == 0xf4 && buf
[1] == 0xe1)
374 status
= target_read_memory (addr
+ 2, buf
, 3);
377 if (fi
&& get_next_frame (fi
) == NULL
&& (fi
->status
& MY_FRAME_IN_SP
))
378 deprecated_update_frame_base_hack (fi
, read_sp ());
382 /* Get the PC this instruction will branch to. */
383 temp
= (extract_signed_integer (buf
, 3) + addr
+ 5) & 0xffffff;
385 /* Get the name of the function at the target address. */
386 status
= find_pc_partial_function (temp
, &name
, NULL
, NULL
);
389 if (fi
&& get_next_frame (fi
) == NULL
&& (fi
->status
& MY_FRAME_IN_SP
))
390 deprecated_update_frame_base_hack (fi
, read_sp ());
394 /* Note if it is an out of line prologue. */
395 out_of_line_prologue
= (strcmp (name
, "__prologue") == 0);
397 /* This sucks up 5 bytes of instruction space. */
398 if (out_of_line_prologue
)
403 if (fi
&& get_next_frame (fi
) == NULL
&& (fi
->status
& MY_FRAME_IN_SP
))
405 fi
->stack_size
-= 16;
406 deprecated_update_frame_base_hack (fi
, read_sp () - fi
->stack_size
);
412 /* Now actually handle the out of line prologue. */
413 if (out_of_line_prologue
)
415 int outgoing_args_size
= 0;
417 /* First adjust the stack size for this function. The out of
418 line prologue saves 4 registers (16bytes of data). */
420 fi
->stack_size
-= 16;
422 /* Update fi->frame if necessary. */
423 if (fi
&& get_next_frame (fi
) == NULL
)
424 deprecated_update_frame_base_hack (fi
, read_sp () - fi
->stack_size
);
426 /* After the out of line prologue, there may be another
427 stack adjustment for the outgoing arguments.
429 Search for add imm8,a3 (0xd3XX)
430 or add imm16,a3 (0xf70bXXXX)
431 or add imm24,a3 (0xf467XXXXXX). */
433 status
= target_read_memory (addr
, buf
, 2);
438 fi
->fsr
.regs
[2] = get_frame_base (fi
) + fi
->stack_size
+ 4;
439 fi
->fsr
.regs
[3] = get_frame_base (fi
) + fi
->stack_size
+ 8;
440 fi
->fsr
.regs
[5] = get_frame_base (fi
) + fi
->stack_size
+ 12;
441 fi
->fsr
.regs
[6] = get_frame_base (fi
) + fi
->stack_size
+ 16;
448 outgoing_args_size
= extract_signed_integer (&buf
[1], 1);
451 else if (buf
[0] == 0xf7 && buf
[1] == 0x0b)
453 status
= target_read_memory (addr
+ 2, buf
, 2);
458 fi
->fsr
.regs
[2] = get_frame_base (fi
) + fi
->stack_size
+ 4;
459 fi
->fsr
.regs
[3] = get_frame_base (fi
) + fi
->stack_size
+ 8;
460 fi
->fsr
.regs
[5] = get_frame_base (fi
) + fi
->stack_size
+ 12;
461 fi
->fsr
.regs
[6] = get_frame_base (fi
) + fi
->stack_size
+ 16;
465 outgoing_args_size
= extract_signed_integer (buf
, 2);
468 else if (buf
[0] == 0xf4 && buf
[1] == 0x67)
470 status
= target_read_memory (addr
+ 2, buf
, 3);
473 if (fi
&& get_next_frame (fi
) == NULL
)
475 fi
->fsr
.regs
[2] = get_frame_base (fi
) + fi
->stack_size
+ 4;
476 fi
->fsr
.regs
[3] = get_frame_base (fi
) + fi
->stack_size
+ 8;
477 fi
->fsr
.regs
[5] = get_frame_base (fi
) + fi
->stack_size
+ 12;
478 fi
->fsr
.regs
[6] = get_frame_base (fi
) + fi
->stack_size
+ 16;
482 outgoing_args_size
= extract_signed_integer (buf
, 3);
486 outgoing_args_size
= 0;
488 /* Now that we know the size of the outgoing arguments, fix
489 fi->frame again if this is the innermost frame. */
490 if (fi
&& get_next_frame (fi
) == NULL
)
491 deprecated_update_frame_base_hack (fi
, get_frame_base (fi
) - outgoing_args_size
);
493 /* Note the register save information and update the stack
494 size for this frame too. */
497 fi
->fsr
.regs
[2] = get_frame_base (fi
) + fi
->stack_size
+ 4;
498 fi
->fsr
.regs
[3] = get_frame_base (fi
) + fi
->stack_size
+ 8;
499 fi
->fsr
.regs
[5] = get_frame_base (fi
) + fi
->stack_size
+ 12;
500 fi
->fsr
.regs
[6] = get_frame_base (fi
) + fi
->stack_size
+ 16;
501 fi
->stack_size
+= outgoing_args_size
;
503 /* There can be no more prologue insns, so return now. */
507 /* At this point fi->frame needs to be correct.
509 If MY_FRAME_IN_SP is set and we're the innermost frame, then we
510 need to fix fi->frame so that backtracing, find_frame_saved_regs,
511 etc work correctly. */
512 if (fi
&& get_next_frame (fi
) == NULL
&& (fi
->status
& MY_FRAME_IN_SP
) != 0)
513 deprecated_update_frame_base_hack (fi
, read_sp () - fi
->stack_size
);
515 /* And last we have the register saves. These are relatively
516 simple because they're physically done off the stack pointer,
517 and thus the number of different instructions we need to
518 check is greatly reduced because we know the displacements
521 Search for movx d2,(X,a3) (0xf55eXX)
522 then movx d3,(X,a3) (0xf55fXX)
523 then mov a1,(X,a3) (0x5dXX) No frame pointer case
524 then mov a2,(X,a3) (0x5eXX) No frame pointer case
525 or mov a0,(X,a3) (0x5cXX) Frame pointer case. */
527 status
= target_read_memory (addr
, buf
, 2);
530 if (buf
[0] == 0xf5 && buf
[1] == 0x5e)
534 status
= target_read_memory (addr
+ 2, buf
, 1);
537 fi
->fsr
.regs
[2] = (get_frame_base (fi
) + stack_size
538 + extract_signed_integer (buf
, 1));
543 status
= target_read_memory (addr
, buf
, 2);
547 if (buf
[0] == 0xf5 && buf
[1] == 0x5f)
551 status
= target_read_memory (addr
+ 2, buf
, 1);
554 fi
->fsr
.regs
[3] = (get_frame_base (fi
) + stack_size
555 + extract_signed_integer (buf
, 1));
560 status
= target_read_memory (addr
, buf
, 2);
568 status
= target_read_memory (addr
+ 1, buf
, 1);
571 fi
->fsr
.regs
[5] = (get_frame_base (fi
) + stack_size
572 + extract_signed_integer (buf
, 1));
577 status
= target_read_memory (addr
, buf
, 2);
581 if (buf
[0] == 0x5e || buf
[0] == 0x5c)
585 status
= target_read_memory (addr
+ 1, buf
, 1);
588 fi
->fsr
.regs
[6] = (get_frame_base (fi
) + stack_size
589 + extract_signed_integer (buf
, 1));
590 fi
->status
&= ~CALLER_A2_IN_A0
;
600 /* Function: frame_chain
601 Figure out and return the caller's frame pointer given current
604 We don't handle dummy frames yet but we would probably just return the
605 stack pointer that was in use at the time the function call was made? */
608 mn10200_frame_chain (struct frame_info
*fi
)
610 struct frame_info
*dummy_frame
= deprecated_frame_xmalloc ();
611 struct cleanup
*old_chain
= make_cleanup (xfree
, dummy_frame
);
614 /* Walk through the prologue to determine the stack size,
615 location of saved registers, end of the prologue, etc. */
617 mn10200_analyze_prologue (fi
, (CORE_ADDR
) 0);
619 /* Quit now if mn10200_analyze_prologue set NO_MORE_FRAMES. */
620 if (fi
->status
& NO_MORE_FRAMES
)
623 /* Now that we've analyzed our prologue, determine the frame
624 pointer for our caller.
626 If our caller has a frame pointer, then we need to
627 find the entry value of $a2 to our function.
629 If CALLER_A2_IN_A0, then the chain is in $a0.
631 If fsr.regs[6] is nonzero, then it's at the memory
632 location pointed to by fsr.regs[6].
634 Else it's still in $a2.
636 If our caller does not have a frame pointer, then his
637 frame base is fi->frame + -caller's stack size + 4. */
639 /* The easiest way to get that info is to analyze our caller's frame.
641 So we set up a dummy frame and call mn10200_analyze_prologue to
642 find stuff for us. */
643 deprecated_update_frame_pc_hack (dummy_frame
, FRAME_SAVED_PC (fi
));
644 deprecated_update_frame_base_hack (dummy_frame
, get_frame_base (fi
));
645 memset (dummy_frame
->fsr
.regs
, '\000', sizeof dummy_frame
->fsr
.regs
);
646 dummy_frame
->status
= 0;
647 dummy_frame
->stack_size
= 0;
648 mn10200_analyze_prologue (dummy_frame
, 0);
650 if (dummy_frame
->status
& MY_FRAME_IN_FP
)
652 /* Our caller has a frame pointer. So find the frame in $a2, $a0,
655 ret
= (read_memory_integer (fi
->fsr
.regs
[FP_REGNUM
], REGISTER_SIZE
)
657 else if (fi
->status
& CALLER_A2_IN_A0
)
658 ret
= read_register (4);
660 ret
= read_register (FP_REGNUM
);
664 /* Our caller does not have a frame pointer. So his frame starts
665 at the base of our frame (fi->frame) + <his size> + 4 (saved pc). */
666 ret
= get_frame_base (fi
) + -dummy_frame
->stack_size
+ 4;
668 do_cleanups (old_chain
);
672 /* Function: skip_prologue
673 Return the address of the first inst past the prologue of the function. */
676 mn10200_skip_prologue (CORE_ADDR pc
)
678 /* We used to check the debug symbols, but that can lose if
679 we have a null prologue. */
680 return mn10200_analyze_prologue (NULL
, pc
);
683 /* Function: pop_frame
684 This routine gets called when either the user uses the `return'
685 command, or the call dummy breakpoint gets hit. */
688 mn10200_pop_frame (struct frame_info
*frame
)
692 if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (frame
),
693 get_frame_base (frame
),
694 get_frame_base (frame
)))
695 generic_pop_dummy_frame ();
698 write_register (PC_REGNUM
, FRAME_SAVED_PC (frame
));
700 /* Restore any saved registers. */
701 for (regnum
= 0; regnum
< NUM_REGS
; regnum
++)
702 if (frame
->fsr
.regs
[regnum
] != 0)
706 value
= read_memory_unsigned_integer (frame
->fsr
.regs
[regnum
],
707 REGISTER_RAW_SIZE (regnum
));
708 write_register (regnum
, value
);
711 /* Actually cut back the stack. */
712 write_register (SP_REGNUM
, get_frame_base (frame
));
714 /* Don't we need to set the PC?!? XXX FIXME. */
717 /* Throw away any cached frame information. */
718 flush_cached_frames ();
721 /* Function: push_arguments
722 Setup arguments for a call to the target. Arguments go in
723 order on the stack. */
726 mn10200_push_arguments (int nargs
, struct value
**args
, CORE_ADDR sp
,
727 unsigned char struct_return
, CORE_ADDR struct_addr
)
731 int stack_offset
= 0;
732 int regsused
= struct_return
? 1 : 0;
734 /* This should be a nop, but align the stack just in case something
735 went wrong. Stacks are two byte aligned on the mn10200. */
738 /* Now make space on the stack for the args.
740 XXX This doesn't appear to handle pass-by-invisible reference
742 for (argnum
= 0; argnum
< nargs
; argnum
++)
744 int arg_length
= (TYPE_LENGTH (VALUE_TYPE (args
[argnum
])) + 1) & ~1;
746 /* If we've used all argument registers, then this argument is
748 if (regsused
>= 2 || arg_length
> 4)
753 /* We know we've got some arg register space left. If this argument
754 will fit entirely in regs, then put it there. */
755 else if (arg_length
<= 2
756 || TYPE_CODE (VALUE_TYPE (args
[argnum
])) == TYPE_CODE_PTR
)
760 else if (regsused
== 0)
771 /* Allocate stack space. */
774 regsused
= struct_return
? 1 : 0;
775 /* Push all arguments onto the stack. */
776 for (argnum
= 0; argnum
< nargs
; argnum
++)
781 /* XXX Check this. What about UNIONS? */
782 if (TYPE_CODE (VALUE_TYPE (*args
)) == TYPE_CODE_STRUCT
783 && TYPE_LENGTH (VALUE_TYPE (*args
)) > 8)
785 /* XXX Wrong, we want a pointer to this argument. */
786 len
= TYPE_LENGTH (VALUE_TYPE (*args
));
787 val
= (char *) VALUE_CONTENTS (*args
);
791 len
= TYPE_LENGTH (VALUE_TYPE (*args
));
792 val
= (char *) VALUE_CONTENTS (*args
);
797 || TYPE_CODE (VALUE_TYPE (*args
)) == TYPE_CODE_PTR
))
799 write_register (regsused
, extract_unsigned_integer (val
, 4));
802 else if (regsused
== 0 && len
== 4)
804 write_register (regsused
, extract_unsigned_integer (val
, 2));
805 write_register (regsused
+ 1, extract_unsigned_integer (val
+ 2, 2));
813 write_memory (sp
+ stack_offset
, val
, 2);
826 /* Function: push_return_address (pc)
827 Set up the return address for the inferior function call.
828 Needed for targets where we don't actually execute a JSR/BSR instruction */
831 mn10200_push_return_address (CORE_ADDR pc
, CORE_ADDR sp
)
833 unsigned char buf
[4];
835 store_unsigned_integer (buf
, 4, CALL_DUMMY_ADDRESS ());
836 write_memory (sp
- 4, buf
, 4);
840 /* Function: store_struct_return (addr,sp)
841 Store the structure value return address for an inferior function
845 mn10200_store_struct_return (CORE_ADDR addr
, CORE_ADDR sp
)
847 /* The structure return address is passed as the first argument. */
848 write_register (0, addr
);
852 /* Function: frame_saved_pc
853 Find the caller of this frame. We do this by seeing if RP_REGNUM
854 is saved in the stack anywhere, otherwise we get it from the
855 registers. If the inner frame is a dummy frame, return its PC
856 instead of RP, because that's where "caller" of the dummy-frame
860 mn10200_frame_saved_pc (struct frame_info
*fi
)
862 /* The saved PC will always be at the base of the current frame. */
863 return (read_memory_integer (get_frame_base (fi
), REGISTER_SIZE
) & 0xffffff);
866 /* Function: init_extra_frame_info
867 Setup the frame's frame pointer, pc, and frame addresses for saved
868 registers. Most of the work is done in mn10200_analyze_prologue().
870 Note that when we are called for the last frame (currently active frame),
871 that get_frame_pc (fi) and fi->frame will already be setup. However, fi->frame will
872 be valid only if this routine uses FP. For previous frames, fi-frame will
873 always be correct. mn10200_analyze_prologue will fix fi->frame if
876 We can be called with the PC in the call dummy under two circumstances.
877 First, during normal backtracing, second, while figuring out the frame
878 pointer just prior to calling the target function (see run_stack_dummy). */
881 mn10200_init_extra_frame_info (struct frame_info
*fi
)
883 if (get_next_frame (fi
))
884 deprecated_update_frame_pc_hack (fi
, FRAME_SAVED_PC (get_next_frame (fi
)));
886 memset (fi
->fsr
.regs
, '\000', sizeof fi
->fsr
.regs
);
890 mn10200_analyze_prologue (fi
, 0);
894 _initialize_mn10200_tdep (void)
896 tm_print_insn
= print_insn_mn10200
;
This page took 0.068232 seconds and 4 git commands to generate.