Automatic date update in version.in
[binutils-gdb.git] / gdb / mn10300-tdep.c
blobcd70f8adb68de09ef6817e378817e6f81c62e843
1 /* Target-dependent code for the Matsushita MN10300 for GDB, the GNU debugger.
3 Copyright (C) 1996-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "arch-utils.h"
21 #include "dis-asm.h"
22 #include "gdbtypes.h"
23 #include "regcache.h"
24 #include "gdbcore.h"
25 #include "value.h"
26 #include "frame.h"
27 #include "frame-unwind.h"
28 #include "frame-base.h"
29 #include "symtab.h"
30 #include "dwarf2/frame.h"
31 #include "osabi.h"
32 #include "infcall.h"
33 #include "prologue-value.h"
34 #include "target.h"
36 #include "mn10300-tdep.h"
39 /* The am33-2 has 64 registers. */
40 #define MN10300_MAX_NUM_REGS 64
42 /* Big enough to hold the size of the largest register in bytes. */
43 #define MN10300_MAX_REGISTER_SIZE 64
45 /* This structure holds the results of a prologue analysis. */
46 struct mn10300_prologue
48 /* The architecture for which we generated this prologue info. */
49 struct gdbarch *gdbarch;
51 /* The offset from the frame base to the stack pointer --- always
52 zero or negative.
54 Calling this a "size" is a bit misleading, but given that the
55 stack grows downwards, using offsets for everything keeps one
56 from going completely sign-crazy: you never change anything's
57 sign for an ADD instruction; always change the second operand's
58 sign for a SUB instruction; and everything takes care of
59 itself. */
60 int frame_size;
62 /* Non-zero if this function has initialized the frame pointer from
63 the stack pointer, zero otherwise. */
64 int has_frame_ptr;
66 /* If has_frame_ptr is non-zero, this is the offset from the frame
67 base to where the frame pointer points. This is always zero or
68 negative. */
69 int frame_ptr_offset;
71 /* The address of the first instruction at which the frame has been
72 set up and the arguments are where the debug info says they are
73 --- as best as we can tell. */
74 CORE_ADDR prologue_end;
76 /* reg_offset[R] is the offset from the CFA at which register R is
77 saved, or 1 if register R has not been saved. (Real values are
78 always zero or negative.) */
79 int reg_offset[MN10300_MAX_NUM_REGS];
83 /* Compute the alignment required by a type. */
85 static int
86 mn10300_type_align (struct type *type)
88 int i, align = 1;
90 switch (type->code ())
92 case TYPE_CODE_INT:
93 case TYPE_CODE_ENUM:
94 case TYPE_CODE_SET:
95 case TYPE_CODE_RANGE:
96 case TYPE_CODE_CHAR:
97 case TYPE_CODE_BOOL:
98 case TYPE_CODE_FLT:
99 case TYPE_CODE_PTR:
100 case TYPE_CODE_REF:
101 case TYPE_CODE_RVALUE_REF:
102 return type->length ();
104 case TYPE_CODE_COMPLEX:
105 return type->length () / 2;
107 case TYPE_CODE_STRUCT:
108 case TYPE_CODE_UNION:
109 for (i = 0; i < type->num_fields (); i++)
111 int falign = mn10300_type_align (type->field (i).type ());
112 while (align < falign)
113 align <<= 1;
115 return align;
117 case TYPE_CODE_ARRAY:
118 /* HACK! Structures containing arrays, even small ones, are not
119 eligible for returning in registers. */
120 return 256;
122 case TYPE_CODE_TYPEDEF:
123 return mn10300_type_align (check_typedef (type));
125 default:
126 internal_error (_("bad switch"));
130 /* Should call_function allocate stack space for a struct return? */
131 static int
132 mn10300_use_struct_convention (struct type *type)
134 /* Structures bigger than a pair of words can't be returned in
135 registers. */
136 if (type->length () > 8)
137 return 1;
139 switch (type->code ())
141 case TYPE_CODE_STRUCT:
142 case TYPE_CODE_UNION:
143 /* Structures with a single field are handled as the field
144 itself. */
145 if (type->num_fields () == 1)
146 return mn10300_use_struct_convention (type->field (0).type ());
148 /* Structures with word or double-word size are passed in memory, as
149 long as they require at least word alignment. */
150 if (mn10300_type_align (type) >= 4)
151 return 0;
153 return 1;
155 /* Arrays are addressable, so they're never returned in
156 registers. This condition can only hold when the array is
157 the only field of a struct or union. */
158 case TYPE_CODE_ARRAY:
159 return 1;
161 case TYPE_CODE_TYPEDEF:
162 return mn10300_use_struct_convention (check_typedef (type));
164 default:
165 return 0;
169 static void
170 mn10300_store_return_value (struct gdbarch *gdbarch, struct type *type,
171 struct regcache *regcache, const gdb_byte *valbuf)
173 int len = type->length ();
174 int reg, regsz;
176 if (type->code () == TYPE_CODE_PTR)
177 reg = 4;
178 else
179 reg = 0;
181 regsz = register_size (gdbarch, reg);
183 if (len <= regsz)
184 regcache->raw_write_part (reg, 0, len, valbuf);
185 else if (len <= 2 * regsz)
187 regcache->raw_write (reg, valbuf);
188 gdb_assert (regsz == register_size (gdbarch, reg + 1));
189 regcache->raw_write_part (reg + 1, 0, len - regsz, valbuf + regsz);
191 else
192 internal_error (_("Cannot store return value %d bytes long."), len);
195 static void
196 mn10300_extract_return_value (struct gdbarch *gdbarch, struct type *type,
197 struct regcache *regcache, void *valbuf)
199 gdb_byte buf[MN10300_MAX_REGISTER_SIZE];
200 int len = type->length ();
201 int reg, regsz;
203 if (type->code () == TYPE_CODE_PTR)
204 reg = 4;
205 else
206 reg = 0;
208 regsz = register_size (gdbarch, reg);
209 gdb_assert (regsz <= MN10300_MAX_REGISTER_SIZE);
210 if (len <= regsz)
212 regcache->raw_read (reg, buf);
213 memcpy (valbuf, buf, len);
215 else if (len <= 2 * regsz)
217 regcache->raw_read (reg, buf);
218 memcpy (valbuf, buf, regsz);
219 gdb_assert (regsz == register_size (gdbarch, reg + 1));
220 regcache->raw_read (reg + 1, buf);
221 memcpy ((char *) valbuf + regsz, buf, len - regsz);
223 else
224 internal_error (_("Cannot extract return value %d bytes long."), len);
227 /* Determine, for architecture GDBARCH, how a return value of TYPE
228 should be returned. If it is supposed to be returned in registers,
229 and READBUF is non-zero, read the appropriate value from REGCACHE,
230 and copy it into READBUF. If WRITEBUF is non-zero, write the value
231 from WRITEBUF into REGCACHE. */
233 static enum return_value_convention
234 mn10300_return_value (struct gdbarch *gdbarch, struct value *function,
235 struct type *type, struct regcache *regcache,
236 gdb_byte *readbuf, const gdb_byte *writebuf)
238 if (mn10300_use_struct_convention (type))
239 return RETURN_VALUE_STRUCT_CONVENTION;
241 if (readbuf)
242 mn10300_extract_return_value (gdbarch, type, regcache, readbuf);
243 if (writebuf)
244 mn10300_store_return_value (gdbarch, type, regcache, writebuf);
246 return RETURN_VALUE_REGISTER_CONVENTION;
249 static const char *
250 register_name (int reg, const char **regs, long num_regs)
252 gdb_assert (reg < num_regs);
253 return regs[reg];
256 static const char *
257 mn10300_generic_register_name (struct gdbarch *gdbarch, int reg)
259 static const char *regs[] =
260 { "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3",
261 "sp", "pc", "mdr", "psw", "lir", "lar", "", "",
262 "", "", "", "", "", "", "", "",
263 "", "", "", "", "", "", "", "fp"
265 return register_name (reg, regs, ARRAY_SIZE (regs));
269 static const char *
270 am33_register_name (struct gdbarch *gdbarch, int reg)
272 static const char *regs[] =
273 { "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3",
274 "sp", "pc", "mdr", "psw", "lir", "lar", "",
275 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
276 "ssp", "msp", "usp", "mcrh", "mcrl", "mcvf", "", "", ""
278 return register_name (reg, regs, ARRAY_SIZE (regs));
281 static const char *
282 am33_2_register_name (struct gdbarch *gdbarch, int reg)
284 static const char *regs[] =
286 "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3",
287 "sp", "pc", "mdr", "psw", "lir", "lar", "mdrq", "r0",
288 "r1", "r2", "r3", "r4", "r5", "r6", "r7", "ssp",
289 "msp", "usp", "mcrh", "mcrl", "mcvf", "fpcr", "", "",
290 "fs0", "fs1", "fs2", "fs3", "fs4", "fs5", "fs6", "fs7",
291 "fs8", "fs9", "fs10", "fs11", "fs12", "fs13", "fs14", "fs15",
292 "fs16", "fs17", "fs18", "fs19", "fs20", "fs21", "fs22", "fs23",
293 "fs24", "fs25", "fs26", "fs27", "fs28", "fs29", "fs30", "fs31"
295 return register_name (reg, regs, ARRAY_SIZE (regs));
298 static struct type *
299 mn10300_register_type (struct gdbarch *gdbarch, int reg)
301 return builtin_type (gdbarch)->builtin_int;
304 /* The breakpoint instruction must be the same size as the smallest
305 instruction in the instruction set.
307 The Matsushita mn10x00 processors have single byte instructions
308 so we need a single byte breakpoint. Matsushita hasn't defined
309 one, so we defined it ourselves. */
310 constexpr gdb_byte mn10300_break_insn[] = {0xff};
312 typedef BP_MANIPULATION (mn10300_break_insn) mn10300_breakpoint;
314 /* Model the semantics of pushing a register onto the stack. This
315 is a helper function for mn10300_analyze_prologue, below. */
316 static void
317 push_reg (pv_t *regs, struct pv_area *stack, int regnum)
319 regs[E_SP_REGNUM] = pv_add_constant (regs[E_SP_REGNUM], -4);
320 stack->store (regs[E_SP_REGNUM], 4, regs[regnum]);
323 /* Translate an "r" register number extracted from an instruction encoding
324 into a GDB register number. Adapted from a simulator function
325 of the same name; see am33.igen. */
326 static int
327 translate_rreg (int rreg)
329 /* The higher register numbers actually correspond to the
330 basic machine's address and data registers. */
331 if (rreg > 7 && rreg < 12)
332 return E_A0_REGNUM + rreg - 8;
333 else if (rreg > 11 && rreg < 16)
334 return E_D0_REGNUM + rreg - 12;
335 else
336 return E_E0_REGNUM + rreg;
339 /* Find saved registers in a 'struct pv_area'; we pass this to pv_area::scan.
341 If VALUE is a saved register, ADDR says it was saved at a constant
342 offset from the frame base, and SIZE indicates that the whole
343 register was saved, record its offset in RESULT_UNTYPED. */
344 static void
345 check_for_saved (void *result_untyped, pv_t addr, CORE_ADDR size, pv_t value)
347 struct mn10300_prologue *result = (struct mn10300_prologue *) result_untyped;
349 if (value.kind == pvk_register
350 && value.k == 0
351 && pv_is_register (addr, E_SP_REGNUM)
352 && size == register_size (result->gdbarch, value.reg))
353 result->reg_offset[value.reg] = addr.k;
356 /* Analyze the prologue to determine where registers are saved,
357 the end of the prologue, etc. The result of this analysis is
358 returned in RESULT. See struct mn10300_prologue above for more
359 information. */
360 static void
361 mn10300_analyze_prologue (struct gdbarch *gdbarch,
362 CORE_ADDR start_pc, CORE_ADDR limit_pc,
363 struct mn10300_prologue *result)
365 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
366 CORE_ADDR pc;
367 int rn;
368 pv_t regs[MN10300_MAX_NUM_REGS];
369 CORE_ADDR after_last_frame_setup_insn = start_pc;
370 int am33_mode = get_am33_mode (gdbarch);
372 memset (result, 0, sizeof (*result));
373 result->gdbarch = gdbarch;
375 for (rn = 0; rn < MN10300_MAX_NUM_REGS; rn++)
377 regs[rn] = pv_register (rn, 0);
378 result->reg_offset[rn] = 1;
380 pv_area stack (E_SP_REGNUM, gdbarch_addr_bit (gdbarch));
382 /* The typical call instruction will have saved the return address on the
383 stack. Space for the return address has already been preallocated in
384 the caller's frame. It's possible, such as when using -mrelax with gcc
385 that other registers were saved as well. If this happens, we really
386 have no chance of deciphering the frame. DWARF info can save the day
387 when this happens. */
388 stack.store (regs[E_SP_REGNUM], 4, regs[E_PC_REGNUM]);
390 pc = start_pc;
391 while (pc < limit_pc)
393 int status;
394 gdb_byte instr[2];
396 /* Instructions can be as small as one byte; however, we usually
397 need at least two bytes to do the decoding, so fetch that many
398 to begin with. */
399 status = target_read_memory (pc, instr, 2);
400 if (status != 0)
401 break;
403 /* movm [regs], sp */
404 if (instr[0] == 0xcf)
406 gdb_byte save_mask;
408 save_mask = instr[1];
410 if ((save_mask & movm_exreg0_bit) && am33_mode)
412 push_reg (regs, &stack, E_E2_REGNUM);
413 push_reg (regs, &stack, E_E3_REGNUM);
415 if ((save_mask & movm_exreg1_bit) && am33_mode)
417 push_reg (regs, &stack, E_E4_REGNUM);
418 push_reg (regs, &stack, E_E5_REGNUM);
419 push_reg (regs, &stack, E_E6_REGNUM);
420 push_reg (regs, &stack, E_E7_REGNUM);
422 if ((save_mask & movm_exother_bit) && am33_mode)
424 push_reg (regs, &stack, E_E0_REGNUM);
425 push_reg (regs, &stack, E_E1_REGNUM);
426 push_reg (regs, &stack, E_MDRQ_REGNUM);
427 push_reg (regs, &stack, E_MCRH_REGNUM);
428 push_reg (regs, &stack, E_MCRL_REGNUM);
429 push_reg (regs, &stack, E_MCVF_REGNUM);
431 if (save_mask & movm_d2_bit)
432 push_reg (regs, &stack, E_D2_REGNUM);
433 if (save_mask & movm_d3_bit)
434 push_reg (regs, &stack, E_D3_REGNUM);
435 if (save_mask & movm_a2_bit)
436 push_reg (regs, &stack, E_A2_REGNUM);
437 if (save_mask & movm_a3_bit)
438 push_reg (regs, &stack, E_A3_REGNUM);
439 if (save_mask & movm_other_bit)
441 push_reg (regs, &stack, E_D0_REGNUM);
442 push_reg (regs, &stack, E_D1_REGNUM);
443 push_reg (regs, &stack, E_A0_REGNUM);
444 push_reg (regs, &stack, E_A1_REGNUM);
445 push_reg (regs, &stack, E_MDR_REGNUM);
446 push_reg (regs, &stack, E_LIR_REGNUM);
447 push_reg (regs, &stack, E_LAR_REGNUM);
448 /* The `other' bit leaves a blank area of four bytes at
449 the beginning of its block of saved registers, making
450 it 32 bytes long in total. */
451 regs[E_SP_REGNUM] = pv_add_constant (regs[E_SP_REGNUM], -4);
454 pc += 2;
455 after_last_frame_setup_insn = pc;
457 /* mov sp, aN */
458 else if ((instr[0] & 0xfc) == 0x3c)
460 int aN = instr[0] & 0x03;
462 regs[E_A0_REGNUM + aN] = regs[E_SP_REGNUM];
464 pc += 1;
465 if (aN == 3)
466 after_last_frame_setup_insn = pc;
468 /* mov aM, aN */
469 else if ((instr[0] & 0xf0) == 0x90
470 && (instr[0] & 0x03) != ((instr[0] & 0x0c) >> 2))
472 int aN = instr[0] & 0x03;
473 int aM = (instr[0] & 0x0c) >> 2;
475 regs[E_A0_REGNUM + aN] = regs[E_A0_REGNUM + aM];
477 pc += 1;
479 /* mov dM, dN */
480 else if ((instr[0] & 0xf0) == 0x80
481 && (instr[0] & 0x03) != ((instr[0] & 0x0c) >> 2))
483 int dN = instr[0] & 0x03;
484 int dM = (instr[0] & 0x0c) >> 2;
486 regs[E_D0_REGNUM + dN] = regs[E_D0_REGNUM + dM];
488 pc += 1;
490 /* mov aM, dN */
491 else if (instr[0] == 0xf1 && (instr[1] & 0xf0) == 0xd0)
493 int dN = instr[1] & 0x03;
494 int aM = (instr[1] & 0x0c) >> 2;
496 regs[E_D0_REGNUM + dN] = regs[E_A0_REGNUM + aM];
498 pc += 2;
500 /* mov dM, aN */
501 else if (instr[0] == 0xf1 && (instr[1] & 0xf0) == 0xe0)
503 int aN = instr[1] & 0x03;
504 int dM = (instr[1] & 0x0c) >> 2;
506 regs[E_A0_REGNUM + aN] = regs[E_D0_REGNUM + dM];
508 pc += 2;
510 /* add imm8, SP */
511 else if (instr[0] == 0xf8 && instr[1] == 0xfe)
513 gdb_byte buf[1];
514 LONGEST imm8;
517 status = target_read_memory (pc + 2, buf, 1);
518 if (status != 0)
519 break;
521 imm8 = extract_signed_integer (buf, 1, byte_order);
522 regs[E_SP_REGNUM] = pv_add_constant (regs[E_SP_REGNUM], imm8);
524 pc += 3;
525 /* Stack pointer adjustments are frame related. */
526 after_last_frame_setup_insn = pc;
528 /* add imm16, SP */
529 else if (instr[0] == 0xfa && instr[1] == 0xfe)
531 gdb_byte buf[2];
532 LONGEST imm16;
534 status = target_read_memory (pc + 2, buf, 2);
535 if (status != 0)
536 break;
538 imm16 = extract_signed_integer (buf, 2, byte_order);
539 regs[E_SP_REGNUM] = pv_add_constant (regs[E_SP_REGNUM], imm16);
541 pc += 4;
542 /* Stack pointer adjustments are frame related. */
543 after_last_frame_setup_insn = pc;
545 /* add imm32, SP */
546 else if (instr[0] == 0xfc && instr[1] == 0xfe)
548 gdb_byte buf[4];
549 LONGEST imm32;
551 status = target_read_memory (pc + 2, buf, 4);
552 if (status != 0)
553 break;
556 imm32 = extract_signed_integer (buf, 4, byte_order);
557 regs[E_SP_REGNUM] = pv_add_constant (regs[E_SP_REGNUM], imm32);
559 pc += 6;
560 /* Stack pointer adjustments are frame related. */
561 after_last_frame_setup_insn = pc;
563 /* add imm8, aN */
564 else if ((instr[0] & 0xfc) == 0x20)
566 int aN;
567 LONGEST imm8;
569 aN = instr[0] & 0x03;
570 imm8 = extract_signed_integer (&instr[1], 1, byte_order);
572 regs[E_A0_REGNUM + aN] = pv_add_constant (regs[E_A0_REGNUM + aN],
573 imm8);
575 pc += 2;
577 /* add imm16, aN */
578 else if (instr[0] == 0xfa && (instr[1] & 0xfc) == 0xd0)
580 int aN;
581 LONGEST imm16;
582 gdb_byte buf[2];
584 aN = instr[1] & 0x03;
586 status = target_read_memory (pc + 2, buf, 2);
587 if (status != 0)
588 break;
591 imm16 = extract_signed_integer (buf, 2, byte_order);
593 regs[E_A0_REGNUM + aN] = pv_add_constant (regs[E_A0_REGNUM + aN],
594 imm16);
596 pc += 4;
598 /* add imm32, aN */
599 else if (instr[0] == 0xfc && (instr[1] & 0xfc) == 0xd0)
601 int aN;
602 LONGEST imm32;
603 gdb_byte buf[4];
605 aN = instr[1] & 0x03;
607 status = target_read_memory (pc + 2, buf, 4);
608 if (status != 0)
609 break;
611 imm32 = extract_signed_integer (buf, 2, byte_order);
613 regs[E_A0_REGNUM + aN] = pv_add_constant (regs[E_A0_REGNUM + aN],
614 imm32);
615 pc += 6;
617 /* fmov fsM, (rN) */
618 else if (instr[0] == 0xf9 && (instr[1] & 0xfd) == 0x30)
620 int fsM, sM, Y, rN;
621 gdb_byte buf[1];
623 Y = (instr[1] & 0x02) >> 1;
625 status = target_read_memory (pc + 2, buf, 1);
626 if (status != 0)
627 break;
629 sM = (buf[0] & 0xf0) >> 4;
630 rN = buf[0] & 0x0f;
631 fsM = (Y << 4) | sM;
633 stack.store (regs[translate_rreg (rN)], 4,
634 regs[E_FS0_REGNUM + fsM]);
636 pc += 3;
638 /* fmov fsM, (sp) */
639 else if (instr[0] == 0xf9 && (instr[1] & 0xfd) == 0x34)
641 int fsM, sM, Y;
642 gdb_byte buf[1];
644 Y = (instr[1] & 0x02) >> 1;
646 status = target_read_memory (pc + 2, buf, 1);
647 if (status != 0)
648 break;
650 sM = (buf[0] & 0xf0) >> 4;
651 fsM = (Y << 4) | sM;
653 stack.store (regs[E_SP_REGNUM], 4,
654 regs[E_FS0_REGNUM + fsM]);
656 pc += 3;
658 /* fmov fsM, (rN, rI) */
659 else if (instr[0] == 0xfb && instr[1] == 0x37)
661 int fsM, sM, Z, rN, rI;
662 gdb_byte buf[2];
665 status = target_read_memory (pc + 2, buf, 2);
666 if (status != 0)
667 break;
669 rI = (buf[0] & 0xf0) >> 4;
670 rN = buf[0] & 0x0f;
671 sM = (buf[1] & 0xf0) >> 4;
672 Z = (buf[1] & 0x02) >> 1;
673 fsM = (Z << 4) | sM;
675 stack.store (pv_add (regs[translate_rreg (rN)],
676 regs[translate_rreg (rI)]),
677 4, regs[E_FS0_REGNUM + fsM]);
679 pc += 4;
681 /* fmov fsM, (d8, rN) */
682 else if (instr[0] == 0xfb && (instr[1] & 0xfd) == 0x30)
684 int fsM, sM, Y, rN;
685 LONGEST d8;
686 gdb_byte buf[2];
688 Y = (instr[1] & 0x02) >> 1;
690 status = target_read_memory (pc + 2, buf, 2);
691 if (status != 0)
692 break;
694 sM = (buf[0] & 0xf0) >> 4;
695 rN = buf[0] & 0x0f;
696 fsM = (Y << 4) | sM;
697 d8 = extract_signed_integer (&buf[1], 1, byte_order);
699 stack.store (pv_add_constant (regs[translate_rreg (rN)], d8),
700 4, regs[E_FS0_REGNUM + fsM]);
702 pc += 4;
704 /* fmov fsM, (d24, rN) */
705 else if (instr[0] == 0xfd && (instr[1] & 0xfd) == 0x30)
707 int fsM, sM, Y, rN;
708 LONGEST d24;
709 gdb_byte buf[4];
711 Y = (instr[1] & 0x02) >> 1;
713 status = target_read_memory (pc + 2, buf, 4);
714 if (status != 0)
715 break;
717 sM = (buf[0] & 0xf0) >> 4;
718 rN = buf[0] & 0x0f;
719 fsM = (Y << 4) | sM;
720 d24 = extract_signed_integer (&buf[1], 3, byte_order);
722 stack.store (pv_add_constant (regs[translate_rreg (rN)], d24),
723 4, regs[E_FS0_REGNUM + fsM]);
725 pc += 6;
727 /* fmov fsM, (d32, rN) */
728 else if (instr[0] == 0xfe && (instr[1] & 0xfd) == 0x30)
730 int fsM, sM, Y, rN;
731 LONGEST d32;
732 gdb_byte buf[5];
734 Y = (instr[1] & 0x02) >> 1;
736 status = target_read_memory (pc + 2, buf, 5);
737 if (status != 0)
738 break;
740 sM = (buf[0] & 0xf0) >> 4;
741 rN = buf[0] & 0x0f;
742 fsM = (Y << 4) | sM;
743 d32 = extract_signed_integer (&buf[1], 4, byte_order);
745 stack.store (pv_add_constant (regs[translate_rreg (rN)], d32),
746 4, regs[E_FS0_REGNUM + fsM]);
748 pc += 7;
750 /* fmov fsM, (d8, SP) */
751 else if (instr[0] == 0xfb && (instr[1] & 0xfd) == 0x34)
753 int fsM, sM, Y;
754 LONGEST d8;
755 gdb_byte buf[2];
757 Y = (instr[1] & 0x02) >> 1;
759 status = target_read_memory (pc + 2, buf, 2);
760 if (status != 0)
761 break;
763 sM = (buf[0] & 0xf0) >> 4;
764 fsM = (Y << 4) | sM;
765 d8 = extract_signed_integer (&buf[1], 1, byte_order);
767 stack.store (pv_add_constant (regs[E_SP_REGNUM], d8),
768 4, regs[E_FS0_REGNUM + fsM]);
770 pc += 4;
772 /* fmov fsM, (d24, SP) */
773 else if (instr[0] == 0xfd && (instr[1] & 0xfd) == 0x34)
775 int fsM, sM, Y;
776 LONGEST d24;
777 gdb_byte buf[4];
779 Y = (instr[1] & 0x02) >> 1;
781 status = target_read_memory (pc + 2, buf, 4);
782 if (status != 0)
783 break;
785 sM = (buf[0] & 0xf0) >> 4;
786 fsM = (Y << 4) | sM;
787 d24 = extract_signed_integer (&buf[1], 3, byte_order);
789 stack.store (pv_add_constant (regs[E_SP_REGNUM], d24),
790 4, regs[E_FS0_REGNUM + fsM]);
792 pc += 6;
794 /* fmov fsM, (d32, SP) */
795 else if (instr[0] == 0xfe && (instr[1] & 0xfd) == 0x34)
797 int fsM, sM, Y;
798 LONGEST d32;
799 gdb_byte buf[5];
801 Y = (instr[1] & 0x02) >> 1;
803 status = target_read_memory (pc + 2, buf, 5);
804 if (status != 0)
805 break;
807 sM = (buf[0] & 0xf0) >> 4;
808 fsM = (Y << 4) | sM;
809 d32 = extract_signed_integer (&buf[1], 4, byte_order);
811 stack.store (pv_add_constant (regs[E_SP_REGNUM], d32),
812 4, regs[E_FS0_REGNUM + fsM]);
814 pc += 7;
816 /* fmov fsM, (rN+) */
817 else if (instr[0] == 0xf9 && (instr[1] & 0xfd) == 0x31)
819 int fsM, sM, Y, rN, rN_regnum;
820 gdb_byte buf[1];
822 Y = (instr[1] & 0x02) >> 1;
824 status = target_read_memory (pc + 2, buf, 1);
825 if (status != 0)
826 break;
828 sM = (buf[0] & 0xf0) >> 4;
829 rN = buf[0] & 0x0f;
830 fsM = (Y << 4) | sM;
832 rN_regnum = translate_rreg (rN);
834 stack.store (regs[rN_regnum], 4,
835 regs[E_FS0_REGNUM + fsM]);
836 regs[rN_regnum] = pv_add_constant (regs[rN_regnum], 4);
838 pc += 3;
840 /* fmov fsM, (rN+, imm8) */
841 else if (instr[0] == 0xfb && (instr[1] & 0xfd) == 0x31)
843 int fsM, sM, Y, rN, rN_regnum;
844 LONGEST imm8;
845 gdb_byte buf[2];
847 Y = (instr[1] & 0x02) >> 1;
849 status = target_read_memory (pc + 2, buf, 2);
850 if (status != 0)
851 break;
853 sM = (buf[0] & 0xf0) >> 4;
854 rN = buf[0] & 0x0f;
855 fsM = (Y << 4) | sM;
856 imm8 = extract_signed_integer (&buf[1], 1, byte_order);
858 rN_regnum = translate_rreg (rN);
860 stack.store (regs[rN_regnum], 4, regs[E_FS0_REGNUM + fsM]);
861 regs[rN_regnum] = pv_add_constant (regs[rN_regnum], imm8);
863 pc += 4;
865 /* fmov fsM, (rN+, imm24) */
866 else if (instr[0] == 0xfd && (instr[1] & 0xfd) == 0x31)
868 int fsM, sM, Y, rN, rN_regnum;
869 LONGEST imm24;
870 gdb_byte buf[4];
872 Y = (instr[1] & 0x02) >> 1;
874 status = target_read_memory (pc + 2, buf, 4);
875 if (status != 0)
876 break;
878 sM = (buf[0] & 0xf0) >> 4;
879 rN = buf[0] & 0x0f;
880 fsM = (Y << 4) | sM;
881 imm24 = extract_signed_integer (&buf[1], 3, byte_order);
883 rN_regnum = translate_rreg (rN);
885 stack.store (regs[rN_regnum], 4, regs[E_FS0_REGNUM + fsM]);
886 regs[rN_regnum] = pv_add_constant (regs[rN_regnum], imm24);
888 pc += 6;
890 /* fmov fsM, (rN+, imm32) */
891 else if (instr[0] == 0xfe && (instr[1] & 0xfd) == 0x31)
893 int fsM, sM, Y, rN, rN_regnum;
894 LONGEST imm32;
895 gdb_byte buf[5];
897 Y = (instr[1] & 0x02) >> 1;
899 status = target_read_memory (pc + 2, buf, 5);
900 if (status != 0)
901 break;
903 sM = (buf[0] & 0xf0) >> 4;
904 rN = buf[0] & 0x0f;
905 fsM = (Y << 4) | sM;
906 imm32 = extract_signed_integer (&buf[1], 4, byte_order);
908 rN_regnum = translate_rreg (rN);
910 stack.store (regs[rN_regnum], 4, regs[E_FS0_REGNUM + fsM]);
911 regs[rN_regnum] = pv_add_constant (regs[rN_regnum], imm32);
913 pc += 7;
915 /* mov imm8, aN */
916 else if ((instr[0] & 0xf0) == 0x90)
918 int aN = instr[0] & 0x03;
919 LONGEST imm8;
921 imm8 = extract_signed_integer (&instr[1], 1, byte_order);
923 regs[E_A0_REGNUM + aN] = pv_constant (imm8);
924 pc += 2;
926 /* mov imm16, aN */
927 else if ((instr[0] & 0xfc) == 0x24)
929 int aN = instr[0] & 0x03;
930 gdb_byte buf[2];
931 LONGEST imm16;
933 status = target_read_memory (pc + 1, buf, 2);
934 if (status != 0)
935 break;
937 imm16 = extract_signed_integer (buf, 2, byte_order);
938 regs[E_A0_REGNUM + aN] = pv_constant (imm16);
939 pc += 3;
941 /* mov imm32, aN */
942 else if (instr[0] == 0xfc && ((instr[1] & 0xfc) == 0xdc))
944 int aN = instr[1] & 0x03;
945 gdb_byte buf[4];
946 LONGEST imm32;
948 status = target_read_memory (pc + 2, buf, 4);
949 if (status != 0)
950 break;
952 imm32 = extract_signed_integer (buf, 4, byte_order);
953 regs[E_A0_REGNUM + aN] = pv_constant (imm32);
954 pc += 6;
956 /* mov imm8, dN */
957 else if ((instr[0] & 0xf0) == 0x80)
959 int dN = instr[0] & 0x03;
960 LONGEST imm8;
962 imm8 = extract_signed_integer (&instr[1], 1, byte_order);
964 regs[E_D0_REGNUM + dN] = pv_constant (imm8);
965 pc += 2;
967 /* mov imm16, dN */
968 else if ((instr[0] & 0xfc) == 0x2c)
970 int dN = instr[0] & 0x03;
971 gdb_byte buf[2];
972 LONGEST imm16;
974 status = target_read_memory (pc + 1, buf, 2);
975 if (status != 0)
976 break;
978 imm16 = extract_signed_integer (buf, 2, byte_order);
979 regs[E_D0_REGNUM + dN] = pv_constant (imm16);
980 pc += 3;
982 /* mov imm32, dN */
983 else if (instr[0] == 0xfc && ((instr[1] & 0xfc) == 0xcc))
985 int dN = instr[1] & 0x03;
986 gdb_byte buf[4];
987 LONGEST imm32;
989 status = target_read_memory (pc + 2, buf, 4);
990 if (status != 0)
991 break;
993 imm32 = extract_signed_integer (buf, 4, byte_order);
994 regs[E_D0_REGNUM + dN] = pv_constant (imm32);
995 pc += 6;
997 else
999 /* We've hit some instruction that we don't recognize. Hopefully,
1000 we have enough to do prologue analysis. */
1001 break;
1005 /* Is the frame size (offset, really) a known constant? */
1006 if (pv_is_register (regs[E_SP_REGNUM], E_SP_REGNUM))
1007 result->frame_size = regs[E_SP_REGNUM].k;
1009 /* Was the frame pointer initialized? */
1010 if (pv_is_register (regs[E_A3_REGNUM], E_SP_REGNUM))
1012 result->has_frame_ptr = 1;
1013 result->frame_ptr_offset = regs[E_A3_REGNUM].k;
1016 /* Record where all the registers were saved. */
1017 stack.scan (check_for_saved, (void *) result);
1019 result->prologue_end = after_last_frame_setup_insn;
1022 /* Function: skip_prologue
1023 Return the address of the first inst past the prologue of the function. */
1025 static CORE_ADDR
1026 mn10300_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
1028 const char *name;
1029 CORE_ADDR func_addr, func_end;
1030 struct mn10300_prologue p;
1032 /* Try to find the extent of the function that contains PC. */
1033 if (!find_pc_partial_function (pc, &name, &func_addr, &func_end))
1034 return pc;
1036 mn10300_analyze_prologue (gdbarch, pc, func_end, &p);
1037 return p.prologue_end;
1040 /* Wrapper for mn10300_analyze_prologue: find the function start;
1041 use the current frame PC as the limit, then
1042 invoke mn10300_analyze_prologue and return its result. */
1043 static struct mn10300_prologue *
1044 mn10300_analyze_frame_prologue (const frame_info_ptr &this_frame,
1045 void **this_prologue_cache)
1047 if (!*this_prologue_cache)
1049 CORE_ADDR func_start, stop_addr;
1051 *this_prologue_cache = FRAME_OBSTACK_ZALLOC (struct mn10300_prologue);
1053 func_start = get_frame_func (this_frame);
1054 stop_addr = get_frame_pc (this_frame);
1056 /* If we couldn't find any function containing the PC, then
1057 just initialize the prologue cache, but don't do anything. */
1058 if (!func_start)
1059 stop_addr = func_start;
1061 mn10300_analyze_prologue (get_frame_arch (this_frame),
1062 func_start, stop_addr,
1063 ((struct mn10300_prologue *)
1064 *this_prologue_cache));
1067 return (struct mn10300_prologue *) *this_prologue_cache;
1070 /* Given the next frame and a prologue cache, return this frame's
1071 base. */
1072 static CORE_ADDR
1073 mn10300_frame_base (const frame_info_ptr &this_frame, void **this_prologue_cache)
1075 struct mn10300_prologue *p
1076 = mn10300_analyze_frame_prologue (this_frame, this_prologue_cache);
1078 /* In functions that use alloca, the distance between the stack
1079 pointer and the frame base varies dynamically, so we can't use
1080 the SP plus static information like prologue analysis to find the
1081 frame base. However, such functions must have a frame pointer,
1082 to be able to restore the SP on exit. So whenever we do have a
1083 frame pointer, use that to find the base. */
1084 if (p->has_frame_ptr)
1086 CORE_ADDR fp = get_frame_register_unsigned (this_frame, E_A3_REGNUM);
1087 return fp - p->frame_ptr_offset;
1089 else
1091 CORE_ADDR sp = get_frame_register_unsigned (this_frame, E_SP_REGNUM);
1092 return sp - p->frame_size;
1096 static void
1097 mn10300_frame_this_id (const frame_info_ptr &this_frame,
1098 void **this_prologue_cache,
1099 struct frame_id *this_id)
1101 *this_id = frame_id_build (mn10300_frame_base (this_frame,
1102 this_prologue_cache),
1103 get_frame_func (this_frame));
1107 static struct value *
1108 mn10300_frame_prev_register (const frame_info_ptr &this_frame,
1109 void **this_prologue_cache, int regnum)
1111 struct mn10300_prologue *p
1112 = mn10300_analyze_frame_prologue (this_frame, this_prologue_cache);
1113 CORE_ADDR frame_base = mn10300_frame_base (this_frame, this_prologue_cache);
1115 if (regnum == E_SP_REGNUM)
1116 return frame_unwind_got_constant (this_frame, regnum, frame_base);
1118 /* If prologue analysis says we saved this register somewhere,
1119 return a description of the stack slot holding it. */
1120 if (p->reg_offset[regnum] != 1)
1121 return frame_unwind_got_memory (this_frame, regnum,
1122 frame_base + p->reg_offset[regnum]);
1124 /* Otherwise, presume we haven't changed the value of this
1125 register, and get it from the next frame. */
1126 return frame_unwind_got_register (this_frame, regnum, regnum);
1129 static const struct frame_unwind mn10300_frame_unwind = {
1130 "mn10300 prologue",
1131 NORMAL_FRAME,
1132 default_frame_unwind_stop_reason,
1133 mn10300_frame_this_id,
1134 mn10300_frame_prev_register,
1135 NULL,
1136 default_frame_sniffer
1139 static void
1140 mn10300_frame_unwind_init (struct gdbarch *gdbarch)
1142 dwarf2_append_unwinders (gdbarch);
1143 frame_unwind_append_unwinder (gdbarch, &mn10300_frame_unwind);
1146 /* Function: push_dummy_call
1148 * Set up machine state for a target call, including
1149 * function arguments, stack, return address, etc.
1153 static CORE_ADDR
1154 mn10300_push_dummy_call (struct gdbarch *gdbarch,
1155 struct value *target_func,
1156 struct regcache *regcache,
1157 CORE_ADDR bp_addr,
1158 int nargs, struct value **args,
1159 CORE_ADDR sp,
1160 function_call_return_method return_method,
1161 CORE_ADDR struct_addr)
1163 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1164 const int push_size = register_size (gdbarch, E_PC_REGNUM);
1165 int regs_used;
1166 int len, arg_len;
1167 int stack_offset = 0;
1168 int argnum;
1169 const gdb_byte *val;
1170 gdb_byte valbuf[MN10300_MAX_REGISTER_SIZE];
1172 /* This should be a nop, but align the stack just in case something
1173 went wrong. Stacks are four byte aligned on the mn10300. */
1174 sp &= ~3;
1176 /* Now make space on the stack for the args.
1178 XXX This doesn't appear to handle pass-by-invisible reference
1179 arguments. */
1180 regs_used = (return_method == return_method_struct) ? 1 : 0;
1181 for (len = 0, argnum = 0; argnum < nargs; argnum++)
1183 arg_len = (args[argnum]->type ()->length () + 3) & ~3;
1184 while (regs_used < 2 && arg_len > 0)
1186 regs_used++;
1187 arg_len -= push_size;
1189 len += arg_len;
1192 /* Allocate stack space. */
1193 sp -= len;
1195 if (return_method == return_method_struct)
1197 regs_used = 1;
1198 regcache_cooked_write_unsigned (regcache, E_D0_REGNUM, struct_addr);
1200 else
1201 regs_used = 0;
1203 /* Push all arguments onto the stack. */
1204 for (argnum = 0; argnum < nargs; argnum++)
1206 /* FIXME what about structs? Unions? */
1207 if ((*args)->type ()->code () == TYPE_CODE_STRUCT
1208 && (*args)->type ()->length () > 8)
1210 /* Change to pointer-to-type. */
1211 arg_len = push_size;
1212 gdb_assert (push_size <= MN10300_MAX_REGISTER_SIZE);
1213 store_unsigned_integer (valbuf, push_size, byte_order,
1214 (*args)->address ());
1215 val = &valbuf[0];
1217 else
1219 arg_len = (*args)->type ()->length ();
1220 val = (*args)->contents ().data ();
1223 while (regs_used < 2 && arg_len > 0)
1225 regcache_cooked_write_unsigned (regcache, regs_used,
1226 extract_unsigned_integer (val, push_size, byte_order));
1227 val += push_size;
1228 arg_len -= push_size;
1229 regs_used++;
1232 while (arg_len > 0)
1234 write_memory (sp + stack_offset, val, push_size);
1235 arg_len -= push_size;
1236 val += push_size;
1237 stack_offset += push_size;
1240 args++;
1243 /* Make space for the flushback area. */
1244 sp -= 8;
1246 /* Push the return address that contains the magic breakpoint. */
1247 sp -= 4;
1248 write_memory_unsigned_integer (sp, push_size, byte_order, bp_addr);
1250 /* The CPU also writes the return address always into the
1251 MDR register on "call". */
1252 regcache_cooked_write_unsigned (regcache, E_MDR_REGNUM, bp_addr);
1254 /* Update $sp. */
1255 regcache_cooked_write_unsigned (regcache, E_SP_REGNUM, sp);
1257 /* On the mn10300, it's possible to move some of the stack adjustment
1258 and saving of the caller-save registers out of the prologue and
1259 into the call sites. (When using gcc, this optimization can
1260 occur when using the -mrelax switch.) If this occurs, the dwarf2
1261 info will reflect this fact. We can test to see if this is the
1262 case by creating a new frame using the current stack pointer and
1263 the address of the function that we're about to call. We then
1264 unwind SP and see if it's different than the SP of our newly
1265 created frame. If the SP values are the same, the caller is not
1266 expected to allocate any additional stack. On the other hand, if
1267 the SP values are different, the difference determines the
1268 additional stack that must be allocated.
1270 Note that we don't update the return value though because that's
1271 the value of the stack just after pushing the arguments, but prior
1272 to performing the call. This value is needed in order to
1273 construct the frame ID of the dummy call. */
1275 CORE_ADDR func_addr = find_function_addr (target_func, NULL);
1276 CORE_ADDR unwound_sp
1277 = gdbarch_unwind_sp (gdbarch, create_new_frame (sp, func_addr));
1278 if (sp != unwound_sp)
1279 regcache_cooked_write_unsigned (regcache, E_SP_REGNUM,
1280 sp - (unwound_sp - sp));
1283 return sp;
1286 /* If DWARF2 is a register number appearing in Dwarf2 debug info, then
1287 mn10300_dwarf2_reg_to_regnum (DWARF2) is the corresponding GDB
1288 register number. Why don't Dwarf2 and GDB use the same numbering?
1289 Who knows? But since people have object files lying around with
1290 the existing Dwarf2 numbering, and other people have written stubs
1291 to work with the existing GDB, neither of them can change. So we
1292 just have to cope. */
1293 static int
1294 mn10300_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int dwarf2)
1296 /* This table is supposed to be shaped like the gdbarch_register_name
1297 initializer in gcc/config/mn10300/mn10300.h. Registers which
1298 appear in GCC's numbering, but have no counterpart in GDB's
1299 world, are marked with a -1. */
1300 static int dwarf2_to_gdb[] = {
1301 E_D0_REGNUM, E_D1_REGNUM, E_D2_REGNUM, E_D3_REGNUM,
1302 E_A0_REGNUM, E_A1_REGNUM, E_A2_REGNUM, E_A3_REGNUM,
1303 -1, E_SP_REGNUM,
1305 E_E0_REGNUM, E_E1_REGNUM, E_E2_REGNUM, E_E3_REGNUM,
1306 E_E4_REGNUM, E_E5_REGNUM, E_E6_REGNUM, E_E7_REGNUM,
1308 E_FS0_REGNUM + 0, E_FS0_REGNUM + 1, E_FS0_REGNUM + 2, E_FS0_REGNUM + 3,
1309 E_FS0_REGNUM + 4, E_FS0_REGNUM + 5, E_FS0_REGNUM + 6, E_FS0_REGNUM + 7,
1311 E_FS0_REGNUM + 8, E_FS0_REGNUM + 9, E_FS0_REGNUM + 10, E_FS0_REGNUM + 11,
1312 E_FS0_REGNUM + 12, E_FS0_REGNUM + 13, E_FS0_REGNUM + 14, E_FS0_REGNUM + 15,
1314 E_FS0_REGNUM + 16, E_FS0_REGNUM + 17, E_FS0_REGNUM + 18, E_FS0_REGNUM + 19,
1315 E_FS0_REGNUM + 20, E_FS0_REGNUM + 21, E_FS0_REGNUM + 22, E_FS0_REGNUM + 23,
1317 E_FS0_REGNUM + 24, E_FS0_REGNUM + 25, E_FS0_REGNUM + 26, E_FS0_REGNUM + 27,
1318 E_FS0_REGNUM + 28, E_FS0_REGNUM + 29, E_FS0_REGNUM + 30, E_FS0_REGNUM + 31,
1320 E_MDR_REGNUM, E_PSW_REGNUM, E_PC_REGNUM
1323 if (dwarf2 < 0
1324 || dwarf2 >= ARRAY_SIZE (dwarf2_to_gdb))
1325 return -1;
1327 return dwarf2_to_gdb[dwarf2];
1330 static struct gdbarch *
1331 mn10300_gdbarch_init (struct gdbarch_info info,
1332 struct gdbarch_list *arches)
1334 int num_regs;
1336 arches = gdbarch_list_lookup_by_info (arches, &info);
1337 if (arches != NULL)
1338 return arches->gdbarch;
1340 gdbarch *gdbarch
1341 = gdbarch_alloc (&info, gdbarch_tdep_up (new mn10300_gdbarch_tdep));
1342 mn10300_gdbarch_tdep *tdep = gdbarch_tdep<mn10300_gdbarch_tdep> (gdbarch);
1344 switch (info.bfd_arch_info->mach)
1346 case 0:
1347 case bfd_mach_mn10300:
1348 set_gdbarch_register_name (gdbarch, mn10300_generic_register_name);
1349 tdep->am33_mode = 0;
1350 num_regs = 32;
1351 break;
1352 case bfd_mach_am33:
1353 set_gdbarch_register_name (gdbarch, am33_register_name);
1354 tdep->am33_mode = 1;
1355 num_regs = 32;
1356 break;
1357 case bfd_mach_am33_2:
1358 set_gdbarch_register_name (gdbarch, am33_2_register_name);
1359 tdep->am33_mode = 2;
1360 num_regs = 64;
1361 set_gdbarch_fp0_regnum (gdbarch, 32);
1362 break;
1363 default:
1364 internal_error (_("mn10300_gdbarch_init: Unknown mn10300 variant"));
1365 break;
1368 /* By default, chars are unsigned. */
1369 set_gdbarch_char_signed (gdbarch, 0);
1371 /* Registers. */
1372 set_gdbarch_num_regs (gdbarch, num_regs);
1373 set_gdbarch_register_type (gdbarch, mn10300_register_type);
1374 set_gdbarch_skip_prologue (gdbarch, mn10300_skip_prologue);
1375 set_gdbarch_pc_regnum (gdbarch, E_PC_REGNUM);
1376 set_gdbarch_sp_regnum (gdbarch, E_SP_REGNUM);
1377 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, mn10300_dwarf2_reg_to_regnum);
1379 /* Stack unwinding. */
1380 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
1381 /* Breakpoints. */
1382 set_gdbarch_breakpoint_kind_from_pc (gdbarch,
1383 mn10300_breakpoint::kind_from_pc);
1384 set_gdbarch_sw_breakpoint_from_kind (gdbarch,
1385 mn10300_breakpoint::bp_from_kind);
1386 /* decr_pc_after_break? */
1388 /* Stage 2 */
1389 set_gdbarch_return_value (gdbarch, mn10300_return_value);
1391 /* Stage 3 -- get target calls working. */
1392 set_gdbarch_push_dummy_call (gdbarch, mn10300_push_dummy_call);
1393 /* set_gdbarch_return_value (store, extract) */
1396 mn10300_frame_unwind_init (gdbarch);
1398 /* Hook in ABI-specific overrides, if they have been registered. */
1399 gdbarch_init_osabi (info, gdbarch);
1401 return gdbarch;
1404 /* Dump out the mn10300 specific architecture information. */
1406 static void
1407 mn10300_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
1409 mn10300_gdbarch_tdep *tdep = gdbarch_tdep<mn10300_gdbarch_tdep> (gdbarch);
1410 gdb_printf (file, "mn10300_dump_tdep: am33_mode = %d\n",
1411 tdep->am33_mode);
1414 void _initialize_mn10300_tdep ();
1415 void
1416 _initialize_mn10300_tdep ()
1418 gdbarch_register (bfd_arch_mn10300, mn10300_gdbarch_init, mn10300_dump_tdep);