Wed Dec 2 15:11:38 1998 Michael Snyder <msnyder@cleaver.cygnus.com>
[deliverable/binutils-gdb.git] / gdb / mn10300-tdep.c
1 /* Target-dependent code for the Matsushita MN10300 for GDB, the GNU debugger.
2 Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
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.
10
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.
15
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, Boston, MA 02111-1307, USA. */
19
20 #include "defs.h"
21 #include "frame.h"
22 #include "inferior.h"
23 #include "obstack.h"
24 #include "target.h"
25 #include "value.h"
26 #include "bfd.h"
27 #include "gdb_string.h"
28 #include "gdbcore.h"
29 #include "symfile.h"
30
31 char *mn10300_generic_register_names[] = REGISTER_NAMES;
32
33 /* start-sanitize-am33 */
34 char *am33_register_names [] =
35 { "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3",
36 "sp", "pc", "mdr", "psw", "lir", "lar", "",
37 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
38 "ssp", "msp", "usp", "mcrh", "mcrl", "mcvf", "", "", ""};
39 int am33_mode;
40 /* end-sanitize-am33 */
41
42 static CORE_ADDR mn10300_analyze_prologue PARAMS ((struct frame_info *fi,
43 CORE_ADDR pc));
44
45 /* Values for frame_info.status */
46
47 #define MY_FRAME_IN_SP 0x1
48 #define MY_FRAME_IN_FP 0x2
49 #define NO_MORE_FRAMES 0x4
50
51
52 /* Should call_function allocate stack space for a struct return? */
53 int
54 mn10300_use_struct_convention (gcc_p, type)
55 int gcc_p;
56 struct type *type;
57 {
58 return (TYPE_NFIELDS (type) > 1 || TYPE_LENGTH (type) > 8);
59 }
60
61 /* The breakpoint instruction must be the same size as the smallest
62 instruction in the instruction set.
63
64 The Matsushita mn10x00 processors have single byte instructions
65 so we need a single byte breakpoint. Matsushita hasn't defined
66 one, so we defined it ourselves. */
67
68 unsigned char *
69 mn10300_breakpoint_from_pc (bp_addr, bp_size)
70 CORE_ADDR *bp_addr;
71 int *bp_size;
72 {
73 static char breakpoint[] = {0xff};
74 *bp_size = 1;
75 return breakpoint;
76 }
77
78
79 /* Fix fi->frame if it's bogus at this point. This is a helper
80 function for mn10300_analyze_prologue. */
81
82 static void
83 fix_frame_pointer (fi, stack_size)
84 struct frame_info *fi;
85 int stack_size;
86 {
87 if (fi && fi->next == NULL)
88 {
89 if (fi->status & MY_FRAME_IN_SP)
90 fi->frame = read_sp () - stack_size;
91 else if (fi->status & MY_FRAME_IN_FP)
92 fi->frame = read_register (A3_REGNUM);
93 }
94 }
95
96
97 /* Set offsets of registers saved by movm instruction.
98 This is a helper function for mn10300_analyze_prologue. */
99
100 static void
101 set_movm_offsets (fi, movm_args)
102 struct frame_info *fi;
103 int movm_args;
104 {
105 int offset = 0;
106
107 if (fi == NULL || movm_args == 0)
108 return;
109
110 if (movm_args & 0x10)
111 {
112 fi->fsr.regs[A3_REGNUM] = fi->frame + offset;
113 offset += 4;
114 }
115 if (movm_args & 0x20)
116 {
117 fi->fsr.regs[A2_REGNUM] = fi->frame + offset;
118 offset += 4;
119 }
120 if (movm_args & 0x40)
121 {
122 fi->fsr.regs[D3_REGNUM] = fi->frame + offset;
123 offset += 4;
124 }
125 if (movm_args & 0x80)
126 {
127 fi->fsr.regs[D2_REGNUM] = fi->frame + offset;
128 offset += 4;
129 }
130 /* start-sanitize-am33 */
131 if (am33_mode && movm_args & 0x02)
132 {
133 fi->fsr.regs[E0_REGNUM+5] = fi->frame + offset;
134 fi->fsr.regs[E0_REGNUM+4] = fi->frame + offset + 4;
135 fi->fsr.regs[E0_REGNUM+3] = fi->frame + offset + 8;
136 fi->fsr.regs[E0_REGNUM+2] = fi->frame + offset + 12;
137 }
138 /* end-sanitize-am33 */
139 }
140
141
142 /* The main purpose of this file is dealing with prologues to extract
143 information about stack frames and saved registers.
144
145 For reference here's how prologues look on the mn10300:
146
147 With frame pointer:
148 movm [d2,d3,a2,a3],sp
149 mov sp,a3
150 add <size>,sp
151
152 Without frame pointer:
153 movm [d2,d3,a2,a3],sp (if needed)
154 add <size>,sp
155
156 One day we might keep the stack pointer constant, that won't
157 change the code for prologues, but it will make the frame
158 pointerless case much more common. */
159
160 /* Analyze the prologue to determine where registers are saved,
161 the end of the prologue, etc etc. Return the end of the prologue
162 scanned.
163
164 We store into FI (if non-null) several tidbits of information:
165
166 * stack_size -- size of this stack frame. Note that if we stop in
167 certain parts of the prologue/epilogue we may claim the size of the
168 current frame is zero. This happens when the current frame has
169 not been allocated yet or has already been deallocated.
170
171 * fsr -- Addresses of registers saved in the stack by this frame.
172
173 * status -- A (relatively) generic status indicator. It's a bitmask
174 with the following bits:
175
176 MY_FRAME_IN_SP: The base of the current frame is actually in
177 the stack pointer. This can happen for frame pointerless
178 functions, or cases where we're stopped in the prologue/epilogue
179 itself. For these cases mn10300_analyze_prologue will need up
180 update fi->frame before returning or analyzing the register
181 save instructions.
182
183 MY_FRAME_IN_FP: The base of the current frame is in the
184 frame pointer register ($a2).
185
186 NO_MORE_FRAMES: Set this if the current frame is "start" or
187 if the first instruction looks like mov <imm>,sp. This tells
188 frame chain to not bother trying to unwind past this frame. */
189
190 static CORE_ADDR
191 mn10300_analyze_prologue (fi, pc)
192 struct frame_info *fi;
193 CORE_ADDR pc;
194 {
195 CORE_ADDR func_addr, func_end, addr, stop;
196 CORE_ADDR stack_size;
197 int imm_size;
198 unsigned char buf[4];
199 int status, movm_args = 0;
200 char *name;
201
202 /* Use the PC in the frame if it's provided to look up the
203 start of this function. */
204 pc = (fi ? fi->pc : pc);
205
206 /* Find the start of this function. */
207 status = find_pc_partial_function (pc, &name, &func_addr, &func_end);
208
209 /* Do nothing if we couldn't find the start of this function or if we're
210 stopped at the first instruction in the prologue. */
211 if (status == 0)
212 return pc;
213
214 /* If we're in start, then give up. */
215 if (strcmp (name, "start") == 0)
216 {
217 if (fi != NULL)
218 fi->status = NO_MORE_FRAMES;
219 return pc;
220 }
221
222 /* At the start of a function our frame is in the stack pointer. */
223 if (fi)
224 fi->status = MY_FRAME_IN_SP;
225
226 /* Get the next two bytes into buf, we need two because rets is a two
227 byte insn and the first isn't enough to uniquely identify it. */
228 status = read_memory_nobpt (pc, buf, 2);
229 if (status != 0)
230 return pc;
231
232 /* If we're physically on an "rets" instruction, then our frame has
233 already been deallocated. Note this can also be true for retf
234 and ret if they specify a size of zero.
235
236 In this case fi->frame is bogus, we need to fix it. */
237 if (fi && buf[0] == 0xf0 && buf[1] == 0xfc)
238 {
239 if (fi->next == NULL)
240 fi->frame = read_sp ();
241 return fi->pc;
242 }
243
244 /* Similarly if we're stopped on the first insn of a prologue as our
245 frame hasn't been allocated yet. */
246 if (fi && fi->pc == func_addr)
247 {
248 if (fi->next == NULL)
249 fi->frame = read_sp ();
250 return fi->pc;
251 }
252
253 /* Figure out where to stop scanning. */
254 stop = fi ? fi->pc : func_end;
255
256 /* Don't walk off the end of the function. */
257 stop = stop > func_end ? func_end : stop;
258
259 /* Start scanning on the first instruction of this function. */
260 addr = func_addr;
261
262 /* Suck in two bytes. */
263 status = read_memory_nobpt (addr, buf, 2);
264 if (status != 0)
265 {
266 fix_frame_pointer (fi, 0);
267 return addr;
268 }
269
270 /* First see if this insn sets the stack pointer; if so, it's something
271 we won't understand, so quit now. */
272 if (buf[0] == 0xf2 && (buf[1] & 0xf3) == 0xf0)
273 {
274 if (fi)
275 fi->status = NO_MORE_FRAMES;
276 return addr;
277 }
278
279 /* Now look for movm [regs],sp, which saves the callee saved registers.
280
281 At this time we don't know if fi->frame is valid, so we only note
282 that we encountered a movm instruction. Later, we'll set the entries
283 in fsr.regs as needed. */
284 if (buf[0] == 0xcf)
285 {
286 /* Extract the register list for the movm instruction. */
287 status = read_memory_nobpt (addr + 1, buf, 1);
288 movm_args = *buf;
289
290 addr += 2;
291
292 /* Quit now if we're beyond the stop point. */
293 if (addr >= stop)
294 {
295 /* Fix fi->frame since it's bogus at this point. */
296 if (fi && fi->next == NULL)
297 fi->frame = read_sp ();
298
299 /* Note if/where callee saved registers were saved. */
300 set_movm_offsets (fi, movm_args);
301 return addr;
302 }
303
304 /* Get the next two bytes so the prologue scan can continue. */
305 status = read_memory_nobpt (addr, buf, 2);
306 if (status != 0)
307 {
308 /* Fix fi->frame since it's bogus at this point. */
309 if (fi && fi->next == NULL)
310 fi->frame = read_sp ();
311
312 /* Note if/where callee saved registers were saved. */
313 set_movm_offsets (fi, movm_args);
314 return addr;
315 }
316 }
317
318 /* Now see if we set up a frame pointer via "mov sp,a3" */
319 if (buf[0] == 0x3f)
320 {
321 addr += 1;
322
323 /* The frame pointer is now valid. */
324 if (fi)
325 {
326 fi->status |= MY_FRAME_IN_FP;
327 fi->status &= ~MY_FRAME_IN_SP;
328 }
329
330 /* Quit now if we're beyond the stop point. */
331 if (addr >= stop)
332 {
333 /* Fix fi->frame if it's bogus at this point. */
334 fix_frame_pointer (fi, 0);
335
336 /* Note if/where callee saved registers were saved. */
337 set_movm_offsets (fi, movm_args);
338 return addr;
339 }
340
341 /* Get two more bytes so scanning can continue. */
342 status = read_memory_nobpt (addr, buf, 2);
343 if (status != 0)
344 {
345 /* Fix fi->frame if it's bogus at this point. */
346 fix_frame_pointer (fi, 0);
347
348 /* Note if/where callee saved registers were saved. */
349 set_movm_offsets (fi, movm_args);
350 return addr;
351 }
352 }
353
354 /* Next we should allocate the local frame. No more prologue insns
355 are found after allocating the local frame.
356
357 Search for add imm8,sp (0xf8feXX)
358 or add imm16,sp (0xfafeXXXX)
359 or add imm32,sp (0xfcfeXXXXXXXX).
360
361 If none of the above was found, then this prologue has no
362 additional stack. */
363
364 status = read_memory_nobpt (addr, buf, 2);
365 if (status != 0)
366 {
367 /* Fix fi->frame if it's bogus at this point. */
368 fix_frame_pointer (fi, 0);
369
370 /* Note if/where callee saved registers were saved. */
371 set_movm_offsets (fi, movm_args);
372 return addr;
373 }
374
375 imm_size = 0;
376 if (buf[0] == 0xf8 && buf[1] == 0xfe)
377 imm_size = 1;
378 else if (buf[0] == 0xfa && buf[1] == 0xfe)
379 imm_size = 2;
380 else if (buf[0] == 0xfc && buf[1] == 0xfe)
381 imm_size = 4;
382
383 if (imm_size != 0)
384 {
385 /* Suck in imm_size more bytes, they'll hold the size of the
386 current frame. */
387 status = read_memory_nobpt (addr + 2, buf, imm_size);
388 if (status != 0)
389 {
390 /* Fix fi->frame if it's bogus at this point. */
391 fix_frame_pointer (fi, 0);
392
393 /* Note if/where callee saved registers were saved. */
394 set_movm_offsets (fi, movm_args);
395 return addr;
396 }
397
398 /* Note the size of the stack in the frame info structure. */
399 stack_size = extract_signed_integer (buf, imm_size);
400 if (fi)
401 fi->stack_size = stack_size;
402
403 /* We just consumed 2 + imm_size bytes. */
404 addr += 2 + imm_size;
405
406 /* No more prologue insns follow, so begin preparation to return. */
407 /* Fix fi->frame if it's bogus at this point. */
408 fix_frame_pointer (fi, stack_size);
409
410 /* Note if/where callee saved registers were saved. */
411 set_movm_offsets (fi, movm_args);
412 return addr;
413 }
414
415 /* We never found an insn which allocates local stack space, regardless
416 this is the end of the prologue. */
417 /* Fix fi->frame if it's bogus at this point. */
418 fix_frame_pointer (fi, 0);
419
420 /* Note if/where callee saved registers were saved. */
421 set_movm_offsets (fi, movm_args);
422 return addr;
423 }
424
425 /* Function: frame_chain
426 Figure out and return the caller's frame pointer given current
427 frame_info struct.
428
429 We don't handle dummy frames yet but we would probably just return the
430 stack pointer that was in use at the time the function call was made? */
431
432 CORE_ADDR
433 mn10300_frame_chain (fi)
434 struct frame_info *fi;
435 {
436 struct frame_info dummy_frame;
437
438 /* Walk through the prologue to determine the stack size,
439 location of saved registers, end of the prologue, etc. */
440 if (fi->status == 0)
441 mn10300_analyze_prologue (fi, (CORE_ADDR)0);
442
443 /* Quit now if mn10300_analyze_prologue set NO_MORE_FRAMES. */
444 if (fi->status & NO_MORE_FRAMES)
445 return 0;
446
447 /* Now that we've analyzed our prologue, determine the frame
448 pointer for our caller.
449
450 If our caller has a frame pointer, then we need to
451 find the entry value of $a3 to our function.
452
453 If fsr.regs[A3_REGNUM] is nonzero, then it's at the memory
454 location pointed to by fsr.regs[A3_REGNUM].
455
456 Else it's still in $a3.
457
458 If our caller does not have a frame pointer, then his
459 frame base is fi->frame + -caller's stack size. */
460
461 /* The easiest way to get that info is to analyze our caller's frame.
462
463 So we set up a dummy frame and call mn10300_analyze_prologue to
464 find stuff for us. */
465 dummy_frame.pc = FRAME_SAVED_PC (fi);
466 dummy_frame.frame = fi->frame;
467 memset (dummy_frame.fsr.regs, '\000', sizeof dummy_frame.fsr.regs);
468 dummy_frame.status = 0;
469 dummy_frame.stack_size = 0;
470 mn10300_analyze_prologue (&dummy_frame, 0);
471
472 if (dummy_frame.status & MY_FRAME_IN_FP)
473 {
474 /* Our caller has a frame pointer. So find the frame in $a3 or
475 in the stack. */
476 if (fi->fsr.regs[A3_REGNUM])
477 return (read_memory_integer (fi->fsr.regs[A3_REGNUM], REGISTER_SIZE));
478 else
479 return read_register (A3_REGNUM);
480 }
481 else
482 {
483 int adjust = 0;
484
485 adjust += (fi->fsr.regs[D2_REGNUM] ? 4 : 0);
486 adjust += (fi->fsr.regs[D3_REGNUM] ? 4 : 0);
487 adjust += (fi->fsr.regs[A2_REGNUM] ? 4 : 0);
488 adjust += (fi->fsr.regs[A3_REGNUM] ? 4 : 0);
489 /* start-sanitize-am33 */
490 if (am33_mode)
491 {
492 adjust += (fi->fsr.regs[E0_REGNUM+5] ? 4 : 0);
493 adjust += (fi->fsr.regs[E0_REGNUM+4] ? 4 : 0);
494 adjust += (fi->fsr.regs[E0_REGNUM+3] ? 4 : 0);
495 adjust += (fi->fsr.regs[E0_REGNUM+2] ? 4 : 0);
496 }
497 /* end-sanitize-am33 */
498
499 /* Our caller does not have a frame pointer. So his frame starts
500 at the base of our frame (fi->frame) + register save space
501 + <his size>. */
502 return fi->frame + adjust + -dummy_frame.stack_size;
503 }
504 }
505
506 /* Function: skip_prologue
507 Return the address of the first inst past the prologue of the function. */
508
509 CORE_ADDR
510 mn10300_skip_prologue (pc)
511 CORE_ADDR pc;
512 {
513 /* We used to check the debug symbols, but that can lose if
514 we have a null prologue. */
515 return mn10300_analyze_prologue (NULL, pc);
516 }
517
518
519 /* Function: pop_frame
520 This routine gets called when either the user uses the `return'
521 command, or the call dummy breakpoint gets hit. */
522
523 void
524 mn10300_pop_frame (frame)
525 struct frame_info *frame;
526 {
527 int regnum;
528
529 if (PC_IN_CALL_DUMMY(frame->pc, frame->frame, frame->frame))
530 generic_pop_dummy_frame ();
531 else
532 {
533 write_register (PC_REGNUM, FRAME_SAVED_PC (frame));
534
535 /* Restore any saved registers. */
536 for (regnum = 0; regnum < NUM_REGS; regnum++)
537 if (frame->fsr.regs[regnum] != 0)
538 {
539 ULONGEST value;
540
541 value = read_memory_unsigned_integer (frame->fsr.regs[regnum],
542 REGISTER_RAW_SIZE (regnum));
543 write_register (regnum, value);
544 }
545
546 /* Actually cut back the stack. */
547 write_register (SP_REGNUM, FRAME_FP (frame));
548
549 /* Don't we need to set the PC?!? XXX FIXME. */
550 }
551
552 /* Throw away any cached frame information. */
553 flush_cached_frames ();
554 }
555
556 /* Function: push_arguments
557 Setup arguments for a call to the target. Arguments go in
558 order on the stack. */
559
560 CORE_ADDR
561 mn10300_push_arguments (nargs, args, sp, struct_return, struct_addr)
562 int nargs;
563 value_ptr *args;
564 CORE_ADDR sp;
565 unsigned char struct_return;
566 CORE_ADDR struct_addr;
567 {
568 int argnum = 0;
569 int len = 0;
570 int stack_offset = 0;
571 int regsused = struct_return ? 1 : 0;
572
573 /* This should be a nop, but align the stack just in case something
574 went wrong. Stacks are four byte aligned on the mn10300. */
575 sp &= ~3;
576
577 /* Now make space on the stack for the args.
578
579 XXX This doesn't appear to handle pass-by-invisible reference
580 arguments. */
581 for (argnum = 0; argnum < nargs; argnum++)
582 {
583 int arg_length = (TYPE_LENGTH (VALUE_TYPE (args[argnum])) + 3) & ~3;
584
585 while (regsused < 2 && arg_length > 0)
586 {
587 regsused++;
588 arg_length -= 4;
589 }
590 len += arg_length;
591 }
592
593 /* Allocate stack space. */
594 sp -= len;
595
596 regsused = struct_return ? 1 : 0;
597 /* Push all arguments onto the stack. */
598 for (argnum = 0; argnum < nargs; argnum++)
599 {
600 int len;
601 char *val;
602
603 /* XXX Check this. What about UNIONS? */
604 if (TYPE_CODE (VALUE_TYPE (*args)) == TYPE_CODE_STRUCT
605 && TYPE_LENGTH (VALUE_TYPE (*args)) > 8)
606 {
607 /* XXX Wrong, we want a pointer to this argument. */
608 len = TYPE_LENGTH (VALUE_TYPE (*args));
609 val = (char *)VALUE_CONTENTS (*args);
610 }
611 else
612 {
613 len = TYPE_LENGTH (VALUE_TYPE (*args));
614 val = (char *)VALUE_CONTENTS (*args);
615 }
616
617 while (regsused < 2 && len > 0)
618 {
619 write_register (regsused, extract_unsigned_integer (val, 4));
620 val += 4;
621 len -= 4;
622 regsused++;
623 }
624
625 while (len > 0)
626 {
627 write_memory (sp + stack_offset, val, 4);
628 len -= 4;
629 val += 4;
630 stack_offset += 4;
631 }
632
633 args++;
634 }
635
636 /* Make space for the flushback area. */
637 sp -= 8;
638 return sp;
639 }
640
641 /* Function: push_return_address (pc)
642 Set up the return address for the inferior function call.
643 Needed for targets where we don't actually execute a JSR/BSR instruction */
644
645 CORE_ADDR
646 mn10300_push_return_address (pc, sp)
647 CORE_ADDR pc;
648 CORE_ADDR sp;
649 {
650 unsigned char buf[4];
651
652 store_unsigned_integer (buf, 4, CALL_DUMMY_ADDRESS ());
653 write_memory (sp - 4, buf, 4);
654 return sp - 4;
655 }
656
657 /* Function: store_struct_return (addr,sp)
658 Store the structure value return address for an inferior function
659 call. */
660
661 CORE_ADDR
662 mn10300_store_struct_return (addr, sp)
663 CORE_ADDR addr;
664 CORE_ADDR sp;
665 {
666 /* The structure return address is passed as the first argument. */
667 write_register (0, addr);
668 return sp;
669 }
670
671 /* Function: frame_saved_pc
672 Find the caller of this frame. We do this by seeing if RP_REGNUM
673 is saved in the stack anywhere, otherwise we get it from the
674 registers. If the inner frame is a dummy frame, return its PC
675 instead of RP, because that's where "caller" of the dummy-frame
676 will be found. */
677
678 CORE_ADDR
679 mn10300_frame_saved_pc (fi)
680 struct frame_info *fi;
681 {
682 int adjust = 0;
683
684 adjust += (fi->fsr.regs[D2_REGNUM] ? 4 : 0);
685 adjust += (fi->fsr.regs[D3_REGNUM] ? 4 : 0);
686 adjust += (fi->fsr.regs[A2_REGNUM] ? 4 : 0);
687 adjust += (fi->fsr.regs[A3_REGNUM] ? 4 : 0);
688 /* start-sanitize-am33 */
689 if (am33_mode)
690 {
691 adjust += (fi->fsr.regs[E0_REGNUM+5] ? 4 : 0);
692 adjust += (fi->fsr.regs[E0_REGNUM+4] ? 4 : 0);
693 adjust += (fi->fsr.regs[E0_REGNUM+3] ? 4 : 0);
694 adjust += (fi->fsr.regs[E0_REGNUM+2] ? 4 : 0);
695 }
696 /* end-sanitize-am33 */
697
698 return (read_memory_integer (fi->frame + adjust, REGISTER_SIZE));
699 }
700
701 void
702 get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval)
703 char *raw_buffer;
704 int *optimized;
705 CORE_ADDR *addrp;
706 struct frame_info *frame;
707 int regnum;
708 enum lval_type *lval;
709 {
710 generic_get_saved_register (raw_buffer, optimized, addrp,
711 frame, regnum, lval);
712 }
713
714 /* Function: init_extra_frame_info
715 Setup the frame's frame pointer, pc, and frame addresses for saved
716 registers. Most of the work is done in mn10300_analyze_prologue().
717
718 Note that when we are called for the last frame (currently active frame),
719 that fi->pc and fi->frame will already be setup. However, fi->frame will
720 be valid only if this routine uses FP. For previous frames, fi-frame will
721 always be correct. mn10300_analyze_prologue will fix fi->frame if
722 it's not valid.
723
724 We can be called with the PC in the call dummy under two circumstances.
725 First, during normal backtracing, second, while figuring out the frame
726 pointer just prior to calling the target function (see run_stack_dummy). */
727
728 void
729 mn10300_init_extra_frame_info (fi)
730 struct frame_info *fi;
731 {
732 if (fi->next)
733 fi->pc = FRAME_SAVED_PC (fi->next);
734
735 memset (fi->fsr.regs, '\000', sizeof fi->fsr.regs);
736 fi->status = 0;
737 fi->stack_size = 0;
738
739 mn10300_analyze_prologue (fi, 0);
740 }
741
742 /* This can be made more generic later. */
743 static void
744 set_machine_hook (filename)
745 char *filename;
746 {
747 int i;
748
749 if (bfd_get_mach (exec_bfd) == bfd_mach_mn10300
750 || bfd_get_mach (exec_bfd) == 0)
751 {
752 for (i = 0; i < NUM_REGS; i++)
753 reg_names[i] = mn10300_generic_register_names[i];
754 }
755
756 /* start-sanitize-am33 */
757 am33_mode = 0;
758 if (bfd_get_mach (exec_bfd) == bfd_mach_am33)
759 {
760 for (i = 0; i < NUM_REGS; i++)
761 reg_names[i] = am33_register_names[i];
762 am33_mode = 1;
763 }
764 /* end-sanitize-am33 */
765 }
766
767 void
768 _initialize_mn10300_tdep ()
769 {
770 /* printf("_initialize_mn10300_tdep\n"); */
771
772 tm_print_insn = print_insn_mn10300;
773
774 specify_exec_file_hook (set_machine_hook);
775 }
776
This page took 0.055398 seconds and 4 git commands to generate.