1999-01-19 Fernando Nasser <fnasser@totem.to.cygnus.com>
[deliverable/binutils-gdb.git] / gdb / m88k-tdep.c
CommitLineData
ea3c0839 1/* Target-machine dependent code for Motorola 88000 series, for GDB.
18b46e7c 2 Copyright 1988, 1990, 1991, 1994, 1995 Free Software Foundation, Inc.
8aa13b87
JK
3
4This file is part of GDB.
5
99a7de40 6This program is free software; you can redistribute it and/or modify
8aa13b87 7it under the terms of the GNU General Public License as published by
99a7de40
JG
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
8aa13b87 10
99a7de40 11This program is distributed in the hope that it will be useful,
8aa13b87
JK
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
99a7de40 17along with this program; if not, write to the Free Software
6c9638b4 18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
8aa13b87 19
8aa13b87 20#include "defs.h"
8aa13b87
JK
21#include "frame.h"
22#include "inferior.h"
23#include "value.h"
8aa13b87 24#include "gdbcore.h"
8aa13b87
JK
25#include "symtab.h"
26#include "setjmp.h"
27#include "value.h"
28
2a770cac
JG
29/* Size of an instruction */
30#define BYTES_PER_88K_INSN 4
31
ea3c0839 32void frame_find_saved_regs ();
8aa13b87 33
669caa9c
SS
34/* Is this target an m88110? Otherwise assume m88100. This has
35 relevance for the ways in which we screw with instruction pointers. */
36
817ac7f8
RP
37int target_is_m88110 = 0;
38
8743fc88
AC
39/* The m88k kernel aligns all instructions on 4-byte boundaries. The
40 kernel also uses the least significant two bits for its own hocus
41 pocus. When gdb receives an address from the kernel, it needs to
42 preserve those right-most two bits, but gdb also needs to be careful
43 to realize that those two bits are not really a part of the address
44 of an instruction. Shrug. */
45
46CORE_ADDR
47m88k_addr_bits_remove (addr)
48 CORE_ADDR addr;
49{
50 return ((addr) & ~3);
51}
52
53
ea3c0839
JG
54/* Given a GDB frame, determine the address of the calling function's frame.
55 This will be used to create a new GDB frame struct, and then
56 INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame.
57
58 For us, the frame address is its stack pointer value, so we look up
59 the function prologue to determine the caller's sp value, and return it. */
60
669caa9c 61CORE_ADDR
ea3c0839 62frame_chain (thisframe)
669caa9c 63 struct frame_info *thisframe;
8aa13b87 64{
8aa13b87 65
ea3c0839
JG
66 frame_find_saved_regs (thisframe, (struct frame_saved_regs *) 0);
67 /* NOTE: this depends on frame_find_saved_regs returning the VALUE, not
68 the ADDRESS, of SP_REGNUM. It also depends on the cache of
69 frame_find_saved_regs results. */
70 if (thisframe->fsr->regs[SP_REGNUM])
71 return thisframe->fsr->regs[SP_REGNUM];
72 else
73 return thisframe->frame; /* Leaf fn -- next frame up has same SP. */
74}
8aa13b87 75
ea3c0839
JG
76int
77frameless_function_invocation (frame)
669caa9c 78 struct frame_info *frame;
8aa13b87 79{
ea3c0839
JG
80
81 frame_find_saved_regs (frame, (struct frame_saved_regs *) 0);
82 /* NOTE: this depends on frame_find_saved_regs returning the VALUE, not
83 the ADDRESS, of SP_REGNUM. It also depends on the cache of
84 frame_find_saved_regs results. */
85 if (frame->fsr->regs[SP_REGNUM])
86 return 0; /* Frameful -- return addr saved somewhere */
8aa13b87 87 else
ea3c0839 88 return 1; /* Frameless -- no saved return address */
8aa13b87
JK
89}
90
ea3c0839 91void
669caa9c 92init_extra_frame_info (fromleaf, frame)
ea3c0839 93 int fromleaf;
669caa9c 94 struct frame_info *frame;
ea3c0839 95{
669caa9c
SS
96 frame->fsr = 0; /* Not yet allocated */
97 frame->args_pointer = 0; /* Unknown */
98 frame->locals_pointer = 0; /* Unknown */
ea3c0839 99}
ea3c0839
JG
100\f
101/* Examine an m88k function prologue, recording the addresses at which
102 registers are saved explicitly by the prologue code, and returning
103 the address of the first instruction after the prologue (but not
104 after the instruction at address LIMIT, as explained below).
105
106 LIMIT places an upper bound on addresses of the instructions to be
107 examined. If the prologue code scan reaches LIMIT, the scan is
108 aborted and LIMIT is returned. This is used, when examining the
109 prologue for the current frame, to keep examine_prologue () from
110 claiming that a given register has been saved when in fact the
111 instruction that saves it has not yet been executed. LIMIT is used
112 at other times to stop the scan when we hit code after the true
113 function prologue (e.g. for the first source line) which might
114 otherwise be mistaken for function prologue.
115
116 The format of the function prologue matched by this routine is
117 derived from examination of the source to gcc 1.95, particularly
118 the routine output_prologue () in config/out-m88k.c.
119
120 subu r31,r31,n # stack pointer update
121
122 (st rn,r31,offset)? # save incoming regs
123 (st.d rn,r31,offset)?
124
125 (addu r30,r31,n)? # frame pointer update
126
127 (pic sequence)? # PIC code prologue
430923f3
JG
128
129 (or rn,rm,0)? # Move parameters to other regs
ea3c0839
JG
130*/
131
132/* Macros for extracting fields from instructions. */
133
134#define BITMASK(pos, width) (((0x1 << (width)) - 1) << (pos))
135#define EXTRACT_FIELD(val, pos, width) ((val) >> (pos) & BITMASK (0, width))
08f32e32
SS
136#define SUBU_OFFSET(x) ((unsigned)(x & 0xFFFF))
137#define ST_OFFSET(x) ((unsigned)((x) & 0xFFFF))
138#define ST_SRC(x) EXTRACT_FIELD ((x), 21, 5)
139#define ADDU_OFFSET(x) ((unsigned)(x & 0xFFFF))
ea3c0839 140
08f32e32
SS
141/*
142 * prologue_insn_tbl is a table of instructions which may comprise a
143 * function prologue. Associated with each table entry (corresponding
144 * to a single instruction or group of instructions), is an action.
145 * This action is used by examine_prologue (below) to determine
146 * the state of certain machine registers and where the stack frame lives.
147 */
148
149enum prologue_insn_action {
150 PIA_SKIP, /* don't care what the instruction does */
151 PIA_NOTE_ST, /* note register stored and where */
152 PIA_NOTE_STD, /* note pair of registers stored and where */
153 PIA_NOTE_SP_ADJUSTMENT, /* note stack pointer adjustment */
154 PIA_NOTE_FP_ASSIGNMENT, /* note frame pointer assignment */
155 PIA_NOTE_PROLOGUE_END, /* no more prologue */
156};
ea3c0839 157
08f32e32
SS
158struct prologue_insns {
159 unsigned long insn;
160 unsigned long mask;
161 enum prologue_insn_action action;
ea3c0839
JG
162};
163
08f32e32
SS
164struct prologue_insns prologue_insn_tbl[] = {
165 /* Various register move instructions */
166 { 0x58000000, 0xf800ffff, PIA_SKIP }, /* or/or.u with immed of 0 */
167 { 0xf4005800, 0xfc1fffe0, PIA_SKIP }, /* or rd, r0, rs */
168 { 0xf4005800, 0xfc00ffff, PIA_SKIP }, /* or rd, rs, r0 */
169
170 /* Stack pointer setup: "subu sp, sp, n" where n is a multiple of 8 */
171 { 0x67ff0000, 0xffff0007, PIA_NOTE_SP_ADJUSTMENT },
172
173 /* Frame pointer assignment: "addu r30, r31, n" */
174 { 0x63df0000, 0xffff0000, PIA_NOTE_FP_ASSIGNMENT },
175
176 /* Store to stack instructions; either "st rx, sp, n" or "st.d rx, sp, n" */
177 { 0x241f0000, 0xfc1f0000, PIA_NOTE_ST }, /* st rx, sp, n */
178 { 0x201f0000, 0xfc1f0000, PIA_NOTE_STD }, /* st.d rs, sp, n */
179
180 /* Instructions needed for setting up r25 for pic code. */
181 { 0x5f200000, 0xffff0000, PIA_SKIP }, /* or.u r25, r0, offset_high */
182 { 0xcc000002, 0xffffffff, PIA_SKIP }, /* bsr.n Lab */
183 { 0x5b390000, 0xffff0000, PIA_SKIP }, /* or r25, r25, offset_low */
184 { 0xf7396001, 0xffffffff, PIA_SKIP }, /* Lab: addu r25, r25, r1 */
185
186 /* Various branch or jump instructions which have a delay slot -- these
187 do not form part of the prologue, but the instruction in the delay
188 slot might be a store instruction which should be noted. */
189 { 0xc4000000, 0xe4000000, PIA_NOTE_PROLOGUE_END },
190 /* br.n, bsr.n, bb0.n, or bb1.n */
191 { 0xec000000, 0xfc000000, PIA_NOTE_PROLOGUE_END }, /* bcnd.n */
192 { 0xf400c400, 0xfffff7e0, PIA_NOTE_PROLOGUE_END } /* jmp.n or jsr.n */
193
ea3c0839
JG
194};
195
08f32e32 196
ea3c0839
JG
197/* Fetch the instruction at ADDR, returning 0 if ADDR is beyond LIM or
198 is not the address of a valid instruction, the address of the next
199 instruction beyond ADDR otherwise. *PWORD1 receives the first word
08f32e32 200 of the instruction. */
ea3c0839 201
637603f9 202#define NEXT_PROLOGUE_INSN(addr, lim, pword1) \
ea3c0839
JG
203 (((addr) < (lim)) ? next_insn (addr, pword1) : 0)
204
205/* Read the m88k instruction at 'memaddr' and return the address of
206 the next instruction after that, or 0 if 'memaddr' is not the
207 address of a valid instruction. The instruction
208 is stored at 'pword1'. */
8aa13b87 209
ea3c0839
JG
210CORE_ADDR
211next_insn (memaddr, pword1)
212 unsigned long *pword1;
213 CORE_ADDR memaddr;
8aa13b87 214{
2a770cac
JG
215 *pword1 = read_memory_integer (memaddr, BYTES_PER_88K_INSN);
216 return memaddr + BYTES_PER_88K_INSN;
8aa13b87
JK
217}
218
ea3c0839 219/* Read a register from frames called by us (or from the hardware regs). */
8aa13b87 220
637603f9 221static int
669caa9c
SS
222read_next_frame_reg(frame, regno)
223 struct frame_info *frame;
ea3c0839 224 int regno;
8aa13b87 225{
669caa9c
SS
226 for (; frame; frame = frame->next) {
227 if (regno == SP_REGNUM)
228 return FRAME_FP (frame);
229 else if (frame->fsr->regs[regno])
230 return read_memory_integer(frame->fsr->regs[regno], 4);
ea3c0839
JG
231 }
232 return read_register(regno);
8aa13b87 233}
8aa13b87 234
ea3c0839
JG
235/* Examine the prologue of a function. `ip' points to the first instruction.
236 `limit' is the limit of the prologue (e.g. the addr of the first
237 linenumber, or perhaps the program counter if we're stepping through).
238 `frame_sp' is the stack pointer value in use in this frame.
239 `fsr' is a pointer to a frame_saved_regs structure into which we put
240 info about the registers saved by this frame.
241 `fi' is a struct frame_info pointer; we fill in various fields in it
242 to reflect the offsets of the arg pointer and the locals pointer. */
243
244static CORE_ADDR
245examine_prologue (ip, limit, frame_sp, fsr, fi)
246 register CORE_ADDR ip;
247 register CORE_ADDR limit;
669caa9c 248 CORE_ADDR frame_sp;
ea3c0839
JG
249 struct frame_saved_regs *fsr;
250 struct frame_info *fi;
251{
252 register CORE_ADDR next_ip;
253 register int src;
637603f9 254 unsigned int insn;
ea3c0839
JG
255 int size, offset;
256 char must_adjust[32]; /* If set, must adjust offsets in fsr */
257 int sp_offset = -1; /* -1 means not set (valid must be mult of 8) */
258 int fp_offset = -1; /* -1 means not set */
259 CORE_ADDR frame_fp;
08f32e32 260 CORE_ADDR prologue_end = 0;
ea3c0839 261
4ed97c9a 262 memset (must_adjust, '\0', sizeof (must_adjust));
637603f9 263 next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn);
ea3c0839 264
08f32e32 265 while (next_ip)
ea3c0839 266 {
08f32e32 267 struct prologue_insns *pip;
ea3c0839 268
08f32e32
SS
269 for (pip=prologue_insn_tbl; (insn & pip->mask) != pip->insn; )
270 if (++pip >= prologue_insn_tbl + sizeof prologue_insn_tbl)
271 goto end_of_prologue_found; /* not a prologue insn */
ea3c0839 272
08f32e32 273 switch (pip->action)
ea3c0839 274 {
08f32e32
SS
275 case PIA_NOTE_ST:
276 case PIA_NOTE_STD:
277 if (sp_offset != -1) {
278 src = ST_SRC (insn);
279 offset = ST_OFFSET (insn);
280 must_adjust[src] = 1;
281 fsr->regs[src++] = offset; /* Will be adjusted later */
282 if (pip->action == PIA_NOTE_STD && src < 32)
283 {
284 offset += 4;
285 must_adjust[src] = 1;
286 fsr->regs[src++] = offset;
287 }
288 }
289 else
290 goto end_of_prologue_found;
291 break;
292 case PIA_NOTE_SP_ADJUSTMENT:
293 if (sp_offset == -1)
294 sp_offset = -SUBU_OFFSET (insn);
295 else
296 goto end_of_prologue_found;
297 break;
298 case PIA_NOTE_FP_ASSIGNMENT:
299 if (fp_offset == -1)
300 fp_offset = ADDU_OFFSET (insn);
301 else
302 goto end_of_prologue_found;
303 break;
304 case PIA_NOTE_PROLOGUE_END:
305 if (!prologue_end)
306 prologue_end = ip;
307 break;
308 case PIA_SKIP:
309 default :
310 /* Do nothing */
311 break;
ea3c0839 312 }
ea3c0839 313
ea3c0839 314 ip = next_ip;
637603f9 315 next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn);
ea3c0839
JG
316 }
317
08f32e32 318end_of_prologue_found:
ea3c0839 319
08f32e32
SS
320 if (prologue_end)
321 ip = prologue_end;
430923f3 322
ea3c0839
JG
323 /* We're done with the prologue. If we don't care about the stack
324 frame itself, just return. (Note that fsr->regs has been trashed,
325 but the one caller who calls with fi==0 passes a dummy there.) */
326
327 if (fi == 0)
328 return ip;
329
637603f9
RP
330 /*
331 OK, now we have:
332
333 sp_offset original (before any alloca calls) displacement of SP
334 (will be negative).
335
336 fp_offset displacement from original SP to the FP for this frame
337 or -1.
338
339 fsr->regs[0..31] displacement from original SP to the stack
340 location where reg[0..31] is stored.
341
342 must_adjust[0..31] set if corresponding offset was set.
ea3c0839 343
637603f9
RP
344 If alloca has been called between the function prologue and the current
345 IP, then the current SP (frame_sp) will not be the original SP as set by
346 the function prologue. If the current SP is not the original SP, then the
347 compiler will have allocated an FP for this frame, fp_offset will be set,
348 and we can use it to calculate the original SP.
ea3c0839 349
637603f9
RP
350 Then, we figure out where the arguments and locals are, and relocate the
351 offsets in fsr->regs to absolute addresses. */
ea3c0839
JG
352
353 if (fp_offset != -1) {
354 /* We have a frame pointer, so get it, and base our calc's on it. */
637603f9 355 frame_fp = (CORE_ADDR) read_next_frame_reg (fi->next, ACTUAL_FP_REGNUM);
ea3c0839
JG
356 frame_sp = frame_fp - fp_offset;
357 } else {
358 /* We have no frame pointer, therefore frame_sp is still the same value
359 as set by prologue. But where is the frame itself? */
360 if (must_adjust[SRP_REGNUM]) {
361 /* Function header saved SRP (r1), the return address. Frame starts
362 4 bytes down from where it was saved. */
363 frame_fp = frame_sp + fsr->regs[SRP_REGNUM] - 4;
364 fi->locals_pointer = frame_fp;
365 } else {
366 /* Function header didn't save SRP (r1), so we are in a leaf fn or
367 are otherwise confused. */
368 frame_fp = -1;
369 }
370 }
371
372 /* The locals are relative to the FP (whether it exists as an allocated
373 register, or just as an assumed offset from the SP) */
374 fi->locals_pointer = frame_fp;
375
376 /* The arguments are just above the SP as it was before we adjusted it
377 on entry. */
378 fi->args_pointer = frame_sp - sp_offset;
379
380 /* Now that we know the SP value used by the prologue, we know where
381 it saved all the registers. */
382 for (src = 0; src < 32; src++)
383 if (must_adjust[src])
384 fsr->regs[src] += frame_sp;
385
386 /* The saved value of the SP is always known. */
387 /* (we hope...) */
388 if (fsr->regs[SP_REGNUM] != 0
389 && fsr->regs[SP_REGNUM] != frame_sp - sp_offset)
199b2450 390 fprintf_unfiltered(gdb_stderr, "Bad saved SP value %x != %x, offset %x!\n",
ea3c0839
JG
391 fsr->regs[SP_REGNUM],
392 frame_sp - sp_offset, sp_offset);
393
394 fsr->regs[SP_REGNUM] = frame_sp - sp_offset;
8aa13b87 395
ea3c0839
JG
396 return (ip);
397}
8aa13b87 398
ea3c0839
JG
399/* Given an ip value corresponding to the start of a function,
400 return the ip of the first instruction after the function
401 prologue. */
8aa13b87
JK
402
403CORE_ADDR
ea3c0839
JG
404skip_prologue (ip)
405 CORE_ADDR (ip);
8aa13b87 406{
ea3c0839
JG
407 struct frame_saved_regs saved_regs_dummy;
408 struct symtab_and_line sal;
409 CORE_ADDR limit;
8aa13b87 410
ea3c0839
JG
411 sal = find_pc_line (ip, 0);
412 limit = (sal.end) ? sal.end : 0xffffffff;
413
669caa9c 414 return (examine_prologue (ip, limit, (CORE_ADDR) 0, &saved_regs_dummy,
ea3c0839
JG
415 (struct frame_info *)0 ));
416}
417
418/* Put here the code to store, into a struct frame_saved_regs,
419 the addresses of the saved registers of frame described by FRAME_INFO.
420 This includes special registers such as pc and fp saved in special
421 ways in the stack frame. sp is even more special:
422 the address we return for it IS the sp for the next frame.
423
86a51f41
AC
424 We cache the result of doing this in the frame_obstack, since it is
425 fairly expensive. */
ea3c0839
JG
426
427void
428frame_find_saved_regs (fi, fsr)
429 struct frame_info *fi;
430 struct frame_saved_regs *fsr;
431{
ea3c0839 432 register struct frame_saved_regs *cache_fsr;
ea3c0839
JG
433 CORE_ADDR ip;
434 struct symtab_and_line sal;
435 CORE_ADDR limit;
436
437 if (!fi->fsr)
8aa13b87 438 {
ea3c0839 439 cache_fsr = (struct frame_saved_regs *)
86a51f41 440 frame_obstack_alloc (sizeof (struct frame_saved_regs));
4ed97c9a 441 memset (cache_fsr, '\0', sizeof (struct frame_saved_regs));
ea3c0839
JG
442 fi->fsr = cache_fsr;
443
444 /* Find the start and end of the function prologue. If the PC
445 is in the function prologue, we only consider the part that
08f32e32
SS
446 has executed already. In the case where the PC is not in
447 the function prologue, we set limit to two instructions beyond
448 where the prologue ends in case if any of the prologue instructions
449 were moved into a delay slot of a branch instruction. */
ea3c0839
JG
450
451 ip = get_pc_function_start (fi->pc);
452 sal = find_pc_line (ip, 0);
08f32e32
SS
453 limit = (sal.end && sal.end < fi->pc) ? sal.end + 2 * BYTES_PER_88K_INSN
454 : fi->pc;
ea3c0839
JG
455
456 /* This will fill in fields in *fi as well as in cache_fsr. */
7bec77b4
JK
457#ifdef SIGTRAMP_FRAME_FIXUP
458 if (fi->signal_handler_caller)
459 SIGTRAMP_FRAME_FIXUP(fi->frame);
460#endif
ea3c0839 461 examine_prologue (ip, limit, fi->frame, cache_fsr, fi);
7bec77b4
JK
462#ifdef SIGTRAMP_SP_FIXUP
463 if (fi->signal_handler_caller && fi->fsr->regs[SP_REGNUM])
464 SIGTRAMP_SP_FIXUP(fi->fsr->regs[SP_REGNUM]);
465#endif
8aa13b87
JK
466 }
467
ea3c0839
JG
468 if (fsr)
469 *fsr = *fi->fsr;
470}
471
472/* Return the address of the locals block for the frame
473 described by FI. Returns 0 if the address is unknown.
474 NOTE! Frame locals are referred to by negative offsets from the
475 argument pointer, so this is the same as frame_args_address(). */
476
477CORE_ADDR
478frame_locals_address (fi)
479 struct frame_info *fi;
480{
ea3c0839 481 struct frame_saved_regs fsr;
ea3c0839
JG
482
483 if (fi->args_pointer) /* Cached value is likely there. */
484 return fi->args_pointer;
485
486 /* Nope, generate it. */
487
488 get_frame_saved_regs (fi, &fsr);
489
490 return fi->args_pointer;
491}
492
493/* Return the address of the argument block for the frame
494 described by FI. Returns 0 if the address is unknown. */
495
496CORE_ADDR
497frame_args_address (fi)
498 struct frame_info *fi;
499{
ea3c0839 500 struct frame_saved_regs fsr;
ea3c0839
JG
501
502 if (fi->args_pointer) /* Cached value is likely there. */
503 return fi->args_pointer;
504
505 /* Nope, generate it. */
506
507 get_frame_saved_regs (fi, &fsr);
508
509 return fi->args_pointer;
510}
511
512/* Return the saved PC from this frame.
513
514 If the frame has a memory copy of SRP_REGNUM, use that. If not,
515 just use the register SRP_REGNUM itself. */
516
517CORE_ADDR
518frame_saved_pc (frame)
669caa9c 519 struct frame_info *frame;
ea3c0839
JG
520{
521 return read_next_frame_reg(frame, SRP_REGNUM);
8aa13b87
JK
522}
523
abef03ce
JK
524
525#define DUMMY_FRAME_SIZE 192
526
527static void
528write_word (sp, word)
529 CORE_ADDR sp;
119dfbb7 530 ULONGEST word;
abef03ce 531{
f4f0d174 532 register int len = REGISTER_SIZE;
abef03ce
JK
533 char buffer[MAX_REGISTER_RAW_SIZE];
534
535 store_unsigned_integer (buffer, len, word);
536 write_memory (sp, buffer, len);
537}
538
539void
540m88k_push_dummy_frame()
541{
542 register CORE_ADDR sp = read_register (SP_REGNUM);
543 register int rn;
544 int offset;
545
546 sp -= DUMMY_FRAME_SIZE; /* allocate a bunch of space */
547
548 for (rn = 0, offset = 0; rn <= SP_REGNUM; rn++, offset+=4)
549 write_word (sp+offset, read_register(rn));
8aa13b87 550
abef03ce
JK
551 write_word (sp+offset, read_register (SXIP_REGNUM));
552 offset += 4;
553
554 write_word (sp+offset, read_register (SNIP_REGNUM));
555 offset += 4;
556
557 write_word (sp+offset, read_register (SFIP_REGNUM));
558 offset += 4;
559
560 write_word (sp+offset, read_register (PSR_REGNUM));
561 offset += 4;
562
563 write_word (sp+offset, read_register (FPSR_REGNUM));
564 offset += 4;
565
566 write_word (sp+offset, read_register (FPCR_REGNUM));
567 offset += 4;
568
569 write_register (SP_REGNUM, sp);
570 write_register (ACTUAL_FP_REGNUM, sp);
571}
572
573void
574pop_frame ()
ea3c0839 575{
669caa9c 576 register struct frame_info *frame = get_current_frame ();
abef03ce
JK
577 register CORE_ADDR fp;
578 register int regnum;
579 struct frame_saved_regs fsr;
abef03ce 580
669caa9c
SS
581 fp = FRAME_FP (frame);
582 get_frame_saved_regs (frame, &fsr);
abef03ce 583
669caa9c 584 if (PC_IN_CALL_DUMMY (read_pc (), read_register (SP_REGNUM), FRAME_FP (fi)))
abef03ce
JK
585 {
586 /* FIXME: I think get_frame_saved_regs should be handling this so
587 that we can deal with the saved registers properly (e.g. frame
588 1 is a call dummy, the user types "frame 2" and then "print $ps"). */
589 register CORE_ADDR sp = read_register (ACTUAL_FP_REGNUM);
590 int offset;
591
592 for (regnum = 0, offset = 0; regnum <= SP_REGNUM; regnum++, offset+=4)
593 (void) write_register (regnum, read_memory_integer (sp+offset, 4));
594
595 write_register (SXIP_REGNUM, read_memory_integer (sp+offset, 4));
596 offset += 4;
8aa13b87 597
abef03ce
JK
598 write_register (SNIP_REGNUM, read_memory_integer (sp+offset, 4));
599 offset += 4;
8aa13b87 600
abef03ce
JK
601 write_register (SFIP_REGNUM, read_memory_integer (sp+offset, 4));
602 offset += 4;
8aa13b87 603
abef03ce
JK
604 write_register (PSR_REGNUM, read_memory_integer (sp+offset, 4));
605 offset += 4;
ea3c0839 606
abef03ce
JK
607 write_register (FPSR_REGNUM, read_memory_integer (sp+offset, 4));
608 offset += 4;
8aa13b87 609
abef03ce
JK
610 write_register (FPCR_REGNUM, read_memory_integer (sp+offset, 4));
611 offset += 4;
ea3c0839 612
abef03ce
JK
613 }
614 else
615 {
616 for (regnum = FP_REGNUM ; regnum > 0 ; regnum--)
617 if (fsr.regs[regnum])
618 write_register (regnum,
619 read_memory_integer (fsr.regs[regnum], 4));
669caa9c 620 write_pc (frame_saved_pc (frame));
abef03ce
JK
621 }
622 reinit_frame_cache ();
8aa13b87 623}
18b46e7c
SS
624
625void
626_initialize_m88k_tdep ()
627{
628 tm_print_insn = print_insn_m88k;
629}
This page took 0.361616 seconds and 4 git commands to generate.