1 /* Parameters for target machine ARC, for GDB, the GNU debugger.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Contributed by Cygnus Support Corporation.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* Byte order is configurable, but this machine runs little-endian. */
22 #define TARGET_BYTE_ORDER LITTLE_ENDIAN
24 /* We have IEEE floating point, if we have any float at all. */
27 /* Offset from address of function to start of its code.
28 Zero on most machines. */
29 #define FUNCTION_START_OFFSET 0
31 /* Advance pc across any function entry prologue instructions
32 to reach some "real" code. */
34 #define SKIP_PROLOGUE(pc) { pc = skip_prologue (pc); }
35 extern CORE_ADDR skip_prologue ();
37 /* Sequence of bytes for breakpoint instruction. */
38 #define BREAKPOINT {0x01, 0x80, 0xbe, 0x1f}
40 #define DECR_PC_AFTER_BREAK 4
42 /* Immediately after a function call, return the saved pc.
43 Can't always go through the frames for this because on some machines
44 the new frame is not set up until the new function
45 executes some instructions. */
47 #define SAVED_PC_AFTER_CALL(frame) (read_register (BLINK_REGNUM))
49 /* Stack grows upward */
53 /* Nonzero if instruction at pc is a return instruction. */
55 #define ABOUT_TO_RETURN(pc) (read_memory_integer(pc,4) == 0x380f8000)
57 /* Say how long (ordinary) registers are. This is a piece of bogosity
58 used in push_word and a few other places; REGISTER_RAW_SIZE is the
59 real way to know how big a register is. */
60 #define REGISTER_SIZE 4
62 /* Number of machine registers */
65 /* Initializer for an array of names of registers.
66 There should be NUM_REGS strings in this initializer. */
68 #define REGISTER_NAMES \
70 /* 0 */ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
71 /* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
72 /* 16 */ "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
73 /* 24 */ "r24", "r25", "r26", "r27", "r28", "ilink1", "ilink2", "blink", \
74 /* 32 */ "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
75 /* 40 */ "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \
76 /* 48 */ "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
77 /* 56 */ "r56", "mlo", "mmid", "mhi", "lpcnt", \
78 /* 61 */ "sta", "sema", "lpst", "lpend", "iden", "debug", \
79 /* 67 */ "aux10", "aux11", "aux12", "aux13", "aux14", \
80 /* 72 */ "aux15", "aux16", "aux17", "aux18", "aux19", \
81 /* 77 */ "aux1a", "aux1b", "aux1c", "aux1d", "aux1e", \
82 /* 82 */ "aux1f", "aux20", "aux21", "aux22", \
83 /* 86 */ "aux30", "aux31", "aux32", "aux33", "aux40", \
87 /* Register numbers of various important registers (used to index
88 into arrays of register names and register values). */
90 #define R0_REGNUM 0 /* First local register */
91 #define R59_REGNUM 59 /* Last local register */
92 #define FP_REGNUM 27 /* Contains address of executing stack frame */
93 #define SP_REGNUM 28 /* stack pointer */
94 #define BLINK_REGNUM 31 /* link register */
95 #define STA_REGNUM 61 /* processor status word */
96 #define PC_REGNUM 91 /* instruction pointer */
97 #define AUX_BEG_REGNUM 61 /* aux reg begins */
98 #define AUX_END_REGNUM 90 /* aux reg ends, pc not real aux reg */
100 #define AUX_REG_MAP \
102 { 0, 1, 2, 3, 4, 5, \
103 16, -1, -1, -1, -1, \
104 -1, -1, -1, -1, -1, \
105 -1, -1, -1, -1, 30, \
107 48, 49, 50, 51, 64, \
110 { 0, 1, 2, 3, 4, 5, \
111 16, -1, -1, -1, -1, \
112 -1, -1, -1, -1, -1, \
113 -1, -1, -1, -1, 30, \
115 -1, -1, -1, -1, -1, \
118 { 0, 1, 2, 3, 4, 5, \
119 16, 17, 18, 19, 20, \
120 21, 22, 23, 24, 25, \
121 26, 27, 28, 29, 30, \
123 -1, -1, -1, -1, -1, \
128 #define PFP_REGNUM R0_REGNUM /* Previous frame pointer */
130 /* Total amount of space needed to store our copies of the machine's
131 register state, the array `registers'. */
132 #define REGISTER_BYTES (91*4)
134 /* Index within `registers' of the first byte of the space for register N. */
135 #define REGISTER_BYTE(N) (4*(N))
137 /* Number of bytes of storage in the actual machine representation
139 #define REGISTER_RAW_SIZE(N) 4
141 /* Number of bytes of storage in the program's representation for register N. */
142 #define REGISTER_VIRTUAL_SIZE(N) 4
144 /* Largest value REGISTER_RAW_SIZE can have. */
145 #define MAX_REGISTER_RAW_SIZE 4
147 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
148 #define MAX_REGISTER_VIRTUAL_SIZE 4
150 /* Return the GDB type object for the "standard" data type
151 of data in register N. */
152 #define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int)
155 /* Macros for understanding function return values... */
157 /* Does the specified function use the "struct returning" convention
158 or the "value returning" convention? The "value returning" convention
159 almost invariably returns the entire value in registers. The
160 "struct returning" convention often returns the entire value in
161 memory, and passes a pointer (out of or into the function) saying
162 where the value (is or should go).
164 Since this sometimes depends on whether it was compiled with GCC,
165 this is also an argument. This is used in call_function to build a
166 stack, and in value_being_returned to print return values.
168 On arc, a structure is always retunred with pointer in r??. */
170 #define USE_STRUCT_CONVENTION(gcc_p, type) 1
172 /* Extract from an array REGBUF containing the (raw) register state
173 a function return value of type TYPE, and copy that, in virtual format,
174 into VALBUF. This is only called if USE_STRUCT_CONVENTION for this
177 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
178 memcpy(VALBUF, REGBUF+REGISTER_BYTE(R0_REGNUM), TYPE_LENGTH (TYPE))
180 /* If USE_STRUCT_CONVENTION produces a 1,
181 extract from an array REGBUF containing the (raw) register state
182 the address in which a function should return its structure value,
183 as a CORE_ADDR (or an expression that can be used as one). */
184 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
185 (error("Don't know where large structure is returned on arc"), 0)
187 /* Write into appropriate registers a function return value
188 of type TYPE, given in virtual format, for "value returning" functions.
189 For 'return' command: not (yet) implemented for arc. */
190 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
191 error ("Returning values from functions is not implemented in arc gdb")
193 /* Store the address of the place in which to copy the structure the
194 subroutine will return. This is called from call_function. */
195 #define STORE_STRUCT_RETURN(ADDR, SP) \
196 error ("Returning values from functions is not implemented in arc gdb")
199 /* Describe the pointer in each stack frame to the previous stack frame
202 /* FRAME_CHAIN takes a frame's nominal address
203 and produces the frame's chain-pointer.
204 However, if FRAME_CHAIN_VALID returns zero,
205 it means the given frame is the outermost one and has no caller. */
207 /* We cache information about saved registers in the frame structure,
208 to save us from having to re-scan function prologues every time
209 a register in a non-current frame is accessed. */
211 #define EXTRA_FRAME_INFO \
212 struct frame_saved_regs *fsr; \
213 CORE_ADDR arg_pointer;
215 /* Zero the frame_saved_regs pointer when the frame is initialized,
216 so that FRAME_FIND_SAVED_REGS () will know to allocate and
217 initialize a frame_saved_regs struct the first time it is called.
218 Set the arg_pointer to -1, which is not valid; 0 and other values
219 indicate real, cached values. */
221 #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \
222 ((fi)->fsr = 0, (fi)->arg_pointer = -1)
224 /* On the arc, we get the chain pointer by reading the PFP saved
226 /* the PFP and RPC is in fp and fp+4. or it is in fp+4 and fp+8 ??? */
228 #define FRAME_CHAIN(thisframe) \
229 (read_memory_integer (FRAME_FP(thisframe), 4))
231 /* FRAME_CHAIN_VALID returns zero if the given frame is the outermost one
233 #define FRAME_CHAIN_VALID(thisframe) \
236 /* A macro that tells us whether the function invocation represented
237 by FI does not have a frame on the stack associated with it. If it
238 does not, FRAMELESS is set to 1, else 0. */
240 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
242 if ((FI)->signal_handler_caller) \
245 (FRAMELESS) = frameless_look_for_prologue(FI); \
248 #define FRAME_SAVED_PC(frame) \
249 (read_memory_integer(FRAME_CHAIN(frame)+8,4))
251 /* On the ARC, FRAME_ARGS_ADDRESS should return the value of
252 g14 as passed into the frame, if known. We need a function for this.
253 We cache this value in the frame info if we've already looked it up. */
255 #define FRAME_ARGS_ADDRESS(fi) \
256 (((fi)->arg_pointer != -1)? (fi)->arg_pointer: (fi)->frame + 4)
258 /* This is the same except it should return 0 when
259 it does not really know where the args are, rather than guessing.
260 This value is not cached since it is only used infrequently. */
262 #define FRAME_LOCALS_ADDRESS(fi) (fi)->frame + 4
264 /* Set NUMARGS to the number of args passed to a frame.
265 Can return -1, meaning no way to tell. */
267 #define FRAME_NUM_ARGS(numargs, fi) (numargs = -1)
269 /* Return number of bytes at start of arglist that are not really args. */
271 #define FRAME_ARGS_SKIP 0
273 /* Produce the positions of the saved registers in a stack frame. */
275 #define FRAME_FIND_SAVED_REGS(frame_info_addr, sr) \
276 frame_find_saved_regs (frame_info_addr, &sr)
277 extern void frame_find_saved_regs(); /* See arc-tdep.c */
280 /* Things needed for making calls to functions in the inferior process */
281 #define PUSH_DUMMY_FRAME \
284 /* Discard from the stack the innermost frame, restoring all registers. */
288 /* This sequence of words is the instructions bl xxxx, flag 1 */
289 #define CALL_DUMMY { 0x28000000, 0x1fbe8001 }
290 #define CALL_DUMMY_LENGTH 8
292 /* Start execution at beginning of dummy */
293 #define CALL_DUMMY_START_OFFSET 0
295 /* Insert the specified number of args and function address
296 into a call sequence of the above form stored at 'dummyname'.*/
297 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
299 int from, to, delta, loc; \
300 loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \
303 delta = (to - from) >> 2; \
304 *((char *)(dummyname) + 1) = (delta & 0x1); \
305 *((char *)(dummyname) + 2) = ((delta >> 1) & 0xff); \
306 *((char *)(dummyname) + 3) = ((delta >> 9) & 0xff); \
307 *((char *)(dummyname) + 4) = ((delta >> 17) & 0x7); \