1 /* Target dependent code for CRIS, for GDB, the GNU debugger.
2 Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
3 Contributed by Axis Communications AB.
4 Written by Hendrik Ruijter, Stefan Andersson, and Orjan Friberg.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
31 #include "opcode/cris.h"
32 #include "arch-utils.h"
35 /* To get entry_point_address. */
38 #include "solib.h" /* Support for shared libraries. */
39 #include "solib-svr4.h" /* For struct link_map_offsets. */
40 #include "gdb_string.h"
45 /* There are no floating point registers. Used in gdbserver low-linux.c. */
48 /* There are 16 general registers. */
51 /* There are 16 special registers. */
55 /* Register numbers of various important registers.
56 DEPRECATED_FP_REGNUM Contains address of executing stack frame.
57 STR_REGNUM Contains the address of structure return values.
58 RET_REGNUM Contains the return value when shorter than or equal to 32 bits
59 ARG1_REGNUM Contains the first parameter to a function.
60 ARG2_REGNUM Contains the second parameter to a function.
61 ARG3_REGNUM Contains the third parameter to a function.
62 ARG4_REGNUM Contains the fourth parameter to a function. Rest on stack.
63 SP_REGNUM Contains address of top of stack.
64 PC_REGNUM Contains address of next instruction.
65 SRP_REGNUM Subroutine return pointer register.
66 BRP_REGNUM Breakpoint return pointer register. */
68 /* DEPRECATED_FP_REGNUM = 8, SP_REGNUM = 14, and PC_REGNUM = 15 have
69 been incorporated into the multi-arch framework. */
73 /* Enums with respect to the general registers, valid for all
82 /* Enums with respect to the special registers, some of which may not be
83 applicable to all CRIS versions. */
101 extern const struct cris_spec_reg cris_spec_regs[];
103 /* CRIS version, set via the user command 'set cris-version'. Affects
104 register names and sizes.*/
105 static int usr_cmd_cris_version;
107 /* Indicates whether to trust the above variable. */
108 static int usr_cmd_cris_version_valid = 0;
110 /* CRIS mode, set via the user command 'set cris-mode'. Affects availability
111 of some registers. */
112 static const char *usr_cmd_cris_mode;
114 /* Indicates whether to trust the above variable. */
115 static int usr_cmd_cris_mode_valid = 0;
117 static const char CRIS_MODE_USER[] = "CRIS_MODE_USER";
118 static const char CRIS_MODE_SUPERVISOR[] = "CRIS_MODE_SUPERVISOR";
119 static const char *cris_mode_enums[] =
122 CRIS_MODE_SUPERVISOR,
126 /* CRIS ABI, set via the user command 'set cris-abi'.
127 There are two flavours:
128 1. Original ABI with 32-bit doubles, where arguments <= 4 bytes are
130 2. New ABI with 64-bit doubles, where arguments <= 8 bytes are passed by
132 static const char *usr_cmd_cris_abi;
134 /* Indicates whether to trust the above variable. */
135 static int usr_cmd_cris_abi_valid = 0;
137 /* These variables are strings instead of enums to make them usable as
138 parameters to add_set_enum_cmd. */
139 static const char CRIS_ABI_ORIGINAL[] = "CRIS_ABI_ORIGINAL";
140 static const char CRIS_ABI_V2[] = "CRIS_ABI_V2";
141 static const char CRIS_ABI_SYMBOL[] = ".$CRIS_ABI_V2";
142 static const char *cris_abi_enums[] =
149 /* CRIS architecture specific information. */
153 const char *cris_mode;
154 const char *cris_abi;
157 /* Functions for accessing target dependent data. */
162 return (gdbarch_tdep (current_gdbarch)->cris_version);
168 return (gdbarch_tdep (current_gdbarch)->cris_mode);
174 return (gdbarch_tdep (current_gdbarch)->cris_abi);
177 /* For saving call-clobbered contents in R9 when returning structs. */
178 static CORE_ADDR struct_return_address;
180 struct frame_extra_info
186 /* The instruction environment needed to find single-step breakpoints. */
188 struct instruction_environment
190 unsigned long reg[NUM_GENREGS];
191 unsigned long preg[NUM_SPECREGS];
192 unsigned long branch_break_address;
193 unsigned long delay_slot_pc;
194 unsigned long prefix_value;
199 int delay_slot_pc_active;
201 int disable_interrupt;
204 /* Save old breakpoints in order to restore the state before a single_step.
205 At most, two breakpoints will have to be remembered. */
207 char binsn_quantum[BREAKPOINT_MAX];
208 static binsn_quantum break_mem[2];
209 static CORE_ADDR next_pc = 0;
210 static CORE_ADDR branch_target_address = 0;
211 static unsigned char branch_break_inserted = 0;
213 /* Machine-dependencies in CRIS for opcodes. */
215 /* Instruction sizes. */
216 enum cris_instruction_sizes
223 /* Addressing modes. */
224 enum cris_addressing_modes
231 /* Prefix addressing modes. */
232 enum cris_prefix_addressing_modes
234 PREFIX_INDEX_MODE = 2,
235 PREFIX_ASSIGN_MODE = 3,
237 /* Handle immediate byte offset addressing mode prefix format. */
238 PREFIX_OFFSET_MODE = 2
241 /* Masks for opcodes. */
242 enum cris_opcode_masks
244 BRANCH_SIGNED_SHORT_OFFSET_MASK = 0x1,
245 SIGNED_EXTEND_BIT_MASK = 0x2,
246 SIGNED_BYTE_MASK = 0x80,
247 SIGNED_BYTE_EXTEND_MASK = 0xFFFFFF00,
248 SIGNED_WORD_MASK = 0x8000,
249 SIGNED_WORD_EXTEND_MASK = 0xFFFF0000,
250 SIGNED_DWORD_MASK = 0x80000000,
251 SIGNED_QUICK_VALUE_MASK = 0x20,
252 SIGNED_QUICK_VALUE_EXTEND_MASK = 0xFFFFFFC0
255 /* Functions for opcodes. The general form of the ETRAX 16-bit instruction:
263 cris_get_operand2 (unsigned short insn)
265 return ((insn & 0xF000) >> 12);
269 cris_get_mode (unsigned short insn)
271 return ((insn & 0x0C00) >> 10);
275 cris_get_opcode (unsigned short insn)
277 return ((insn & 0x03C0) >> 6);
281 cris_get_size (unsigned short insn)
283 return ((insn & 0x0030) >> 4);
287 cris_get_operand1 (unsigned short insn)
289 return (insn & 0x000F);
292 /* Additional functions in order to handle opcodes. */
295 cris_get_wide_opcode (unsigned short insn)
297 return ((insn & 0x03E0) >> 5);
301 cris_get_short_size (unsigned short insn)
303 return ((insn & 0x0010) >> 4);
307 cris_get_quick_value (unsigned short insn)
309 return (insn & 0x003F);
313 cris_get_bdap_quick_offset (unsigned short insn)
315 return (insn & 0x00FF);
319 cris_get_branch_short_offset (unsigned short insn)
321 return (insn & 0x00FF);
325 cris_get_asr_shift_steps (unsigned long value)
327 return (value & 0x3F);
331 cris_get_asr_quick_shift_steps (unsigned short insn)
333 return (insn & 0x1F);
337 cris_get_clear_size (unsigned short insn)
339 return ((insn) & 0xC000);
343 cris_is_signed_extend_bit_on (unsigned short insn)
345 return (((insn) & 0x20) == 0x20);
349 cris_is_xflag_bit_on (unsigned short insn)
351 return (((insn) & 0x1000) == 0x1000);
355 cris_set_size_to_dword (unsigned short *insn)
362 cris_get_signed_offset (unsigned short insn)
364 return ((signed char) (insn & 0x00FF));
367 /* Calls an op function given the op-type, working on the insn and the
369 static void cris_gdb_func (enum cris_op_type, unsigned short, inst_env_type *);
371 static CORE_ADDR cris_skip_prologue_main (CORE_ADDR pc, int frameless_p);
373 static struct gdbarch *cris_gdbarch_init (struct gdbarch_info,
374 struct gdbarch_list *);
376 static int cris_delayed_get_disassembler (bfd_vma, disassemble_info *);
378 static void cris_dump_tdep (struct gdbarch *, struct ui_file *);
380 static void cris_version_update (char *ignore_args, int from_tty,
381 struct cmd_list_element *c);
383 static void cris_mode_update (char *ignore_args, int from_tty,
384 struct cmd_list_element *c);
386 static void cris_abi_update (char *ignore_args, int from_tty,
387 struct cmd_list_element *c);
389 static CORE_ADDR bfd_lookup_symbol (bfd *, const char *);
391 /* Frames information. The definition of the struct frame_info is
395 enum frame_type type;
399 If the compilation option -fno-omit-frame-pointer is present the
400 variable frame will be set to the content of R8 which is the frame
403 The variable pc contains the address where execution is performed
404 in the present frame. The innermost frame contains the current content
405 of the register PC. All other frames contain the content of the
406 register PC in the next frame.
408 The variable `type' indicates the frame's type: normal, SIGTRAMP
409 (associated with a signal handler), dummy (associated with a dummy
412 The variable return_pc contains the address where execution should be
413 resumed when the present frame has finished, the return address.
415 The variable leaf_function is 1 if the return address is in the register
416 SRP, and 0 if it is on the stack.
418 Prologue instructions C-code.
419 The prologue may consist of (-fno-omit-frame-pointer)
423 move.d sp,r8 move.d sp,r8
425 movem rY,[sp] movem rY,[sp]
426 move.S rZ,[r8-U] move.S rZ,[r8-U]
428 where 1 is a non-terminal function, and 2 is a leaf-function.
430 Note that this assumption is extremely brittle, and will break at the
431 slightest change in GCC's prologue.
433 If local variables are declared or register contents are saved on stack
434 the subq-instruction will be present with X as the number of bytes
435 needed for storage. The reshuffle with respect to r8 may be performed
436 with any size S (b, w, d) and any of the general registers Z={0..13}.
437 The offset U should be representable by a signed 8-bit value in all cases.
438 Thus, the prefix word is assumed to be immediate byte offset mode followed
439 by another word containing the instruction.
448 Prologue instructions C++-code.
449 Case 1) and 2) in the C-code may be followed by
455 move.S [r8+U],rZ ; P4
457 if any of the call parameters are stored. The host expects these
458 instructions to be executed in order to get the call parameters right. */
460 /* Examine the prologue of a function. The variable ip is the address of
461 the first instruction of the prologue. The variable limit is the address
462 of the first instruction after the prologue. The variable fi contains the
463 information in struct frame_info. The variable frameless_p controls whether
464 the entire prologue is examined (0) or just enough instructions to
465 determine that it is a prologue (1). */
468 cris_examine (CORE_ADDR ip, CORE_ADDR limit, struct frame_info *fi,
471 /* Present instruction. */
474 /* Next instruction, lookahead. */
475 unsigned short insn_next;
478 /* Is there a push fp? */
481 /* Number of byte on stack used for local variables and movem. */
484 /* Highest register number in a movem. */
487 /* move.d r<source_register>,rS */
488 short source_register;
490 /* This frame is with respect to a leaf until a push srp is found. */
491 get_frame_extra_info (fi)->leaf_function = 1;
493 /* This frame is without the FP until a push fp is found. */
496 /* Assume nothing on stack. */
500 /* No information about register contents so far. */
502 /* We only want to know the end of the prologue when fi->saved_regs == 0.
503 When the saved registers are allocated full information is required. */
504 if (get_frame_saved_regs (fi))
506 for (regno = 0; regno < NUM_REGS; regno++)
507 get_frame_saved_regs (fi)[regno] = 0;
510 /* Find the prologue instructions. */
513 insn = read_memory_unsigned_integer (ip, sizeof (short));
514 ip += sizeof (short);
517 /* push <reg> 32 bit instruction */
518 insn_next = read_memory_unsigned_integer (ip, sizeof (short));
519 ip += sizeof (short);
520 regno = cris_get_operand2 (insn_next);
522 /* This check, meant to recognize srp, used to be regno ==
523 (SRP_REGNUM - NUM_GENREGS), but that covers r11 also. */
524 if (insn_next == 0xBE7E)
530 get_frame_extra_info (fi)->leaf_function = 0;
532 else if (regno == DEPRECATED_FP_REGNUM)
537 else if (insn == 0x866E)
546 else if (cris_get_operand2 (insn) == SP_REGNUM
547 && cris_get_mode (insn) == 0x0000
548 && cris_get_opcode (insn) == 0x000A)
551 val = cris_get_quick_value (insn);
553 else if (cris_get_mode (insn) == 0x0002
554 && cris_get_opcode (insn) == 0x000F
555 && cris_get_size (insn) == 0x0003
556 && cris_get_operand1 (insn) == SP_REGNUM)
558 /* movem r<regsave>,[sp] */
563 regsave = cris_get_operand2 (insn);
565 else if (cris_get_operand2 (insn) == SP_REGNUM
566 && ((insn & 0x0F00) >> 8) == 0x0001
567 && (cris_get_signed_offset (insn) < 0))
569 /* Immediate byte offset addressing prefix word with sp as base
570 register. Used for CRIS v8 i.e. ETRAX 100 and newer if <val>
571 is between 64 and 128.
572 movem r<regsave>,[sp=sp-<val>] */
573 val = -cris_get_signed_offset (insn);
574 insn_next = read_memory_unsigned_integer (ip, sizeof (short));
575 ip += sizeof (short);
576 if (cris_get_mode (insn_next) == PREFIX_ASSIGN_MODE
577 && cris_get_opcode (insn_next) == 0x000F
578 && cris_get_size (insn_next) == 0x0003
579 && cris_get_operand1 (insn_next) == SP_REGNUM)
585 regsave = cris_get_operand2 (insn_next);
589 /* The prologue ended before the limit was reached. */
590 ip -= 2 * sizeof (short);
594 else if (cris_get_mode (insn) == 0x0001
595 && cris_get_opcode (insn) == 0x0009
596 && cris_get_size (insn) == 0x0002)
598 /* move.d r<10..13>,r<0..15> */
603 source_register = cris_get_operand1 (insn);
605 /* FIXME? In the glibc solibs, the prologue might contain something
606 like (this example taken from relocate_doit):
609 which isn't covered by the source_register check below. Question
610 is whether to add a check for this combo, or make better use of
611 the limit variable instead. */
612 if (source_register < ARG1_REGNUM || source_register > ARG4_REGNUM)
614 /* The prologue ended before the limit was reached. */
615 ip -= sizeof (short);
619 else if (cris_get_operand2 (insn) == DEPRECATED_FP_REGNUM
620 /* The size is a fixed-size. */
621 && ((insn & 0x0F00) >> 8) == 0x0001
622 /* A negative offset. */
623 && (cris_get_signed_offset (insn) < 0))
625 /* move.S rZ,[r8-U] (?) */
626 insn_next = read_memory_unsigned_integer (ip, sizeof (short));
627 ip += sizeof (short);
628 regno = cris_get_operand2 (insn_next);
629 if ((regno >= 0 && regno < SP_REGNUM)
630 && cris_get_mode (insn_next) == PREFIX_OFFSET_MODE
631 && cris_get_opcode (insn_next) == 0x000F)
633 /* move.S rZ,[r8-U] */
638 /* The prologue ended before the limit was reached. */
639 ip -= 2 * sizeof (short);
643 else if (cris_get_operand2 (insn) == DEPRECATED_FP_REGNUM
644 /* The size is a fixed-size. */
645 && ((insn & 0x0F00) >> 8) == 0x0001
646 /* A positive offset. */
647 && (cris_get_signed_offset (insn) > 0))
649 /* move.S [r8+U],rZ (?) */
650 insn_next = read_memory_unsigned_integer (ip, sizeof (short));
651 ip += sizeof (short);
652 regno = cris_get_operand2 (insn_next);
653 if ((regno >= 0 && regno < SP_REGNUM)
654 && cris_get_mode (insn_next) == PREFIX_OFFSET_MODE
655 && cris_get_opcode (insn_next) == 0x0009
656 && cris_get_operand1 (insn_next) == regno)
658 /* move.S [r8+U],rZ */
663 /* The prologue ended before the limit was reached. */
664 ip -= 2 * sizeof (short);
670 /* The prologue ended before the limit was reached. */
671 ip -= sizeof (short);
677 /* We only want to know the end of the prologue when
678 fi->saved_regs == 0. */
679 if (!get_frame_saved_regs (fi))
684 get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM] = get_frame_base (fi);
686 /* Calculate the addresses. */
687 for (regno = regsave; regno >= 0; regno--)
689 get_frame_saved_regs (fi)[regno] = get_frame_base (fi) - val;
692 if (get_frame_extra_info (fi)->leaf_function)
694 /* Set the register SP to contain the stack pointer of
696 get_frame_saved_regs (fi)[SP_REGNUM] = get_frame_base (fi) + 4;
700 /* Set the register SP to contain the stack pointer of
702 get_frame_saved_regs (fi)[SP_REGNUM] = get_frame_base (fi) + 8;
704 /* Set the register SRP to contain the return address of
706 get_frame_saved_regs (fi)[SRP_REGNUM] = get_frame_base (fi) + 4;
712 /* Advance pc beyond any function entry prologue instructions at pc
713 to reach some "real" code. */
716 cris_skip_prologue (CORE_ADDR pc)
718 return cris_skip_prologue_main (pc, 0);
721 /* As cris_skip_prologue, but stops as soon as it knows that the function
722 has a frame. Its result is equal to its input pc if the function is
723 frameless, unequal otherwise. */
726 cris_skip_prologue_frameless_p (CORE_ADDR pc)
728 return cris_skip_prologue_main (pc, 1);
731 /* Given a PC value corresponding to the start of a function, return the PC
732 of the first instruction after the function prologue. */
735 cris_skip_prologue_main (CORE_ADDR pc, int frameless_p)
737 struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
738 struct frame_info *fi;
739 struct symtab_and_line sal = find_pc_line (pc, 0);
741 CORE_ADDR pc_after_prologue;
743 /* frame_info now contains dynamic memory. Since fi is a dummy
744 here, I don't bother allocating memory for saved_regs. */
745 fi = deprecated_frame_xmalloc_with_cleanup (0, sizeof (struct frame_extra_info));
747 /* If there is no symbol information then sal.end == 0, and we end up
748 examining only the first instruction in the function prologue.
749 Exaggerating the limit seems to be harmless. */
751 best_limit = sal.end;
753 best_limit = pc + 100;
755 pc_after_prologue = cris_examine (pc, best_limit, fi, frameless_p);
756 do_cleanups (old_chain);
757 return pc_after_prologue;
760 /* Use the program counter to determine the contents and size of a breakpoint
761 instruction. It returns a pointer to a string of bytes that encode a
762 breakpoint instruction, stores the length of the string to *lenptr, and
763 adjusts pcptr (if necessary) to point to the actual memory location where
764 the breakpoint should be inserted. */
766 const unsigned char *
767 cris_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
769 static unsigned char break_insn[] = {0x38, 0xe9};
775 /* Returns the register SRP (subroutine return pointer) which must contain
776 the content of the register PC after a function call. */
779 cris_saved_pc_after_call (struct frame_info *frame)
781 return read_register (SRP_REGNUM);
784 /* Returns 1 if spec_reg is applicable to the current gdbarch's CRIS version,
788 cris_spec_reg_applicable (struct cris_spec_reg spec_reg)
790 int version = cris_version ();
792 switch (spec_reg.applicable_version)
794 case cris_ver_version_all:
796 case cris_ver_warning:
797 /* Indeterminate/obsolete. */
800 /* Simulator only. */
803 return (version >= 0 && version <= 3);
805 return (version >= 3);
807 return (version == 8 || version == 9);
809 return (version >= 8);
811 return (version >= 10);
813 /* Invalid cris version. */
818 /* Returns the register size in unit byte. Returns 0 for an unimplemented
819 register, -1 for an invalid register. */
822 cris_register_size (int regno)
827 if (regno >= 0 && regno < NUM_GENREGS)
829 /* General registers (R0 - R15) are 32 bits. */
832 else if (regno >= NUM_GENREGS && regno < NUM_REGS)
834 /* Special register (R16 - R31). cris_spec_regs is zero-based.
835 Adjust regno accordingly. */
836 spec_regno = regno - NUM_GENREGS;
838 /* The entries in cris_spec_regs are stored in register number order,
839 which means we can shortcut into the array when searching it. */
840 for (i = spec_regno; cris_spec_regs[i].name != NULL; i++)
842 if (cris_spec_regs[i].number == spec_regno
843 && cris_spec_reg_applicable (cris_spec_regs[i]))
844 /* Go with the first applicable register. */
845 return cris_spec_regs[i].reg_size;
847 /* Special register not applicable to this CRIS version. */
852 /* Invalid register. */
857 /* Nonzero if regno should not be fetched from the target. This is the case
858 for unimplemented (size 0) and non-existant registers. */
861 cris_cannot_fetch_register (int regno)
863 return ((regno < 0 || regno >= NUM_REGS)
864 || (cris_register_size (regno) == 0));
867 /* Nonzero if regno should not be written to the target, for various
871 cris_cannot_store_register (int regno)
873 /* There are three kinds of registers we refuse to write to.
874 1. Those that not implemented.
875 2. Those that are read-only (depends on the processor mode).
876 3. Those registers to which a write has no effect.
879 if (regno < 0 || regno >= NUM_REGS || cris_register_size (regno) == 0)
880 /* Not implemented. */
883 else if (regno == VR_REGNUM)
887 else if (regno == P0_REGNUM || regno == P4_REGNUM || regno == P8_REGNUM)
888 /* Writing has no effect. */
891 else if (cris_mode () == CRIS_MODE_USER)
893 if (regno == IBR_REGNUM || regno == BAR_REGNUM || regno == BRP_REGNUM
894 || regno == IRP_REGNUM)
895 /* Read-only in user mode. */
902 /* Returns the register offset for the first byte of register regno's space
903 in the saved register state. Returns -1 for an invalid or unimplemented
907 cris_register_offset (int regno)
913 if (regno >= 0 && regno < NUM_REGS)
915 /* FIXME: The offsets should be cached and calculated only once,
916 when the architecture being debugged has changed. */
917 for (i = 0; i < regno; i++)
918 offset += cris_register_size (i);
924 /* Invalid register. */
929 /* Return the GDB type (defined in gdbtypes.c) for the "standard" data type
930 of data in register regno. */
933 cris_register_virtual_type (int regno)
935 if (regno == SP_REGNUM || regno == PC_REGNUM
936 || (regno > P8_REGNUM && regno < USP_REGNUM))
938 /* SP, PC, IBR, IRP, SRP, BAR, DCCR, BRP */
939 return lookup_pointer_type (builtin_type_void);
941 else if (regno == P8_REGNUM || regno == USP_REGNUM
942 || (regno >= 0 && regno < SP_REGNUM))
944 /* R0 - R13, P8, P15 */
945 return builtin_type_unsigned_long;
947 else if (regno > P3_REGNUM && regno < P8_REGNUM)
949 /* P4, CCR, DCR0, DCR1 */
950 return builtin_type_unsigned_short;
952 else if (regno > PC_REGNUM && regno < P4_REGNUM)
955 return builtin_type_unsigned_char;
959 /* Invalid register. */
960 return builtin_type_void;
964 /* Stores a function return value of type type, where valbuf is the address
965 of the value to be stored. */
967 /* In the original CRIS ABI, R10 is used to store return values. */
970 cris_abi_original_store_return_value (struct type *type, char *valbuf)
972 int len = TYPE_LENGTH (type);
974 if (len <= DEPRECATED_REGISTER_SIZE)
975 deprecated_write_register_bytes (REGISTER_BYTE (RET_REGNUM), valbuf, len);
977 internal_error (__FILE__, __LINE__, "cris_abi_original_store_return_value: type length too large.");
980 /* In the CRIS ABI V2, R10 and R11 are used to store return values. */
983 cris_abi_v2_store_return_value (struct type *type, char *valbuf)
985 int len = TYPE_LENGTH (type);
987 if (len <= 2 * DEPRECATED_REGISTER_SIZE)
989 /* Note that this works since R10 and R11 are consecutive registers. */
990 deprecated_write_register_bytes (REGISTER_BYTE (RET_REGNUM), valbuf,
994 internal_error (__FILE__, __LINE__, "cris_abi_v2_store_return_value: type length too large.");
997 /* Return the name of register regno as a string. Return NULL for an invalid or
998 unimplemented register. */
1001 cris_register_name (int regno)
1003 static char *cris_genreg_names[] =
1004 { "r0", "r1", "r2", "r3", \
1005 "r4", "r5", "r6", "r7", \
1006 "r8", "r9", "r10", "r11", \
1007 "r12", "r13", "sp", "pc" };
1012 if (regno >= 0 && regno < NUM_GENREGS)
1014 /* General register. */
1015 return cris_genreg_names[regno];
1017 else if (regno >= NUM_GENREGS && regno < NUM_REGS)
1019 /* Special register (R16 - R31). cris_spec_regs is zero-based.
1020 Adjust regno accordingly. */
1021 spec_regno = regno - NUM_GENREGS;
1023 /* The entries in cris_spec_regs are stored in register number order,
1024 which means we can shortcut into the array when searching it. */
1025 for (i = spec_regno; cris_spec_regs[i].name != NULL; i++)
1027 if (cris_spec_regs[i].number == spec_regno
1028 && cris_spec_reg_applicable (cris_spec_regs[i]))
1029 /* Go with the first applicable register. */
1030 return cris_spec_regs[i].name;
1032 /* Special register not applicable to this CRIS version. */
1037 /* Invalid register. */
1043 cris_register_bytes_ok (long bytes)
1045 return (bytes == DEPRECATED_REGISTER_BYTES);
1048 /* Extract from an array regbuf containing the raw register state a function
1049 return value of type type, and copy that, in virtual format, into
1052 /* In the original CRIS ABI, R10 is used to return values. */
1055 cris_abi_original_extract_return_value (struct type *type, char *regbuf,
1058 int len = TYPE_LENGTH (type);
1060 if (len <= DEPRECATED_REGISTER_SIZE)
1061 memcpy (valbuf, regbuf + REGISTER_BYTE (RET_REGNUM), len);
1063 internal_error (__FILE__, __LINE__, "cris_abi_original_extract_return_value: type length too large");
1066 /* In the CRIS ABI V2, R10 and R11 are used to store return values. */
1069 cris_abi_v2_extract_return_value (struct type *type, char *regbuf,
1072 int len = TYPE_LENGTH (type);
1074 if (len <= 2 * DEPRECATED_REGISTER_SIZE)
1075 memcpy (valbuf, regbuf + REGISTER_BYTE (RET_REGNUM), len);
1077 internal_error (__FILE__, __LINE__, "cris_abi_v2_extract_return_value: type length too large");
1080 /* Store the address of the place in which to copy the structure the
1081 subroutine will return. In the CRIS ABI, R9 is used in order to pass
1082 the address of the allocated area where a structure return value must
1083 be stored. R9 is call-clobbered, which means we must save it here for
1087 cris_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
1089 write_register (STR_REGNUM, addr);
1090 struct_return_address = addr;
1093 /* Extract from regbuf the address where a function should return a
1094 structure value. It's not there in the CRIS ABI, so we must do it another
1098 cris_extract_struct_value_address (char *regbuf)
1100 return struct_return_address;
1103 /* Returns 1 if a value of the given type being returned from a function
1104 must have space allocated for it on the stack. gcc_p is true if the
1105 function being considered is known to have been compiled by GCC.
1106 In the CRIS ABI, structure return values are passed to the called
1107 function by reference in register R9 to a caller-allocated area, so
1108 this is always true. */
1111 cris_use_struct_convention (int gcc_p, struct type *type)
1116 /* Returns 1 if the given type will be passed by pointer rather than
1119 /* In the original CRIS ABI, arguments shorter than or equal to 32 bits are
1123 cris_abi_original_reg_struct_has_addr (int gcc_p, struct type *type)
1125 return (TYPE_LENGTH (type) > 4);
1128 /* In the CRIS ABI V2, arguments shorter than or equal to 64 bits are passed
1132 cris_abi_v2_reg_struct_has_addr (int gcc_p, struct type *type)
1134 return (TYPE_LENGTH (type) > 8);
1137 /* Returns 1 if the function invocation represented by fi does not have a
1138 stack frame associated with it. Otherwise return 0. */
1141 cris_frameless_function_invocation (struct frame_info *fi)
1143 if ((get_frame_type (fi) == SIGTRAMP_FRAME))
1146 return frameless_look_for_prologue (fi);
1149 /* See frame.h. Determines the address of all registers in the
1150 current stack frame storing each in frame->saved_regs. Space for
1151 frame->saved_regs shall be allocated by
1152 DEPRECATED_FRAME_INIT_SAVED_REGS using frame_saved_regs_zalloc. */
1155 cris_frame_init_saved_regs (struct frame_info *fi)
1158 struct symtab_and_line sal;
1160 char *dummy_regs = deprecated_generic_find_dummy_frame (get_frame_pc (fi),
1161 get_frame_base (fi));
1163 /* Examine the entire prologue. */
1164 register int frameless_p = 0;
1166 /* Has this frame's registers already been initialized? */
1167 if (get_frame_saved_regs (fi))
1170 frame_saved_regs_zalloc (fi);
1174 /* I don't see this ever happening, considering the context in which
1175 cris_frame_init_saved_regs is called (always when we're not in
1177 memcpy (get_frame_saved_regs (fi), dummy_regs, SIZEOF_FRAME_SAVED_REGS);
1181 ip = get_frame_func (fi);
1182 sal = find_pc_line (ip, 0);
1184 /* If there is no symbol information then sal.end == 0, and we end up
1185 examining only the first instruction in the function prologue.
1186 Exaggerating the limit seems to be harmless. */
1188 best_limit = sal.end;
1190 best_limit = ip + 100;
1192 cris_examine (ip, best_limit, fi, frameless_p);
1196 /* Initialises the extra frame information at the creation of a new frame.
1197 The inparameter fromleaf is 0 when the call is from create_new_frame.
1198 When the call is from get_prev_frame_info, fromleaf is determined by
1199 cris_frameless_function_invocation. */
1202 cris_init_extra_frame_info (int fromleaf, struct frame_info *fi)
1204 if (get_next_frame (fi))
1206 /* Called from get_prev_frame. */
1207 deprecated_update_frame_pc_hack (fi, DEPRECATED_FRAME_SAVED_PC (get_next_frame (fi)));
1210 frame_extra_info_zalloc (fi, sizeof (struct frame_extra_info));
1212 get_frame_extra_info (fi)->return_pc = 0;
1213 get_frame_extra_info (fi)->leaf_function = 0;
1215 if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi),
1216 get_frame_base (fi),
1217 get_frame_base (fi)))
1219 /* We need to setup fi->frame here because call_function_by_hand
1220 gets it wrong by assuming it's always FP. */
1221 deprecated_update_frame_base_hack (fi, deprecated_read_register_dummy (get_frame_pc (fi), get_frame_base (fi), SP_REGNUM));
1222 get_frame_extra_info (fi)->return_pc =
1223 deprecated_read_register_dummy (get_frame_pc (fi),
1224 get_frame_base (fi), PC_REGNUM);
1226 /* FIXME: Is this necessarily true? */
1227 get_frame_extra_info (fi)->leaf_function = 0;
1231 cris_frame_init_saved_regs (fi);
1233 /* Check fromleaf/frameless_function_invocation. (FIXME) */
1235 if (get_frame_saved_regs (fi)[SRP_REGNUM] != 0)
1237 /* SRP was saved on the stack; non-leaf function. */
1238 get_frame_extra_info (fi)->return_pc =
1239 read_memory_integer (get_frame_saved_regs (fi)[SRP_REGNUM],
1240 REGISTER_RAW_SIZE (SRP_REGNUM));
1244 /* SRP is still in a register; leaf function. */
1245 get_frame_extra_info (fi)->return_pc = read_register (SRP_REGNUM);
1246 /* FIXME: Should leaf_function be set to 1 here? */
1247 get_frame_extra_info (fi)->leaf_function = 1;
1252 /* Return the content of the frame pointer in the present frame. In other
1253 words, determine the address of the calling function's frame. */
1256 cris_frame_chain (struct frame_info *fi)
1258 if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi),
1259 get_frame_base (fi),
1260 get_frame_base (fi)))
1262 return get_frame_base (fi);
1264 else if (!inside_entry_file (get_frame_pc (fi)))
1266 return read_memory_unsigned_integer (get_frame_base (fi), 4);
1274 /* Return the saved PC (which equals the return address) of this frame. */
1277 cris_frame_saved_pc (struct frame_info *fi)
1279 return get_frame_extra_info (fi)->return_pc;
1282 /* Setup the function arguments for calling a function in the inferior. */
1285 cris_abi_original_push_arguments (int nargs, struct value **args,
1286 CORE_ADDR sp, int struct_return,
1287 CORE_ADDR struct_addr)
1298 /* Data and parameters reside in different areas on the stack.
1299 Both frame pointers grow toward higher addresses. */
1300 CORE_ADDR fp_params;
1303 /* Are we returning a value using a structure return or a normal value
1304 return? struct_addr is the address of the reserved space for the return
1305 structure to be written on the stack. */
1308 write_register (STR_REGNUM, struct_addr);
1311 /* Make sure there's space on the stack. Allocate space for data and a
1312 parameter to refer to that data. */
1313 for (argnum = 0, stack_alloc = 0; argnum < nargs; argnum++)
1314 stack_alloc += (TYPE_LENGTH (VALUE_TYPE (args[argnum])) + DEPRECATED_REGISTER_SIZE);
1316 /* We may over-allocate a little here, but that won't hurt anything. */
1318 /* Initialize stack frame pointers. */
1320 fp_data = sp + (nargs * DEPRECATED_REGISTER_SIZE);
1322 /* Now load as many as possible of the first arguments into
1323 registers, and push the rest onto the stack. */
1324 argreg = ARG1_REGNUM;
1327 for (argnum = 0; argnum < nargs; argnum++)
1329 type = VALUE_TYPE (args[argnum]);
1330 len = TYPE_LENGTH (type);
1331 val = (char *) VALUE_CONTENTS (args[argnum]);
1333 if (len <= DEPRECATED_REGISTER_SIZE && argreg <= ARG4_REGNUM)
1335 /* Data fits in a register; put it in the first available
1337 write_register (argreg, *(unsigned long *) val);
1340 else if (len > DEPRECATED_REGISTER_SIZE && argreg <= ARG4_REGNUM)
1342 /* Data does not fit in register; pass it on the stack and
1343 put its address in the first available register. */
1344 write_memory (fp_data, val, len);
1345 write_register (argreg, fp_data);
1349 else if (len > DEPRECATED_REGISTER_SIZE)
1351 /* Data does not fit in register; put both data and
1352 parameter on the stack. */
1353 write_memory (fp_data, val, len);
1354 write_memory (fp_params, (char *) (&fp_data), DEPRECATED_REGISTER_SIZE);
1356 fp_params += DEPRECATED_REGISTER_SIZE;
1360 /* Data fits in a register, but we are out of registers;
1361 put the parameter on the stack. */
1362 write_memory (fp_params, val, DEPRECATED_REGISTER_SIZE);
1363 fp_params += DEPRECATED_REGISTER_SIZE;
1371 cris_abi_v2_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
1372 int struct_return, CORE_ADDR struct_addr)
1381 /* The function's arguments and memory allocated by gdb for the arguments to
1382 point at reside in separate areas on the stack.
1383 Both frame pointers grow toward higher addresses. */
1387 /* Are we returning a value using a structure return or a normal value
1388 return? struct_addr is the address of the reserved space for the return
1389 structure to be written on the stack. */
1392 write_register (STR_REGNUM, struct_addr);
1395 /* Allocate enough to keep things word-aligned on both parts of the
1398 for (argnum = 0; argnum < nargs; argnum++)
1403 len = TYPE_LENGTH (VALUE_TYPE (args[argnum]));
1404 reg_demand = (len / DEPRECATED_REGISTER_SIZE) + (len % DEPRECATED_REGISTER_SIZE != 0 ? 1 : 0);
1406 /* reg_demand * DEPRECATED_REGISTER_SIZE is the amount of memory
1407 we might need to allocate for this argument. 2 *
1408 DEPRECATED_REGISTER_SIZE is the amount of stack space we
1409 might need to pass the argument itself (either by value or by
1411 stack_alloc += (reg_demand * DEPRECATED_REGISTER_SIZE + 2 * DEPRECATED_REGISTER_SIZE);
1414 /* We may over-allocate a little here, but that won't hurt anything. */
1416 /* Initialize frame pointers. */
1418 fp_mem = sp + (nargs * (2 * DEPRECATED_REGISTER_SIZE));
1420 /* Now load as many as possible of the first arguments into registers,
1421 and push the rest onto the stack. */
1422 argreg = ARG1_REGNUM;
1425 for (argnum = 0; argnum < nargs; argnum++)
1432 len = TYPE_LENGTH (VALUE_TYPE (args[argnum]));
1433 val = (char *) VALUE_CONTENTS (args[argnum]);
1435 /* How may registers worth of storage do we need for this argument? */
1436 reg_demand = (len / DEPRECATED_REGISTER_SIZE) + (len % DEPRECATED_REGISTER_SIZE != 0 ? 1 : 0);
1438 if (len <= (2 * DEPRECATED_REGISTER_SIZE)
1439 && (argreg + reg_demand - 1 <= ARG4_REGNUM))
1441 /* Data passed by value. Fits in available register(s). */
1442 for (i = 0; i < reg_demand; i++)
1444 write_register (argreg, *(unsigned long *) val);
1446 val += DEPRECATED_REGISTER_SIZE;
1449 else if (len <= (2 * DEPRECATED_REGISTER_SIZE) && argreg <= ARG4_REGNUM)
1451 /* Data passed by value. Does not fit in available register(s).
1452 Use the register(s) first, then the stack. */
1453 for (i = 0; i < reg_demand; i++)
1455 if (argreg <= ARG4_REGNUM)
1457 write_register (argreg, *(unsigned long *) val);
1459 val += DEPRECATED_REGISTER_SIZE;
1463 /* I guess this memory write could write the
1464 remaining data all at once instead of in
1465 DEPRECATED_REGISTER_SIZE chunks. */
1466 write_memory (fp_arg, val, DEPRECATED_REGISTER_SIZE);
1467 fp_arg += DEPRECATED_REGISTER_SIZE;
1468 val += DEPRECATED_REGISTER_SIZE;
1472 else if (len > (2 * DEPRECATED_REGISTER_SIZE))
1474 /* Data passed by reference. Put it on the stack. */
1475 write_memory (fp_mem, val, len);
1476 write_memory (fp_arg, (char *) (&fp_mem), DEPRECATED_REGISTER_SIZE);
1478 /* fp_mem need not be word-aligned since it's just a chunk of
1479 memory being pointed at. That is, += len would do. */
1480 fp_mem += reg_demand * DEPRECATED_REGISTER_SIZE;
1481 fp_arg += DEPRECATED_REGISTER_SIZE;
1485 /* Data passed by value. No available registers. Put it on
1487 write_memory (fp_arg, val, len);
1489 /* fp_arg must be word-aligned (i.e., don't += len) to match
1490 the function prologue. */
1491 fp_arg += reg_demand * DEPRECATED_REGISTER_SIZE;
1498 /* Never put the return address on the stack. The register SRP is pushed
1499 by the called function unless it is a leaf-function. Due to the BRP
1500 register the PC will change when continue is sent. */
1503 cris_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
1505 write_register (SRP_REGNUM, CALL_DUMMY_ADDRESS ());
1509 /* Restore the machine to the state it had before the current frame
1510 was created. Discard the innermost frame from the stack and restore
1511 all saved registers. */
1514 cris_pop_frame (void)
1516 register struct frame_info *fi = get_current_frame ();
1518 register int stack_offset = 0;
1520 if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi),
1521 get_frame_base (fi),
1522 get_frame_base (fi)))
1524 /* This happens when we hit a breakpoint set at the entry point,
1525 when returning from a dummy frame. */
1526 generic_pop_dummy_frame ();
1530 cris_frame_init_saved_regs (fi);
1532 /* For each register, the address of where it was saved on entry to
1533 the frame now lies in fi->saved_regs[regno], or zero if it was not
1534 saved. This includes special registers such as PC and FP saved in
1535 special ways in the stack frame. The SP_REGNUM is even more
1536 special, the address here is the SP for the next frame, not the
1537 address where the SP was saved. */
1539 /* Restore general registers R0 - R7. They were pushed on the stack
1540 after SP was saved. */
1541 for (regno = 0; regno < DEPRECATED_FP_REGNUM; regno++)
1543 if (get_frame_saved_regs (fi)[regno])
1545 write_register (regno,
1546 read_memory_integer (get_frame_saved_regs (fi)[regno], 4));
1550 if (get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM])
1552 /* Pop the frame pointer (R8). It was pushed before SP
1554 write_register (DEPRECATED_FP_REGNUM,
1555 read_memory_integer (get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM], 4));
1558 /* Not a leaf function. */
1559 if (get_frame_saved_regs (fi)[SRP_REGNUM])
1561 /* SRP was pushed before SP was saved. */
1565 /* Restore the SP and adjust for R8 and (possibly) SRP. */
1566 write_register (SP_REGNUM, get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM] + stack_offset);
1570 /* Currently, we can't get the correct info into fi->saved_regs
1571 without a frame pointer. */
1574 /* Restore the PC. */
1575 write_register (PC_REGNUM, get_frame_extra_info (fi)->return_pc);
1577 flush_cached_frames ();
1580 /* Calculates a value that measures how good inst_args constraints an
1581 instruction. It stems from cris_constraint, found in cris-dis.c. */
1584 constraint (unsigned int insn, const signed char *inst_args,
1585 inst_env_type *inst_env)
1590 const char *s = inst_args;
1596 if ((insn & 0x30) == 0x30)
1601 /* A prefix operand. */
1602 if (inst_env->prefix_found)
1608 /* A "push" prefix. (This check was REMOVED by san 970921.) Check for
1609 valid "push" size. In case of special register, it may be != 4. */
1610 if (inst_env->prefix_found)
1616 retval = (((insn >> 0xC) & 0xF) == (insn & 0xF));
1624 tmp = (insn >> 0xC) & 0xF;
1626 for (i = 0; cris_spec_regs[i].name != NULL; i++)
1628 /* Since we match four bits, we will give a value of
1629 4 - 1 = 3 in a match. If there is a corresponding
1630 exact match of a special register in another pattern, it
1631 will get a value of 4, which will be higher. This should
1632 be correct in that an exact pattern would match better that
1634 Note that there is a reason for not returning zero; the
1635 pattern for "clear" is partly matched in the bit-pattern
1636 (the two lower bits must be zero), while the bit-pattern
1637 for a move from a special register is matched in the
1638 register constraint.
1639 This also means we will will have a race condition if
1640 there is a partly match in three bits in the bit pattern. */
1641 if (tmp == cris_spec_regs[i].number)
1648 if (cris_spec_regs[i].name == NULL)
1655 /* Returns the number of bits set in the variable value. */
1658 number_of_bits (unsigned int value)
1660 int number_of_bits = 0;
1664 number_of_bits += 1;
1665 value &= (value - 1);
1667 return number_of_bits;
1670 /* Finds the address that should contain the single step breakpoint(s).
1671 It stems from code in cris-dis.c. */
1674 find_cris_op (unsigned short insn, inst_env_type *inst_env)
1677 int max_level_of_match = -1;
1678 int max_matched = -1;
1681 for (i = 0; cris_opcodes[i].name != NULL; i++)
1683 if (((cris_opcodes[i].match & insn) == cris_opcodes[i].match)
1684 && ((cris_opcodes[i].lose & insn) == 0))
1686 level_of_match = constraint (insn, cris_opcodes[i].args, inst_env);
1687 if (level_of_match >= 0)
1690 number_of_bits (cris_opcodes[i].match | cris_opcodes[i].lose);
1691 if (level_of_match > max_level_of_match)
1694 max_level_of_match = level_of_match;
1695 if (level_of_match == 16)
1697 /* All bits matched, cannot find better. */
1707 /* Attempts to find single-step breakpoints. Returns -1 on failure which is
1708 actually an internal error. */
1711 find_step_target (inst_env_type *inst_env)
1715 unsigned short insn;
1717 /* Create a local register image and set the initial state. */
1718 for (i = 0; i < NUM_GENREGS; i++)
1720 inst_env->reg[i] = (unsigned long) read_register (i);
1722 offset = NUM_GENREGS;
1723 for (i = 0; i < NUM_SPECREGS; i++)
1725 inst_env->preg[i] = (unsigned long) read_register (offset + i);
1727 inst_env->branch_found = 0;
1728 inst_env->slot_needed = 0;
1729 inst_env->delay_slot_pc_active = 0;
1730 inst_env->prefix_found = 0;
1731 inst_env->invalid = 0;
1732 inst_env->xflag_found = 0;
1733 inst_env->disable_interrupt = 0;
1735 /* Look for a step target. */
1738 /* Read an instruction from the client. */
1739 insn = read_memory_unsigned_integer (inst_env->reg[PC_REGNUM], 2);
1741 /* If the instruction is not in a delay slot the new content of the
1742 PC is [PC] + 2. If the instruction is in a delay slot it is not
1743 that simple. Since a instruction in a delay slot cannot change
1744 the content of the PC, it does not matter what value PC will have.
1745 Just make sure it is a valid instruction. */
1746 if (!inst_env->delay_slot_pc_active)
1748 inst_env->reg[PC_REGNUM] += 2;
1752 inst_env->delay_slot_pc_active = 0;
1753 inst_env->reg[PC_REGNUM] = inst_env->delay_slot_pc;
1755 /* Analyse the present instruction. */
1756 i = find_cris_op (insn, inst_env);
1759 inst_env->invalid = 1;
1763 cris_gdb_func (cris_opcodes[i].op, insn, inst_env);
1765 } while (!inst_env->invalid
1766 && (inst_env->prefix_found || inst_env->xflag_found
1767 || inst_env->slot_needed));
1771 /* There is no hardware single-step support. The function find_step_target
1772 digs through the opcodes in order to find all possible targets.
1773 Either one ordinary target or two targets for branches may be found. */
1776 cris_software_single_step (enum target_signal ignore, int insert_breakpoints)
1778 inst_env_type inst_env;
1780 if (insert_breakpoints)
1782 /* Analyse the present instruction environment and insert
1784 int status = find_step_target (&inst_env);
1787 /* Could not find a target. FIXME: Should do something. */
1791 /* Insert at most two breakpoints. One for the next PC content
1792 and possibly another one for a branch, jump, etc. */
1793 next_pc = (CORE_ADDR) inst_env.reg[PC_REGNUM];
1794 target_insert_breakpoint (next_pc, break_mem[0]);
1795 if (inst_env.branch_found
1796 && (CORE_ADDR) inst_env.branch_break_address != next_pc)
1798 branch_target_address =
1799 (CORE_ADDR) inst_env.branch_break_address;
1800 target_insert_breakpoint (branch_target_address, break_mem[1]);
1801 branch_break_inserted = 1;
1807 /* Remove breakpoints. */
1808 target_remove_breakpoint (next_pc, break_mem[0]);
1809 if (branch_break_inserted)
1811 target_remove_breakpoint (branch_target_address, break_mem[1]);
1812 branch_break_inserted = 0;
1817 /* Calculates the prefix value for quick offset addressing mode. */
1820 quick_mode_bdap_prefix (unsigned short inst, inst_env_type *inst_env)
1822 /* It's invalid to be in a delay slot. You can't have a prefix to this
1823 instruction (not 100% sure). */
1824 if (inst_env->slot_needed || inst_env->prefix_found)
1826 inst_env->invalid = 1;
1830 inst_env->prefix_value = inst_env->reg[cris_get_operand2 (inst)];
1831 inst_env->prefix_value += cris_get_bdap_quick_offset (inst);
1833 /* A prefix doesn't change the xflag_found. But the rest of the flags
1835 inst_env->slot_needed = 0;
1836 inst_env->prefix_found = 1;
1839 /* Updates the autoincrement register. The size of the increment is derived
1840 from the size of the operation. The PC is always kept aligned on even
1844 process_autoincrement (int size, unsigned short inst, inst_env_type *inst_env)
1846 if (size == INST_BYTE_SIZE)
1848 inst_env->reg[cris_get_operand1 (inst)] += 1;
1850 /* The PC must be word aligned, so increase the PC with one
1851 word even if the size is byte. */
1852 if (cris_get_operand1 (inst) == REG_PC)
1854 inst_env->reg[REG_PC] += 1;
1857 else if (size == INST_WORD_SIZE)
1859 inst_env->reg[cris_get_operand1 (inst)] += 2;
1861 else if (size == INST_DWORD_SIZE)
1863 inst_env->reg[cris_get_operand1 (inst)] += 4;
1868 inst_env->invalid = 1;
1872 /* Just a forward declaration. */
1874 unsigned long get_data_from_address (unsigned short *inst, CORE_ADDR address);
1876 /* Calculates the prefix value for the general case of offset addressing
1880 bdap_prefix (unsigned short inst, inst_env_type *inst_env)
1885 /* It's invalid to be in a delay slot. */
1886 if (inst_env->slot_needed || inst_env->prefix_found)
1888 inst_env->invalid = 1;
1892 /* The calculation of prefix_value used to be after process_autoincrement,
1893 but that fails for an instruction such as jsr [$r0+12] which is encoded
1894 as 5f0d 0c00 30b9 when compiled with -fpic. Since PC is operand1 it
1895 mustn't be incremented until we have read it and what it points at. */
1896 inst_env->prefix_value = inst_env->reg[cris_get_operand2 (inst)];
1898 /* The offset is an indirection of the contents of the operand1 register. */
1899 inst_env->prefix_value +=
1900 get_data_from_address (&inst, inst_env->reg[cris_get_operand1 (inst)]);
1902 if (cris_get_mode (inst) == AUTOINC_MODE)
1904 process_autoincrement (cris_get_size (inst), inst, inst_env);
1907 /* A prefix doesn't change the xflag_found. But the rest of the flags
1909 inst_env->slot_needed = 0;
1910 inst_env->prefix_found = 1;
1913 /* Calculates the prefix value for the index addressing mode. */
1916 biap_prefix (unsigned short inst, inst_env_type *inst_env)
1918 /* It's invalid to be in a delay slot. I can't see that it's possible to
1919 have a prefix to this instruction. So I will treat this as invalid. */
1920 if (inst_env->slot_needed || inst_env->prefix_found)
1922 inst_env->invalid = 1;
1926 inst_env->prefix_value = inst_env->reg[cris_get_operand1 (inst)];
1928 /* The offset is the operand2 value shifted the size of the instruction
1930 inst_env->prefix_value +=
1931 inst_env->reg[cris_get_operand2 (inst)] << cris_get_size (inst);
1933 /* If the PC is operand1 (base) the address used is the address after
1934 the main instruction, i.e. address + 2 (the PC is already compensated
1935 for the prefix operation). */
1936 if (cris_get_operand1 (inst) == REG_PC)
1938 inst_env->prefix_value += 2;
1941 /* A prefix doesn't change the xflag_found. But the rest of the flags
1943 inst_env->slot_needed = 0;
1944 inst_env->xflag_found = 0;
1945 inst_env->prefix_found = 1;
1948 /* Calculates the prefix value for the double indirect addressing mode. */
1951 dip_prefix (unsigned short inst, inst_env_type *inst_env)
1956 /* It's invalid to be in a delay slot. */
1957 if (inst_env->slot_needed || inst_env->prefix_found)
1959 inst_env->invalid = 1;
1963 /* The prefix value is one dereference of the contents of the operand1
1965 address = (CORE_ADDR) inst_env->reg[cris_get_operand1 (inst)];
1966 inst_env->prefix_value = read_memory_unsigned_integer (address, 4);
1968 /* Check if the mode is autoincrement. */
1969 if (cris_get_mode (inst) == AUTOINC_MODE)
1971 inst_env->reg[cris_get_operand1 (inst)] += 4;
1974 /* A prefix doesn't change the xflag_found. But the rest of the flags
1976 inst_env->slot_needed = 0;
1977 inst_env->xflag_found = 0;
1978 inst_env->prefix_found = 1;
1981 /* Finds the destination for a branch with 8-bits offset. */
1984 eight_bit_offset_branch_op (unsigned short inst, inst_env_type *inst_env)
1989 /* If we have a prefix or are in a delay slot it's bad. */
1990 if (inst_env->slot_needed || inst_env->prefix_found)
1992 inst_env->invalid = 1;
1996 /* We have a branch, find out where the branch will land. */
1997 offset = cris_get_branch_short_offset (inst);
1999 /* Check if the offset is signed. */
2000 if (offset & BRANCH_SIGNED_SHORT_OFFSET_MASK)
2005 /* The offset ends with the sign bit, set it to zero. The address
2006 should always be word aligned. */
2007 offset &= ~BRANCH_SIGNED_SHORT_OFFSET_MASK;
2009 inst_env->branch_found = 1;
2010 inst_env->branch_break_address = inst_env->reg[REG_PC] + offset;
2012 inst_env->slot_needed = 1;
2013 inst_env->prefix_found = 0;
2014 inst_env->xflag_found = 0;
2015 inst_env->disable_interrupt = 1;
2018 /* Finds the destination for a branch with 16-bits offset. */
2021 sixteen_bit_offset_branch_op (unsigned short inst, inst_env_type *inst_env)
2025 /* If we have a prefix or is in a delay slot it's bad. */
2026 if (inst_env->slot_needed || inst_env->prefix_found)
2028 inst_env->invalid = 1;
2032 /* We have a branch, find out the offset for the branch. */
2033 offset = read_memory_integer (inst_env->reg[REG_PC], 2);
2035 /* The instruction is one word longer than normal, so add one word
2037 inst_env->reg[REG_PC] += 2;
2039 inst_env->branch_found = 1;
2040 inst_env->branch_break_address = inst_env->reg[REG_PC] + offset;
2043 inst_env->slot_needed = 1;
2044 inst_env->prefix_found = 0;
2045 inst_env->xflag_found = 0;
2046 inst_env->disable_interrupt = 1;
2049 /* Handles the ABS instruction. */
2052 abs_op (unsigned short inst, inst_env_type *inst_env)
2057 /* ABS can't have a prefix, so it's bad if it does. */
2058 if (inst_env->prefix_found)
2060 inst_env->invalid = 1;
2064 /* Check if the operation affects the PC. */
2065 if (cris_get_operand2 (inst) == REG_PC)
2068 /* It's invalid to change to the PC if we are in a delay slot. */
2069 if (inst_env->slot_needed)
2071 inst_env->invalid = 1;
2075 value = (long) inst_env->reg[REG_PC];
2077 /* The value of abs (SIGNED_DWORD_MASK) is SIGNED_DWORD_MASK. */
2078 if (value != SIGNED_DWORD_MASK)
2081 inst_env->reg[REG_PC] = (long) value;
2085 inst_env->slot_needed = 0;
2086 inst_env->prefix_found = 0;
2087 inst_env->xflag_found = 0;
2088 inst_env->disable_interrupt = 0;
2091 /* Handles the ADDI instruction. */
2094 addi_op (unsigned short inst, inst_env_type *inst_env)
2096 /* It's invalid to have the PC as base register. And ADDI can't have
2098 if (inst_env->prefix_found || (cris_get_operand1 (inst) == REG_PC))
2100 inst_env->invalid = 1;
2104 inst_env->slot_needed = 0;
2105 inst_env->prefix_found = 0;
2106 inst_env->xflag_found = 0;
2107 inst_env->disable_interrupt = 0;
2110 /* Handles the ASR instruction. */
2113 asr_op (unsigned short inst, inst_env_type *inst_env)
2116 unsigned long value;
2117 unsigned long signed_extend_mask = 0;
2119 /* ASR can't have a prefix, so check that it doesn't. */
2120 if (inst_env->prefix_found)
2122 inst_env->invalid = 1;
2126 /* Check if the PC is the target register. */
2127 if (cris_get_operand2 (inst) == REG_PC)
2129 /* It's invalid to change the PC in a delay slot. */
2130 if (inst_env->slot_needed)
2132 inst_env->invalid = 1;
2135 /* Get the number of bits to shift. */
2136 shift_steps = cris_get_asr_shift_steps (inst_env->reg[cris_get_operand1 (inst)]);
2137 value = inst_env->reg[REG_PC];
2139 /* Find out how many bits the operation should apply to. */
2140 if (cris_get_size (inst) == INST_BYTE_SIZE)
2142 if (value & SIGNED_BYTE_MASK)
2144 signed_extend_mask = 0xFF;
2145 signed_extend_mask = signed_extend_mask >> shift_steps;
2146 signed_extend_mask = ~signed_extend_mask;
2148 value = value >> shift_steps;
2149 value |= signed_extend_mask;
2151 inst_env->reg[REG_PC] &= 0xFFFFFF00;
2152 inst_env->reg[REG_PC] |= value;
2154 else if (cris_get_size (inst) == INST_WORD_SIZE)
2156 if (value & SIGNED_WORD_MASK)
2158 signed_extend_mask = 0xFFFF;
2159 signed_extend_mask = signed_extend_mask >> shift_steps;
2160 signed_extend_mask = ~signed_extend_mask;
2162 value = value >> shift_steps;
2163 value |= signed_extend_mask;
2165 inst_env->reg[REG_PC] &= 0xFFFF0000;
2166 inst_env->reg[REG_PC] |= value;
2168 else if (cris_get_size (inst) == INST_DWORD_SIZE)
2170 if (value & SIGNED_DWORD_MASK)
2172 signed_extend_mask = 0xFFFFFFFF;
2173 signed_extend_mask = signed_extend_mask >> shift_steps;
2174 signed_extend_mask = ~signed_extend_mask;
2176 value = value >> shift_steps;
2177 value |= signed_extend_mask;
2178 inst_env->reg[REG_PC] = value;
2181 inst_env->slot_needed = 0;
2182 inst_env->prefix_found = 0;
2183 inst_env->xflag_found = 0;
2184 inst_env->disable_interrupt = 0;
2187 /* Handles the ASRQ instruction. */
2190 asrq_op (unsigned short inst, inst_env_type *inst_env)
2194 unsigned long value;
2195 unsigned long signed_extend_mask = 0;
2197 /* ASRQ can't have a prefix, so check that it doesn't. */
2198 if (inst_env->prefix_found)
2200 inst_env->invalid = 1;
2204 /* Check if the PC is the target register. */
2205 if (cris_get_operand2 (inst) == REG_PC)
2208 /* It's invalid to change the PC in a delay slot. */
2209 if (inst_env->slot_needed)
2211 inst_env->invalid = 1;
2214 /* The shift size is given as a 5 bit quick value, i.e. we don't
2215 want the the sign bit of the quick value. */
2216 shift_steps = cris_get_asr_shift_steps (inst);
2217 value = inst_env->reg[REG_PC];
2218 if (value & SIGNED_DWORD_MASK)
2220 signed_extend_mask = 0xFFFFFFFF;
2221 signed_extend_mask = signed_extend_mask >> shift_steps;
2222 signed_extend_mask = ~signed_extend_mask;
2224 value = value >> shift_steps;
2225 value |= signed_extend_mask;
2226 inst_env->reg[REG_PC] = value;
2228 inst_env->slot_needed = 0;
2229 inst_env->prefix_found = 0;
2230 inst_env->xflag_found = 0;
2231 inst_env->disable_interrupt = 0;
2234 /* Handles the AX, EI and SETF instruction. */
2237 ax_ei_setf_op (unsigned short inst, inst_env_type *inst_env)
2239 if (inst_env->prefix_found)
2241 inst_env->invalid = 1;
2244 /* Check if the instruction is setting the X flag. */
2245 if (cris_is_xflag_bit_on (inst))
2247 inst_env->xflag_found = 1;
2251 inst_env->xflag_found = 0;
2253 inst_env->slot_needed = 0;
2254 inst_env->prefix_found = 0;
2255 inst_env->disable_interrupt = 1;
2258 /* Checks if the instruction is in assign mode. If so, it updates the assign
2259 register. Note that check_assign assumes that the caller has checked that
2260 there is a prefix to this instruction. The mode check depends on this. */
2263 check_assign (unsigned short inst, inst_env_type *inst_env)
2265 /* Check if it's an assign addressing mode. */
2266 if (cris_get_mode (inst) == PREFIX_ASSIGN_MODE)
2268 /* Assign the prefix value to operand 1. */
2269 inst_env->reg[cris_get_operand1 (inst)] = inst_env->prefix_value;
2273 /* Handles the 2-operand BOUND instruction. */
2276 two_operand_bound_op (unsigned short inst, inst_env_type *inst_env)
2278 /* It's invalid to have the PC as the index operand. */
2279 if (cris_get_operand2 (inst) == REG_PC)
2281 inst_env->invalid = 1;
2284 /* Check if we have a prefix. */
2285 if (inst_env->prefix_found)
2287 check_assign (inst, inst_env);
2289 /* Check if this is an autoincrement mode. */
2290 else if (cris_get_mode (inst) == AUTOINC_MODE)
2292 /* It's invalid to change the PC in a delay slot. */
2293 if (inst_env->slot_needed)
2295 inst_env->invalid = 1;
2298 process_autoincrement (cris_get_size (inst), inst, inst_env);
2300 inst_env->slot_needed = 0;
2301 inst_env->prefix_found = 0;
2302 inst_env->xflag_found = 0;
2303 inst_env->disable_interrupt = 0;
2306 /* Handles the 3-operand BOUND instruction. */
2309 three_operand_bound_op (unsigned short inst, inst_env_type *inst_env)
2311 /* It's an error if we haven't got a prefix. And it's also an error
2312 if the PC is the destination register. */
2313 if ((!inst_env->prefix_found) || (cris_get_operand1 (inst) == REG_PC))
2315 inst_env->invalid = 1;
2318 inst_env->slot_needed = 0;
2319 inst_env->prefix_found = 0;
2320 inst_env->xflag_found = 0;
2321 inst_env->disable_interrupt = 0;
2324 /* Clears the status flags in inst_env. */
2327 btst_nop_op (unsigned short inst, inst_env_type *inst_env)
2329 /* It's an error if we have got a prefix. */
2330 if (inst_env->prefix_found)
2332 inst_env->invalid = 1;
2336 inst_env->slot_needed = 0;
2337 inst_env->prefix_found = 0;
2338 inst_env->xflag_found = 0;
2339 inst_env->disable_interrupt = 0;
2342 /* Clears the status flags in inst_env. */
2345 clearf_di_op (unsigned short inst, inst_env_type *inst_env)
2347 /* It's an error if we have got a prefix. */
2348 if (inst_env->prefix_found)
2350 inst_env->invalid = 1;
2354 inst_env->slot_needed = 0;
2355 inst_env->prefix_found = 0;
2356 inst_env->xflag_found = 0;
2357 inst_env->disable_interrupt = 1;
2360 /* Handles the CLEAR instruction if it's in register mode. */
2363 reg_mode_clear_op (unsigned short inst, inst_env_type *inst_env)
2365 /* Check if the target is the PC. */
2366 if (cris_get_operand2 (inst) == REG_PC)
2368 /* The instruction will clear the instruction's size bits. */
2369 int clear_size = cris_get_clear_size (inst);
2370 if (clear_size == INST_BYTE_SIZE)
2372 inst_env->delay_slot_pc = inst_env->reg[REG_PC] & 0xFFFFFF00;
2374 if (clear_size == INST_WORD_SIZE)
2376 inst_env->delay_slot_pc = inst_env->reg[REG_PC] & 0xFFFF0000;
2378 if (clear_size == INST_DWORD_SIZE)
2380 inst_env->delay_slot_pc = 0x0;
2382 /* The jump will be delayed with one delay slot. So we need a delay
2384 inst_env->slot_needed = 1;
2385 inst_env->delay_slot_pc_active = 1;
2389 /* The PC will not change => no delay slot. */
2390 inst_env->slot_needed = 0;
2392 inst_env->prefix_found = 0;
2393 inst_env->xflag_found = 0;
2394 inst_env->disable_interrupt = 0;
2397 /* Handles the TEST instruction if it's in register mode. */
2400 reg_mode_test_op (unsigned short inst, inst_env_type *inst_env)
2402 /* It's an error if we have got a prefix. */
2403 if (inst_env->prefix_found)
2405 inst_env->invalid = 1;
2408 inst_env->slot_needed = 0;
2409 inst_env->prefix_found = 0;
2410 inst_env->xflag_found = 0;
2411 inst_env->disable_interrupt = 0;
2415 /* Handles the CLEAR and TEST instruction if the instruction isn't
2416 in register mode. */
2419 none_reg_mode_clear_test_op (unsigned short inst, inst_env_type *inst_env)
2421 /* Check if we are in a prefix mode. */
2422 if (inst_env->prefix_found)
2424 /* The only way the PC can change is if this instruction is in
2425 assign addressing mode. */
2426 check_assign (inst, inst_env);
2428 /* Indirect mode can't change the PC so just check if the mode is
2430 else if (cris_get_mode (inst) == AUTOINC_MODE)
2432 process_autoincrement (cris_get_size (inst), inst, inst_env);
2434 inst_env->slot_needed = 0;
2435 inst_env->prefix_found = 0;
2436 inst_env->xflag_found = 0;
2437 inst_env->disable_interrupt = 0;
2440 /* Checks that the PC isn't the destination register or the instructions has
2444 dstep_logshift_mstep_neg_not_op (unsigned short inst, inst_env_type *inst_env)
2446 /* It's invalid to have the PC as the destination. The instruction can't
2448 if ((cris_get_operand2 (inst) == REG_PC) || inst_env->prefix_found)
2450 inst_env->invalid = 1;
2454 inst_env->slot_needed = 0;
2455 inst_env->prefix_found = 0;
2456 inst_env->xflag_found = 0;
2457 inst_env->disable_interrupt = 0;
2460 /* Checks that the instruction doesn't have a prefix. */
2463 break_op (unsigned short inst, inst_env_type *inst_env)
2465 /* The instruction can't have a prefix. */
2466 if (inst_env->prefix_found)
2468 inst_env->invalid = 1;
2472 inst_env->slot_needed = 0;
2473 inst_env->prefix_found = 0;
2474 inst_env->xflag_found = 0;
2475 inst_env->disable_interrupt = 1;
2478 /* Checks that the PC isn't the destination register and that the instruction
2479 doesn't have a prefix. */
2482 scc_op (unsigned short inst, inst_env_type *inst_env)
2484 /* It's invalid to have the PC as the destination. The instruction can't
2486 if ((cris_get_operand2 (inst) == REG_PC) || inst_env->prefix_found)
2488 inst_env->invalid = 1;
2492 inst_env->slot_needed = 0;
2493 inst_env->prefix_found = 0;
2494 inst_env->xflag_found = 0;
2495 inst_env->disable_interrupt = 1;
2498 /* Handles the register mode JUMP instruction. */
2501 reg_mode_jump_op (unsigned short inst, inst_env_type *inst_env)
2503 /* It's invalid to do a JUMP in a delay slot. The mode is register, so
2504 you can't have a prefix. */
2505 if ((inst_env->slot_needed) || (inst_env->prefix_found))
2507 inst_env->invalid = 1;
2511 /* Just change the PC. */
2512 inst_env->reg[REG_PC] = inst_env->reg[cris_get_operand1 (inst)];
2513 inst_env->slot_needed = 0;
2514 inst_env->prefix_found = 0;
2515 inst_env->xflag_found = 0;
2516 inst_env->disable_interrupt = 1;
2519 /* Handles the JUMP instruction for all modes except register. */
2521 void none_reg_mode_jump_op (unsigned short inst, inst_env_type *inst_env)
2523 unsigned long newpc;
2526 /* It's invalid to do a JUMP in a delay slot. */
2527 if (inst_env->slot_needed)
2529 inst_env->invalid = 1;
2533 /* Check if we have a prefix. */
2534 if (inst_env->prefix_found)
2536 check_assign (inst, inst_env);
2538 /* Get the new value for the the PC. */
2540 read_memory_unsigned_integer ((CORE_ADDR) inst_env->prefix_value,
2545 /* Get the new value for the PC. */
2546 address = (CORE_ADDR) inst_env->reg[cris_get_operand1 (inst)];
2547 newpc = read_memory_unsigned_integer (address, 4);
2549 /* Check if we should increment a register. */
2550 if (cris_get_mode (inst) == AUTOINC_MODE)
2552 inst_env->reg[cris_get_operand1 (inst)] += 4;
2555 inst_env->reg[REG_PC] = newpc;
2557 inst_env->slot_needed = 0;
2558 inst_env->prefix_found = 0;
2559 inst_env->xflag_found = 0;
2560 inst_env->disable_interrupt = 1;
2563 /* Handles moves to special registers (aka P-register) for all modes. */
2566 move_to_preg_op (unsigned short inst, inst_env_type *inst_env)
2568 if (inst_env->prefix_found)
2570 /* The instruction has a prefix that means we are only interested if
2571 the instruction is in assign mode. */
2572 if (cris_get_mode (inst) == PREFIX_ASSIGN_MODE)
2574 /* The prefix handles the problem if we are in a delay slot. */
2575 if (cris_get_operand1 (inst) == REG_PC)
2577 /* Just take care of the assign. */
2578 check_assign (inst, inst_env);
2582 else if (cris_get_mode (inst) == AUTOINC_MODE)
2584 /* The instruction doesn't have a prefix, the only case left that we
2585 are interested in is the autoincrement mode. */
2586 if (cris_get_operand1 (inst) == REG_PC)
2588 /* If the PC is to be incremented it's invalid to be in a
2590 if (inst_env->slot_needed)
2592 inst_env->invalid = 1;
2596 /* The increment depends on the size of the special register. */
2597 if (cris_register_size (cris_get_operand2 (inst)) == 1)
2599 process_autoincrement (INST_BYTE_SIZE, inst, inst_env);
2601 else if (cris_register_size (cris_get_operand2 (inst)) == 2)
2603 process_autoincrement (INST_WORD_SIZE, inst, inst_env);
2607 process_autoincrement (INST_DWORD_SIZE, inst, inst_env);
2611 inst_env->slot_needed = 0;
2612 inst_env->prefix_found = 0;
2613 inst_env->xflag_found = 0;
2614 inst_env->disable_interrupt = 1;
2617 /* Handles moves from special registers (aka P-register) for all modes
2621 none_reg_mode_move_from_preg_op (unsigned short inst, inst_env_type *inst_env)
2623 if (inst_env->prefix_found)
2625 /* The instruction has a prefix that means we are only interested if
2626 the instruction is in assign mode. */
2627 if (cris_get_mode (inst) == PREFIX_ASSIGN_MODE)
2629 /* The prefix handles the problem if we are in a delay slot. */
2630 if (cris_get_operand1 (inst) == REG_PC)
2632 /* Just take care of the assign. */
2633 check_assign (inst, inst_env);
2637 /* The instruction doesn't have a prefix, the only case left that we
2638 are interested in is the autoincrement mode. */
2639 else if (cris_get_mode (inst) == AUTOINC_MODE)
2641 if (cris_get_operand1 (inst) == REG_PC)
2643 /* If the PC is to be incremented it's invalid to be in a
2645 if (inst_env->slot_needed)
2647 inst_env->invalid = 1;
2651 /* The increment depends on the size of the special register. */
2652 if (cris_register_size (cris_get_operand2 (inst)) == 1)
2654 process_autoincrement (INST_BYTE_SIZE, inst, inst_env);
2656 else if (cris_register_size (cris_get_operand2 (inst)) == 2)
2658 process_autoincrement (INST_WORD_SIZE, inst, inst_env);
2662 process_autoincrement (INST_DWORD_SIZE, inst, inst_env);
2666 inst_env->slot_needed = 0;
2667 inst_env->prefix_found = 0;
2668 inst_env->xflag_found = 0;
2669 inst_env->disable_interrupt = 1;
2672 /* Handles moves from special registers (aka P-register) when the mode
2676 reg_mode_move_from_preg_op (unsigned short inst, inst_env_type *inst_env)
2678 /* Register mode move from special register can't have a prefix. */
2679 if (inst_env->prefix_found)
2681 inst_env->invalid = 1;
2685 if (cris_get_operand1 (inst) == REG_PC)
2687 /* It's invalid to change the PC in a delay slot. */
2688 if (inst_env->slot_needed)
2690 inst_env->invalid = 1;
2693 /* The destination is the PC, the jump will have a delay slot. */
2694 inst_env->delay_slot_pc = inst_env->preg[cris_get_operand2 (inst)];
2695 inst_env->slot_needed = 1;
2696 inst_env->delay_slot_pc_active = 1;
2700 /* If the destination isn't PC, there will be no jump. */
2701 inst_env->slot_needed = 0;
2703 inst_env->prefix_found = 0;
2704 inst_env->xflag_found = 0;
2705 inst_env->disable_interrupt = 1;
2708 /* Handles the MOVEM from memory to general register instruction. */
2711 move_mem_to_reg_movem_op (unsigned short inst, inst_env_type *inst_env)
2713 if (inst_env->prefix_found)
2715 /* The prefix handles the problem if we are in a delay slot. Is the
2716 MOVEM instruction going to change the PC? */
2717 if (cris_get_operand2 (inst) >= REG_PC)
2719 inst_env->reg[REG_PC] =
2720 read_memory_unsigned_integer (inst_env->prefix_value, 4);
2722 /* The assign value is the value after the increment. Normally, the
2723 assign value is the value before the increment. */
2724 if ((cris_get_operand1 (inst) == REG_PC)
2725 && (cris_get_mode (inst) == PREFIX_ASSIGN_MODE))
2727 inst_env->reg[REG_PC] = inst_env->prefix_value;
2728 inst_env->reg[REG_PC] += 4 * (cris_get_operand2 (inst) + 1);
2733 /* Is the MOVEM instruction going to change the PC? */
2734 if (cris_get_operand2 (inst) == REG_PC)
2736 /* It's invalid to change the PC in a delay slot. */
2737 if (inst_env->slot_needed)
2739 inst_env->invalid = 1;
2742 inst_env->reg[REG_PC] =
2743 read_memory_unsigned_integer (inst_env->reg[cris_get_operand1 (inst)],
2746 /* The increment is not depending on the size, instead it's depending
2747 on the number of registers loaded from memory. */
2748 if ((cris_get_operand1 (inst) == REG_PC) && (cris_get_mode (inst) == AUTOINC_MODE))
2750 /* It's invalid to change the PC in a delay slot. */
2751 if (inst_env->slot_needed)
2753 inst_env->invalid = 1;
2756 inst_env->reg[REG_PC] += 4 * (cris_get_operand2 (inst) + 1);
2759 inst_env->slot_needed = 0;
2760 inst_env->prefix_found = 0;
2761 inst_env->xflag_found = 0;
2762 inst_env->disable_interrupt = 0;
2765 /* Handles the MOVEM to memory from general register instruction. */
2768 move_reg_to_mem_movem_op (unsigned short inst, inst_env_type *inst_env)
2770 if (inst_env->prefix_found)
2772 /* The assign value is the value after the increment. Normally, the
2773 assign value is the value before the increment. */
2774 if ((cris_get_operand1 (inst) == REG_PC) &&
2775 (cris_get_mode (inst) == PREFIX_ASSIGN_MODE))
2777 /* The prefix handles the problem if we are in a delay slot. */
2778 inst_env->reg[REG_PC] = inst_env->prefix_value;
2779 inst_env->reg[REG_PC] += 4 * (cris_get_operand2 (inst) + 1);
2784 /* The increment is not depending on the size, instead it's depending
2785 on the number of registers loaded to memory. */
2786 if ((cris_get_operand1 (inst) == REG_PC) && (cris_get_mode (inst) == AUTOINC_MODE))
2788 /* It's invalid to change the PC in a delay slot. */
2789 if (inst_env->slot_needed)
2791 inst_env->invalid = 1;
2794 inst_env->reg[REG_PC] += 4 * (cris_get_operand2 (inst) + 1);
2797 inst_env->slot_needed = 0;
2798 inst_env->prefix_found = 0;
2799 inst_env->xflag_found = 0;
2800 inst_env->disable_interrupt = 0;
2803 /* Handles the pop instruction to a general register.
2804 POP is a assembler macro for MOVE.D [SP+], Rd. */
2807 reg_pop_op (unsigned short inst, inst_env_type *inst_env)
2809 /* POP can't have a prefix. */
2810 if (inst_env->prefix_found)
2812 inst_env->invalid = 1;
2815 if (cris_get_operand2 (inst) == REG_PC)
2817 /* It's invalid to change the PC in a delay slot. */
2818 if (inst_env->slot_needed)
2820 inst_env->invalid = 1;
2823 inst_env->reg[REG_PC] =
2824 read_memory_unsigned_integer (inst_env->reg[REG_SP], 4);
2826 inst_env->slot_needed = 0;
2827 inst_env->prefix_found = 0;
2828 inst_env->xflag_found = 0;
2829 inst_env->disable_interrupt = 0;
2832 /* Handles moves from register to memory. */
2835 move_reg_to_mem_index_inc_op (unsigned short inst, inst_env_type *inst_env)
2837 /* Check if we have a prefix. */
2838 if (inst_env->prefix_found)
2840 /* The only thing that can change the PC is an assign. */
2841 check_assign (inst, inst_env);
2843 else if ((cris_get_operand1 (inst) == REG_PC)
2844 && (cris_get_mode (inst) == AUTOINC_MODE))
2846 /* It's invalid to change the PC in a delay slot. */
2847 if (inst_env->slot_needed)
2849 inst_env->invalid = 1;
2852 process_autoincrement (cris_get_size (inst), inst, inst_env);
2854 inst_env->slot_needed = 0;
2855 inst_env->prefix_found = 0;
2856 inst_env->xflag_found = 0;
2857 inst_env->disable_interrupt = 0;
2860 /* Handles the intructions that's not yet implemented, by setting
2861 inst_env->invalid to true. */
2864 not_implemented_op (unsigned short inst, inst_env_type *inst_env)
2866 inst_env->invalid = 1;
2869 /* Handles the XOR instruction. */
2872 xor_op (unsigned short inst, inst_env_type *inst_env)
2874 /* XOR can't have a prefix. */
2875 if (inst_env->prefix_found)
2877 inst_env->invalid = 1;
2881 /* Check if the PC is the target. */
2882 if (cris_get_operand2 (inst) == REG_PC)
2884 /* It's invalid to change the PC in a delay slot. */
2885 if (inst_env->slot_needed)
2887 inst_env->invalid = 1;
2890 inst_env->reg[REG_PC] ^= inst_env->reg[cris_get_operand1 (inst)];
2892 inst_env->slot_needed = 0;
2893 inst_env->prefix_found = 0;
2894 inst_env->xflag_found = 0;
2895 inst_env->disable_interrupt = 0;
2898 /* Handles the MULS instruction. */
2901 muls_op (unsigned short inst, inst_env_type *inst_env)
2903 /* MULS/U can't have a prefix. */
2904 if (inst_env->prefix_found)
2906 inst_env->invalid = 1;
2910 /* Consider it invalid if the PC is the target. */
2911 if (cris_get_operand2 (inst) == REG_PC)
2913 inst_env->invalid = 1;
2916 inst_env->slot_needed = 0;
2917 inst_env->prefix_found = 0;
2918 inst_env->xflag_found = 0;
2919 inst_env->disable_interrupt = 0;
2922 /* Handles the MULU instruction. */
2925 mulu_op (unsigned short inst, inst_env_type *inst_env)
2927 /* MULS/U can't have a prefix. */
2928 if (inst_env->prefix_found)
2930 inst_env->invalid = 1;
2934 /* Consider it invalid if the PC is the target. */
2935 if (cris_get_operand2 (inst) == REG_PC)
2937 inst_env->invalid = 1;
2940 inst_env->slot_needed = 0;
2941 inst_env->prefix_found = 0;
2942 inst_env->xflag_found = 0;
2943 inst_env->disable_interrupt = 0;
2946 /* Calculate the result of the instruction for ADD, SUB, CMP AND, OR and MOVE.
2947 The MOVE instruction is the move from source to register. */
2950 add_sub_cmp_and_or_move_action (unsigned short inst, inst_env_type *inst_env,
2951 unsigned long source1, unsigned long source2)
2953 unsigned long pc_mask;
2954 unsigned long operation_mask;
2956 /* Find out how many bits the operation should apply to. */
2957 if (cris_get_size (inst) == INST_BYTE_SIZE)
2959 pc_mask = 0xFFFFFF00;
2960 operation_mask = 0xFF;
2962 else if (cris_get_size (inst) == INST_WORD_SIZE)
2964 pc_mask = 0xFFFF0000;
2965 operation_mask = 0xFFFF;
2967 else if (cris_get_size (inst) == INST_DWORD_SIZE)
2970 operation_mask = 0xFFFFFFFF;
2974 /* The size is out of range. */
2975 inst_env->invalid = 1;
2979 /* The instruction just works on uw_operation_mask bits. */
2980 source2 &= operation_mask;
2981 source1 &= operation_mask;
2983 /* Now calculate the result. The opcode's 3 first bits separates
2984 the different actions. */
2985 switch (cris_get_opcode (inst) & 7)
2995 case 2: /* subtract */
2999 case 3: /* compare */
3011 inst_env->invalid = 1;
3017 /* Make sure that the result doesn't contain more than the instruction
3019 source2 &= operation_mask;
3021 /* Calculate the new breakpoint address. */
3022 inst_env->reg[REG_PC] &= pc_mask;
3023 inst_env->reg[REG_PC] |= source1;
3027 /* Extends the value from either byte or word size to a dword. If the mode
3028 is zero extend then the value is extended with zero. If instead the mode
3029 is signed extend the sign bit of the value is taken into consideration. */
3032 do_sign_or_zero_extend (unsigned long value, unsigned short *inst)
3034 /* The size can be either byte or word, check which one it is.
3035 Don't check the highest bit, it's indicating if it's a zero
3037 if (cris_get_size (*inst) & INST_WORD_SIZE)
3042 /* Check if the instruction is signed extend. If so, check if value has
3044 if (cris_is_signed_extend_bit_on (*inst) && (value & SIGNED_WORD_MASK))
3046 value |= SIGNED_WORD_EXTEND_MASK;
3054 /* Check if the instruction is signed extend. If so, check if value has
3056 if (cris_is_signed_extend_bit_on (*inst) && (value & SIGNED_BYTE_MASK))
3058 value |= SIGNED_BYTE_EXTEND_MASK;
3061 /* The size should now be dword. */
3062 cris_set_size_to_dword (inst);
3066 /* Handles the register mode for the ADD, SUB, CMP, AND, OR and MOVE
3067 instruction. The MOVE instruction is the move from source to register. */
3070 reg_mode_add_sub_cmp_and_or_move_op (unsigned short inst,
3071 inst_env_type *inst_env)
3073 unsigned long operand1;
3074 unsigned long operand2;
3076 /* It's invalid to have a prefix to the instruction. This is a register
3077 mode instruction and can't have a prefix. */
3078 if (inst_env->prefix_found)
3080 inst_env->invalid = 1;
3083 /* Check if the instruction has PC as its target. */
3084 if (cris_get_operand2 (inst) == REG_PC)
3086 if (inst_env->slot_needed)
3088 inst_env->invalid = 1;
3091 /* The instruction has the PC as its target register. */
3092 operand1 = inst_env->reg[cris_get_operand1 (inst)];
3093 operand2 = inst_env->reg[REG_PC];
3095 /* Check if it's a extend, signed or zero instruction. */
3096 if (cris_get_opcode (inst) < 4)
3098 operand1 = do_sign_or_zero_extend (operand1, &inst);
3100 /* Calculate the PC value after the instruction, i.e. where the
3101 breakpoint should be. The order of the udw_operands is vital. */
3102 add_sub_cmp_and_or_move_action (inst, inst_env, operand2, operand1);
3104 inst_env->slot_needed = 0;
3105 inst_env->prefix_found = 0;
3106 inst_env->xflag_found = 0;
3107 inst_env->disable_interrupt = 0;
3110 /* Returns the data contained at address. The size of the data is derived from
3111 the size of the operation. If the instruction is a zero or signed
3112 extend instruction, the size field is changed in instruction. */
3115 get_data_from_address (unsigned short *inst, CORE_ADDR address)
3117 int size = cris_get_size (*inst);
3118 unsigned long value;
3120 /* If it's an extend instruction we don't want the signed extend bit,
3121 because it influences the size. */
3122 if (cris_get_opcode (*inst) < 4)
3124 size &= ~SIGNED_EXTEND_BIT_MASK;
3126 /* Is there a need for checking the size? Size should contain the number of
3129 value = read_memory_unsigned_integer (address, size);
3131 /* Check if it's an extend, signed or zero instruction. */
3132 if (cris_get_opcode (*inst) < 4)
3134 value = do_sign_or_zero_extend (value, inst);
3139 /* Handles the assign addresing mode for the ADD, SUB, CMP, AND, OR and MOVE
3140 instructions. The MOVE instruction is the move from source to register. */
3143 handle_prefix_assign_mode_for_aritm_op (unsigned short inst,
3144 inst_env_type *inst_env)
3146 unsigned long operand2;
3147 unsigned long operand3;
3149 check_assign (inst, inst_env);
3150 if (cris_get_operand2 (inst) == REG_PC)
3152 operand2 = inst_env->reg[REG_PC];
3154 /* Get the value of the third operand. */
3155 operand3 = get_data_from_address (&inst, inst_env->prefix_value);
3157 /* Calculate the PC value after the instruction, i.e. where the
3158 breakpoint should be. The order of the udw_operands is vital. */
3159 add_sub_cmp_and_or_move_action (inst, inst_env, operand2, operand3);
3161 inst_env->slot_needed = 0;
3162 inst_env->prefix_found = 0;
3163 inst_env->xflag_found = 0;
3164 inst_env->disable_interrupt = 0;
3167 /* Handles the three-operand addressing mode for the ADD, SUB, CMP, AND and
3168 OR instructions. Note that for this to work as expected, the calling
3169 function must have made sure that there is a prefix to this instruction. */
3172 three_operand_add_sub_cmp_and_or_op (unsigned short inst,
3173 inst_env_type *inst_env)
3175 unsigned long operand2;
3176 unsigned long operand3;
3178 if (cris_get_operand1 (inst) == REG_PC)
3180 /* The PC will be changed by the instruction. */
3181 operand2 = inst_env->reg[cris_get_operand2 (inst)];
3183 /* Get the value of the third operand. */
3184 operand3 = get_data_from_address (&inst, inst_env->prefix_value);
3186 /* Calculate the PC value after the instruction, i.e. where the
3187 breakpoint should be. */
3188 add_sub_cmp_and_or_move_action (inst, inst_env, operand2, operand3);
3190 inst_env->slot_needed = 0;
3191 inst_env->prefix_found = 0;
3192 inst_env->xflag_found = 0;
3193 inst_env->disable_interrupt = 0;
3196 /* Handles the index addresing mode for the ADD, SUB, CMP, AND, OR and MOVE
3197 instructions. The MOVE instruction is the move from source to register. */
3200 handle_prefix_index_mode_for_aritm_op (unsigned short inst,
3201 inst_env_type *inst_env)
3203 if (cris_get_operand1 (inst) != cris_get_operand2 (inst))
3205 /* If the instruction is MOVE it's invalid. If the instruction is ADD,
3206 SUB, AND or OR something weird is going on (if everything works these
3207 instructions should end up in the three operand version). */
3208 inst_env->invalid = 1;
3213 /* three_operand_add_sub_cmp_and_or does the same as we should do here
3215 three_operand_add_sub_cmp_and_or_op (inst, inst_env);
3217 inst_env->slot_needed = 0;
3218 inst_env->prefix_found = 0;
3219 inst_env->xflag_found = 0;
3220 inst_env->disable_interrupt = 0;
3223 /* Handles the autoincrement and indirect addresing mode for the ADD, SUB,
3224 CMP, AND OR and MOVE instruction. The MOVE instruction is the move from
3225 source to register. */
3228 handle_inc_and_index_mode_for_aritm_op (unsigned short inst,
3229 inst_env_type *inst_env)
3231 unsigned long operand1;
3232 unsigned long operand2;
3233 unsigned long operand3;
3236 /* The instruction is either an indirect or autoincrement addressing mode.
3237 Check if the destination register is the PC. */
3238 if (cris_get_operand2 (inst) == REG_PC)
3240 /* Must be done here, get_data_from_address may change the size
3242 size = cris_get_size (inst);
3243 operand2 = inst_env->reg[REG_PC];
3245 /* Get the value of the third operand, i.e. the indirect operand. */
3246 operand1 = inst_env->reg[cris_get_operand1 (inst)];
3247 operand3 = get_data_from_address (&inst, operand1);
3249 /* Calculate the PC value after the instruction, i.e. where the
3250 breakpoint should be. The order of the udw_operands is vital. */
3251 add_sub_cmp_and_or_move_action (inst, inst_env, operand2, operand3);
3253 /* If this is an autoincrement addressing mode, check if the increment
3255 if ((cris_get_operand1 (inst) == REG_PC) && (cris_get_mode (inst) == AUTOINC_MODE))
3257 /* Get the size field. */
3258 size = cris_get_size (inst);
3260 /* If it's an extend instruction we don't want the signed extend bit,
3261 because it influences the size. */
3262 if (cris_get_opcode (inst) < 4)
3264 size &= ~SIGNED_EXTEND_BIT_MASK;
3266 process_autoincrement (size, inst, inst_env);
3268 inst_env->slot_needed = 0;
3269 inst_env->prefix_found = 0;
3270 inst_env->xflag_found = 0;
3271 inst_env->disable_interrupt = 0;
3274 /* Handles the two-operand addressing mode, all modes except register, for
3275 the ADD, SUB CMP, AND and OR instruction. */
3278 none_reg_mode_add_sub_cmp_and_or_move_op (unsigned short inst,
3279 inst_env_type *inst_env)
3281 if (inst_env->prefix_found)
3283 if (cris_get_mode (inst) == PREFIX_INDEX_MODE)
3285 handle_prefix_index_mode_for_aritm_op (inst, inst_env);
3287 else if (cris_get_mode (inst) == PREFIX_ASSIGN_MODE)
3289 handle_prefix_assign_mode_for_aritm_op (inst, inst_env);
3293 /* The mode is invalid for a prefixed base instruction. */
3294 inst_env->invalid = 1;
3300 handle_inc_and_index_mode_for_aritm_op (inst, inst_env);
3304 /* Handles the quick addressing mode for the ADD and SUB instruction. */
3307 quick_mode_add_sub_op (unsigned short inst, inst_env_type *inst_env)
3309 unsigned long operand1;
3310 unsigned long operand2;
3312 /* It's a bad idea to be in a prefix instruction now. This is a quick mode
3313 instruction and can't have a prefix. */
3314 if (inst_env->prefix_found)
3316 inst_env->invalid = 1;
3320 /* Check if the instruction has PC as its target. */
3321 if (cris_get_operand2 (inst) == REG_PC)
3323 if (inst_env->slot_needed)
3325 inst_env->invalid = 1;
3328 operand1 = cris_get_quick_value (inst);
3329 operand2 = inst_env->reg[REG_PC];
3331 /* The size should now be dword. */
3332 cris_set_size_to_dword (&inst);
3334 /* Calculate the PC value after the instruction, i.e. where the
3335 breakpoint should be. */
3336 add_sub_cmp_and_or_move_action (inst, inst_env, operand2, operand1);
3338 inst_env->slot_needed = 0;
3339 inst_env->prefix_found = 0;
3340 inst_env->xflag_found = 0;
3341 inst_env->disable_interrupt = 0;
3344 /* Handles the quick addressing mode for the CMP, AND and OR instruction. */
3347 quick_mode_and_cmp_move_or_op (unsigned short inst, inst_env_type *inst_env)
3349 unsigned long operand1;
3350 unsigned long operand2;
3352 /* It's a bad idea to be in a prefix instruction now. This is a quick mode
3353 instruction and can't have a prefix. */
3354 if (inst_env->prefix_found)
3356 inst_env->invalid = 1;
3359 /* Check if the instruction has PC as its target. */
3360 if (cris_get_operand2 (inst) == REG_PC)
3362 if (inst_env->slot_needed)
3364 inst_env->invalid = 1;
3367 /* The instruction has the PC as its target register. */
3368 operand1 = cris_get_quick_value (inst);
3369 operand2 = inst_env->reg[REG_PC];
3371 /* The quick value is signed, so check if we must do a signed extend. */
3372 if (operand1 & SIGNED_QUICK_VALUE_MASK)
3375 operand1 |= SIGNED_QUICK_VALUE_EXTEND_MASK;
3377 /* The size should now be dword. */
3378 cris_set_size_to_dword (&inst);
3380 /* Calculate the PC value after the instruction, i.e. where the
3381 breakpoint should be. */
3382 add_sub_cmp_and_or_move_action (inst, inst_env, operand2, operand1);
3384 inst_env->slot_needed = 0;
3385 inst_env->prefix_found = 0;
3386 inst_env->xflag_found = 0;
3387 inst_env->disable_interrupt = 0;
3390 /* Translate op_type to a function and call it. */
3392 static void cris_gdb_func (enum cris_op_type op_type, unsigned short inst,
3393 inst_env_type *inst_env)
3397 case cris_not_implemented_op:
3398 not_implemented_op (inst, inst_env);
3402 abs_op (inst, inst_env);
3406 addi_op (inst, inst_env);
3410 asr_op (inst, inst_env);
3414 asrq_op (inst, inst_env);
3417 case cris_ax_ei_setf_op:
3418 ax_ei_setf_op (inst, inst_env);
3421 case cris_bdap_prefix:
3422 bdap_prefix (inst, inst_env);
3425 case cris_biap_prefix:
3426 biap_prefix (inst, inst_env);
3430 break_op (inst, inst_env);
3433 case cris_btst_nop_op:
3434 btst_nop_op (inst, inst_env);
3437 case cris_clearf_di_op:
3438 clearf_di_op (inst, inst_env);
3441 case cris_dip_prefix:
3442 dip_prefix (inst, inst_env);
3445 case cris_dstep_logshift_mstep_neg_not_op:
3446 dstep_logshift_mstep_neg_not_op (inst, inst_env);
3449 case cris_eight_bit_offset_branch_op:
3450 eight_bit_offset_branch_op (inst, inst_env);
3453 case cris_move_mem_to_reg_movem_op:
3454 move_mem_to_reg_movem_op (inst, inst_env);
3457 case cris_move_reg_to_mem_movem_op:
3458 move_reg_to_mem_movem_op (inst, inst_env);
3461 case cris_move_to_preg_op:
3462 move_to_preg_op (inst, inst_env);
3466 muls_op (inst, inst_env);
3470 mulu_op (inst, inst_env);
3473 case cris_none_reg_mode_add_sub_cmp_and_or_move_op:
3474 none_reg_mode_add_sub_cmp_and_or_move_op (inst, inst_env);
3477 case cris_none_reg_mode_clear_test_op:
3478 none_reg_mode_clear_test_op (inst, inst_env);
3481 case cris_none_reg_mode_jump_op:
3482 none_reg_mode_jump_op (inst, inst_env);
3485 case cris_none_reg_mode_move_from_preg_op:
3486 none_reg_mode_move_from_preg_op (inst, inst_env);
3489 case cris_quick_mode_add_sub_op:
3490 quick_mode_add_sub_op (inst, inst_env);
3493 case cris_quick_mode_and_cmp_move_or_op:
3494 quick_mode_and_cmp_move_or_op (inst, inst_env);
3497 case cris_quick_mode_bdap_prefix:
3498 quick_mode_bdap_prefix (inst, inst_env);
3501 case cris_reg_mode_add_sub_cmp_and_or_move_op:
3502 reg_mode_add_sub_cmp_and_or_move_op (inst, inst_env);
3505 case cris_reg_mode_clear_op:
3506 reg_mode_clear_op (inst, inst_env);
3509 case cris_reg_mode_jump_op:
3510 reg_mode_jump_op (inst, inst_env);
3513 case cris_reg_mode_move_from_preg_op:
3514 reg_mode_move_from_preg_op (inst, inst_env);
3517 case cris_reg_mode_test_op:
3518 reg_mode_test_op (inst, inst_env);
3522 scc_op (inst, inst_env);
3525 case cris_sixteen_bit_offset_branch_op:
3526 sixteen_bit_offset_branch_op (inst, inst_env);
3529 case cris_three_operand_add_sub_cmp_and_or_op:
3530 three_operand_add_sub_cmp_and_or_op (inst, inst_env);
3533 case cris_three_operand_bound_op:
3534 three_operand_bound_op (inst, inst_env);
3537 case cris_two_operand_bound_op:
3538 two_operand_bound_op (inst, inst_env);
3542 xor_op (inst, inst_env);
3547 /* This wrapper is to avoid cris_get_assembler being called before
3548 exec_bfd has been set. */
3551 cris_delayed_get_disassembler (bfd_vma addr, disassemble_info *info)
3553 deprecated_tm_print_insn = cris_get_disassembler (exec_bfd);
3554 return TARGET_PRINT_INSN (addr, info);
3557 /* Copied from <asm/elf.h>. */
3558 typedef unsigned long elf_greg_t;
3560 /* Same as user_regs_struct struct in <asm/user.h>. */
3561 typedef elf_greg_t elf_gregset_t[35];
3563 /* Unpack an elf_gregset_t into GDB's register cache. */
3566 supply_gregset (elf_gregset_t *gregsetp)
3569 elf_greg_t *regp = *gregsetp;
3570 static char zerobuf[4] = {0};
3572 /* The kernel dumps all 32 registers as unsigned longs, but supply_register
3573 knows about the actual size of each register so that's no problem. */
3574 for (i = 0; i < NUM_GENREGS + NUM_SPECREGS; i++)
3576 supply_register (i, (char *)®p[i]);
3580 /* Use a local version of this function to get the correct types for
3581 regsets, until multi-arch core support is ready. */
3584 fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
3585 int which, CORE_ADDR reg_addr)
3587 elf_gregset_t gregset;
3592 if (core_reg_size != sizeof (gregset))
3594 warning ("wrong size gregset struct in core file");
3598 memcpy (&gregset, core_reg_sect, sizeof (gregset));
3599 supply_gregset (&gregset);
3603 /* We've covered all the kinds of registers we know about here,
3604 so this must be something we wouldn't know what to do with
3605 anyway. Just ignore it. */
3610 static struct core_fns cris_elf_core_fns =
3612 bfd_target_elf_flavour, /* core_flavour */
3613 default_check_format, /* check_format */
3614 default_core_sniffer, /* core_sniffer */
3615 fetch_core_registers, /* core_read_registers */
3619 /* Fetch (and possibly build) an appropriate link_map_offsets
3620 structure for native GNU/Linux CRIS targets using the struct
3621 offsets defined in link.h (but without actual reference to that
3624 This makes it possible to access GNU/Linux CRIS shared libraries
3625 from a GDB that was not built on an GNU/Linux CRIS host (for cross
3628 See gdb/solib-svr4.h for an explanation of these fields. */
3630 struct link_map_offsets *
3631 cris_linux_svr4_fetch_link_map_offsets (void)
3633 static struct link_map_offsets lmo;
3634 static struct link_map_offsets *lmp = NULL;
3640 lmo.r_debug_size = 8; /* The actual size is 20 bytes, but
3641 this is all we need. */
3642 lmo.r_map_offset = 4;
3645 lmo.link_map_size = 20;
3647 lmo.l_addr_offset = 0;
3648 lmo.l_addr_size = 4;
3650 lmo.l_name_offset = 4;
3651 lmo.l_name_size = 4;
3653 lmo.l_next_offset = 12;
3654 lmo.l_next_size = 4;
3656 lmo.l_prev_offset = 16;
3657 lmo.l_prev_size = 4;
3664 cris_fpless_backtrace (char *noargs, int from_tty)
3666 /* Points at the instruction after the jsr (except when in innermost frame
3667 where it points at the original pc). */
3670 /* Temporary variable, used for parsing from the start of the function that
3671 the pc is in, up to the pc. */
3672 CORE_ADDR tmp_pc = 0;
3675 /* Information about current frame. */
3676 struct symtab_and_line sal;
3679 /* Present instruction. */
3680 unsigned short insn;
3682 /* Next instruction, lookahead. */
3683 unsigned short insn_next;
3685 /* This is to store the offset between sp at start of function and until we
3686 reach push srp (if any). */
3687 int sp_add_later = 0;
3688 int push_srp_found = 0;
3692 /* Frame counter. */
3695 /* For the innermost frame, we want to look at srp in case it's a leaf
3696 function (since there's no push srp in that case). */
3697 int innermost_frame = 1;
3699 deprecated_read_register_gen (PC_REGNUM, (char *) &pc);
3700 deprecated_read_register_gen (SP_REGNUM, (char *) &sp);
3702 /* We make an explicit return when we can't find an outer frame. */
3705 /* Get file name and line number. */
3706 sal = find_pc_line (pc, 0);
3708 /* Get function name. */
3709 find_pc_partial_function (pc, &func_name, (CORE_ADDR *) NULL,
3710 (CORE_ADDR *) NULL);
3712 /* Print information about current frame. */
3713 printf_unfiltered ("#%i 0x%08lx in %s", frame++, pc, func_name);
3716 printf_unfiltered (" at %s:%i", sal.symtab->filename, sal.line);
3718 printf_unfiltered ("\n");
3720 /* Get the start address of this function. */
3721 tmp_pc = get_pc_function_start (pc);
3723 /* Mini parser, only meant to find push sp and sub ...,sp from the start
3724 of the function, up to the pc. */
3727 insn = read_memory_unsigned_integer (tmp_pc, sizeof (short));
3728 tmp_pc += sizeof (short);
3731 /* push <reg> 32 bit instruction */
3732 insn_next = read_memory_unsigned_integer (tmp_pc,
3734 tmp_pc += sizeof (short);
3736 /* Recognize srp. */
3737 if (insn_next == 0xBE7E)
3739 /* For subsequent (not this one though) push or sub which
3740 affects sp, adjust sp immediately. */
3743 /* Note: this will break if we ever encounter a
3744 push vr (1 byte) or push ccr (2 bytes). */
3749 /* Some other register was pushed. */
3760 else if (cris_get_operand2 (insn) == SP_REGNUM
3761 && cris_get_mode (insn) == 0x0000
3762 && cris_get_opcode (insn) == 0x000A)
3765 val = cris_get_quick_value (insn);
3773 sp_add_later += val;
3777 else if (cris_get_operand2 (insn) == SP_REGNUM
3778 /* Autoincrement addressing mode. */
3779 && cris_get_mode (insn) == 0x0003
3781 && ((insn) & 0x03E0) >> 5 == 0x0004)
3784 val = get_data_from_address (&insn, tmp_pc);
3792 sp_add_later += val;
3795 else if (cris_get_operand2 (insn) == SP_REGNUM
3796 && ((insn & 0x0F00) >> 8) == 0x0001
3797 && (cris_get_signed_offset (insn) < 0))
3799 /* Immediate byte offset addressing prefix word with sp as base
3800 register. Used for CRIS v8 i.e. ETRAX 100 and newer if <val>
3801 is between 64 and 128.
3802 movem r<regsave>,[sp=sp-<val>] */
3803 val = -cris_get_signed_offset (insn);
3804 insn_next = read_memory_unsigned_integer (tmp_pc,
3806 tmp_pc += sizeof (short);
3808 if (cris_get_mode (insn_next) == PREFIX_ASSIGN_MODE
3809 && cris_get_opcode (insn_next) == 0x000F
3810 && cris_get_size (insn_next) == 0x0003
3811 && cris_get_operand1 (insn_next) == SP_REGNUM)
3819 sp_add_later += val;
3830 /* sp should now point at where srp is stored on the stack. Update
3831 the pc to the srp. */
3832 pc = read_memory_unsigned_integer (sp, 4);
3834 else if (innermost_frame)
3836 /* We couldn't find a push srp in the prologue, so this must be
3837 a leaf function, and thus we use the srp register directly.
3838 This should happen at most once, for the innermost function. */
3839 deprecated_read_register_gen (SRP_REGNUM, (char *) &pc);
3843 /* Couldn't find an outer frame. */
3847 /* Reset flag. (In case the innermost frame wasn't a leaf, we don't
3848 want to look at the srp register later either). */
3849 innermost_frame = 0;
3851 /* Now, add the offset for everything up to, and including push srp,
3852 that was held back during the prologue parsing. */
3859 _initialize_cris_tdep (void)
3861 struct cmd_list_element *c;
3863 gdbarch_register (bfd_arch_cris, cris_gdbarch_init, cris_dump_tdep);
3865 /* Used in disassembly. */
3866 deprecated_tm_print_insn = cris_delayed_get_disassembler;
3868 /* CRIS-specific user-commands. */
3869 c = add_set_cmd ("cris-version", class_support, var_integer,
3870 (char *) &usr_cmd_cris_version,
3871 "Set the current CRIS version.", &setlist);
3872 set_cmd_sfunc (c, cris_version_update);
3873 add_show_from_set (c, &showlist);
3875 c = add_set_enum_cmd ("cris-mode", class_support, cris_mode_enums,
3877 "Set the current CRIS mode.", &setlist);
3878 set_cmd_sfunc (c, cris_mode_update);
3879 add_show_from_set (c, &showlist);
3881 c = add_set_enum_cmd ("cris-abi", class_support, cris_abi_enums,
3883 "Set the current CRIS ABI version.", &setlist);
3884 set_cmd_sfunc (c, cris_abi_update);
3885 add_show_from_set (c, &showlist);
3887 c = add_cmd ("cris-fpless-backtrace", class_support, cris_fpless_backtrace,
3888 "Display call chain using the subroutine return pointer.\n"
3889 "Note that this displays the address after the jump to the "
3890 "subroutine.", &cmdlist);
3892 add_core_fns (&cris_elf_core_fns);
3896 /* Prints out all target specific values. */
3899 cris_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
3901 struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
3904 fprintf_unfiltered (file, "cris_dump_tdep: tdep->cris_version = %i\n",
3905 tdep->cris_version);
3906 fprintf_unfiltered (file, "cris_dump_tdep: tdep->cris_mode = %s\n",
3908 fprintf_unfiltered (file, "cris_dump_tdep: tdep->cris_abi = %s\n",
3915 cris_version_update (char *ignore_args, int from_tty,
3916 struct cmd_list_element *c)
3918 struct gdbarch_info info;
3920 /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
3921 the set command passed as a parameter. The clone operation will
3922 include (BUG?) any ``set'' command callback, if present.
3923 Commands like ``info set'' call all the ``show'' command
3924 callbacks. Unfortunatly, for ``show'' commands cloned from
3925 ``set'', this includes callbacks belonging to ``set'' commands.
3926 Making this worse, this only occures if add_show_from_set() is
3927 called after add_cmd_sfunc() (BUG?). */
3929 /* From here on, trust the user's CRIS version setting. */
3930 if (cmd_type (c) == set_cmd)
3932 usr_cmd_cris_version_valid = 1;
3934 /* Update the current architecture, if needed. */
3935 gdbarch_info_init (&info);
3936 if (!gdbarch_update_p (info))
3937 internal_error (__FILE__, __LINE__, "cris_gdbarch_update: failed to update architecture.");
3942 cris_mode_update (char *ignore_args, int from_tty,
3943 struct cmd_list_element *c)
3945 struct gdbarch_info info;
3947 /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
3948 the set command passed as a parameter. The clone operation will
3949 include (BUG?) any ``set'' command callback, if present.
3950 Commands like ``info set'' call all the ``show'' command
3951 callbacks. Unfortunatly, for ``show'' commands cloned from
3952 ``set'', this includes callbacks belonging to ``set'' commands.
3953 Making this worse, this only occures if add_show_from_set() is
3954 called after add_cmd_sfunc() (BUG?). */
3956 /* From here on, trust the user's CRIS mode setting. */
3957 if (cmd_type (c) == set_cmd)
3959 usr_cmd_cris_mode_valid = 1;
3961 /* Update the current architecture, if needed. */
3962 gdbarch_info_init (&info);
3963 if (!gdbarch_update_p (info))
3964 internal_error (__FILE__, __LINE__, "cris_gdbarch_update: failed to update architecture.");
3969 cris_abi_update (char *ignore_args, int from_tty,
3970 struct cmd_list_element *c)
3972 struct gdbarch_info info;
3974 /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
3975 the set command passed as a parameter. The clone operation will
3976 include (BUG?) any ``set'' command callback, if present.
3977 Commands like ``info set'' call all the ``show'' command
3978 callbacks. Unfortunatly, for ``show'' commands cloned from
3979 ``set'', this includes callbacks belonging to ``set'' commands.
3980 Making this worse, this only occures if add_show_from_set() is
3981 called after add_cmd_sfunc() (BUG?). */
3983 /* From here on, trust the user's CRIS ABI setting. */
3984 if (cmd_type (c) == set_cmd)
3986 usr_cmd_cris_abi_valid = 1;
3988 /* Update the current architecture, if needed. */
3989 gdbarch_info_init (&info);
3990 if (!gdbarch_update_p (info))
3991 internal_error (__FILE__, __LINE__, "cris_gdbarch_update: failed to update architecture.");
3995 /* Copied from pa64solib.c, with a couple of minor changes. */
3998 bfd_lookup_symbol (bfd *abfd, const char *symname)
4000 unsigned int storage_needed;
4002 asymbol **symbol_table;
4003 unsigned int number_of_symbols;
4005 struct cleanup *back_to;
4006 CORE_ADDR symaddr = 0;
4008 storage_needed = bfd_get_symtab_upper_bound (abfd);
4010 if (storage_needed > 0)
4012 symbol_table = (asymbol **) xmalloc (storage_needed);
4013 back_to = make_cleanup (free, symbol_table);
4014 number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
4016 for (i = 0; i < number_of_symbols; i++)
4018 sym = *symbol_table++;
4019 if (!strcmp (sym->name, symname))
4021 /* Bfd symbols are section relative. */
4022 symaddr = sym->value + sym->section->vma;
4026 do_cleanups (back_to);
4031 static struct gdbarch *
4032 cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
4034 struct gdbarch *gdbarch;
4035 struct gdbarch_tdep *tdep;
4037 const char *cris_mode;
4038 const char *cris_abi;
4039 CORE_ADDR cris_abi_sym = 0;
4042 if (usr_cmd_cris_version_valid)
4044 /* Trust the user's CRIS version setting. */
4045 cris_version = usr_cmd_cris_version;
4049 /* Assume it's CRIS version 10. */
4053 if (usr_cmd_cris_mode_valid)
4055 /* Trust the user's CRIS mode setting. */
4056 cris_mode = usr_cmd_cris_mode;
4058 else if (cris_version == 10)
4060 /* Assume CRIS version 10 is in user mode. */
4061 cris_mode = CRIS_MODE_USER;
4065 /* Strictly speaking, older CRIS version don't have a supervisor mode,
4066 but we regard its only mode as supervisor mode. */
4067 cris_mode = CRIS_MODE_SUPERVISOR;
4070 if (usr_cmd_cris_abi_valid)
4072 /* Trust the user's ABI setting. */
4073 cris_abi = usr_cmd_cris_abi;
4077 if (bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
4079 /* An elf target uses the new ABI. */
4080 cris_abi = CRIS_ABI_V2;
4082 else if (bfd_get_flavour (info.abfd) == bfd_target_aout_flavour)
4084 /* An a.out target may use either ABI. Look for hints in the
4086 cris_abi_sym = bfd_lookup_symbol (info.abfd, CRIS_ABI_SYMBOL);
4087 cris_abi = cris_abi_sym ? CRIS_ABI_V2 : CRIS_ABI_ORIGINAL;
4091 /* Unknown bfd flavour. Assume it's the new ABI. */
4092 cris_abi = CRIS_ABI_V2;
4095 else if (arches != NULL)
4097 /* No bfd available. Stick with the ABI from the most recently
4098 selected architecture of this same family (the head of arches
4099 always points to this). (This is to avoid changing the ABI
4100 when the user updates the architecture with the 'set
4101 cris-version' command.) */
4102 cris_abi = gdbarch_tdep (arches->gdbarch)->cris_abi;
4106 /* No bfd, and no previously selected architecture available.
4107 Assume it's the new ABI. */
4108 cris_abi = CRIS_ABI_V2;
4111 /* Make the current settings visible to the user. */
4112 usr_cmd_cris_version = cris_version;
4113 usr_cmd_cris_mode = cris_mode;
4114 usr_cmd_cris_abi = cris_abi;
4116 /* Find a candidate among the list of pre-declared architectures. Both
4117 CRIS version and ABI must match. */
4118 for (arches = gdbarch_list_lookup_by_info (arches, &info);
4120 arches = gdbarch_list_lookup_by_info (arches->next, &info))
4122 if ((gdbarch_tdep (arches->gdbarch)->cris_version == cris_version)
4123 && (gdbarch_tdep (arches->gdbarch)->cris_mode == cris_mode)
4124 && (gdbarch_tdep (arches->gdbarch)->cris_abi == cris_abi))
4125 return arches->gdbarch;
4128 /* No matching architecture was found. Create a new one. */
4129 tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
4130 gdbarch = gdbarch_alloc (&info, tdep);
4132 /* NOTE: cagney/2002-12-06: This can be deleted when this arch is
4133 ready to unwind the PC first (see frame.c:get_prev_frame()). */
4134 set_gdbarch_deprecated_init_frame_pc (gdbarch, init_frame_pc_default);
4136 tdep->cris_version = cris_version;
4137 tdep->cris_mode = cris_mode;
4138 tdep->cris_abi = cris_abi;
4140 /* INIT shall ensure that the INFO.BYTE_ORDER is non-zero. */
4141 switch (info.byte_order)
4143 case BFD_ENDIAN_LITTLE:
4147 case BFD_ENDIAN_BIG:
4148 internal_error (__FILE__, __LINE__, "cris_gdbarch_init: big endian byte order in info");
4152 internal_error (__FILE__, __LINE__, "cris_gdbarch_init: unknown byte order in info");
4155 /* Initialize the ABI dependent things. */
4156 if (tdep->cris_abi == CRIS_ABI_ORIGINAL)
4158 set_gdbarch_double_bit (gdbarch, 32);
4159 set_gdbarch_deprecated_push_arguments (gdbarch, cris_abi_original_push_arguments);
4160 set_gdbarch_deprecated_store_return_value (gdbarch,
4161 cris_abi_original_store_return_value);
4162 set_gdbarch_deprecated_extract_return_value
4163 (gdbarch, cris_abi_original_extract_return_value);
4164 set_gdbarch_reg_struct_has_addr
4165 (gdbarch, cris_abi_original_reg_struct_has_addr);
4167 else if (tdep->cris_abi == CRIS_ABI_V2)
4169 set_gdbarch_double_bit (gdbarch, 64);
4170 set_gdbarch_deprecated_push_arguments (gdbarch, cris_abi_v2_push_arguments);
4171 set_gdbarch_deprecated_store_return_value (gdbarch, cris_abi_v2_store_return_value);
4172 set_gdbarch_deprecated_extract_return_value
4173 (gdbarch, cris_abi_v2_extract_return_value);
4174 set_gdbarch_reg_struct_has_addr (gdbarch,
4175 cris_abi_v2_reg_struct_has_addr);
4178 internal_error (__FILE__, __LINE__, "cris_gdbarch_init: unknown CRIS ABI");
4180 /* The default definition of a long double is 2 * TARGET_DOUBLE_BIT,
4181 which means we have to set this explicitly. */
4182 set_gdbarch_long_double_bit (gdbarch, 64);
4184 /* There are 32 registers (some of which may not be implemented). */
4185 set_gdbarch_num_regs (gdbarch, 32);
4186 set_gdbarch_sp_regnum (gdbarch, 14);
4187 set_gdbarch_deprecated_fp_regnum (gdbarch, 8);
4188 set_gdbarch_pc_regnum (gdbarch, 15);
4190 set_gdbarch_register_name (gdbarch, cris_register_name);
4192 /* Length of ordinary registers used in push_word and a few other places.
4193 REGISTER_RAW_SIZE is the real way to know how big a register is. */
4194 set_gdbarch_deprecated_register_size (gdbarch, 4);
4197 set_gdbarch_register_bytes_ok (gdbarch, cris_register_bytes_ok);
4198 set_gdbarch_software_single_step (gdbarch, cris_software_single_step);
4201 set_gdbarch_cannot_store_register (gdbarch, cris_cannot_store_register);
4202 set_gdbarch_cannot_fetch_register (gdbarch, cris_cannot_fetch_register);
4205 /* The total amount of space needed to store (in an array called registers)
4206 GDB's copy of the machine's register state. Note: We can not use
4207 cris_register_size at this point, since it relies on current_gdbarch
4209 switch (tdep->cris_version)
4215 /* Support for these may be added later. */
4216 internal_error (__FILE__, __LINE__, "cris_gdbarch_init: unsupported CRIS version");
4221 /* CRIS v8 and v9, a.k.a. ETRAX 100. General registers R0 - R15
4222 (32 bits), special registers P0 - P1 (8 bits), P4 - P5 (16 bits),
4223 and P8 - P14 (32 bits). */
4224 register_bytes = (16 * 4) + (2 * 1) + (2 * 2) + (7 * 4);
4229 /* CRIS v10 and v11, a.k.a. ETRAX 100LX. In addition to ETRAX 100,
4230 P7 (32 bits), and P15 (32 bits) have been implemented. */
4231 register_bytes = (16 * 4) + (2 * 1) + (2 * 2) + (9 * 4);
4235 internal_error (__FILE__, __LINE__, "cris_gdbarch_init: unknown CRIS version");
4238 set_gdbarch_deprecated_register_bytes (gdbarch, register_bytes);
4240 /* Returns the register offset for the first byte of register regno's space
4241 in the saved register state. */
4242 set_gdbarch_register_byte (gdbarch, cris_register_offset);
4244 /* The length of the registers in the actual machine representation. */
4245 set_gdbarch_register_raw_size (gdbarch, cris_register_size);
4247 /* The largest value REGISTER_RAW_SIZE can have. */
4248 set_gdbarch_deprecated_max_register_raw_size (gdbarch, 32);
4250 /* The length of the registers in the program's representation. */
4251 set_gdbarch_register_virtual_size (gdbarch, cris_register_size);
4253 /* The largest value REGISTER_VIRTUAL_SIZE can have. */
4254 set_gdbarch_deprecated_max_register_virtual_size (gdbarch, 32);
4256 set_gdbarch_register_virtual_type (gdbarch, cris_register_virtual_type);
4258 /* Use generic dummy frames. */
4260 /* Read all about dummy frames in blockframe.c. */
4261 set_gdbarch_deprecated_pc_in_call_dummy (gdbarch, deprecated_pc_in_call_dummy_at_entry_point);
4263 /* Defined to 1 to indicate that the target supports inferior function
4265 set_gdbarch_deprecated_call_dummy_words (gdbarch, 0);
4266 set_gdbarch_deprecated_sizeof_call_dummy_words (gdbarch, 0);
4268 set_gdbarch_deprecated_get_saved_register (gdbarch, deprecated_generic_get_saved_register);
4270 /* No register requires conversion from raw format to virtual format. */
4271 set_gdbarch_register_convertible (gdbarch, generic_register_convertible_not);
4273 set_gdbarch_deprecated_push_return_address (gdbarch, cris_push_return_address);
4274 set_gdbarch_deprecated_pop_frame (gdbarch, cris_pop_frame);
4276 set_gdbarch_deprecated_store_struct_return (gdbarch, cris_store_struct_return);
4277 set_gdbarch_deprecated_extract_struct_value_address
4278 (gdbarch, cris_extract_struct_value_address);
4279 set_gdbarch_use_struct_convention (gdbarch, cris_use_struct_convention);
4281 set_gdbarch_deprecated_frame_init_saved_regs (gdbarch, cris_frame_init_saved_regs);
4282 set_gdbarch_deprecated_init_extra_frame_info (gdbarch, cris_init_extra_frame_info);
4283 set_gdbarch_skip_prologue (gdbarch, cris_skip_prologue);
4284 set_gdbarch_prologue_frameless_p (gdbarch, generic_prologue_frameless_p);
4286 /* The stack grows downward. */
4287 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
4289 set_gdbarch_breakpoint_from_pc (gdbarch, cris_breakpoint_from_pc);
4291 /* The PC must not be decremented after a breakpoint. (The breakpoint
4292 handler takes care of that.) */
4293 set_gdbarch_decr_pc_after_break (gdbarch, 0);
4295 /* Offset from address of function to start of its code. */
4296 set_gdbarch_function_start_offset (gdbarch, 0);
4298 /* The number of bytes at the start of arglist that are not really args,
4299 0 in the CRIS ABI. */
4300 set_gdbarch_frame_args_skip (gdbarch, 0);
4301 set_gdbarch_frameless_function_invocation
4302 (gdbarch, cris_frameless_function_invocation);
4303 set_gdbarch_deprecated_frame_chain (gdbarch, cris_frame_chain);
4305 set_gdbarch_deprecated_frame_saved_pc (gdbarch, cris_frame_saved_pc);
4306 set_gdbarch_deprecated_saved_pc_after_call (gdbarch, cris_saved_pc_after_call);
4308 set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
4310 /* Helpful for backtracing and returning in a call dummy. */
4311 set_gdbarch_save_dummy_frame_tos (gdbarch, generic_save_dummy_frame_tos);
4313 /* Should be using push_dummy_call. */
4314 set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
4316 /* Use target_specific function to define link map offsets. */
4317 set_solib_svr4_fetch_link_map_offsets
4318 (gdbarch, cris_linux_svr4_fetch_link_map_offsets);