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. */
47 /* Breakpoint shadows for the single step instructions will be kept here. */
49 static struct sstep_breaks
{
56 * Calculate the destination of a branch/jump. Return -1 if not a branch.
59 branch_dest (opcode
, instr
, pc
, safety
)
60 int opcode
, instr
, pc
, safety
;
68 absolute
= (int) ((instr
>> 1) & 1);
72 immediate
= ((instr
& ~3) << 6) >> 6; /* br unconditionl */
75 if (opcode
!= 18) /* br conditional */
76 immediate
= ((instr
& ~3) << 16) >> 16;
80 dest
= pc
+ immediate
;
84 ext_op
= (instr
>>1) & 0x3ff;
86 if (ext_op
== 16) /* br conditional register */
87 dest
= read_register (LR_REGNUM
) & ~3;
89 else if (ext_op
== 528) /* br cond to count reg */
90 dest
= read_register (CTR_REGNUM
) & ~3;
97 return (dest
< TEXT_SEGMENT_BASE
) ? safety
: dest
;
102 /* AIX does not support PT_STEP. Simulate it. */
108 #define INSNLEN(OPCODE) 4
110 static char breakp
[] = BREAKPOINT
;
111 int ii
, insn
, ret
, loc
;
112 int breaks
[2], opcode
;
115 extern CORE_ADDR text_start
;
118 ret
= read_memory (loc
, &insn
, sizeof (int));
120 printf ("Error in single_step()!!\n");
122 breaks
[0] = loc
+ INSNLEN(insn
);
124 breaks
[1] = branch_dest (opcode
, insn
, loc
, breaks
[0]);
126 /* Don't put two breakpoints on the same address. */
127 if (breaks
[1] == breaks
[0])
130 stepBreaks
[1].address
= -1;
132 for (ii
=0; ii
< 2; ++ii
) {
134 /* ignore invalid breakpoint. */
135 if ( breaks
[ii
] == -1)
138 read_memory (breaks
[ii
], &(stepBreaks
[ii
].data
), sizeof(int));
140 ret
= write_memory (breaks
[ii
], breakp
, sizeof(int));
141 stepBreaks
[ii
].address
= breaks
[ii
];
145 ptrace (PT_CONTINUE
, inferior_pid
, 1, signal
, 0);
149 /* remove step breakpoints. */
150 for (ii
=0; ii
< 2; ++ii
)
151 if (stepBreaks
[ii
].address
!= -1)
153 (stepBreaks
[ii
].address
, &(stepBreaks
[ii
].data
), sizeof(int));
162 /* return pc value after skipping a function prologue. */
170 if (target_read_memory (pc
, (char *)&op
, sizeof (op
)))
171 return pc
; /* Can't access it -- assume no prologue. */
172 SWAP_TARGET_AND_HOST (&op
, sizeof (op
));
174 /* Assume that subsequent fetches can fail with low probability. */
176 if (op
== 0x7c0802a6) { /* mflr r0 */
178 op
= read_memory_integer (pc
, 4);
181 if ((op
& 0xfc00003e) == 0x7c000026) { /* mfcr Rx */
183 op
= read_memory_integer (pc
, 4);
186 if ((op
& 0xfc000000) == 0x48000000) { /* bl foo, to save fprs??? */
188 op
= read_memory_integer (pc
, 4);
192 if ((op
& 0xfc1f0000) == 0xd8010000) { /* stfd Rx,NUM(r1) */
193 pc
+= 4; /* store floating register double */
194 op
= read_memory_integer (pc
, 4);
198 if ((op
& 0xfc1f0000) == 0xbc010000) { /* stm Rx, NUM(r1) */
200 op
= read_memory_integer (pc
, 4);
203 while (((tmp
= op
>> 16) == 0x9001) || /* st r0, NUM(r1) */
204 (tmp
== 0x9421) || /* stu r1, NUM(r1) */
205 (op
== 0x93e1fffc)) /* st r31,-4(r1) */
208 op
= read_memory_integer (pc
, 4);
211 while ((tmp
= (op
>> 22)) == 0x20f) { /* l r31, ... or */
212 pc
+= 4; /* l r30, ... */
213 op
= read_memory_integer (pc
, 4);
216 /* store parameters into stack */
218 (op
& 0xfc1f0000) == 0xd8010000 || /* stfd Rx,NUM(r1) */
219 (op
& 0xfc1f0000) == 0x90010000 || /* st r?, NUM(r1) */
220 (op
& 0xfc000000) == 0xfc000000 || /* frsp, fp?, .. */
221 (op
& 0xd0000000) == 0xd0000000) /* stfs, fp?, .. */
223 pc
+= 4; /* store fpr double */
224 op
= read_memory_integer (pc
, 4);
227 if (op
== 0x603f0000) { /* oril r31, r1, 0x0 */
228 pc
+= 4; /* this happens if r31 is used as */
229 op
= read_memory_integer (pc
, 4); /* frame ptr. (gcc does that) */
232 while ((op
>> 16) == (0x907f + tmp
)) { /* st r3, NUM(r31) */
233 pc
+= 4; /* st r4, NUM(r31), ... */
234 op
= read_memory_integer (pc
, 4);
242 /* text start and end addresses in virtual memory. */
244 CORE_ADDR text_start
;
247 /*************************************************************************
248 Support for creating pushind a dummy frame into the stack, and popping
250 *************************************************************************/
252 /* The total size of dummy frame is 436, which is;
257 and 24 extra bytes for the callee's link area. The last 24 bytes
258 for the link area might not be necessary, since it will be taken
259 care of by push_arguments(). */
261 #define DUMMY_FRAME_SIZE 436
263 #define DUMMY_FRAME_ADDR_SIZE 10
265 /* Make sure you initialize these in somewhere, in case gdb gives up what it
266 was debugging and starts debugging something else. FIXMEibm */
268 static int dummy_frame_count
= 0;
269 static int dummy_frame_size
= 0;
270 static CORE_ADDR
*dummy_frame_addr
= 0;
272 extern int stop_stack_dummy
;
274 /* push a dummy frame into stack, save all register. Currently we are saving
275 only gpr's and fpr's, which is not good enough! FIXMEmgo */
279 int sp
, pc
; /* stack pointer and link register */
282 fetch_inferior_registers (-1);
284 if (dummy_frame_count
>= dummy_frame_size
) {
285 dummy_frame_size
+= DUMMY_FRAME_ADDR_SIZE
;
286 if (dummy_frame_addr
)
287 dummy_frame_addr
= (CORE_ADDR
*) xrealloc
288 (dummy_frame_addr
, sizeof(CORE_ADDR
) * (dummy_frame_size
));
290 dummy_frame_addr
= (CORE_ADDR
*)
291 xmalloc (sizeof(CORE_ADDR
) * (dummy_frame_size
));
294 sp
= read_register(SP_REGNUM
);
295 pc
= read_register(PC_REGNUM
);
297 dummy_frame_addr
[dummy_frame_count
++] = sp
;
299 /* Be careful! If the stack pointer is not decremented first, then kernel
300 thinks he is free to use the space underneath it. And kernel actually
301 uses that area for IPC purposes when executing ptrace(2) calls. So
302 before writing register values into the new frame, decrement and update
303 %sp first in order to secure your frame. */
305 write_register (SP_REGNUM
, sp
-DUMMY_FRAME_SIZE
);
307 /* gdb relies on the state of current_frame. We'd better update it,
308 otherwise things like do_registers_info() wouldn't work properly! */
310 flush_cached_frames ();
311 set_current_frame (create_new_frame (sp
-DUMMY_FRAME_SIZE
, pc
));
313 /* save program counter in link register's space. */
314 write_memory (sp
+8, &pc
, 4);
316 /* save all floating point and general purpose registers here. */
319 for (ii
= 0; ii
< 32; ++ii
)
320 write_memory (sp
-8-(ii
*8), ®isters
[REGISTER_BYTE (31-ii
+FP0_REGNUM
)], 8);
323 for (ii
=1; ii
<=32; ++ii
)
324 write_memory (sp
-256-(ii
*4), ®isters
[REGISTER_BYTE (32-ii
)], 4);
326 /* so far, 32*2 + 32 words = 384 bytes have been written.
327 7 extra registers in our register set: pc, ps, cnd, lr, cnt, xer, mq */
329 for (ii
=1; ii
<= (LAST_SP_REGNUM
-FIRST_SP_REGNUM
+1); ++ii
) {
330 write_memory (sp
-384-(ii
*4),
331 ®isters
[REGISTER_BYTE (FPLAST_REGNUM
+ ii
)], 4);
334 /* Save sp or so called back chain right here. */
335 write_memory (sp
-DUMMY_FRAME_SIZE
, &sp
, 4);
336 sp
-= DUMMY_FRAME_SIZE
;
338 /* And finally, this is the back chain. */
339 write_memory (sp
+8, &pc
, 4);
343 /* Pop a dummy frame.
345 In rs6000 when we push a dummy frame, we save all of the registers. This
346 is usually done before user calls a function explicitly.
348 After a dummy frame is pushed, some instructions are copied into stack,
349 and stack pointer is decremented even more. Since we don't have a frame
350 pointer to get back to the parent frame of the dummy, we start having
351 trouble poping it. Therefore, we keep a dummy frame stack, keeping
352 addresses of dummy frames as such. When poping happens and when we
353 detect that was a dummy frame, we pop it back to its parent by using
354 dummy frame stack (`dummy_frame_addr' array).
361 sp
= dummy_frame_addr
[--dummy_frame_count
];
363 /* restore all fpr's. */
364 for (ii
= 1; ii
<= 32; ++ii
)
365 read_memory (sp
-(ii
*8), ®isters
[REGISTER_BYTE (32-ii
+FP0_REGNUM
)], 8);
367 /* restore all gpr's */
368 for (ii
=1; ii
<= 32; ++ii
) {
369 read_memory (sp
-256-(ii
*4), ®isters
[REGISTER_BYTE (32-ii
)], 4);
372 /* restore the rest of the registers. */
373 for (ii
=1; ii
<=(LAST_SP_REGNUM
-FIRST_SP_REGNUM
+1); ++ii
)
374 read_memory (sp
-384-(ii
*4),
375 ®isters
[REGISTER_BYTE (FPLAST_REGNUM
+ ii
)], 4);
377 read_memory (sp
-(DUMMY_FRAME_SIZE
-8),
378 ®isters
[REGISTER_BYTE(PC_REGNUM
)], 4);
380 /* when a dummy frame was being pushed, we had to decrement %sp first, in
381 order to secure astack space. Thus, saved %sp (or %r1) value, is not the
382 one we should restore. Change it with the one we need. */
384 *(int*)®isters
[REGISTER_BYTE(FP_REGNUM
)] = sp
;
386 /* Now we can restore all registers. */
388 store_inferior_registers (-1);
390 flush_cached_frames ();
391 set_current_frame (create_new_frame (sp
, pc
));
395 /* pop the innermost frame, go back to the caller. */
399 int pc
, lr
, sp
, prev_sp
; /* %pc, %lr, %sp */
400 struct aix_framedata fdata
;
401 FRAME fr
= get_current_frame ();
407 if (stop_stack_dummy
&& dummy_frame_count
) {
412 /* figure out previous %pc value. If the function is frameless, it is
413 still in the link register, otherwise walk the frames and retrieve the
414 saved %pc value in the previous frame. */
416 addr
= get_pc_function_start (fr
->pc
) + FUNCTION_START_OFFSET
;
417 function_frame_info (addr
, &fdata
);
419 read_memory (sp
, &prev_sp
, 4);
421 lr
= read_register (LR_REGNUM
);
423 read_memory (prev_sp
+8, &lr
, 4);
425 /* reset %pc value. */
426 write_register (PC_REGNUM
, lr
);
428 /* reset register values if any was saved earlier. */
429 addr
= prev_sp
- fdata
.offset
;
431 if (fdata
.saved_gpr
!= -1)
432 for (ii
=fdata
.saved_gpr
; ii
<= 31; ++ii
) {
433 read_memory (addr
, ®isters
[REGISTER_BYTE (ii
)], 4);
434 addr
+= sizeof (int);
437 if (fdata
.saved_fpr
!= -1)
438 for (ii
=fdata
.saved_fpr
; ii
<= 31; ++ii
) {
439 read_memory (addr
, ®isters
[REGISTER_BYTE (ii
+FP0_REGNUM
)], 8);
443 write_register (SP_REGNUM
, prev_sp
);
444 store_inferior_registers (-1);
445 flush_cached_frames ();
446 set_current_frame (create_new_frame (prev_sp
, lr
));
450 /* fixup the call sequence of a dummy function, with the real function address.
451 its argumets will be passed by gdb. */
453 fix_call_dummy(dummyname
, pc
, fun
, nargs
, type
)
457 int nargs
; /* not used */
458 int type
; /* not used */
461 #define TOC_ADDR_OFFSET 20
462 #define TARGET_ADDR_OFFSET 28
465 unsigned long target_addr
;
466 unsigned long tocvalue
;
469 tocvalue
= find_toc_address (target_addr
);
471 ii
= *(int*)((char*)dummyname
+ TOC_ADDR_OFFSET
);
472 ii
= (ii
& 0xffff0000) | (tocvalue
>> 16);
473 *(int*)((char*)dummyname
+ TOC_ADDR_OFFSET
) = ii
;
475 ii
= *(int*)((char*)dummyname
+ TOC_ADDR_OFFSET
+4);
476 ii
= (ii
& 0xffff0000) | (tocvalue
& 0x0000ffff);
477 *(int*)((char*)dummyname
+ TOC_ADDR_OFFSET
+4) = ii
;
479 ii
= *(int*)((char*)dummyname
+ TARGET_ADDR_OFFSET
);
480 ii
= (ii
& 0xffff0000) | (target_addr
>> 16);
481 *(int*)((char*)dummyname
+ TARGET_ADDR_OFFSET
) = ii
;
483 ii
= *(int*)((char*)dummyname
+ TARGET_ADDR_OFFSET
+4);
484 ii
= (ii
& 0xffff0000) | (target_addr
& 0x0000ffff);
485 *(int*)((char*)dummyname
+ TARGET_ADDR_OFFSET
+4) = ii
;
490 /* return information about a function frame.
491 in struct aix_frameinfo fdata:
492 - frameless is TRUE, if function does not save %pc value in its frame.
493 - offset is the number of bytes used in the frame to save registers.
494 - saved_gpr is the number of the first saved gpr.
495 - saved_fpr is the number of the first saved fpr.
496 - alloca_reg is the number of the register used for alloca() handling.
499 function_frame_info (pc
, fdata
)
501 struct aix_framedata
*fdata
;
504 register unsigned int op
;
507 fdata
->saved_gpr
= fdata
->saved_fpr
= fdata
->alloca_reg
= -1;
509 op
= read_memory_integer (pc
, 4);
510 if (op
== 0x7c0802a6) { /* mflr r0 */
512 op
= read_memory_integer (pc
, 4);
513 fdata
->frameless
= 0;
515 else /* else, this is a frameless invocation */
516 fdata
->frameless
= 1;
519 if ((op
& 0xfc00003e) == 0x7c000026) { /* mfcr Rx */
521 op
= read_memory_integer (pc
, 4);
524 if ((op
& 0xfc000000) == 0x48000000) { /* bl foo, to save fprs??? */
526 op
= read_memory_integer (pc
, 4);
529 if ((op
& 0xfc1f0000) == 0xd8010000) { /* stfd Rx,NUM(r1) */
530 pc
+= 4; /* store floating register double */
531 op
= read_memory_integer (pc
, 4);
534 if ((op
& 0xfc1f0000) == 0xbc010000) { /* stm Rx, NUM(r1) */
536 fdata
->saved_gpr
= (op
>> 21) & 0x1f;
539 tmp2
= 0xffff0000 | tmp2
;
543 fdata
->saved_fpr
= (tmp2
- ((32 - fdata
->saved_gpr
) * 4)) / 8;
544 if ( fdata
->saved_fpr
> 0)
545 fdata
->saved_fpr
= 32 - fdata
->saved_fpr
;
547 fdata
->saved_fpr
= -1;
549 fdata
->offset
= tmp2
;
551 op
= read_memory_integer (pc
, 4);
554 while (((tmp
= op
>> 16) == 0x9001) || /* st r0, NUM(r1) */
555 (tmp
== 0x9421) || /* stu r1, NUM(r1) */
556 (op
== 0x93e1fffc)) /* st r31,-4(r1) */
558 /* gcc takes a short cut and uses this instruction to save r31 only. */
560 if (op
== 0x93e1fffc) {
562 /* fatal ("Unrecognized prolog."); */
563 printf ("Unrecognized prolog!\n");
565 fdata
->saved_gpr
= 31;
569 op
= read_memory_integer (pc
, 4);
572 while ((tmp
= (op
>> 22)) == 0x20f) { /* l r31, ... or */
573 pc
+= 4; /* l r30, ... */
574 op
= read_memory_integer (pc
, 4);
577 /* store parameters into stack */
579 (op
& 0xfc1f0000) == 0xd8010000 || /* stfd Rx,NUM(r1) */
580 (op
& 0xfc1f0000) == 0x90010000 || /* st r?, NUM(r1) */
581 (op
& 0xfc000000) == 0xfc000000 || /* frsp, fp?, .. */
582 (op
& 0xd0000000) == 0xd0000000) /* stfs, fp?, .. */
584 pc
+= 4; /* store fpr double */
585 op
= read_memory_integer (pc
, 4);
588 if (op
== 0x603f0000) /* oril r31, r1, 0x0 */
589 fdata
->alloca_reg
= 31;
593 /* Pass the arguments in either registers, or in the stack. In RS6000, the first
594 eight words of the argument list (that might be less than eight parameters if
595 some parameters occupy more than one word) are passed in r3..r11 registers.
596 float and double parameters are passed in fpr's, in addition to that. Rest of
597 the parameters if any are passed in user stack. There might be cases in which
598 half of the parameter is copied into registers, the other half is pushed into
601 If the function is returning a structure, then the return address is passed
602 in r3, then the first 7 words of the parametes can be passed in registers,
606 push_arguments (nargs
, args
, sp
, struct_return
, struct_addr
)
611 CORE_ADDR struct_addr
;
614 int argno
; /* current argument number */
615 int argbytes
; /* current argument byte */
616 char tmp_buffer
[50];
618 int f_argno
= 0; /* current floating point argno */
620 CORE_ADDR saved_sp
, pc
;
622 if ( dummy_frame_count
<= 0)
623 printf ("FATAL ERROR -push_arguments()! frame not found!!\n");
625 /* The first eight words of ther arguments are passed in registers. Copy
628 If the function is returning a `struct', then the first word (which
629 will be passed in r3) is used for struct return address. In that
630 case we should advance one word and start from r4 register to copy
633 ii
= struct_return
? 1 : 0;
635 for (argno
=0, argbytes
=0; argno
< nargs
&& ii
<8; ++ii
) {
637 arg
= value_arg_coerce (args
[argno
]);
638 len
= TYPE_LENGTH (VALUE_TYPE (arg
));
640 if (TYPE_CODE (VALUE_TYPE (arg
)) == TYPE_CODE_FLT
) {
642 /* floating point arguments are passed in fpr's, as well as gpr's.
643 There are 13 fpr's reserved for passing parameters. At this point
644 there is no way we would run out of them. */
648 "Fatal Error: a floating point parameter #%d with a size > 8 is found!\n", argno
);
650 bcopy (VALUE_CONTENTS (arg
),
651 ®isters
[REGISTER_BYTE(FP0_REGNUM
+ 1 + f_argno
)], len
);
657 /* Argument takes more than one register. */
658 while (argbytes
< len
) {
660 *(int*)®isters
[REGISTER_BYTE(ii
+3)] = 0;
661 bcopy ( ((char*)VALUE_CONTENTS (arg
))+argbytes
,
662 ®isters
[REGISTER_BYTE(ii
+3)],
663 (len
- argbytes
) > 4 ? 4 : len
- argbytes
);
667 goto ran_out_of_registers_for_arguments
;
672 else { /* Argument can fit in one register. No problem. */
673 *(int*)®isters
[REGISTER_BYTE(ii
+3)] = 0;
674 bcopy (VALUE_CONTENTS (arg
), ®isters
[REGISTER_BYTE(ii
+3)], len
);
679 ran_out_of_registers_for_arguments
:
681 /* location for 8 parameters are always reserved. */
684 /* another six words for back chain, TOC register, link register, etc. */
687 /* if there are more arguments, allocate space for them in
688 the stack, then push them starting from the ninth one. */
690 if ((argno
< nargs
) || argbytes
) {
695 space
+= ((len
- argbytes
+ 3) & -4);
701 for (; jj
< nargs
; ++jj
) {
702 val
= value_arg_coerce (args
[jj
]);
703 space
+= ((TYPE_LENGTH (VALUE_TYPE (val
))) + 3) & -4;
706 /* add location required for the rest of the parameters */
707 space
= (space
+ 7) & -8;
710 /* This is another instance we need to be concerned about securing our
711 stack space. If we write anything underneath %sp (r1), we might conflict
712 with the kernel who thinks he is free to use this area. So, update %sp
713 first before doing anything else. */
715 write_register (SP_REGNUM
, sp
);
717 /* if the last argument copied into the registers didn't fit there
718 completely, push the rest of it into stack. */
722 sp
+24+(ii
*4), ((char*)VALUE_CONTENTS (arg
))+argbytes
, len
- argbytes
);
724 ii
+= ((len
- argbytes
+ 3) & -4) / 4;
727 /* push the rest of the arguments into stack. */
728 for (; argno
< nargs
; ++argno
) {
730 arg
= value_arg_coerce (args
[argno
]);
731 len
= TYPE_LENGTH (VALUE_TYPE (arg
));
734 /* float types should be passed in fpr's, as well as in the stack. */
735 if (TYPE_CODE (VALUE_TYPE (arg
)) == TYPE_CODE_FLT
&& f_argno
< 13) {
739 "Fatal Error: a floating point parameter #%d with a size > 8 is found!\n", argno
);
741 bcopy (VALUE_CONTENTS (arg
),
742 ®isters
[REGISTER_BYTE(FP0_REGNUM
+ 1 + f_argno
)], len
);
746 write_memory (sp
+24+(ii
*4), VALUE_CONTENTS (arg
), len
);
747 ii
+= ((len
+ 3) & -4) / 4;
751 /* Secure stack areas first, before doing anything else. */
752 write_register (SP_REGNUM
, sp
);
754 saved_sp
= dummy_frame_addr
[dummy_frame_count
- 1];
755 read_memory (saved_sp
, tmp_buffer
, 24);
756 write_memory (sp
, tmp_buffer
, 24);
758 write_memory (sp
, &saved_sp
, 4); /* set back chain properly */
760 store_inferior_registers (-1);
764 /* a given return value in `regbuf' with a type `valtype', extract and copy its
765 value into `valbuf' */
767 extract_return_value (valtype
, regbuf
, valbuf
)
768 struct type
*valtype
;
769 char regbuf
[REGISTER_BYTES
];
773 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
) {
776 /* floats and doubles are returned in fpr1. fpr's have a size of 8 bytes.
777 We need to truncate the return value into float size (4 byte) if
780 if (TYPE_LENGTH (valtype
) > 4) /* this is a double */
781 bcopy (®buf
[REGISTER_BYTE (FP0_REGNUM
+ 1)], valbuf
,
782 TYPE_LENGTH (valtype
));
784 bcopy (®buf
[REGISTER_BYTE (FP0_REGNUM
+ 1)], &dd
, 8);
786 bcopy (&ff
, valbuf
, sizeof(float));
790 /* return value is copied starting from r3. */
791 bcopy (®buf
[REGISTER_BYTE (3)], valbuf
, TYPE_LENGTH (valtype
));
795 /* keep keep structure return address in this variable. */
797 CORE_ADDR rs6000_struct_return_address
;
800 /* Throw away this debugging code. FIXMEmgo. */
805 for (ii
=0; ii
<40; ++ii
) {
808 val
= read_memory_integer (fram
+ ii
* 4, 4);
809 printf ("0x%08x\t", val
);
816 /* Indirect function calls use a piece of trampoline code do co context switching,
817 i.e. to set the new TOC table. Skip such code if exists. */
819 skip_trampoline_code (pc
)
822 register unsigned int ii
, op
;
824 static unsigned trampoline_code
[] = {
825 0x800b0000, /* l r0,0x0(r11) */
826 0x90410014, /* st r2,0x14(r1) */
827 0x7c0903a6, /* mtctr r0 */
828 0x804b0004, /* l r2,0x4(r11) */
829 0x816b0008, /* l r11,0x8(r11) */
830 0x4e800420, /* bctr */
835 for (ii
=0; trampoline_code
[ii
]; ++ii
) {
836 op
= read_memory_integer (pc
+ (ii
*4), 4);
837 if (op
!= trampoline_code
[ii
])
840 ii
= read_register (11); /* r11 holds destination addr */
841 pc
= read_memory_integer (ii
, 4); /* (r11) value */