1 /* Target dependent code for CRIS, for GDB, the GNU debugger.
3 Copyright (C) 2001-2022 Free Software Foundation, Inc.
5 Contributed by Axis Communications AB.
6 Written by Hendrik Ruijter, Stefan Andersson, and Orjan Friberg.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #include "frame-unwind.h"
26 #include "frame-base.h"
27 #include "trad-frame.h"
28 #include "dwarf2/frame.h"
36 #include "opcode/cris.h"
38 #include "arch-utils.h"
44 #include "solib.h" /* Support for shared libraries. */
45 #include "solib-svr4.h"
48 #include "cris-tdep.h"
52 /* There are no floating point registers. Used in gdbserver low-linux.c. */
55 /* There are 16 general registers. */
58 /* There are 16 special registers. */
61 /* CRISv32 has a pseudo PC register, not noted here. */
63 /* CRISv32 has 16 support registers. */
67 /* Register numbers of various important registers.
68 CRIS_FP_REGNUM Contains address of executing stack frame.
69 STR_REGNUM Contains the address of structure return values.
70 RET_REGNUM Contains the return value when shorter than or equal to 32 bits
71 ARG1_REGNUM Contains the first parameter to a function.
72 ARG2_REGNUM Contains the second parameter to a function.
73 ARG3_REGNUM Contains the third parameter to a function.
74 ARG4_REGNUM Contains the fourth parameter to a function. Rest on stack.
75 gdbarch_sp_regnum Contains address of top of stack.
76 gdbarch_pc_regnum Contains address of next instruction.
77 SRP_REGNUM Subroutine return pointer register.
78 BRP_REGNUM Breakpoint return pointer register. */
82 /* Enums with respect to the general registers, valid for all
83 CRIS versions. The frame pointer is always in R8. */
85 /* ABI related registers. */
93 /* Registers which happen to be common. */
98 /* CRISv10 et al. specific registers. */
110 /* CRISv32 specific registers. */
123 CRISV32USP_REGNUM
= 30, /* Shares name but not number with CRISv10. */
125 CRISV32PC_REGNUM
= 32, /* Shares name but not number with CRISv10. */
145 extern const struct cris_spec_reg cris_spec_regs
[];
147 /* CRIS version, set via the user command 'set cris-version'. Affects
148 register names and sizes. */
149 static unsigned int usr_cmd_cris_version
;
151 /* Indicates whether to trust the above variable. */
152 static bool usr_cmd_cris_version_valid
= false;
154 static const char cris_mode_normal
[] = "normal";
155 static const char cris_mode_guru
[] = "guru";
156 static const char *const cris_modes
[] = {
162 /* CRIS mode, set via the user command 'set cris-mode'. Affects
163 type of break instruction among other things. */
164 static const char *usr_cmd_cris_mode
= cris_mode_normal
;
166 /* Whether to make use of Dwarf-2 CFI (default on). */
167 static bool usr_cmd_cris_dwarf2_cfi
= true;
169 /* Sigtramp identification code copied from i386-linux-tdep.c. */
171 #define SIGTRAMP_INSN0 0x9c5f /* movu.w 0xXX, $r9 */
172 #define SIGTRAMP_OFFSET0 0
173 #define SIGTRAMP_INSN1 0xe93d /* break 13 */
174 #define SIGTRAMP_OFFSET1 4
176 static const unsigned short sigtramp_code
[] =
178 SIGTRAMP_INSN0
, 0x0077, /* movu.w $0x77, $r9 */
179 SIGTRAMP_INSN1
/* break 13 */
182 #define SIGTRAMP_LEN (sizeof sigtramp_code)
184 /* Note: same length as normal sigtramp code. */
186 static const unsigned short rt_sigtramp_code
[] =
188 SIGTRAMP_INSN0
, 0x00ad, /* movu.w $0xad, $r9 */
189 SIGTRAMP_INSN1
/* break 13 */
192 /* If PC is in a sigtramp routine, return the address of the start of
193 the routine. Otherwise, return 0. */
196 cris_sigtramp_start (struct frame_info
*this_frame
)
198 CORE_ADDR pc
= get_frame_pc (this_frame
);
199 gdb_byte buf
[SIGTRAMP_LEN
];
201 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
))
204 if (((buf
[1] << 8) + buf
[0]) != SIGTRAMP_INSN0
)
206 if (((buf
[1] << 8) + buf
[0]) != SIGTRAMP_INSN1
)
209 pc
-= SIGTRAMP_OFFSET1
;
210 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
))
214 if (memcmp (buf
, sigtramp_code
, SIGTRAMP_LEN
) != 0)
220 /* If PC is in a RT sigtramp routine, return the address of the start of
221 the routine. Otherwise, return 0. */
224 cris_rt_sigtramp_start (struct frame_info
*this_frame
)
226 CORE_ADDR pc
= get_frame_pc (this_frame
);
227 gdb_byte buf
[SIGTRAMP_LEN
];
229 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
))
232 if (((buf
[1] << 8) + buf
[0]) != SIGTRAMP_INSN0
)
234 if (((buf
[1] << 8) + buf
[0]) != SIGTRAMP_INSN1
)
237 pc
-= SIGTRAMP_OFFSET1
;
238 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
))
242 if (memcmp (buf
, rt_sigtramp_code
, SIGTRAMP_LEN
) != 0)
248 /* Assuming THIS_FRAME is a frame for a GNU/Linux sigtramp routine,
249 return the address of the associated sigcontext structure. */
252 cris_sigcontext_addr (struct frame_info
*this_frame
)
254 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
255 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
260 get_frame_register (this_frame
, gdbarch_sp_regnum (gdbarch
), buf
);
261 sp
= extract_unsigned_integer (buf
, 4, byte_order
);
263 /* Look for normal sigtramp frame first. */
264 pc
= cris_sigtramp_start (this_frame
);
267 /* struct signal_frame (arch/cris/kernel/signal.c) contains
268 struct sigcontext as its first member, meaning the SP points to
273 pc
= cris_rt_sigtramp_start (this_frame
);
276 /* struct rt_signal_frame (arch/cris/kernel/signal.c) contains
277 a struct ucontext, which in turn contains a struct sigcontext.
279 4 + 4 + 128 to struct ucontext, then
280 4 + 4 + 12 to struct sigcontext. */
284 error (_("Couldn't recognize signal trampoline."));
288 struct cris_unwind_cache
290 /* The previous frame's inner most stack address. Used as this
291 frame ID's stack_addr. */
293 /* The frame's base, optionally used by the high-level debug info. */
296 /* How far the SP and r8 (FP) have been offset from the start of
297 the stack frame (as defined by the previous frame's stack
303 /* From old frame_extra_info struct. */
307 /* Table indicating the location of each and every register. */
308 trad_frame_saved_reg
*saved_regs
;
311 static struct cris_unwind_cache
*
312 cris_sigtramp_frame_unwind_cache (struct frame_info
*this_frame
,
315 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
316 cris_gdbarch_tdep
*tdep
= (cris_gdbarch_tdep
*) gdbarch_tdep (gdbarch
);
317 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
318 struct cris_unwind_cache
*info
;
324 return (struct cris_unwind_cache
*) (*this_cache
);
326 info
= FRAME_OBSTACK_ZALLOC (struct cris_unwind_cache
);
327 (*this_cache
) = info
;
328 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
330 /* Zero all fields. */
336 info
->uses_frame
= 0;
338 info
->leaf_function
= 0;
340 get_frame_register (this_frame
, gdbarch_sp_regnum (gdbarch
), buf
);
341 info
->base
= extract_unsigned_integer (buf
, 4, byte_order
);
343 addr
= cris_sigcontext_addr (this_frame
);
345 /* Layout of the sigcontext struct:
348 unsigned long oldmask;
352 if (tdep
->cris_version
== 10)
354 /* R0 to R13 are stored in reverse order at offset (2 * 4) in
356 for (i
= 0; i
<= 13; i
++)
357 info
->saved_regs
[i
].set_addr (addr
+ ((15 - i
) * 4));
359 info
->saved_regs
[MOF_REGNUM
].set_addr (addr
+ (16 * 4));
360 info
->saved_regs
[DCCR_REGNUM
].set_addr (addr
+ (17 * 4));
361 info
->saved_regs
[SRP_REGNUM
].set_addr (addr
+ (18 * 4));
362 /* Note: IRP is off by 2 at this point. There's no point in correcting
363 it though since that will mean that the backtrace will show a PC
364 different from what is shown when stopped. */
365 info
->saved_regs
[IRP_REGNUM
].set_addr (addr
+ (19 * 4));
366 info
->saved_regs
[gdbarch_pc_regnum (gdbarch
)]
367 = info
->saved_regs
[IRP_REGNUM
];
368 info
->saved_regs
[gdbarch_sp_regnum (gdbarch
)].set_addr (addr
+ (24 * 4));
373 /* R0 to R13 are stored in order at offset (1 * 4) in
375 for (i
= 0; i
<= 13; i
++)
376 info
->saved_regs
[i
].set_addr (addr
+ ((i
+ 1) * 4));
378 info
->saved_regs
[ACR_REGNUM
].set_addr (addr
+ (15 * 4));
379 info
->saved_regs
[SRS_REGNUM
].set_addr (addr
+ (16 * 4));
380 info
->saved_regs
[MOF_REGNUM
].set_addr (addr
+ (17 * 4));
381 info
->saved_regs
[SPC_REGNUM
].set_addr (addr
+ (18 * 4));
382 info
->saved_regs
[CCS_REGNUM
].set_addr (addr
+ (19 * 4));
383 info
->saved_regs
[SRP_REGNUM
].set_addr (addr
+ (20 * 4));
384 info
->saved_regs
[ERP_REGNUM
].set_addr (addr
+ (21 * 4));
385 info
->saved_regs
[EXS_REGNUM
].set_addr (addr
+ (22 * 4));
386 info
->saved_regs
[EDA_REGNUM
].set_addr (addr
+ (23 * 4));
388 /* FIXME: If ERP is in a delay slot at this point then the PC will
389 be wrong at this point. This problem manifests itself in the
390 sigaltstack.exp test case, which occasionally generates FAILs when
391 the signal is received while in a delay slot.
393 This could be solved by a couple of read_memory_unsigned_integer and a
394 trad_frame_set_value. */
395 info
->saved_regs
[gdbarch_pc_regnum (gdbarch
)]
396 = info
->saved_regs
[ERP_REGNUM
];
398 info
->saved_regs
[gdbarch_sp_regnum (gdbarch
)].set_addr (addr
+ (25 * 4));
405 cris_sigtramp_frame_this_id (struct frame_info
*this_frame
, void **this_cache
,
406 struct frame_id
*this_id
)
408 struct cris_unwind_cache
*cache
=
409 cris_sigtramp_frame_unwind_cache (this_frame
, this_cache
);
410 (*this_id
) = frame_id_build (cache
->base
, get_frame_pc (this_frame
));
413 /* Forward declaration. */
415 static struct value
*cris_frame_prev_register (struct frame_info
*this_frame
,
416 void **this_cache
, int regnum
);
417 static struct value
*
418 cris_sigtramp_frame_prev_register (struct frame_info
*this_frame
,
419 void **this_cache
, int regnum
)
421 /* Make sure we've initialized the cache. */
422 cris_sigtramp_frame_unwind_cache (this_frame
, this_cache
);
423 return cris_frame_prev_register (this_frame
, this_cache
, regnum
);
427 cris_sigtramp_frame_sniffer (const struct frame_unwind
*self
,
428 struct frame_info
*this_frame
,
431 if (cris_sigtramp_start (this_frame
)
432 || cris_rt_sigtramp_start (this_frame
))
438 static const struct frame_unwind cris_sigtramp_frame_unwind
=
442 default_frame_unwind_stop_reason
,
443 cris_sigtramp_frame_this_id
,
444 cris_sigtramp_frame_prev_register
,
446 cris_sigtramp_frame_sniffer
450 crisv32_single_step_through_delay (struct gdbarch
*gdbarch
,
451 struct frame_info
*this_frame
)
453 cris_gdbarch_tdep
*tdep
= (cris_gdbarch_tdep
*) gdbarch_tdep (gdbarch
);
457 if (tdep
->cris_mode
== cris_mode_guru
)
458 erp
= get_frame_register_unsigned (this_frame
, NRP_REGNUM
);
460 erp
= get_frame_register_unsigned (this_frame
, ERP_REGNUM
);
464 /* In delay slot - check if there's a breakpoint at the preceding
466 if (breakpoint_here_p (get_frame_address_space (this_frame
), erp
& ~0x1))
472 /* The instruction environment needed to find single-step breakpoints. */
475 struct instruction_environment
477 unsigned long reg
[NUM_GENREGS
];
478 unsigned long preg
[NUM_SPECREGS
];
479 unsigned long branch_break_address
;
480 unsigned long delay_slot_pc
;
481 unsigned long prefix_value
;
486 int delay_slot_pc_active
;
488 int disable_interrupt
;
489 enum bfd_endian byte_order
;
492 /* Machine-dependencies in CRIS for opcodes. */
494 /* Instruction sizes. */
495 enum cris_instruction_sizes
502 /* Addressing modes. */
503 enum cris_addressing_modes
510 /* Prefix addressing modes. */
511 enum cris_prefix_addressing_modes
513 PREFIX_INDEX_MODE
= 2,
514 PREFIX_ASSIGN_MODE
= 3,
516 /* Handle immediate byte offset addressing mode prefix format. */
517 PREFIX_OFFSET_MODE
= 2
520 /* Masks for opcodes. */
521 enum cris_opcode_masks
523 BRANCH_SIGNED_SHORT_OFFSET_MASK
= 0x1,
524 SIGNED_EXTEND_BIT_MASK
= 0x2,
525 SIGNED_BYTE_MASK
= 0x80,
526 SIGNED_BYTE_EXTEND_MASK
= 0xFFFFFF00,
527 SIGNED_WORD_MASK
= 0x8000,
528 SIGNED_WORD_EXTEND_MASK
= 0xFFFF0000,
529 SIGNED_DWORD_MASK
= 0x80000000,
530 SIGNED_QUICK_VALUE_MASK
= 0x20,
531 SIGNED_QUICK_VALUE_EXTEND_MASK
= 0xFFFFFFC0
534 /* Functions for opcodes. The general form of the ETRAX 16-bit instruction:
542 cris_get_operand2 (unsigned short insn
)
544 return ((insn
& 0xF000) >> 12);
548 cris_get_mode (unsigned short insn
)
550 return ((insn
& 0x0C00) >> 10);
554 cris_get_opcode (unsigned short insn
)
556 return ((insn
& 0x03C0) >> 6);
560 cris_get_size (unsigned short insn
)
562 return ((insn
& 0x0030) >> 4);
566 cris_get_operand1 (unsigned short insn
)
568 return (insn
& 0x000F);
571 /* Additional functions in order to handle opcodes. */
574 cris_get_quick_value (unsigned short insn
)
576 return (insn
& 0x003F);
580 cris_get_bdap_quick_offset (unsigned short insn
)
582 return (insn
& 0x00FF);
586 cris_get_branch_short_offset (unsigned short insn
)
588 return (insn
& 0x00FF);
592 cris_get_asr_shift_steps (unsigned long value
)
594 return (value
& 0x3F);
598 cris_get_clear_size (unsigned short insn
)
600 return ((insn
) & 0xC000);
604 cris_is_signed_extend_bit_on (unsigned short insn
)
606 return (((insn
) & 0x20) == 0x20);
610 cris_is_xflag_bit_on (unsigned short insn
)
612 return (((insn
) & 0x1000) == 0x1000);
616 cris_set_size_to_dword (unsigned short *insn
)
623 cris_get_signed_offset (unsigned short insn
)
625 return ((signed char) (insn
& 0x00FF));
628 /* Calls an op function given the op-type, working on the insn and the
630 static void cris_gdb_func (struct gdbarch
*, enum cris_op_type
, unsigned short,
633 static struct gdbarch
*cris_gdbarch_init (struct gdbarch_info
,
634 struct gdbarch_list
*);
636 static void cris_dump_tdep (struct gdbarch
*, struct ui_file
*);
638 static void set_cris_version (const char *ignore_args
, int from_tty
,
639 struct cmd_list_element
*c
);
641 static void set_cris_mode (const char *ignore_args
, int from_tty
,
642 struct cmd_list_element
*c
);
644 static void set_cris_dwarf2_cfi (const char *ignore_args
, int from_tty
,
645 struct cmd_list_element
*c
);
647 static CORE_ADDR
cris_scan_prologue (CORE_ADDR pc
,
648 struct frame_info
*this_frame
,
649 struct cris_unwind_cache
*info
);
651 static CORE_ADDR
crisv32_scan_prologue (CORE_ADDR pc
,
652 struct frame_info
*this_frame
,
653 struct cris_unwind_cache
*info
);
655 /* When arguments must be pushed onto the stack, they go on in reverse
656 order. The below implements a FILO (stack) to do this.
657 Copied from d10v-tdep.c. */
662 struct stack_item
*prev
;
666 static struct stack_item
*
667 push_stack_item (struct stack_item
*prev
, const gdb_byte
*contents
, int len
)
669 struct stack_item
*si
= XNEW (struct stack_item
);
670 si
->data
= (gdb_byte
*) xmalloc (len
);
673 memcpy (si
->data
, contents
, len
);
677 static struct stack_item
*
678 pop_stack_item (struct stack_item
*si
)
680 struct stack_item
*dead
= si
;
687 /* Put here the code to store, into fi->saved_regs, the addresses of
688 the saved registers of frame described by FRAME_INFO. This
689 includes special registers such as pc and fp saved in special ways
690 in the stack frame. sp is even more special: the address we return
691 for it IS the sp for the next frame. */
693 static struct cris_unwind_cache
*
694 cris_frame_unwind_cache (struct frame_info
*this_frame
,
695 void **this_prologue_cache
)
697 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
698 cris_gdbarch_tdep
*tdep
= (cris_gdbarch_tdep
*) gdbarch_tdep (gdbarch
);
699 struct cris_unwind_cache
*info
;
701 if ((*this_prologue_cache
))
702 return (struct cris_unwind_cache
*) (*this_prologue_cache
);
704 info
= FRAME_OBSTACK_ZALLOC (struct cris_unwind_cache
);
705 (*this_prologue_cache
) = info
;
706 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
708 /* Zero all fields. */
714 info
->uses_frame
= 0;
716 info
->leaf_function
= 0;
718 /* Prologue analysis does the rest... */
719 if (tdep
->cris_version
== 32)
720 crisv32_scan_prologue (get_frame_func (this_frame
), this_frame
, info
);
722 cris_scan_prologue (get_frame_func (this_frame
), this_frame
, info
);
727 /* Given a GDB frame, determine the address of the calling function's
728 frame. This will be used to create a new GDB frame struct. */
731 cris_frame_this_id (struct frame_info
*this_frame
,
732 void **this_prologue_cache
,
733 struct frame_id
*this_id
)
735 struct cris_unwind_cache
*info
736 = cris_frame_unwind_cache (this_frame
, this_prologue_cache
);
741 /* The FUNC is easy. */
742 func
= get_frame_func (this_frame
);
744 /* Hopefully the prologue analysis either correctly determined the
745 frame's base (which is the SP from the previous frame), or set
746 that base to "NULL". */
747 base
= info
->prev_sp
;
751 id
= frame_id_build (base
, func
);
756 static struct value
*
757 cris_frame_prev_register (struct frame_info
*this_frame
,
758 void **this_prologue_cache
, int regnum
)
760 struct cris_unwind_cache
*info
761 = cris_frame_unwind_cache (this_frame
, this_prologue_cache
);
762 return trad_frame_get_prev_register (this_frame
, info
->saved_regs
, regnum
);
766 cris_frame_align (struct gdbarch
*gdbarch
, CORE_ADDR sp
)
768 /* Align to the size of an instruction (so that they can safely be
769 pushed onto the stack). */
774 cris_push_dummy_code (struct gdbarch
*gdbarch
,
775 CORE_ADDR sp
, CORE_ADDR funaddr
,
776 struct value
**args
, int nargs
,
777 struct type
*value_type
,
778 CORE_ADDR
*real_pc
, CORE_ADDR
*bp_addr
,
779 struct regcache
*regcache
)
781 /* Allocate space sufficient for a breakpoint. */
783 /* Store the address of that breakpoint */
785 /* CRIS always starts the call at the callee's entry point. */
791 cris_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
792 struct regcache
*regcache
, CORE_ADDR bp_addr
,
793 int nargs
, struct value
**args
, CORE_ADDR sp
,
794 function_call_return_method return_method
,
795 CORE_ADDR struct_addr
)
797 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
801 struct stack_item
*si
= NULL
;
803 /* Push the return address. */
804 regcache_cooked_write_unsigned (regcache
, SRP_REGNUM
, bp_addr
);
806 /* Are we returning a value using a structure return or a normal value
807 return? struct_addr is the address of the reserved space for the return
808 structure to be written on the stack. */
809 if (return_method
== return_method_struct
)
810 regcache_cooked_write_unsigned (regcache
, STR_REGNUM
, struct_addr
);
812 /* Now load as many as possible of the first arguments into registers,
813 and push the rest onto the stack. */
814 argreg
= ARG1_REGNUM
;
816 for (argnum
= 0; argnum
< nargs
; argnum
++)
823 len
= TYPE_LENGTH (value_type (args
[argnum
]));
824 val
= value_contents (args
[argnum
]).data ();
826 /* How may registers worth of storage do we need for this argument? */
827 reg_demand
= (len
/ 4) + (len
% 4 != 0 ? 1 : 0);
829 if (len
<= (2 * 4) && (argreg
+ reg_demand
- 1 <= ARG4_REGNUM
))
831 /* Data passed by value. Fits in available register(s). */
832 for (i
= 0; i
< reg_demand
; i
++)
834 regcache
->cooked_write (argreg
, val
);
839 else if (len
<= (2 * 4) && argreg
<= ARG4_REGNUM
)
841 /* Data passed by value. Does not fit in available register(s).
842 Use the register(s) first, then the stack. */
843 for (i
= 0; i
< reg_demand
; i
++)
845 if (argreg
<= ARG4_REGNUM
)
847 regcache
->cooked_write (argreg
, val
);
853 /* Push item for later so that pushed arguments
854 come in the right order. */
855 si
= push_stack_item (si
, val
, 4);
860 else if (len
> (2 * 4))
862 /* Data passed by reference. Push copy of data onto stack
863 and pass pointer to this copy as argument. */
864 sp
= (sp
- len
) & ~3;
865 write_memory (sp
, val
, len
);
867 if (argreg
<= ARG4_REGNUM
)
869 regcache_cooked_write_unsigned (regcache
, argreg
, sp
);
875 store_unsigned_integer (buf
, 4, byte_order
, sp
);
876 si
= push_stack_item (si
, buf
, 4);
881 /* Data passed by value. No available registers. Put it on
883 si
= push_stack_item (si
, val
, len
);
889 /* fp_arg must be word-aligned (i.e., don't += len) to match
890 the function prologue. */
891 sp
= (sp
- si
->len
) & ~3;
892 write_memory (sp
, si
->data
, si
->len
);
893 si
= pop_stack_item (si
);
896 /* Finally, update the SP register. */
897 regcache_cooked_write_unsigned (regcache
, gdbarch_sp_regnum (gdbarch
), sp
);
902 static const struct frame_unwind cris_frame_unwind
=
906 default_frame_unwind_stop_reason
,
908 cris_frame_prev_register
,
910 default_frame_sniffer
914 cris_frame_base_address (struct frame_info
*this_frame
, void **this_cache
)
916 struct cris_unwind_cache
*info
917 = cris_frame_unwind_cache (this_frame
, this_cache
);
921 static const struct frame_base cris_frame_base
=
924 cris_frame_base_address
,
925 cris_frame_base_address
,
926 cris_frame_base_address
929 /* Frames information. The definition of the struct frame_info is
933 enum frame_type type;
937 If the compilation option -fno-omit-frame-pointer is present the
938 variable frame will be set to the content of R8 which is the frame
941 The variable pc contains the address where execution is performed
942 in the present frame. The innermost frame contains the current content
943 of the register PC. All other frames contain the content of the
944 register PC in the next frame.
946 The variable `type' indicates the frame's type: normal, SIGTRAMP
947 (associated with a signal handler), dummy (associated with a dummy
950 The variable return_pc contains the address where execution should be
951 resumed when the present frame has finished, the return address.
953 The variable leaf_function is 1 if the return address is in the register
954 SRP, and 0 if it is on the stack.
956 Prologue instructions C-code.
957 The prologue may consist of (-fno-omit-frame-pointer)
961 move.d sp,r8 move.d sp,r8
963 movem rY,[sp] movem rY,[sp]
964 move.S rZ,[r8-U] move.S rZ,[r8-U]
966 where 1 is a non-terminal function, and 2 is a leaf-function.
968 Note that this assumption is extremely brittle, and will break at the
969 slightest change in GCC's prologue.
971 If local variables are declared or register contents are saved on stack
972 the subq-instruction will be present with X as the number of bytes
973 needed for storage. The reshuffle with respect to r8 may be performed
974 with any size S (b, w, d) and any of the general registers Z={0..13}.
975 The offset U should be representable by a signed 8-bit value in all cases.
976 Thus, the prefix word is assumed to be immediate byte offset mode followed
977 by another word containing the instruction.
986 Prologue instructions C++-code.
987 Case 1) and 2) in the C-code may be followed by
993 move.S [r8+U],rZ ; P4
995 if any of the call parameters are stored. The host expects these
996 instructions to be executed in order to get the call parameters right. */
998 /* Examine the prologue of a function. The variable ip is the address of
999 the first instruction of the prologue. The variable limit is the address
1000 of the first instruction after the prologue. The variable fi contains the
1001 information in struct frame_info. The variable frameless_p controls whether
1002 the entire prologue is examined (0) or just enough instructions to
1003 determine that it is a prologue (1). */
1006 cris_scan_prologue (CORE_ADDR pc
, struct frame_info
*this_frame
,
1007 struct cris_unwind_cache
*info
)
1009 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1010 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1012 /* Present instruction. */
1013 unsigned short insn
;
1015 /* Next instruction, lookahead. */
1016 unsigned short insn_next
;
1019 /* Number of byte on stack used for local variables and movem. */
1022 /* Highest register number in a movem. */
1025 /* move.d r<source_register>,rS */
1026 short source_register
;
1031 /* This frame is with respect to a leaf until a push srp is found. */
1034 info
->leaf_function
= 1;
1037 /* Assume nothing on stack. */
1041 /* If we were called without a this_frame, that means we were called
1042 from cris_skip_prologue which already tried to find the end of the
1043 prologue through the symbol information. 64 instructions past current
1044 pc is arbitrarily chosen, but at least it means we'll stop eventually. */
1045 limit
= this_frame
? get_frame_pc (this_frame
) : pc
+ 64;
1047 /* Find the prologue instructions. */
1048 while (pc
> 0 && pc
< limit
)
1050 insn
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1054 /* push <reg> 32 bit instruction. */
1055 insn_next
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1057 regno
= cris_get_operand2 (insn_next
);
1060 info
->sp_offset
+= 4;
1062 /* This check, meant to recognize srp, used to be regno ==
1063 (SRP_REGNUM - NUM_GENREGS), but that covers r11 also. */
1064 if (insn_next
== 0xBE7E)
1068 info
->leaf_function
= 0;
1071 else if (insn_next
== 0x8FEE)
1076 info
->r8_offset
= info
->sp_offset
;
1080 else if (insn
== 0x866E)
1085 info
->uses_frame
= 1;
1089 else if (cris_get_operand2 (insn
) == gdbarch_sp_regnum (gdbarch
)
1090 && cris_get_mode (insn
) == 0x0000
1091 && cris_get_opcode (insn
) == 0x000A)
1096 info
->sp_offset
+= cris_get_quick_value (insn
);
1099 else if (cris_get_mode (insn
) == 0x0002
1100 && cris_get_opcode (insn
) == 0x000F
1101 && cris_get_size (insn
) == 0x0003
1102 && cris_get_operand1 (insn
) == gdbarch_sp_regnum (gdbarch
))
1104 /* movem r<regsave>,[sp] */
1105 regsave
= cris_get_operand2 (insn
);
1107 else if (cris_get_operand2 (insn
) == gdbarch_sp_regnum (gdbarch
)
1108 && ((insn
& 0x0F00) >> 8) == 0x0001
1109 && (cris_get_signed_offset (insn
) < 0))
1111 /* Immediate byte offset addressing prefix word with sp as base
1112 register. Used for CRIS v8 i.e. ETRAX 100 and newer if <val>
1113 is between 64 and 128.
1114 movem r<regsave>,[sp=sp-<val>] */
1117 info
->sp_offset
+= -cris_get_signed_offset (insn
);
1119 insn_next
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1121 if (cris_get_mode (insn_next
) == PREFIX_ASSIGN_MODE
1122 && cris_get_opcode (insn_next
) == 0x000F
1123 && cris_get_size (insn_next
) == 0x0003
1124 && cris_get_operand1 (insn_next
) == gdbarch_sp_regnum
1127 regsave
= cris_get_operand2 (insn_next
);
1131 /* The prologue ended before the limit was reached. */
1136 else if (cris_get_mode (insn
) == 0x0001
1137 && cris_get_opcode (insn
) == 0x0009
1138 && cris_get_size (insn
) == 0x0002)
1140 /* move.d r<10..13>,r<0..15> */
1141 source_register
= cris_get_operand1 (insn
);
1143 /* FIXME? In the glibc solibs, the prologue might contain something
1144 like (this example taken from relocate_doit):
1146 sub.d 0xfffef426,$r0
1147 which isn't covered by the source_register check below. Question
1148 is whether to add a check for this combo, or make better use of
1149 the limit variable instead. */
1150 if (source_register
< ARG1_REGNUM
|| source_register
> ARG4_REGNUM
)
1152 /* The prologue ended before the limit was reached. */
1157 else if (cris_get_operand2 (insn
) == CRIS_FP_REGNUM
1158 /* The size is a fixed-size. */
1159 && ((insn
& 0x0F00) >> 8) == 0x0001
1160 /* A negative offset. */
1161 && (cris_get_signed_offset (insn
) < 0))
1163 /* move.S rZ,[r8-U] (?) */
1164 insn_next
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1166 regno
= cris_get_operand2 (insn_next
);
1167 if ((regno
>= 0 && regno
< gdbarch_sp_regnum (gdbarch
))
1168 && cris_get_mode (insn_next
) == PREFIX_OFFSET_MODE
1169 && cris_get_opcode (insn_next
) == 0x000F)
1171 /* move.S rZ,[r8-U] */
1176 /* The prologue ended before the limit was reached. */
1181 else if (cris_get_operand2 (insn
) == CRIS_FP_REGNUM
1182 /* The size is a fixed-size. */
1183 && ((insn
& 0x0F00) >> 8) == 0x0001
1184 /* A positive offset. */
1185 && (cris_get_signed_offset (insn
) > 0))
1187 /* move.S [r8+U],rZ (?) */
1188 insn_next
= read_memory_unsigned_integer (pc
, 2, byte_order
);
1190 regno
= cris_get_operand2 (insn_next
);
1191 if ((regno
>= 0 && regno
< gdbarch_sp_regnum (gdbarch
))
1192 && cris_get_mode (insn_next
) == PREFIX_OFFSET_MODE
1193 && cris_get_opcode (insn_next
) == 0x0009
1194 && cris_get_operand1 (insn_next
) == regno
)
1196 /* move.S [r8+U],rZ */
1201 /* The prologue ended before the limit was reached. */
1208 /* The prologue ended before the limit was reached. */
1214 /* We only want to know the end of the prologue when this_frame and info
1215 are NULL (called from cris_skip_prologue i.e.). */
1216 if (this_frame
== NULL
&& info
== NULL
)
1221 info
->size
= info
->sp_offset
;
1223 /* Compute the previous frame's stack pointer (which is also the
1224 frame's ID's stack address), and this frame's base pointer. */
1225 if (info
->uses_frame
)
1228 /* The SP was moved to the FP. This indicates that a new frame
1229 was created. Get THIS frame's FP value by unwinding it from
1231 this_base
= get_frame_register_unsigned (this_frame
, CRIS_FP_REGNUM
);
1232 info
->base
= this_base
;
1233 info
->saved_regs
[CRIS_FP_REGNUM
].set_addr (info
->base
);
1235 /* The FP points at the last saved register. Adjust the FP back
1236 to before the first saved register giving the SP. */
1237 info
->prev_sp
= info
->base
+ info
->r8_offset
;
1242 /* Assume that the FP is this frame's SP but with that pushed
1243 stack space added back. */
1244 this_base
= get_frame_register_unsigned (this_frame
,
1245 gdbarch_sp_regnum (gdbarch
));
1246 info
->base
= this_base
;
1247 info
->prev_sp
= info
->base
+ info
->size
;
1250 /* Calculate the addresses for the saved registers on the stack. */
1251 /* FIXME: The address calculation should really be done on the fly while
1252 we're analyzing the prologue (we only hold one regsave value as it is
1254 val
= info
->sp_offset
;
1256 for (regno
= regsave
; regno
>= 0; regno
--)
1258 info
->saved_regs
[regno
].set_addr (info
->base
+ info
->r8_offset
- val
);
1262 /* The previous frame's SP needed to be computed. Save the computed
1264 info
->saved_regs
[gdbarch_sp_regnum (gdbarch
)].set_value (info
->prev_sp
);
1266 if (!info
->leaf_function
)
1268 /* SRP saved on the stack. But where? */
1269 if (info
->r8_offset
== 0)
1271 /* R8 not pushed yet. */
1272 info
->saved_regs
[SRP_REGNUM
].set_addr (info
->base
);
1276 /* R8 pushed, but SP may or may not be moved to R8 yet. */
1277 info
->saved_regs
[SRP_REGNUM
].set_addr (info
->base
+ 4);
1281 /* The PC is found in SRP (the actual register or located on the stack). */
1282 info
->saved_regs
[gdbarch_pc_regnum (gdbarch
)]
1283 = info
->saved_regs
[SRP_REGNUM
];
1289 crisv32_scan_prologue (CORE_ADDR pc
, struct frame_info
*this_frame
,
1290 struct cris_unwind_cache
*info
)
1292 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1295 /* Unlike the CRISv10 prologue scanner (cris_scan_prologue), this is not
1296 meant to be a full-fledged prologue scanner. It is only needed for
1297 the cases where we end up in code always lacking DWARF-2 CFI, notably:
1299 * PLT stubs (library calls)
1301 * signal trampolines
1303 For those cases, it is assumed that there is no actual prologue; that
1304 the stack pointer is not adjusted, and (as a consequence) the return
1305 address is not pushed onto the stack. */
1307 /* We only want to know the end of the prologue when this_frame and info
1308 are NULL (called from cris_skip_prologue i.e.). */
1309 if (this_frame
== NULL
&& info
== NULL
)
1314 /* The SP is assumed to be unaltered. */
1315 this_base
= get_frame_register_unsigned (this_frame
,
1316 gdbarch_sp_regnum (gdbarch
));
1317 info
->base
= this_base
;
1318 info
->prev_sp
= this_base
;
1320 /* The PC is assumed to be found in SRP. */
1321 info
->saved_regs
[gdbarch_pc_regnum (gdbarch
)]
1322 = info
->saved_regs
[SRP_REGNUM
];
1327 /* Advance pc beyond any function entry prologue instructions at pc
1328 to reach some "real" code. */
1330 /* Given a PC value corresponding to the start of a function, return the PC
1331 of the first instruction after the function prologue. */
1334 cris_skip_prologue (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
1336 cris_gdbarch_tdep
*tdep
= (cris_gdbarch_tdep
*) gdbarch_tdep (gdbarch
);
1337 CORE_ADDR func_addr
, func_end
;
1338 struct symtab_and_line sal
;
1339 CORE_ADDR pc_after_prologue
;
1341 /* If we have line debugging information, then the end of the prologue
1342 should the first assembly instruction of the first source line. */
1343 if (find_pc_partial_function (pc
, NULL
, &func_addr
, &func_end
))
1345 sal
= find_pc_line (func_addr
, 0);
1346 if (sal
.end
> 0 && sal
.end
< func_end
)
1350 if (tdep
->cris_version
== 32)
1351 pc_after_prologue
= crisv32_scan_prologue (pc
, NULL
, NULL
);
1353 pc_after_prologue
= cris_scan_prologue (pc
, NULL
, NULL
);
1355 return pc_after_prologue
;
1358 /* Implement the breakpoint_kind_from_pc gdbarch method. */
1361 cris_breakpoint_kind_from_pc (struct gdbarch
*gdbarch
, CORE_ADDR
*pcptr
)
1366 /* Implement the sw_breakpoint_from_kind gdbarch method. */
1368 static const gdb_byte
*
1369 cris_sw_breakpoint_from_kind (struct gdbarch
*gdbarch
, int kind
, int *size
)
1371 cris_gdbarch_tdep
*tdep
= (cris_gdbarch_tdep
*) gdbarch_tdep (gdbarch
);
1372 static unsigned char break8_insn
[] = {0x38, 0xe9};
1373 static unsigned char break15_insn
[] = {0x3f, 0xe9};
1377 if (tdep
->cris_mode
== cris_mode_guru
)
1378 return break15_insn
;
1383 /* Returns 1 if spec_reg is applicable to the current gdbarch's CRIS version,
1387 cris_spec_reg_applicable (struct gdbarch
*gdbarch
,
1388 struct cris_spec_reg spec_reg
)
1390 cris_gdbarch_tdep
*tdep
= (cris_gdbarch_tdep
*) gdbarch_tdep (gdbarch
);
1391 unsigned int version
= tdep
->cris_version
;
1393 switch (spec_reg
.applicable_version
)
1395 case cris_ver_version_all
:
1397 case cris_ver_warning
:
1398 /* Indeterminate/obsolete. */
1401 return in_inclusive_range (version
, 0U, 3U);
1403 return (version
>= 3);
1405 return in_inclusive_range (version
, 8U, 9U);
1407 return (version
>= 8);
1408 case cris_ver_v0_10
:
1409 return in_inclusive_range (version
, 0U, 10U);
1410 case cris_ver_v3_10
:
1411 return in_inclusive_range (version
, 3U, 10U);
1412 case cris_ver_v8_10
:
1413 return in_inclusive_range (version
, 8U, 10U);
1415 return (version
== 10);
1417 return (version
>= 10);
1419 return (version
>= 32);
1421 /* Invalid cris version. */
1426 /* Returns the register size in unit byte. Returns 0 for an unimplemented
1427 register, -1 for an invalid register. */
1430 cris_register_size (struct gdbarch
*gdbarch
, int regno
)
1435 if (regno
>= 0 && regno
< NUM_GENREGS
)
1437 /* General registers (R0 - R15) are 32 bits. */
1440 else if (regno
>= NUM_GENREGS
&& regno
< (NUM_GENREGS
+ NUM_SPECREGS
))
1442 /* Special register (R16 - R31). cris_spec_regs is zero-based.
1443 Adjust regno accordingly. */
1444 spec_regno
= regno
- NUM_GENREGS
;
1446 for (i
= 0; cris_spec_regs
[i
].name
!= NULL
; i
++)
1448 if (cris_spec_regs
[i
].number
== spec_regno
1449 && cris_spec_reg_applicable (gdbarch
, cris_spec_regs
[i
]))
1450 /* Go with the first applicable register. */
1451 return cris_spec_regs
[i
].reg_size
;
1453 /* Special register not applicable to this CRIS version. */
1456 else if (regno
>= gdbarch_pc_regnum (gdbarch
)
1457 && regno
< gdbarch_num_regs (gdbarch
))
1459 /* This will apply to CRISv32 only where there are additional registers
1460 after the special registers (pseudo PC and support registers). */
1468 /* Nonzero if regno should not be fetched from the target. This is the case
1469 for unimplemented (size 0) and non-existant registers. */
1472 cris_cannot_fetch_register (struct gdbarch
*gdbarch
, int regno
)
1474 return ((regno
< 0 || regno
>= gdbarch_num_regs (gdbarch
))
1475 || (cris_register_size (gdbarch
, regno
) == 0));
1478 /* Nonzero if regno should not be written to the target, for various
1482 cris_cannot_store_register (struct gdbarch
*gdbarch
, int regno
)
1484 /* There are three kinds of registers we refuse to write to.
1485 1. Those that not implemented.
1486 2. Those that are read-only (depends on the processor mode).
1487 3. Those registers to which a write has no effect. */
1490 || regno
>= gdbarch_num_regs (gdbarch
)
1491 || cris_register_size (gdbarch
, regno
) == 0)
1492 /* Not implemented. */
1495 else if (regno
== VR_REGNUM
)
1499 else if (regno
== P0_REGNUM
|| regno
== P4_REGNUM
|| regno
== P8_REGNUM
)
1500 /* Writing has no effect. */
1503 /* IBR, BAR, BRP and IRP are read-only in user mode. Let the debug
1504 agent decide whether they are writable. */
1509 /* Nonzero if regno should not be fetched from the target. This is the case
1510 for unimplemented (size 0) and non-existant registers. */
1513 crisv32_cannot_fetch_register (struct gdbarch
*gdbarch
, int regno
)
1515 return ((regno
< 0 || regno
>= gdbarch_num_regs (gdbarch
))
1516 || (cris_register_size (gdbarch
, regno
) == 0));
1519 /* Nonzero if regno should not be written to the target, for various
1523 crisv32_cannot_store_register (struct gdbarch
*gdbarch
, int regno
)
1525 /* There are three kinds of registers we refuse to write to.
1526 1. Those that not implemented.
1527 2. Those that are read-only (depends on the processor mode).
1528 3. Those registers to which a write has no effect. */
1531 || regno
>= gdbarch_num_regs (gdbarch
)
1532 || cris_register_size (gdbarch
, regno
) == 0)
1533 /* Not implemented. */
1536 else if (regno
== VR_REGNUM
)
1540 else if (regno
== BZ_REGNUM
|| regno
== WZ_REGNUM
|| regno
== DZ_REGNUM
)
1541 /* Writing has no effect. */
1544 /* Many special registers are read-only in user mode. Let the debug
1545 agent decide whether they are writable. */
1550 /* Return the GDB type (defined in gdbtypes.c) for the "standard" data type
1551 of data in register regno. */
1553 static struct type
*
1554 cris_register_type (struct gdbarch
*gdbarch
, int regno
)
1556 if (regno
== gdbarch_pc_regnum (gdbarch
))
1557 return builtin_type (gdbarch
)->builtin_func_ptr
;
1558 else if (regno
== gdbarch_sp_regnum (gdbarch
)
1559 || regno
== CRIS_FP_REGNUM
)
1560 return builtin_type (gdbarch
)->builtin_data_ptr
;
1561 else if ((regno
>= 0 && regno
< gdbarch_sp_regnum (gdbarch
))
1562 || (regno
>= MOF_REGNUM
&& regno
<= USP_REGNUM
))
1563 /* Note: R8 taken care of previous clause. */
1564 return builtin_type (gdbarch
)->builtin_uint32
;
1565 else if (regno
>= P4_REGNUM
&& regno
<= CCR_REGNUM
)
1566 return builtin_type (gdbarch
)->builtin_uint16
;
1567 else if (regno
>= P0_REGNUM
&& regno
<= VR_REGNUM
)
1568 return builtin_type (gdbarch
)->builtin_uint8
;
1570 /* Invalid (unimplemented) register. */
1571 return builtin_type (gdbarch
)->builtin_int0
;
1574 static struct type
*
1575 crisv32_register_type (struct gdbarch
*gdbarch
, int regno
)
1577 if (regno
== gdbarch_pc_regnum (gdbarch
))
1578 return builtin_type (gdbarch
)->builtin_func_ptr
;
1579 else if (regno
== gdbarch_sp_regnum (gdbarch
)
1580 || regno
== CRIS_FP_REGNUM
)
1581 return builtin_type (gdbarch
)->builtin_data_ptr
;
1582 else if ((regno
>= 0 && regno
<= ACR_REGNUM
)
1583 || (regno
>= EXS_REGNUM
&& regno
<= SPC_REGNUM
)
1584 || (regno
== PID_REGNUM
)
1585 || (regno
>= S0_REGNUM
&& regno
<= S15_REGNUM
))
1586 /* Note: R8 and SP taken care of by previous clause. */
1587 return builtin_type (gdbarch
)->builtin_uint32
;
1588 else if (regno
== WZ_REGNUM
)
1589 return builtin_type (gdbarch
)->builtin_uint16
;
1590 else if (regno
== BZ_REGNUM
|| regno
== VR_REGNUM
|| regno
== SRS_REGNUM
)
1591 return builtin_type (gdbarch
)->builtin_uint8
;
1594 /* Invalid (unimplemented) register. Should not happen as there are
1595 no unimplemented CRISv32 registers. */
1596 warning (_("crisv32_register_type: unknown regno %d"), regno
);
1597 return builtin_type (gdbarch
)->builtin_int0
;
1601 /* Stores a function return value of type type, where valbuf is the address
1602 of the value to be stored. */
1604 /* In the CRIS ABI, R10 and R11 are used to store return values. */
1607 cris_store_return_value (struct type
*type
, struct regcache
*regcache
,
1608 const gdb_byte
*valbuf
)
1610 struct gdbarch
*gdbarch
= regcache
->arch ();
1611 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1613 int len
= TYPE_LENGTH (type
);
1617 /* Put the return value in R10. */
1618 val
= extract_unsigned_integer (valbuf
, len
, byte_order
);
1619 regcache_cooked_write_unsigned (regcache
, ARG1_REGNUM
, val
);
1623 /* Put the return value in R10 and R11. */
1624 val
= extract_unsigned_integer (valbuf
, 4, byte_order
);
1625 regcache_cooked_write_unsigned (regcache
, ARG1_REGNUM
, val
);
1626 val
= extract_unsigned_integer (valbuf
+ 4, len
- 4, byte_order
);
1627 regcache_cooked_write_unsigned (regcache
, ARG2_REGNUM
, val
);
1630 error (_("cris_store_return_value: type length too large."));
1633 /* Return the name of register regno as a string. Return NULL for an
1634 invalid or unimplemented register. */
1637 cris_special_register_name (struct gdbarch
*gdbarch
, int regno
)
1642 /* Special register (R16 - R31). cris_spec_regs is zero-based.
1643 Adjust regno accordingly. */
1644 spec_regno
= regno
- NUM_GENREGS
;
1646 /* Assume nothing about the layout of the cris_spec_regs struct
1648 for (i
= 0; cris_spec_regs
[i
].name
!= NULL
; i
++)
1650 if (cris_spec_regs
[i
].number
== spec_regno
1651 && cris_spec_reg_applicable (gdbarch
, cris_spec_regs
[i
]))
1652 /* Go with the first applicable register. */
1653 return cris_spec_regs
[i
].name
;
1655 /* Special register not applicable to this CRIS version. */
1660 cris_register_name (struct gdbarch
*gdbarch
, int regno
)
1662 static const char *cris_genreg_names
[] =
1663 { "r0", "r1", "r2", "r3", \
1664 "r4", "r5", "r6", "r7", \
1665 "r8", "r9", "r10", "r11", \
1666 "r12", "r13", "sp", "pc" };
1668 if (regno
>= 0 && regno
< NUM_GENREGS
)
1670 /* General register. */
1671 return cris_genreg_names
[regno
];
1673 else if (regno
>= NUM_GENREGS
&& regno
< gdbarch_num_regs (gdbarch
))
1675 return cris_special_register_name (gdbarch
, regno
);
1679 /* Invalid register. */
1685 crisv32_register_name (struct gdbarch
*gdbarch
, int regno
)
1687 static const char *crisv32_genreg_names
[] =
1688 { "r0", "r1", "r2", "r3", \
1689 "r4", "r5", "r6", "r7", \
1690 "r8", "r9", "r10", "r11", \
1691 "r12", "r13", "sp", "acr"
1694 static const char *crisv32_sreg_names
[] =
1695 { "s0", "s1", "s2", "s3", \
1696 "s4", "s5", "s6", "s7", \
1697 "s8", "s9", "s10", "s11", \
1698 "s12", "s13", "s14", "s15"
1701 if (regno
>= 0 && regno
< NUM_GENREGS
)
1703 /* General register. */
1704 return crisv32_genreg_names
[regno
];
1706 else if (regno
>= NUM_GENREGS
&& regno
< (NUM_GENREGS
+ NUM_SPECREGS
))
1708 return cris_special_register_name (gdbarch
, regno
);
1710 else if (regno
== gdbarch_pc_regnum (gdbarch
))
1714 else if (regno
>= S0_REGNUM
&& regno
<= S15_REGNUM
)
1716 return crisv32_sreg_names
[regno
- S0_REGNUM
];
1720 /* Invalid register. */
1725 /* Convert DWARF register number REG to the appropriate register
1726 number used by GDB. */
1729 cris_dwarf2_reg_to_regnum (struct gdbarch
*gdbarch
, int reg
)
1731 /* We need to re-map a couple of registers (SRP is 16 in Dwarf-2 register
1732 numbering, MOF is 18).
1733 Adapted from gcc/config/cris/cris.h. */
1734 static int cris_dwarf_regmap
[] = {
1746 if (reg
>= 0 && reg
< ARRAY_SIZE (cris_dwarf_regmap
))
1747 regnum
= cris_dwarf_regmap
[reg
];
1752 /* DWARF-2 frame support. */
1755 cris_dwarf2_frame_init_reg (struct gdbarch
*gdbarch
, int regnum
,
1756 struct dwarf2_frame_state_reg
*reg
,
1757 struct frame_info
*this_frame
)
1759 /* The return address column. */
1760 if (regnum
== gdbarch_pc_regnum (gdbarch
))
1761 reg
->how
= DWARF2_FRAME_REG_RA
;
1763 /* The call frame address. */
1764 else if (regnum
== gdbarch_sp_regnum (gdbarch
))
1765 reg
->how
= DWARF2_FRAME_REG_CFA
;
1768 /* Extract from an array regbuf containing the raw register state a function
1769 return value of type type, and copy that, in virtual format, into
1772 /* In the CRIS ABI, R10 and R11 are used to store return values. */
1775 cris_extract_return_value (struct type
*type
, struct regcache
*regcache
,
1778 struct gdbarch
*gdbarch
= regcache
->arch ();
1779 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1781 int len
= TYPE_LENGTH (type
);
1785 /* Get the return value from R10. */
1786 regcache_cooked_read_unsigned (regcache
, ARG1_REGNUM
, &val
);
1787 store_unsigned_integer (valbuf
, len
, byte_order
, val
);
1791 /* Get the return value from R10 and R11. */
1792 regcache_cooked_read_unsigned (regcache
, ARG1_REGNUM
, &val
);
1793 store_unsigned_integer (valbuf
, 4, byte_order
, val
);
1794 regcache_cooked_read_unsigned (regcache
, ARG2_REGNUM
, &val
);
1795 store_unsigned_integer (valbuf
+ 4, len
- 4, byte_order
, val
);
1798 error (_("cris_extract_return_value: type length too large"));
1801 /* Handle the CRIS return value convention. */
1803 static enum return_value_convention
1804 cris_return_value (struct gdbarch
*gdbarch
, struct value
*function
,
1805 struct type
*type
, struct regcache
*regcache
,
1806 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
1808 if (type
->code () == TYPE_CODE_STRUCT
1809 || type
->code () == TYPE_CODE_UNION
1810 || TYPE_LENGTH (type
) > 8)
1811 /* Structs, unions, and anything larger than 8 bytes (2 registers)
1812 goes on the stack. */
1813 return RETURN_VALUE_STRUCT_CONVENTION
;
1816 cris_extract_return_value (type
, regcache
, readbuf
);
1818 cris_store_return_value (type
, regcache
, writebuf
);
1820 return RETURN_VALUE_REGISTER_CONVENTION
;
1823 /* Calculates a value that measures how good inst_args constraints an
1824 instruction. It stems from cris_constraint, found in cris-dis.c. */
1827 constraint (unsigned int insn
, const char *inst_args
,
1828 inst_env_type
*inst_env
)
1833 const gdb_byte
*s
= (const gdb_byte
*) inst_args
;
1839 if ((insn
& 0x30) == 0x30)
1844 /* A prefix operand. */
1845 if (inst_env
->prefix_found
)
1851 /* A "push" prefix. (This check was REMOVED by san 970921.) Check for
1852 valid "push" size. In case of special register, it may be != 4. */
1853 if (inst_env
->prefix_found
)
1859 retval
= (((insn
>> 0xC) & 0xF) == (insn
& 0xF));
1867 tmp
= (insn
>> 0xC) & 0xF;
1869 for (i
= 0; cris_spec_regs
[i
].name
!= NULL
; i
++)
1871 /* Since we match four bits, we will give a value of
1872 4 - 1 = 3 in a match. If there is a corresponding
1873 exact match of a special register in another pattern, it
1874 will get a value of 4, which will be higher. This should
1875 be correct in that an exact pattern would match better that
1877 Note that there is a reason for not returning zero; the
1878 pattern for "clear" is partly matched in the bit-pattern
1879 (the two lower bits must be zero), while the bit-pattern
1880 for a move from a special register is matched in the
1881 register constraint.
1882 This also means we will will have a race condition if
1883 there is a partly match in three bits in the bit pattern. */
1884 if (tmp
== cris_spec_regs
[i
].number
)
1891 if (cris_spec_regs
[i
].name
== NULL
)
1898 /* Returns the number of bits set in the variable value. */
1901 number_of_bits (unsigned int value
)
1903 int number_of_bits
= 0;
1907 number_of_bits
+= 1;
1908 value
&= (value
- 1);
1910 return number_of_bits
;
1913 /* Finds the address that should contain the single step breakpoint(s).
1914 It stems from code in cris-dis.c. */
1917 find_cris_op (unsigned short insn
, inst_env_type
*inst_env
)
1920 int max_level_of_match
= -1;
1921 int max_matched
= -1;
1924 for (i
= 0; cris_opcodes
[i
].name
!= NULL
; i
++)
1926 if (((cris_opcodes
[i
].match
& insn
) == cris_opcodes
[i
].match
)
1927 && ((cris_opcodes
[i
].lose
& insn
) == 0)
1928 /* Only CRISv10 instructions, please. */
1929 && (cris_opcodes
[i
].applicable_version
!= cris_ver_v32p
))
1931 level_of_match
= constraint (insn
, cris_opcodes
[i
].args
, inst_env
);
1932 if (level_of_match
>= 0)
1935 number_of_bits (cris_opcodes
[i
].match
| cris_opcodes
[i
].lose
);
1936 if (level_of_match
> max_level_of_match
)
1939 max_level_of_match
= level_of_match
;
1940 if (level_of_match
== 16)
1942 /* All bits matched, cannot find better. */
1952 /* Attempts to find single-step breakpoints. Returns -1 on failure which is
1953 actually an internal error. */
1956 find_step_target (struct regcache
*regcache
, inst_env_type
*inst_env
)
1960 unsigned short insn
;
1961 struct gdbarch
*gdbarch
= regcache
->arch ();
1962 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1964 /* Create a local register image and set the initial state. */
1965 for (i
= 0; i
< NUM_GENREGS
; i
++)
1968 (unsigned long) regcache_raw_get_unsigned (regcache
, i
);
1970 offset
= NUM_GENREGS
;
1971 for (i
= 0; i
< NUM_SPECREGS
; i
++)
1974 (unsigned long) regcache_raw_get_unsigned (regcache
, offset
+ i
);
1976 inst_env
->branch_found
= 0;
1977 inst_env
->slot_needed
= 0;
1978 inst_env
->delay_slot_pc_active
= 0;
1979 inst_env
->prefix_found
= 0;
1980 inst_env
->invalid
= 0;
1981 inst_env
->xflag_found
= 0;
1982 inst_env
->disable_interrupt
= 0;
1983 inst_env
->byte_order
= byte_order
;
1985 /* Look for a step target. */
1988 /* Read an instruction from the client. */
1989 insn
= read_memory_unsigned_integer
1990 (inst_env
->reg
[gdbarch_pc_regnum (gdbarch
)], 2, byte_order
);
1992 /* If the instruction is not in a delay slot the new content of the
1993 PC is [PC] + 2. If the instruction is in a delay slot it is not
1994 that simple. Since a instruction in a delay slot cannot change
1995 the content of the PC, it does not matter what value PC will have.
1996 Just make sure it is a valid instruction. */
1997 if (!inst_env
->delay_slot_pc_active
)
1999 inst_env
->reg
[gdbarch_pc_regnum (gdbarch
)] += 2;
2003 inst_env
->delay_slot_pc_active
= 0;
2004 inst_env
->reg
[gdbarch_pc_regnum (gdbarch
)]
2005 = inst_env
->delay_slot_pc
;
2007 /* Analyse the present instruction. */
2008 i
= find_cris_op (insn
, inst_env
);
2011 inst_env
->invalid
= 1;
2015 cris_gdb_func (gdbarch
, cris_opcodes
[i
].op
, insn
, inst_env
);
2017 } while (!inst_env
->invalid
2018 && (inst_env
->prefix_found
|| inst_env
->xflag_found
2019 || inst_env
->slot_needed
));
2023 /* There is no hardware single-step support. The function find_step_target
2024 digs through the opcodes in order to find all possible targets.
2025 Either one ordinary target or two targets for branches may be found. */
2027 static std::vector
<CORE_ADDR
>
2028 cris_software_single_step (struct regcache
*regcache
)
2030 struct gdbarch
*gdbarch
= regcache
->arch ();
2031 inst_env_type inst_env
;
2032 std::vector
<CORE_ADDR
> next_pcs
;
2034 /* Analyse the present instruction environment and insert
2036 int status
= find_step_target (regcache
, &inst_env
);
2039 /* Could not find a target. Things are likely to go downhill
2041 warning (_("CRIS software single step could not find a step target."));
2045 /* Insert at most two breakpoints. One for the next PC content
2046 and possibly another one for a branch, jump, etc. */
2048 = (CORE_ADDR
) inst_env
.reg
[gdbarch_pc_regnum (gdbarch
)];
2050 next_pcs
.push_back (next_pc
);
2051 if (inst_env
.branch_found
2052 && (CORE_ADDR
) inst_env
.branch_break_address
!= next_pc
)
2054 CORE_ADDR branch_target_address
2055 = (CORE_ADDR
) inst_env
.branch_break_address
;
2057 next_pcs
.push_back (branch_target_address
);
2064 /* Calculates the prefix value for quick offset addressing mode. */
2067 quick_mode_bdap_prefix (unsigned short inst
, inst_env_type
*inst_env
)
2069 /* It's invalid to be in a delay slot. You can't have a prefix to this
2070 instruction (not 100% sure). */
2071 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2073 inst_env
->invalid
= 1;
2077 inst_env
->prefix_value
= inst_env
->reg
[cris_get_operand2 (inst
)];
2078 inst_env
->prefix_value
+= cris_get_bdap_quick_offset (inst
);
2080 /* A prefix doesn't change the xflag_found. But the rest of the flags
2082 inst_env
->slot_needed
= 0;
2083 inst_env
->prefix_found
= 1;
2086 /* Updates the autoincrement register. The size of the increment is derived
2087 from the size of the operation. The PC is always kept aligned on even
2091 process_autoincrement (int size
, unsigned short inst
, inst_env_type
*inst_env
)
2093 if (size
== INST_BYTE_SIZE
)
2095 inst_env
->reg
[cris_get_operand1 (inst
)] += 1;
2097 /* The PC must be word aligned, so increase the PC with one
2098 word even if the size is byte. */
2099 if (cris_get_operand1 (inst
) == REG_PC
)
2101 inst_env
->reg
[REG_PC
] += 1;
2104 else if (size
== INST_WORD_SIZE
)
2106 inst_env
->reg
[cris_get_operand1 (inst
)] += 2;
2108 else if (size
== INST_DWORD_SIZE
)
2110 inst_env
->reg
[cris_get_operand1 (inst
)] += 4;
2115 inst_env
->invalid
= 1;
2119 /* Just a forward declaration. */
2121 static unsigned long get_data_from_address (unsigned short *inst
,
2123 enum bfd_endian byte_order
);
2125 /* Calculates the prefix value for the general case of offset addressing
2129 bdap_prefix (unsigned short inst
, inst_env_type
*inst_env
)
2131 /* It's invalid to be in a delay slot. */
2132 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2134 inst_env
->invalid
= 1;
2138 /* The calculation of prefix_value used to be after process_autoincrement,
2139 but that fails for an instruction such as jsr [$r0+12] which is encoded
2140 as 5f0d 0c00 30b9 when compiled with -fpic. Since PC is operand1 it
2141 mustn't be incremented until we have read it and what it points at. */
2142 inst_env
->prefix_value
= inst_env
->reg
[cris_get_operand2 (inst
)];
2144 /* The offset is an indirection of the contents of the operand1 register. */
2145 inst_env
->prefix_value
+=
2146 get_data_from_address (&inst
, inst_env
->reg
[cris_get_operand1 (inst
)],
2147 inst_env
->byte_order
);
2149 if (cris_get_mode (inst
) == AUTOINC_MODE
)
2151 process_autoincrement (cris_get_size (inst
), inst
, inst_env
);
2154 /* A prefix doesn't change the xflag_found. But the rest of the flags
2156 inst_env
->slot_needed
= 0;
2157 inst_env
->prefix_found
= 1;
2160 /* Calculates the prefix value for the index addressing mode. */
2163 biap_prefix (unsigned short inst
, inst_env_type
*inst_env
)
2165 /* It's invalid to be in a delay slot. I can't see that it's possible to
2166 have a prefix to this instruction. So I will treat this as invalid. */
2167 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2169 inst_env
->invalid
= 1;
2173 inst_env
->prefix_value
= inst_env
->reg
[cris_get_operand1 (inst
)];
2175 /* The offset is the operand2 value shifted the size of the instruction
2177 inst_env
->prefix_value
+=
2178 inst_env
->reg
[cris_get_operand2 (inst
)] << cris_get_size (inst
);
2180 /* If the PC is operand1 (base) the address used is the address after
2181 the main instruction, i.e. address + 2 (the PC is already compensated
2182 for the prefix operation). */
2183 if (cris_get_operand1 (inst
) == REG_PC
)
2185 inst_env
->prefix_value
+= 2;
2188 /* A prefix doesn't change the xflag_found. But the rest of the flags
2190 inst_env
->slot_needed
= 0;
2191 inst_env
->xflag_found
= 0;
2192 inst_env
->prefix_found
= 1;
2195 /* Calculates the prefix value for the double indirect addressing mode. */
2198 dip_prefix (unsigned short inst
, inst_env_type
*inst_env
)
2203 /* It's invalid to be in a delay slot. */
2204 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2206 inst_env
->invalid
= 1;
2210 /* The prefix value is one dereference of the contents of the operand1
2212 address
= (CORE_ADDR
) inst_env
->reg
[cris_get_operand1 (inst
)];
2213 inst_env
->prefix_value
2214 = read_memory_unsigned_integer (address
, 4, inst_env
->byte_order
);
2216 /* Check if the mode is autoincrement. */
2217 if (cris_get_mode (inst
) == AUTOINC_MODE
)
2219 inst_env
->reg
[cris_get_operand1 (inst
)] += 4;
2222 /* A prefix doesn't change the xflag_found. But the rest of the flags
2224 inst_env
->slot_needed
= 0;
2225 inst_env
->xflag_found
= 0;
2226 inst_env
->prefix_found
= 1;
2229 /* Finds the destination for a branch with 8-bits offset. */
2232 eight_bit_offset_branch_op (unsigned short inst
, inst_env_type
*inst_env
)
2237 /* If we have a prefix or are in a delay slot it's bad. */
2238 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2240 inst_env
->invalid
= 1;
2244 /* We have a branch, find out where the branch will land. */
2245 offset
= cris_get_branch_short_offset (inst
);
2247 /* Check if the offset is signed. */
2248 if (offset
& BRANCH_SIGNED_SHORT_OFFSET_MASK
)
2253 /* The offset ends with the sign bit, set it to zero. The address
2254 should always be word aligned. */
2255 offset
&= ~BRANCH_SIGNED_SHORT_OFFSET_MASK
;
2257 inst_env
->branch_found
= 1;
2258 inst_env
->branch_break_address
= inst_env
->reg
[REG_PC
] + offset
;
2260 inst_env
->slot_needed
= 1;
2261 inst_env
->prefix_found
= 0;
2262 inst_env
->xflag_found
= 0;
2263 inst_env
->disable_interrupt
= 1;
2266 /* Finds the destination for a branch with 16-bits offset. */
2269 sixteen_bit_offset_branch_op (unsigned short inst
, inst_env_type
*inst_env
)
2273 /* If we have a prefix or is in a delay slot it's bad. */
2274 if (inst_env
->slot_needed
|| inst_env
->prefix_found
)
2276 inst_env
->invalid
= 1;
2280 /* We have a branch, find out the offset for the branch. */
2281 offset
= read_memory_integer (inst_env
->reg
[REG_PC
], 2,
2282 inst_env
->byte_order
);
2284 /* The instruction is one word longer than normal, so add one word
2286 inst_env
->reg
[REG_PC
] += 2;
2288 inst_env
->branch_found
= 1;
2289 inst_env
->branch_break_address
= inst_env
->reg
[REG_PC
] + offset
;
2292 inst_env
->slot_needed
= 1;
2293 inst_env
->prefix_found
= 0;
2294 inst_env
->xflag_found
= 0;
2295 inst_env
->disable_interrupt
= 1;
2298 /* Handles the ABS instruction. */
2301 abs_op (unsigned short inst
, inst_env_type
*inst_env
)
2306 /* ABS can't have a prefix, so it's bad if it does. */
2307 if (inst_env
->prefix_found
)
2309 inst_env
->invalid
= 1;
2313 /* Check if the operation affects the PC. */
2314 if (cris_get_operand2 (inst
) == REG_PC
)
2317 /* It's invalid to change to the PC if we are in a delay slot. */
2318 if (inst_env
->slot_needed
)
2320 inst_env
->invalid
= 1;
2324 value
= (long) inst_env
->reg
[REG_PC
];
2326 /* The value of abs (SIGNED_DWORD_MASK) is SIGNED_DWORD_MASK. */
2327 if (value
!= SIGNED_DWORD_MASK
)
2330 inst_env
->reg
[REG_PC
] = (long) value
;
2334 inst_env
->slot_needed
= 0;
2335 inst_env
->prefix_found
= 0;
2336 inst_env
->xflag_found
= 0;
2337 inst_env
->disable_interrupt
= 0;
2340 /* Handles the ADDI instruction. */
2343 addi_op (unsigned short inst
, inst_env_type
*inst_env
)
2345 /* It's invalid to have the PC as base register. And ADDI can't have
2347 if (inst_env
->prefix_found
|| (cris_get_operand1 (inst
) == REG_PC
))
2349 inst_env
->invalid
= 1;
2353 inst_env
->slot_needed
= 0;
2354 inst_env
->prefix_found
= 0;
2355 inst_env
->xflag_found
= 0;
2356 inst_env
->disable_interrupt
= 0;
2359 /* Handles the ASR instruction. */
2362 asr_op (unsigned short inst
, inst_env_type
*inst_env
)
2365 unsigned long value
;
2366 unsigned long signed_extend_mask
= 0;
2368 /* ASR can't have a prefix, so check that it doesn't. */
2369 if (inst_env
->prefix_found
)
2371 inst_env
->invalid
= 1;
2375 /* Check if the PC is the target register. */
2376 if (cris_get_operand2 (inst
) == REG_PC
)
2378 /* It's invalid to change the PC in a delay slot. */
2379 if (inst_env
->slot_needed
)
2381 inst_env
->invalid
= 1;
2384 /* Get the number of bits to shift. */
2386 = cris_get_asr_shift_steps (inst_env
->reg
[cris_get_operand1 (inst
)]);
2387 value
= inst_env
->reg
[REG_PC
];
2389 /* Find out how many bits the operation should apply to. */
2390 if (cris_get_size (inst
) == INST_BYTE_SIZE
)
2392 if (value
& SIGNED_BYTE_MASK
)
2394 signed_extend_mask
= 0xFF;
2395 signed_extend_mask
= signed_extend_mask
>> shift_steps
;
2396 signed_extend_mask
= ~signed_extend_mask
;
2398 value
= value
>> shift_steps
;
2399 value
|= signed_extend_mask
;
2401 inst_env
->reg
[REG_PC
] &= 0xFFFFFF00;
2402 inst_env
->reg
[REG_PC
] |= value
;
2404 else if (cris_get_size (inst
) == INST_WORD_SIZE
)
2406 if (value
& SIGNED_WORD_MASK
)
2408 signed_extend_mask
= 0xFFFF;
2409 signed_extend_mask
= signed_extend_mask
>> shift_steps
;
2410 signed_extend_mask
= ~signed_extend_mask
;
2412 value
= value
>> shift_steps
;
2413 value
|= signed_extend_mask
;
2415 inst_env
->reg
[REG_PC
] &= 0xFFFF0000;
2416 inst_env
->reg
[REG_PC
] |= value
;
2418 else if (cris_get_size (inst
) == INST_DWORD_SIZE
)
2420 if (value
& SIGNED_DWORD_MASK
)
2422 signed_extend_mask
= 0xFFFFFFFF;
2423 signed_extend_mask
= signed_extend_mask
>> shift_steps
;
2424 signed_extend_mask
= ~signed_extend_mask
;
2426 value
= value
>> shift_steps
;
2427 value
|= signed_extend_mask
;
2428 inst_env
->reg
[REG_PC
] = value
;
2431 inst_env
->slot_needed
= 0;
2432 inst_env
->prefix_found
= 0;
2433 inst_env
->xflag_found
= 0;
2434 inst_env
->disable_interrupt
= 0;
2437 /* Handles the ASRQ instruction. */
2440 asrq_op (unsigned short inst
, inst_env_type
*inst_env
)
2444 unsigned long value
;
2445 unsigned long signed_extend_mask
= 0;
2447 /* ASRQ can't have a prefix, so check that it doesn't. */
2448 if (inst_env
->prefix_found
)
2450 inst_env
->invalid
= 1;
2454 /* Check if the PC is the target register. */
2455 if (cris_get_operand2 (inst
) == REG_PC
)
2458 /* It's invalid to change the PC in a delay slot. */
2459 if (inst_env
->slot_needed
)
2461 inst_env
->invalid
= 1;
2464 /* The shift size is given as a 5 bit quick value, i.e. we don't
2465 want the sign bit of the quick value. */
2466 shift_steps
= cris_get_asr_shift_steps (inst
);
2467 value
= inst_env
->reg
[REG_PC
];
2468 if (value
& SIGNED_DWORD_MASK
)
2470 signed_extend_mask
= 0xFFFFFFFF;
2471 signed_extend_mask
= signed_extend_mask
>> shift_steps
;
2472 signed_extend_mask
= ~signed_extend_mask
;
2474 value
= value
>> shift_steps
;
2475 value
|= signed_extend_mask
;
2476 inst_env
->reg
[REG_PC
] = value
;
2478 inst_env
->slot_needed
= 0;
2479 inst_env
->prefix_found
= 0;
2480 inst_env
->xflag_found
= 0;
2481 inst_env
->disable_interrupt
= 0;
2484 /* Handles the AX, EI and SETF instruction. */
2487 ax_ei_setf_op (unsigned short inst
, inst_env_type
*inst_env
)
2489 if (inst_env
->prefix_found
)
2491 inst_env
->invalid
= 1;
2494 /* Check if the instruction is setting the X flag. */
2495 if (cris_is_xflag_bit_on (inst
))
2497 inst_env
->xflag_found
= 1;
2501 inst_env
->xflag_found
= 0;
2503 inst_env
->slot_needed
= 0;
2504 inst_env
->prefix_found
= 0;
2505 inst_env
->disable_interrupt
= 1;
2508 /* Checks if the instruction is in assign mode. If so, it updates the assign
2509 register. Note that check_assign assumes that the caller has checked that
2510 there is a prefix to this instruction. The mode check depends on this. */
2513 check_assign (unsigned short inst
, inst_env_type
*inst_env
)
2515 /* Check if it's an assign addressing mode. */
2516 if (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
)
2518 /* Assign the prefix value to operand 1. */
2519 inst_env
->reg
[cris_get_operand1 (inst
)] = inst_env
->prefix_value
;
2523 /* Handles the 2-operand BOUND instruction. */
2526 two_operand_bound_op (unsigned short inst
, inst_env_type
*inst_env
)
2528 /* It's invalid to have the PC as the index operand. */
2529 if (cris_get_operand2 (inst
) == REG_PC
)
2531 inst_env
->invalid
= 1;
2534 /* Check if we have a prefix. */
2535 if (inst_env
->prefix_found
)
2537 check_assign (inst
, inst_env
);
2539 /* Check if this is an autoincrement mode. */
2540 else if (cris_get_mode (inst
) == AUTOINC_MODE
)
2542 /* It's invalid to change the PC in a delay slot. */
2543 if (inst_env
->slot_needed
)
2545 inst_env
->invalid
= 1;
2548 process_autoincrement (cris_get_size (inst
), inst
, inst_env
);
2550 inst_env
->slot_needed
= 0;
2551 inst_env
->prefix_found
= 0;
2552 inst_env
->xflag_found
= 0;
2553 inst_env
->disable_interrupt
= 0;
2556 /* Handles the 3-operand BOUND instruction. */
2559 three_operand_bound_op (unsigned short inst
, inst_env_type
*inst_env
)
2561 /* It's an error if we haven't got a prefix. And it's also an error
2562 if the PC is the destination register. */
2563 if ((!inst_env
->prefix_found
) || (cris_get_operand1 (inst
) == REG_PC
))
2565 inst_env
->invalid
= 1;
2568 inst_env
->slot_needed
= 0;
2569 inst_env
->prefix_found
= 0;
2570 inst_env
->xflag_found
= 0;
2571 inst_env
->disable_interrupt
= 0;
2574 /* Clears the status flags in inst_env. */
2577 btst_nop_op (unsigned short inst
, inst_env_type
*inst_env
)
2579 /* It's an error if we have got a prefix. */
2580 if (inst_env
->prefix_found
)
2582 inst_env
->invalid
= 1;
2586 inst_env
->slot_needed
= 0;
2587 inst_env
->prefix_found
= 0;
2588 inst_env
->xflag_found
= 0;
2589 inst_env
->disable_interrupt
= 0;
2592 /* Clears the status flags in inst_env. */
2595 clearf_di_op (unsigned short inst
, inst_env_type
*inst_env
)
2597 /* It's an error if we have got a prefix. */
2598 if (inst_env
->prefix_found
)
2600 inst_env
->invalid
= 1;
2604 inst_env
->slot_needed
= 0;
2605 inst_env
->prefix_found
= 0;
2606 inst_env
->xflag_found
= 0;
2607 inst_env
->disable_interrupt
= 1;
2610 /* Handles the CLEAR instruction if it's in register mode. */
2613 reg_mode_clear_op (unsigned short inst
, inst_env_type
*inst_env
)
2615 /* Check if the target is the PC. */
2616 if (cris_get_operand2 (inst
) == REG_PC
)
2618 /* The instruction will clear the instruction's size bits. */
2619 int clear_size
= cris_get_clear_size (inst
);
2620 if (clear_size
== INST_BYTE_SIZE
)
2622 inst_env
->delay_slot_pc
= inst_env
->reg
[REG_PC
] & 0xFFFFFF00;
2624 if (clear_size
== INST_WORD_SIZE
)
2626 inst_env
->delay_slot_pc
= inst_env
->reg
[REG_PC
] & 0xFFFF0000;
2628 if (clear_size
== INST_DWORD_SIZE
)
2630 inst_env
->delay_slot_pc
= 0x0;
2632 /* The jump will be delayed with one delay slot. So we need a delay
2634 inst_env
->slot_needed
= 1;
2635 inst_env
->delay_slot_pc_active
= 1;
2639 /* The PC will not change => no delay slot. */
2640 inst_env
->slot_needed
= 0;
2642 inst_env
->prefix_found
= 0;
2643 inst_env
->xflag_found
= 0;
2644 inst_env
->disable_interrupt
= 0;
2647 /* Handles the TEST instruction if it's in register mode. */
2650 reg_mode_test_op (unsigned short inst
, inst_env_type
*inst_env
)
2652 /* It's an error if we have got a prefix. */
2653 if (inst_env
->prefix_found
)
2655 inst_env
->invalid
= 1;
2658 inst_env
->slot_needed
= 0;
2659 inst_env
->prefix_found
= 0;
2660 inst_env
->xflag_found
= 0;
2661 inst_env
->disable_interrupt
= 0;
2665 /* Handles the CLEAR and TEST instruction if the instruction isn't
2666 in register mode. */
2669 none_reg_mode_clear_test_op (unsigned short inst
, inst_env_type
*inst_env
)
2671 /* Check if we are in a prefix mode. */
2672 if (inst_env
->prefix_found
)
2674 /* The only way the PC can change is if this instruction is in
2675 assign addressing mode. */
2676 check_assign (inst
, inst_env
);
2678 /* Indirect mode can't change the PC so just check if the mode is
2680 else if (cris_get_mode (inst
) == AUTOINC_MODE
)
2682 process_autoincrement (cris_get_size (inst
), inst
, inst_env
);
2684 inst_env
->slot_needed
= 0;
2685 inst_env
->prefix_found
= 0;
2686 inst_env
->xflag_found
= 0;
2687 inst_env
->disable_interrupt
= 0;
2690 /* Checks that the PC isn't the destination register or the instructions has
2694 dstep_logshift_mstep_neg_not_op (unsigned short inst
, inst_env_type
*inst_env
)
2696 /* It's invalid to have the PC as the destination. The instruction can't
2698 if ((cris_get_operand2 (inst
) == REG_PC
) || inst_env
->prefix_found
)
2700 inst_env
->invalid
= 1;
2704 inst_env
->slot_needed
= 0;
2705 inst_env
->prefix_found
= 0;
2706 inst_env
->xflag_found
= 0;
2707 inst_env
->disable_interrupt
= 0;
2710 /* Checks that the instruction doesn't have a prefix. */
2713 break_op (unsigned short inst
, inst_env_type
*inst_env
)
2715 /* The instruction can't have a prefix. */
2716 if (inst_env
->prefix_found
)
2718 inst_env
->invalid
= 1;
2722 inst_env
->slot_needed
= 0;
2723 inst_env
->prefix_found
= 0;
2724 inst_env
->xflag_found
= 0;
2725 inst_env
->disable_interrupt
= 1;
2728 /* Checks that the PC isn't the destination register and that the instruction
2729 doesn't have a prefix. */
2732 scc_op (unsigned short inst
, inst_env_type
*inst_env
)
2734 /* It's invalid to have the PC as the destination. The instruction can't
2736 if ((cris_get_operand2 (inst
) == REG_PC
) || inst_env
->prefix_found
)
2738 inst_env
->invalid
= 1;
2742 inst_env
->slot_needed
= 0;
2743 inst_env
->prefix_found
= 0;
2744 inst_env
->xflag_found
= 0;
2745 inst_env
->disable_interrupt
= 1;
2748 /* Handles the register mode JUMP instruction. */
2751 reg_mode_jump_op (unsigned short inst
, inst_env_type
*inst_env
)
2753 /* It's invalid to do a JUMP in a delay slot. The mode is register, so
2754 you can't have a prefix. */
2755 if ((inst_env
->slot_needed
) || (inst_env
->prefix_found
))
2757 inst_env
->invalid
= 1;
2761 /* Just change the PC. */
2762 inst_env
->reg
[REG_PC
] = inst_env
->reg
[cris_get_operand1 (inst
)];
2763 inst_env
->slot_needed
= 0;
2764 inst_env
->prefix_found
= 0;
2765 inst_env
->xflag_found
= 0;
2766 inst_env
->disable_interrupt
= 1;
2769 /* Handles the JUMP instruction for all modes except register. */
2772 none_reg_mode_jump_op (unsigned short inst
, inst_env_type
*inst_env
)
2774 unsigned long newpc
;
2777 /* It's invalid to do a JUMP in a delay slot. */
2778 if (inst_env
->slot_needed
)
2780 inst_env
->invalid
= 1;
2784 /* Check if we have a prefix. */
2785 if (inst_env
->prefix_found
)
2787 check_assign (inst
, inst_env
);
2789 /* Get the new value for the PC. */
2791 read_memory_unsigned_integer ((CORE_ADDR
) inst_env
->prefix_value
,
2792 4, inst_env
->byte_order
);
2796 /* Get the new value for the PC. */
2797 address
= (CORE_ADDR
) inst_env
->reg
[cris_get_operand1 (inst
)];
2798 newpc
= read_memory_unsigned_integer (address
,
2799 4, inst_env
->byte_order
);
2801 /* Check if we should increment a register. */
2802 if (cris_get_mode (inst
) == AUTOINC_MODE
)
2804 inst_env
->reg
[cris_get_operand1 (inst
)] += 4;
2807 inst_env
->reg
[REG_PC
] = newpc
;
2809 inst_env
->slot_needed
= 0;
2810 inst_env
->prefix_found
= 0;
2811 inst_env
->xflag_found
= 0;
2812 inst_env
->disable_interrupt
= 1;
2815 /* Handles moves to special registers (aka P-register) for all modes. */
2818 move_to_preg_op (struct gdbarch
*gdbarch
, unsigned short inst
,
2819 inst_env_type
*inst_env
)
2821 if (inst_env
->prefix_found
)
2823 /* The instruction has a prefix that means we are only interested if
2824 the instruction is in assign mode. */
2825 if (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
)
2827 /* The prefix handles the problem if we are in a delay slot. */
2828 if (cris_get_operand1 (inst
) == REG_PC
)
2830 /* Just take care of the assign. */
2831 check_assign (inst
, inst_env
);
2835 else if (cris_get_mode (inst
) == AUTOINC_MODE
)
2837 /* The instruction doesn't have a prefix, the only case left that we
2838 are interested in is the autoincrement mode. */
2839 if (cris_get_operand1 (inst
) == REG_PC
)
2841 /* If the PC is to be incremented it's invalid to be in a
2843 if (inst_env
->slot_needed
)
2845 inst_env
->invalid
= 1;
2849 /* The increment depends on the size of the special register. */
2850 if (cris_register_size (gdbarch
, cris_get_operand2 (inst
)) == 1)
2852 process_autoincrement (INST_BYTE_SIZE
, inst
, inst_env
);
2854 else if (cris_register_size (gdbarch
, cris_get_operand2 (inst
)) == 2)
2856 process_autoincrement (INST_WORD_SIZE
, inst
, inst_env
);
2860 process_autoincrement (INST_DWORD_SIZE
, inst
, inst_env
);
2864 inst_env
->slot_needed
= 0;
2865 inst_env
->prefix_found
= 0;
2866 inst_env
->xflag_found
= 0;
2867 inst_env
->disable_interrupt
= 1;
2870 /* Handles moves from special registers (aka P-register) for all modes
2874 none_reg_mode_move_from_preg_op (struct gdbarch
*gdbarch
, unsigned short inst
,
2875 inst_env_type
*inst_env
)
2877 if (inst_env
->prefix_found
)
2879 /* The instruction has a prefix that means we are only interested if
2880 the instruction is in assign mode. */
2881 if (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
)
2883 /* The prefix handles the problem if we are in a delay slot. */
2884 if (cris_get_operand1 (inst
) == REG_PC
)
2886 /* Just take care of the assign. */
2887 check_assign (inst
, inst_env
);
2891 /* The instruction doesn't have a prefix, the only case left that we
2892 are interested in is the autoincrement mode. */
2893 else if (cris_get_mode (inst
) == AUTOINC_MODE
)
2895 if (cris_get_operand1 (inst
) == REG_PC
)
2897 /* If the PC is to be incremented it's invalid to be in a
2899 if (inst_env
->slot_needed
)
2901 inst_env
->invalid
= 1;
2905 /* The increment depends on the size of the special register. */
2906 if (cris_register_size (gdbarch
, cris_get_operand2 (inst
)) == 1)
2908 process_autoincrement (INST_BYTE_SIZE
, inst
, inst_env
);
2910 else if (cris_register_size (gdbarch
, cris_get_operand2 (inst
)) == 2)
2912 process_autoincrement (INST_WORD_SIZE
, inst
, inst_env
);
2916 process_autoincrement (INST_DWORD_SIZE
, inst
, inst_env
);
2920 inst_env
->slot_needed
= 0;
2921 inst_env
->prefix_found
= 0;
2922 inst_env
->xflag_found
= 0;
2923 inst_env
->disable_interrupt
= 1;
2926 /* Handles moves from special registers (aka P-register) when the mode
2930 reg_mode_move_from_preg_op (unsigned short inst
, inst_env_type
*inst_env
)
2932 /* Register mode move from special register can't have a prefix. */
2933 if (inst_env
->prefix_found
)
2935 inst_env
->invalid
= 1;
2939 if (cris_get_operand1 (inst
) == REG_PC
)
2941 /* It's invalid to change the PC in a delay slot. */
2942 if (inst_env
->slot_needed
)
2944 inst_env
->invalid
= 1;
2947 /* The destination is the PC, the jump will have a delay slot. */
2948 inst_env
->delay_slot_pc
= inst_env
->preg
[cris_get_operand2 (inst
)];
2949 inst_env
->slot_needed
= 1;
2950 inst_env
->delay_slot_pc_active
= 1;
2954 /* If the destination isn't PC, there will be no jump. */
2955 inst_env
->slot_needed
= 0;
2957 inst_env
->prefix_found
= 0;
2958 inst_env
->xflag_found
= 0;
2959 inst_env
->disable_interrupt
= 1;
2962 /* Handles the MOVEM from memory to general register instruction. */
2965 move_mem_to_reg_movem_op (unsigned short inst
, inst_env_type
*inst_env
)
2967 if (inst_env
->prefix_found
)
2969 /* The prefix handles the problem if we are in a delay slot. Is the
2970 MOVEM instruction going to change the PC? */
2971 if (cris_get_operand2 (inst
) >= REG_PC
)
2973 inst_env
->reg
[REG_PC
] =
2974 read_memory_unsigned_integer (inst_env
->prefix_value
,
2975 4, inst_env
->byte_order
);
2977 /* The assign value is the value after the increment. Normally, the
2978 assign value is the value before the increment. */
2979 if ((cris_get_operand1 (inst
) == REG_PC
)
2980 && (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
))
2982 inst_env
->reg
[REG_PC
] = inst_env
->prefix_value
;
2983 inst_env
->reg
[REG_PC
] += 4 * (cris_get_operand2 (inst
) + 1);
2988 /* Is the MOVEM instruction going to change the PC? */
2989 if (cris_get_operand2 (inst
) == REG_PC
)
2991 /* It's invalid to change the PC in a delay slot. */
2992 if (inst_env
->slot_needed
)
2994 inst_env
->invalid
= 1;
2997 inst_env
->reg
[REG_PC
] =
2998 read_memory_unsigned_integer (inst_env
->reg
[cris_get_operand1 (inst
)],
2999 4, inst_env
->byte_order
);
3001 /* The increment is not depending on the size, instead it's depending
3002 on the number of registers loaded from memory. */
3003 if ((cris_get_operand1 (inst
) == REG_PC
)
3004 && (cris_get_mode (inst
) == AUTOINC_MODE
))
3006 /* It's invalid to change the PC in a delay slot. */
3007 if (inst_env
->slot_needed
)
3009 inst_env
->invalid
= 1;
3012 inst_env
->reg
[REG_PC
] += 4 * (cris_get_operand2 (inst
) + 1);
3015 inst_env
->slot_needed
= 0;
3016 inst_env
->prefix_found
= 0;
3017 inst_env
->xflag_found
= 0;
3018 inst_env
->disable_interrupt
= 0;
3021 /* Handles the MOVEM to memory from general register instruction. */
3024 move_reg_to_mem_movem_op (unsigned short inst
, inst_env_type
*inst_env
)
3026 if (inst_env
->prefix_found
)
3028 /* The assign value is the value after the increment. Normally, the
3029 assign value is the value before the increment. */
3030 if ((cris_get_operand1 (inst
) == REG_PC
)
3031 && (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
))
3033 /* The prefix handles the problem if we are in a delay slot. */
3034 inst_env
->reg
[REG_PC
] = inst_env
->prefix_value
;
3035 inst_env
->reg
[REG_PC
] += 4 * (cris_get_operand2 (inst
) + 1);
3040 /* The increment is not depending on the size, instead it's depending
3041 on the number of registers loaded to memory. */
3042 if ((cris_get_operand1 (inst
) == REG_PC
)
3043 && (cris_get_mode (inst
) == AUTOINC_MODE
))
3045 /* It's invalid to change the PC in a delay slot. */
3046 if (inst_env
->slot_needed
)
3048 inst_env
->invalid
= 1;
3051 inst_env
->reg
[REG_PC
] += 4 * (cris_get_operand2 (inst
) + 1);
3054 inst_env
->slot_needed
= 0;
3055 inst_env
->prefix_found
= 0;
3056 inst_env
->xflag_found
= 0;
3057 inst_env
->disable_interrupt
= 0;
3060 /* Handles the instructions that's not yet implemented, by setting
3061 inst_env->invalid to true. */
3064 not_implemented_op (unsigned short inst
, inst_env_type
*inst_env
)
3066 inst_env
->invalid
= 1;
3069 /* Handles the XOR instruction. */
3072 xor_op (unsigned short inst
, inst_env_type
*inst_env
)
3074 /* XOR can't have a prefix. */
3075 if (inst_env
->prefix_found
)
3077 inst_env
->invalid
= 1;
3081 /* Check if the PC is the target. */
3082 if (cris_get_operand2 (inst
) == REG_PC
)
3084 /* It's invalid to change the PC in a delay slot. */
3085 if (inst_env
->slot_needed
)
3087 inst_env
->invalid
= 1;
3090 inst_env
->reg
[REG_PC
] ^= inst_env
->reg
[cris_get_operand1 (inst
)];
3092 inst_env
->slot_needed
= 0;
3093 inst_env
->prefix_found
= 0;
3094 inst_env
->xflag_found
= 0;
3095 inst_env
->disable_interrupt
= 0;
3098 /* Handles the MULS instruction. */
3101 muls_op (unsigned short inst
, inst_env_type
*inst_env
)
3103 /* MULS/U can't have a prefix. */
3104 if (inst_env
->prefix_found
)
3106 inst_env
->invalid
= 1;
3110 /* Consider it invalid if the PC is the target. */
3111 if (cris_get_operand2 (inst
) == REG_PC
)
3113 inst_env
->invalid
= 1;
3116 inst_env
->slot_needed
= 0;
3117 inst_env
->prefix_found
= 0;
3118 inst_env
->xflag_found
= 0;
3119 inst_env
->disable_interrupt
= 0;
3122 /* Handles the MULU instruction. */
3125 mulu_op (unsigned short inst
, inst_env_type
*inst_env
)
3127 /* MULS/U can't have a prefix. */
3128 if (inst_env
->prefix_found
)
3130 inst_env
->invalid
= 1;
3134 /* Consider it invalid if the PC is the target. */
3135 if (cris_get_operand2 (inst
) == REG_PC
)
3137 inst_env
->invalid
= 1;
3140 inst_env
->slot_needed
= 0;
3141 inst_env
->prefix_found
= 0;
3142 inst_env
->xflag_found
= 0;
3143 inst_env
->disable_interrupt
= 0;
3146 /* Calculate the result of the instruction for ADD, SUB, CMP AND, OR and MOVE.
3147 The MOVE instruction is the move from source to register. */
3150 add_sub_cmp_and_or_move_action (unsigned short inst
, inst_env_type
*inst_env
,
3151 unsigned long source1
, unsigned long source2
)
3153 unsigned long pc_mask
;
3154 unsigned long operation_mask
;
3156 /* Find out how many bits the operation should apply to. */
3157 if (cris_get_size (inst
) == INST_BYTE_SIZE
)
3159 pc_mask
= 0xFFFFFF00;
3160 operation_mask
= 0xFF;
3162 else if (cris_get_size (inst
) == INST_WORD_SIZE
)
3164 pc_mask
= 0xFFFF0000;
3165 operation_mask
= 0xFFFF;
3167 else if (cris_get_size (inst
) == INST_DWORD_SIZE
)
3170 operation_mask
= 0xFFFFFFFF;
3174 /* The size is out of range. */
3175 inst_env
->invalid
= 1;
3179 /* The instruction just works on uw_operation_mask bits. */
3180 source2
&= operation_mask
;
3181 source1
&= operation_mask
;
3183 /* Now calculate the result. The opcode's 3 first bits separates
3184 the different actions. */
3185 switch (cris_get_opcode (inst
) & 7)
3195 case 2: /* subtract */
3199 case 3: /* compare */
3211 inst_env
->invalid
= 1;
3217 /* Make sure that the result doesn't contain more than the instruction
3219 source2
&= operation_mask
;
3221 /* Calculate the new breakpoint address. */
3222 inst_env
->reg
[REG_PC
] &= pc_mask
;
3223 inst_env
->reg
[REG_PC
] |= source1
;
3227 /* Extends the value from either byte or word size to a dword. If the mode
3228 is zero extend then the value is extended with zero. If instead the mode
3229 is signed extend the sign bit of the value is taken into consideration. */
3231 static unsigned long
3232 do_sign_or_zero_extend (unsigned long value
, unsigned short *inst
)
3234 /* The size can be either byte or word, check which one it is.
3235 Don't check the highest bit, it's indicating if it's a zero
3237 if (cris_get_size (*inst
) & INST_WORD_SIZE
)
3242 /* Check if the instruction is signed extend. If so, check if value has
3244 if (cris_is_signed_extend_bit_on (*inst
) && (value
& SIGNED_WORD_MASK
))
3246 value
|= SIGNED_WORD_EXTEND_MASK
;
3254 /* Check if the instruction is signed extend. If so, check if value has
3256 if (cris_is_signed_extend_bit_on (*inst
) && (value
& SIGNED_BYTE_MASK
))
3258 value
|= SIGNED_BYTE_EXTEND_MASK
;
3261 /* The size should now be dword. */
3262 cris_set_size_to_dword (inst
);
3266 /* Handles the register mode for the ADD, SUB, CMP, AND, OR and MOVE
3267 instruction. The MOVE instruction is the move from source to register. */
3270 reg_mode_add_sub_cmp_and_or_move_op (unsigned short inst
,
3271 inst_env_type
*inst_env
)
3273 unsigned long operand1
;
3274 unsigned long operand2
;
3276 /* It's invalid to have a prefix to the instruction. This is a register
3277 mode instruction and can't have a prefix. */
3278 if (inst_env
->prefix_found
)
3280 inst_env
->invalid
= 1;
3283 /* Check if the instruction has PC as its target. */
3284 if (cris_get_operand2 (inst
) == REG_PC
)
3286 if (inst_env
->slot_needed
)
3288 inst_env
->invalid
= 1;
3291 /* The instruction has the PC as its target register. */
3292 operand1
= inst_env
->reg
[cris_get_operand1 (inst
)];
3293 operand2
= inst_env
->reg
[REG_PC
];
3295 /* Check if it's a extend, signed or zero instruction. */
3296 if (cris_get_opcode (inst
) < 4)
3298 operand1
= do_sign_or_zero_extend (operand1
, &inst
);
3300 /* Calculate the PC value after the instruction, i.e. where the
3301 breakpoint should be. The order of the udw_operands is vital. */
3302 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand1
);
3304 inst_env
->slot_needed
= 0;
3305 inst_env
->prefix_found
= 0;
3306 inst_env
->xflag_found
= 0;
3307 inst_env
->disable_interrupt
= 0;
3310 /* Returns the data contained at address. The size of the data is derived from
3311 the size of the operation. If the instruction is a zero or signed
3312 extend instruction, the size field is changed in instruction. */
3314 static unsigned long
3315 get_data_from_address (unsigned short *inst
, CORE_ADDR address
,
3316 enum bfd_endian byte_order
)
3318 int size
= cris_get_size (*inst
);
3319 unsigned long value
;
3321 /* If it's an extend instruction we don't want the signed extend bit,
3322 because it influences the size. */
3323 if (cris_get_opcode (*inst
) < 4)
3325 size
&= ~SIGNED_EXTEND_BIT_MASK
;
3327 /* Is there a need for checking the size? Size should contain the number of
3330 value
= read_memory_unsigned_integer (address
, size
, byte_order
);
3332 /* Check if it's an extend, signed or zero instruction. */
3333 if (cris_get_opcode (*inst
) < 4)
3335 value
= do_sign_or_zero_extend (value
, inst
);
3340 /* Handles the assign addresing mode for the ADD, SUB, CMP, AND, OR and MOVE
3341 instructions. The MOVE instruction is the move from source to register. */
3344 handle_prefix_assign_mode_for_aritm_op (unsigned short inst
,
3345 inst_env_type
*inst_env
)
3347 unsigned long operand2
;
3348 unsigned long operand3
;
3350 check_assign (inst
, inst_env
);
3351 if (cris_get_operand2 (inst
) == REG_PC
)
3353 operand2
= inst_env
->reg
[REG_PC
];
3355 /* Get the value of the third operand. */
3356 operand3
= get_data_from_address (&inst
, inst_env
->prefix_value
,
3357 inst_env
->byte_order
);
3359 /* Calculate the PC value after the instruction, i.e. where the
3360 breakpoint should be. The order of the udw_operands is vital. */
3361 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand3
);
3363 inst_env
->slot_needed
= 0;
3364 inst_env
->prefix_found
= 0;
3365 inst_env
->xflag_found
= 0;
3366 inst_env
->disable_interrupt
= 0;
3369 /* Handles the three-operand addressing mode for the ADD, SUB, CMP, AND and
3370 OR instructions. Note that for this to work as expected, the calling
3371 function must have made sure that there is a prefix to this instruction. */
3374 three_operand_add_sub_cmp_and_or_op (unsigned short inst
,
3375 inst_env_type
*inst_env
)
3377 unsigned long operand2
;
3378 unsigned long operand3
;
3380 if (cris_get_operand1 (inst
) == REG_PC
)
3382 /* The PC will be changed by the instruction. */
3383 operand2
= inst_env
->reg
[cris_get_operand2 (inst
)];
3385 /* Get the value of the third operand. */
3386 operand3
= get_data_from_address (&inst
, inst_env
->prefix_value
,
3387 inst_env
->byte_order
);
3389 /* Calculate the PC value after the instruction, i.e. where the
3390 breakpoint should be. */
3391 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand3
);
3393 inst_env
->slot_needed
= 0;
3394 inst_env
->prefix_found
= 0;
3395 inst_env
->xflag_found
= 0;
3396 inst_env
->disable_interrupt
= 0;
3399 /* Handles the index addresing mode for the ADD, SUB, CMP, AND, OR and MOVE
3400 instructions. The MOVE instruction is the move from source to register. */
3403 handle_prefix_index_mode_for_aritm_op (unsigned short inst
,
3404 inst_env_type
*inst_env
)
3406 if (cris_get_operand1 (inst
) != cris_get_operand2 (inst
))
3408 /* If the instruction is MOVE it's invalid. If the instruction is ADD,
3409 SUB, AND or OR something weird is going on (if everything works these
3410 instructions should end up in the three operand version). */
3411 inst_env
->invalid
= 1;
3416 /* three_operand_add_sub_cmp_and_or does the same as we should do here
3418 three_operand_add_sub_cmp_and_or_op (inst
, inst_env
);
3420 inst_env
->slot_needed
= 0;
3421 inst_env
->prefix_found
= 0;
3422 inst_env
->xflag_found
= 0;
3423 inst_env
->disable_interrupt
= 0;
3426 /* Handles the autoincrement and indirect addresing mode for the ADD, SUB,
3427 CMP, AND OR and MOVE instruction. The MOVE instruction is the move from
3428 source to register. */
3431 handle_inc_and_index_mode_for_aritm_op (unsigned short inst
,
3432 inst_env_type
*inst_env
)
3434 unsigned long operand1
;
3435 unsigned long operand2
;
3436 unsigned long operand3
;
3439 /* The instruction is either an indirect or autoincrement addressing mode.
3440 Check if the destination register is the PC. */
3441 if (cris_get_operand2 (inst
) == REG_PC
)
3443 /* Must be done here, get_data_from_address may change the size
3445 size
= cris_get_size (inst
);
3446 operand2
= inst_env
->reg
[REG_PC
];
3448 /* Get the value of the third operand, i.e. the indirect operand. */
3449 operand1
= inst_env
->reg
[cris_get_operand1 (inst
)];
3450 operand3
= get_data_from_address (&inst
, operand1
, inst_env
->byte_order
);
3452 /* Calculate the PC value after the instruction, i.e. where the
3453 breakpoint should be. The order of the udw_operands is vital. */
3454 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand3
);
3456 /* If this is an autoincrement addressing mode, check if the increment
3458 if ((cris_get_operand1 (inst
) == REG_PC
)
3459 && (cris_get_mode (inst
) == AUTOINC_MODE
))
3461 /* Get the size field. */
3462 size
= cris_get_size (inst
);
3464 /* If it's an extend instruction we don't want the signed extend bit,
3465 because it influences the size. */
3466 if (cris_get_opcode (inst
) < 4)
3468 size
&= ~SIGNED_EXTEND_BIT_MASK
;
3470 process_autoincrement (size
, inst
, inst_env
);
3472 inst_env
->slot_needed
= 0;
3473 inst_env
->prefix_found
= 0;
3474 inst_env
->xflag_found
= 0;
3475 inst_env
->disable_interrupt
= 0;
3478 /* Handles the two-operand addressing mode, all modes except register, for
3479 the ADD, SUB CMP, AND and OR instruction. */
3482 none_reg_mode_add_sub_cmp_and_or_move_op (unsigned short inst
,
3483 inst_env_type
*inst_env
)
3485 if (inst_env
->prefix_found
)
3487 if (cris_get_mode (inst
) == PREFIX_INDEX_MODE
)
3489 handle_prefix_index_mode_for_aritm_op (inst
, inst_env
);
3491 else if (cris_get_mode (inst
) == PREFIX_ASSIGN_MODE
)
3493 handle_prefix_assign_mode_for_aritm_op (inst
, inst_env
);
3497 /* The mode is invalid for a prefixed base instruction. */
3498 inst_env
->invalid
= 1;
3504 handle_inc_and_index_mode_for_aritm_op (inst
, inst_env
);
3508 /* Handles the quick addressing mode for the ADD and SUB instruction. */
3511 quick_mode_add_sub_op (unsigned short inst
, inst_env_type
*inst_env
)
3513 unsigned long operand1
;
3514 unsigned long operand2
;
3516 /* It's a bad idea to be in a prefix instruction now. This is a quick mode
3517 instruction and can't have a prefix. */
3518 if (inst_env
->prefix_found
)
3520 inst_env
->invalid
= 1;
3524 /* Check if the instruction has PC as its target. */
3525 if (cris_get_operand2 (inst
) == REG_PC
)
3527 if (inst_env
->slot_needed
)
3529 inst_env
->invalid
= 1;
3532 operand1
= cris_get_quick_value (inst
);
3533 operand2
= inst_env
->reg
[REG_PC
];
3535 /* The size should now be dword. */
3536 cris_set_size_to_dword (&inst
);
3538 /* Calculate the PC value after the instruction, i.e. where the
3539 breakpoint should be. */
3540 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand1
);
3542 inst_env
->slot_needed
= 0;
3543 inst_env
->prefix_found
= 0;
3544 inst_env
->xflag_found
= 0;
3545 inst_env
->disable_interrupt
= 0;
3548 /* Handles the quick addressing mode for the CMP, AND and OR instruction. */
3551 quick_mode_and_cmp_move_or_op (unsigned short inst
, inst_env_type
*inst_env
)
3553 unsigned long operand1
;
3554 unsigned long operand2
;
3556 /* It's a bad idea to be in a prefix instruction now. This is a quick mode
3557 instruction and can't have a prefix. */
3558 if (inst_env
->prefix_found
)
3560 inst_env
->invalid
= 1;
3563 /* Check if the instruction has PC as its target. */
3564 if (cris_get_operand2 (inst
) == REG_PC
)
3566 if (inst_env
->slot_needed
)
3568 inst_env
->invalid
= 1;
3571 /* The instruction has the PC as its target register. */
3572 operand1
= cris_get_quick_value (inst
);
3573 operand2
= inst_env
->reg
[REG_PC
];
3575 /* The quick value is signed, so check if we must do a signed extend. */
3576 if (operand1
& SIGNED_QUICK_VALUE_MASK
)
3579 operand1
|= SIGNED_QUICK_VALUE_EXTEND_MASK
;
3581 /* The size should now be dword. */
3582 cris_set_size_to_dword (&inst
);
3584 /* Calculate the PC value after the instruction, i.e. where the
3585 breakpoint should be. */
3586 add_sub_cmp_and_or_move_action (inst
, inst_env
, operand2
, operand1
);
3588 inst_env
->slot_needed
= 0;
3589 inst_env
->prefix_found
= 0;
3590 inst_env
->xflag_found
= 0;
3591 inst_env
->disable_interrupt
= 0;
3594 /* Translate op_type to a function and call it. */
3597 cris_gdb_func (struct gdbarch
*gdbarch
, enum cris_op_type op_type
,
3598 unsigned short inst
, inst_env_type
*inst_env
)
3602 case cris_not_implemented_op
:
3603 not_implemented_op (inst
, inst_env
);
3607 abs_op (inst
, inst_env
);
3611 addi_op (inst
, inst_env
);
3615 asr_op (inst
, inst_env
);
3619 asrq_op (inst
, inst_env
);
3622 case cris_ax_ei_setf_op
:
3623 ax_ei_setf_op (inst
, inst_env
);
3626 case cris_bdap_prefix
:
3627 bdap_prefix (inst
, inst_env
);
3630 case cris_biap_prefix
:
3631 biap_prefix (inst
, inst_env
);
3635 break_op (inst
, inst_env
);
3638 case cris_btst_nop_op
:
3639 btst_nop_op (inst
, inst_env
);
3642 case cris_clearf_di_op
:
3643 clearf_di_op (inst
, inst_env
);
3646 case cris_dip_prefix
:
3647 dip_prefix (inst
, inst_env
);
3650 case cris_dstep_logshift_mstep_neg_not_op
:
3651 dstep_logshift_mstep_neg_not_op (inst
, inst_env
);
3654 case cris_eight_bit_offset_branch_op
:
3655 eight_bit_offset_branch_op (inst
, inst_env
);
3658 case cris_move_mem_to_reg_movem_op
:
3659 move_mem_to_reg_movem_op (inst
, inst_env
);
3662 case cris_move_reg_to_mem_movem_op
:
3663 move_reg_to_mem_movem_op (inst
, inst_env
);
3666 case cris_move_to_preg_op
:
3667 move_to_preg_op (gdbarch
, inst
, inst_env
);
3671 muls_op (inst
, inst_env
);
3675 mulu_op (inst
, inst_env
);
3678 case cris_none_reg_mode_add_sub_cmp_and_or_move_op
:
3679 none_reg_mode_add_sub_cmp_and_or_move_op (inst
, inst_env
);
3682 case cris_none_reg_mode_clear_test_op
:
3683 none_reg_mode_clear_test_op (inst
, inst_env
);
3686 case cris_none_reg_mode_jump_op
:
3687 none_reg_mode_jump_op (inst
, inst_env
);
3690 case cris_none_reg_mode_move_from_preg_op
:
3691 none_reg_mode_move_from_preg_op (gdbarch
, inst
, inst_env
);
3694 case cris_quick_mode_add_sub_op
:
3695 quick_mode_add_sub_op (inst
, inst_env
);
3698 case cris_quick_mode_and_cmp_move_or_op
:
3699 quick_mode_and_cmp_move_or_op (inst
, inst_env
);
3702 case cris_quick_mode_bdap_prefix
:
3703 quick_mode_bdap_prefix (inst
, inst_env
);
3706 case cris_reg_mode_add_sub_cmp_and_or_move_op
:
3707 reg_mode_add_sub_cmp_and_or_move_op (inst
, inst_env
);
3710 case cris_reg_mode_clear_op
:
3711 reg_mode_clear_op (inst
, inst_env
);
3714 case cris_reg_mode_jump_op
:
3715 reg_mode_jump_op (inst
, inst_env
);
3718 case cris_reg_mode_move_from_preg_op
:
3719 reg_mode_move_from_preg_op (inst
, inst_env
);
3722 case cris_reg_mode_test_op
:
3723 reg_mode_test_op (inst
, inst_env
);
3727 scc_op (inst
, inst_env
);
3730 case cris_sixteen_bit_offset_branch_op
:
3731 sixteen_bit_offset_branch_op (inst
, inst_env
);
3734 case cris_three_operand_add_sub_cmp_and_or_op
:
3735 three_operand_add_sub_cmp_and_or_op (inst
, inst_env
);
3738 case cris_three_operand_bound_op
:
3739 three_operand_bound_op (inst
, inst_env
);
3742 case cris_two_operand_bound_op
:
3743 two_operand_bound_op (inst
, inst_env
);
3747 xor_op (inst
, inst_env
);
3752 /* Originally from <asm/elf.h>. */
3753 typedef unsigned char cris_elf_greg_t
[4];
3755 /* Same as user_regs_struct struct in <asm/user.h>. */
3756 #define CRISV10_ELF_NGREG 35
3757 typedef cris_elf_greg_t cris_elf_gregset_t
[CRISV10_ELF_NGREG
];
3759 #define CRISV32_ELF_NGREG 32
3760 typedef cris_elf_greg_t crisv32_elf_gregset_t
[CRISV32_ELF_NGREG
];
3762 /* Unpack a cris_elf_gregset_t into GDB's register cache. */
3765 cris_supply_gregset (const struct regset
*regset
, struct regcache
*regcache
,
3766 int regnum
, const void *gregs
, size_t len
)
3768 struct gdbarch
*gdbarch
= regcache
->arch ();
3769 cris_gdbarch_tdep
*tdep
= (cris_gdbarch_tdep
*) gdbarch_tdep (gdbarch
);
3771 const cris_elf_greg_t
*regp
= static_cast<const cris_elf_greg_t
*>(gregs
);
3773 if (len
!= sizeof (cris_elf_gregset_t
)
3774 && len
!= sizeof (crisv32_elf_gregset_t
))
3775 warning (_("wrong size gregset struct in core file"));
3776 gdb_assert (len
>= sizeof (crisv32_elf_gregset_t
));
3778 /* The kernel dumps all 32 registers as unsigned longs, but supply_register
3779 knows about the actual size of each register so that's no problem. */
3780 for (i
= 0; i
< NUM_GENREGS
+ NUM_SPECREGS
; i
++)
3782 if (regnum
== -1 || regnum
== i
)
3783 regcache
->raw_supply (i
, (char *)®p
[i
]);
3786 if (tdep
->cris_version
== 32 && (regnum
== -1 || regnum
== ERP_REGNUM
))
3788 /* Needed to set pseudo-register PC for CRISv32. */
3789 /* FIXME: If ERP is in a delay slot at this point then the PC will
3790 be wrong. Issue a warning to alert the user. */
3791 regcache
->raw_supply (gdbarch_pc_regnum (gdbarch
),
3792 (char *)®p
[ERP_REGNUM
]);
3794 if (*(char *)®p
[ERP_REGNUM
] & 0x1)
3795 gdb_printf (gdb_stderr
, "Warning: PC in delay slot\n");
3799 static const struct regset cris_regset
= {
3801 cris_supply_gregset
,
3802 /* We don't need a collect function because we only use this for core files
3803 (via iterate_over_regset_sections). */
3805 REGSET_VARIABLE_SIZE
3808 static void cris_iterate_over_regset_sections (struct gdbarch
*gdbarch
,
3809 iterate_over_regset_sections_cb
*cb
,
3811 const struct regcache
*regcache
)
3813 cb (".reg", sizeof (crisv32_elf_gregset_t
), sizeof (crisv32_elf_gregset_t
),
3814 &cris_regset
, NULL
, cb_data
);
3817 void _initialize_cris_tdep ();
3819 _initialize_cris_tdep ()
3821 gdbarch_register (bfd_arch_cris
, cris_gdbarch_init
, cris_dump_tdep
);
3823 /* CRIS-specific user-commands. */
3824 add_setshow_zuinteger_cmd ("cris-version", class_support
,
3825 &usr_cmd_cris_version
,
3826 _("Set the current CRIS version."),
3827 _("Show the current CRIS version."),
3829 Set to 10 for CRISv10 or 32 for CRISv32 if autodetection fails.\n\
3832 NULL
, /* FIXME: i18n: Current CRIS version
3834 &setlist
, &showlist
);
3836 add_setshow_enum_cmd ("cris-mode", class_support
,
3837 cris_modes
, &usr_cmd_cris_mode
,
3838 _("Set the current CRIS mode."),
3839 _("Show the current CRIS mode."),
3841 Set to CRIS_MODE_GURU when debugging in guru mode.\n\
3842 Makes GDB use the NRP register instead of the ERP register in certain cases."),
3844 NULL
, /* FIXME: i18n: Current CRIS version is %s. */
3845 &setlist
, &showlist
);
3847 add_setshow_boolean_cmd ("cris-dwarf2-cfi", class_support
,
3848 &usr_cmd_cris_dwarf2_cfi
,
3849 _("Set the usage of Dwarf-2 CFI for CRIS."),
3850 _("Show the usage of Dwarf-2 CFI for CRIS."),
3851 _("Set this to \"off\" if using gcc-cris < R59."),
3852 set_cris_dwarf2_cfi
,
3853 NULL
, /* FIXME: i18n: Usage of Dwarf-2 CFI
3855 &setlist
, &showlist
);
3858 /* Prints out all target specific values. */
3861 cris_dump_tdep (struct gdbarch
*gdbarch
, struct ui_file
*file
)
3863 cris_gdbarch_tdep
*tdep
= (cris_gdbarch_tdep
*) gdbarch_tdep (gdbarch
);
3866 gdb_printf (file
, "cris_dump_tdep: tdep->cris_version = %i\n",
3867 tdep
->cris_version
);
3868 gdb_printf (file
, "cris_dump_tdep: tdep->cris_mode = %s\n",
3870 gdb_printf (file
, "cris_dump_tdep: tdep->cris_dwarf2_cfi = %i\n",
3871 tdep
->cris_dwarf2_cfi
);
3876 set_cris_version (const char *ignore_args
, int from_tty
,
3877 struct cmd_list_element
*c
)
3879 struct gdbarch_info info
;
3881 usr_cmd_cris_version_valid
= 1;
3883 /* Update the current architecture, if needed. */
3884 if (!gdbarch_update_p (info
))
3885 internal_error (__FILE__
, __LINE__
,
3886 _("cris_gdbarch_update: failed to update architecture."));
3890 set_cris_mode (const char *ignore_args
, int from_tty
,
3891 struct cmd_list_element
*c
)
3893 struct gdbarch_info info
;
3895 /* Update the current architecture, if needed. */
3896 if (!gdbarch_update_p (info
))
3897 internal_error (__FILE__
, __LINE__
,
3898 "cris_gdbarch_update: failed to update architecture.");
3902 set_cris_dwarf2_cfi (const char *ignore_args
, int from_tty
,
3903 struct cmd_list_element
*c
)
3905 struct gdbarch_info info
;
3907 /* Update the current architecture, if needed. */
3908 if (!gdbarch_update_p (info
))
3909 internal_error (__FILE__
, __LINE__
,
3910 _("cris_gdbarch_update: failed to update architecture."));
3913 static struct gdbarch
*
3914 cris_gdbarch_init (struct gdbarch_info info
, struct gdbarch_list
*arches
)
3916 struct gdbarch
*gdbarch
;
3917 unsigned int cris_version
;
3919 if (usr_cmd_cris_version_valid
)
3921 /* Trust the user's CRIS version setting. */
3922 cris_version
= usr_cmd_cris_version
;
3924 else if (info
.abfd
&& bfd_get_mach (info
.abfd
) == bfd_mach_cris_v32
)
3930 /* Assume it's CRIS version 10. */
3934 /* Make the current settings visible to the user. */
3935 usr_cmd_cris_version
= cris_version
;
3937 /* Find a candidate among the list of pre-declared architectures. */
3938 for (arches
= gdbarch_list_lookup_by_info (arches
, &info
);
3940 arches
= gdbarch_list_lookup_by_info (arches
->next
, &info
))
3942 cris_gdbarch_tdep
*tdep
3943 = (cris_gdbarch_tdep
*) gdbarch_tdep (arches
->gdbarch
);
3945 if (tdep
->cris_version
== usr_cmd_cris_version
3946 && tdep
->cris_mode
== usr_cmd_cris_mode
3947 && tdep
->cris_dwarf2_cfi
== usr_cmd_cris_dwarf2_cfi
)
3948 return arches
->gdbarch
;
3951 /* No matching architecture was found. Create a new one. */
3952 cris_gdbarch_tdep
*tdep
= new cris_gdbarch_tdep
;
3953 info
.byte_order
= BFD_ENDIAN_LITTLE
;
3954 gdbarch
= gdbarch_alloc (&info
, tdep
);
3956 tdep
->cris_version
= usr_cmd_cris_version
;
3957 tdep
->cris_mode
= usr_cmd_cris_mode
;
3958 tdep
->cris_dwarf2_cfi
= usr_cmd_cris_dwarf2_cfi
;
3960 set_gdbarch_return_value (gdbarch
, cris_return_value
);
3961 set_gdbarch_sp_regnum (gdbarch
, 14);
3963 /* Length of ordinary registers used in push_word and a few other
3964 places. register_size() is the real way to know how big a
3967 set_gdbarch_double_bit (gdbarch
, 64);
3968 /* The default definition of a long double is 2 * gdbarch_double_bit,
3969 which means we have to set this explicitly. */
3970 set_gdbarch_long_double_bit (gdbarch
, 64);
3972 /* The total amount of space needed to store (in an array called registers)
3973 GDB's copy of the machine's register state. Note: We can not use
3974 cris_register_size at this point, since it relies on gdbarch
3976 switch (tdep
->cris_version
)
3984 /* Old versions; not supported. */
3989 /* CRIS v10 and v11, a.k.a. ETRAX 100LX. In addition to ETRAX 100,
3990 P7 (32 bits), and P15 (32 bits) have been implemented. */
3991 set_gdbarch_pc_regnum (gdbarch
, 15);
3992 set_gdbarch_register_type (gdbarch
, cris_register_type
);
3993 /* There are 32 registers (some of which may not be implemented). */
3994 set_gdbarch_num_regs (gdbarch
, 32);
3995 set_gdbarch_register_name (gdbarch
, cris_register_name
);
3996 set_gdbarch_cannot_store_register (gdbarch
, cris_cannot_store_register
);
3997 set_gdbarch_cannot_fetch_register (gdbarch
, cris_cannot_fetch_register
);
3999 set_gdbarch_software_single_step (gdbarch
, cris_software_single_step
);
4003 /* CRIS v32. General registers R0 - R15 (32 bits), special registers
4004 P0 - P15 (32 bits) except P0, P1, P3 (8 bits) and P4 (16 bits)
4005 and pseudo-register PC (32 bits). */
4006 set_gdbarch_pc_regnum (gdbarch
, 32);
4007 set_gdbarch_register_type (gdbarch
, crisv32_register_type
);
4008 /* 32 registers + pseudo-register PC + 16 support registers. */
4009 set_gdbarch_num_regs (gdbarch
, 32 + 1 + 16);
4010 set_gdbarch_register_name (gdbarch
, crisv32_register_name
);
4012 set_gdbarch_cannot_store_register
4013 (gdbarch
, crisv32_cannot_store_register
);
4014 set_gdbarch_cannot_fetch_register
4015 (gdbarch
, crisv32_cannot_fetch_register
);
4017 set_gdbarch_have_nonsteppable_watchpoint (gdbarch
, 1);
4019 set_gdbarch_single_step_through_delay
4020 (gdbarch
, crisv32_single_step_through_delay
);
4025 /* Unknown version. */
4029 /* Dummy frame functions (shared between CRISv10 and CRISv32 since they
4030 have the same ABI). */
4031 set_gdbarch_push_dummy_code (gdbarch
, cris_push_dummy_code
);
4032 set_gdbarch_push_dummy_call (gdbarch
, cris_push_dummy_call
);
4033 set_gdbarch_frame_align (gdbarch
, cris_frame_align
);
4034 set_gdbarch_skip_prologue (gdbarch
, cris_skip_prologue
);
4036 /* The stack grows downward. */
4037 set_gdbarch_inner_than (gdbarch
, core_addr_lessthan
);
4039 set_gdbarch_breakpoint_kind_from_pc (gdbarch
, cris_breakpoint_kind_from_pc
);
4040 set_gdbarch_sw_breakpoint_from_kind (gdbarch
, cris_sw_breakpoint_from_kind
);
4041 set_gdbarch_iterate_over_regset_sections (gdbarch
, cris_iterate_over_regset_sections
);
4043 if (tdep
->cris_dwarf2_cfi
== 1)
4045 /* Hook in the Dwarf-2 frame sniffer. */
4046 set_gdbarch_dwarf2_reg_to_regnum (gdbarch
, cris_dwarf2_reg_to_regnum
);
4047 dwarf2_frame_set_init_reg (gdbarch
, cris_dwarf2_frame_init_reg
);
4048 dwarf2_append_unwinders (gdbarch
);
4051 if (tdep
->cris_mode
!= cris_mode_guru
)
4053 frame_unwind_append_unwinder (gdbarch
, &cris_sigtramp_frame_unwind
);
4056 frame_unwind_append_unwinder (gdbarch
, &cris_frame_unwind
);
4057 frame_base_set_default (gdbarch
, &cris_frame_base
);
4059 /* Hook in ABI-specific overrides, if they have been registered. */
4060 gdbarch_init_osabi (info
, gdbarch
);