1 /* Target dependent code for CRIS, for GDB, the GNU debugger.
3 Copyright (C) 2001-2019 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"
43 #include "solib.h" /* Support for shared libraries. */
44 #include "solib-svr4.h"
47 #include "cris-tdep.h"
51 /* There are no floating point registers. Used in gdbserver low-linux.c. */
54 /* There are 16 general registers. */
57 /* There are 16 special registers. */
60 /* CRISv32 has a pseudo PC register, not noted here. */
62 /* CRISv32 has 16 support registers. */
66 /* Register numbers of various important registers.
67 CRIS_FP_REGNUM Contains address of executing stack frame.
68 STR_REGNUM Contains the address of structure return values.
69 RET_REGNUM Contains the return value when shorter than or equal to 32 bits
70 ARG1_REGNUM Contains the first parameter to a function.
71 ARG2_REGNUM Contains the second parameter to a function.
72 ARG3_REGNUM Contains the third parameter to a function.
73 ARG4_REGNUM Contains the fourth parameter to a function. Rest on stack.
74 gdbarch_sp_regnum Contains address of top of stack.
75 gdbarch_pc_regnum Contains address of next instruction.
76 SRP_REGNUM Subroutine return pointer register.
77 BRP_REGNUM Breakpoint return pointer register. */
81 /* Enums with respect to the general registers, valid for all
82 CRIS versions. The frame pointer is always in R8. */
84 /* ABI related registers. */
92 /* Registers which happen to be common. */
97 /* CRISv10 et al. specific registers. */
109 /* CRISv32 specific registers. */
122 CRISV32USP_REGNUM
= 30, /* Shares name but not number with CRISv10. */
124 CRISV32PC_REGNUM
= 32, /* Shares name but not number with CRISv10. */
144 extern const struct cris_spec_reg cris_spec_regs
[];
146 /* CRIS version, set via the user command 'set cris-version'. Affects
147 register names and sizes. */
148 static unsigned int usr_cmd_cris_version
;
150 /* Indicates whether to trust the above variable. */
151 static int usr_cmd_cris_version_valid
= 0;
153 static const char cris_mode_normal
[] = "normal";
154 static const char cris_mode_guru
[] = "guru";
155 static const char *const cris_modes
[] = {
161 /* CRIS mode, set via the user command 'set cris-mode'. Affects
162 type of break instruction among other things. */
163 static const char *usr_cmd_cris_mode
= cris_mode_normal
;
165 /* Whether to make use of Dwarf-2 CFI (default on). */
166 static int usr_cmd_cris_dwarf2_cfi
= 1;
168 /* Sigtramp identification code copied from i386-linux-tdep.c. */
170 #define SIGTRAMP_INSN0 0x9c5f /* movu.w 0xXX, $r9 */
171 #define SIGTRAMP_OFFSET0 0
172 #define SIGTRAMP_INSN1 0xe93d /* break 13 */
173 #define SIGTRAMP_OFFSET1 4
175 static const unsigned short sigtramp_code
[] =
177 SIGTRAMP_INSN0
, 0x0077, /* movu.w $0x77, $r9 */
178 SIGTRAMP_INSN1
/* break 13 */
181 #define SIGTRAMP_LEN (sizeof sigtramp_code)
183 /* Note: same length as normal sigtramp code. */
185 static const unsigned short rt_sigtramp_code
[] =
187 SIGTRAMP_INSN0
, 0x00ad, /* movu.w $0xad, $r9 */
188 SIGTRAMP_INSN1
/* break 13 */
191 /* If PC is in a sigtramp routine, return the address of the start of
192 the routine. Otherwise, return 0. */
195 cris_sigtramp_start (struct frame_info
*this_frame
)
197 CORE_ADDR pc
= get_frame_pc (this_frame
);
198 gdb_byte buf
[SIGTRAMP_LEN
];
200 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
, SIGTRAMP_LEN
))
203 if (((buf
[1] << 8) + buf
[0]) != SIGTRAMP_INSN0
)
205 if (((buf
[1] << 8) + buf
[0]) != SIGTRAMP_INSN1
)
208 pc
-= SIGTRAMP_OFFSET1
;
209 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
, SIGTRAMP_LEN
))
213 if (memcmp (buf
, sigtramp_code
, SIGTRAMP_LEN
) != 0)
219 /* If PC is in a RT sigtramp routine, return the address of the start of
220 the routine. Otherwise, return 0. */
223 cris_rt_sigtramp_start (struct frame_info
*this_frame
)
225 CORE_ADDR pc
= get_frame_pc (this_frame
);
226 gdb_byte buf
[SIGTRAMP_LEN
];
228 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
, SIGTRAMP_LEN
))
231 if (((buf
[1] << 8) + buf
[0]) != SIGTRAMP_INSN0
)
233 if (((buf
[1] << 8) + buf
[0]) != SIGTRAMP_INSN1
)
236 pc
-= SIGTRAMP_OFFSET1
;
237 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
, SIGTRAMP_LEN
))
241 if (memcmp (buf
, rt_sigtramp_code
, SIGTRAMP_LEN
) != 0)
247 /* Assuming THIS_FRAME is a frame for a GNU/Linux sigtramp routine,
248 return the address of the associated sigcontext structure. */
251 cris_sigcontext_addr (struct frame_info
*this_frame
)
253 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
254 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
259 get_frame_register (this_frame
, gdbarch_sp_regnum (gdbarch
), buf
);
260 sp
= extract_unsigned_integer (buf
, 4, byte_order
);
262 /* Look for normal sigtramp frame first. */
263 pc
= cris_sigtramp_start (this_frame
);
266 /* struct signal_frame (arch/cris/kernel/signal.c) contains
267 struct sigcontext as its first member, meaning the SP points to
272 pc
= cris_rt_sigtramp_start (this_frame
);
275 /* struct rt_signal_frame (arch/cris/kernel/signal.c) contains
276 a struct ucontext, which in turn contains a struct sigcontext.
278 4 + 4 + 128 to struct ucontext, then
279 4 + 4 + 12 to struct sigcontext. */
283 error (_("Couldn't recognize signal trampoline."));
287 struct cris_unwind_cache
289 /* The previous frame's inner most stack address. Used as this
290 frame ID's stack_addr. */
292 /* The frame's base, optionally used by the high-level debug info. */
295 /* How far the SP and r8 (FP) have been offset from the start of
296 the stack frame (as defined by the previous frame's stack
302 /* From old frame_extra_info struct. */
306 /* Table indicating the location of each and every register. */
307 struct trad_frame_saved_reg
*saved_regs
;
310 static struct cris_unwind_cache
*
311 cris_sigtramp_frame_unwind_cache (struct frame_info
*this_frame
,
314 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
315 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
316 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
317 struct cris_unwind_cache
*info
;
323 return (struct cris_unwind_cache
*) (*this_cache
);
325 info
= FRAME_OBSTACK_ZALLOC (struct cris_unwind_cache
);
326 (*this_cache
) = info
;
327 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
329 /* Zero all fields. */
335 info
->uses_frame
= 0;
337 info
->leaf_function
= 0;
339 get_frame_register (this_frame
, gdbarch_sp_regnum (gdbarch
), buf
);
340 info
->base
= extract_unsigned_integer (buf
, 4, byte_order
);
342 addr
= cris_sigcontext_addr (this_frame
);
344 /* Layout of the sigcontext struct:
347 unsigned long oldmask;
351 if (tdep
->cris_version
== 10)
353 /* R0 to R13 are stored in reverse order at offset (2 * 4) in
355 for (i
= 0; i
<= 13; i
++)
356 info
->saved_regs
[i
].addr
= addr
+ ((15 - i
) * 4);
358 info
->saved_regs
[MOF_REGNUM
].addr
= addr
+ (16 * 4);
359 info
->saved_regs
[DCCR_REGNUM
].addr
= addr
+ (17 * 4);
360 info
->saved_regs
[SRP_REGNUM
].addr
= addr
+ (18 * 4);
361 /* Note: IRP is off by 2 at this point. There's no point in correcting
362 it though since that will mean that the backtrace will show a PC
363 different from what is shown when stopped. */
364 info
->saved_regs
[IRP_REGNUM
].addr
= addr
+ (19 * 4);
365 info
->saved_regs
[gdbarch_pc_regnum (gdbarch
)]
366 = info
->saved_regs
[IRP_REGNUM
];
367 info
->saved_regs
[gdbarch_sp_regnum (gdbarch
)].addr
= addr
+ (24 * 4);
372 /* R0 to R13 are stored in order at offset (1 * 4) in
374 for (i
= 0; i
<= 13; i
++)
375 info
->saved_regs
[i
].addr
= addr
+ ((i
+ 1) * 4);
377 info
->saved_regs
[ACR_REGNUM
].addr
= addr
+ (15 * 4);
378 info
->saved_regs
[SRS_REGNUM
].addr
= addr
+ (16 * 4);
379 info
->saved_regs
[MOF_REGNUM
].addr
= addr
+ (17 * 4);
380 info
->saved_regs
[SPC_REGNUM
].addr
= addr
+ (18 * 4);
381 info
->saved_regs
[CCS_REGNUM
].addr
= addr
+ (19 * 4);
382 info
->saved_regs
[SRP_REGNUM
].addr
= addr
+ (20 * 4);
383 info
->saved_regs
[ERP_REGNUM
].addr
= addr
+ (21 * 4);
384 info
->saved_regs
[EXS_REGNUM
].addr
= addr
+ (22 * 4);
385 info
->saved_regs
[EDA_REGNUM
].addr
= addr
+ (23 * 4);
387 /* FIXME: If ERP is in a delay slot at this point then the PC will
388 be wrong at this point. This problem manifests itself in the
389 sigaltstack.exp test case, which occasionally generates FAILs when
390 the signal is received while in a delay slot.
392 This could be solved by a couple of read_memory_unsigned_integer and a
393 trad_frame_set_value. */
394 info
->saved_regs
[gdbarch_pc_regnum (gdbarch
)]
395 = info
->saved_regs
[ERP_REGNUM
];
397 info
->saved_regs
[gdbarch_sp_regnum (gdbarch
)].addr
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
=
441 default_frame_unwind_stop_reason
,
442 cris_sigtramp_frame_this_id
,
443 cris_sigtramp_frame_prev_register
,
445 cris_sigtramp_frame_sniffer
449 crisv32_single_step_through_delay (struct gdbarch
*gdbarch
,
450 struct frame_info
*this_frame
)
452 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
456 if (tdep
->cris_mode
== cris_mode_guru
)
457 erp
= get_frame_register_unsigned (this_frame
, NRP_REGNUM
);
459 erp
= get_frame_register_unsigned (this_frame
, ERP_REGNUM
);
463 /* In delay slot - check if there's a breakpoint at the preceding
465 if (breakpoint_here_p (get_frame_address_space (this_frame
), erp
& ~0x1))
471 /* The instruction environment needed to find single-step breakpoints. */
474 struct instruction_environment
476 unsigned long reg
[NUM_GENREGS
];
477 unsigned long preg
[NUM_SPECREGS
];
478 unsigned long branch_break_address
;
479 unsigned long delay_slot_pc
;
480 unsigned long prefix_value
;
485 int delay_slot_pc_active
;
487 int disable_interrupt
;
488 enum bfd_endian byte_order
;
491 /* Machine-dependencies in CRIS for opcodes. */
493 /* Instruction sizes. */
494 enum cris_instruction_sizes
501 /* Addressing modes. */
502 enum cris_addressing_modes
509 /* Prefix addressing modes. */
510 enum cris_prefix_addressing_modes
512 PREFIX_INDEX_MODE
= 2,
513 PREFIX_ASSIGN_MODE
= 3,
515 /* Handle immediate byte offset addressing mode prefix format. */
516 PREFIX_OFFSET_MODE
= 2
519 /* Masks for opcodes. */
520 enum cris_opcode_masks
522 BRANCH_SIGNED_SHORT_OFFSET_MASK
= 0x1,
523 SIGNED_EXTEND_BIT_MASK
= 0x2,
524 SIGNED_BYTE_MASK
= 0x80,
525 SIGNED_BYTE_EXTEND_MASK
= 0xFFFFFF00,
526 SIGNED_WORD_MASK
= 0x8000,
527 SIGNED_WORD_EXTEND_MASK
= 0xFFFF0000,
528 SIGNED_DWORD_MASK
= 0x80000000,
529 SIGNED_QUICK_VALUE_MASK
= 0x20,
530 SIGNED_QUICK_VALUE_EXTEND_MASK
= 0xFFFFFFC0
533 /* Functions for opcodes. The general form of the ETRAX 16-bit instruction:
541 cris_get_operand2 (unsigned short insn
)
543 return ((insn
& 0xF000) >> 12);
547 cris_get_mode (unsigned short insn
)
549 return ((insn
& 0x0C00) >> 10);
553 cris_get_opcode (unsigned short insn
)
555 return ((insn
& 0x03C0) >> 6);
559 cris_get_size (unsigned short insn
)
561 return ((insn
& 0x0030) >> 4);
565 cris_get_operand1 (unsigned short insn
)
567 return (insn
& 0x000F);
570 /* Additional functions in order to handle opcodes. */
573 cris_get_quick_value (unsigned short insn
)
575 return (insn
& 0x003F);
579 cris_get_bdap_quick_offset (unsigned short insn
)
581 return (insn
& 0x00FF);
585 cris_get_branch_short_offset (unsigned short insn
)
587 return (insn
& 0x00FF);
591 cris_get_asr_shift_steps (unsigned long value
)
593 return (value
& 0x3F);
597 cris_get_clear_size (unsigned short insn
)
599 return ((insn
) & 0xC000);
603 cris_is_signed_extend_bit_on (unsigned short insn
)
605 return (((insn
) & 0x20) == 0x20);
609 cris_is_xflag_bit_on (unsigned short insn
)
611 return (((insn
) & 0x1000) == 0x1000);
615 cris_set_size_to_dword (unsigned short *insn
)
622 cris_get_signed_offset (unsigned short insn
)
624 return ((signed char) (insn
& 0x00FF));
627 /* Calls an op function given the op-type, working on the insn and the
629 static void cris_gdb_func (struct gdbarch
*, enum cris_op_type
, unsigned short,
632 static struct gdbarch
*cris_gdbarch_init (struct gdbarch_info
,
633 struct gdbarch_list
*);
635 static void cris_dump_tdep (struct gdbarch
*, struct ui_file
*);
637 static void set_cris_version (const char *ignore_args
, int from_tty
,
638 struct cmd_list_element
*c
);
640 static void set_cris_mode (const char *ignore_args
, int from_tty
,
641 struct cmd_list_element
*c
);
643 static void set_cris_dwarf2_cfi (const char *ignore_args
, int from_tty
,
644 struct cmd_list_element
*c
);
646 static CORE_ADDR
cris_scan_prologue (CORE_ADDR pc
,
647 struct frame_info
*this_frame
,
648 struct cris_unwind_cache
*info
);
650 static CORE_ADDR
crisv32_scan_prologue (CORE_ADDR pc
,
651 struct frame_info
*this_frame
,
652 struct cris_unwind_cache
*info
);
654 /* When arguments must be pushed onto the stack, they go on in reverse
655 order. The below implements a FILO (stack) to do this.
656 Copied from d10v-tdep.c. */
661 struct stack_item
*prev
;
665 static struct stack_item
*
666 push_stack_item (struct stack_item
*prev
, const gdb_byte
*contents
, int len
)
668 struct stack_item
*si
= XNEW (struct stack_item
);
669 si
->data
= (gdb_byte
*) xmalloc (len
);
672 memcpy (si
->data
, contents
, len
);
676 static struct stack_item
*
677 pop_stack_item (struct stack_item
*si
)
679 struct stack_item
*dead
= si
;
686 /* Put here the code to store, into fi->saved_regs, the addresses of
687 the saved registers of frame described by FRAME_INFO. This
688 includes special registers such as pc and fp saved in special ways
689 in the stack frame. sp is even more special: the address we return
690 for it IS the sp for the next frame. */
692 static struct cris_unwind_cache
*
693 cris_frame_unwind_cache (struct frame_info
*this_frame
,
694 void **this_prologue_cache
)
696 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
697 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
698 struct cris_unwind_cache
*info
;
700 if ((*this_prologue_cache
))
701 return (struct cris_unwind_cache
*) (*this_prologue_cache
);
703 info
= FRAME_OBSTACK_ZALLOC (struct cris_unwind_cache
);
704 (*this_prologue_cache
) = info
;
705 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
707 /* Zero all fields. */
713 info
->uses_frame
= 0;
715 info
->leaf_function
= 0;
717 /* Prologue analysis does the rest... */
718 if (tdep
->cris_version
== 32)
719 crisv32_scan_prologue (get_frame_func (this_frame
), this_frame
, info
);
721 cris_scan_prologue (get_frame_func (this_frame
), this_frame
, info
);
726 /* Given a GDB frame, determine the address of the calling function's
727 frame. This will be used to create a new GDB frame struct. */
730 cris_frame_this_id (struct frame_info
*this_frame
,
731 void **this_prologue_cache
,
732 struct frame_id
*this_id
)
734 struct cris_unwind_cache
*info
735 = cris_frame_unwind_cache (this_frame
, this_prologue_cache
);
740 /* The FUNC is easy. */
741 func
= get_frame_func (this_frame
);
743 /* Hopefully the prologue analysis either correctly determined the
744 frame's base (which is the SP from the previous frame), or set
745 that base to "NULL". */
746 base
= info
->prev_sp
;
750 id
= frame_id_build (base
, func
);
755 static struct value
*
756 cris_frame_prev_register (struct frame_info
*this_frame
,
757 void **this_prologue_cache
, int regnum
)
759 struct cris_unwind_cache
*info
760 = cris_frame_unwind_cache (this_frame
, this_prologue_cache
);
761 return trad_frame_get_prev_register (this_frame
, info
->saved_regs
, regnum
);
765 cris_frame_align (struct gdbarch
*gdbarch
, CORE_ADDR sp
)
767 /* Align to the size of an instruction (so that they can safely be
768 pushed onto the stack). */
773 cris_push_dummy_code (struct gdbarch
*gdbarch
,
774 CORE_ADDR sp
, CORE_ADDR funaddr
,
775 struct value
**args
, int nargs
,
776 struct type
*value_type
,
777 CORE_ADDR
*real_pc
, CORE_ADDR
*bp_addr
,
778 struct regcache
*regcache
)
780 /* Allocate space sufficient for a breakpoint. */
782 /* Store the address of that breakpoint */
784 /* CRIS always starts the call at the callee's entry point. */
790 cris_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
791 struct regcache
*regcache
, CORE_ADDR bp_addr
,
792 int nargs
, struct value
**args
, CORE_ADDR sp
,
793 function_call_return_method return_method
,
794 CORE_ADDR struct_addr
)
796 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
800 struct stack_item
*si
= NULL
;
802 /* Push the return address. */
803 regcache_cooked_write_unsigned (regcache
, SRP_REGNUM
, bp_addr
);
805 /* Are we returning a value using a structure return or a normal value
806 return? struct_addr is the address of the reserved space for the return
807 structure to be written on the stack. */
808 if (return_method
== return_method_struct
)
809 regcache_cooked_write_unsigned (regcache
, STR_REGNUM
, struct_addr
);
811 /* Now load as many as possible of the first arguments into registers,
812 and push the rest onto the stack. */
813 argreg
= ARG1_REGNUM
;
815 for (argnum
= 0; argnum
< nargs
; argnum
++)
822 len
= TYPE_LENGTH (value_type (args
[argnum
]));
823 val
= value_contents (args
[argnum
]);
825 /* How may registers worth of storage do we need for this argument? */
826 reg_demand
= (len
/ 4) + (len
% 4 != 0 ? 1 : 0);
828 if (len
<= (2 * 4) && (argreg
+ reg_demand
- 1 <= ARG4_REGNUM
))
830 /* Data passed by value. Fits in available register(s). */
831 for (i
= 0; i
< reg_demand
; i
++)
833 regcache
->cooked_write (argreg
, val
);
838 else if (len
<= (2 * 4) && argreg
<= ARG4_REGNUM
)
840 /* Data passed by value. Does not fit in available register(s).
841 Use the register(s) first, then the stack. */
842 for (i
= 0; i
< reg_demand
; i
++)
844 if (argreg
<= ARG4_REGNUM
)
846 regcache
->cooked_write (argreg
, val
);
852 /* Push item for later so that pushed arguments
853 come in the right order. */
854 si
= push_stack_item (si
, val
, 4);
859 else if (len
> (2 * 4))
861 /* Data passed by reference. Push copy of data onto stack
862 and pass pointer to this copy as argument. */
863 sp
= (sp
- len
) & ~3;
864 write_memory (sp
, val
, len
);
866 if (argreg
<= ARG4_REGNUM
)
868 regcache_cooked_write_unsigned (regcache
, argreg
, sp
);
874 store_unsigned_integer (buf
, 4, byte_order
, sp
);
875 si
= push_stack_item (si
, buf
, 4);
880 /* Data passed by value. No available registers. Put it on
882 si
= push_stack_item (si
, val
, len
);
888 /* fp_arg must be word-aligned (i.e., don't += len) to match
889 the function prologue. */
890 sp
= (sp
- si
->len
) & ~3;
891 write_memory (sp
, si
->data
, si
->len
);
892 si
= pop_stack_item (si
);
895 /* Finally, update the SP register. */
896 regcache_cooked_write_unsigned (regcache
, gdbarch_sp_regnum (gdbarch
), sp
);
901 static const struct frame_unwind cris_frame_unwind
=
904 default_frame_unwind_stop_reason
,
906 cris_frame_prev_register
,
908 default_frame_sniffer
912 cris_frame_base_address (struct frame_info
*this_frame
, void **this_cache
)
914 struct cris_unwind_cache
*info
915 = cris_frame_unwind_cache (this_frame
, this_cache
);
919 static const struct frame_base cris_frame_base
=
922 cris_frame_base_address
,
923 cris_frame_base_address
,
924 cris_frame_base_address
927 /* Frames information. The definition of the struct frame_info is
931 enum frame_type type;
935 If the compilation option -fno-omit-frame-pointer is present the
936 variable frame will be set to the content of R8 which is the frame
939 The variable pc contains the address where execution is performed
940 in the present frame. The innermost frame contains the current content
941 of the register PC. All other frames contain the content of the
942 register PC in the next frame.
944 The variable `type' indicates the frame's type: normal, SIGTRAMP
945 (associated with a signal handler), dummy (associated with a dummy
948 The variable return_pc contains the address where execution should be
949 resumed when the present frame has finished, the return address.
951 The variable leaf_function is 1 if the return address is in the register
952 SRP, and 0 if it is on the stack.
954 Prologue instructions C-code.
955 The prologue may consist of (-fno-omit-frame-pointer)
959 move.d sp,r8 move.d sp,r8
961 movem rY,[sp] movem rY,[sp]
962 move.S rZ,[r8-U] move.S rZ,[r8-U]
964 where 1 is a non-terminal function, and 2 is a leaf-function.
966 Note that this assumption is extremely brittle, and will break at the
967 slightest change in GCC's prologue.
969 If local variables are declared or register contents are saved on stack
970 the subq-instruction will be present with X as the number of bytes
971 needed for storage. The reshuffle with respect to r8 may be performed
972 with any size S (b, w, d) and any of the general registers Z={0..13}.
973 The offset U should be representable by a signed 8-bit value in all cases.
974 Thus, the prefix word is assumed to be immediate byte offset mode followed
975 by another word containing the instruction.
984 Prologue instructions C++-code.
985 Case 1) and 2) in the C-code may be followed by
991 move.S [r8+U],rZ ; P4
993 if any of the call parameters are stored. The host expects these
994 instructions to be executed in order to get the call parameters right. */
996 /* Examine the prologue of a function. The variable ip is the address of
997 the first instruction of the prologue. The variable limit is the address
998 of the first instruction after the prologue. The variable fi contains the
999 information in struct frame_info. The variable frameless_p controls whether
1000 the entire prologue is examined (0) or just enough instructions to
1001 determine that it is a prologue (1). */
1004 cris_scan_prologue (CORE_ADDR pc
, struct frame_info
*this_frame
,
1005 struct cris_unwind_cache
*info
)
1007 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1008 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1010 /* Present instruction. */
1011 unsigned short insn
;
1013 /* Next instruction, lookahead. */
1014 unsigned short insn_next
;
1017 /* Number of byte on stack used for local variables and movem. */
1020 /* Highest register number in a movem. */
1023 /* move.d r<source_register>,rS */
1024 short source_register
;
1029 /* This frame is with respect to a leaf until a push srp is found. */
1032 info
->leaf_function
= 1;
1035 /* Assume nothing on stack. */
1039 /* If we were called without a this_frame, that means we were called
1040 from cris_skip_prologue which already tried to find the end of the
1041 prologue through the symbol information. 64 instructions past current
1042 pc is arbitrarily chosen, but at least it means we'll stop eventually. */
1043 limit
= this_frame
? get_frame_pc (this_frame
) : pc
+ 64;
1045 /* Find the prologue instructions. */
1046 while (pc
> 0 && pc
< limit
)
1048 insn
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1052 /* push <reg> 32 bit instruction. */
1053 insn_next
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1055 regno
= cris_get_operand2 (insn_next
);
1058 info
->sp_offset
+= 4;
1060 /* This check, meant to recognize srp, used to be regno ==
1061 (SRP_REGNUM - NUM_GENREGS), but that covers r11 also. */
1062 if (insn_next
== 0xBE7E)
1066 info
->leaf_function
= 0;
1069 else if (insn_next
== 0x8FEE)
1074 info
->r8_offset
= info
->sp_offset
;
1078 else if (insn
== 0x866E)
1083 info
->uses_frame
= 1;
1087 else if (cris_get_operand2 (insn
) == gdbarch_sp_regnum (gdbarch
)
1088 && cris_get_mode (insn
) == 0x0000
1089 && cris_get_opcode (insn
) == 0x000A)
1094 info
->sp_offset
+= cris_get_quick_value (insn
);
1097 else if (cris_get_mode (insn
) == 0x0002
1098 && cris_get_opcode (insn
) == 0x000F
1099 && cris_get_size (insn
) == 0x0003
1100 && cris_get_operand1 (insn
) == gdbarch_sp_regnum (gdbarch
))
1102 /* movem r<regsave>,[sp] */
1103 regsave
= cris_get_operand2 (insn
);
1105 else if (cris_get_operand2 (insn
) == gdbarch_sp_regnum (gdbarch
)
1106 && ((insn
& 0x0F00) >> 8) == 0x0001
1107 && (cris_get_signed_offset (insn
) < 0))
1109 /* Immediate byte offset addressing prefix word with sp as base
1110 register. Used for CRIS v8 i.e. ETRAX 100 and newer if <val>
1111 is between 64 and 128.
1112 movem r<regsave>,[sp=sp-<val>] */
1115 info
->sp_offset
+= -cris_get_signed_offset (insn
);
1117 insn_next
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1119 if (cris_get_mode (insn_next
) == PREFIX_ASSIGN_MODE
1120 && cris_get_opcode (insn_next
) == 0x000F
1121 && cris_get_size (insn_next
) == 0x0003
1122 && cris_get_operand1 (insn_next
) == gdbarch_sp_regnum
1125 regsave
= cris_get_operand2 (insn_next
);
1129 /* The prologue ended before the limit was reached. */
1134 else if (cris_get_mode (insn
) == 0x0001
1135 && cris_get_opcode (insn
) == 0x0009
1136 && cris_get_size (insn
) == 0x0002)
1138 /* move.d r<10..13>,r<0..15> */
1139 source_register
= cris_get_operand1 (insn
);
1141 /* FIXME? In the glibc solibs, the prologue might contain something
1142 like (this example taken from relocate_doit):
1144 sub.d 0xfffef426,$r0
1145 which isn't covered by the source_register check below. Question
1146 is whether to add a check for this combo, or make better use of
1147 the limit variable instead. */
1148 if (source_register
< ARG1_REGNUM
|| source_register
> ARG4_REGNUM
)
1150 /* The prologue ended before the limit was reached. */
1155 else if (cris_get_operand2 (insn
) == CRIS_FP_REGNUM
1156 /* The size is a fixed-size. */
1157 && ((insn
& 0x0F00) >> 8) == 0x0001
1158 /* A negative offset. */
1159 && (cris_get_signed_offset (insn
) < 0))
1161 /* move.S rZ,[r8-U] (?) */
1162 insn_next
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1164 regno
= cris_get_operand2 (insn_next
);
1165 if ((regno
>= 0 && regno
< gdbarch_sp_regnum (gdbarch
))
1166 && cris_get_mode (insn_next
) == PREFIX_OFFSET_MODE
1167 && cris_get_opcode (insn_next
) == 0x000F)
1169 /* move.S rZ,[r8-U] */
1174 /* The prologue ended before the limit was reached. */
1179 else if (cris_get_operand2 (insn
) == CRIS_FP_REGNUM
1180 /* The size is a fixed-size. */
1181 && ((insn
& 0x0F00) >> 8) == 0x0001
1182 /* A positive offset. */
1183 && (cris_get_signed_offset (insn
) > 0))
1185 /* move.S [r8+U],rZ (?) */
1186 insn_next
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1188 regno
= cris_get_operand2 (insn_next
);
1189 if ((regno
>= 0 && regno
< gdbarch_sp_regnum (gdbarch
))
1190 && cris_get_mode (insn_next
) == PREFIX_OFFSET_MODE
1191 && cris_get_opcode (insn_next
) == 0x0009
1192 && cris_get_operand1 (insn_next
) == regno
)
1194 /* move.S [r8+U],rZ */
1199 /* The prologue ended before the limit was reached. */
1206 /* The prologue ended before the limit was reached. */
1212 /* We only want to know the end of the prologue when this_frame and info
1213 are NULL (called from cris_skip_prologue i.e.). */
1214 if (this_frame
== NULL
&& info
== NULL
)
1219 info
->size
= info
->sp_offset
;
1221 /* Compute the previous frame's stack pointer (which is also the
1222 frame's ID's stack address), and this frame's base pointer. */
1223 if (info
->uses_frame
)
1226 /* The SP was moved to the FP. This indicates that a new frame
1227 was created. Get THIS frame's FP value by unwinding it from
1229 this_base
= get_frame_register_unsigned (this_frame
, CRIS_FP_REGNUM
);
1230 info
->base
= this_base
;
1231 info
->saved_regs
[CRIS_FP_REGNUM
].addr
= info
->base
;
1233 /* The FP points at the last saved register. Adjust the FP back
1234 to before the first saved register giving the SP. */
1235 info
->prev_sp
= info
->base
+ info
->r8_offset
;
1240 /* Assume that the FP is this frame's SP but with that pushed
1241 stack space added back. */
1242 this_base
= get_frame_register_unsigned (this_frame
,
1243 gdbarch_sp_regnum (gdbarch
));
1244 info
->base
= this_base
;
1245 info
->prev_sp
= info
->base
+ info
->size
;
1248 /* Calculate the addresses for the saved registers on the stack. */
1249 /* FIXME: The address calculation should really be done on the fly while
1250 we're analyzing the prologue (we only hold one regsave value as it is
1252 val
= info
->sp_offset
;
1254 for (regno
= regsave
; regno
>= 0; regno
--)
1256 info
->saved_regs
[regno
].addr
= info
->base
+ info
->r8_offset
- val
;
1260 /* The previous frame's SP needed to be computed. Save the computed
1262 trad_frame_set_value (info
->saved_regs
,
1263 gdbarch_sp_regnum (gdbarch
), info
->prev_sp
);
1265 if (!info
->leaf_function
)
1267 /* SRP saved on the stack. But where? */
1268 if (info
->r8_offset
== 0)
1270 /* R8 not pushed yet. */
1271 info
->saved_regs
[SRP_REGNUM
].addr
= info
->base
;
1275 /* R8 pushed, but SP may or may not be moved to R8 yet. */
1276 info
->saved_regs
[SRP_REGNUM
].addr
= info
->base
+ 4;
1280 /* The PC is found in SRP (the actual register or located on the stack). */
1281 info
->saved_regs
[gdbarch_pc_regnum (gdbarch
)]
1282 = info
->saved_regs
[SRP_REGNUM
];
1288 crisv32_scan_prologue (CORE_ADDR pc
, struct frame_info
*this_frame
,
1289 struct cris_unwind_cache
*info
)
1291 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1294 /* Unlike the CRISv10 prologue scanner (cris_scan_prologue), this is not
1295 meant to be a full-fledged prologue scanner. It is only needed for
1296 the cases where we end up in code always lacking DWARF-2 CFI, notably:
1298 * PLT stubs (library calls)
1300 * signal trampolines
1302 For those cases, it is assumed that there is no actual prologue; that
1303 the stack pointer is not adjusted, and (as a consequence) the return
1304 address is not pushed onto the stack. */
1306 /* We only want to know the end of the prologue when this_frame and info
1307 are NULL (called from cris_skip_prologue i.e.). */
1308 if (this_frame
== NULL
&& info
== NULL
)
1313 /* The SP is assumed to be unaltered. */
1314 this_base
= get_frame_register_unsigned (this_frame
,
1315 gdbarch_sp_regnum (gdbarch
));
1316 info
->base
= this_base
;
1317 info
->prev_sp
= this_base
;
1319 /* The PC is assumed to be found in SRP. */
1320 info
->saved_regs
[gdbarch_pc_regnum (gdbarch
)]
1321 = info
->saved_regs
[SRP_REGNUM
];
1326 /* Advance pc beyond any function entry prologue instructions at pc
1327 to reach some "real" code. */
1329 /* Given a PC value corresponding to the start of a function, return the PC
1330 of the first instruction after the function prologue. */
1333 cris_skip_prologue (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
1335 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1336 CORE_ADDR func_addr
, func_end
;
1337 struct symtab_and_line sal
;
1338 CORE_ADDR pc_after_prologue
;
1340 /* If we have line debugging information, then the end of the prologue
1341 should the first assembly instruction of the first source line. */
1342 if (find_pc_partial_function (pc
, NULL
, &func_addr
, &func_end
))
1344 sal
= find_pc_line (func_addr
, 0);
1345 if (sal
.end
> 0 && sal
.end
< func_end
)
1349 if (tdep
->cris_version
== 32)
1350 pc_after_prologue
= crisv32_scan_prologue (pc
, NULL
, NULL
);
1352 pc_after_prologue
= cris_scan_prologue (pc
, NULL
, NULL
);
1354 return pc_after_prologue
;
1357 /* Implement the breakpoint_kind_from_pc gdbarch method. */
1360 cris_breakpoint_kind_from_pc (struct gdbarch
*gdbarch
, CORE_ADDR
*pcptr
)
1365 /* Implement the sw_breakpoint_from_kind gdbarch method. */
1367 static const gdb_byte
*
1368 cris_sw_breakpoint_from_kind (struct gdbarch
*gdbarch
, int kind
, int *size
)
1370 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1371 static unsigned char break8_insn
[] = {0x38, 0xe9};
1372 static unsigned char break15_insn
[] = {0x3f, 0xe9};
1376 if (tdep
->cris_mode
== cris_mode_guru
)
1377 return break15_insn
;
1382 /* Returns 1 if spec_reg is applicable to the current gdbarch's CRIS version,
1386 cris_spec_reg_applicable (struct gdbarch
*gdbarch
,
1387 struct cris_spec_reg spec_reg
)
1389 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1390 unsigned int version
= tdep
->cris_version
;
1392 switch (spec_reg
.applicable_version
)
1394 case cris_ver_version_all
:
1396 case cris_ver_warning
:
1397 /* Indeterminate/obsolete. */
1400 return in_inclusive_range (version
, 0U, 3U);
1402 return (version
>= 3);
1404 return in_inclusive_range (version
, 8U, 9U);
1406 return (version
>= 8);
1407 case cris_ver_v0_10
:
1408 return in_inclusive_range (version
, 0U, 10U);
1409 case cris_ver_v3_10
:
1410 return in_inclusive_range (version
, 3U, 10U);
1411 case cris_ver_v8_10
:
1412 return in_inclusive_range (version
, 8U, 10U);
1414 return (version
== 10);
1416 return (version
>= 10);
1418 return (version
>= 32);
1420 /* Invalid cris version. */
1425 /* Returns the register size in unit byte. Returns 0 for an unimplemented
1426 register, -1 for an invalid register. */
1429 cris_register_size (struct gdbarch
*gdbarch
, int regno
)
1434 if (regno
>= 0 && regno
< NUM_GENREGS
)
1436 /* General registers (R0 - R15) are 32 bits. */
1439 else if (regno
>= NUM_GENREGS
&& regno
< (NUM_GENREGS
+ NUM_SPECREGS
))
1441 /* Special register (R16 - R31). cris_spec_regs is zero-based.
1442 Adjust regno accordingly. */
1443 spec_regno
= regno
- NUM_GENREGS
;
1445 for (i
= 0; cris_spec_regs
[i
].name
!= NULL
; i
++)
1447 if (cris_spec_regs
[i
].number
== spec_regno
1448 && cris_spec_reg_applicable (gdbarch
, cris_spec_regs
[i
]))
1449 /* Go with the first applicable register. */
1450 return cris_spec_regs
[i
].reg_size
;
1452 /* Special register not applicable to this CRIS version. */
1455 else if (regno
>= gdbarch_pc_regnum (gdbarch
)
1456 && regno
< gdbarch_num_regs (gdbarch
))
1458 /* This will apply to CRISv32 only where there are additional registers
1459 after the special registers (pseudo PC and support registers). */
1467 /* Nonzero if regno should not be fetched from the target. This is the case
1468 for unimplemented (size 0) and non-existant registers. */
1471 cris_cannot_fetch_register (struct gdbarch
*gdbarch
, int regno
)
1473 return ((regno
< 0 || regno
>= gdbarch_num_regs (gdbarch
))
1474 || (cris_register_size (gdbarch
, regno
) == 0));
1477 /* Nonzero if regno should not be written to the target, for various
1481 cris_cannot_store_register (struct gdbarch
*gdbarch
, int regno
)
1483 /* There are three kinds of registers we refuse to write to.
1484 1. Those that not implemented.
1485 2. Those that are read-only (depends on the processor mode).
1486 3. Those registers to which a write has no effect. */
1489 || regno
>= gdbarch_num_regs (gdbarch
)
1490 || cris_register_size (gdbarch
, regno
) == 0)
1491 /* Not implemented. */
1494 else if (regno
== VR_REGNUM
)
1498 else if (regno
== P0_REGNUM
|| regno
== P4_REGNUM
|| regno
== P8_REGNUM
)
1499 /* Writing has no effect. */
1502 /* IBR, BAR, BRP and IRP are read-only in user mode. Let the debug
1503 agent decide whether they are writable. */
1508 /* Nonzero if regno should not be fetched from the target. This is the case
1509 for unimplemented (size 0) and non-existant registers. */
1512 crisv32_cannot_fetch_register (struct gdbarch
*gdbarch
, int regno
)
1514 return ((regno
< 0 || regno
>= gdbarch_num_regs (gdbarch
))
1515 || (cris_register_size (gdbarch
, regno
) == 0));
1518 /* Nonzero if regno should not be written to the target, for various
1522 crisv32_cannot_store_register (struct gdbarch
*gdbarch
, int regno
)
1524 /* There are three kinds of registers we refuse to write to.
1525 1. Those that not implemented.
1526 2. Those that are read-only (depends on the processor mode).
1527 3. Those registers to which a write has no effect. */
1530 || regno
>= gdbarch_num_regs (gdbarch
)
1531 || cris_register_size (gdbarch
, regno
) == 0)
1532 /* Not implemented. */
1535 else if (regno
== VR_REGNUM
)
1539 else if (regno
== BZ_REGNUM
|| regno
== WZ_REGNUM
|| regno
== DZ_REGNUM
)
1540 /* Writing has no effect. */
1543 /* Many special registers are read-only in user mode. Let the debug
1544 agent decide whether they are writable. */
1549 /* Return the GDB type (defined in gdbtypes.c) for the "standard" data type
1550 of data in register regno. */
1552 static struct type
*
1553 cris_register_type (struct gdbarch
*gdbarch
, int regno
)
1555 if (regno
== gdbarch_pc_regnum (gdbarch
))
1556 return builtin_type (gdbarch
)->builtin_func_ptr
;
1557 else if (regno
== gdbarch_sp_regnum (gdbarch
)
1558 || regno
== CRIS_FP_REGNUM
)
1559 return builtin_type (gdbarch
)->builtin_data_ptr
;
1560 else if ((regno
>= 0 && regno
< gdbarch_sp_regnum (gdbarch
))
1561 || (regno
>= MOF_REGNUM
&& regno
<= USP_REGNUM
))
1562 /* Note: R8 taken care of previous clause. */
1563 return builtin_type (gdbarch
)->builtin_uint32
;
1564 else if (regno
>= P4_REGNUM
&& regno
<= CCR_REGNUM
)
1565 return builtin_type (gdbarch
)->builtin_uint16
;
1566 else if (regno
>= P0_REGNUM
&& regno
<= VR_REGNUM
)
1567 return builtin_type (gdbarch
)->builtin_uint8
;
1569 /* Invalid (unimplemented) register. */
1570 return builtin_type (gdbarch
)->builtin_int0
;
1573 static struct type
*
1574 crisv32_register_type (struct gdbarch
*gdbarch
, int regno
)
1576 if (regno
== gdbarch_pc_regnum (gdbarch
))
1577 return builtin_type (gdbarch
)->builtin_func_ptr
;
1578 else if (regno
== gdbarch_sp_regnum (gdbarch
)
1579 || regno
== CRIS_FP_REGNUM
)
1580 return builtin_type (gdbarch
)->builtin_data_ptr
;
1581 else if ((regno
>= 0 && regno
<= ACR_REGNUM
)
1582 || (regno
>= EXS_REGNUM
&& regno
<= SPC_REGNUM
)
1583 || (regno
== PID_REGNUM
)
1584 || (regno
>= S0_REGNUM
&& regno
<= S15_REGNUM
))
1585 /* Note: R8 and SP taken care of by previous clause. */
1586 return builtin_type (gdbarch
)->builtin_uint32
;
1587 else if (regno
== WZ_REGNUM
)
1588 return builtin_type (gdbarch
)->builtin_uint16
;
1589 else if (regno
== BZ_REGNUM
|| regno
== VR_REGNUM
|| regno
== SRS_REGNUM
)
1590 return builtin_type (gdbarch
)->builtin_uint8
;
1593 /* Invalid (unimplemented) register. Should not happen as there are
1594 no unimplemented CRISv32 registers. */
1595 warning (_("crisv32_register_type: unknown regno %d"), regno
);
1596 return builtin_type (gdbarch
)->builtin_int0
;
1600 /* Stores a function return value of type type, where valbuf is the address
1601 of the value to be stored. */
1603 /* In the CRIS ABI, R10 and R11 are used to store return values. */
1606 cris_store_return_value (struct type
*type
, struct regcache
*regcache
,
1607 const gdb_byte
*valbuf
)
1609 struct gdbarch
*gdbarch
= regcache
->arch ();
1610 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1612 int len
= TYPE_LENGTH (type
);
1616 /* Put the return value in R10. */
1617 val
= extract_unsigned_integer (valbuf
, len
, byte_order
);
1618 regcache_cooked_write_unsigned (regcache
, ARG1_REGNUM
, val
);
1622 /* Put the return value in R10 and R11. */
1623 val
= extract_unsigned_integer (valbuf
, 4, byte_order
);
1624 regcache_cooked_write_unsigned (regcache
, ARG1_REGNUM
, val
);
1625 val
= extract_unsigned_integer (valbuf
+ 4, len
- 4, byte_order
);
1626 regcache_cooked_write_unsigned (regcache
, ARG2_REGNUM
, val
);
1629 error (_("cris_store_return_value: type length too large."));
1632 /* Return the name of register regno as a string. Return NULL for an
1633 invalid or unimplemented register. */
1636 cris_special_register_name (struct gdbarch
*gdbarch
, int regno
)
1641 /* Special register (R16 - R31). cris_spec_regs is zero-based.
1642 Adjust regno accordingly. */
1643 spec_regno
= regno
- NUM_GENREGS
;
1645 /* Assume nothing about the layout of the cris_spec_regs struct
1647 for (i
= 0; cris_spec_regs
[i
].name
!= NULL
; i
++)
1649 if (cris_spec_regs
[i
].number
== spec_regno
1650 && cris_spec_reg_applicable (gdbarch
, cris_spec_regs
[i
]))
1651 /* Go with the first applicable register. */
1652 return cris_spec_regs
[i
].name
;
1654 /* Special register not applicable to this CRIS version. */
1659 cris_register_name (struct gdbarch
*gdbarch
, int regno
)
1661 static const char *cris_genreg_names
[] =
1662 { "r0", "r1", "r2", "r3", \
1663 "r4", "r5", "r6", "r7", \
1664 "r8", "r9", "r10", "r11", \
1665 "r12", "r13", "sp", "pc" };
1667 if (regno
>= 0 && regno
< NUM_GENREGS
)
1669 /* General register. */
1670 return cris_genreg_names
[regno
];
1672 else if (regno
>= NUM_GENREGS
&& regno
< gdbarch_num_regs (gdbarch
))
1674 return cris_special_register_name (gdbarch
, regno
);
1678 /* Invalid register. */
1684 crisv32_register_name (struct gdbarch
*gdbarch
, int regno
)
1686 static const char *crisv32_genreg_names
[] =
1687 { "r0", "r1", "r2", "r3", \
1688 "r4", "r5", "r6", "r7", \
1689 "r8", "r9", "r10", "r11", \
1690 "r12", "r13", "sp", "acr"
1693 static const char *crisv32_sreg_names
[] =
1694 { "s0", "s1", "s2", "s3", \
1695 "s4", "s5", "s6", "s7", \
1696 "s8", "s9", "s10", "s11", \
1697 "s12", "s13", "s14", "s15"
1700 if (regno
>= 0 && regno
< NUM_GENREGS
)
1702 /* General register. */
1703 return crisv32_genreg_names
[regno
];
1705 else if (regno
>= NUM_GENREGS
&& regno
< (NUM_GENREGS
+ NUM_SPECREGS
))
1707 return cris_special_register_name (gdbarch
, regno
);
1709 else if (regno
== gdbarch_pc_regnum (gdbarch
))
1713 else if (regno
>= S0_REGNUM
&& regno
<= S15_REGNUM
)
1715 return crisv32_sreg_names
[regno
- S0_REGNUM
];
1719 /* Invalid register. */
1724 /* Convert DWARF register number REG to the appropriate register
1725 number used by GDB. */
1728 cris_dwarf2_reg_to_regnum (struct gdbarch
*gdbarch
, int reg
)
1730 /* We need to re-map a couple of registers (SRP is 16 in Dwarf-2 register
1731 numbering, MOF is 18).
1732 Adapted from gcc/config/cris/cris.h. */
1733 static int cris_dwarf_regmap
[] = {
1745 if (reg
>= 0 && reg
< ARRAY_SIZE (cris_dwarf_regmap
))
1746 regnum
= cris_dwarf_regmap
[reg
];
1751 /* DWARF-2 frame support. */
1754 cris_dwarf2_frame_init_reg (struct gdbarch
*gdbarch
, int regnum
,
1755 struct dwarf2_frame_state_reg
*reg
,
1756 struct frame_info
*this_frame
)
1758 /* The return address column. */
1759 if (regnum
== gdbarch_pc_regnum (gdbarch
))
1760 reg
->how
= DWARF2_FRAME_REG_RA
;
1762 /* The call frame address. */
1763 else if (regnum
== gdbarch_sp_regnum (gdbarch
))
1764 reg
->how
= DWARF2_FRAME_REG_CFA
;
1767 /* Extract from an array regbuf containing the raw register state a function
1768 return value of type type, and copy that, in virtual format, into
1771 /* In the CRIS ABI, R10 and R11 are used to store return values. */
1774 cris_extract_return_value (struct type
*type
, struct regcache
*regcache
,
1777 struct gdbarch
*gdbarch
= regcache
->arch ();
1778 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1780 int len
= TYPE_LENGTH (type
);
1784 /* Get the return value from R10. */
1785 regcache_cooked_read_unsigned (regcache
, ARG1_REGNUM
, &val
);
1786 store_unsigned_integer (valbuf
, len
, byte_order
, val
);
1790 /* Get the return value from R10 and R11. */
1791 regcache_cooked_read_unsigned (regcache
, ARG1_REGNUM
, &val
);
1792 store_unsigned_integer (valbuf
, 4, byte_order
, val
);
1793 regcache_cooked_read_unsigned (regcache
, ARG2_REGNUM
, &val
);
1794 store_unsigned_integer (valbuf
+ 4, len
- 4, byte_order
, val
);
1797 error (_("cris_extract_return_value: type length too large"));
1800 /* Handle the CRIS return value convention. */
1802 static enum return_value_convention
1803 cris_return_value (struct gdbarch
*gdbarch
, struct value
*function
,
1804 struct type
*type
, struct regcache
*regcache
,
1805 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
1807 if (TYPE_CODE (type
) == TYPE_CODE_STRUCT
1808 || TYPE_CODE (type
) == TYPE_CODE_UNION
1809 || TYPE_LENGTH (type
) > 8)
1810 /* Structs, unions, and anything larger than 8 bytes (2 registers)
1811 goes on the stack. */
1812 return RETURN_VALUE_STRUCT_CONVENTION
;
1815 cris_extract_return_value (type
, regcache
, readbuf
);
1817 cris_store_return_value (type
, regcache
, writebuf
);
1819 return RETURN_VALUE_REGISTER_CONVENTION
;
1822 /* Calculates a value that measures how good inst_args constraints an
1823 instruction. It stems from cris_constraint, found in cris-dis.c. */
1826 constraint (unsigned int insn
, const char *inst_args
,
1827 inst_env_type
*inst_env
)
1832 const gdb_byte
*s
= (const gdb_byte
*) inst_args
;
1838 if ((insn
& 0x30) == 0x30)
1843 /* A prefix operand. */
1844 if (inst_env
->prefix_found
)
1850 /* A "push" prefix. (This check was REMOVED by san 970921.) Check for
1851 valid "push" size. In case of special register, it may be != 4. */
1852 if (inst_env
->prefix_found
)
1858 retval
= (((insn
>> 0xC) & 0xF) == (insn
& 0xF));
1866 tmp
= (insn
>> 0xC) & 0xF;
1868 for (i
= 0; cris_spec_regs
[i
].name
!= NULL
; i
++)
1870 /* Since we match four bits, we will give a value of
1871 4 - 1 = 3 in a match. If there is a corresponding
1872 exact match of a special register in another pattern, it
1873 will get a value of 4, which will be higher. This should
1874 be correct in that an exact pattern would match better that
1876 Note that there is a reason for not returning zero; the
1877 pattern for "clear" is partly matched in the bit-pattern
1878 (the two lower bits must be zero), while the bit-pattern
1879 for a move from a special register is matched in the
1880 register constraint.
1881 This also means we will will have a race condition if
1882 there is a partly match in three bits in the bit pattern. */
1883 if (tmp
== cris_spec_regs
[i
].number
)
1890 if (cris_spec_regs
[i
].name
== NULL
)
1897 /* Returns the number of bits set in the variable value. */
1900 number_of_bits (unsigned int value
)
1902 int number_of_bits
= 0;
1906 number_of_bits
+= 1;
1907 value
&= (value
- 1);
1909 return number_of_bits
;
1912 /* Finds the address that should contain the single step breakpoint(s).
1913 It stems from code in cris-dis.c. */
1916 find_cris_op (unsigned short insn
, inst_env_type
*inst_env
)
1919 int max_level_of_match
= -1;
1920 int max_matched
= -1;
1923 for (i
= 0; cris_opcodes
[i
].name
!= NULL
; i
++)
1925 if (((cris_opcodes
[i
].match
& insn
) == cris_opcodes
[i
].match
)
1926 && ((cris_opcodes
[i
].lose
& insn
) == 0)
1927 /* Only CRISv10 instructions, please. */
1928 && (cris_opcodes
[i
].applicable_version
!= cris_ver_v32p
))
1930 level_of_match
= constraint (insn
, cris_opcodes
[i
].args
, inst_env
);
1931 if (level_of_match
>= 0)
1934 number_of_bits (cris_opcodes
[i
].match
| cris_opcodes
[i
].lose
);
1935 if (level_of_match
> max_level_of_match
)
1938 max_level_of_match
= level_of_match
;
1939 if (level_of_match
== 16)
1941 /* All bits matched, cannot find better. */
1951 /* Attempts to find single-step breakpoints. Returns -1 on failure which is
1952 actually an internal error. */
1955 find_step_target (struct regcache
*regcache
, inst_env_type
*inst_env
)
1959 unsigned short insn
;
1960 struct gdbarch
*gdbarch
= regcache
->arch ();
1961 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1963 /* Create a local register image and set the initial state. */
1964 for (i
= 0; i
< NUM_GENREGS
; i
++)
1967 (unsigned long) regcache_raw_get_unsigned (regcache
, i
);
1969 offset
= NUM_GENREGS
;
1970 for (i
= 0; i
< NUM_SPECREGS
; i
++)
1973 (unsigned long) regcache_raw_get_unsigned (regcache
, offset
+ i
);
1975 inst_env
->branch_found
= 0;
1976 inst_env
->slot_needed
= 0;
1977 inst_env
->delay_slot_pc_active
= 0;
1978 inst_env
->prefix_found
= 0;
1979 inst_env
->invalid
= 0;
1980 inst_env
->xflag_found
= 0;
1981 inst_env
->disable_interrupt
= 0;
1982 inst_env
->byte_order
= byte_order
;
1984 /* Look for a step target. */
1987 /* Read an instruction from the client. */
1988 insn
= read_memory_unsigned_integer
1989 (inst_env
->reg
[gdbarch_pc_regnum (gdbarch
)], 2, byte_order
);
1991 /* If the instruction is not in a delay slot the new content of the
1992 PC is [PC] + 2. If the instruction is in a delay slot it is not
1993 that simple. Since a instruction in a delay slot cannot change
1994 the content of the PC, it does not matter what value PC will have.
1995 Just make sure it is a valid instruction. */
1996 if (!inst_env
->delay_slot_pc_active
)
1998 inst_env
->reg
[gdbarch_pc_regnum (gdbarch
)] += 2;
2002 inst_env
->delay_slot_pc_active
= 0;
2003 inst_env
->reg
[gdbarch_pc_regnum (gdbarch
)]
2004 = inst_env
->delay_slot_pc
;
2006 /* Analyse the present instruction. */
2007 i
= find_cris_op (insn
, inst_env
);
2010 inst_env
->invalid
= 1;
2014 cris_gdb_func (gdbarch
, cris_opcodes
[i
].op
, insn
, inst_env
);
2016 } while (!inst_env
->invalid
2017 && (inst_env
->prefix_found
|| inst_env
->xflag_found
2018 || inst_env
->slot_needed
));
2022 /* There is no hardware single-step support. The function find_step_target
2023 digs through the opcodes in order to find all possible targets.
2024 Either one ordinary target or two targets for branches may be found. */
2026 static std::vector
<CORE_ADDR
>
2027 cris_software_single_step (struct regcache
*regcache
)
2029 struct gdbarch
*gdbarch
= regcache
->arch ();
2030 inst_env_type inst_env
;
2031 std::vector
<CORE_ADDR
> next_pcs
;
2033 /* Analyse the present instruction environment and insert
2035 int status
= find_step_target (regcache
, &inst_env
);
2038 /* Could not find a target. Things are likely to go downhill
2040 warning (_("CRIS software single step could not find a step target."));
2044 /* Insert at most two breakpoints. One for the next PC content
2045 and possibly another one for a branch, jump, etc. */
2047 = (CORE_ADDR
) inst_env
.reg
[gdbarch_pc_regnum (gdbarch
)];
2049 next_pcs
.push_back (next_pc
);
2050 if (inst_env
.branch_found
2051 && (CORE_ADDR
) inst_env
.branch_break_address
!= next_pc
)
2053 CORE_ADDR branch_target_address
2054 = (CORE_ADDR
) inst_env
.branch_break_address
;
2056 next_pcs
.push_back (branch_target_address
);
2063 /* Calculates the prefix value for quick offset addressing mode. */
2066 quick_mode_bdap_prefix (unsigned short inst
, inst_env_type
*inst_env
)
2068 /* It's invalid to be in a delay slot. You can't have a prefix to this
2069 instruction (not 100% sure). */
2070 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2072 inst_env
->invalid
= 1;
2076 inst_env
->prefix_value
= inst_env
->reg
[cris_get_operand2 (inst
)];
2077 inst_env
->prefix_value
+= cris_get_bdap_quick_offset (inst
);
2079 /* A prefix doesn't change the xflag_found. But the rest of the flags
2081 inst_env
->slot_needed
= 0;
2082 inst_env
->prefix_found
= 1;
2085 /* Updates the autoincrement register. The size of the increment is derived
2086 from the size of the operation. The PC is always kept aligned on even
2090 process_autoincrement (int size
, unsigned short inst
, inst_env_type
*inst_env
)
2092 if (size
== INST_BYTE_SIZE
)
2094 inst_env
->reg
[cris_get_operand1 (inst
)] += 1;
2096 /* The PC must be word aligned, so increase the PC with one
2097 word even if the size is byte. */
2098 if (cris_get_operand1 (inst
) == REG_PC
)
2100 inst_env
->reg
[REG_PC
] += 1;
2103 else if (size
== INST_WORD_SIZE
)
2105 inst_env
->reg
[cris_get_operand1 (inst
)] += 2;
2107 else if (size
== INST_DWORD_SIZE
)
2109 inst_env
->reg
[cris_get_operand1 (inst
)] += 4;
2114 inst_env
->invalid
= 1;
2118 /* Just a forward declaration. */
2120 static unsigned long get_data_from_address (unsigned short *inst
,
2122 enum bfd_endian byte_order
);
2124 /* Calculates the prefix value for the general case of offset addressing
2128 bdap_prefix (unsigned short inst
, inst_env_type
*inst_env
)
2130 /* It's invalid to be in a delay slot. */
2131 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2133 inst_env
->invalid
= 1;
2137 /* The calculation of prefix_value used to be after process_autoincrement,
2138 but that fails for an instruction such as jsr [$r0+12] which is encoded
2139 as 5f0d 0c00 30b9 when compiled with -fpic. Since PC is operand1 it
2140 mustn't be incremented until we have read it and what it points at. */
2141 inst_env
->prefix_value
= inst_env
->reg
[cris_get_operand2 (inst
)];
2143 /* The offset is an indirection of the contents of the operand1 register. */
2144 inst_env
->prefix_value
+=
2145 get_data_from_address (&inst
, inst_env
->reg
[cris_get_operand1 (inst
)],
2146 inst_env
->byte_order
);
2148 if (cris_get_mode (inst
) == AUTOINC_MODE
)
2150 process_autoincrement (cris_get_size (inst
), inst
, inst_env
);
2153 /* A prefix doesn't change the xflag_found. But the rest of the flags
2155 inst_env
->slot_needed
= 0;
2156 inst_env
->prefix_found
= 1;
2159 /* Calculates the prefix value for the index addressing mode. */
2162 biap_prefix (unsigned short inst
, inst_env_type
*inst_env
)
2164 /* It's invalid to be in a delay slot. I can't see that it's possible to
2165 have a prefix to this instruction. So I will treat this as invalid. */
2166 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2168 inst_env
->invalid
= 1;
2172 inst_env
->prefix_value
= inst_env
->reg
[cris_get_operand1 (inst
)];
2174 /* The offset is the operand2 value shifted the size of the instruction
2176 inst_env
->prefix_value
+=
2177 inst_env
->reg
[cris_get_operand2 (inst
)] << cris_get_size (inst
);
2179 /* If the PC is operand1 (base) the address used is the address after
2180 the main instruction, i.e. address + 2 (the PC is already compensated
2181 for the prefix operation). */
2182 if (cris_get_operand1 (inst
) == REG_PC
)
2184 inst_env
->prefix_value
+= 2;
2187 /* A prefix doesn't change the xflag_found. But the rest of the flags
2189 inst_env
->slot_needed
= 0;
2190 inst_env
->xflag_found
= 0;
2191 inst_env
->prefix_found
= 1;
2194 /* Calculates the prefix value for the double indirect addressing mode. */
2197 dip_prefix (unsigned short inst
, inst_env_type
*inst_env
)
2202 /* It's invalid to be in a delay slot. */
2203 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2205 inst_env
->invalid
= 1;
2209 /* The prefix value is one dereference of the contents of the operand1
2211 address
= (CORE_ADDR
) inst_env
->reg
[cris_get_operand1 (inst
)];
2212 inst_env
->prefix_value
2213 = read_memory_unsigned_integer (address
, 4, inst_env
->byte_order
);
2215 /* Check if the mode is autoincrement. */
2216 if (cris_get_mode (inst
) == AUTOINC_MODE
)
2218 inst_env
->reg
[cris_get_operand1 (inst
)] += 4;
2221 /* A prefix doesn't change the xflag_found. But the rest of the flags
2223 inst_env
->slot_needed
= 0;
2224 inst_env
->xflag_found
= 0;
2225 inst_env
->prefix_found
= 1;
2228 /* Finds the destination for a branch with 8-bits offset. */
2231 eight_bit_offset_branch_op (unsigned short inst
, inst_env_type
*inst_env
)
2236 /* If we have a prefix or are in a delay slot it's bad. */
2237 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2239 inst_env
->invalid
= 1;
2243 /* We have a branch, find out where the branch will land. */
2244 offset
= cris_get_branch_short_offset (inst
);
2246 /* Check if the offset is signed. */
2247 if (offset
& BRANCH_SIGNED_SHORT_OFFSET_MASK
)
2252 /* The offset ends with the sign bit, set it to zero. The address
2253 should always be word aligned. */
2254 offset
&= ~BRANCH_SIGNED_SHORT_OFFSET_MASK
;
2256 inst_env
->branch_found
= 1;
2257 inst_env
->branch_break_address
= inst_env
->reg
[REG_PC
] + offset
;
2259 inst_env
->slot_needed
= 1;
2260 inst_env
->prefix_found
= 0;
2261 inst_env
->xflag_found
= 0;
2262 inst_env
->disable_interrupt
= 1;
2265 /* Finds the destination for a branch with 16-bits offset. */
2268 sixteen_bit_offset_branch_op (unsigned short inst
, inst_env_type
*inst_env
)
2272 /* If we have a prefix or is in a delay slot it's bad. */
2273 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2275 inst_env
->invalid
= 1;
2279 /* We have a branch, find out the offset for the branch. */
2280 offset
= read_memory_integer (inst_env
->reg
[REG_PC
], 2,
2281 inst_env
->byte_order
);
2283 /* The instruction is one word longer than normal, so add one word
2285 inst_env
->reg
[REG_PC
] += 2;
2287 inst_env
->branch_found
= 1;
2288 inst_env
->branch_break_address
= inst_env
->reg
[REG_PC
] + offset
;
2291 inst_env
->slot_needed
= 1;
2292 inst_env
->prefix_found
= 0;
2293 inst_env
->xflag_found
= 0;
2294 inst_env
->disable_interrupt
= 1;
2297 /* Handles the ABS instruction. */
2300 abs_op (unsigned short inst
, inst_env_type
*inst_env
)
2305 /* ABS can't have a prefix, so it's bad if it does. */
2306 if (inst_env
->prefix_found
)
2308 inst_env
->invalid
= 1;
2312 /* Check if the operation affects the PC. */
2313 if (cris_get_operand2 (inst
) == REG_PC
)
2316 /* It's invalid to change to the PC if we are in a delay slot. */
2317 if (inst_env
->slot_needed
)
2319 inst_env
->invalid
= 1;
2323 value
= (long) inst_env
->reg
[REG_PC
];
2325 /* The value of abs (SIGNED_DWORD_MASK) is SIGNED_DWORD_MASK. */
2326 if (value
!= SIGNED_DWORD_MASK
)
2329 inst_env
->reg
[REG_PC
] = (long) value
;
2333 inst_env
->slot_needed
= 0;
2334 inst_env
->prefix_found
= 0;
2335 inst_env
->xflag_found
= 0;
2336 inst_env
->disable_interrupt
= 0;
2339 /* Handles the ADDI instruction. */
2342 addi_op (unsigned short inst
, inst_env_type
*inst_env
)
2344 /* It's invalid to have the PC as base register. And ADDI can't have
2346 if (inst_env
->prefix_found
|| (cris_get_operand1 (inst
) == REG_PC
))
2348 inst_env
->invalid
= 1;
2352 inst_env
->slot_needed
= 0;
2353 inst_env
->prefix_found
= 0;
2354 inst_env
->xflag_found
= 0;
2355 inst_env
->disable_interrupt
= 0;
2358 /* Handles the ASR instruction. */
2361 asr_op (unsigned short inst
, inst_env_type
*inst_env
)
2364 unsigned long value
;
2365 unsigned long signed_extend_mask
= 0;
2367 /* ASR can't have a prefix, so check that it doesn't. */
2368 if (inst_env
->prefix_found
)
2370 inst_env
->invalid
= 1;
2374 /* Check if the PC is the target register. */
2375 if (cris_get_operand2 (inst
) == REG_PC
)
2377 /* It's invalid to change the PC in a delay slot. */
2378 if (inst_env
->slot_needed
)
2380 inst_env
->invalid
= 1;
2383 /* Get the number of bits to shift. */
2385 = cris_get_asr_shift_steps (inst_env
->reg
[cris_get_operand1 (inst
)]);
2386 value
= inst_env
->reg
[REG_PC
];
2388 /* Find out how many bits the operation should apply to. */
2389 if (cris_get_size (inst
) == INST_BYTE_SIZE
)
2391 if (value
& SIGNED_BYTE_MASK
)
2393 signed_extend_mask
= 0xFF;
2394 signed_extend_mask
= signed_extend_mask
>> shift_steps
;
2395 signed_extend_mask
= ~signed_extend_mask
;
2397 value
= value
>> shift_steps
;
2398 value
|= signed_extend_mask
;
2400 inst_env
->reg
[REG_PC
] &= 0xFFFFFF00;
2401 inst_env
->reg
[REG_PC
] |= value
;
2403 else if (cris_get_size (inst
) == INST_WORD_SIZE
)
2405 if (value
& SIGNED_WORD_MASK
)
2407 signed_extend_mask
= 0xFFFF;
2408 signed_extend_mask
= signed_extend_mask
>> shift_steps
;
2409 signed_extend_mask
= ~signed_extend_mask
;
2411 value
= value
>> shift_steps
;
2412 value
|= signed_extend_mask
;
2414 inst_env
->reg
[REG_PC
] &= 0xFFFF0000;
2415 inst_env
->reg
[REG_PC
] |= value
;
2417 else if (cris_get_size (inst
) == INST_DWORD_SIZE
)
2419 if (value
& SIGNED_DWORD_MASK
)
2421 signed_extend_mask
= 0xFFFFFFFF;
2422 signed_extend_mask
= signed_extend_mask
>> shift_steps
;
2423 signed_extend_mask
= ~signed_extend_mask
;
2425 value
= value
>> shift_steps
;
2426 value
|= signed_extend_mask
;
2427 inst_env
->reg
[REG_PC
] = value
;
2430 inst_env
->slot_needed
= 0;
2431 inst_env
->prefix_found
= 0;
2432 inst_env
->xflag_found
= 0;
2433 inst_env
->disable_interrupt
= 0;
2436 /* Handles the ASRQ instruction. */
2439 asrq_op (unsigned short inst
, inst_env_type
*inst_env
)
2443 unsigned long value
;
2444 unsigned long signed_extend_mask
= 0;
2446 /* ASRQ can't have a prefix, so check that it doesn't. */
2447 if (inst_env
->prefix_found
)
2449 inst_env
->invalid
= 1;
2453 /* Check if the PC is the target register. */
2454 if (cris_get_operand2 (inst
) == REG_PC
)
2457 /* It's invalid to change the PC in a delay slot. */
2458 if (inst_env
->slot_needed
)
2460 inst_env
->invalid
= 1;
2463 /* The shift size is given as a 5 bit quick value, i.e. we don't
2464 want the sign bit of the quick value. */
2465 shift_steps
= cris_get_asr_shift_steps (inst
);
2466 value
= inst_env
->reg
[REG_PC
];
2467 if (value
& SIGNED_DWORD_MASK
)
2469 signed_extend_mask
= 0xFFFFFFFF;
2470 signed_extend_mask
= signed_extend_mask
>> shift_steps
;
2471 signed_extend_mask
= ~signed_extend_mask
;
2473 value
= value
>> shift_steps
;
2474 value
|= signed_extend_mask
;
2475 inst_env
->reg
[REG_PC
] = value
;
2477 inst_env
->slot_needed
= 0;
2478 inst_env
->prefix_found
= 0;
2479 inst_env
->xflag_found
= 0;
2480 inst_env
->disable_interrupt
= 0;
2483 /* Handles the AX, EI and SETF instruction. */
2486 ax_ei_setf_op (unsigned short inst
, inst_env_type
*inst_env
)
2488 if (inst_env
->prefix_found
)
2490 inst_env
->invalid
= 1;
2493 /* Check if the instruction is setting the X flag. */
2494 if (cris_is_xflag_bit_on (inst
))
2496 inst_env
->xflag_found
= 1;
2500 inst_env
->xflag_found
= 0;
2502 inst_env
->slot_needed
= 0;
2503 inst_env
->prefix_found
= 0;
2504 inst_env
->disable_interrupt
= 1;
2507 /* Checks if the instruction is in assign mode. If so, it updates the assign
2508 register. Note that check_assign assumes that the caller has checked that
2509 there is a prefix to this instruction. The mode check depends on this. */
2512 check_assign (unsigned short inst
, inst_env_type
*inst_env
)
2514 /* Check if it's an assign addressing mode. */
2515 if (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
)
2517 /* Assign the prefix value to operand 1. */
2518 inst_env
->reg
[cris_get_operand1 (inst
)] = inst_env
->prefix_value
;
2522 /* Handles the 2-operand BOUND instruction. */
2525 two_operand_bound_op (unsigned short inst
, inst_env_type
*inst_env
)
2527 /* It's invalid to have the PC as the index operand. */
2528 if (cris_get_operand2 (inst
) == REG_PC
)
2530 inst_env
->invalid
= 1;
2533 /* Check if we have a prefix. */
2534 if (inst_env
->prefix_found
)
2536 check_assign (inst
, inst_env
);
2538 /* Check if this is an autoincrement mode. */
2539 else if (cris_get_mode (inst
) == AUTOINC_MODE
)
2541 /* It's invalid to change the PC in a delay slot. */
2542 if (inst_env
->slot_needed
)
2544 inst_env
->invalid
= 1;
2547 process_autoincrement (cris_get_size (inst
), inst
, inst_env
);
2549 inst_env
->slot_needed
= 0;
2550 inst_env
->prefix_found
= 0;
2551 inst_env
->xflag_found
= 0;
2552 inst_env
->disable_interrupt
= 0;
2555 /* Handles the 3-operand BOUND instruction. */
2558 three_operand_bound_op (unsigned short inst
, inst_env_type
*inst_env
)
2560 /* It's an error if we haven't got a prefix. And it's also an error
2561 if the PC is the destination register. */
2562 if ((!inst_env
->prefix_found
) || (cris_get_operand1 (inst
) == REG_PC
))
2564 inst_env
->invalid
= 1;
2567 inst_env
->slot_needed
= 0;
2568 inst_env
->prefix_found
= 0;
2569 inst_env
->xflag_found
= 0;
2570 inst_env
->disable_interrupt
= 0;
2573 /* Clears the status flags in inst_env. */
2576 btst_nop_op (unsigned short inst
, inst_env_type
*inst_env
)
2578 /* It's an error if we have got a prefix. */
2579 if (inst_env
->prefix_found
)
2581 inst_env
->invalid
= 1;
2585 inst_env
->slot_needed
= 0;
2586 inst_env
->prefix_found
= 0;
2587 inst_env
->xflag_found
= 0;
2588 inst_env
->disable_interrupt
= 0;
2591 /* Clears the status flags in inst_env. */
2594 clearf_di_op (unsigned short inst
, inst_env_type
*inst_env
)
2596 /* It's an error if we have got a prefix. */
2597 if (inst_env
->prefix_found
)
2599 inst_env
->invalid
= 1;
2603 inst_env
->slot_needed
= 0;
2604 inst_env
->prefix_found
= 0;
2605 inst_env
->xflag_found
= 0;
2606 inst_env
->disable_interrupt
= 1;
2609 /* Handles the CLEAR instruction if it's in register mode. */
2612 reg_mode_clear_op (unsigned short inst
, inst_env_type
*inst_env
)
2614 /* Check if the target is the PC. */
2615 if (cris_get_operand2 (inst
) == REG_PC
)
2617 /* The instruction will clear the instruction's size bits. */
2618 int clear_size
= cris_get_clear_size (inst
);
2619 if (clear_size
== INST_BYTE_SIZE
)
2621 inst_env
->delay_slot_pc
= inst_env
->reg
[REG_PC
] & 0xFFFFFF00;
2623 if (clear_size
== INST_WORD_SIZE
)
2625 inst_env
->delay_slot_pc
= inst_env
->reg
[REG_PC
] & 0xFFFF0000;
2627 if (clear_size
== INST_DWORD_SIZE
)
2629 inst_env
->delay_slot_pc
= 0x0;
2631 /* The jump will be delayed with one delay slot. So we need a delay
2633 inst_env
->slot_needed
= 1;
2634 inst_env
->delay_slot_pc_active
= 1;
2638 /* The PC will not change => no delay slot. */
2639 inst_env
->slot_needed
= 0;
2641 inst_env
->prefix_found
= 0;
2642 inst_env
->xflag_found
= 0;
2643 inst_env
->disable_interrupt
= 0;
2646 /* Handles the TEST instruction if it's in register mode. */
2649 reg_mode_test_op (unsigned short inst
, inst_env_type
*inst_env
)
2651 /* It's an error if we have got a prefix. */
2652 if (inst_env
->prefix_found
)
2654 inst_env
->invalid
= 1;
2657 inst_env
->slot_needed
= 0;
2658 inst_env
->prefix_found
= 0;
2659 inst_env
->xflag_found
= 0;
2660 inst_env
->disable_interrupt
= 0;
2664 /* Handles the CLEAR and TEST instruction if the instruction isn't
2665 in register mode. */
2668 none_reg_mode_clear_test_op (unsigned short inst
, inst_env_type
*inst_env
)
2670 /* Check if we are in a prefix mode. */
2671 if (inst_env
->prefix_found
)
2673 /* The only way the PC can change is if this instruction is in
2674 assign addressing mode. */
2675 check_assign (inst
, inst_env
);
2677 /* Indirect mode can't change the PC so just check if the mode is
2679 else if (cris_get_mode (inst
) == AUTOINC_MODE
)
2681 process_autoincrement (cris_get_size (inst
), inst
, inst_env
);
2683 inst_env
->slot_needed
= 0;
2684 inst_env
->prefix_found
= 0;
2685 inst_env
->xflag_found
= 0;
2686 inst_env
->disable_interrupt
= 0;
2689 /* Checks that the PC isn't the destination register or the instructions has
2693 dstep_logshift_mstep_neg_not_op (unsigned short inst
, inst_env_type
*inst_env
)
2695 /* It's invalid to have the PC as the destination. The instruction can't
2697 if ((cris_get_operand2 (inst
) == REG_PC
) || inst_env
->prefix_found
)
2699 inst_env
->invalid
= 1;
2703 inst_env
->slot_needed
= 0;
2704 inst_env
->prefix_found
= 0;
2705 inst_env
->xflag_found
= 0;
2706 inst_env
->disable_interrupt
= 0;
2709 /* Checks that the instruction doesn't have a prefix. */
2712 break_op (unsigned short inst
, inst_env_type
*inst_env
)
2714 /* The instruction can't have a prefix. */
2715 if (inst_env
->prefix_found
)
2717 inst_env
->invalid
= 1;
2721 inst_env
->slot_needed
= 0;
2722 inst_env
->prefix_found
= 0;
2723 inst_env
->xflag_found
= 0;
2724 inst_env
->disable_interrupt
= 1;
2727 /* Checks that the PC isn't the destination register and that the instruction
2728 doesn't have a prefix. */
2731 scc_op (unsigned short inst
, inst_env_type
*inst_env
)
2733 /* It's invalid to have the PC as the destination. The instruction can't
2735 if ((cris_get_operand2 (inst
) == REG_PC
) || inst_env
->prefix_found
)
2737 inst_env
->invalid
= 1;
2741 inst_env
->slot_needed
= 0;
2742 inst_env
->prefix_found
= 0;
2743 inst_env
->xflag_found
= 0;
2744 inst_env
->disable_interrupt
= 1;
2747 /* Handles the register mode JUMP instruction. */
2750 reg_mode_jump_op (unsigned short inst
, inst_env_type
*inst_env
)
2752 /* It's invalid to do a JUMP in a delay slot. The mode is register, so
2753 you can't have a prefix. */
2754 if ((inst_env
->slot_needed
) || (inst_env
->prefix_found
))
2756 inst_env
->invalid
= 1;
2760 /* Just change the PC. */
2761 inst_env
->reg
[REG_PC
] = inst_env
->reg
[cris_get_operand1 (inst
)];
2762 inst_env
->slot_needed
= 0;
2763 inst_env
->prefix_found
= 0;
2764 inst_env
->xflag_found
= 0;
2765 inst_env
->disable_interrupt
= 1;
2768 /* Handles the JUMP instruction for all modes except register. */
2771 none_reg_mode_jump_op (unsigned short inst
, inst_env_type
*inst_env
)
2773 unsigned long newpc
;
2776 /* It's invalid to do a JUMP in a delay slot. */
2777 if (inst_env
->slot_needed
)
2779 inst_env
->invalid
= 1;
2783 /* Check if we have a prefix. */
2784 if (inst_env
->prefix_found
)
2786 check_assign (inst
, inst_env
);
2788 /* Get the new value for the PC. */
2790 read_memory_unsigned_integer ((CORE_ADDR
) inst_env
->prefix_value
,
2791 4, inst_env
->byte_order
);
2795 /* Get the new value for the PC. */
2796 address
= (CORE_ADDR
) inst_env
->reg
[cris_get_operand1 (inst
)];
2797 newpc
= read_memory_unsigned_integer (address
,
2798 4, inst_env
->byte_order
);
2800 /* Check if we should increment a register. */
2801 if (cris_get_mode (inst
) == AUTOINC_MODE
)
2803 inst_env
->reg
[cris_get_operand1 (inst
)] += 4;
2806 inst_env
->reg
[REG_PC
] = newpc
;
2808 inst_env
->slot_needed
= 0;
2809 inst_env
->prefix_found
= 0;
2810 inst_env
->xflag_found
= 0;
2811 inst_env
->disable_interrupt
= 1;
2814 /* Handles moves to special registers (aka P-register) for all modes. */
2817 move_to_preg_op (struct gdbarch
*gdbarch
, unsigned short inst
,
2818 inst_env_type
*inst_env
)
2820 if (inst_env
->prefix_found
)
2822 /* The instruction has a prefix that means we are only interested if
2823 the instruction is in assign mode. */
2824 if (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
)
2826 /* The prefix handles the problem if we are in a delay slot. */
2827 if (cris_get_operand1 (inst
) == REG_PC
)
2829 /* Just take care of the assign. */
2830 check_assign (inst
, inst_env
);
2834 else if (cris_get_mode (inst
) == AUTOINC_MODE
)
2836 /* The instruction doesn't have a prefix, the only case left that we
2837 are interested in is the autoincrement mode. */
2838 if (cris_get_operand1 (inst
) == REG_PC
)
2840 /* If the PC is to be incremented it's invalid to be in a
2842 if (inst_env
->slot_needed
)
2844 inst_env
->invalid
= 1;
2848 /* The increment depends on the size of the special register. */
2849 if (cris_register_size (gdbarch
, cris_get_operand2 (inst
)) == 1)
2851 process_autoincrement (INST_BYTE_SIZE
, inst
, inst_env
);
2853 else if (cris_register_size (gdbarch
, cris_get_operand2 (inst
)) == 2)
2855 process_autoincrement (INST_WORD_SIZE
, inst
, inst_env
);
2859 process_autoincrement (INST_DWORD_SIZE
, inst
, inst_env
);
2863 inst_env
->slot_needed
= 0;
2864 inst_env
->prefix_found
= 0;
2865 inst_env
->xflag_found
= 0;
2866 inst_env
->disable_interrupt
= 1;
2869 /* Handles moves from special registers (aka P-register) for all modes
2873 none_reg_mode_move_from_preg_op (struct gdbarch
*gdbarch
, unsigned short inst
,
2874 inst_env_type
*inst_env
)
2876 if (inst_env
->prefix_found
)
2878 /* The instruction has a prefix that means we are only interested if
2879 the instruction is in assign mode. */
2880 if (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
)
2882 /* The prefix handles the problem if we are in a delay slot. */
2883 if (cris_get_operand1 (inst
) == REG_PC
)
2885 /* Just take care of the assign. */
2886 check_assign (inst
, inst_env
);
2890 /* The instruction doesn't have a prefix, the only case left that we
2891 are interested in is the autoincrement mode. */
2892 else if (cris_get_mode (inst
) == AUTOINC_MODE
)
2894 if (cris_get_operand1 (inst
) == REG_PC
)
2896 /* If the PC is to be incremented it's invalid to be in a
2898 if (inst_env
->slot_needed
)
2900 inst_env
->invalid
= 1;
2904 /* The increment depends on the size of the special register. */
2905 if (cris_register_size (gdbarch
, cris_get_operand2 (inst
)) == 1)
2907 process_autoincrement (INST_BYTE_SIZE
, inst
, inst_env
);
2909 else if (cris_register_size (gdbarch
, cris_get_operand2 (inst
)) == 2)
2911 process_autoincrement (INST_WORD_SIZE
, inst
, inst_env
);
2915 process_autoincrement (INST_DWORD_SIZE
, inst
, inst_env
);
2919 inst_env
->slot_needed
= 0;
2920 inst_env
->prefix_found
= 0;
2921 inst_env
->xflag_found
= 0;
2922 inst_env
->disable_interrupt
= 1;
2925 /* Handles moves from special registers (aka P-register) when the mode
2929 reg_mode_move_from_preg_op (unsigned short inst
, inst_env_type
*inst_env
)
2931 /* Register mode move from special register can't have a prefix. */
2932 if (inst_env
->prefix_found
)
2934 inst_env
->invalid
= 1;
2938 if (cris_get_operand1 (inst
) == REG_PC
)
2940 /* It's invalid to change the PC in a delay slot. */
2941 if (inst_env
->slot_needed
)
2943 inst_env
->invalid
= 1;
2946 /* The destination is the PC, the jump will have a delay slot. */
2947 inst_env
->delay_slot_pc
= inst_env
->preg
[cris_get_operand2 (inst
)];
2948 inst_env
->slot_needed
= 1;
2949 inst_env
->delay_slot_pc_active
= 1;
2953 /* If the destination isn't PC, there will be no jump. */
2954 inst_env
->slot_needed
= 0;
2956 inst_env
->prefix_found
= 0;
2957 inst_env
->xflag_found
= 0;
2958 inst_env
->disable_interrupt
= 1;
2961 /* Handles the MOVEM from memory to general register instruction. */
2964 move_mem_to_reg_movem_op (unsigned short inst
, inst_env_type
*inst_env
)
2966 if (inst_env
->prefix_found
)
2968 /* The prefix handles the problem if we are in a delay slot. Is the
2969 MOVEM instruction going to change the PC? */
2970 if (cris_get_operand2 (inst
) >= REG_PC
)
2972 inst_env
->reg
[REG_PC
] =
2973 read_memory_unsigned_integer (inst_env
->prefix_value
,
2974 4, inst_env
->byte_order
);
2976 /* The assign value is the value after the increment. Normally, the
2977 assign value is the value before the increment. */
2978 if ((cris_get_operand1 (inst
) == REG_PC
)
2979 && (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
))
2981 inst_env
->reg
[REG_PC
] = inst_env
->prefix_value
;
2982 inst_env
->reg
[REG_PC
] += 4 * (cris_get_operand2 (inst
) + 1);
2987 /* Is the MOVEM instruction going to change the PC? */
2988 if (cris_get_operand2 (inst
) == REG_PC
)
2990 /* It's invalid to change the PC in a delay slot. */
2991 if (inst_env
->slot_needed
)
2993 inst_env
->invalid
= 1;
2996 inst_env
->reg
[REG_PC
] =
2997 read_memory_unsigned_integer (inst_env
->reg
[cris_get_operand1 (inst
)],
2998 4, inst_env
->byte_order
);
3000 /* The increment is not depending on the size, instead it's depending
3001 on the number of registers loaded from memory. */
3002 if ((cris_get_operand1 (inst
) == REG_PC
)
3003 && (cris_get_mode (inst
) == AUTOINC_MODE
))
3005 /* It's invalid to change the PC in a delay slot. */
3006 if (inst_env
->slot_needed
)
3008 inst_env
->invalid
= 1;
3011 inst_env
->reg
[REG_PC
] += 4 * (cris_get_operand2 (inst
) + 1);
3014 inst_env
->slot_needed
= 0;
3015 inst_env
->prefix_found
= 0;
3016 inst_env
->xflag_found
= 0;
3017 inst_env
->disable_interrupt
= 0;
3020 /* Handles the MOVEM to memory from general register instruction. */
3023 move_reg_to_mem_movem_op (unsigned short inst
, inst_env_type
*inst_env
)
3025 if (inst_env
->prefix_found
)
3027 /* The assign value is the value after the increment. Normally, the
3028 assign value is the value before the increment. */
3029 if ((cris_get_operand1 (inst
) == REG_PC
)
3030 && (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
))
3032 /* The prefix handles the problem if we are in a delay slot. */
3033 inst_env
->reg
[REG_PC
] = inst_env
->prefix_value
;
3034 inst_env
->reg
[REG_PC
] += 4 * (cris_get_operand2 (inst
) + 1);
3039 /* The increment is not depending on the size, instead it's depending
3040 on the number of registers loaded to memory. */
3041 if ((cris_get_operand1 (inst
) == REG_PC
)
3042 && (cris_get_mode (inst
) == AUTOINC_MODE
))
3044 /* It's invalid to change the PC in a delay slot. */
3045 if (inst_env
->slot_needed
)
3047 inst_env
->invalid
= 1;
3050 inst_env
->reg
[REG_PC
] += 4 * (cris_get_operand2 (inst
) + 1);
3053 inst_env
->slot_needed
= 0;
3054 inst_env
->prefix_found
= 0;
3055 inst_env
->xflag_found
= 0;
3056 inst_env
->disable_interrupt
= 0;
3059 /* Handles the intructions that's not yet implemented, by setting
3060 inst_env->invalid to true. */
3063 not_implemented_op (unsigned short inst
, inst_env_type
*inst_env
)
3065 inst_env
->invalid
= 1;
3068 /* Handles the XOR instruction. */
3071 xor_op (unsigned short inst
, inst_env_type
*inst_env
)
3073 /* XOR can't have a prefix. */
3074 if (inst_env
->prefix_found
)
3076 inst_env
->invalid
= 1;
3080 /* Check if the PC is the target. */
3081 if (cris_get_operand2 (inst
) == REG_PC
)
3083 /* It's invalid to change the PC in a delay slot. */
3084 if (inst_env
->slot_needed
)
3086 inst_env
->invalid
= 1;
3089 inst_env
->reg
[REG_PC
] ^= inst_env
->reg
[cris_get_operand1 (inst
)];
3091 inst_env
->slot_needed
= 0;
3092 inst_env
->prefix_found
= 0;
3093 inst_env
->xflag_found
= 0;
3094 inst_env
->disable_interrupt
= 0;
3097 /* Handles the MULS instruction. */
3100 muls_op (unsigned short inst
, inst_env_type
*inst_env
)
3102 /* MULS/U can't have a prefix. */
3103 if (inst_env
->prefix_found
)
3105 inst_env
->invalid
= 1;
3109 /* Consider it invalid if the PC is the target. */
3110 if (cris_get_operand2 (inst
) == REG_PC
)
3112 inst_env
->invalid
= 1;
3115 inst_env
->slot_needed
= 0;
3116 inst_env
->prefix_found
= 0;
3117 inst_env
->xflag_found
= 0;
3118 inst_env
->disable_interrupt
= 0;
3121 /* Handles the MULU instruction. */
3124 mulu_op (unsigned short inst
, inst_env_type
*inst_env
)
3126 /* MULS/U can't have a prefix. */
3127 if (inst_env
->prefix_found
)
3129 inst_env
->invalid
= 1;
3133 /* Consider it invalid if the PC is the target. */
3134 if (cris_get_operand2 (inst
) == REG_PC
)
3136 inst_env
->invalid
= 1;
3139 inst_env
->slot_needed
= 0;
3140 inst_env
->prefix_found
= 0;
3141 inst_env
->xflag_found
= 0;
3142 inst_env
->disable_interrupt
= 0;
3145 /* Calculate the result of the instruction for ADD, SUB, CMP AND, OR and MOVE.
3146 The MOVE instruction is the move from source to register. */
3149 add_sub_cmp_and_or_move_action (unsigned short inst
, inst_env_type
*inst_env
,
3150 unsigned long source1
, unsigned long source2
)
3152 unsigned long pc_mask
;
3153 unsigned long operation_mask
;
3155 /* Find out how many bits the operation should apply to. */
3156 if (cris_get_size (inst
) == INST_BYTE_SIZE
)
3158 pc_mask
= 0xFFFFFF00;
3159 operation_mask
= 0xFF;
3161 else if (cris_get_size (inst
) == INST_WORD_SIZE
)
3163 pc_mask
= 0xFFFF0000;
3164 operation_mask
= 0xFFFF;
3166 else if (cris_get_size (inst
) == INST_DWORD_SIZE
)
3169 operation_mask
= 0xFFFFFFFF;
3173 /* The size is out of range. */
3174 inst_env
->invalid
= 1;
3178 /* The instruction just works on uw_operation_mask bits. */
3179 source2
&= operation_mask
;
3180 source1
&= operation_mask
;
3182 /* Now calculate the result. The opcode's 3 first bits separates
3183 the different actions. */
3184 switch (cris_get_opcode (inst
) & 7)
3194 case 2: /* subtract */
3198 case 3: /* compare */
3210 inst_env
->invalid
= 1;
3216 /* Make sure that the result doesn't contain more than the instruction
3218 source2
&= operation_mask
;
3220 /* Calculate the new breakpoint address. */
3221 inst_env
->reg
[REG_PC
] &= pc_mask
;
3222 inst_env
->reg
[REG_PC
] |= source1
;
3226 /* Extends the value from either byte or word size to a dword. If the mode
3227 is zero extend then the value is extended with zero. If instead the mode
3228 is signed extend the sign bit of the value is taken into consideration. */
3230 static unsigned long
3231 do_sign_or_zero_extend (unsigned long value
, unsigned short *inst
)
3233 /* The size can be either byte or word, check which one it is.
3234 Don't check the highest bit, it's indicating if it's a zero
3236 if (cris_get_size (*inst
) & INST_WORD_SIZE
)
3241 /* Check if the instruction is signed extend. If so, check if value has
3243 if (cris_is_signed_extend_bit_on (*inst
) && (value
& SIGNED_WORD_MASK
))
3245 value
|= SIGNED_WORD_EXTEND_MASK
;
3253 /* Check if the instruction is signed extend. If so, check if value has
3255 if (cris_is_signed_extend_bit_on (*inst
) && (value
& SIGNED_BYTE_MASK
))
3257 value
|= SIGNED_BYTE_EXTEND_MASK
;
3260 /* The size should now be dword. */
3261 cris_set_size_to_dword (inst
);
3265 /* Handles the register mode for the ADD, SUB, CMP, AND, OR and MOVE
3266 instruction. The MOVE instruction is the move from source to register. */
3269 reg_mode_add_sub_cmp_and_or_move_op (unsigned short inst
,
3270 inst_env_type
*inst_env
)
3272 unsigned long operand1
;
3273 unsigned long operand2
;
3275 /* It's invalid to have a prefix to the instruction. This is a register
3276 mode instruction and can't have a prefix. */
3277 if (inst_env
->prefix_found
)
3279 inst_env
->invalid
= 1;
3282 /* Check if the instruction has PC as its target. */
3283 if (cris_get_operand2 (inst
) == REG_PC
)
3285 if (inst_env
->slot_needed
)
3287 inst_env
->invalid
= 1;
3290 /* The instruction has the PC as its target register. */
3291 operand1
= inst_env
->reg
[cris_get_operand1 (inst
)];
3292 operand2
= inst_env
->reg
[REG_PC
];
3294 /* Check if it's a extend, signed or zero instruction. */
3295 if (cris_get_opcode (inst
) < 4)
3297 operand1
= do_sign_or_zero_extend (operand1
, &inst
);
3299 /* Calculate the PC value after the instruction, i.e. where the
3300 breakpoint should be. The order of the udw_operands is vital. */
3301 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand1
);
3303 inst_env
->slot_needed
= 0;
3304 inst_env
->prefix_found
= 0;
3305 inst_env
->xflag_found
= 0;
3306 inst_env
->disable_interrupt
= 0;
3309 /* Returns the data contained at address. The size of the data is derived from
3310 the size of the operation. If the instruction is a zero or signed
3311 extend instruction, the size field is changed in instruction. */
3313 static unsigned long
3314 get_data_from_address (unsigned short *inst
, CORE_ADDR address
,
3315 enum bfd_endian byte_order
)
3317 int size
= cris_get_size (*inst
);
3318 unsigned long value
;
3320 /* If it's an extend instruction we don't want the signed extend bit,
3321 because it influences the size. */
3322 if (cris_get_opcode (*inst
) < 4)
3324 size
&= ~SIGNED_EXTEND_BIT_MASK
;
3326 /* Is there a need for checking the size? Size should contain the number of
3329 value
= read_memory_unsigned_integer (address
, size
, byte_order
);
3331 /* Check if it's an extend, signed or zero instruction. */
3332 if (cris_get_opcode (*inst
) < 4)
3334 value
= do_sign_or_zero_extend (value
, inst
);
3339 /* Handles the assign addresing mode for the ADD, SUB, CMP, AND, OR and MOVE
3340 instructions. The MOVE instruction is the move from source to register. */
3343 handle_prefix_assign_mode_for_aritm_op (unsigned short inst
,
3344 inst_env_type
*inst_env
)
3346 unsigned long operand2
;
3347 unsigned long operand3
;
3349 check_assign (inst
, inst_env
);
3350 if (cris_get_operand2 (inst
) == REG_PC
)
3352 operand2
= inst_env
->reg
[REG_PC
];
3354 /* Get the value of the third operand. */
3355 operand3
= get_data_from_address (&inst
, inst_env
->prefix_value
,
3356 inst_env
->byte_order
);
3358 /* Calculate the PC value after the instruction, i.e. where the
3359 breakpoint should be. The order of the udw_operands is vital. */
3360 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand3
);
3362 inst_env
->slot_needed
= 0;
3363 inst_env
->prefix_found
= 0;
3364 inst_env
->xflag_found
= 0;
3365 inst_env
->disable_interrupt
= 0;
3368 /* Handles the three-operand addressing mode for the ADD, SUB, CMP, AND and
3369 OR instructions. Note that for this to work as expected, the calling
3370 function must have made sure that there is a prefix to this instruction. */
3373 three_operand_add_sub_cmp_and_or_op (unsigned short inst
,
3374 inst_env_type
*inst_env
)
3376 unsigned long operand2
;
3377 unsigned long operand3
;
3379 if (cris_get_operand1 (inst
) == REG_PC
)
3381 /* The PC will be changed by the instruction. */
3382 operand2
= inst_env
->reg
[cris_get_operand2 (inst
)];
3384 /* Get the value of the third operand. */
3385 operand3
= get_data_from_address (&inst
, inst_env
->prefix_value
,
3386 inst_env
->byte_order
);
3388 /* Calculate the PC value after the instruction, i.e. where the
3389 breakpoint should be. */
3390 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand3
);
3392 inst_env
->slot_needed
= 0;
3393 inst_env
->prefix_found
= 0;
3394 inst_env
->xflag_found
= 0;
3395 inst_env
->disable_interrupt
= 0;
3398 /* Handles the index addresing mode for the ADD, SUB, CMP, AND, OR and MOVE
3399 instructions. The MOVE instruction is the move from source to register. */
3402 handle_prefix_index_mode_for_aritm_op (unsigned short inst
,
3403 inst_env_type
*inst_env
)
3405 if (cris_get_operand1 (inst
) != cris_get_operand2 (inst
))
3407 /* If the instruction is MOVE it's invalid. If the instruction is ADD,
3408 SUB, AND or OR something weird is going on (if everything works these
3409 instructions should end up in the three operand version). */
3410 inst_env
->invalid
= 1;
3415 /* three_operand_add_sub_cmp_and_or does the same as we should do here
3417 three_operand_add_sub_cmp_and_or_op (inst
, inst_env
);
3419 inst_env
->slot_needed
= 0;
3420 inst_env
->prefix_found
= 0;
3421 inst_env
->xflag_found
= 0;
3422 inst_env
->disable_interrupt
= 0;
3425 /* Handles the autoincrement and indirect addresing mode for the ADD, SUB,
3426 CMP, AND OR and MOVE instruction. The MOVE instruction is the move from
3427 source to register. */
3430 handle_inc_and_index_mode_for_aritm_op (unsigned short inst
,
3431 inst_env_type
*inst_env
)
3433 unsigned long operand1
;
3434 unsigned long operand2
;
3435 unsigned long operand3
;
3438 /* The instruction is either an indirect or autoincrement addressing mode.
3439 Check if the destination register is the PC. */
3440 if (cris_get_operand2 (inst
) == REG_PC
)
3442 /* Must be done here, get_data_from_address may change the size
3444 size
= cris_get_size (inst
);
3445 operand2
= inst_env
->reg
[REG_PC
];
3447 /* Get the value of the third operand, i.e. the indirect operand. */
3448 operand1
= inst_env
->reg
[cris_get_operand1 (inst
)];
3449 operand3
= get_data_from_address (&inst
, operand1
, inst_env
->byte_order
);
3451 /* Calculate the PC value after the instruction, i.e. where the
3452 breakpoint should be. The order of the udw_operands is vital. */
3453 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand3
);
3455 /* If this is an autoincrement addressing mode, check if the increment
3457 if ((cris_get_operand1 (inst
) == REG_PC
)
3458 && (cris_get_mode (inst
) == AUTOINC_MODE
))
3460 /* Get the size field. */
3461 size
= cris_get_size (inst
);
3463 /* If it's an extend instruction we don't want the signed extend bit,
3464 because it influences the size. */
3465 if (cris_get_opcode (inst
) < 4)
3467 size
&= ~SIGNED_EXTEND_BIT_MASK
;
3469 process_autoincrement (size
, inst
, inst_env
);
3471 inst_env
->slot_needed
= 0;
3472 inst_env
->prefix_found
= 0;
3473 inst_env
->xflag_found
= 0;
3474 inst_env
->disable_interrupt
= 0;
3477 /* Handles the two-operand addressing mode, all modes except register, for
3478 the ADD, SUB CMP, AND and OR instruction. */
3481 none_reg_mode_add_sub_cmp_and_or_move_op (unsigned short inst
,
3482 inst_env_type
*inst_env
)
3484 if (inst_env
->prefix_found
)
3486 if (cris_get_mode (inst
) == PREFIX_INDEX_MODE
)
3488 handle_prefix_index_mode_for_aritm_op (inst
, inst_env
);
3490 else if (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
)
3492 handle_prefix_assign_mode_for_aritm_op (inst
, inst_env
);
3496 /* The mode is invalid for a prefixed base instruction. */
3497 inst_env
->invalid
= 1;
3503 handle_inc_and_index_mode_for_aritm_op (inst
, inst_env
);
3507 /* Handles the quick addressing mode for the ADD and SUB instruction. */
3510 quick_mode_add_sub_op (unsigned short inst
, inst_env_type
*inst_env
)
3512 unsigned long operand1
;
3513 unsigned long operand2
;
3515 /* It's a bad idea to be in a prefix instruction now. This is a quick mode
3516 instruction and can't have a prefix. */
3517 if (inst_env
->prefix_found
)
3519 inst_env
->invalid
= 1;
3523 /* Check if the instruction has PC as its target. */
3524 if (cris_get_operand2 (inst
) == REG_PC
)
3526 if (inst_env
->slot_needed
)
3528 inst_env
->invalid
= 1;
3531 operand1
= cris_get_quick_value (inst
);
3532 operand2
= inst_env
->reg
[REG_PC
];
3534 /* The size should now be dword. */
3535 cris_set_size_to_dword (&inst
);
3537 /* Calculate the PC value after the instruction, i.e. where the
3538 breakpoint should be. */
3539 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand1
);
3541 inst_env
->slot_needed
= 0;
3542 inst_env
->prefix_found
= 0;
3543 inst_env
->xflag_found
= 0;
3544 inst_env
->disable_interrupt
= 0;
3547 /* Handles the quick addressing mode for the CMP, AND and OR instruction. */
3550 quick_mode_and_cmp_move_or_op (unsigned short inst
, inst_env_type
*inst_env
)
3552 unsigned long operand1
;
3553 unsigned long operand2
;
3555 /* It's a bad idea to be in a prefix instruction now. This is a quick mode
3556 instruction and can't have a prefix. */
3557 if (inst_env
->prefix_found
)
3559 inst_env
->invalid
= 1;
3562 /* Check if the instruction has PC as its target. */
3563 if (cris_get_operand2 (inst
) == REG_PC
)
3565 if (inst_env
->slot_needed
)
3567 inst_env
->invalid
= 1;
3570 /* The instruction has the PC as its target register. */
3571 operand1
= cris_get_quick_value (inst
);
3572 operand2
= inst_env
->reg
[REG_PC
];
3574 /* The quick value is signed, so check if we must do a signed extend. */
3575 if (operand1
& SIGNED_QUICK_VALUE_MASK
)
3578 operand1
|= SIGNED_QUICK_VALUE_EXTEND_MASK
;
3580 /* The size should now be dword. */
3581 cris_set_size_to_dword (&inst
);
3583 /* Calculate the PC value after the instruction, i.e. where the
3584 breakpoint should be. */
3585 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand1
);
3587 inst_env
->slot_needed
= 0;
3588 inst_env
->prefix_found
= 0;
3589 inst_env
->xflag_found
= 0;
3590 inst_env
->disable_interrupt
= 0;
3593 /* Translate op_type to a function and call it. */
3596 cris_gdb_func (struct gdbarch
*gdbarch
, enum cris_op_type op_type
,
3597 unsigned short inst
, inst_env_type
*inst_env
)
3601 case cris_not_implemented_op
:
3602 not_implemented_op (inst
, inst_env
);
3606 abs_op (inst
, inst_env
);
3610 addi_op (inst
, inst_env
);
3614 asr_op (inst
, inst_env
);
3618 asrq_op (inst
, inst_env
);
3621 case cris_ax_ei_setf_op
:
3622 ax_ei_setf_op (inst
, inst_env
);
3625 case cris_bdap_prefix
:
3626 bdap_prefix (inst
, inst_env
);
3629 case cris_biap_prefix
:
3630 biap_prefix (inst
, inst_env
);
3634 break_op (inst
, inst_env
);
3637 case cris_btst_nop_op
:
3638 btst_nop_op (inst
, inst_env
);
3641 case cris_clearf_di_op
:
3642 clearf_di_op (inst
, inst_env
);
3645 case cris_dip_prefix
:
3646 dip_prefix (inst
, inst_env
);
3649 case cris_dstep_logshift_mstep_neg_not_op
:
3650 dstep_logshift_mstep_neg_not_op (inst
, inst_env
);
3653 case cris_eight_bit_offset_branch_op
:
3654 eight_bit_offset_branch_op (inst
, inst_env
);
3657 case cris_move_mem_to_reg_movem_op
:
3658 move_mem_to_reg_movem_op (inst
, inst_env
);
3661 case cris_move_reg_to_mem_movem_op
:
3662 move_reg_to_mem_movem_op (inst
, inst_env
);
3665 case cris_move_to_preg_op
:
3666 move_to_preg_op (gdbarch
, inst
, inst_env
);
3670 muls_op (inst
, inst_env
);
3674 mulu_op (inst
, inst_env
);
3677 case cris_none_reg_mode_add_sub_cmp_and_or_move_op
:
3678 none_reg_mode_add_sub_cmp_and_or_move_op (inst
, inst_env
);
3681 case cris_none_reg_mode_clear_test_op
:
3682 none_reg_mode_clear_test_op (inst
, inst_env
);
3685 case cris_none_reg_mode_jump_op
:
3686 none_reg_mode_jump_op (inst
, inst_env
);
3689 case cris_none_reg_mode_move_from_preg_op
:
3690 none_reg_mode_move_from_preg_op (gdbarch
, inst
, inst_env
);
3693 case cris_quick_mode_add_sub_op
:
3694 quick_mode_add_sub_op (inst
, inst_env
);
3697 case cris_quick_mode_and_cmp_move_or_op
:
3698 quick_mode_and_cmp_move_or_op (inst
, inst_env
);
3701 case cris_quick_mode_bdap_prefix
:
3702 quick_mode_bdap_prefix (inst
, inst_env
);
3705 case cris_reg_mode_add_sub_cmp_and_or_move_op
:
3706 reg_mode_add_sub_cmp_and_or_move_op (inst
, inst_env
);
3709 case cris_reg_mode_clear_op
:
3710 reg_mode_clear_op (inst
, inst_env
);
3713 case cris_reg_mode_jump_op
:
3714 reg_mode_jump_op (inst
, inst_env
);
3717 case cris_reg_mode_move_from_preg_op
:
3718 reg_mode_move_from_preg_op (inst
, inst_env
);
3721 case cris_reg_mode_test_op
:
3722 reg_mode_test_op (inst
, inst_env
);
3726 scc_op (inst
, inst_env
);
3729 case cris_sixteen_bit_offset_branch_op
:
3730 sixteen_bit_offset_branch_op (inst
, inst_env
);
3733 case cris_three_operand_add_sub_cmp_and_or_op
:
3734 three_operand_add_sub_cmp_and_or_op (inst
, inst_env
);
3737 case cris_three_operand_bound_op
:
3738 three_operand_bound_op (inst
, inst_env
);
3741 case cris_two_operand_bound_op
:
3742 two_operand_bound_op (inst
, inst_env
);
3746 xor_op (inst
, inst_env
);
3751 /* Originally from <asm/elf.h>. */
3752 typedef unsigned char cris_elf_greg_t
[4];
3754 /* Same as user_regs_struct struct in <asm/user.h>. */
3755 #define CRISV10_ELF_NGREG 35
3756 typedef cris_elf_greg_t cris_elf_gregset_t
[CRISV10_ELF_NGREG
];
3758 #define CRISV32_ELF_NGREG 32
3759 typedef cris_elf_greg_t crisv32_elf_gregset_t
[CRISV32_ELF_NGREG
];
3761 /* Unpack a cris_elf_gregset_t into GDB's register cache. */
3764 cris_supply_gregset (struct regcache
*regcache
, cris_elf_gregset_t
*gregsetp
)
3766 struct gdbarch
*gdbarch
= regcache
->arch ();
3767 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
3769 cris_elf_greg_t
*regp
= *gregsetp
;
3771 /* The kernel dumps all 32 registers as unsigned longs, but supply_register
3772 knows about the actual size of each register so that's no problem. */
3773 for (i
= 0; i
< NUM_GENREGS
+ NUM_SPECREGS
; i
++)
3775 regcache
->raw_supply (i
, (char *)®p
[i
]);
3778 if (tdep
->cris_version
== 32)
3780 /* Needed to set pseudo-register PC for CRISv32. */
3781 /* FIXME: If ERP is in a delay slot at this point then the PC will
3782 be wrong. Issue a warning to alert the user. */
3783 regcache
->raw_supply (gdbarch_pc_regnum (gdbarch
),
3784 (char *)®p
[ERP_REGNUM
]);
3786 if (*(char *)®p
[ERP_REGNUM
] & 0x1)
3787 fprintf_unfiltered (gdb_stderr
, "Warning: PC in delay slot\n");
3791 /* Use a local version of this function to get the correct types for
3792 regsets, until multi-arch core support is ready. */
3795 fetch_core_registers (struct regcache
*regcache
,
3796 char *core_reg_sect
, unsigned core_reg_size
,
3797 int which
, CORE_ADDR reg_addr
)
3799 cris_elf_gregset_t gregset
;
3804 if (core_reg_size
!= sizeof (cris_elf_gregset_t
)
3805 && core_reg_size
!= sizeof (crisv32_elf_gregset_t
))
3807 warning (_("wrong size gregset struct in core file"));
3811 memcpy (&gregset
, core_reg_sect
, sizeof (gregset
));
3812 cris_supply_gregset (regcache
, &gregset
);
3816 /* We've covered all the kinds of registers we know about here,
3817 so this must be something we wouldn't know what to do with
3818 anyway. Just ignore it. */
3823 static struct core_fns cris_elf_core_fns
=
3825 bfd_target_elf_flavour
, /* core_flavour */
3826 default_check_format
, /* check_format */
3827 default_core_sniffer
, /* core_sniffer */
3828 fetch_core_registers
, /* core_read_registers */
3833 _initialize_cris_tdep (void)
3835 gdbarch_register (bfd_arch_cris
, cris_gdbarch_init
, cris_dump_tdep
);
3837 /* CRIS-specific user-commands. */
3838 add_setshow_zuinteger_cmd ("cris-version", class_support
,
3839 &usr_cmd_cris_version
,
3840 _("Set the current CRIS version."),
3841 _("Show the current CRIS version."),
3843 Set to 10 for CRISv10 or 32 for CRISv32 if autodetection fails.\n\
3846 NULL
, /* FIXME: i18n: Current CRIS version
3848 &setlist
, &showlist
);
3850 add_setshow_enum_cmd ("cris-mode", class_support
,
3851 cris_modes
, &usr_cmd_cris_mode
,
3852 _("Set the current CRIS mode."),
3853 _("Show the current CRIS mode."),
3855 Set to CRIS_MODE_GURU when debugging in guru mode.\n\
3856 Makes GDB use the NRP register instead of the ERP register in certain cases."),
3858 NULL
, /* FIXME: i18n: Current CRIS version is %s. */
3859 &setlist
, &showlist
);
3861 add_setshow_boolean_cmd ("cris-dwarf2-cfi", class_support
,
3862 &usr_cmd_cris_dwarf2_cfi
,
3863 _("Set the usage of Dwarf-2 CFI for CRIS."),
3864 _("Show the usage of Dwarf-2 CFI for CRIS."),
3865 _("Set this to \"off\" if using gcc-cris < R59."),
3866 set_cris_dwarf2_cfi
,
3867 NULL
, /* FIXME: i18n: Usage of Dwarf-2 CFI
3869 &setlist
, &showlist
);
3871 deprecated_add_core_fns (&cris_elf_core_fns
);
3874 /* Prints out all target specific values. */
3877 cris_dump_tdep (struct gdbarch
*gdbarch
, struct ui_file
*file
)
3879 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
3882 fprintf_unfiltered (file
, "cris_dump_tdep: tdep->cris_version = %i\n",
3883 tdep
->cris_version
);
3884 fprintf_unfiltered (file
, "cris_dump_tdep: tdep->cris_mode = %s\n",
3886 fprintf_unfiltered (file
, "cris_dump_tdep: tdep->cris_dwarf2_cfi = %i\n",
3887 tdep
->cris_dwarf2_cfi
);
3892 set_cris_version (const char *ignore_args
, int from_tty
,
3893 struct cmd_list_element
*c
)
3895 struct gdbarch_info info
;
3897 usr_cmd_cris_version_valid
= 1;
3899 /* Update the current architecture, if needed. */
3900 gdbarch_info_init (&info
);
3901 if (!gdbarch_update_p (info
))
3902 internal_error (__FILE__
, __LINE__
,
3903 _("cris_gdbarch_update: failed to update architecture."));
3907 set_cris_mode (const char *ignore_args
, int from_tty
,
3908 struct cmd_list_element
*c
)
3910 struct gdbarch_info info
;
3912 /* Update the current architecture, if needed. */
3913 gdbarch_info_init (&info
);
3914 if (!gdbarch_update_p (info
))
3915 internal_error (__FILE__
, __LINE__
,
3916 "cris_gdbarch_update: failed to update architecture.");
3920 set_cris_dwarf2_cfi (const char *ignore_args
, int from_tty
,
3921 struct cmd_list_element
*c
)
3923 struct gdbarch_info info
;
3925 /* Update the current architecture, if needed. */
3926 gdbarch_info_init (&info
);
3927 if (!gdbarch_update_p (info
))
3928 internal_error (__FILE__
, __LINE__
,
3929 _("cris_gdbarch_update: failed to update architecture."));
3932 static struct gdbarch
*
3933 cris_gdbarch_init (struct gdbarch_info info
, struct gdbarch_list
*arches
)
3935 struct gdbarch
*gdbarch
;
3936 struct gdbarch_tdep
*tdep
;
3937 unsigned int cris_version
;
3939 if (usr_cmd_cris_version_valid
)
3941 /* Trust the user's CRIS version setting. */
3942 cris_version
= usr_cmd_cris_version
;
3944 else if (info
.abfd
&& bfd_get_mach (info
.abfd
) == bfd_mach_cris_v32
)
3950 /* Assume it's CRIS version 10. */
3954 /* Make the current settings visible to the user. */
3955 usr_cmd_cris_version
= cris_version
;
3957 /* Find a candidate among the list of pre-declared architectures. */
3958 for (arches
= gdbarch_list_lookup_by_info (arches
, &info
);
3960 arches
= gdbarch_list_lookup_by_info (arches
->next
, &info
))
3962 if ((gdbarch_tdep (arches
->gdbarch
)->cris_version
3963 == usr_cmd_cris_version
)
3964 && (gdbarch_tdep (arches
->gdbarch
)->cris_mode
3965 == usr_cmd_cris_mode
)
3966 && (gdbarch_tdep (arches
->gdbarch
)->cris_dwarf2_cfi
3967 == usr_cmd_cris_dwarf2_cfi
))
3968 return arches
->gdbarch
;
3971 /* No matching architecture was found. Create a new one. */
3972 tdep
= XCNEW (struct gdbarch_tdep
);
3973 info
.byte_order
= BFD_ENDIAN_LITTLE
;
3974 gdbarch
= gdbarch_alloc (&info
, tdep
);
3976 tdep
->cris_version
= usr_cmd_cris_version
;
3977 tdep
->cris_mode
= usr_cmd_cris_mode
;
3978 tdep
->cris_dwarf2_cfi
= usr_cmd_cris_dwarf2_cfi
;
3980 set_gdbarch_return_value (gdbarch
, cris_return_value
);
3981 set_gdbarch_sp_regnum (gdbarch
, 14);
3983 /* Length of ordinary registers used in push_word and a few other
3984 places. register_size() is the real way to know how big a
3987 set_gdbarch_double_bit (gdbarch
, 64);
3988 /* The default definition of a long double is 2 * gdbarch_double_bit,
3989 which means we have to set this explicitly. */
3990 set_gdbarch_long_double_bit (gdbarch
, 64);
3992 /* The total amount of space needed to store (in an array called registers)
3993 GDB's copy of the machine's register state. Note: We can not use
3994 cris_register_size at this point, since it relies on gdbarch
3996 switch (tdep
->cris_version
)
4004 /* Old versions; not supported. */
4009 /* CRIS v10 and v11, a.k.a. ETRAX 100LX. In addition to ETRAX 100,
4010 P7 (32 bits), and P15 (32 bits) have been implemented. */
4011 set_gdbarch_pc_regnum (gdbarch
, 15);
4012 set_gdbarch_register_type (gdbarch
, cris_register_type
);
4013 /* There are 32 registers (some of which may not be implemented). */
4014 set_gdbarch_num_regs (gdbarch
, 32);
4015 set_gdbarch_register_name (gdbarch
, cris_register_name
);
4016 set_gdbarch_cannot_store_register (gdbarch
, cris_cannot_store_register
);
4017 set_gdbarch_cannot_fetch_register (gdbarch
, cris_cannot_fetch_register
);
4019 set_gdbarch_software_single_step (gdbarch
, cris_software_single_step
);
4023 /* CRIS v32. General registers R0 - R15 (32 bits), special registers
4024 P0 - P15 (32 bits) except P0, P1, P3 (8 bits) and P4 (16 bits)
4025 and pseudo-register PC (32 bits). */
4026 set_gdbarch_pc_regnum (gdbarch
, 32);
4027 set_gdbarch_register_type (gdbarch
, crisv32_register_type
);
4028 /* 32 registers + pseudo-register PC + 16 support registers. */
4029 set_gdbarch_num_regs (gdbarch
, 32 + 1 + 16);
4030 set_gdbarch_register_name (gdbarch
, crisv32_register_name
);
4032 set_gdbarch_cannot_store_register
4033 (gdbarch
, crisv32_cannot_store_register
);
4034 set_gdbarch_cannot_fetch_register
4035 (gdbarch
, crisv32_cannot_fetch_register
);
4037 set_gdbarch_have_nonsteppable_watchpoint (gdbarch
, 1);
4039 set_gdbarch_single_step_through_delay
4040 (gdbarch
, crisv32_single_step_through_delay
);
4045 /* Unknown version. */
4049 /* Dummy frame functions (shared between CRISv10 and CRISv32 since they
4050 have the same ABI). */
4051 set_gdbarch_push_dummy_code (gdbarch
, cris_push_dummy_code
);
4052 set_gdbarch_push_dummy_call (gdbarch
, cris_push_dummy_call
);
4053 set_gdbarch_frame_align (gdbarch
, cris_frame_align
);
4054 set_gdbarch_skip_prologue (gdbarch
, cris_skip_prologue
);
4056 /* The stack grows downward. */
4057 set_gdbarch_inner_than (gdbarch
, core_addr_lessthan
);
4059 set_gdbarch_breakpoint_kind_from_pc (gdbarch
, cris_breakpoint_kind_from_pc
);
4060 set_gdbarch_sw_breakpoint_from_kind (gdbarch
, cris_sw_breakpoint_from_kind
);
4062 if (tdep
->cris_dwarf2_cfi
== 1)
4064 /* Hook in the Dwarf-2 frame sniffer. */
4065 set_gdbarch_dwarf2_reg_to_regnum (gdbarch
, cris_dwarf2_reg_to_regnum
);
4066 dwarf2_frame_set_init_reg (gdbarch
, cris_dwarf2_frame_init_reg
);
4067 dwarf2_append_unwinders (gdbarch
);
4070 if (tdep
->cris_mode
!= cris_mode_guru
)
4072 frame_unwind_append_unwinder (gdbarch
, &cris_sigtramp_frame_unwind
);
4075 frame_unwind_append_unwinder (gdbarch
, &cris_frame_unwind
);
4076 frame_base_set_default (gdbarch
, &cris_frame_base
);
4078 /* Hook in ABI-specific overrides, if they have been registered. */
4079 gdbarch_init_osabi (info
, gdbarch
);