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