#define yyerrflag and yynerrs to avoid global name conflicts.
[deliverable/binutils-gdb.git] / gdb / tm-arm.h
CommitLineData
dd3b648e
RP
1/* Definitions to make GDB target for an ARM under RISCiX (4.3bsd).
2 Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
99a7de40 6This program is free software; you can redistribute it and/or modify
dd3b648e 7it under the terms of the GNU General Public License as published by
99a7de40
JG
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
dd3b648e 10
99a7de40 11This program is distributed in the hope that it will be useful,
dd3b648e
RP
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
99a7de40
JG
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
dd3b648e
RP
19
20#define TARGET_BYTE_ORDER LITTLE_ENDIAN
21
22/* IEEE format floating point */
23
24#define IEEE_FLOAT
25
26/* I provide my own xfer_core_file to cope with shared libraries */
27
28#define XFER_CORE_FILE
29
30/* Define this if the C compiler puts an underscore at the front
31 of external names before giving them to the linker. */
32
33#define NAMES_HAVE_UNDERSCORE
34
35/* Debugger information will be in DBX format. */
36
37#define READ_DBX_FORMAT
38
39/* Offset from address of function to start of its code.
40 Zero on most machines. */
41
42#define FUNCTION_START_OFFSET 0
43
44/* Advance PC across any function entry prologue instructions
45 to reach some "real" code. */
46
47#define SKIP_PROLOGUE(pc) pc = skip_prologue(pc)
48
49/* Immediately after a function call, return the saved pc.
50 Can't always go through the frames for this because on some machines
51 the new frame is not set up until the new function executes
52 some instructions. */
53
54#define SAVED_PC_AFTER_CALL(frame) (read_register (LR_REGNUM) & 0x03fffffc)
55
56/* I don't know the real values for these. */
57#define TARGET_UPAGES UPAGES
58#define TARGET_NBPG NBPG
59
60/* Address of end of stack space. */
61
62#define STACK_END_ADDR (0x01000000 - (TARGET_UPAGES * TARGET_NBPG))
63
64/* Stack grows downward. */
65
66#define INNER_THAN <
67
68/* Sequence of bytes for breakpoint instruction. */
69
70#define BREAKPOINT {0x00,0x00,0x18,0xef} /* BKPT_SWI from <sys/ptrace.h> */
71
72/* Amount PC must be decremented by after a breakpoint.
73 This is often the number of bytes in BREAKPOINT
74 but not always. */
75
76#define DECR_PC_AFTER_BREAK 0
77
78/* Nonzero if instruction at PC is a return instruction. */
79
80#define ABOUT_TO_RETURN(pc) \
81 ((read_memory_integer(pc, 4) & 0x0fffffff == 0x01b0f00e) || \
82 (read_memory_integer(pc, 4) & 0x0ffff800 == 0x09eba800))
83
84/* Return 1 if P points to an invalid floating point value.
85 LEN is the length in bytes. */
86
87#define INVALID_FLOAT(p, len) 0
88
89/* code to execute to print interesting information about the
90 * floating point processor (if any)
91 * No need to define if there is nothing to do.
92 */
93#define FLOAT_INFO { arm_float_info (); }
94
95/* Say how long (ordinary) registers are. */
96
97#define REGISTER_TYPE long
98
99/* Number of machine registers */
100
101/* Note: I make a fake copy of the pc in register 25 (calling it ps) so
102 that I can clear the status bits from pc (register 15) */
103
104#define NUM_REGS 26
105
106/* Initializer for an array of names of registers.
107 There should be NUM_REGS strings in this initializer. */
108
109#define REGISTER_NAMES \
110 { "a1", "a2", "a3", "a4", \
111 "v1", "v2", "v3", "v4", "v5", "v6", \
112 "sl", "fp", "ip", "sp", "lr", "pc", \
113 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "fps", "ps" }
114
115/* Register numbers of various important registers.
116 Note that some of these values are "real" register numbers,
117 and correspond to the general registers of the machine,
118 and some are "phony" register numbers which are too large
119 to be actual register numbers as far as the user is concerned
120 but do serve to get the desired values when passed to read_register. */
121
122#define AP_REGNUM 11
123#define FP_REGNUM 11 /* Contains address of executing stack frame */
124#define SP_REGNUM 13 /* Contains address of top of stack */
125#define LR_REGNUM 14 /* address to return to from a function call */
126#define PC_REGNUM 15 /* Contains program counter */
127#define F0_REGNUM 16 /* first floating point register */
128#define FPS_REGNUM 24 /* floating point status register */
129#define PS_REGNUM 25 /* Contains processor status */
130
131
132/* Total amount of space needed to store our copies of the machine's
133 register state, the array `registers'. */
134#define REGISTER_BYTES (16*4 + 12*8 + 4 + 4)
135
136/* Index within `registers' of the first byte of the space for
137 register N. */
138
139#define REGISTER_BYTE(N) (((N) < F0_REGNUM) ? (N)*4 : \
140 (((N) < PS_REGNUM) ? 16*4 + ((N) - 16)*12 : \
141 16*4 + 8*12 + ((N) - FPS_REGNUM) * 4))
142
143/* Number of bytes of storage in the actual machine representation
144 for register N. On the vax, all regs are 4 bytes. */
145
146#define REGISTER_RAW_SIZE(N) (((N) < F0_REGNUM || (N) >= FPS_REGNUM) ? 4 : 12)
147
148/* Number of bytes of storage in the program's representation
149 for register N. On the vax, all regs are 4 bytes. */
150
151#define REGISTER_VIRTUAL_SIZE(N) (((N) < F0_REGNUM || (N) >= FPS_REGNUM) ? 4 : 8)
152
153/* Largest value REGISTER_RAW_SIZE can have. */
154
155#define MAX_REGISTER_RAW_SIZE 12
156
157/* Largest value REGISTER_VIRTUAL_SIZE can have. */
158
159#define MAX_REGISTER_VIRTUAL_SIZE 8
160
161/* Nonzero if register N requires conversion
162 from raw format to virtual format. */
163
164#define REGISTER_CONVERTIBLE(N) ((unsigned)(N) - F0_REGNUM < 8)
165
166/* Convert data from raw format for register REGNUM
167 to virtual format for register REGNUM. */
168
169#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
170 if (REGISTER_CONVERTIBLE(REGNUM)) \
171 convert_from_extended((FROM), (TO)); \
172 else \
173 bcopy ((FROM), (TO), 4);
174
175/* Convert data from virtual format for register REGNUM
176 to raw format for register REGNUM. */
177
178#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
179 if (REGISTER_CONVERTIBLE(REGNUM)) \
180 convert_to_extended((FROM), (TO)); \
181 else \
182 bcopy ((FROM), (TO), 4);
183
184/* Return the GDB type object for the "standard" data type
185 of data in register N. */
186
187#define REGISTER_VIRTUAL_TYPE(N) \
188 (((unsigned)(N) - F0_REGNUM) < 8 ? builtin_type_double : builtin_type_int)
189\f
190/* The system C compiler uses a similar structure return convention to gcc */
191
192#define USE_STRUCT_CONVENTION(gcc_p, type) (TYPE_LENGTH (type) > 4)
193
194/* Store the address of the place in which to copy the structure the
195 subroutine will return. This is called from call_function. */
196
197#define STORE_STRUCT_RETURN(ADDR, SP) \
198 { write_register (0, (ADDR)); }
199
200/* Extract from an array REGBUF containing the (raw) register state
201 a function return value of type TYPE, and copy that, in virtual format,
202 into VALBUF. */
203
204#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
205 if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
206 convert_from_extended(REGBUF + REGISTER_BYTE (F0_REGNUM), VALBUF); \
207 else \
208 bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
209
210/* Write into appropriate registers a function return value
211 of type TYPE, given in virtual format. */
212
213#define STORE_RETURN_VALUE(TYPE,VALBUF) \
214 if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) { \
215 char _buf[MAX_REGISTER_RAW_SIZE]; \
216 convert_to_extended(VALBUF, _buf); \
217 write_register_bytes (REGISTER_BYTE (F0_REGNUM), _buf, MAX_REGISTER_RAW_SIZE); \
218 } else \
219 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
220
221/* Extract from an array REGBUF containing the (raw) register state
222 the address in which a function should return its structure value,
223 as a CORE_ADDR (or an expression that can be used as one). */
224
225#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
226
227/* Specify that for the native compiler variables for a particular
228 lexical context are listed after the beginning LBRAC instead of
229 before in the executables list of symbols. */
230#define VARIABLES_INSIDE_BLOCK(desc, gcc_p) (!(gcc_p))
231
232\f
233/* Describe the pointer in each stack frame to the previous stack frame
234 (its caller). */
235
236/* FRAME_CHAIN takes a frame's nominal address
237 and produces the frame's chain-pointer.
238
239 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
240 and produces the nominal address of the caller frame.
241
242 However, if FRAME_CHAIN_VALID returns zero,
243 it means the given frame is the outermost one and has no caller.
244 In that case, FRAME_CHAIN_COMBINE is not used. */
245
246/* In the case of the ARM, the frame's nominal address is the FP value,
247 and 12 bytes before comes the saved previous FP value as a 4-byte word. */
248
249#define FRAME_CHAIN(thisframe) \
250 ((thisframe)->pc >= first_object_file_end ? \
251 read_memory_integer ((thisframe)->frame - 12, 4) :\
252 0)
253
254#define FRAME_CHAIN_VALID(chain, thisframe) \
255 (chain != 0 && (FRAME_SAVED_PC (thisframe) >= first_object_file_end))
256
257#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
258
259/* Define other aspects of the stack frame. */
260
261/* A macro that tells us whether the function invocation represented
262 by FI does not have a frame on the stack associated with it. If it
263 does not, FRAMELESS is set to 1, else 0. */
264#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
265{ \
266 CORE_ADDR func_start, after_prologue; \
267 func_start = (get_pc_function_start ((FI)->pc) + \
268 FUNCTION_START_OFFSET); \
269 after_prologue = func_start; \
270 SKIP_PROLOGUE (after_prologue); \
271 (FRAMELESS) = (after_prologue == func_start); \
272}
273
274/* Saved Pc. */
275
276#define FRAME_SAVED_PC(FRAME) \
277 (read_memory_integer ((FRAME)->frame - 4, 4) & 0x03fffffc)
278
279#define FRAME_ARGS_ADDRESS(fi) (fi->frame)
280
281#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
282
283/* Return number of args passed to a frame.
284 Can return -1, meaning no way to tell. */
285
286#define FRAME_NUM_ARGS(numargs, fi) (numargs = -1)
287
288/* Return number of bytes at start of arglist that are not really args. */
289
290#define FRAME_ARGS_SKIP 0
291
292/* Put here the code to store, into a struct frame_saved_regs,
293 the addresses of the saved registers of frame described by FRAME_INFO.
294 This includes special registers such as pc and fp saved in special
295 ways in the stack frame. sp is even more special:
296 the address we return for it IS the sp for the next frame. */
297
298#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
299{ \
300 register int regnum; \
301 register int frame; \
302 register int next_addr; \
303 register int return_data_save; \
304 register int saved_register_mask; \
305 bzero (&frame_saved_regs, sizeof frame_saved_regs); \
306 frame = (frame_info)->frame; \
307 return_data_save = read_memory_integer(frame, 4) & 0x03fffffc - 12; \
308 saved_register_mask = \
309 read_memory_integer(return_data_save, 4); \
310 next_addr = frame - 12; \
311 for (regnum = 4; regnum < 10; regnum++) \
312 if (saved_register_mask & (1<<regnum)) { \
313 next_addr -= 4; \
314 (frame_saved_regs).regs[regnum] = next_addr; \
315 } \
316 if (read_memory_integer(return_data_save + 4, 4) == 0xed6d7103) { \
317 next_addr -= 12; \
318 (frame_saved_regs).regs[F0_REGNUM + 7] = next_addr; \
319 } \
320 if (read_memory_integer(return_data_save + 8, 4) == 0xed6d6103) { \
321 next_addr -= 12; \
322 (frame_saved_regs).regs[F0_REGNUM + 6] = next_addr; \
323 } \
324 if (read_memory_integer(return_data_save + 12, 4) == 0xed6d5103) { \
325 next_addr -= 12; \
326 (frame_saved_regs).regs[F0_REGNUM + 5] = next_addr; \
327 } \
328 if (read_memory_integer(return_data_save + 16, 4) == 0xed6d4103) { \
329 next_addr -= 12; \
330 (frame_saved_regs).regs[F0_REGNUM + 4] = next_addr; \
331 } \
332 (frame_saved_regs).regs[SP_REGNUM] = next_addr; \
333 (frame_saved_regs).regs[PC_REGNUM] = frame - 4; \
334 (frame_saved_regs).regs[PS_REGNUM] = frame - 4; \
335 (frame_saved_regs).regs[FP_REGNUM] = frame - 12; \
336}
337\f
338/* Things needed for making the inferior call functions. */
339
340/* Push an empty stack frame, to record the current PC, etc. */
341
342#define PUSH_DUMMY_FRAME \
343{ \
344 register CORE_ADDR sp = read_register (SP_REGNUM); \
345 register int regnum; \
346 /* opcode for ldmdb fp,{v1-v6,fp,ip,lr,pc}^ */ \
347 sp = push_word(sp, 0xe92dbf0); /* dummy return_data_save ins */ \
348 /* push a pointer to the dummy instruction minus 12 */ \
349 sp = push_word(sp, read_register (SP_REGNUM) - 16); \
350 sp = push_word(sp, read_register (PS_REGNUM)); \
351 sp = push_word(sp, read_register (SP_REGNUM)); \
352 sp = push_word(sp, read_register (FP_REGNUM)); \
353 for (regnum = 9; regnum >= 4; regnum --) \
354 sp = push_word(sp, read_register (regnum)); \
355 write_register (FP_REGNUM, read_register (SP_REGNUM) - 8); \
356 write_register (SP_REGNUM, sp); }
357
358/* Discard from the stack the innermost frame, restoring all registers. */
359
360#define POP_FRAME \
361{ \
362 register CORE_ADDR fp = read_register (FP_REGNUM); \
363 register unsigned long return_data_save = \
364 read_memory_integer ( (read_memory_integer (fp, 4) & \
365 0x03fffffc) - 12, 4); \
366 register int regnum; \
367 write_register (PS_REGNUM, read_memory_integer (fp - 4, 4)); \
368 write_register (PC_REGNUM, read_register (PS_REGNUM) & 0x03fffffc); \
369 write_register (SP_REGNUM, read_memory_integer (fp - 8, 4)); \
370 write_register (FP_REGNUM, read_memory_integer (fp - 12, 4)); \
371 fp -= 12; \
372 for (regnum = 9; regnum >= 4; regnum--) \
373 if (return_data_save & (1<<regnum)) { \
374 fp -= 4; \
375 write_register (regnum, read_memory_integer(fp, 4)); \
376 } \
377 flush_cached_frames (); \
378 set_current_frame (create_new_frame (read_register (FP_REGNUM), \
379 read_pc ())); \
380}
381
382/* This sequence of words is the instructions
383
384 ldmia sp!,{a1-a4}
385 mov lk,pc
386 bl *+8
387 swi bkpt_swi
388
389 Note this is 16 bytes. */
390
391#define CALL_DUMMY {0xe8bd000f, 0xe1a0e00f, 0xeb000000, 0xef180000}
392
393#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
394
395/* Insert the specified number of args and function address
396 into a call sequence of the above form stored at DUMMYNAME. */
397
398#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
399{ \
400 register enum type_code code = TYPE_CODE (type); \
401 register nargs_in_registers, struct_return = 0; \
402 /* fix the load-arguments mask to move the first 4 or less arguments \
403 into a1-a4 but make sure the structure return address in a1 is \
404 not disturbed if the function is returning a structure */ \
405 if ((code == TYPE_CODE_STRUCT || \
406 code == TYPE_CODE_UNION || \
407 code == TYPE_CODE_ARRAY) && \
408 TYPE_LENGTH (type) > 4) { \
409 nargs_in_registers = min(nargs + 1, 4); \
410 struct_return = 1; \
411 } else \
412 nargs_in_registers = min(nargs, 4); \
413 *(char *) dummyname = (1 << nargs_in_registers) - 1 - struct_return; \
414 *(int *)((char *) dummyname + 8) = \
415 (((fun - (pc + 16)) / 4) & 0x00ffffff) | 0xeb000000; }
This page took 0.048996 seconds and 4 git commands to generate.