1 /* Target dependent code for CRIS, for GDB, the GNU debugger.
3 Copyright (C) 2001-2022 Free Software Foundation, Inc.
5 Contributed by Axis Communications AB.
6 Written by Hendrik Ruijter, Stefan Andersson, and Orjan Friberg.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #include "frame-unwind.h"
26 #include "frame-base.h"
27 #include "trad-frame.h"
28 #include "dwarf2/frame.h"
36 #include "opcode/cris.h"
38 #include "arch-utils.h"
44 #include "solib.h" /* Support for shared libraries. */
45 #include "solib-svr4.h"
48 #include "cris-tdep.h"
52 /* There are no floating point registers. Used in gdbserver low-linux.c. */
55 /* There are 16 general registers. */
58 /* There are 16 special registers. */
61 /* CRISv32 has a pseudo PC register, not noted here. */
63 /* CRISv32 has 16 support registers. */
67 /* Register numbers of various important registers.
68 CRIS_FP_REGNUM Contains address of executing stack frame.
69 STR_REGNUM Contains the address of structure return values.
70 RET_REGNUM Contains the return value when shorter than or equal to 32 bits
71 ARG1_REGNUM Contains the first parameter to a function.
72 ARG2_REGNUM Contains the second parameter to a function.
73 ARG3_REGNUM Contains the third parameter to a function.
74 ARG4_REGNUM Contains the fourth parameter to a function. Rest on stack.
75 gdbarch_sp_regnum Contains address of top of stack.
76 gdbarch_pc_regnum Contains address of next instruction.
77 SRP_REGNUM Subroutine return pointer register.
78 BRP_REGNUM Breakpoint return pointer register. */
82 /* Enums with respect to the general registers, valid for all
83 CRIS versions. The frame pointer is always in R8. */
85 /* ABI related registers. */
93 /* Registers which happen to be common. */
98 /* CRISv10 et al. specific registers. */
110 /* CRISv32 specific registers. */
123 CRISV32USP_REGNUM
= 30, /* Shares name but not number with CRISv10. */
125 CRISV32PC_REGNUM
= 32, /* Shares name but not number with CRISv10. */
145 extern const struct cris_spec_reg cris_spec_regs
[];
147 /* CRIS version, set via the user command 'set cris-version'. Affects
148 register names and sizes. */
149 static unsigned int usr_cmd_cris_version
;
151 /* Indicates whether to trust the above variable. */
152 static bool usr_cmd_cris_version_valid
= false;
154 static const char cris_mode_normal
[] = "normal";
155 static const char cris_mode_guru
[] = "guru";
156 static const char *const cris_modes
[] = {
162 /* CRIS mode, set via the user command 'set cris-mode'. Affects
163 type of break instruction among other things. */
164 static const char *usr_cmd_cris_mode
= cris_mode_normal
;
166 /* Whether to make use of Dwarf-2 CFI (default on). */
167 static bool usr_cmd_cris_dwarf2_cfi
= true;
169 /* Sigtramp identification code copied from i386-linux-tdep.c. */
171 #define SIGTRAMP_INSN0 0x9c5f /* movu.w 0xXX, $r9 */
172 #define SIGTRAMP_OFFSET0 0
173 #define SIGTRAMP_INSN1 0xe93d /* break 13 */
174 #define SIGTRAMP_OFFSET1 4
176 static const unsigned short sigtramp_code
[] =
178 SIGTRAMP_INSN0
, 0x0077, /* movu.w $0x77, $r9 */
179 SIGTRAMP_INSN1
/* break 13 */
182 #define SIGTRAMP_LEN (sizeof sigtramp_code)
184 /* Note: same length as normal sigtramp code. */
186 static const unsigned short rt_sigtramp_code
[] =
188 SIGTRAMP_INSN0
, 0x00ad, /* movu.w $0xad, $r9 */
189 SIGTRAMP_INSN1
/* break 13 */
192 /* If PC is in a sigtramp routine, return the address of the start of
193 the routine. Otherwise, return 0. */
196 cris_sigtramp_start (struct frame_info
*this_frame
)
198 CORE_ADDR pc
= get_frame_pc (this_frame
);
199 gdb_byte buf
[SIGTRAMP_LEN
];
201 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
))
204 if (((buf
[1] << 8) + buf
[0]) != SIGTRAMP_INSN0
)
206 if (((buf
[1] << 8) + buf
[0]) != SIGTRAMP_INSN1
)
209 pc
-= SIGTRAMP_OFFSET1
;
210 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
))
214 if (memcmp (buf
, sigtramp_code
, SIGTRAMP_LEN
) != 0)
220 /* If PC is in a RT sigtramp routine, return the address of the start of
221 the routine. Otherwise, return 0. */
224 cris_rt_sigtramp_start (struct frame_info
*this_frame
)
226 CORE_ADDR pc
= get_frame_pc (this_frame
);
227 gdb_byte buf
[SIGTRAMP_LEN
];
229 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
))
232 if (((buf
[1] << 8) + buf
[0]) != SIGTRAMP_INSN0
)
234 if (((buf
[1] << 8) + buf
[0]) != SIGTRAMP_INSN1
)
237 pc
-= SIGTRAMP_OFFSET1
;
238 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
))
242 if (memcmp (buf
, rt_sigtramp_code
, SIGTRAMP_LEN
) != 0)
248 /* Assuming THIS_FRAME is a frame for a GNU/Linux sigtramp routine,
249 return the address of the associated sigcontext structure. */
252 cris_sigcontext_addr (struct frame_info
*this_frame
)
254 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
255 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
260 get_frame_register (this_frame
, gdbarch_sp_regnum (gdbarch
), buf
);
261 sp
= extract_unsigned_integer (buf
, 4, byte_order
);
263 /* Look for normal sigtramp frame first. */
264 pc
= cris_sigtramp_start (this_frame
);
267 /* struct signal_frame (arch/cris/kernel/signal.c) contains
268 struct sigcontext as its first member, meaning the SP points to
273 pc
= cris_rt_sigtramp_start (this_frame
);
276 /* struct rt_signal_frame (arch/cris/kernel/signal.c) contains
277 a struct ucontext, which in turn contains a struct sigcontext.
279 4 + 4 + 128 to struct ucontext, then
280 4 + 4 + 12 to struct sigcontext. */
284 error (_("Couldn't recognize signal trampoline."));
288 struct cris_unwind_cache
290 /* The previous frame's inner most stack address. Used as this
291 frame ID's stack_addr. */
293 /* The frame's base, optionally used by the high-level debug info. */
296 /* How far the SP and r8 (FP) have been offset from the start of
297 the stack frame (as defined by the previous frame's stack
303 /* From old frame_extra_info struct. */
307 /* Table indicating the location of each and every register. */
308 trad_frame_saved_reg
*saved_regs
;
311 static struct cris_unwind_cache
*
312 cris_sigtramp_frame_unwind_cache (struct frame_info
*this_frame
,
315 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
316 cris_gdbarch_tdep
*tdep
= gdbarch_tdep
<cris_gdbarch_tdep
> (gdbarch
);
317 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
318 struct cris_unwind_cache
*info
;
324 return (struct cris_unwind_cache
*) (*this_cache
);
326 info
= FRAME_OBSTACK_ZALLOC (struct cris_unwind_cache
);
327 (*this_cache
) = info
;
328 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
330 /* Zero all fields. */
336 info
->uses_frame
= 0;
338 info
->leaf_function
= 0;
340 get_frame_register (this_frame
, gdbarch_sp_regnum (gdbarch
), buf
);
341 info
->base
= extract_unsigned_integer (buf
, 4, byte_order
);
343 addr
= cris_sigcontext_addr (this_frame
);
345 /* Layout of the sigcontext struct:
348 unsigned long oldmask;
352 if (tdep
->cris_version
== 10)
354 /* R0 to R13 are stored in reverse order at offset (2 * 4) in
356 for (i
= 0; i
<= 13; i
++)
357 info
->saved_regs
[i
].set_addr (addr
+ ((15 - i
) * 4));
359 info
->saved_regs
[MOF_REGNUM
].set_addr (addr
+ (16 * 4));
360 info
->saved_regs
[DCCR_REGNUM
].set_addr (addr
+ (17 * 4));
361 info
->saved_regs
[SRP_REGNUM
].set_addr (addr
+ (18 * 4));
362 /* Note: IRP is off by 2 at this point. There's no point in correcting
363 it though since that will mean that the backtrace will show a PC
364 different from what is shown when stopped. */
365 info
->saved_regs
[IRP_REGNUM
].set_addr (addr
+ (19 * 4));
366 info
->saved_regs
[gdbarch_pc_regnum (gdbarch
)]
367 = info
->saved_regs
[IRP_REGNUM
];
368 info
->saved_regs
[gdbarch_sp_regnum (gdbarch
)].set_addr (addr
+ (24 * 4));
373 /* R0 to R13 are stored in order at offset (1 * 4) in
375 for (i
= 0; i
<= 13; i
++)
376 info
->saved_regs
[i
].set_addr (addr
+ ((i
+ 1) * 4));
378 info
->saved_regs
[ACR_REGNUM
].set_addr (addr
+ (15 * 4));
379 info
->saved_regs
[SRS_REGNUM
].set_addr (addr
+ (16 * 4));
380 info
->saved_regs
[MOF_REGNUM
].set_addr (addr
+ (17 * 4));
381 info
->saved_regs
[SPC_REGNUM
].set_addr (addr
+ (18 * 4));
382 info
->saved_regs
[CCS_REGNUM
].set_addr (addr
+ (19 * 4));
383 info
->saved_regs
[SRP_REGNUM
].set_addr (addr
+ (20 * 4));
384 info
->saved_regs
[ERP_REGNUM
].set_addr (addr
+ (21 * 4));
385 info
->saved_regs
[EXS_REGNUM
].set_addr (addr
+ (22 * 4));
386 info
->saved_regs
[EDA_REGNUM
].set_addr (addr
+ (23 * 4));
388 /* FIXME: If ERP is in a delay slot at this point then the PC will
389 be wrong at this point. This problem manifests itself in the
390 sigaltstack.exp test case, which occasionally generates FAILs when
391 the signal is received while in a delay slot.
393 This could be solved by a couple of read_memory_unsigned_integer and a
394 trad_frame_set_value. */
395 info
->saved_regs
[gdbarch_pc_regnum (gdbarch
)]
396 = info
->saved_regs
[ERP_REGNUM
];
398 info
->saved_regs
[gdbarch_sp_regnum (gdbarch
)].set_addr (addr
+ (25 * 4));
405 cris_sigtramp_frame_this_id (struct frame_info
*this_frame
, void **this_cache
,
406 struct frame_id
*this_id
)
408 struct cris_unwind_cache
*cache
=
409 cris_sigtramp_frame_unwind_cache (this_frame
, this_cache
);
410 (*this_id
) = frame_id_build (cache
->base
, get_frame_pc (this_frame
));
413 /* Forward declaration. */
415 static struct value
*cris_frame_prev_register (struct frame_info
*this_frame
,
416 void **this_cache
, int regnum
);
417 static struct value
*
418 cris_sigtramp_frame_prev_register (struct frame_info
*this_frame
,
419 void **this_cache
, int regnum
)
421 /* Make sure we've initialized the cache. */
422 cris_sigtramp_frame_unwind_cache (this_frame
, this_cache
);
423 return cris_frame_prev_register (this_frame
, this_cache
, regnum
);
427 cris_sigtramp_frame_sniffer (const struct frame_unwind
*self
,
428 struct frame_info
*this_frame
,
431 if (cris_sigtramp_start (this_frame
)
432 || cris_rt_sigtramp_start (this_frame
))
438 static const struct frame_unwind cris_sigtramp_frame_unwind
=
442 default_frame_unwind_stop_reason
,
443 cris_sigtramp_frame_this_id
,
444 cris_sigtramp_frame_prev_register
,
446 cris_sigtramp_frame_sniffer
450 crisv32_single_step_through_delay (struct gdbarch
*gdbarch
,
451 struct frame_info
*this_frame
)
453 cris_gdbarch_tdep
*tdep
= gdbarch_tdep
<cris_gdbarch_tdep
> (gdbarch
);
457 if (tdep
->cris_mode
== cris_mode_guru
)
458 erp
= get_frame_register_unsigned (this_frame
, NRP_REGNUM
);
460 erp
= get_frame_register_unsigned (this_frame
, ERP_REGNUM
);
464 /* In delay slot - check if there's a breakpoint at the preceding
466 if (breakpoint_here_p (get_frame_address_space (this_frame
), erp
& ~0x1))
472 /* The instruction environment needed to find single-step breakpoints. */
475 struct instruction_environment
477 unsigned long reg
[NUM_GENREGS
];
478 unsigned long preg
[NUM_SPECREGS
];
479 unsigned long branch_break_address
;
480 unsigned long delay_slot_pc
;
481 unsigned long prefix_value
;
486 int delay_slot_pc_active
;
488 int disable_interrupt
;
489 enum bfd_endian byte_order
;
492 /* Machine-dependencies in CRIS for opcodes. */
494 /* Instruction sizes. */
495 enum cris_instruction_sizes
502 /* Addressing modes. */
503 enum cris_addressing_modes
510 /* Prefix addressing modes. */
511 enum cris_prefix_addressing_modes
513 PREFIX_INDEX_MODE
= 2,
514 PREFIX_ASSIGN_MODE
= 3,
516 /* Handle immediate byte offset addressing mode prefix format. */
517 PREFIX_OFFSET_MODE
= 2
520 /* Masks for opcodes. */
521 enum cris_opcode_masks
523 BRANCH_SIGNED_SHORT_OFFSET_MASK
= 0x1,
524 SIGNED_EXTEND_BIT_MASK
= 0x2,
525 SIGNED_BYTE_MASK
= 0x80,
526 SIGNED_BYTE_EXTEND_MASK
= 0xFFFFFF00,
527 SIGNED_WORD_MASK
= 0x8000,
528 SIGNED_WORD_EXTEND_MASK
= 0xFFFF0000,
529 SIGNED_DWORD_MASK
= 0x80000000,
530 SIGNED_QUICK_VALUE_MASK
= 0x20,
531 SIGNED_QUICK_VALUE_EXTEND_MASK
= 0xFFFFFFC0
534 /* Functions for opcodes. The general form of the ETRAX 16-bit instruction:
542 cris_get_operand2 (unsigned short insn
)
544 return ((insn
& 0xF000) >> 12);
548 cris_get_mode (unsigned short insn
)
550 return ((insn
& 0x0C00) >> 10);
554 cris_get_opcode (unsigned short insn
)
556 return ((insn
& 0x03C0) >> 6);
560 cris_get_size (unsigned short insn
)
562 return ((insn
& 0x0030) >> 4);
566 cris_get_operand1 (unsigned short insn
)
568 return (insn
& 0x000F);
571 /* Additional functions in order to handle opcodes. */
574 cris_get_quick_value (unsigned short insn
)
576 return (insn
& 0x003F);
580 cris_get_bdap_quick_offset (unsigned short insn
)
582 return (insn
& 0x00FF);
586 cris_get_branch_short_offset (unsigned short insn
)
588 return (insn
& 0x00FF);
592 cris_get_asr_shift_steps (unsigned long value
)
594 return (value
& 0x3F);
598 cris_get_clear_size (unsigned short insn
)
600 return ((insn
) & 0xC000);
604 cris_is_signed_extend_bit_on (unsigned short insn
)
606 return (((insn
) & 0x20) == 0x20);
610 cris_is_xflag_bit_on (unsigned short insn
)
612 return (((insn
) & 0x1000) == 0x1000);
616 cris_set_size_to_dword (unsigned short *insn
)
623 cris_get_signed_offset (unsigned short insn
)
625 return ((signed char) (insn
& 0x00FF));
628 /* Calls an op function given the op-type, working on the insn and the
630 static void cris_gdb_func (struct gdbarch
*, enum cris_op_type
, unsigned short,
633 static struct gdbarch
*cris_gdbarch_init (struct gdbarch_info
,
634 struct gdbarch_list
*);
636 static void cris_dump_tdep (struct gdbarch
*, struct ui_file
*);
638 static void set_cris_version (const char *ignore_args
, int from_tty
,
639 struct cmd_list_element
*c
);
641 static void set_cris_mode (const char *ignore_args
, int from_tty
,
642 struct cmd_list_element
*c
);
644 static void set_cris_dwarf2_cfi (const char *ignore_args
, int from_tty
,
645 struct cmd_list_element
*c
);
647 static CORE_ADDR
cris_scan_prologue (CORE_ADDR pc
,
648 struct frame_info
*this_frame
,
649 struct cris_unwind_cache
*info
);
651 static CORE_ADDR
crisv32_scan_prologue (CORE_ADDR pc
,
652 struct frame_info
*this_frame
,
653 struct cris_unwind_cache
*info
);
655 /* When arguments must be pushed onto the stack, they go on in reverse
656 order. The below implements a FILO (stack) to do this.
657 Copied from d10v-tdep.c. */
659 struct cris_stack_item
662 struct cris_stack_item
*prev
;
666 static struct cris_stack_item
*
667 push_stack_item (struct cris_stack_item
*prev
, const gdb_byte
*contents
,
670 struct cris_stack_item
*si
= XNEW (struct cris_stack_item
);
671 si
->data
= (gdb_byte
*) xmalloc (len
);
674 memcpy (si
->data
, contents
, len
);
678 static struct cris_stack_item
*
679 pop_stack_item (struct cris_stack_item
*si
)
681 struct cris_stack_item
*dead
= si
;
688 /* Put here the code to store, into fi->saved_regs, the addresses of
689 the saved registers of frame described by FRAME_INFO. This
690 includes special registers such as pc and fp saved in special ways
691 in the stack frame. sp is even more special: the address we return
692 for it IS the sp for the next frame. */
694 static struct cris_unwind_cache
*
695 cris_frame_unwind_cache (struct frame_info
*this_frame
,
696 void **this_prologue_cache
)
698 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
699 cris_gdbarch_tdep
*tdep
= gdbarch_tdep
<cris_gdbarch_tdep
> (gdbarch
);
700 struct cris_unwind_cache
*info
;
702 if ((*this_prologue_cache
))
703 return (struct cris_unwind_cache
*) (*this_prologue_cache
);
705 info
= FRAME_OBSTACK_ZALLOC (struct cris_unwind_cache
);
706 (*this_prologue_cache
) = info
;
707 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
709 /* Zero all fields. */
715 info
->uses_frame
= 0;
717 info
->leaf_function
= 0;
719 /* Prologue analysis does the rest... */
720 if (tdep
->cris_version
== 32)
721 crisv32_scan_prologue (get_frame_func (this_frame
), this_frame
, info
);
723 cris_scan_prologue (get_frame_func (this_frame
), this_frame
, info
);
728 /* Given a GDB frame, determine the address of the calling function's
729 frame. This will be used to create a new GDB frame struct. */
732 cris_frame_this_id (struct frame_info
*this_frame
,
733 void **this_prologue_cache
,
734 struct frame_id
*this_id
)
736 struct cris_unwind_cache
*info
737 = cris_frame_unwind_cache (this_frame
, this_prologue_cache
);
742 /* The FUNC is easy. */
743 func
= get_frame_func (this_frame
);
745 /* Hopefully the prologue analysis either correctly determined the
746 frame's base (which is the SP from the previous frame), or set
747 that base to "NULL". */
748 base
= info
->prev_sp
;
752 id
= frame_id_build (base
, func
);
757 static struct value
*
758 cris_frame_prev_register (struct frame_info
*this_frame
,
759 void **this_prologue_cache
, int regnum
)
761 struct cris_unwind_cache
*info
762 = cris_frame_unwind_cache (this_frame
, this_prologue_cache
);
763 return trad_frame_get_prev_register (this_frame
, info
->saved_regs
, regnum
);
767 cris_frame_align (struct gdbarch
*gdbarch
, CORE_ADDR sp
)
769 /* Align to the size of an instruction (so that they can safely be
770 pushed onto the stack). */
775 cris_push_dummy_code (struct gdbarch
*gdbarch
,
776 CORE_ADDR sp
, CORE_ADDR funaddr
,
777 struct value
**args
, int nargs
,
778 struct type
*value_type
,
779 CORE_ADDR
*real_pc
, CORE_ADDR
*bp_addr
,
780 struct regcache
*regcache
)
782 /* Allocate space sufficient for a breakpoint. */
784 /* Store the address of that breakpoint */
786 /* CRIS always starts the call at the callee's entry point. */
792 cris_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
793 struct regcache
*regcache
, CORE_ADDR bp_addr
,
794 int nargs
, struct value
**args
, CORE_ADDR sp
,
795 function_call_return_method return_method
,
796 CORE_ADDR struct_addr
)
798 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
802 struct cris_stack_item
*si
= NULL
;
804 /* Push the return address. */
805 regcache_cooked_write_unsigned (regcache
, SRP_REGNUM
, bp_addr
);
807 /* Are we returning a value using a structure return or a normal value
808 return? struct_addr is the address of the reserved space for the return
809 structure to be written on the stack. */
810 if (return_method
== return_method_struct
)
811 regcache_cooked_write_unsigned (regcache
, STR_REGNUM
, struct_addr
);
813 /* Now load as many as possible of the first arguments into registers,
814 and push the rest onto the stack. */
815 argreg
= ARG1_REGNUM
;
817 for (argnum
= 0; argnum
< nargs
; argnum
++)
824 len
= value_type (args
[argnum
])->length ();
825 val
= value_contents (args
[argnum
]).data ();
827 /* How may registers worth of storage do we need for this argument? */
828 reg_demand
= (len
/ 4) + (len
% 4 != 0 ? 1 : 0);
830 if (len
<= (2 * 4) && (argreg
+ reg_demand
- 1 <= ARG4_REGNUM
))
832 /* Data passed by value. Fits in available register(s). */
833 for (i
= 0; i
< reg_demand
; i
++)
835 regcache
->cooked_write (argreg
, val
);
840 else if (len
<= (2 * 4) && argreg
<= ARG4_REGNUM
)
842 /* Data passed by value. Does not fit in available register(s).
843 Use the register(s) first, then the stack. */
844 for (i
= 0; i
< reg_demand
; i
++)
846 if (argreg
<= ARG4_REGNUM
)
848 regcache
->cooked_write (argreg
, val
);
854 /* Push item for later so that pushed arguments
855 come in the right order. */
856 si
= push_stack_item (si
, val
, 4);
861 else if (len
> (2 * 4))
863 /* Data passed by reference. Push copy of data onto stack
864 and pass pointer to this copy as argument. */
865 sp
= (sp
- len
) & ~3;
866 write_memory (sp
, val
, len
);
868 if (argreg
<= ARG4_REGNUM
)
870 regcache_cooked_write_unsigned (regcache
, argreg
, sp
);
876 store_unsigned_integer (buf
, 4, byte_order
, sp
);
877 si
= push_stack_item (si
, buf
, 4);
882 /* Data passed by value. No available registers. Put it on
884 si
= push_stack_item (si
, val
, len
);
890 /* fp_arg must be word-aligned (i.e., don't += len) to match
891 the function prologue. */
892 sp
= (sp
- si
->len
) & ~3;
893 write_memory (sp
, si
->data
, si
->len
);
894 si
= pop_stack_item (si
);
897 /* Finally, update the SP register. */
898 regcache_cooked_write_unsigned (regcache
, gdbarch_sp_regnum (gdbarch
), sp
);
903 static const struct frame_unwind cris_frame_unwind
=
907 default_frame_unwind_stop_reason
,
909 cris_frame_prev_register
,
911 default_frame_sniffer
915 cris_frame_base_address (struct frame_info
*this_frame
, void **this_cache
)
917 struct cris_unwind_cache
*info
918 = cris_frame_unwind_cache (this_frame
, this_cache
);
922 static const struct frame_base cris_frame_base
=
925 cris_frame_base_address
,
926 cris_frame_base_address
,
927 cris_frame_base_address
930 /* Frames information. The definition of the struct frame_info is
934 enum frame_type type;
938 If the compilation option -fno-omit-frame-pointer is present the
939 variable frame will be set to the content of R8 which is the frame
942 The variable pc contains the address where execution is performed
943 in the present frame. The innermost frame contains the current content
944 of the register PC. All other frames contain the content of the
945 register PC in the next frame.
947 The variable `type' indicates the frame's type: normal, SIGTRAMP
948 (associated with a signal handler), dummy (associated with a dummy
951 The variable return_pc contains the address where execution should be
952 resumed when the present frame has finished, the return address.
954 The variable leaf_function is 1 if the return address is in the register
955 SRP, and 0 if it is on the stack.
957 Prologue instructions C-code.
958 The prologue may consist of (-fno-omit-frame-pointer)
962 move.d sp,r8 move.d sp,r8
964 movem rY,[sp] movem rY,[sp]
965 move.S rZ,[r8-U] move.S rZ,[r8-U]
967 where 1 is a non-terminal function, and 2 is a leaf-function.
969 Note that this assumption is extremely brittle, and will break at the
970 slightest change in GCC's prologue.
972 If local variables are declared or register contents are saved on stack
973 the subq-instruction will be present with X as the number of bytes
974 needed for storage. The reshuffle with respect to r8 may be performed
975 with any size S (b, w, d) and any of the general registers Z={0..13}.
976 The offset U should be representable by a signed 8-bit value in all cases.
977 Thus, the prefix word is assumed to be immediate byte offset mode followed
978 by another word containing the instruction.
987 Prologue instructions C++-code.
988 Case 1) and 2) in the C-code may be followed by
994 move.S [r8+U],rZ ; P4
996 if any of the call parameters are stored. The host expects these
997 instructions to be executed in order to get the call parameters right. */
999 /* Examine the prologue of a function. The variable ip is the address of
1000 the first instruction of the prologue. The variable limit is the address
1001 of the first instruction after the prologue. The variable fi contains the
1002 information in struct frame_info. The variable frameless_p controls whether
1003 the entire prologue is examined (0) or just enough instructions to
1004 determine that it is a prologue (1). */
1007 cris_scan_prologue (CORE_ADDR pc
, struct frame_info
*this_frame
,
1008 struct cris_unwind_cache
*info
)
1010 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1011 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1013 /* Present instruction. */
1014 unsigned short insn
;
1016 /* Next instruction, lookahead. */
1017 unsigned short insn_next
;
1020 /* Number of byte on stack used for local variables and movem. */
1023 /* Highest register number in a movem. */
1026 /* move.d r<source_register>,rS */
1027 short source_register
;
1032 /* This frame is with respect to a leaf until a push srp is found. */
1035 info
->leaf_function
= 1;
1038 /* Assume nothing on stack. */
1042 /* If we were called without a this_frame, that means we were called
1043 from cris_skip_prologue which already tried to find the end of the
1044 prologue through the symbol information. 64 instructions past current
1045 pc is arbitrarily chosen, but at least it means we'll stop eventually. */
1046 limit
= this_frame
? get_frame_pc (this_frame
) : pc
+ 64;
1048 /* Find the prologue instructions. */
1049 while (pc
> 0 && pc
< limit
)
1051 insn
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1055 /* push <reg> 32 bit instruction. */
1056 insn_next
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1058 regno
= cris_get_operand2 (insn_next
);
1061 info
->sp_offset
+= 4;
1063 /* This check, meant to recognize srp, used to be regno ==
1064 (SRP_REGNUM - NUM_GENREGS), but that covers r11 also. */
1065 if (insn_next
== 0xBE7E)
1069 info
->leaf_function
= 0;
1072 else if (insn_next
== 0x8FEE)
1077 info
->r8_offset
= info
->sp_offset
;
1081 else if (insn
== 0x866E)
1086 info
->uses_frame
= 1;
1090 else if (cris_get_operand2 (insn
) == gdbarch_sp_regnum (gdbarch
)
1091 && cris_get_mode (insn
) == 0x0000
1092 && cris_get_opcode (insn
) == 0x000A)
1097 info
->sp_offset
+= cris_get_quick_value (insn
);
1100 else if (cris_get_mode (insn
) == 0x0002
1101 && cris_get_opcode (insn
) == 0x000F
1102 && cris_get_size (insn
) == 0x0003
1103 && cris_get_operand1 (insn
) == gdbarch_sp_regnum (gdbarch
))
1105 /* movem r<regsave>,[sp] */
1106 regsave
= cris_get_operand2 (insn
);
1108 else if (cris_get_operand2 (insn
) == gdbarch_sp_regnum (gdbarch
)
1109 && ((insn
& 0x0F00) >> 8) == 0x0001
1110 && (cris_get_signed_offset (insn
) < 0))
1112 /* Immediate byte offset addressing prefix word with sp as base
1113 register. Used for CRIS v8 i.e. ETRAX 100 and newer if <val>
1114 is between 64 and 128.
1115 movem r<regsave>,[sp=sp-<val>] */
1118 info
->sp_offset
+= -cris_get_signed_offset (insn
);
1120 insn_next
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1122 if (cris_get_mode (insn_next
) == PREFIX_ASSIGN_MODE
1123 && cris_get_opcode (insn_next
) == 0x000F
1124 && cris_get_size (insn_next
) == 0x0003
1125 && cris_get_operand1 (insn_next
) == gdbarch_sp_regnum
1128 regsave
= cris_get_operand2 (insn_next
);
1132 /* The prologue ended before the limit was reached. */
1137 else if (cris_get_mode (insn
) == 0x0001
1138 && cris_get_opcode (insn
) == 0x0009
1139 && cris_get_size (insn
) == 0x0002)
1141 /* move.d r<10..13>,r<0..15> */
1142 source_register
= cris_get_operand1 (insn
);
1144 /* FIXME? In the glibc solibs, the prologue might contain something
1145 like (this example taken from relocate_doit):
1147 sub.d 0xfffef426,$r0
1148 which isn't covered by the source_register check below. Question
1149 is whether to add a check for this combo, or make better use of
1150 the limit variable instead. */
1151 if (source_register
< ARG1_REGNUM
|| source_register
> ARG4_REGNUM
)
1153 /* The prologue ended before the limit was reached. */
1158 else if (cris_get_operand2 (insn
) == CRIS_FP_REGNUM
1159 /* The size is a fixed-size. */
1160 && ((insn
& 0x0F00) >> 8) == 0x0001
1161 /* A negative offset. */
1162 && (cris_get_signed_offset (insn
) < 0))
1164 /* move.S rZ,[r8-U] (?) */
1165 insn_next
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1167 regno
= cris_get_operand2 (insn_next
);
1168 if ((regno
>= 0 && regno
< gdbarch_sp_regnum (gdbarch
))
1169 && cris_get_mode (insn_next
) == PREFIX_OFFSET_MODE
1170 && cris_get_opcode (insn_next
) == 0x000F)
1172 /* move.S rZ,[r8-U] */
1177 /* The prologue ended before the limit was reached. */
1182 else if (cris_get_operand2 (insn
) == CRIS_FP_REGNUM
1183 /* The size is a fixed-size. */
1184 && ((insn
& 0x0F00) >> 8) == 0x0001
1185 /* A positive offset. */
1186 && (cris_get_signed_offset (insn
) > 0))
1188 /* move.S [r8+U],rZ (?) */
1189 insn_next
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1191 regno
= cris_get_operand2 (insn_next
);
1192 if ((regno
>= 0 && regno
< gdbarch_sp_regnum (gdbarch
))
1193 && cris_get_mode (insn_next
) == PREFIX_OFFSET_MODE
1194 && cris_get_opcode (insn_next
) == 0x0009
1195 && cris_get_operand1 (insn_next
) == regno
)
1197 /* move.S [r8+U],rZ */
1202 /* The prologue ended before the limit was reached. */
1209 /* The prologue ended before the limit was reached. */
1215 /* We only want to know the end of the prologue when this_frame and info
1216 are NULL (called from cris_skip_prologue i.e.). */
1217 if (this_frame
== NULL
&& info
== NULL
)
1222 info
->size
= info
->sp_offset
;
1224 /* Compute the previous frame's stack pointer (which is also the
1225 frame's ID's stack address), and this frame's base pointer. */
1226 if (info
->uses_frame
)
1229 /* The SP was moved to the FP. This indicates that a new frame
1230 was created. Get THIS frame's FP value by unwinding it from
1232 this_base
= get_frame_register_unsigned (this_frame
, CRIS_FP_REGNUM
);
1233 info
->base
= this_base
;
1234 info
->saved_regs
[CRIS_FP_REGNUM
].set_addr (info
->base
);
1236 /* The FP points at the last saved register. Adjust the FP back
1237 to before the first saved register giving the SP. */
1238 info
->prev_sp
= info
->base
+ info
->r8_offset
;
1243 /* Assume that the FP is this frame's SP but with that pushed
1244 stack space added back. */
1245 this_base
= get_frame_register_unsigned (this_frame
,
1246 gdbarch_sp_regnum (gdbarch
));
1247 info
->base
= this_base
;
1248 info
->prev_sp
= info
->base
+ info
->size
;
1251 /* Calculate the addresses for the saved registers on the stack. */
1252 /* FIXME: The address calculation should really be done on the fly while
1253 we're analyzing the prologue (we only hold one regsave value as it is
1255 val
= info
->sp_offset
;
1257 for (regno
= regsave
; regno
>= 0; regno
--)
1259 info
->saved_regs
[regno
].set_addr (info
->base
+ info
->r8_offset
- val
);
1263 /* The previous frame's SP needed to be computed. Save the computed
1265 info
->saved_regs
[gdbarch_sp_regnum (gdbarch
)].set_value (info
->prev_sp
);
1267 if (!info
->leaf_function
)
1269 /* SRP saved on the stack. But where? */
1270 if (info
->r8_offset
== 0)
1272 /* R8 not pushed yet. */
1273 info
->saved_regs
[SRP_REGNUM
].set_addr (info
->base
);
1277 /* R8 pushed, but SP may or may not be moved to R8 yet. */
1278 info
->saved_regs
[SRP_REGNUM
].set_addr (info
->base
+ 4);
1282 /* The PC is found in SRP (the actual register or located on the stack). */
1283 info
->saved_regs
[gdbarch_pc_regnum (gdbarch
)]
1284 = info
->saved_regs
[SRP_REGNUM
];
1290 crisv32_scan_prologue (CORE_ADDR pc
, struct frame_info
*this_frame
,
1291 struct cris_unwind_cache
*info
)
1293 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1296 /* Unlike the CRISv10 prologue scanner (cris_scan_prologue), this is not
1297 meant to be a full-fledged prologue scanner. It is only needed for
1298 the cases where we end up in code always lacking DWARF-2 CFI, notably:
1300 * PLT stubs (library calls)
1302 * signal trampolines
1304 For those cases, it is assumed that there is no actual prologue; that
1305 the stack pointer is not adjusted, and (as a consequence) the return
1306 address is not pushed onto the stack. */
1308 /* We only want to know the end of the prologue when this_frame and info
1309 are NULL (called from cris_skip_prologue i.e.). */
1310 if (this_frame
== NULL
&& info
== NULL
)
1315 /* The SP is assumed to be unaltered. */
1316 this_base
= get_frame_register_unsigned (this_frame
,
1317 gdbarch_sp_regnum (gdbarch
));
1318 info
->base
= this_base
;
1319 info
->prev_sp
= this_base
;
1321 /* The PC is assumed to be found in SRP. */
1322 info
->saved_regs
[gdbarch_pc_regnum (gdbarch
)]
1323 = info
->saved_regs
[SRP_REGNUM
];
1328 /* Advance pc beyond any function entry prologue instructions at pc
1329 to reach some "real" code. */
1331 /* Given a PC value corresponding to the start of a function, return the PC
1332 of the first instruction after the function prologue. */
1335 cris_skip_prologue (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
1337 cris_gdbarch_tdep
*tdep
= gdbarch_tdep
<cris_gdbarch_tdep
> (gdbarch
);
1338 CORE_ADDR func_addr
, func_end
;
1339 struct symtab_and_line sal
;
1340 CORE_ADDR pc_after_prologue
;
1342 /* If we have line debugging information, then the end of the prologue
1343 should the first assembly instruction of the first source line. */
1344 if (find_pc_partial_function (pc
, NULL
, &func_addr
, &func_end
))
1346 sal
= find_pc_line (func_addr
, 0);
1347 if (sal
.end
> 0 && sal
.end
< func_end
)
1351 if (tdep
->cris_version
== 32)
1352 pc_after_prologue
= crisv32_scan_prologue (pc
, NULL
, NULL
);
1354 pc_after_prologue
= cris_scan_prologue (pc
, NULL
, NULL
);
1356 return pc_after_prologue
;
1359 /* Implement the breakpoint_kind_from_pc gdbarch method. */
1362 cris_breakpoint_kind_from_pc (struct gdbarch
*gdbarch
, CORE_ADDR
*pcptr
)
1367 /* Implement the sw_breakpoint_from_kind gdbarch method. */
1369 static const gdb_byte
*
1370 cris_sw_breakpoint_from_kind (struct gdbarch
*gdbarch
, int kind
, int *size
)
1372 cris_gdbarch_tdep
*tdep
= gdbarch_tdep
<cris_gdbarch_tdep
> (gdbarch
);
1373 static unsigned char break8_insn
[] = {0x38, 0xe9};
1374 static unsigned char break15_insn
[] = {0x3f, 0xe9};
1378 if (tdep
->cris_mode
== cris_mode_guru
)
1379 return break15_insn
;
1384 /* Returns 1 if spec_reg is applicable to the current gdbarch's CRIS version,
1388 cris_spec_reg_applicable (struct gdbarch
*gdbarch
,
1389 struct cris_spec_reg spec_reg
)
1391 cris_gdbarch_tdep
*tdep
= gdbarch_tdep
<cris_gdbarch_tdep
> (gdbarch
);
1392 unsigned int version
= tdep
->cris_version
;
1394 switch (spec_reg
.applicable_version
)
1396 case cris_ver_version_all
:
1398 case cris_ver_warning
:
1399 /* Indeterminate/obsolete. */
1402 return in_inclusive_range (version
, 0U, 3U);
1404 return (version
>= 3);
1406 return in_inclusive_range (version
, 8U, 9U);
1408 return (version
>= 8);
1409 case cris_ver_v0_10
:
1410 return in_inclusive_range (version
, 0U, 10U);
1411 case cris_ver_v3_10
:
1412 return in_inclusive_range (version
, 3U, 10U);
1413 case cris_ver_v8_10
:
1414 return in_inclusive_range (version
, 8U, 10U);
1416 return (version
== 10);
1418 return (version
>= 10);
1420 return (version
>= 32);
1422 /* Invalid cris version. */
1427 /* Returns the register size in unit byte. Returns 0 for an unimplemented
1428 register, -1 for an invalid register. */
1431 cris_register_size (struct gdbarch
*gdbarch
, int regno
)
1436 if (regno
>= 0 && regno
< NUM_GENREGS
)
1438 /* General registers (R0 - R15) are 32 bits. */
1441 else if (regno
>= NUM_GENREGS
&& regno
< (NUM_GENREGS
+ NUM_SPECREGS
))
1443 /* Special register (R16 - R31). cris_spec_regs is zero-based.
1444 Adjust regno accordingly. */
1445 spec_regno
= regno
- NUM_GENREGS
;
1447 for (i
= 0; cris_spec_regs
[i
].name
!= NULL
; i
++)
1449 if (cris_spec_regs
[i
].number
== spec_regno
1450 && cris_spec_reg_applicable (gdbarch
, cris_spec_regs
[i
]))
1451 /* Go with the first applicable register. */
1452 return cris_spec_regs
[i
].reg_size
;
1454 /* Special register not applicable to this CRIS version. */
1457 else if (regno
>= gdbarch_pc_regnum (gdbarch
)
1458 && regno
< gdbarch_num_regs (gdbarch
))
1460 /* This will apply to CRISv32 only where there are additional registers
1461 after the special registers (pseudo PC and support registers). */
1469 /* Nonzero if regno should not be fetched from the target. This is the case
1470 for unimplemented (size 0) and non-existant registers. */
1473 cris_cannot_fetch_register (struct gdbarch
*gdbarch
, int regno
)
1475 return ((regno
< 0 || regno
>= gdbarch_num_regs (gdbarch
))
1476 || (cris_register_size (gdbarch
, regno
) == 0));
1479 /* Nonzero if regno should not be written to the target, for various
1483 cris_cannot_store_register (struct gdbarch
*gdbarch
, int regno
)
1485 /* There are three kinds of registers we refuse to write to.
1486 1. Those that not implemented.
1487 2. Those that are read-only (depends on the processor mode).
1488 3. Those registers to which a write has no effect. */
1491 || regno
>= gdbarch_num_regs (gdbarch
)
1492 || cris_register_size (gdbarch
, regno
) == 0)
1493 /* Not implemented. */
1496 else if (regno
== VR_REGNUM
)
1500 else if (regno
== P0_REGNUM
|| regno
== P4_REGNUM
|| regno
== P8_REGNUM
)
1501 /* Writing has no effect. */
1504 /* IBR, BAR, BRP and IRP are read-only in user mode. Let the debug
1505 agent decide whether they are writable. */
1510 /* Nonzero if regno should not be fetched from the target. This is the case
1511 for unimplemented (size 0) and non-existant registers. */
1514 crisv32_cannot_fetch_register (struct gdbarch
*gdbarch
, int regno
)
1516 return ((regno
< 0 || regno
>= gdbarch_num_regs (gdbarch
))
1517 || (cris_register_size (gdbarch
, regno
) == 0));
1520 /* Nonzero if regno should not be written to the target, for various
1524 crisv32_cannot_store_register (struct gdbarch
*gdbarch
, int regno
)
1526 /* There are three kinds of registers we refuse to write to.
1527 1. Those that not implemented.
1528 2. Those that are read-only (depends on the processor mode).
1529 3. Those registers to which a write has no effect. */
1532 || regno
>= gdbarch_num_regs (gdbarch
)
1533 || cris_register_size (gdbarch
, regno
) == 0)
1534 /* Not implemented. */
1537 else if (regno
== VR_REGNUM
)
1541 else if (regno
== BZ_REGNUM
|| regno
== WZ_REGNUM
|| regno
== DZ_REGNUM
)
1542 /* Writing has no effect. */
1545 /* Many special registers are read-only in user mode. Let the debug
1546 agent decide whether they are writable. */
1551 /* Return the GDB type (defined in gdbtypes.c) for the "standard" data type
1552 of data in register regno. */
1554 static struct type
*
1555 cris_register_type (struct gdbarch
*gdbarch
, int regno
)
1557 if (regno
== gdbarch_pc_regnum (gdbarch
))
1558 return builtin_type (gdbarch
)->builtin_func_ptr
;
1559 else if (regno
== gdbarch_sp_regnum (gdbarch
)
1560 || regno
== CRIS_FP_REGNUM
)
1561 return builtin_type (gdbarch
)->builtin_data_ptr
;
1562 else if ((regno
>= 0 && regno
< gdbarch_sp_regnum (gdbarch
))
1563 || (regno
>= MOF_REGNUM
&& regno
<= USP_REGNUM
))
1564 /* Note: R8 taken care of previous clause. */
1565 return builtin_type (gdbarch
)->builtin_uint32
;
1566 else if (regno
>= P4_REGNUM
&& regno
<= CCR_REGNUM
)
1567 return builtin_type (gdbarch
)->builtin_uint16
;
1568 else if (regno
>= P0_REGNUM
&& regno
<= VR_REGNUM
)
1569 return builtin_type (gdbarch
)->builtin_uint8
;
1571 /* Invalid (unimplemented) register. */
1572 return builtin_type (gdbarch
)->builtin_int0
;
1575 static struct type
*
1576 crisv32_register_type (struct gdbarch
*gdbarch
, int regno
)
1578 if (regno
== gdbarch_pc_regnum (gdbarch
))
1579 return builtin_type (gdbarch
)->builtin_func_ptr
;
1580 else if (regno
== gdbarch_sp_regnum (gdbarch
)
1581 || regno
== CRIS_FP_REGNUM
)
1582 return builtin_type (gdbarch
)->builtin_data_ptr
;
1583 else if ((regno
>= 0 && regno
<= ACR_REGNUM
)
1584 || (regno
>= EXS_REGNUM
&& regno
<= SPC_REGNUM
)
1585 || (regno
== PID_REGNUM
)
1586 || (regno
>= S0_REGNUM
&& regno
<= S15_REGNUM
))
1587 /* Note: R8 and SP taken care of by previous clause. */
1588 return builtin_type (gdbarch
)->builtin_uint32
;
1589 else if (regno
== WZ_REGNUM
)
1590 return builtin_type (gdbarch
)->builtin_uint16
;
1591 else if (regno
== BZ_REGNUM
|| regno
== VR_REGNUM
|| regno
== SRS_REGNUM
)
1592 return builtin_type (gdbarch
)->builtin_uint8
;
1595 /* Invalid (unimplemented) register. Should not happen as there are
1596 no unimplemented CRISv32 registers. */
1597 warning (_("crisv32_register_type: unknown regno %d"), regno
);
1598 return builtin_type (gdbarch
)->builtin_int0
;
1602 /* Stores a function return value of type type, where valbuf is the address
1603 of the value to be stored. */
1605 /* In the CRIS ABI, R10 and R11 are used to store return values. */
1608 cris_store_return_value (struct type
*type
, struct regcache
*regcache
,
1609 const gdb_byte
*valbuf
)
1611 struct gdbarch
*gdbarch
= regcache
->arch ();
1612 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1614 int len
= type
->length ();
1618 /* Put the return value in R10. */
1619 val
= extract_unsigned_integer (valbuf
, len
, byte_order
);
1620 regcache_cooked_write_unsigned (regcache
, ARG1_REGNUM
, val
);
1624 /* Put the return value in R10 and R11. */
1625 val
= extract_unsigned_integer (valbuf
, 4, byte_order
);
1626 regcache_cooked_write_unsigned (regcache
, ARG1_REGNUM
, val
);
1627 val
= extract_unsigned_integer (valbuf
+ 4, len
- 4, byte_order
);
1628 regcache_cooked_write_unsigned (regcache
, ARG2_REGNUM
, val
);
1631 error (_("cris_store_return_value: type length too large."));
1634 /* Return the name of register regno as a string. Return NULL for an
1635 invalid or unimplemented register. */
1638 cris_special_register_name (struct gdbarch
*gdbarch
, int regno
)
1643 /* Special register (R16 - R31). cris_spec_regs is zero-based.
1644 Adjust regno accordingly. */
1645 spec_regno
= regno
- NUM_GENREGS
;
1647 /* Assume nothing about the layout of the cris_spec_regs struct
1649 for (i
= 0; cris_spec_regs
[i
].name
!= NULL
; i
++)
1651 if (cris_spec_regs
[i
].number
== spec_regno
1652 && cris_spec_reg_applicable (gdbarch
, cris_spec_regs
[i
]))
1653 /* Go with the first applicable register. */
1654 return cris_spec_regs
[i
].name
;
1656 /* Special register not applicable to this CRIS version. */
1661 cris_register_name (struct gdbarch
*gdbarch
, int regno
)
1663 static const char *cris_genreg_names
[] =
1664 { "r0", "r1", "r2", "r3", \
1665 "r4", "r5", "r6", "r7", \
1666 "r8", "r9", "r10", "r11", \
1667 "r12", "r13", "sp", "pc" };
1669 if (regno
>= 0 && regno
< NUM_GENREGS
)
1671 /* General register. */
1672 return cris_genreg_names
[regno
];
1674 else if (regno
>= NUM_GENREGS
&& regno
< gdbarch_num_regs (gdbarch
))
1676 return cris_special_register_name (gdbarch
, regno
);
1680 /* Invalid register. */
1686 crisv32_register_name (struct gdbarch
*gdbarch
, int regno
)
1688 static const char *crisv32_genreg_names
[] =
1689 { "r0", "r1", "r2", "r3", \
1690 "r4", "r5", "r6", "r7", \
1691 "r8", "r9", "r10", "r11", \
1692 "r12", "r13", "sp", "acr"
1695 static const char *crisv32_sreg_names
[] =
1696 { "s0", "s1", "s2", "s3", \
1697 "s4", "s5", "s6", "s7", \
1698 "s8", "s9", "s10", "s11", \
1699 "s12", "s13", "s14", "s15"
1702 if (regno
>= 0 && regno
< NUM_GENREGS
)
1704 /* General register. */
1705 return crisv32_genreg_names
[regno
];
1707 else if (regno
>= NUM_GENREGS
&& regno
< (NUM_GENREGS
+ NUM_SPECREGS
))
1709 return cris_special_register_name (gdbarch
, regno
);
1711 else if (regno
== gdbarch_pc_regnum (gdbarch
))
1715 else if (regno
>= S0_REGNUM
&& regno
<= S15_REGNUM
)
1717 return crisv32_sreg_names
[regno
- S0_REGNUM
];
1721 /* Invalid register. */
1726 /* Convert DWARF register number REG to the appropriate register
1727 number used by GDB. */
1730 cris_dwarf2_reg_to_regnum (struct gdbarch
*gdbarch
, int reg
)
1732 /* We need to re-map a couple of registers (SRP is 16 in Dwarf-2 register
1733 numbering, MOF is 18).
1734 Adapted from gcc/config/cris/cris.h. */
1735 static int cris_dwarf_regmap
[] = {
1747 if (reg
>= 0 && reg
< ARRAY_SIZE (cris_dwarf_regmap
))
1748 regnum
= cris_dwarf_regmap
[reg
];
1753 /* DWARF-2 frame support. */
1756 cris_dwarf2_frame_init_reg (struct gdbarch
*gdbarch
, int regnum
,
1757 struct dwarf2_frame_state_reg
*reg
,
1758 struct frame_info
*this_frame
)
1760 /* The return address column. */
1761 if (regnum
== gdbarch_pc_regnum (gdbarch
))
1762 reg
->how
= DWARF2_FRAME_REG_RA
;
1764 /* The call frame address. */
1765 else if (regnum
== gdbarch_sp_regnum (gdbarch
))
1766 reg
->how
= DWARF2_FRAME_REG_CFA
;
1769 /* Extract from an array regbuf containing the raw register state a function
1770 return value of type type, and copy that, in virtual format, into
1773 /* In the CRIS ABI, R10 and R11 are used to store return values. */
1776 cris_extract_return_value (struct type
*type
, struct regcache
*regcache
,
1779 struct gdbarch
*gdbarch
= regcache
->arch ();
1780 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1782 int len
= type
->length ();
1786 /* Get the return value from R10. */
1787 regcache_cooked_read_unsigned (regcache
, ARG1_REGNUM
, &val
);
1788 store_unsigned_integer (valbuf
, len
, byte_order
, val
);
1792 /* Get the return value from R10 and R11. */
1793 regcache_cooked_read_unsigned (regcache
, ARG1_REGNUM
, &val
);
1794 store_unsigned_integer (valbuf
, 4, byte_order
, val
);
1795 regcache_cooked_read_unsigned (regcache
, ARG2_REGNUM
, &val
);
1796 store_unsigned_integer (valbuf
+ 4, len
- 4, byte_order
, val
);
1799 error (_("cris_extract_return_value: type length too large"));
1802 /* Handle the CRIS return value convention. */
1804 static enum return_value_convention
1805 cris_return_value (struct gdbarch
*gdbarch
, struct value
*function
,
1806 struct type
*type
, struct regcache
*regcache
,
1807 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
1809 if (type
->code () == TYPE_CODE_STRUCT
1810 || type
->code () == TYPE_CODE_UNION
1811 || type
->length () > 8)
1812 /* Structs, unions, and anything larger than 8 bytes (2 registers)
1813 goes on the stack. */
1814 return RETURN_VALUE_STRUCT_CONVENTION
;
1817 cris_extract_return_value (type
, regcache
, readbuf
);
1819 cris_store_return_value (type
, regcache
, writebuf
);
1821 return RETURN_VALUE_REGISTER_CONVENTION
;
1824 /* Calculates a value that measures how good inst_args constraints an
1825 instruction. It stems from cris_constraint, found in cris-dis.c. */
1828 constraint (unsigned int insn
, const char *inst_args
,
1829 inst_env_type
*inst_env
)
1834 const gdb_byte
*s
= (const gdb_byte
*) inst_args
;
1840 if ((insn
& 0x30) == 0x30)
1845 /* A prefix operand. */
1846 if (inst_env
->prefix_found
)
1852 /* A "push" prefix. (This check was REMOVED by san 970921.) Check for
1853 valid "push" size. In case of special register, it may be != 4. */
1854 if (inst_env
->prefix_found
)
1860 retval
= (((insn
>> 0xC) & 0xF) == (insn
& 0xF));
1868 tmp
= (insn
>> 0xC) & 0xF;
1870 for (i
= 0; cris_spec_regs
[i
].name
!= NULL
; i
++)
1872 /* Since we match four bits, we will give a value of
1873 4 - 1 = 3 in a match. If there is a corresponding
1874 exact match of a special register in another pattern, it
1875 will get a value of 4, which will be higher. This should
1876 be correct in that an exact pattern would match better that
1878 Note that there is a reason for not returning zero; the
1879 pattern for "clear" is partly matched in the bit-pattern
1880 (the two lower bits must be zero), while the bit-pattern
1881 for a move from a special register is matched in the
1882 register constraint.
1883 This also means we will will have a race condition if
1884 there is a partly match in three bits in the bit pattern. */
1885 if (tmp
== cris_spec_regs
[i
].number
)
1892 if (cris_spec_regs
[i
].name
== NULL
)
1899 /* Returns the number of bits set in the variable value. */
1902 number_of_bits (unsigned int value
)
1904 int number_of_bits
= 0;
1908 number_of_bits
+= 1;
1909 value
&= (value
- 1);
1911 return number_of_bits
;
1914 /* Finds the address that should contain the single step breakpoint(s).
1915 It stems from code in cris-dis.c. */
1918 find_cris_op (unsigned short insn
, inst_env_type
*inst_env
)
1921 int max_level_of_match
= -1;
1922 int max_matched
= -1;
1925 for (i
= 0; cris_opcodes
[i
].name
!= NULL
; i
++)
1927 if (((cris_opcodes
[i
].match
& insn
) == cris_opcodes
[i
].match
)
1928 && ((cris_opcodes
[i
].lose
& insn
) == 0)
1929 /* Only CRISv10 instructions, please. */
1930 && (cris_opcodes
[i
].applicable_version
!= cris_ver_v32p
))
1932 level_of_match
= constraint (insn
, cris_opcodes
[i
].args
, inst_env
);
1933 if (level_of_match
>= 0)
1936 number_of_bits (cris_opcodes
[i
].match
| cris_opcodes
[i
].lose
);
1937 if (level_of_match
> max_level_of_match
)
1940 max_level_of_match
= level_of_match
;
1941 if (level_of_match
== 16)
1943 /* All bits matched, cannot find better. */
1953 /* Attempts to find single-step breakpoints. Returns -1 on failure which is
1954 actually an internal error. */
1957 find_step_target (struct regcache
*regcache
, inst_env_type
*inst_env
)
1961 unsigned short insn
;
1962 struct gdbarch
*gdbarch
= regcache
->arch ();
1963 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1965 /* Create a local register image and set the initial state. */
1966 for (i
= 0; i
< NUM_GENREGS
; i
++)
1969 (unsigned long) regcache_raw_get_unsigned (regcache
, i
);
1971 offset
= NUM_GENREGS
;
1972 for (i
= 0; i
< NUM_SPECREGS
; i
++)
1975 (unsigned long) regcache_raw_get_unsigned (regcache
, offset
+ i
);
1977 inst_env
->branch_found
= 0;
1978 inst_env
->slot_needed
= 0;
1979 inst_env
->delay_slot_pc_active
= 0;
1980 inst_env
->prefix_found
= 0;
1981 inst_env
->invalid
= 0;
1982 inst_env
->xflag_found
= 0;
1983 inst_env
->disable_interrupt
= 0;
1984 inst_env
->byte_order
= byte_order
;
1986 /* Look for a step target. */
1989 /* Read an instruction from the client. */
1990 insn
= read_memory_unsigned_integer
1991 (inst_env
->reg
[gdbarch_pc_regnum (gdbarch
)], 2, byte_order
);
1993 /* If the instruction is not in a delay slot the new content of the
1994 PC is [PC] + 2. If the instruction is in a delay slot it is not
1995 that simple. Since a instruction in a delay slot cannot change
1996 the content of the PC, it does not matter what value PC will have.
1997 Just make sure it is a valid instruction. */
1998 if (!inst_env
->delay_slot_pc_active
)
2000 inst_env
->reg
[gdbarch_pc_regnum (gdbarch
)] += 2;
2004 inst_env
->delay_slot_pc_active
= 0;
2005 inst_env
->reg
[gdbarch_pc_regnum (gdbarch
)]
2006 = inst_env
->delay_slot_pc
;
2008 /* Analyse the present instruction. */
2009 i
= find_cris_op (insn
, inst_env
);
2012 inst_env
->invalid
= 1;
2016 cris_gdb_func (gdbarch
, cris_opcodes
[i
].op
, insn
, inst_env
);
2018 } while (!inst_env
->invalid
2019 && (inst_env
->prefix_found
|| inst_env
->xflag_found
2020 || inst_env
->slot_needed
));
2024 /* There is no hardware single-step support. The function find_step_target
2025 digs through the opcodes in order to find all possible targets.
2026 Either one ordinary target or two targets for branches may be found. */
2028 static std::vector
<CORE_ADDR
>
2029 cris_software_single_step (struct regcache
*regcache
)
2031 struct gdbarch
*gdbarch
= regcache
->arch ();
2032 inst_env_type inst_env
;
2033 std::vector
<CORE_ADDR
> next_pcs
;
2035 /* Analyse the present instruction environment and insert
2037 int status
= find_step_target (regcache
, &inst_env
);
2040 /* Could not find a target. Things are likely to go downhill
2042 warning (_("CRIS software single step could not find a step target."));
2046 /* Insert at most two breakpoints. One for the next PC content
2047 and possibly another one for a branch, jump, etc. */
2049 = (CORE_ADDR
) inst_env
.reg
[gdbarch_pc_regnum (gdbarch
)];
2051 next_pcs
.push_back (next_pc
);
2052 if (inst_env
.branch_found
2053 && (CORE_ADDR
) inst_env
.branch_break_address
!= next_pc
)
2055 CORE_ADDR branch_target_address
2056 = (CORE_ADDR
) inst_env
.branch_break_address
;
2058 next_pcs
.push_back (branch_target_address
);
2065 /* Calculates the prefix value for quick offset addressing mode. */
2068 quick_mode_bdap_prefix (unsigned short inst
, inst_env_type
*inst_env
)
2070 /* It's invalid to be in a delay slot. You can't have a prefix to this
2071 instruction (not 100% sure). */
2072 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2074 inst_env
->invalid
= 1;
2078 inst_env
->prefix_value
= inst_env
->reg
[cris_get_operand2 (inst
)];
2079 inst_env
->prefix_value
+= cris_get_bdap_quick_offset (inst
);
2081 /* A prefix doesn't change the xflag_found. But the rest of the flags
2083 inst_env
->slot_needed
= 0;
2084 inst_env
->prefix_found
= 1;
2087 /* Updates the autoincrement register. The size of the increment is derived
2088 from the size of the operation. The PC is always kept aligned on even
2092 process_autoincrement (int size
, unsigned short inst
, inst_env_type
*inst_env
)
2094 if (size
== INST_BYTE_SIZE
)
2096 inst_env
->reg
[cris_get_operand1 (inst
)] += 1;
2098 /* The PC must be word aligned, so increase the PC with one
2099 word even if the size is byte. */
2100 if (cris_get_operand1 (inst
) == REG_PC
)
2102 inst_env
->reg
[REG_PC
] += 1;
2105 else if (size
== INST_WORD_SIZE
)
2107 inst_env
->reg
[cris_get_operand1 (inst
)] += 2;
2109 else if (size
== INST_DWORD_SIZE
)
2111 inst_env
->reg
[cris_get_operand1 (inst
)] += 4;
2116 inst_env
->invalid
= 1;
2120 /* Just a forward declaration. */
2122 static unsigned long get_data_from_address (unsigned short *inst
,
2124 enum bfd_endian byte_order
);
2126 /* Calculates the prefix value for the general case of offset addressing
2130 bdap_prefix (unsigned short inst
, inst_env_type
*inst_env
)
2132 /* It's invalid to be in a delay slot. */
2133 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2135 inst_env
->invalid
= 1;
2139 /* The calculation of prefix_value used to be after process_autoincrement,
2140 but that fails for an instruction such as jsr [$r0+12] which is encoded
2141 as 5f0d 0c00 30b9 when compiled with -fpic. Since PC is operand1 it
2142 mustn't be incremented until we have read it and what it points at. */
2143 inst_env
->prefix_value
= inst_env
->reg
[cris_get_operand2 (inst
)];
2145 /* The offset is an indirection of the contents of the operand1 register. */
2146 inst_env
->prefix_value
+=
2147 get_data_from_address (&inst
, inst_env
->reg
[cris_get_operand1 (inst
)],
2148 inst_env
->byte_order
);
2150 if (cris_get_mode (inst
) == AUTOINC_MODE
)
2152 process_autoincrement (cris_get_size (inst
), inst
, inst_env
);
2155 /* A prefix doesn't change the xflag_found. But the rest of the flags
2157 inst_env
->slot_needed
= 0;
2158 inst_env
->prefix_found
= 1;
2161 /* Calculates the prefix value for the index addressing mode. */
2164 biap_prefix (unsigned short inst
, inst_env_type
*inst_env
)
2166 /* It's invalid to be in a delay slot. I can't see that it's possible to
2167 have a prefix to this instruction. So I will treat this as invalid. */
2168 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2170 inst_env
->invalid
= 1;
2174 inst_env
->prefix_value
= inst_env
->reg
[cris_get_operand1 (inst
)];
2176 /* The offset is the operand2 value shifted the size of the instruction
2178 inst_env
->prefix_value
+=
2179 inst_env
->reg
[cris_get_operand2 (inst
)] << cris_get_size (inst
);
2181 /* If the PC is operand1 (base) the address used is the address after
2182 the main instruction, i.e. address + 2 (the PC is already compensated
2183 for the prefix operation). */
2184 if (cris_get_operand1 (inst
) == REG_PC
)
2186 inst_env
->prefix_value
+= 2;
2189 /* A prefix doesn't change the xflag_found. But the rest of the flags
2191 inst_env
->slot_needed
= 0;
2192 inst_env
->xflag_found
= 0;
2193 inst_env
->prefix_found
= 1;
2196 /* Calculates the prefix value for the double indirect addressing mode. */
2199 dip_prefix (unsigned short inst
, inst_env_type
*inst_env
)
2204 /* It's invalid to be in a delay slot. */
2205 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2207 inst_env
->invalid
= 1;
2211 /* The prefix value is one dereference of the contents of the operand1
2213 address
= (CORE_ADDR
) inst_env
->reg
[cris_get_operand1 (inst
)];
2214 inst_env
->prefix_value
2215 = read_memory_unsigned_integer (address
, 4, inst_env
->byte_order
);
2217 /* Check if the mode is autoincrement. */
2218 if (cris_get_mode (inst
) == AUTOINC_MODE
)
2220 inst_env
->reg
[cris_get_operand1 (inst
)] += 4;
2223 /* A prefix doesn't change the xflag_found. But the rest of the flags
2225 inst_env
->slot_needed
= 0;
2226 inst_env
->xflag_found
= 0;
2227 inst_env
->prefix_found
= 1;
2230 /* Finds the destination for a branch with 8-bits offset. */
2233 eight_bit_offset_branch_op (unsigned short inst
, inst_env_type
*inst_env
)
2238 /* If we have a prefix or are in a delay slot it's bad. */
2239 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2241 inst_env
->invalid
= 1;
2245 /* We have a branch, find out where the branch will land. */
2246 offset
= cris_get_branch_short_offset (inst
);
2248 /* Check if the offset is signed. */
2249 if (offset
& BRANCH_SIGNED_SHORT_OFFSET_MASK
)
2254 /* The offset ends with the sign bit, set it to zero. The address
2255 should always be word aligned. */
2256 offset
&= ~BRANCH_SIGNED_SHORT_OFFSET_MASK
;
2258 inst_env
->branch_found
= 1;
2259 inst_env
->branch_break_address
= inst_env
->reg
[REG_PC
] + offset
;
2261 inst_env
->slot_needed
= 1;
2262 inst_env
->prefix_found
= 0;
2263 inst_env
->xflag_found
= 0;
2264 inst_env
->disable_interrupt
= 1;
2267 /* Finds the destination for a branch with 16-bits offset. */
2270 sixteen_bit_offset_branch_op (unsigned short inst
, inst_env_type
*inst_env
)
2274 /* If we have a prefix or is in a delay slot it's bad. */
2275 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2277 inst_env
->invalid
= 1;
2281 /* We have a branch, find out the offset for the branch. */
2282 offset
= read_memory_integer (inst_env
->reg
[REG_PC
], 2,
2283 inst_env
->byte_order
);
2285 /* The instruction is one word longer than normal, so add one word
2287 inst_env
->reg
[REG_PC
] += 2;
2289 inst_env
->branch_found
= 1;
2290 inst_env
->branch_break_address
= inst_env
->reg
[REG_PC
] + offset
;
2293 inst_env
->slot_needed
= 1;
2294 inst_env
->prefix_found
= 0;
2295 inst_env
->xflag_found
= 0;
2296 inst_env
->disable_interrupt
= 1;
2299 /* Handles the ABS instruction. */
2302 abs_op (unsigned short inst
, inst_env_type
*inst_env
)
2307 /* ABS can't have a prefix, so it's bad if it does. */
2308 if (inst_env
->prefix_found
)
2310 inst_env
->invalid
= 1;
2314 /* Check if the operation affects the PC. */
2315 if (cris_get_operand2 (inst
) == REG_PC
)
2318 /* It's invalid to change to the PC if we are in a delay slot. */
2319 if (inst_env
->slot_needed
)
2321 inst_env
->invalid
= 1;
2325 value
= (long) inst_env
->reg
[REG_PC
];
2327 /* The value of abs (SIGNED_DWORD_MASK) is SIGNED_DWORD_MASK. */
2328 if (value
!= SIGNED_DWORD_MASK
)
2331 inst_env
->reg
[REG_PC
] = (long) value
;
2335 inst_env
->slot_needed
= 0;
2336 inst_env
->prefix_found
= 0;
2337 inst_env
->xflag_found
= 0;
2338 inst_env
->disable_interrupt
= 0;
2341 /* Handles the ADDI instruction. */
2344 addi_op (unsigned short inst
, inst_env_type
*inst_env
)
2346 /* It's invalid to have the PC as base register. And ADDI can't have
2348 if (inst_env
->prefix_found
|| (cris_get_operand1 (inst
) == REG_PC
))
2350 inst_env
->invalid
= 1;
2354 inst_env
->slot_needed
= 0;
2355 inst_env
->prefix_found
= 0;
2356 inst_env
->xflag_found
= 0;
2357 inst_env
->disable_interrupt
= 0;
2360 /* Handles the ASR instruction. */
2363 asr_op (unsigned short inst
, inst_env_type
*inst_env
)
2366 unsigned long value
;
2367 unsigned long signed_extend_mask
= 0;
2369 /* ASR can't have a prefix, so check that it doesn't. */
2370 if (inst_env
->prefix_found
)
2372 inst_env
->invalid
= 1;
2376 /* Check if the PC is the target register. */
2377 if (cris_get_operand2 (inst
) == REG_PC
)
2379 /* It's invalid to change the PC in a delay slot. */
2380 if (inst_env
->slot_needed
)
2382 inst_env
->invalid
= 1;
2385 /* Get the number of bits to shift. */
2387 = cris_get_asr_shift_steps (inst_env
->reg
[cris_get_operand1 (inst
)]);
2388 value
= inst_env
->reg
[REG_PC
];
2390 /* Find out how many bits the operation should apply to. */
2391 if (cris_get_size (inst
) == INST_BYTE_SIZE
)
2393 if (value
& SIGNED_BYTE_MASK
)
2395 signed_extend_mask
= 0xFF;
2396 signed_extend_mask
= signed_extend_mask
>> shift_steps
;
2397 signed_extend_mask
= ~signed_extend_mask
;
2399 value
= value
>> shift_steps
;
2400 value
|= signed_extend_mask
;
2402 inst_env
->reg
[REG_PC
] &= 0xFFFFFF00;
2403 inst_env
->reg
[REG_PC
] |= value
;
2405 else if (cris_get_size (inst
) == INST_WORD_SIZE
)
2407 if (value
& SIGNED_WORD_MASK
)
2409 signed_extend_mask
= 0xFFFF;
2410 signed_extend_mask
= signed_extend_mask
>> shift_steps
;
2411 signed_extend_mask
= ~signed_extend_mask
;
2413 value
= value
>> shift_steps
;
2414 value
|= signed_extend_mask
;
2416 inst_env
->reg
[REG_PC
] &= 0xFFFF0000;
2417 inst_env
->reg
[REG_PC
] |= value
;
2419 else if (cris_get_size (inst
) == INST_DWORD_SIZE
)
2421 if (value
& SIGNED_DWORD_MASK
)
2423 signed_extend_mask
= 0xFFFFFFFF;
2424 signed_extend_mask
= signed_extend_mask
>> shift_steps
;
2425 signed_extend_mask
= ~signed_extend_mask
;
2427 value
= value
>> shift_steps
;
2428 value
|= signed_extend_mask
;
2429 inst_env
->reg
[REG_PC
] = value
;
2432 inst_env
->slot_needed
= 0;
2433 inst_env
->prefix_found
= 0;
2434 inst_env
->xflag_found
= 0;
2435 inst_env
->disable_interrupt
= 0;
2438 /* Handles the ASRQ instruction. */
2441 asrq_op (unsigned short inst
, inst_env_type
*inst_env
)
2445 unsigned long value
;
2446 unsigned long signed_extend_mask
= 0;
2448 /* ASRQ can't have a prefix, so check that it doesn't. */
2449 if (inst_env
->prefix_found
)
2451 inst_env
->invalid
= 1;
2455 /* Check if the PC is the target register. */
2456 if (cris_get_operand2 (inst
) == REG_PC
)
2459 /* It's invalid to change the PC in a delay slot. */
2460 if (inst_env
->slot_needed
)
2462 inst_env
->invalid
= 1;
2465 /* The shift size is given as a 5 bit quick value, i.e. we don't
2466 want the sign bit of the quick value. */
2467 shift_steps
= cris_get_asr_shift_steps (inst
);
2468 value
= inst_env
->reg
[REG_PC
];
2469 if (value
& SIGNED_DWORD_MASK
)
2471 signed_extend_mask
= 0xFFFFFFFF;
2472 signed_extend_mask
= signed_extend_mask
>> shift_steps
;
2473 signed_extend_mask
= ~signed_extend_mask
;
2475 value
= value
>> shift_steps
;
2476 value
|= signed_extend_mask
;
2477 inst_env
->reg
[REG_PC
] = value
;
2479 inst_env
->slot_needed
= 0;
2480 inst_env
->prefix_found
= 0;
2481 inst_env
->xflag_found
= 0;
2482 inst_env
->disable_interrupt
= 0;
2485 /* Handles the AX, EI and SETF instruction. */
2488 ax_ei_setf_op (unsigned short inst
, inst_env_type
*inst_env
)
2490 if (inst_env
->prefix_found
)
2492 inst_env
->invalid
= 1;
2495 /* Check if the instruction is setting the X flag. */
2496 if (cris_is_xflag_bit_on (inst
))
2498 inst_env
->xflag_found
= 1;
2502 inst_env
->xflag_found
= 0;
2504 inst_env
->slot_needed
= 0;
2505 inst_env
->prefix_found
= 0;
2506 inst_env
->disable_interrupt
= 1;
2509 /* Checks if the instruction is in assign mode. If so, it updates the assign
2510 register. Note that check_assign assumes that the caller has checked that
2511 there is a prefix to this instruction. The mode check depends on this. */
2514 check_assign (unsigned short inst
, inst_env_type
*inst_env
)
2516 /* Check if it's an assign addressing mode. */
2517 if (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
)
2519 /* Assign the prefix value to operand 1. */
2520 inst_env
->reg
[cris_get_operand1 (inst
)] = inst_env
->prefix_value
;
2524 /* Handles the 2-operand BOUND instruction. */
2527 two_operand_bound_op (unsigned short inst
, inst_env_type
*inst_env
)
2529 /* It's invalid to have the PC as the index operand. */
2530 if (cris_get_operand2 (inst
) == REG_PC
)
2532 inst_env
->invalid
= 1;
2535 /* Check if we have a prefix. */
2536 if (inst_env
->prefix_found
)
2538 check_assign (inst
, inst_env
);
2540 /* Check if this is an autoincrement mode. */
2541 else if (cris_get_mode (inst
) == AUTOINC_MODE
)
2543 /* It's invalid to change the PC in a delay slot. */
2544 if (inst_env
->slot_needed
)
2546 inst_env
->invalid
= 1;
2549 process_autoincrement (cris_get_size (inst
), inst
, inst_env
);
2551 inst_env
->slot_needed
= 0;
2552 inst_env
->prefix_found
= 0;
2553 inst_env
->xflag_found
= 0;
2554 inst_env
->disable_interrupt
= 0;
2557 /* Handles the 3-operand BOUND instruction. */
2560 three_operand_bound_op (unsigned short inst
, inst_env_type
*inst_env
)
2562 /* It's an error if we haven't got a prefix. And it's also an error
2563 if the PC is the destination register. */
2564 if ((!inst_env
->prefix_found
) || (cris_get_operand1 (inst
) == REG_PC
))
2566 inst_env
->invalid
= 1;
2569 inst_env
->slot_needed
= 0;
2570 inst_env
->prefix_found
= 0;
2571 inst_env
->xflag_found
= 0;
2572 inst_env
->disable_interrupt
= 0;
2575 /* Clears the status flags in inst_env. */
2578 btst_nop_op (unsigned short inst
, inst_env_type
*inst_env
)
2580 /* It's an error if we have got a prefix. */
2581 if (inst_env
->prefix_found
)
2583 inst_env
->invalid
= 1;
2587 inst_env
->slot_needed
= 0;
2588 inst_env
->prefix_found
= 0;
2589 inst_env
->xflag_found
= 0;
2590 inst_env
->disable_interrupt
= 0;
2593 /* Clears the status flags in inst_env. */
2596 clearf_di_op (unsigned short inst
, inst_env_type
*inst_env
)
2598 /* It's an error if we have got a prefix. */
2599 if (inst_env
->prefix_found
)
2601 inst_env
->invalid
= 1;
2605 inst_env
->slot_needed
= 0;
2606 inst_env
->prefix_found
= 0;
2607 inst_env
->xflag_found
= 0;
2608 inst_env
->disable_interrupt
= 1;
2611 /* Handles the CLEAR instruction if it's in register mode. */
2614 reg_mode_clear_op (unsigned short inst
, inst_env_type
*inst_env
)
2616 /* Check if the target is the PC. */
2617 if (cris_get_operand2 (inst
) == REG_PC
)
2619 /* The instruction will clear the instruction's size bits. */
2620 int clear_size
= cris_get_clear_size (inst
);
2621 if (clear_size
== INST_BYTE_SIZE
)
2623 inst_env
->delay_slot_pc
= inst_env
->reg
[REG_PC
] & 0xFFFFFF00;
2625 if (clear_size
== INST_WORD_SIZE
)
2627 inst_env
->delay_slot_pc
= inst_env
->reg
[REG_PC
] & 0xFFFF0000;
2629 if (clear_size
== INST_DWORD_SIZE
)
2631 inst_env
->delay_slot_pc
= 0x0;
2633 /* The jump will be delayed with one delay slot. So we need a delay
2635 inst_env
->slot_needed
= 1;
2636 inst_env
->delay_slot_pc_active
= 1;
2640 /* The PC will not change => no delay slot. */
2641 inst_env
->slot_needed
= 0;
2643 inst_env
->prefix_found
= 0;
2644 inst_env
->xflag_found
= 0;
2645 inst_env
->disable_interrupt
= 0;
2648 /* Handles the TEST instruction if it's in register mode. */
2651 reg_mode_test_op (unsigned short inst
, inst_env_type
*inst_env
)
2653 /* It's an error if we have got a prefix. */
2654 if (inst_env
->prefix_found
)
2656 inst_env
->invalid
= 1;
2659 inst_env
->slot_needed
= 0;
2660 inst_env
->prefix_found
= 0;
2661 inst_env
->xflag_found
= 0;
2662 inst_env
->disable_interrupt
= 0;
2666 /* Handles the CLEAR and TEST instruction if the instruction isn't
2667 in register mode. */
2670 none_reg_mode_clear_test_op (unsigned short inst
, inst_env_type
*inst_env
)
2672 /* Check if we are in a prefix mode. */
2673 if (inst_env
->prefix_found
)
2675 /* The only way the PC can change is if this instruction is in
2676 assign addressing mode. */
2677 check_assign (inst
, inst_env
);
2679 /* Indirect mode can't change the PC so just check if the mode is
2681 else if (cris_get_mode (inst
) == AUTOINC_MODE
)
2683 process_autoincrement (cris_get_size (inst
), inst
, inst_env
);
2685 inst_env
->slot_needed
= 0;
2686 inst_env
->prefix_found
= 0;
2687 inst_env
->xflag_found
= 0;
2688 inst_env
->disable_interrupt
= 0;
2691 /* Checks that the PC isn't the destination register or the instructions has
2695 dstep_logshift_mstep_neg_not_op (unsigned short inst
, inst_env_type
*inst_env
)
2697 /* It's invalid to have the PC as the destination. The instruction can't
2699 if ((cris_get_operand2 (inst
) == REG_PC
) || inst_env
->prefix_found
)
2701 inst_env
->invalid
= 1;
2705 inst_env
->slot_needed
= 0;
2706 inst_env
->prefix_found
= 0;
2707 inst_env
->xflag_found
= 0;
2708 inst_env
->disable_interrupt
= 0;
2711 /* Checks that the instruction doesn't have a prefix. */
2714 break_op (unsigned short inst
, inst_env_type
*inst_env
)
2716 /* The instruction can't have a prefix. */
2717 if (inst_env
->prefix_found
)
2719 inst_env
->invalid
= 1;
2723 inst_env
->slot_needed
= 0;
2724 inst_env
->prefix_found
= 0;
2725 inst_env
->xflag_found
= 0;
2726 inst_env
->disable_interrupt
= 1;
2729 /* Checks that the PC isn't the destination register and that the instruction
2730 doesn't have a prefix. */
2733 scc_op (unsigned short inst
, inst_env_type
*inst_env
)
2735 /* It's invalid to have the PC as the destination. The instruction can't
2737 if ((cris_get_operand2 (inst
) == REG_PC
) || inst_env
->prefix_found
)
2739 inst_env
->invalid
= 1;
2743 inst_env
->slot_needed
= 0;
2744 inst_env
->prefix_found
= 0;
2745 inst_env
->xflag_found
= 0;
2746 inst_env
->disable_interrupt
= 1;
2749 /* Handles the register mode JUMP instruction. */
2752 reg_mode_jump_op (unsigned short inst
, inst_env_type
*inst_env
)
2754 /* It's invalid to do a JUMP in a delay slot. The mode is register, so
2755 you can't have a prefix. */
2756 if ((inst_env
->slot_needed
) || (inst_env
->prefix_found
))
2758 inst_env
->invalid
= 1;
2762 /* Just change the PC. */
2763 inst_env
->reg
[REG_PC
] = inst_env
->reg
[cris_get_operand1 (inst
)];
2764 inst_env
->slot_needed
= 0;
2765 inst_env
->prefix_found
= 0;
2766 inst_env
->xflag_found
= 0;
2767 inst_env
->disable_interrupt
= 1;
2770 /* Handles the JUMP instruction for all modes except register. */
2773 none_reg_mode_jump_op (unsigned short inst
, inst_env_type
*inst_env
)
2775 unsigned long newpc
;
2778 /* It's invalid to do a JUMP in a delay slot. */
2779 if (inst_env
->slot_needed
)
2781 inst_env
->invalid
= 1;
2785 /* Check if we have a prefix. */
2786 if (inst_env
->prefix_found
)
2788 check_assign (inst
, inst_env
);
2790 /* Get the new value for the PC. */
2792 read_memory_unsigned_integer ((CORE_ADDR
) inst_env
->prefix_value
,
2793 4, inst_env
->byte_order
);
2797 /* Get the new value for the PC. */
2798 address
= (CORE_ADDR
) inst_env
->reg
[cris_get_operand1 (inst
)];
2799 newpc
= read_memory_unsigned_integer (address
,
2800 4, inst_env
->byte_order
);
2802 /* Check if we should increment a register. */
2803 if (cris_get_mode (inst
) == AUTOINC_MODE
)
2805 inst_env
->reg
[cris_get_operand1 (inst
)] += 4;
2808 inst_env
->reg
[REG_PC
] = newpc
;
2810 inst_env
->slot_needed
= 0;
2811 inst_env
->prefix_found
= 0;
2812 inst_env
->xflag_found
= 0;
2813 inst_env
->disable_interrupt
= 1;
2816 /* Handles moves to special registers (aka P-register) for all modes. */
2819 move_to_preg_op (struct gdbarch
*gdbarch
, unsigned short inst
,
2820 inst_env_type
*inst_env
)
2822 if (inst_env
->prefix_found
)
2824 /* The instruction has a prefix that means we are only interested if
2825 the instruction is in assign mode. */
2826 if (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
)
2828 /* The prefix handles the problem if we are in a delay slot. */
2829 if (cris_get_operand1 (inst
) == REG_PC
)
2831 /* Just take care of the assign. */
2832 check_assign (inst
, inst_env
);
2836 else if (cris_get_mode (inst
) == AUTOINC_MODE
)
2838 /* The instruction doesn't have a prefix, the only case left that we
2839 are interested in is the autoincrement mode. */
2840 if (cris_get_operand1 (inst
) == REG_PC
)
2842 /* If the PC is to be incremented it's invalid to be in a
2844 if (inst_env
->slot_needed
)
2846 inst_env
->invalid
= 1;
2850 /* The increment depends on the size of the special register. */
2851 if (cris_register_size (gdbarch
, cris_get_operand2 (inst
)) == 1)
2853 process_autoincrement (INST_BYTE_SIZE
, inst
, inst_env
);
2855 else if (cris_register_size (gdbarch
, cris_get_operand2 (inst
)) == 2)
2857 process_autoincrement (INST_WORD_SIZE
, inst
, inst_env
);
2861 process_autoincrement (INST_DWORD_SIZE
, inst
, inst_env
);
2865 inst_env
->slot_needed
= 0;
2866 inst_env
->prefix_found
= 0;
2867 inst_env
->xflag_found
= 0;
2868 inst_env
->disable_interrupt
= 1;
2871 /* Handles moves from special registers (aka P-register) for all modes
2875 none_reg_mode_move_from_preg_op (struct gdbarch
*gdbarch
, unsigned short inst
,
2876 inst_env_type
*inst_env
)
2878 if (inst_env
->prefix_found
)
2880 /* The instruction has a prefix that means we are only interested if
2881 the instruction is in assign mode. */
2882 if (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
)
2884 /* The prefix handles the problem if we are in a delay slot. */
2885 if (cris_get_operand1 (inst
) == REG_PC
)
2887 /* Just take care of the assign. */
2888 check_assign (inst
, inst_env
);
2892 /* The instruction doesn't have a prefix, the only case left that we
2893 are interested in is the autoincrement mode. */
2894 else if (cris_get_mode (inst
) == AUTOINC_MODE
)
2896 if (cris_get_operand1 (inst
) == REG_PC
)
2898 /* If the PC is to be incremented it's invalid to be in a
2900 if (inst_env
->slot_needed
)
2902 inst_env
->invalid
= 1;
2906 /* The increment depends on the size of the special register. */
2907 if (cris_register_size (gdbarch
, cris_get_operand2 (inst
)) == 1)
2909 process_autoincrement (INST_BYTE_SIZE
, inst
, inst_env
);
2911 else if (cris_register_size (gdbarch
, cris_get_operand2 (inst
)) == 2)
2913 process_autoincrement (INST_WORD_SIZE
, inst
, inst_env
);
2917 process_autoincrement (INST_DWORD_SIZE
, inst
, inst_env
);
2921 inst_env
->slot_needed
= 0;
2922 inst_env
->prefix_found
= 0;
2923 inst_env
->xflag_found
= 0;
2924 inst_env
->disable_interrupt
= 1;
2927 /* Handles moves from special registers (aka P-register) when the mode
2931 reg_mode_move_from_preg_op (unsigned short inst
, inst_env_type
*inst_env
)
2933 /* Register mode move from special register can't have a prefix. */
2934 if (inst_env
->prefix_found
)
2936 inst_env
->invalid
= 1;
2940 if (cris_get_operand1 (inst
) == REG_PC
)
2942 /* It's invalid to change the PC in a delay slot. */
2943 if (inst_env
->slot_needed
)
2945 inst_env
->invalid
= 1;
2948 /* The destination is the PC, the jump will have a delay slot. */
2949 inst_env
->delay_slot_pc
= inst_env
->preg
[cris_get_operand2 (inst
)];
2950 inst_env
->slot_needed
= 1;
2951 inst_env
->delay_slot_pc_active
= 1;
2955 /* If the destination isn't PC, there will be no jump. */
2956 inst_env
->slot_needed
= 0;
2958 inst_env
->prefix_found
= 0;
2959 inst_env
->xflag_found
= 0;
2960 inst_env
->disable_interrupt
= 1;
2963 /* Handles the MOVEM from memory to general register instruction. */
2966 move_mem_to_reg_movem_op (unsigned short inst
, inst_env_type
*inst_env
)
2968 if (inst_env
->prefix_found
)
2970 /* The prefix handles the problem if we are in a delay slot. Is the
2971 MOVEM instruction going to change the PC? */
2972 if (cris_get_operand2 (inst
) >= REG_PC
)
2974 inst_env
->reg
[REG_PC
] =
2975 read_memory_unsigned_integer (inst_env
->prefix_value
,
2976 4, inst_env
->byte_order
);
2978 /* The assign value is the value after the increment. Normally, the
2979 assign value is the value before the increment. */
2980 if ((cris_get_operand1 (inst
) == REG_PC
)
2981 && (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
))
2983 inst_env
->reg
[REG_PC
] = inst_env
->prefix_value
;
2984 inst_env
->reg
[REG_PC
] += 4 * (cris_get_operand2 (inst
) + 1);
2989 /* Is the MOVEM instruction going to change the PC? */
2990 if (cris_get_operand2 (inst
) == REG_PC
)
2992 /* It's invalid to change the PC in a delay slot. */
2993 if (inst_env
->slot_needed
)
2995 inst_env
->invalid
= 1;
2998 inst_env
->reg
[REG_PC
] =
2999 read_memory_unsigned_integer (inst_env
->reg
[cris_get_operand1 (inst
)],
3000 4, inst_env
->byte_order
);
3002 /* The increment is not depending on the size, instead it's depending
3003 on the number of registers loaded from memory. */
3004 if ((cris_get_operand1 (inst
) == REG_PC
)
3005 && (cris_get_mode (inst
) == AUTOINC_MODE
))
3007 /* It's invalid to change the PC in a delay slot. */
3008 if (inst_env
->slot_needed
)
3010 inst_env
->invalid
= 1;
3013 inst_env
->reg
[REG_PC
] += 4 * (cris_get_operand2 (inst
) + 1);
3016 inst_env
->slot_needed
= 0;
3017 inst_env
->prefix_found
= 0;
3018 inst_env
->xflag_found
= 0;
3019 inst_env
->disable_interrupt
= 0;
3022 /* Handles the MOVEM to memory from general register instruction. */
3025 move_reg_to_mem_movem_op (unsigned short inst
, inst_env_type
*inst_env
)
3027 if (inst_env
->prefix_found
)
3029 /* The assign value is the value after the increment. Normally, the
3030 assign value is the value before the increment. */
3031 if ((cris_get_operand1 (inst
) == REG_PC
)
3032 && (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
))
3034 /* The prefix handles the problem if we are in a delay slot. */
3035 inst_env
->reg
[REG_PC
] = inst_env
->prefix_value
;
3036 inst_env
->reg
[REG_PC
] += 4 * (cris_get_operand2 (inst
) + 1);
3041 /* The increment is not depending on the size, instead it's depending
3042 on the number of registers loaded to memory. */
3043 if ((cris_get_operand1 (inst
) == REG_PC
)
3044 && (cris_get_mode (inst
) == AUTOINC_MODE
))
3046 /* It's invalid to change the PC in a delay slot. */
3047 if (inst_env
->slot_needed
)
3049 inst_env
->invalid
= 1;
3052 inst_env
->reg
[REG_PC
] += 4 * (cris_get_operand2 (inst
) + 1);
3055 inst_env
->slot_needed
= 0;
3056 inst_env
->prefix_found
= 0;
3057 inst_env
->xflag_found
= 0;
3058 inst_env
->disable_interrupt
= 0;
3061 /* Handles the instructions that's not yet implemented, by setting
3062 inst_env->invalid to true. */
3065 not_implemented_op (unsigned short inst
, inst_env_type
*inst_env
)
3067 inst_env
->invalid
= 1;
3070 /* Handles the XOR instruction. */
3073 xor_op (unsigned short inst
, inst_env_type
*inst_env
)
3075 /* XOR can't have a prefix. */
3076 if (inst_env
->prefix_found
)
3078 inst_env
->invalid
= 1;
3082 /* Check if the PC is the target. */
3083 if (cris_get_operand2 (inst
) == REG_PC
)
3085 /* It's invalid to change the PC in a delay slot. */
3086 if (inst_env
->slot_needed
)
3088 inst_env
->invalid
= 1;
3091 inst_env
->reg
[REG_PC
] ^= inst_env
->reg
[cris_get_operand1 (inst
)];
3093 inst_env
->slot_needed
= 0;
3094 inst_env
->prefix_found
= 0;
3095 inst_env
->xflag_found
= 0;
3096 inst_env
->disable_interrupt
= 0;
3099 /* Handles the MULS instruction. */
3102 muls_op (unsigned short inst
, inst_env_type
*inst_env
)
3104 /* MULS/U can't have a prefix. */
3105 if (inst_env
->prefix_found
)
3107 inst_env
->invalid
= 1;
3111 /* Consider it invalid if the PC is the target. */
3112 if (cris_get_operand2 (inst
) == REG_PC
)
3114 inst_env
->invalid
= 1;
3117 inst_env
->slot_needed
= 0;
3118 inst_env
->prefix_found
= 0;
3119 inst_env
->xflag_found
= 0;
3120 inst_env
->disable_interrupt
= 0;
3123 /* Handles the MULU instruction. */
3126 mulu_op (unsigned short inst
, inst_env_type
*inst_env
)
3128 /* MULS/U can't have a prefix. */
3129 if (inst_env
->prefix_found
)
3131 inst_env
->invalid
= 1;
3135 /* Consider it invalid if the PC is the target. */
3136 if (cris_get_operand2 (inst
) == REG_PC
)
3138 inst_env
->invalid
= 1;
3141 inst_env
->slot_needed
= 0;
3142 inst_env
->prefix_found
= 0;
3143 inst_env
->xflag_found
= 0;
3144 inst_env
->disable_interrupt
= 0;
3147 /* Calculate the result of the instruction for ADD, SUB, CMP AND, OR and MOVE.
3148 The MOVE instruction is the move from source to register. */
3151 add_sub_cmp_and_or_move_action (unsigned short inst
, inst_env_type
*inst_env
,
3152 unsigned long source1
, unsigned long source2
)
3154 unsigned long pc_mask
;
3155 unsigned long operation_mask
;
3157 /* Find out how many bits the operation should apply to. */
3158 if (cris_get_size (inst
) == INST_BYTE_SIZE
)
3160 pc_mask
= 0xFFFFFF00;
3161 operation_mask
= 0xFF;
3163 else if (cris_get_size (inst
) == INST_WORD_SIZE
)
3165 pc_mask
= 0xFFFF0000;
3166 operation_mask
= 0xFFFF;
3168 else if (cris_get_size (inst
) == INST_DWORD_SIZE
)
3171 operation_mask
= 0xFFFFFFFF;
3175 /* The size is out of range. */
3176 inst_env
->invalid
= 1;
3180 /* The instruction just works on uw_operation_mask bits. */
3181 source2
&= operation_mask
;
3182 source1
&= operation_mask
;
3184 /* Now calculate the result. The opcode's 3 first bits separates
3185 the different actions. */
3186 switch (cris_get_opcode (inst
) & 7)
3196 case 2: /* subtract */
3200 case 3: /* compare */
3212 inst_env
->invalid
= 1;
3218 /* Make sure that the result doesn't contain more than the instruction
3220 source2
&= operation_mask
;
3222 /* Calculate the new breakpoint address. */
3223 inst_env
->reg
[REG_PC
] &= pc_mask
;
3224 inst_env
->reg
[REG_PC
] |= source1
;
3228 /* Extends the value from either byte or word size to a dword. If the mode
3229 is zero extend then the value is extended with zero. If instead the mode
3230 is signed extend the sign bit of the value is taken into consideration. */
3232 static unsigned long
3233 do_sign_or_zero_extend (unsigned long value
, unsigned short *inst
)
3235 /* The size can be either byte or word, check which one it is.
3236 Don't check the highest bit, it's indicating if it's a zero
3238 if (cris_get_size (*inst
) & INST_WORD_SIZE
)
3243 /* Check if the instruction is signed extend. If so, check if value has
3245 if (cris_is_signed_extend_bit_on (*inst
) && (value
& SIGNED_WORD_MASK
))
3247 value
|= SIGNED_WORD_EXTEND_MASK
;
3255 /* Check if the instruction is signed extend. If so, check if value has
3257 if (cris_is_signed_extend_bit_on (*inst
) && (value
& SIGNED_BYTE_MASK
))
3259 value
|= SIGNED_BYTE_EXTEND_MASK
;
3262 /* The size should now be dword. */
3263 cris_set_size_to_dword (inst
);
3267 /* Handles the register mode for the ADD, SUB, CMP, AND, OR and MOVE
3268 instruction. The MOVE instruction is the move from source to register. */
3271 reg_mode_add_sub_cmp_and_or_move_op (unsigned short inst
,
3272 inst_env_type
*inst_env
)
3274 unsigned long operand1
;
3275 unsigned long operand2
;
3277 /* It's invalid to have a prefix to the instruction. This is a register
3278 mode instruction and can't have a prefix. */
3279 if (inst_env
->prefix_found
)
3281 inst_env
->invalid
= 1;
3284 /* Check if the instruction has PC as its target. */
3285 if (cris_get_operand2 (inst
) == REG_PC
)
3287 if (inst_env
->slot_needed
)
3289 inst_env
->invalid
= 1;
3292 /* The instruction has the PC as its target register. */
3293 operand1
= inst_env
->reg
[cris_get_operand1 (inst
)];
3294 operand2
= inst_env
->reg
[REG_PC
];
3296 /* Check if it's a extend, signed or zero instruction. */
3297 if (cris_get_opcode (inst
) < 4)
3299 operand1
= do_sign_or_zero_extend (operand1
, &inst
);
3301 /* Calculate the PC value after the instruction, i.e. where the
3302 breakpoint should be. The order of the udw_operands is vital. */
3303 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand1
);
3305 inst_env
->slot_needed
= 0;
3306 inst_env
->prefix_found
= 0;
3307 inst_env
->xflag_found
= 0;
3308 inst_env
->disable_interrupt
= 0;
3311 /* Returns the data contained at address. The size of the data is derived from
3312 the size of the operation. If the instruction is a zero or signed
3313 extend instruction, the size field is changed in instruction. */
3315 static unsigned long
3316 get_data_from_address (unsigned short *inst
, CORE_ADDR address
,
3317 enum bfd_endian byte_order
)
3319 int size
= cris_get_size (*inst
);
3320 unsigned long value
;
3322 /* If it's an extend instruction we don't want the signed extend bit,
3323 because it influences the size. */
3324 if (cris_get_opcode (*inst
) < 4)
3326 size
&= ~SIGNED_EXTEND_BIT_MASK
;
3328 /* Is there a need for checking the size? Size should contain the number of
3331 value
= read_memory_unsigned_integer (address
, size
, byte_order
);
3333 /* Check if it's an extend, signed or zero instruction. */
3334 if (cris_get_opcode (*inst
) < 4)
3336 value
= do_sign_or_zero_extend (value
, inst
);
3341 /* Handles the assign addresing mode for the ADD, SUB, CMP, AND, OR and MOVE
3342 instructions. The MOVE instruction is the move from source to register. */
3345 handle_prefix_assign_mode_for_aritm_op (unsigned short inst
,
3346 inst_env_type
*inst_env
)
3348 unsigned long operand2
;
3349 unsigned long operand3
;
3351 check_assign (inst
, inst_env
);
3352 if (cris_get_operand2 (inst
) == REG_PC
)
3354 operand2
= inst_env
->reg
[REG_PC
];
3356 /* Get the value of the third operand. */
3357 operand3
= get_data_from_address (&inst
, inst_env
->prefix_value
,
3358 inst_env
->byte_order
);
3360 /* Calculate the PC value after the instruction, i.e. where the
3361 breakpoint should be. The order of the udw_operands is vital. */
3362 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand3
);
3364 inst_env
->slot_needed
= 0;
3365 inst_env
->prefix_found
= 0;
3366 inst_env
->xflag_found
= 0;
3367 inst_env
->disable_interrupt
= 0;
3370 /* Handles the three-operand addressing mode for the ADD, SUB, CMP, AND and
3371 OR instructions. Note that for this to work as expected, the calling
3372 function must have made sure that there is a prefix to this instruction. */
3375 three_operand_add_sub_cmp_and_or_op (unsigned short inst
,
3376 inst_env_type
*inst_env
)
3378 unsigned long operand2
;
3379 unsigned long operand3
;
3381 if (cris_get_operand1 (inst
) == REG_PC
)
3383 /* The PC will be changed by the instruction. */
3384 operand2
= inst_env
->reg
[cris_get_operand2 (inst
)];
3386 /* Get the value of the third operand. */
3387 operand3
= get_data_from_address (&inst
, inst_env
->prefix_value
,
3388 inst_env
->byte_order
);
3390 /* Calculate the PC value after the instruction, i.e. where the
3391 breakpoint should be. */
3392 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand3
);
3394 inst_env
->slot_needed
= 0;
3395 inst_env
->prefix_found
= 0;
3396 inst_env
->xflag_found
= 0;
3397 inst_env
->disable_interrupt
= 0;
3400 /* Handles the index addresing mode for the ADD, SUB, CMP, AND, OR and MOVE
3401 instructions. The MOVE instruction is the move from source to register. */
3404 handle_prefix_index_mode_for_aritm_op (unsigned short inst
,
3405 inst_env_type
*inst_env
)
3407 if (cris_get_operand1 (inst
) != cris_get_operand2 (inst
))
3409 /* If the instruction is MOVE it's invalid. If the instruction is ADD,
3410 SUB, AND or OR something weird is going on (if everything works these
3411 instructions should end up in the three operand version). */
3412 inst_env
->invalid
= 1;
3417 /* three_operand_add_sub_cmp_and_or does the same as we should do here
3419 three_operand_add_sub_cmp_and_or_op (inst
, inst_env
);
3421 inst_env
->slot_needed
= 0;
3422 inst_env
->prefix_found
= 0;
3423 inst_env
->xflag_found
= 0;
3424 inst_env
->disable_interrupt
= 0;
3427 /* Handles the autoincrement and indirect addresing mode for the ADD, SUB,
3428 CMP, AND OR and MOVE instruction. The MOVE instruction is the move from
3429 source to register. */
3432 handle_inc_and_index_mode_for_aritm_op (unsigned short inst
,
3433 inst_env_type
*inst_env
)
3435 unsigned long operand1
;
3436 unsigned long operand2
;
3437 unsigned long operand3
;
3440 /* The instruction is either an indirect or autoincrement addressing mode.
3441 Check if the destination register is the PC. */
3442 if (cris_get_operand2 (inst
) == REG_PC
)
3444 /* Must be done here, get_data_from_address may change the size
3446 size
= cris_get_size (inst
);
3447 operand2
= inst_env
->reg
[REG_PC
];
3449 /* Get the value of the third operand, i.e. the indirect operand. */
3450 operand1
= inst_env
->reg
[cris_get_operand1 (inst
)];
3451 operand3
= get_data_from_address (&inst
, operand1
, inst_env
->byte_order
);
3453 /* Calculate the PC value after the instruction, i.e. where the
3454 breakpoint should be. The order of the udw_operands is vital. */
3455 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand3
);
3457 /* If this is an autoincrement addressing mode, check if the increment
3459 if ((cris_get_operand1 (inst
) == REG_PC
)
3460 && (cris_get_mode (inst
) == AUTOINC_MODE
))
3462 /* Get the size field. */
3463 size
= cris_get_size (inst
);
3465 /* If it's an extend instruction we don't want the signed extend bit,
3466 because it influences the size. */
3467 if (cris_get_opcode (inst
) < 4)
3469 size
&= ~SIGNED_EXTEND_BIT_MASK
;
3471 process_autoincrement (size
, inst
, inst_env
);
3473 inst_env
->slot_needed
= 0;
3474 inst_env
->prefix_found
= 0;
3475 inst_env
->xflag_found
= 0;
3476 inst_env
->disable_interrupt
= 0;
3479 /* Handles the two-operand addressing mode, all modes except register, for
3480 the ADD, SUB CMP, AND and OR instruction. */
3483 none_reg_mode_add_sub_cmp_and_or_move_op (unsigned short inst
,
3484 inst_env_type
*inst_env
)
3486 if (inst_env
->prefix_found
)
3488 if (cris_get_mode (inst
) == PREFIX_INDEX_MODE
)
3490 handle_prefix_index_mode_for_aritm_op (inst
, inst_env
);
3492 else if (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
)
3494 handle_prefix_assign_mode_for_aritm_op (inst
, inst_env
);
3498 /* The mode is invalid for a prefixed base instruction. */
3499 inst_env
->invalid
= 1;
3505 handle_inc_and_index_mode_for_aritm_op (inst
, inst_env
);
3509 /* Handles the quick addressing mode for the ADD and SUB instruction. */
3512 quick_mode_add_sub_op (unsigned short inst
, inst_env_type
*inst_env
)
3514 unsigned long operand1
;
3515 unsigned long operand2
;
3517 /* It's a bad idea to be in a prefix instruction now. This is a quick mode
3518 instruction and can't have a prefix. */
3519 if (inst_env
->prefix_found
)
3521 inst_env
->invalid
= 1;
3525 /* Check if the instruction has PC as its target. */
3526 if (cris_get_operand2 (inst
) == REG_PC
)
3528 if (inst_env
->slot_needed
)
3530 inst_env
->invalid
= 1;
3533 operand1
= cris_get_quick_value (inst
);
3534 operand2
= inst_env
->reg
[REG_PC
];
3536 /* The size should now be dword. */
3537 cris_set_size_to_dword (&inst
);
3539 /* Calculate the PC value after the instruction, i.e. where the
3540 breakpoint should be. */
3541 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand1
);
3543 inst_env
->slot_needed
= 0;
3544 inst_env
->prefix_found
= 0;
3545 inst_env
->xflag_found
= 0;
3546 inst_env
->disable_interrupt
= 0;
3549 /* Handles the quick addressing mode for the CMP, AND and OR instruction. */
3552 quick_mode_and_cmp_move_or_op (unsigned short inst
, inst_env_type
*inst_env
)
3554 unsigned long operand1
;
3555 unsigned long operand2
;
3557 /* It's a bad idea to be in a prefix instruction now. This is a quick mode
3558 instruction and can't have a prefix. */
3559 if (inst_env
->prefix_found
)
3561 inst_env
->invalid
= 1;
3564 /* Check if the instruction has PC as its target. */
3565 if (cris_get_operand2 (inst
) == REG_PC
)
3567 if (inst_env
->slot_needed
)
3569 inst_env
->invalid
= 1;
3572 /* The instruction has the PC as its target register. */
3573 operand1
= cris_get_quick_value (inst
);
3574 operand2
= inst_env
->reg
[REG_PC
];
3576 /* The quick value is signed, so check if we must do a signed extend. */
3577 if (operand1
& SIGNED_QUICK_VALUE_MASK
)
3580 operand1
|= SIGNED_QUICK_VALUE_EXTEND_MASK
;
3582 /* The size should now be dword. */
3583 cris_set_size_to_dword (&inst
);
3585 /* Calculate the PC value after the instruction, i.e. where the
3586 breakpoint should be. */
3587 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand1
);
3589 inst_env
->slot_needed
= 0;
3590 inst_env
->prefix_found
= 0;
3591 inst_env
->xflag_found
= 0;
3592 inst_env
->disable_interrupt
= 0;
3595 /* Translate op_type to a function and call it. */
3598 cris_gdb_func (struct gdbarch
*gdbarch
, enum cris_op_type op_type
,
3599 unsigned short inst
, inst_env_type
*inst_env
)
3603 case cris_not_implemented_op
:
3604 not_implemented_op (inst
, inst_env
);
3608 abs_op (inst
, inst_env
);
3612 addi_op (inst
, inst_env
);
3616 asr_op (inst
, inst_env
);
3620 asrq_op (inst
, inst_env
);
3623 case cris_ax_ei_setf_op
:
3624 ax_ei_setf_op (inst
, inst_env
);
3627 case cris_bdap_prefix
:
3628 bdap_prefix (inst
, inst_env
);
3631 case cris_biap_prefix
:
3632 biap_prefix (inst
, inst_env
);
3636 break_op (inst
, inst_env
);
3639 case cris_btst_nop_op
:
3640 btst_nop_op (inst
, inst_env
);
3643 case cris_clearf_di_op
:
3644 clearf_di_op (inst
, inst_env
);
3647 case cris_dip_prefix
:
3648 dip_prefix (inst
, inst_env
);
3651 case cris_dstep_logshift_mstep_neg_not_op
:
3652 dstep_logshift_mstep_neg_not_op (inst
, inst_env
);
3655 case cris_eight_bit_offset_branch_op
:
3656 eight_bit_offset_branch_op (inst
, inst_env
);
3659 case cris_move_mem_to_reg_movem_op
:
3660 move_mem_to_reg_movem_op (inst
, inst_env
);
3663 case cris_move_reg_to_mem_movem_op
:
3664 move_reg_to_mem_movem_op (inst
, inst_env
);
3667 case cris_move_to_preg_op
:
3668 move_to_preg_op (gdbarch
, inst
, inst_env
);
3672 muls_op (inst
, inst_env
);
3676 mulu_op (inst
, inst_env
);
3679 case cris_none_reg_mode_add_sub_cmp_and_or_move_op
:
3680 none_reg_mode_add_sub_cmp_and_or_move_op (inst
, inst_env
);
3683 case cris_none_reg_mode_clear_test_op
:
3684 none_reg_mode_clear_test_op (inst
, inst_env
);
3687 case cris_none_reg_mode_jump_op
:
3688 none_reg_mode_jump_op (inst
, inst_env
);
3691 case cris_none_reg_mode_move_from_preg_op
:
3692 none_reg_mode_move_from_preg_op (gdbarch
, inst
, inst_env
);
3695 case cris_quick_mode_add_sub_op
:
3696 quick_mode_add_sub_op (inst
, inst_env
);
3699 case cris_quick_mode_and_cmp_move_or_op
:
3700 quick_mode_and_cmp_move_or_op (inst
, inst_env
);
3703 case cris_quick_mode_bdap_prefix
:
3704 quick_mode_bdap_prefix (inst
, inst_env
);
3707 case cris_reg_mode_add_sub_cmp_and_or_move_op
:
3708 reg_mode_add_sub_cmp_and_or_move_op (inst
, inst_env
);
3711 case cris_reg_mode_clear_op
:
3712 reg_mode_clear_op (inst
, inst_env
);
3715 case cris_reg_mode_jump_op
:
3716 reg_mode_jump_op (inst
, inst_env
);
3719 case cris_reg_mode_move_from_preg_op
:
3720 reg_mode_move_from_preg_op (inst
, inst_env
);
3723 case cris_reg_mode_test_op
:
3724 reg_mode_test_op (inst
, inst_env
);
3728 scc_op (inst
, inst_env
);
3731 case cris_sixteen_bit_offset_branch_op
:
3732 sixteen_bit_offset_branch_op (inst
, inst_env
);
3735 case cris_three_operand_add_sub_cmp_and_or_op
:
3736 three_operand_add_sub_cmp_and_or_op (inst
, inst_env
);
3739 case cris_three_operand_bound_op
:
3740 three_operand_bound_op (inst
, inst_env
);
3743 case cris_two_operand_bound_op
:
3744 two_operand_bound_op (inst
, inst_env
);
3748 xor_op (inst
, inst_env
);
3753 /* Originally from <asm/elf.h>. */
3754 typedef unsigned char cris_elf_greg_t
[4];
3756 /* Same as user_regs_struct struct in <asm/user.h>. */
3757 #define CRISV10_ELF_NGREG 35
3758 typedef cris_elf_greg_t cris_elf_gregset_t
[CRISV10_ELF_NGREG
];
3760 #define CRISV32_ELF_NGREG 32
3761 typedef cris_elf_greg_t crisv32_elf_gregset_t
[CRISV32_ELF_NGREG
];
3763 /* Unpack a cris_elf_gregset_t into GDB's register cache. */
3766 cris_supply_gregset (const struct regset
*regset
, struct regcache
*regcache
,
3767 int regnum
, const void *gregs
, size_t len
)
3769 struct gdbarch
*gdbarch
= regcache
->arch ();
3770 cris_gdbarch_tdep
*tdep
= gdbarch_tdep
<cris_gdbarch_tdep
> (gdbarch
);
3772 const cris_elf_greg_t
*regp
= static_cast<const cris_elf_greg_t
*>(gregs
);
3774 if (len
!= sizeof (cris_elf_gregset_t
)
3775 && len
!= sizeof (crisv32_elf_gregset_t
))
3776 warning (_("wrong size gregset struct in core file"));
3777 gdb_assert (len
>= sizeof (crisv32_elf_gregset_t
));
3779 /* The kernel dumps all 32 registers as unsigned longs, but supply_register
3780 knows about the actual size of each register so that's no problem. */
3781 for (i
= 0; i
< NUM_GENREGS
+ NUM_SPECREGS
; i
++)
3783 if (regnum
== -1 || regnum
== i
)
3784 regcache
->raw_supply (i
, (char *)®p
[i
]);
3787 if (tdep
->cris_version
== 32 && (regnum
== -1 || regnum
== ERP_REGNUM
))
3789 /* Needed to set pseudo-register PC for CRISv32. */
3790 /* FIXME: If ERP is in a delay slot at this point then the PC will
3791 be wrong. Issue a warning to alert the user. */
3792 regcache
->raw_supply (gdbarch_pc_regnum (gdbarch
),
3793 (char *)®p
[ERP_REGNUM
]);
3795 if (*(char *)®p
[ERP_REGNUM
] & 0x1)
3796 gdb_printf (gdb_stderr
, "Warning: PC in delay slot\n");
3800 static const struct regset cris_regset
= {
3802 cris_supply_gregset
,
3803 /* We don't need a collect function because we only use this for core files
3804 (via iterate_over_regset_sections). */
3806 REGSET_VARIABLE_SIZE
3809 static void cris_iterate_over_regset_sections (struct gdbarch
*gdbarch
,
3810 iterate_over_regset_sections_cb
*cb
,
3812 const struct regcache
*regcache
)
3814 cb (".reg", sizeof (crisv32_elf_gregset_t
), sizeof (crisv32_elf_gregset_t
),
3815 &cris_regset
, NULL
, cb_data
);
3818 void _initialize_cris_tdep ();
3820 _initialize_cris_tdep ()
3822 gdbarch_register (bfd_arch_cris
, cris_gdbarch_init
, cris_dump_tdep
);
3824 /* CRIS-specific user-commands. */
3825 add_setshow_zuinteger_cmd ("cris-version", class_support
,
3826 &usr_cmd_cris_version
,
3827 _("Set the current CRIS version."),
3828 _("Show the current CRIS version."),
3830 Set to 10 for CRISv10 or 32 for CRISv32 if autodetection fails.\n\
3833 NULL
, /* FIXME: i18n: Current CRIS version
3835 &setlist
, &showlist
);
3837 add_setshow_enum_cmd ("cris-mode", class_support
,
3838 cris_modes
, &usr_cmd_cris_mode
,
3839 _("Set the current CRIS mode."),
3840 _("Show the current CRIS mode."),
3842 Set to CRIS_MODE_GURU when debugging in guru mode.\n\
3843 Makes GDB use the NRP register instead of the ERP register in certain cases."),
3845 NULL
, /* FIXME: i18n: Current CRIS version is %s. */
3846 &setlist
, &showlist
);
3848 add_setshow_boolean_cmd ("cris-dwarf2-cfi", class_support
,
3849 &usr_cmd_cris_dwarf2_cfi
,
3850 _("Set the usage of Dwarf-2 CFI for CRIS."),
3851 _("Show the usage of Dwarf-2 CFI for CRIS."),
3852 _("Set this to \"off\" if using gcc-cris < R59."),
3853 set_cris_dwarf2_cfi
,
3854 NULL
, /* FIXME: i18n: Usage of Dwarf-2 CFI
3856 &setlist
, &showlist
);
3859 /* Prints out all target specific values. */
3862 cris_dump_tdep (struct gdbarch
*gdbarch
, struct ui_file
*file
)
3864 cris_gdbarch_tdep
*tdep
= gdbarch_tdep
<cris_gdbarch_tdep
> (gdbarch
);
3867 gdb_printf (file
, "cris_dump_tdep: tdep->cris_version = %i\n",
3868 tdep
->cris_version
);
3869 gdb_printf (file
, "cris_dump_tdep: tdep->cris_mode = %s\n",
3871 gdb_printf (file
, "cris_dump_tdep: tdep->cris_dwarf2_cfi = %i\n",
3872 tdep
->cris_dwarf2_cfi
);
3877 set_cris_version (const char *ignore_args
, int from_tty
,
3878 struct cmd_list_element
*c
)
3880 struct gdbarch_info info
;
3882 usr_cmd_cris_version_valid
= 1;
3884 /* Update the current architecture, if needed. */
3885 if (!gdbarch_update_p (info
))
3886 internal_error (__FILE__
, __LINE__
,
3887 _("cris_gdbarch_update: failed to update architecture."));
3891 set_cris_mode (const char *ignore_args
, int from_tty
,
3892 struct cmd_list_element
*c
)
3894 struct gdbarch_info info
;
3896 /* Update the current architecture, if needed. */
3897 if (!gdbarch_update_p (info
))
3898 internal_error (__FILE__
, __LINE__
,
3899 "cris_gdbarch_update: failed to update architecture.");
3903 set_cris_dwarf2_cfi (const char *ignore_args
, int from_tty
,
3904 struct cmd_list_element
*c
)
3906 struct gdbarch_info info
;
3908 /* Update the current architecture, if needed. */
3909 if (!gdbarch_update_p (info
))
3910 internal_error (__FILE__
, __LINE__
,
3911 _("cris_gdbarch_update: failed to update architecture."));
3914 static struct gdbarch
*
3915 cris_gdbarch_init (struct gdbarch_info info
, struct gdbarch_list
*arches
)
3917 struct gdbarch
*gdbarch
;
3918 unsigned int cris_version
;
3920 if (usr_cmd_cris_version_valid
)
3922 /* Trust the user's CRIS version setting. */
3923 cris_version
= usr_cmd_cris_version
;
3925 else if (info
.abfd
&& bfd_get_mach (info
.abfd
) == bfd_mach_cris_v32
)
3931 /* Assume it's CRIS version 10. */
3935 /* Make the current settings visible to the user. */
3936 usr_cmd_cris_version
= cris_version
;
3938 /* Find a candidate among the list of pre-declared architectures. */
3939 for (arches
= gdbarch_list_lookup_by_info (arches
, &info
);
3941 arches
= gdbarch_list_lookup_by_info (arches
->next
, &info
))
3943 cris_gdbarch_tdep
*tdep
3944 = gdbarch_tdep
<cris_gdbarch_tdep
> (arches
->gdbarch
);
3946 if (tdep
->cris_version
== usr_cmd_cris_version
3947 && tdep
->cris_mode
== usr_cmd_cris_mode
3948 && tdep
->cris_dwarf2_cfi
== usr_cmd_cris_dwarf2_cfi
)
3949 return arches
->gdbarch
;
3952 /* No matching architecture was found. Create a new one. */
3953 cris_gdbarch_tdep
*tdep
= new cris_gdbarch_tdep
;
3954 info
.byte_order
= BFD_ENDIAN_LITTLE
;
3955 gdbarch
= gdbarch_alloc (&info
, tdep
);
3957 tdep
->cris_version
= usr_cmd_cris_version
;
3958 tdep
->cris_mode
= usr_cmd_cris_mode
;
3959 tdep
->cris_dwarf2_cfi
= usr_cmd_cris_dwarf2_cfi
;
3961 set_gdbarch_return_value (gdbarch
, cris_return_value
);
3962 set_gdbarch_sp_regnum (gdbarch
, 14);
3964 /* Length of ordinary registers used in push_word and a few other
3965 places. register_size() is the real way to know how big a
3968 set_gdbarch_double_bit (gdbarch
, 64);
3969 /* The default definition of a long double is 2 * gdbarch_double_bit,
3970 which means we have to set this explicitly. */
3971 set_gdbarch_long_double_bit (gdbarch
, 64);
3973 /* The total amount of space needed to store (in an array called registers)
3974 GDB's copy of the machine's register state. Note: We can not use
3975 cris_register_size at this point, since it relies on gdbarch
3977 switch (tdep
->cris_version
)
3985 /* Old versions; not supported. */
3990 /* CRIS v10 and v11, a.k.a. ETRAX 100LX. In addition to ETRAX 100,
3991 P7 (32 bits), and P15 (32 bits) have been implemented. */
3992 set_gdbarch_pc_regnum (gdbarch
, 15);
3993 set_gdbarch_register_type (gdbarch
, cris_register_type
);
3994 /* There are 32 registers (some of which may not be implemented). */
3995 set_gdbarch_num_regs (gdbarch
, 32);
3996 set_gdbarch_register_name (gdbarch
, cris_register_name
);
3997 set_gdbarch_cannot_store_register (gdbarch
, cris_cannot_store_register
);
3998 set_gdbarch_cannot_fetch_register (gdbarch
, cris_cannot_fetch_register
);
4000 set_gdbarch_software_single_step (gdbarch
, cris_software_single_step
);
4004 /* CRIS v32. General registers R0 - R15 (32 bits), special registers
4005 P0 - P15 (32 bits) except P0, P1, P3 (8 bits) and P4 (16 bits)
4006 and pseudo-register PC (32 bits). */
4007 set_gdbarch_pc_regnum (gdbarch
, 32);
4008 set_gdbarch_register_type (gdbarch
, crisv32_register_type
);
4009 /* 32 registers + pseudo-register PC + 16 support registers. */
4010 set_gdbarch_num_regs (gdbarch
, 32 + 1 + 16);
4011 set_gdbarch_register_name (gdbarch
, crisv32_register_name
);
4013 set_gdbarch_cannot_store_register
4014 (gdbarch
, crisv32_cannot_store_register
);
4015 set_gdbarch_cannot_fetch_register
4016 (gdbarch
, crisv32_cannot_fetch_register
);
4018 set_gdbarch_have_nonsteppable_watchpoint (gdbarch
, 1);
4020 set_gdbarch_single_step_through_delay
4021 (gdbarch
, crisv32_single_step_through_delay
);
4026 /* Unknown version. */
4030 /* Dummy frame functions (shared between CRISv10 and CRISv32 since they
4031 have the same ABI). */
4032 set_gdbarch_push_dummy_code (gdbarch
, cris_push_dummy_code
);
4033 set_gdbarch_push_dummy_call (gdbarch
, cris_push_dummy_call
);
4034 set_gdbarch_frame_align (gdbarch
, cris_frame_align
);
4035 set_gdbarch_skip_prologue (gdbarch
, cris_skip_prologue
);
4037 /* The stack grows downward. */
4038 set_gdbarch_inner_than (gdbarch
, core_addr_lessthan
);
4040 set_gdbarch_breakpoint_kind_from_pc (gdbarch
, cris_breakpoint_kind_from_pc
);
4041 set_gdbarch_sw_breakpoint_from_kind (gdbarch
, cris_sw_breakpoint_from_kind
);
4042 set_gdbarch_iterate_over_regset_sections (gdbarch
, cris_iterate_over_regset_sections
);
4044 if (tdep
->cris_dwarf2_cfi
== 1)
4046 /* Hook in the Dwarf-2 frame sniffer. */
4047 set_gdbarch_dwarf2_reg_to_regnum (gdbarch
, cris_dwarf2_reg_to_regnum
);
4048 dwarf2_frame_set_init_reg (gdbarch
, cris_dwarf2_frame_init_reg
);
4049 dwarf2_append_unwinders (gdbarch
);
4052 if (tdep
->cris_mode
!= cris_mode_guru
)
4054 frame_unwind_append_unwinder (gdbarch
, &cris_sigtramp_frame_unwind
);
4057 frame_unwind_append_unwinder (gdbarch
, &cris_frame_unwind
);
4058 frame_base_set_default (gdbarch
, &cris_frame_base
);
4060 /* Hook in ABI-specific overrides, if they have been registered. */
4061 gdbarch_init_osabi (info
, gdbarch
);