1 /* Target-dependent code for GDB, the GNU debugger.
2 Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include <sys/param.h>
30 #include <sys/ioctl.h>
33 #include <sys/ptrace.h>
42 extern int attach_flag
;
44 /* Nonzero if we just simulated a single step break. */
48 /* Breakpoint shadows for the single step instructions will be kept here. */
50 static struct sstep_breaks
{
57 * Calculate the destination of a branch/jump. Return -1 if not a branch.
60 branch_dest (opcode
, instr
, pc
, safety
)
61 int opcode
, instr
, pc
, safety
;
69 absolute
= (int) ((instr
>> 1) & 1);
73 immediate
= ((instr
& ~3) << 6) >> 6; /* br unconditionl */
76 if (opcode
!= 18) /* br conditional */
77 immediate
= ((instr
& ~3) << 16) >> 16;
81 dest
= pc
+ immediate
;
85 ext_op
= (instr
>>1) & 0x3ff;
87 if (ext_op
== 16) /* br conditional register */
88 dest
= read_register (LR_REGNUM
) & ~3;
90 else if (ext_op
== 528) /* br cond to count reg */
91 dest
= read_register (CTR_REGNUM
) & ~3;
98 return (dest
< TEXT_SEGMENT_BASE
) ? safety
: dest
;
103 /* AIX does not support PT_STEP. Simulate it. */
109 #define INSNLEN(OPCODE) 4
111 static char breakp
[] = BREAKPOINT
;
112 int ii
, insn
, ret
, loc
;
113 int breaks
[2], opcode
;
116 extern CORE_ADDR text_start
;
119 ret
= read_memory (loc
, &insn
, sizeof (int));
121 printf ("Error in single_step()!!\n");
123 breaks
[0] = loc
+ INSNLEN(insn
);
125 breaks
[1] = branch_dest (opcode
, insn
, loc
, breaks
[0]);
127 /* Don't put two breakpoints on the same address. */
128 if (breaks
[1] == breaks
[0])
131 stepBreaks
[1].address
= -1;
133 for (ii
=0; ii
< 2; ++ii
) {
135 /* ignore invalid breakpoint. */
136 if ( breaks
[ii
] == -1)
139 read_memory (breaks
[ii
], &(stepBreaks
[ii
].data
), sizeof(int));
141 ret
= write_memory (breaks
[ii
], breakp
, sizeof(int));
142 stepBreaks
[ii
].address
= breaks
[ii
];
146 ptrace (PT_CONTINUE
, inferior_pid
, 1, signal
, 0);
150 /* remove step breakpoints. */
151 for (ii
=0; ii
< 2; ++ii
)
152 if (stepBreaks
[ii
].address
!= -1)
154 (stepBreaks
[ii
].address
, &(stepBreaks
[ii
].data
), sizeof(int));
163 /* return pc value after skipping a function prologue. */
171 if (target_read_memory (pc
, (char *)&op
, sizeof (op
)))
172 return pc
; /* Can't access it -- assume no prologue. */
173 SWAP_TARGET_AND_HOST (&op
, sizeof (op
));
175 /* Assume that subsequent fetches can fail with low probability. */
177 if (op
== 0x7c0802a6) { /* mflr r0 */
179 op
= read_memory_integer (pc
, 4);
182 if ((op
& 0xfc00003e) == 0x7c000026) { /* mfcr Rx */
184 op
= read_memory_integer (pc
, 4);
187 if ((op
& 0xfc000000) == 0x48000000) { /* bl foo, to save fprs??? */
189 op
= read_memory_integer (pc
, 4);
192 if ((op
& 0xfc1f0000) == 0xbc010000) { /* stm Rx, NUM(r1) */
194 op
= read_memory_integer (pc
, 4);
197 while (((tmp
= op
>> 16) == 0x9001) || /* st r0, NUM(r1) */
198 (tmp
== 0x9421) || /* stu r1, NUM(r1) */
199 (op
== 0x93e1fffc)) /* st r31,-4(r1) */
202 op
= read_memory_integer (pc
, 4);
205 while ((tmp
= (op
>> 22)) == 0x20f) { /* l r31, ... or */
206 pc
+= 4; /* l r30, ... */
207 op
= read_memory_integer (pc
, 4);
210 /* store parameters into stack */
212 (op
& 0xfc1f0000) == 0xd8010000 || /* stfd Rx,NUM(r1) */
213 (op
& 0xfc1f0000) == 0x90010000 || /* st r?, NUM(r1) */
214 (op
& 0xfc000000) == 0xfc000000 || /* frsp, fp?, .. */
215 (op
& 0xd0000000) == 0xd0000000) /* stfs, fp?, .. */
217 pc
+= 4; /* store fpr double */
218 op
= read_memory_integer (pc
, 4);
221 if (op
== 0x603f0000) { /* oril r31, r1, 0x0 */
222 pc
+= 4; /* this happens if r31 is used as */
223 op
= read_memory_integer (pc
, 4); /* frame ptr. (gcc does that) */
226 while ((op
>> 16) == (0x907f + tmp
)) { /* st r3, NUM(r31) */
227 pc
+= 4; /* st r4, NUM(r31), ... */
228 op
= read_memory_integer (pc
, 4);
233 /* I have problems with skipping over __main() that I need to address
234 * sometime. Previously, I used to use misc_function_vector which
235 * didn't work as well as I wanted to be. -MGO */
237 /* If the first thing after skipping a prolog is a branch to a function,
238 this might be a call to an initializer in main(), introduced by gcc2.
239 We'd like to skip over it as well. Fortunately, xlc does some extra
240 work before calling a function right after a prologue, thus we can
241 single out such gcc2 behaviour. */
244 if ((op
& 0xfc000001) == 0x48000001) { /* bl foo, an initializer function? */
245 op
= read_memory_integer (pc
+4, 4);
247 if (op
== 0x4def7b82) { /* cror 0xf, 0xf, 0xf (nop) */
249 /* check and see if we are in main. If so, skip over this initializer
252 tmp
= find_pc_misc_function (pc
);
253 if (tmp
>= 0 && !strcmp (misc_function_vector
[tmp
].name
, "main"))
263 /* text start and end addresses in virtual memory. */
265 CORE_ADDR text_start
;
269 /*************************************************************************
270 Support for creating pushind a dummy frame into the stack, and popping
272 *************************************************************************/
274 /* The total size of dummy frame is 436, which is;
279 and 24 extra bytes for the callee's link area. The last 24 bytes
280 for the link area might not be necessary, since it will be taken
281 care of by push_arguments(). */
283 #define DUMMY_FRAME_SIZE 436
285 #define DUMMY_FRAME_ADDR_SIZE 10
287 /* Make sure you initialize these in somewhere, in case gdb gives up what it
288 was debugging and starts debugging something else. FIXMEibm */
290 static int dummy_frame_count
= 0;
291 static int dummy_frame_size
= 0;
292 static CORE_ADDR
*dummy_frame_addr
= 0;
294 extern int stop_stack_dummy
;
296 /* push a dummy frame into stack, save all register. Currently we are saving
297 only gpr's and fpr's, which is not good enough! FIXMEmgo */
301 int sp
, pc
; /* stack pointer and link register */
304 fetch_inferior_registers (-1);
306 if (dummy_frame_count
>= dummy_frame_size
) {
307 dummy_frame_size
+= DUMMY_FRAME_ADDR_SIZE
;
308 if (dummy_frame_addr
)
309 dummy_frame_addr
= (CORE_ADDR
*) xrealloc
310 (dummy_frame_addr
, sizeof(CORE_ADDR
) * (dummy_frame_size
));
312 dummy_frame_addr
= (CORE_ADDR
*)
313 xmalloc (sizeof(CORE_ADDR
) * (dummy_frame_size
));
316 sp
= read_register(SP_REGNUM
);
317 pc
= read_register(PC_REGNUM
);
319 dummy_frame_addr
[dummy_frame_count
++] = sp
;
321 /* Be careful! If the stack pointer is not decremented first, then kernel
322 thinks he is free to use the space underneath it. And kernel actually
323 uses that area for IPC purposes when executing ptrace(2) calls. So
324 before writing register values into the new frame, decrement and update
325 %sp first in order to secure your frame. */
327 write_register (SP_REGNUM
, sp
-DUMMY_FRAME_SIZE
);
329 /* gdb relies on the state of current_frame. We'd better update it,
330 otherwise things like do_registers_info() wouldn't work properly! */
332 flush_cached_frames ();
333 set_current_frame (create_new_frame (sp
-DUMMY_FRAME_SIZE
, pc
));
335 /* save program counter in link register's space. */
336 write_memory (sp
+8, &pc
, 4);
338 /* save all floating point and general purpose registers here. */
341 for (ii
= 0; ii
< 32; ++ii
)
342 write_memory (sp
-8-(ii
*8), ®isters
[REGISTER_BYTE (31-ii
+FP0_REGNUM
)], 8);
345 for (ii
=1; ii
<=32; ++ii
)
346 write_memory (sp
-256-(ii
*4), ®isters
[REGISTER_BYTE (32-ii
)], 4);
348 /* so far, 32*2 + 32 words = 384 bytes have been written.
349 7 extra registers in our register set: pc, ps, cnd, lr, cnt, xer, mq */
351 for (ii
=1; ii
<= (LAST_SP_REGNUM
-FIRST_SP_REGNUM
+1); ++ii
) {
352 write_memory (sp
-384-(ii
*4),
353 ®isters
[REGISTER_BYTE (FPLAST_REGNUM
+ ii
)], 4);
356 /* Save sp or so called back chain right here. */
357 write_memory (sp
-DUMMY_FRAME_SIZE
, &sp
, 4);
358 sp
-= DUMMY_FRAME_SIZE
;
360 /* And finally, this is the back chain. */
361 write_memory (sp
+8, &pc
, 4);
365 /* Pop a dummy frame.
367 In rs6000 when we push a dummy frame, we save all of the registers. This
368 is usually done before user calls a function explicitly.
370 After a dummy frame is pushed, some instructions are copied into stack,
371 and stack pointer is decremented even more. Since we don't have a frame
372 pointer to get back to the parent frame of the dummy, we start having
373 trouble poping it. Therefore, we keep a dummy frame stack, keeping
374 addresses of dummy frames as such. When poping happens and when we
375 detect that was a dummy frame, we pop it back to its parent by using
376 dummy frame stack (`dummy_frame_addr' array).
383 sp
= dummy_frame_addr
[--dummy_frame_count
];
385 /* restore all fpr's. */
386 for (ii
= 1; ii
<= 32; ++ii
)
387 read_memory (sp
-(ii
*8), ®isters
[REGISTER_BYTE (32-ii
+FP0_REGNUM
)], 8);
389 /* restore all gpr's */
390 for (ii
=1; ii
<= 32; ++ii
) {
391 read_memory (sp
-256-(ii
*4), ®isters
[REGISTER_BYTE (32-ii
)], 4);
394 /* restore the rest of the registers. */
395 for (ii
=1; ii
<=(LAST_SP_REGNUM
-FIRST_SP_REGNUM
+1); ++ii
)
396 read_memory (sp
-384-(ii
*4),
397 ®isters
[REGISTER_BYTE (FPLAST_REGNUM
+ ii
)], 4);
399 read_memory (sp
-(DUMMY_FRAME_SIZE
-8),
400 ®isters
[REGISTER_BYTE(PC_REGNUM
)], 4);
402 /* when a dummy frame was being pushed, we had to decrement %sp first, in
403 order to secure astack space. Thus, saved %sp (or %r1) value, is not the
404 one we should restore. Change it with the one we need. */
406 *(int*)®isters
[REGISTER_BYTE(FP_REGNUM
)] = sp
;
408 /* Now we can restore all registers. */
410 store_inferior_registers (-1);
412 flush_cached_frames ();
413 set_current_frame (create_new_frame (sp
, pc
));
417 /* pop the innermost frame, go back to the caller. */
421 int pc
, lr
, sp
, prev_sp
; /* %pc, %lr, %sp */
422 struct aix_framedata fdata
;
423 FRAME fr
= get_current_frame ();
429 if (stop_stack_dummy
&& dummy_frame_count
) {
434 /* figure out previous %pc value. If the function is frameless, it is
435 still in the link register, otherwise walk the frames and retrieve the
436 saved %pc value in the previous frame. */
438 addr
= get_pc_function_start (fr
->pc
) + FUNCTION_START_OFFSET
;
439 function_frame_info (addr
, &fdata
);
441 read_memory (sp
, &prev_sp
, 4);
443 lr
= read_register (LR_REGNUM
);
445 read_memory (prev_sp
+8, &lr
, 4);
447 /* reset %pc value. */
448 write_register (PC_REGNUM
, lr
);
450 /* reset register values if any was saved earlier. */
451 addr
= prev_sp
- fdata
.offset
;
453 if (fdata
.saved_gpr
!= -1)
454 for (ii
=fdata
.saved_gpr
; ii
<= 31; ++ii
) {
455 read_memory (addr
, ®isters
[REGISTER_BYTE (ii
)], 4);
456 addr
+= sizeof (int);
459 if (fdata
.saved_fpr
!= -1)
460 for (ii
=fdata
.saved_fpr
; ii
<= 31; ++ii
) {
461 read_memory (addr
, ®isters
[REGISTER_BYTE (ii
+FP0_REGNUM
)], 8);
465 write_register (SP_REGNUM
, prev_sp
);
466 store_inferior_registers (-1);
467 flush_cached_frames ();
468 set_current_frame (create_new_frame (prev_sp
, lr
));
472 /* fixup the call sequence of a dummy function, with the real function address.
473 its argumets will be passed by gdb. */
475 fix_call_dummy(dummyname
, pc
, fun
, nargs
, type
)
479 int nargs
; /* not used */
480 int type
; /* not used */
483 #define TOC_ADDR_OFFSET 20
484 #define TARGET_ADDR_OFFSET 28
487 unsigned long target_addr
;
488 unsigned long tocvalue
;
491 tocvalue
= find_toc_address (target_addr
);
493 ii
= *(int*)((char*)dummyname
+ TOC_ADDR_OFFSET
);
494 ii
= (ii
& 0xffff0000) | (tocvalue
>> 16);
495 *(int*)((char*)dummyname
+ TOC_ADDR_OFFSET
) = ii
;
497 ii
= *(int*)((char*)dummyname
+ TOC_ADDR_OFFSET
+4);
498 ii
= (ii
& 0xffff0000) | (tocvalue
& 0x0000ffff);
499 *(int*)((char*)dummyname
+ TOC_ADDR_OFFSET
+4) = ii
;
501 ii
= *(int*)((char*)dummyname
+ TARGET_ADDR_OFFSET
);
502 ii
= (ii
& 0xffff0000) | (target_addr
>> 16);
503 *(int*)((char*)dummyname
+ TARGET_ADDR_OFFSET
) = ii
;
505 ii
= *(int*)((char*)dummyname
+ TARGET_ADDR_OFFSET
+4);
506 ii
= (ii
& 0xffff0000) | (target_addr
& 0x0000ffff);
507 *(int*)((char*)dummyname
+ TARGET_ADDR_OFFSET
+4) = ii
;
512 /* return information about a function frame.
513 in struct aix_frameinfo fdata:
514 - frameless is TRUE, if function does not save %pc value in its frame.
515 - offset is the number of bytes used in the frame to save registers.
516 - saved_gpr is the number of the first saved gpr.
517 - saved_fpr is the number of the first saved fpr.
518 - alloca_reg is the number of the register used for alloca() handling.
521 function_frame_info (pc
, fdata
)
523 struct aix_framedata
*fdata
;
526 register unsigned int op
;
529 fdata
->saved_gpr
= fdata
->saved_fpr
= fdata
->alloca_reg
= -1;
531 op
= read_memory_integer (pc
, 4);
532 if (op
== 0x7c0802a6) { /* mflr r0 */
534 op
= read_memory_integer (pc
, 4);
535 fdata
->frameless
= 0;
537 else /* else, this is a frameless invocation */
538 fdata
->frameless
= 1;
541 if ((op
& 0xfc00003e) == 0x7c000026) { /* mfcr Rx */
543 op
= read_memory_integer (pc
, 4);
546 if ((op
& 0xfc000000) == 0x48000000) { /* bl foo, to save fprs??? */
548 op
= read_memory_integer (pc
, 4);
551 if ((op
& 0xfc1f0000) == 0xd8010000) { /* stfd Rx,NUM(r1) */
552 pc
+= 4; /* store floating register double */
553 op
= read_memory_integer (pc
, 4);
556 if ((op
& 0xfc1f0000) == 0xbc010000) { /* stm Rx, NUM(r1) */
558 fdata
->saved_gpr
= (op
>> 21) & 0x1f;
561 tmp2
= 0xffff0000 | tmp2
;
565 fdata
->saved_fpr
= (tmp2
- ((32 - fdata
->saved_gpr
) * 4)) / 8;
566 if ( fdata
->saved_fpr
> 0)
567 fdata
->saved_fpr
= 32 - fdata
->saved_fpr
;
569 fdata
->saved_fpr
= -1;
571 fdata
->offset
= tmp2
;
573 op
= read_memory_integer (pc
, 4);
576 while (((tmp
= op
>> 16) == 0x9001) || /* st r0, NUM(r1) */
577 (tmp
== 0x9421) || /* stu r1, NUM(r1) */
578 (op
== 0x93e1fffc)) /* st r31,-4(r1) */
580 /* gcc takes a short cut and uses this instruction to save r31 only. */
582 if (op
== 0x93e1fffc) {
584 /* fatal ("Unrecognized prolog."); */
585 printf ("Unrecognized prolog!\n");
587 fdata
->saved_gpr
= 31;
591 op
= read_memory_integer (pc
, 4);
594 while ((tmp
= (op
>> 22)) == 0x20f) { /* l r31, ... or */
595 pc
+= 4; /* l r30, ... */
596 op
= read_memory_integer (pc
, 4);
599 /* store parameters into stack */
601 (op
& 0xfc1f0000) == 0xd8010000 || /* stfd Rx,NUM(r1) */
602 (op
& 0xfc1f0000) == 0x90010000 || /* st r?, NUM(r1) */
603 (op
& 0xfc000000) == 0xfc000000 || /* frsp, fp?, .. */
604 (op
& 0xd0000000) == 0xd0000000) /* stfs, fp?, .. */
606 pc
+= 4; /* store fpr double */
607 op
= read_memory_integer (pc
, 4);
610 if (op
== 0x603f0000) /* oril r31, r1, 0x0 */
611 fdata
->alloca_reg
= 31;
615 /* Pass the arguments in either registers, or in the stack. In RS6000, the first
616 eight words of the argument list (that might be less than eight parameters if
617 some parameters occupy more than one word) are passed in r3..r11 registers.
618 float and double parameters are passed in fpr's, in addition to that. Rest of
619 the parameters if any are passed in user stack. There might be cases in which
620 half of the parameter is copied into registers, the other half is pushed into
623 If the function is returning a structure, then the return address is passed
624 in r3, then the first 7 words of the parametes can be passed in registers,
628 push_arguments (nargs
, args
, sp
, struct_return
, struct_addr
)
633 CORE_ADDR struct_addr
;
636 int argno
; /* current argument number */
637 int argbytes
; /* current argument byte */
638 char tmp_buffer
[50];
640 int f_argno
= 0; /* current floating point argno */
642 CORE_ADDR saved_sp
, pc
;
644 if ( dummy_frame_count
<= 0)
645 printf ("FATAL ERROR -push_arguments()! frame not found!!\n");
647 /* The first eight words of ther arguments are passed in registers. Copy
650 If the function is returning a `struct', then the first word (which
651 will be passed in r3) is used for struct return address. In that
652 case we should advance one word and start from r4 register to copy
655 ii
= struct_return
? 1 : 0;
657 for (argno
=0, argbytes
=0; argno
< nargs
&& ii
<8; ++ii
) {
659 arg
= value_arg_coerce (args
[argno
]);
660 len
= TYPE_LENGTH (VALUE_TYPE (arg
));
662 if (TYPE_CODE (VALUE_TYPE (arg
)) == TYPE_CODE_FLT
) {
664 /* floating point arguments are passed in fpr's, as well as gpr's.
665 There are 13 fpr's reserved for passing parameters. At this point
666 there is no way we would run out of them. */
670 "Fatal Error: a floating point parameter #%d with a size > 8 is found!\n", argno
);
672 bcopy (VALUE_CONTENTS (arg
),
673 ®isters
[REGISTER_BYTE(FP0_REGNUM
+ 1 + f_argno
)], len
);
679 /* Argument takes more than one register. */
680 while (argbytes
< len
) {
682 *(int*)®isters
[REGISTER_BYTE(ii
+3)] = 0;
683 bcopy ( ((char*)VALUE_CONTENTS (arg
))+argbytes
,
684 ®isters
[REGISTER_BYTE(ii
+3)],
685 (len
- argbytes
) > 4 ? 4 : len
- argbytes
);
689 goto ran_out_of_registers_for_arguments
;
694 else { /* Argument can fit in one register. No problem. */
695 *(int*)®isters
[REGISTER_BYTE(ii
+3)] = 0;
696 bcopy (VALUE_CONTENTS (arg
), ®isters
[REGISTER_BYTE(ii
+3)], len
);
701 ran_out_of_registers_for_arguments
:
703 /* location for 8 parameters are always reserved. */
706 /* another six words for back chain, TOC register, link register, etc. */
709 /* if there are more arguments, allocate space for them in
710 the stack, then push them starting from the ninth one. */
712 if ((argno
< nargs
) || argbytes
) {
717 space
+= ((len
- argbytes
+ 3) & -4);
723 for (; jj
< nargs
; ++jj
) {
724 val
= value_arg_coerce (args
[jj
]);
725 space
+= ((TYPE_LENGTH (VALUE_TYPE (val
))) + 3) & -4;
728 /* add location required for the rest of the parameters */
729 space
= (space
+ 7) & -8;
732 /* This is another instance we need to be concerned about securing our
733 stack space. If we write anything underneath %sp (r1), we might conflict
734 with the kernel who thinks he is free to use this area. So, update %sp
735 first before doing anything else. */
737 write_register (SP_REGNUM
, sp
);
739 /* if the last argument copied into the registers didn't fit there
740 completely, push the rest of it into stack. */
744 sp
+24+(ii
*4), ((char*)VALUE_CONTENTS (arg
))+argbytes
, len
- argbytes
);
746 ii
+= ((len
- argbytes
+ 3) & -4) / 4;
749 /* push the rest of the arguments into stack. */
750 for (; argno
< nargs
; ++argno
) {
752 arg
= value_arg_coerce (args
[argno
]);
753 len
= TYPE_LENGTH (VALUE_TYPE (arg
));
756 /* float types should be passed in fpr's, as well as in the stack. */
757 if (TYPE_CODE (VALUE_TYPE (arg
)) == TYPE_CODE_FLT
&& f_argno
< 13) {
761 "Fatal Error: a floating point parameter #%d with a size > 8 is found!\n", argno
);
763 bcopy (VALUE_CONTENTS (arg
),
764 ®isters
[REGISTER_BYTE(FP0_REGNUM
+ 1 + f_argno
)], len
);
768 write_memory (sp
+24+(ii
*4), VALUE_CONTENTS (arg
), len
);
769 ii
+= ((len
+ 3) & -4) / 4;
773 /* Secure stack areas first, before doing anything else. */
774 write_register (SP_REGNUM
, sp
);
776 saved_sp
= dummy_frame_addr
[dummy_frame_count
- 1];
777 read_memory (saved_sp
, tmp_buffer
, 24);
778 write_memory (sp
, tmp_buffer
, 24);
780 write_memory (sp
, &saved_sp
, 4); /* set back chain properly */
782 store_inferior_registers (-1);
786 /* a given return value in `regbuf' with a type `valtype', extract and copy its
787 value into `valbuf' */
789 extract_return_value (valtype
, regbuf
, valbuf
)
790 struct type
*valtype
;
791 char regbuf
[REGISTER_BYTES
];
795 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
) {
798 /* floats and doubles are returned in fpr1. fpr's have a size of 8 bytes.
799 We need to truncate the return value into float size (4 byte) if
802 if (TYPE_LENGTH (valtype
) > 4) /* this is a double */
803 bcopy (®buf
[REGISTER_BYTE (FP0_REGNUM
+ 1)], valbuf
,
804 TYPE_LENGTH (valtype
));
806 bcopy (®buf
[REGISTER_BYTE (FP0_REGNUM
+ 1)], &dd
, 8);
808 bcopy (&ff
, valbuf
, sizeof(float));
812 /* return value is copied starting from r3. */
813 bcopy (®buf
[REGISTER_BYTE (3)], valbuf
, TYPE_LENGTH (valtype
));
817 /* keep keep structure return address in this variable. */
819 CORE_ADDR rs6000_struct_return_address
;
822 /* Throw away this debugging code. FIXMEmgo. */
827 for (ii
=0; ii
<40; ++ii
) {
830 val
= read_memory_integer (fram
+ ii
* 4, 4);
831 printf ("0x%08x\t", val
);
838 /* Indirect function calls use a piece of trampoline code do co context switching,
839 i.e. to set the new TOC table. Skip such code if exists. */
841 skip_trampoline_code (pc
)
844 register unsigned int ii
, op
;
846 static unsigned trampoline_code
[] = {
847 0x800b0000, /* l r0,0x0(r11) */
848 0x90410014, /* st r2,0x14(r1) */
849 0x7c0903a6, /* mtctr r0 */
850 0x804b0004, /* l r2,0x4(r11) */
851 0x816b0008, /* l r11,0x8(r11) */
852 0x4e800420, /* bctr */
857 for (ii
=0; trampoline_code
[ii
]; ++ii
) {
858 op
= read_memory_integer (pc
+ (ii
*4), 4);
859 if (op
!= trampoline_code
[ii
])
862 ii
= read_register (11); /* r11 holds destination addr */
863 pc
= read_memory_integer (ii
, 4); /* (r11) value */