1 /* Target-dependent code for the Renesas RX for GDB, the GNU debugger.
3 Copyright (C) 2008-2015 Free Software Foundation, Inc.
5 Contributed by Red Hat, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "arch-utils.h"
24 #include "prologue-value.h"
27 #include "opcode/rx.h"
31 #include "frame-unwind.h"
32 #include "frame-base.h"
35 #include "dwarf2-frame.h"
40 /* Certain important register numbers. */
56 /* Architecture specific data. */
59 /* The ELF header flags specify the multilib used. */
62 /* Type of PSW and BPSW. */
63 struct type
*rx_psw_type
;
66 struct type
*rx_fpsw_type
;
69 /* This structure holds the results of a prologue analysis. */
72 /* The offset from the frame base to the stack pointer --- always
75 Calling this a "size" is a bit misleading, but given that the
76 stack grows downwards, using offsets for everything keeps one
77 from going completely sign-crazy: you never change anything's
78 sign for an ADD instruction; always change the second operand's
79 sign for a SUB instruction; and everything takes care of
83 /* Non-zero if this function has initialized the frame pointer from
84 the stack pointer, zero otherwise. */
87 /* If has_frame_ptr is non-zero, this is the offset from the frame
88 base to where the frame pointer points. This is always zero or
92 /* The address of the first instruction at which the frame has been
93 set up and the arguments are where the debug info says they are
94 --- as best as we can tell. */
95 CORE_ADDR prologue_end
;
97 /* reg_offset[R] is the offset from the CFA at which register R is
98 saved, or 1 if register R has not been saved. (Real values are
99 always zero or negative.) */
100 int reg_offset
[RX_NUM_REGS
];
103 /* Implement the "register_name" gdbarch method. */
105 rx_register_name (struct gdbarch
*gdbarch
, int regnr
)
107 static const char *const reg_names
[] = {
136 return reg_names
[regnr
];
139 /* Implement the "register_type" gdbarch method. */
141 rx_register_type (struct gdbarch
*gdbarch
, int reg_nr
)
143 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
145 if (reg_nr
== RX_PC_REGNUM
)
146 return builtin_type (gdbarch
)->builtin_func_ptr
;
147 else if (reg_nr
== RX_PSW_REGNUM
|| reg_nr
== RX_BPSW_REGNUM
)
148 return tdep
->rx_psw_type
;
149 else if (reg_nr
== RX_FPSW_REGNUM
)
150 return tdep
->rx_fpsw_type
;
151 else if (reg_nr
== RX_ACC_REGNUM
)
152 return builtin_type (gdbarch
)->builtin_unsigned_long_long
;
154 return builtin_type (gdbarch
)->builtin_unsigned_long
;
158 /* Function for finding saved registers in a 'struct pv_area'; this
159 function is passed to pv_area_scan.
161 If VALUE is a saved register, ADDR says it was saved at a constant
162 offset from the frame base, and SIZE indicates that the whole
163 register was saved, record its offset. */
165 check_for_saved (void *result_untyped
, pv_t addr
, CORE_ADDR size
, pv_t value
)
167 struct rx_prologue
*result
= (struct rx_prologue
*) result_untyped
;
169 if (value
.kind
== pvk_register
171 && pv_is_register (addr
, RX_SP_REGNUM
)
172 && size
== register_size (target_gdbarch (), value
.reg
))
173 result
->reg_offset
[value
.reg
] = addr
.k
;
176 /* Define a "handle" struct for fetching the next opcode. */
177 struct rx_get_opcode_byte_handle
182 /* Fetch a byte on behalf of the opcode decoder. HANDLE contains
183 the memory address of the next byte to fetch. If successful,
184 the address in the handle is updated and the byte fetched is
185 returned as the value of the function. If not successful, -1
188 rx_get_opcode_byte (void *handle
)
190 struct rx_get_opcode_byte_handle
*opcdata
= handle
;
194 status
= target_read_memory (opcdata
->pc
, &byte
, 1);
204 /* Analyze a prologue starting at START_PC, going no further than
205 LIMIT_PC. Fill in RESULT as appropriate. */
207 rx_analyze_prologue (CORE_ADDR start_pc
,
208 CORE_ADDR limit_pc
, struct rx_prologue
*result
)
210 CORE_ADDR pc
, next_pc
;
212 pv_t reg
[RX_NUM_REGS
];
213 struct pv_area
*stack
;
214 struct cleanup
*back_to
;
215 CORE_ADDR after_last_frame_setup_insn
= start_pc
;
217 memset (result
, 0, sizeof (*result
));
219 for (rn
= 0; rn
< RX_NUM_REGS
; rn
++)
221 reg
[rn
] = pv_register (rn
, 0);
222 result
->reg_offset
[rn
] = 1;
225 stack
= make_pv_area (RX_SP_REGNUM
, gdbarch_addr_bit (target_gdbarch ()));
226 back_to
= make_cleanup_free_pv_area (stack
);
228 /* The call instruction has saved the return address on the stack. */
229 reg
[RX_SP_REGNUM
] = pv_add_constant (reg
[RX_SP_REGNUM
], -4);
230 pv_area_store (stack
, reg
[RX_SP_REGNUM
], 4, reg
[RX_PC_REGNUM
]);
233 while (pc
< limit_pc
)
236 struct rx_get_opcode_byte_handle opcode_handle
;
237 RX_Opcode_Decoded opc
;
239 opcode_handle
.pc
= pc
;
240 bytes_read
= rx_decode_opcode (pc
, &opc
, rx_get_opcode_byte
,
242 next_pc
= pc
+ bytes_read
;
244 if (opc
.id
== RXO_pushm
/* pushm r1, r2 */
245 && opc
.op
[1].type
== RX_Operand_Register
246 && opc
.op
[2].type
== RX_Operand_Register
)
253 for (r
= r2
; r
>= r1
; r
--)
255 reg
[RX_SP_REGNUM
] = pv_add_constant (reg
[RX_SP_REGNUM
], -4);
256 pv_area_store (stack
, reg
[RX_SP_REGNUM
], 4, reg
[r
]);
258 after_last_frame_setup_insn
= next_pc
;
260 else if (opc
.id
== RXO_mov
/* mov.l rdst, rsrc */
261 && opc
.op
[0].type
== RX_Operand_Register
262 && opc
.op
[1].type
== RX_Operand_Register
263 && opc
.size
== RX_Long
)
267 rdst
= opc
.op
[0].reg
;
268 rsrc
= opc
.op
[1].reg
;
269 reg
[rdst
] = reg
[rsrc
];
270 if (rdst
== RX_FP_REGNUM
&& rsrc
== RX_SP_REGNUM
)
271 after_last_frame_setup_insn
= next_pc
;
273 else if (opc
.id
== RXO_mov
/* mov.l rsrc, [-SP] */
274 && opc
.op
[0].type
== RX_Operand_Predec
275 && opc
.op
[0].reg
== RX_SP_REGNUM
276 && opc
.op
[1].type
== RX_Operand_Register
277 && opc
.size
== RX_Long
)
281 rsrc
= opc
.op
[1].reg
;
282 reg
[RX_SP_REGNUM
] = pv_add_constant (reg
[RX_SP_REGNUM
], -4);
283 pv_area_store (stack
, reg
[RX_SP_REGNUM
], 4, reg
[rsrc
]);
284 after_last_frame_setup_insn
= next_pc
;
286 else if (opc
.id
== RXO_add
/* add #const, rsrc, rdst */
287 && opc
.op
[0].type
== RX_Operand_Register
288 && opc
.op
[1].type
== RX_Operand_Immediate
289 && opc
.op
[2].type
== RX_Operand_Register
)
291 int rdst
= opc
.op
[0].reg
;
292 int addend
= opc
.op
[1].addend
;
293 int rsrc
= opc
.op
[2].reg
;
294 reg
[rdst
] = pv_add_constant (reg
[rsrc
], addend
);
295 /* Negative adjustments to the stack pointer or frame pointer
296 are (most likely) part of the prologue. */
297 if ((rdst
== RX_SP_REGNUM
|| rdst
== RX_FP_REGNUM
) && addend
< 0)
298 after_last_frame_setup_insn
= next_pc
;
300 else if (opc
.id
== RXO_mov
301 && opc
.op
[0].type
== RX_Operand_Indirect
302 && opc
.op
[1].type
== RX_Operand_Register
303 && opc
.size
== RX_Long
304 && (opc
.op
[0].reg
== RX_SP_REGNUM
305 || opc
.op
[0].reg
== RX_FP_REGNUM
)
306 && (RX_R1_REGNUM
<= opc
.op
[1].reg
307 && opc
.op
[1].reg
<= RX_R4_REGNUM
))
309 /* This moves an argument register to the stack. Don't
310 record it, but allow it to be a part of the prologue. */
312 else if (opc
.id
== RXO_branch
313 && opc
.op
[0].type
== RX_Operand_Immediate
314 && next_pc
< opc
.op
[0].addend
)
316 /* When a loop appears as the first statement of a function
317 body, gcc 4.x will use a BRA instruction to branch to the
318 loop condition checking code. This BRA instruction is
319 marked as part of the prologue. We therefore set next_pc
320 to this branch target and also stop the prologue scan.
321 The instructions at and beyond the branch target should
322 no longer be associated with the prologue.
324 Note that we only consider forward branches here. We
325 presume that a forward branch is being used to skip over
328 A backwards branch is covered by the default case below.
329 If we were to encounter a backwards branch, that would
330 most likely mean that we've scanned through a loop body.
331 We definitely want to stop the prologue scan when this
332 happens and that is precisely what is done by the default
335 after_last_frame_setup_insn
= opc
.op
[0].addend
;
336 break; /* Scan no further if we hit this case. */
340 /* Terminate the prologue scan. */
347 /* Is the frame size (offset, really) a known constant? */
348 if (pv_is_register (reg
[RX_SP_REGNUM
], RX_SP_REGNUM
))
349 result
->frame_size
= reg
[RX_SP_REGNUM
].k
;
351 /* Was the frame pointer initialized? */
352 if (pv_is_register (reg
[RX_FP_REGNUM
], RX_SP_REGNUM
))
354 result
->has_frame_ptr
= 1;
355 result
->frame_ptr_offset
= reg
[RX_FP_REGNUM
].k
;
358 /* Record where all the registers were saved. */
359 pv_area_scan (stack
, check_for_saved
, (void *) result
);
361 result
->prologue_end
= after_last_frame_setup_insn
;
363 do_cleanups (back_to
);
367 /* Implement the "skip_prologue" gdbarch method. */
369 rx_skip_prologue (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
372 CORE_ADDR func_addr
, func_end
;
373 struct rx_prologue p
;
375 /* Try to find the extent of the function that contains PC. */
376 if (!find_pc_partial_function (pc
, &name
, &func_addr
, &func_end
))
379 rx_analyze_prologue (pc
, func_end
, &p
);
380 return p
.prologue_end
;
383 /* Given a frame described by THIS_FRAME, decode the prologue of its
384 associated function if there is not cache entry as specified by
385 THIS_PROLOGUE_CACHE. Save the decoded prologue in the cache and
386 return that struct as the value of this function. */
387 static struct rx_prologue
*
388 rx_analyze_frame_prologue (struct frame_info
*this_frame
,
389 void **this_prologue_cache
)
391 if (!*this_prologue_cache
)
393 CORE_ADDR func_start
, stop_addr
;
395 *this_prologue_cache
= FRAME_OBSTACK_ZALLOC (struct rx_prologue
);
397 func_start
= get_frame_func (this_frame
);
398 stop_addr
= get_frame_pc (this_frame
);
400 /* If we couldn't find any function containing the PC, then
401 just initialize the prologue cache, but don't do anything. */
403 stop_addr
= func_start
;
405 rx_analyze_prologue (func_start
, stop_addr
, *this_prologue_cache
);
408 return *this_prologue_cache
;
411 /* Given the next frame and a prologue cache, return this frame's
414 rx_frame_base (struct frame_info
*this_frame
, void **this_prologue_cache
)
416 struct rx_prologue
*p
417 = rx_analyze_frame_prologue (this_frame
, this_prologue_cache
);
419 /* In functions that use alloca, the distance between the stack
420 pointer and the frame base varies dynamically, so we can't use
421 the SP plus static information like prologue analysis to find the
422 frame base. However, such functions must have a frame pointer,
423 to be able to restore the SP on exit. So whenever we do have a
424 frame pointer, use that to find the base. */
425 if (p
->has_frame_ptr
)
427 CORE_ADDR fp
= get_frame_register_unsigned (this_frame
, RX_FP_REGNUM
);
428 return fp
- p
->frame_ptr_offset
;
432 CORE_ADDR sp
= get_frame_register_unsigned (this_frame
, RX_SP_REGNUM
);
433 return sp
- p
->frame_size
;
437 /* Implement the "frame_this_id" method for unwinding frames. */
439 rx_frame_this_id (struct frame_info
*this_frame
,
440 void **this_prologue_cache
, struct frame_id
*this_id
)
442 *this_id
= frame_id_build (rx_frame_base (this_frame
, this_prologue_cache
),
443 get_frame_func (this_frame
));
446 /* Implement the "frame_prev_register" method for unwinding frames. */
447 static struct value
*
448 rx_frame_prev_register (struct frame_info
*this_frame
,
449 void **this_prologue_cache
, int regnum
)
451 struct rx_prologue
*p
452 = rx_analyze_frame_prologue (this_frame
, this_prologue_cache
);
453 CORE_ADDR frame_base
= rx_frame_base (this_frame
, this_prologue_cache
);
454 int reg_size
= register_size (get_frame_arch (this_frame
), regnum
);
456 if (regnum
== RX_SP_REGNUM
)
457 return frame_unwind_got_constant (this_frame
, regnum
, frame_base
);
459 /* If prologue analysis says we saved this register somewhere,
460 return a description of the stack slot holding it. */
461 else if (p
->reg_offset
[regnum
] != 1)
462 return frame_unwind_got_memory (this_frame
, regnum
,
463 frame_base
+ p
->reg_offset
[regnum
]);
465 /* Otherwise, presume we haven't changed the value of this
466 register, and get it from the next frame. */
468 return frame_unwind_got_register (this_frame
, regnum
, regnum
);
471 static const struct frame_unwind rx_frame_unwind
= {
473 default_frame_unwind_stop_reason
,
475 rx_frame_prev_register
,
477 default_frame_sniffer
480 /* Implement the "unwind_pc" gdbarch method. */
482 rx_unwind_pc (struct gdbarch
*gdbarch
, struct frame_info
*this_frame
)
486 pc
= frame_unwind_register_unsigned (this_frame
, RX_PC_REGNUM
);
490 /* Implement the "unwind_sp" gdbarch method. */
492 rx_unwind_sp (struct gdbarch
*gdbarch
, struct frame_info
*this_frame
)
496 sp
= frame_unwind_register_unsigned (this_frame
, RX_SP_REGNUM
);
500 /* Implement the "dummy_id" gdbarch method. */
501 static struct frame_id
502 rx_dummy_id (struct gdbarch
*gdbarch
, struct frame_info
*this_frame
)
505 frame_id_build (get_frame_register_unsigned (this_frame
, RX_SP_REGNUM
),
506 get_frame_pc (this_frame
));
509 /* Implement the "push_dummy_call" gdbarch method. */
511 rx_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
512 struct regcache
*regcache
, CORE_ADDR bp_addr
, int nargs
,
513 struct value
**args
, CORE_ADDR sp
, int struct_return
,
514 CORE_ADDR struct_addr
)
516 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
520 int num_register_candidate_args
;
522 struct type
*func_type
= value_type (function
);
524 /* Dereference function pointer types. */
525 while (TYPE_CODE (func_type
) == TYPE_CODE_PTR
)
526 func_type
= TYPE_TARGET_TYPE (func_type
);
528 /* The end result had better be a function or a method. */
529 gdb_assert (TYPE_CODE (func_type
) == TYPE_CODE_FUNC
530 || TYPE_CODE (func_type
) == TYPE_CODE_METHOD
);
532 /* Functions with a variable number of arguments have all of their
533 variable arguments and the last non-variable argument passed
536 Otherwise, we can pass up to four arguments on the stack.
538 Once computed, we leave this value alone. I.e. we don't update
539 it in case of a struct return going in a register or an argument
540 requiring multiple registers, etc. We rely instead on the value
541 of the ``arg_reg'' variable to get these other details correct. */
543 if (TYPE_VARARGS (func_type
))
544 num_register_candidate_args
= TYPE_NFIELDS (func_type
) - 1;
546 num_register_candidate_args
= 4;
548 /* We make two passes; the first does the stack allocation,
549 the second actually stores the arguments. */
550 for (write_pass
= 0; write_pass
<= 1; write_pass
++)
553 int arg_reg
= RX_R1_REGNUM
;
556 sp
= align_down (sp
- sp_off
, 4);
561 struct type
*return_type
= TYPE_TARGET_TYPE (func_type
);
563 gdb_assert (TYPE_CODE (return_type
) == TYPE_CODE_STRUCT
564 || TYPE_CODE (func_type
) == TYPE_CODE_UNION
);
566 if (TYPE_LENGTH (return_type
) > 16
567 || TYPE_LENGTH (return_type
) % 4 != 0)
570 regcache_cooked_write_unsigned (regcache
, RX_R15_REGNUM
,
575 /* Push the arguments. */
576 for (i
= 0; i
< nargs
; i
++)
578 struct value
*arg
= args
[i
];
579 const gdb_byte
*arg_bits
= value_contents_all (arg
);
580 struct type
*arg_type
= check_typedef (value_type (arg
));
581 ULONGEST arg_size
= TYPE_LENGTH (arg_type
);
583 if (i
== 0 && struct_addr
!= 0 && !struct_return
584 && TYPE_CODE (arg_type
) == TYPE_CODE_PTR
585 && extract_unsigned_integer (arg_bits
, 4,
586 byte_order
) == struct_addr
)
588 /* This argument represents the address at which C++ (and
589 possibly other languages) store their return value.
590 Put this value in R15. */
592 regcache_cooked_write_unsigned (regcache
, RX_R15_REGNUM
,
595 else if (TYPE_CODE (arg_type
) != TYPE_CODE_STRUCT
596 && TYPE_CODE (arg_type
) != TYPE_CODE_UNION
)
598 /* Argument is a scalar. */
601 if (i
< num_register_candidate_args
602 && arg_reg
<= RX_R4_REGNUM
- 1)
604 /* If argument registers are going to be used to pass
605 an 8 byte scalar, the ABI specifies that two registers
606 must be available. */
609 regcache_cooked_write_unsigned (regcache
, arg_reg
,
610 extract_unsigned_integer
613 regcache_cooked_write_unsigned (regcache
,
615 extract_unsigned_integer
623 sp_off
= align_up (sp_off
, 4);
624 /* Otherwise, pass the 8 byte scalar on the stack. */
626 write_memory (sp
+ sp_off
, arg_bits
, 8);
634 gdb_assert (arg_size
<= 4);
637 extract_unsigned_integer (arg_bits
, arg_size
, byte_order
);
639 if (i
< num_register_candidate_args
640 && arg_reg
<= RX_R4_REGNUM
)
643 regcache_cooked_write_unsigned (regcache
, arg_reg
, u
);
650 if (TYPE_PROTOTYPED (func_type
)
651 && i
< TYPE_NFIELDS (func_type
))
653 struct type
*p_arg_type
=
654 TYPE_FIELD_TYPE (func_type
, i
);
655 p_arg_size
= TYPE_LENGTH (p_arg_type
);
658 sp_off
= align_up (sp_off
, p_arg_size
);
661 write_memory_unsigned_integer (sp
+ sp_off
,
662 p_arg_size
, byte_order
,
664 sp_off
+= p_arg_size
;
670 /* Argument is a struct or union. Pass as much of the struct
671 in registers, if possible. Pass the rest on the stack. */
674 if (i
< num_register_candidate_args
675 && arg_reg
<= RX_R4_REGNUM
676 && arg_size
<= 4 * (RX_R4_REGNUM
- arg_reg
+ 1)
677 && arg_size
% 4 == 0)
679 int len
= min (arg_size
, 4);
682 regcache_cooked_write_unsigned (regcache
, arg_reg
,
683 extract_unsigned_integer
692 sp_off
= align_up (sp_off
, 4);
694 write_memory (sp
+ sp_off
, arg_bits
, arg_size
);
695 sp_off
+= align_up (arg_size
, 4);
703 /* Keep track of the stack address prior to pushing the return address.
704 This is the value that we'll return. */
707 /* Push the return address. */
709 write_memory_unsigned_integer (sp
, 4, byte_order
, bp_addr
);
711 /* Update the stack pointer. */
712 regcache_cooked_write_unsigned (regcache
, RX_SP_REGNUM
, sp
);
717 /* Implement the "return_value" gdbarch method. */
718 static enum return_value_convention
719 rx_return_value (struct gdbarch
*gdbarch
,
720 struct value
*function
,
721 struct type
*valtype
,
722 struct regcache
*regcache
,
723 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
725 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
726 ULONGEST valtype_len
= TYPE_LENGTH (valtype
);
728 if (TYPE_LENGTH (valtype
) > 16
729 || ((TYPE_CODE (valtype
) == TYPE_CODE_STRUCT
730 || TYPE_CODE (valtype
) == TYPE_CODE_UNION
)
731 && TYPE_LENGTH (valtype
) % 4 != 0))
732 return RETURN_VALUE_STRUCT_CONVENTION
;
737 int argreg
= RX_R1_REGNUM
;
740 while (valtype_len
> 0)
742 int len
= min (valtype_len
, 4);
744 regcache_cooked_read_unsigned (regcache
, argreg
, &u
);
745 store_unsigned_integer (readbuf
+ offset
, len
, byte_order
, u
);
755 int argreg
= RX_R1_REGNUM
;
758 while (valtype_len
> 0)
760 int len
= min (valtype_len
, 4);
762 u
= extract_unsigned_integer (writebuf
+ offset
, len
, byte_order
);
763 regcache_cooked_write_unsigned (regcache
, argreg
, u
);
770 return RETURN_VALUE_REGISTER_CONVENTION
;
773 /* Implement the "breakpoint_from_pc" gdbarch method. */
774 static const gdb_byte
*
775 rx_breakpoint_from_pc (struct gdbarch
*gdbarch
, CORE_ADDR
*pcptr
, int *lenptr
)
777 static gdb_byte breakpoint
[] = { 0x00 };
778 *lenptr
= sizeof breakpoint
;
782 /* Implement the dwarf_reg_to_regnum" gdbarch method. */
785 rx_dwarf_reg_to_regnum (struct gdbarch
*gdbarch
, int reg
)
787 if (0 <= reg
&& reg
<= 15)
790 return RX_PSW_REGNUM
;
794 internal_error (__FILE__
, __LINE__
,
795 _("Undefined dwarf2 register mapping of reg %d"),
799 /* Allocate and initialize a gdbarch object. */
800 static struct gdbarch
*
801 rx_gdbarch_init (struct gdbarch_info info
, struct gdbarch_list
*arches
)
803 struct gdbarch
*gdbarch
;
804 struct gdbarch_tdep
*tdep
;
807 /* Extract the elf_flags if available. */
808 if (info
.abfd
!= NULL
809 && bfd_get_flavour (info
.abfd
) == bfd_target_elf_flavour
)
810 elf_flags
= elf_elfheader (info
.abfd
)->e_flags
;
815 /* Try to find the architecture in the list of already defined
817 for (arches
= gdbarch_list_lookup_by_info (arches
, &info
);
819 arches
= gdbarch_list_lookup_by_info (arches
->next
, &info
))
821 if (gdbarch_tdep (arches
->gdbarch
)->elf_flags
!= elf_flags
)
824 return arches
->gdbarch
;
827 /* None found, create a new architecture from the information
829 tdep
= (struct gdbarch_tdep
*) xmalloc (sizeof (struct gdbarch_tdep
));
830 gdbarch
= gdbarch_alloc (&info
, tdep
);
831 tdep
->elf_flags
= elf_flags
;
833 /* Initialize the flags type for PSW and BPSW. */
835 tdep
->rx_psw_type
= arch_flags_type (gdbarch
, "rx_psw_type", 4);
836 append_flags_type_flag (tdep
->rx_psw_type
, 0, "C");
837 append_flags_type_flag (tdep
->rx_psw_type
, 1, "Z");
838 append_flags_type_flag (tdep
->rx_psw_type
, 2, "S");
839 append_flags_type_flag (tdep
->rx_psw_type
, 3, "O");
840 append_flags_type_flag (tdep
->rx_psw_type
, 16, "I");
841 append_flags_type_flag (tdep
->rx_psw_type
, 17, "U");
842 append_flags_type_flag (tdep
->rx_psw_type
, 20, "PM");
843 append_flags_type_flag (tdep
->rx_psw_type
, 24, "IPL0");
844 append_flags_type_flag (tdep
->rx_psw_type
, 25, "IPL1");
845 append_flags_type_flag (tdep
->rx_psw_type
, 26, "IPL2");
846 append_flags_type_flag (tdep
->rx_psw_type
, 27, "IPL3");
848 /* Initialize flags type for FPSW. */
850 tdep
->rx_fpsw_type
= arch_flags_type (gdbarch
, "rx_fpsw_type", 4);
851 append_flags_type_flag (tdep
->rx_fpsw_type
, 0, "RM0");
852 append_flags_type_flag (tdep
->rx_fpsw_type
, 1, "RM1");
853 append_flags_type_flag (tdep
->rx_fpsw_type
, 2, "CV");
854 append_flags_type_flag (tdep
->rx_fpsw_type
, 3, "CO");
855 append_flags_type_flag (tdep
->rx_fpsw_type
, 4, "CZ");
856 append_flags_type_flag (tdep
->rx_fpsw_type
, 5, "CU");
857 append_flags_type_flag (tdep
->rx_fpsw_type
, 6, "CX");
858 append_flags_type_flag (tdep
->rx_fpsw_type
, 7, "CE");
859 append_flags_type_flag (tdep
->rx_fpsw_type
, 8, "DN");
860 append_flags_type_flag (tdep
->rx_fpsw_type
, 10, "EV");
861 append_flags_type_flag (tdep
->rx_fpsw_type
, 11, "EO");
862 append_flags_type_flag (tdep
->rx_fpsw_type
, 12, "EZ");
863 append_flags_type_flag (tdep
->rx_fpsw_type
, 13, "EU");
864 append_flags_type_flag (tdep
->rx_fpsw_type
, 14, "EX");
865 append_flags_type_flag (tdep
->rx_fpsw_type
, 26, "FV");
866 append_flags_type_flag (tdep
->rx_fpsw_type
, 27, "FO");
867 append_flags_type_flag (tdep
->rx_fpsw_type
, 28, "FZ");
868 append_flags_type_flag (tdep
->rx_fpsw_type
, 29, "FU");
869 append_flags_type_flag (tdep
->rx_fpsw_type
, 30, "FX");
870 append_flags_type_flag (tdep
->rx_fpsw_type
, 31, "FS");
872 set_gdbarch_num_regs (gdbarch
, RX_NUM_REGS
);
873 set_gdbarch_num_pseudo_regs (gdbarch
, 0);
874 set_gdbarch_register_name (gdbarch
, rx_register_name
);
875 set_gdbarch_register_type (gdbarch
, rx_register_type
);
876 set_gdbarch_pc_regnum (gdbarch
, RX_PC_REGNUM
);
877 set_gdbarch_sp_regnum (gdbarch
, RX_SP_REGNUM
);
878 set_gdbarch_inner_than (gdbarch
, core_addr_lessthan
);
879 set_gdbarch_decr_pc_after_break (gdbarch
, 1);
880 set_gdbarch_breakpoint_from_pc (gdbarch
, rx_breakpoint_from_pc
);
881 set_gdbarch_skip_prologue (gdbarch
, rx_skip_prologue
);
883 set_gdbarch_print_insn (gdbarch
, print_insn_rx
);
885 set_gdbarch_unwind_pc (gdbarch
, rx_unwind_pc
);
886 set_gdbarch_unwind_sp (gdbarch
, rx_unwind_sp
);
888 /* Target builtin data types. */
889 set_gdbarch_char_signed (gdbarch
, 0);
890 set_gdbarch_short_bit (gdbarch
, 16);
891 set_gdbarch_int_bit (gdbarch
, 32);
892 set_gdbarch_long_bit (gdbarch
, 32);
893 set_gdbarch_long_long_bit (gdbarch
, 64);
894 set_gdbarch_ptr_bit (gdbarch
, 32);
895 set_gdbarch_float_bit (gdbarch
, 32);
896 set_gdbarch_float_format (gdbarch
, floatformats_ieee_single
);
897 if (elf_flags
& E_FLAG_RX_64BIT_DOUBLES
)
899 set_gdbarch_double_bit (gdbarch
, 64);
900 set_gdbarch_long_double_bit (gdbarch
, 64);
901 set_gdbarch_double_format (gdbarch
, floatformats_ieee_double
);
902 set_gdbarch_long_double_format (gdbarch
, floatformats_ieee_double
);
906 set_gdbarch_double_bit (gdbarch
, 32);
907 set_gdbarch_long_double_bit (gdbarch
, 32);
908 set_gdbarch_double_format (gdbarch
, floatformats_ieee_single
);
909 set_gdbarch_long_double_format (gdbarch
, floatformats_ieee_single
);
912 /* DWARF register mapping. */
913 set_gdbarch_dwarf2_reg_to_regnum (gdbarch
, rx_dwarf_reg_to_regnum
);
915 /* Frame unwinding. */
916 dwarf2_append_unwinders (gdbarch
);
917 frame_unwind_append_unwinder (gdbarch
, &rx_frame_unwind
);
919 /* Methods for saving / extracting a dummy frame's ID.
920 The ID's stack address must match the SP value returned by
921 PUSH_DUMMY_CALL, and saved by generic_save_dummy_frame_tos. */
922 set_gdbarch_dummy_id (gdbarch
, rx_dummy_id
);
923 set_gdbarch_push_dummy_call (gdbarch
, rx_push_dummy_call
);
924 set_gdbarch_return_value (gdbarch
, rx_return_value
);
926 /* Virtual tables. */
927 set_gdbarch_vbit_in_delta (gdbarch
, 1);
932 /* -Wmissing-prototypes */
933 extern initialize_file_ftype _initialize_rx_tdep
;
935 /* Register the above initialization routine. */
938 _initialize_rx_tdep (void)
940 register_gdbarch_init (bfd_arch_rx
, rx_gdbarch_init
);