4fbeafd7e5ee1f5d9747f3d188c6301a2814c4d3
[deliverable/binutils-gdb.git] / gdb / config / arm / tm-arm.h
1 /* Definitions to make GDB target for an ARM
2 Copyright 1986-1989, 1991, 1993-1999 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 #ifdef __STDC__ /* Forward decls for prototypes */
22 struct type;
23 struct value;
24 #endif
25
26 #define TARGET_BYTE_ORDER_SELECTABLE
27
28 /* IEEE format floating point */
29
30 #define IEEE_FLOAT
31
32 /* FIXME: may need a floatformat_ieee_double_bigbyte_littleword format for
33 BIG_ENDIAN use. -fnf */
34
35 #define TARGET_DOUBLE_FORMAT (target_byte_order == BIG_ENDIAN \
36 ? &floatformat_ieee_double_big \
37 : &floatformat_ieee_double_littlebyte_bigword)
38
39 /* When reading symbols, we need to zap the low bit of the address, which
40 may be set to 1 for Thumb functions. */
41
42 #define SMASH_TEXT_ADDRESS(addr) ((addr) &= ~0x1)
43
44 /* Remove useless bits from addresses in a running program. */
45
46 CORE_ADDR arm_addr_bits_remove PARAMS ((CORE_ADDR));
47
48 #define ADDR_BITS_REMOVE(val) (arm_addr_bits_remove (val))
49
50 /* Offset from address of function to start of its code.
51 Zero on most machines. */
52
53 #define FUNCTION_START_OFFSET 0
54
55 /* Advance PC across any function entry prologue instructions
56 to reach some "real" code. */
57
58 extern CORE_ADDR arm_skip_prologue PARAMS ((CORE_ADDR pc));
59
60 #define SKIP_PROLOGUE(pc) (arm_skip_prologue (pc))
61
62 /* Immediately after a function call, return the saved pc.
63 Can't always go through the frames for this because on some machines
64 the new frame is not set up until the new function executes
65 some instructions. */
66
67 #define SAVED_PC_AFTER_CALL(frame) arm_saved_pc_after_call (frame)
68 struct frame_info;
69 extern CORE_ADDR arm_saved_pc_after_call PARAMS ((struct frame_info *));
70
71 /* I don't know the real values for these. */
72 #define TARGET_UPAGES UPAGES
73 #define TARGET_NBPG NBPG
74
75 /* Address of end of stack space. */
76
77 #define STACK_END_ADDR (0x01000000 - (TARGET_UPAGES * TARGET_NBPG))
78
79 /* Stack grows downward. */
80
81 #define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
82
83 /* !!!! if we're using RDP, then we're inserting breakpoints and storing
84 their handles instread of what was in memory. It is nice that
85 this is the same size as a handle - otherwise remote-rdp will
86 have to change. */
87
88 /* BREAKPOINT_FROM_PC uses the program counter value to determine whether a
89 16- or 32-bit breakpoint should be used. It returns a pointer
90 to a string of bytes that encode a breakpoint instruction, stores
91 the length of the string to *lenptr, and adjusts the pc (if necessary) to
92 point to the actual memory location where the breakpoint should be
93 inserted. */
94
95 extern breakpoint_from_pc_fn arm_breakpoint_from_pc;
96 #define BREAKPOINT_FROM_PC(pcptr, lenptr) arm_breakpoint_from_pc (pcptr, lenptr)
97
98 /* Amount PC must be decremented by after a breakpoint.
99 This is often the number of bytes in BREAKPOINT
100 but not always. */
101
102 #define DECR_PC_AFTER_BREAK 0
103
104 /* code to execute to print interesting information about the
105 * floating point processor (if any)
106 * No need to define if there is nothing to do.
107 */
108 #define FLOAT_INFO { arm_float_info (); }
109
110 /* Say how long (ordinary) registers are. This is a piece of bogosity
111 used in push_word and a few other places; REGISTER_RAW_SIZE is the
112 real way to know how big a register is. */
113
114 #define REGISTER_SIZE 4
115
116 /* Number of machine registers */
117
118 /* Note: I make a fake copy of the pc in register 25 (calling it ps) so
119 that I can clear the status bits from pc (register 15) */
120
121 #define NUM_REGS 26
122
123 /* An array of names of registers. */
124
125 extern char **arm_register_names;
126 #define REGISTER_NAME(i) arm_register_names[i]
127
128 /* Register numbers of various important registers.
129 Note that some of these values are "real" register numbers,
130 and correspond to the general registers of the machine,
131 and some are "phony" register numbers which are too large
132 to be actual register numbers as far as the user is concerned
133 but do serve to get the desired values when passed to read_register. */
134
135 #define A1_REGNUM 0 /* first integer-like argument */
136 #define A4_REGNUM 3 /* last integer-like argument */
137 #define AP_REGNUM 11
138 #define FP_REGNUM 11 /* Contains address of executing stack frame */
139 #define SP_REGNUM 13 /* Contains address of top of stack */
140 #define LR_REGNUM 14 /* address to return to from a function call */
141 #define PC_REGNUM 15 /* Contains program counter */
142 #define F0_REGNUM 16 /* first floating point register */
143 #define F3_REGNUM 19 /* last floating point argument register */
144 #define F7_REGNUM 23 /* last floating point register */
145 #define FPS_REGNUM 24 /* floating point status register */
146 #define PS_REGNUM 25 /* Contains processor status */
147
148 #define THUMB_FP_REGNUM 7 /* R7 is frame register on Thumb */
149
150 #define ARM_NUM_ARG_REGS 4
151 #define ARM_LAST_ARG_REGNUM A4_REGNUM
152 #define ARM_NUM_FP_ARG_REGS 4
153 #define ARM_LAST_FP_ARG_REGNUM F3_REGNUM
154
155 /* Instruction condition field values. */
156 #define INST_EQ 0x0
157 #define INST_NE 0x1
158 #define INST_CS 0x2
159 #define INST_CC 0x3
160 #define INST_MI 0x4
161 #define INST_PL 0x5
162 #define INST_VS 0x6
163 #define INST_VC 0x7
164 #define INST_HI 0x8
165 #define INST_LS 0x9
166 #define INST_GE 0xa
167 #define INST_LT 0xb
168 #define INST_GT 0xc
169 #define INST_LE 0xd
170 #define INST_AL 0xe
171 #define INST_NV 0xf
172
173 #define FLAG_N 0x80000000
174 #define FLAG_Z 0x40000000
175 #define FLAG_C 0x20000000
176 #define FLAG_V 0x10000000
177
178
179
180 /* Total amount of space needed to store our copies of the machine's
181 register state, the array `registers'. */
182 #define REGISTER_BYTES (16*4 + 12*8 + 4 + 4)
183
184 /* Index within `registers' of the first byte of the space for
185 register N. */
186
187 #define REGISTER_BYTE(N) (((N) < F0_REGNUM) ? (N)*4 : \
188 (((N) < PS_REGNUM) ? 16*4 + ((N) - 16)*12 : \
189 16*4 + 8*12 + ((N) - FPS_REGNUM) * 4))
190
191 /* Number of bytes of storage in the actual machine representation
192 for register N. On the vax, all regs are 4 bytes. */
193
194 #define REGISTER_RAW_SIZE(N) (((N) < F0_REGNUM || (N) >= FPS_REGNUM) ? 4 : 12)
195
196 /* Number of bytes of storage in the program's representation
197 for register N. On the vax, all regs are 4 bytes. */
198
199 #define REGISTER_VIRTUAL_SIZE(N) (((N) < F0_REGNUM || (N) >= FPS_REGNUM) ? 4 : 8)
200
201 /* Largest value REGISTER_RAW_SIZE can have. */
202
203 #define MAX_REGISTER_RAW_SIZE 12
204
205 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
206
207 #define MAX_REGISTER_VIRTUAL_SIZE 8
208
209 /* Nonzero if register N requires conversion
210 from raw format to virtual format. */
211 #define REGISTER_CONVERTIBLE(N) ((unsigned)(N) - F0_REGNUM < 8)
212
213 /* Convert data from raw format for register REGNUM in buffer FROM
214 to virtual format with type TYPE in buffer TO. */
215
216 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
217 { \
218 double val; \
219 convert_from_extended ((FROM), & val); \
220 store_floating ((TO), TYPE_LENGTH (TYPE), val); \
221 }
222
223 /* Convert data from virtual format with type TYPE in buffer FROM
224 to raw format for register REGNUM in buffer TO. */
225
226 #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
227 { \
228 double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
229 convert_to_extended (&val, (TO)); \
230 }
231 /* Return the GDB type object for the "standard" data type
232 of data in register N. */
233
234 #define REGISTER_VIRTUAL_TYPE(N) \
235 (((unsigned)(N) - F0_REGNUM) < 8 ? builtin_type_double : builtin_type_int)
236 \f
237 /* The system C compiler uses a similar structure return convention to gcc */
238 extern use_struct_convention_fn arm_use_struct_convention;
239 #define USE_STRUCT_CONVENTION(gcc_p, type) arm_use_struct_convention (gcc_p, type)
240
241 /* Store the address of the place in which to copy the structure the
242 subroutine will return. This is called from call_function. */
243
244 #define STORE_STRUCT_RETURN(ADDR, SP) \
245 { write_register (0, (ADDR)); }
246
247 /* Extract from an array REGBUF containing the (raw) register state
248 a function return value of type TYPE, and copy that, in virtual format,
249 into VALBUF. */
250
251 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
252 if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \
253 convert_from_extended (REGBUF + REGISTER_BYTE (F0_REGNUM), VALBUF); \
254 else \
255 memcpy (VALBUF, REGBUF, TYPE_LENGTH (TYPE))
256
257 /* Write into appropriate registers a function return value
258 of type TYPE, given in virtual format. */
259
260 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
261 if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) { \
262 char _buf[MAX_REGISTER_RAW_SIZE]; \
263 convert_to_extended (VALBUF, _buf); \
264 write_register_bytes (REGISTER_BYTE (F0_REGNUM), _buf, MAX_REGISTER_RAW_SIZE); \
265 } else \
266 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
267
268 /* Extract from an array REGBUF containing the (raw) register state
269 the address in which a function should return its structure value,
270 as a CORE_ADDR (or an expression that can be used as one). */
271
272 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
273 (extract_address ((PTR) (REGBUF), REGISTER_RAW_SIZE(0)))
274
275 /* Specify that for the native compiler variables for a particular
276 lexical context are listed after the beginning LBRAC instead of
277 before in the executables list of symbols. */
278 #define VARIABLES_INSIDE_BLOCK(desc, gcc_p) (!(gcc_p))
279 \f
280
281 /* Define other aspects of the stack frame.
282 We keep the offsets of all saved registers, 'cause we need 'em a lot!
283 We also keep the current size of the stack frame, and the offset of
284 the frame pointer from the stack pointer (for frameless functions, and
285 when we're still in the prologue of a function with a frame) */
286
287 #define EXTRA_FRAME_INFO \
288 struct frame_saved_regs fsr; \
289 int framesize; \
290 int frameoffset; \
291 int framereg;
292
293 extern void arm_init_extra_frame_info PARAMS ((int fromleaf,
294 struct frame_info *fi));
295 #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \
296 arm_init_extra_frame_info (fromleaf, fi)
297
298 /* Return the frame address. On ARM, it is R11; on Thumb it is R7. */
299 CORE_ADDR arm_target_read_fp PARAMS ((void));
300 #define TARGET_READ_FP() arm_target_read_fp ()
301
302 /* Describe the pointer in each stack frame to the previous stack frame
303 (its caller). */
304
305 /* FRAME_CHAIN takes a frame's nominal address
306 and produces the frame's chain-pointer.
307
308 However, if FRAME_CHAIN_VALID returns zero,
309 it means the given frame is the outermost one and has no caller. */
310
311 #define FRAME_CHAIN(thisframe) (CORE_ADDR) arm_frame_chain (thisframe)
312 extern CORE_ADDR arm_frame_chain PARAMS ((struct frame_info *));
313
314 extern int arm_frame_chain_valid PARAMS ((CORE_ADDR, struct frame_info *));
315 #define FRAME_CHAIN_VALID(chain, thisframe) arm_frame_chain_valid (chain, thisframe)
316
317 /* Define other aspects of the stack frame. */
318
319 /* A macro that tells us whether the function invocation represented
320 by FI does not have a frame on the stack associated with it. If it
321 does not, FRAMELESS is set to 1, else 0.
322
323 Sometimes we have functions that do a little setup (like saving the vN
324 registers with the stmdb instruction, but DO NOT set up a frame.
325 The symbol table will report this as a prologue. However, it is
326 important not to try to parse these partial frames as frames, or we
327 will get really confused.
328
329 So I will demand 3 instructions between the start & end of the prologue
330 before I call it a real prologue, i.e. at least
331 mov ip, sp,
332 stmdb sp!, {}
333 sub sp, ip, #4. */
334
335 #define FRAMELESS_FUNCTION_INVOCATION(FI) \
336 (arm_frameless_function_invocation (FI))
337
338 /* Saved Pc. */
339
340 #define FRAME_SAVED_PC(FRAME) arm_frame_saved_pc (FRAME)
341 extern CORE_ADDR arm_frame_saved_pc PARAMS ((struct frame_info *));
342
343 #define FRAME_ARGS_ADDRESS(fi) (fi->frame)
344
345 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
346
347 /* Return number of args passed to a frame.
348 Can return -1, meaning no way to tell. */
349
350 #define FRAME_NUM_ARGS(fi) (-1)
351
352 /* Return number of bytes at start of arglist that are not really args. */
353
354 #define FRAME_ARGS_SKIP 0
355
356 /* Put here the code to store, into a struct frame_saved_regs,
357 the addresses of the saved registers of frame described by FRAME_INFO.
358 This includes special registers such as pc and fp saved in special
359 ways in the stack frame. sp is even more special:
360 the address we return for it IS the sp for the next frame. */
361
362 struct frame_saved_regs;
363 struct frame_info;
364 void frame_find_saved_regs PARAMS ((struct frame_info * fi,
365 struct frame_saved_regs * fsr));
366
367 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
368 arm_frame_find_saved_regs (frame_info, &(frame_saved_regs));
369 \f
370
371 /* Things needed for making the inferior call functions. */
372
373 #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
374 (arm_push_arguments ((nargs), (args), (sp), (struct_return), (struct_addr)))
375 extern CORE_ADDR arm_push_arguments PARAMS ((int, struct value **, CORE_ADDR, int, CORE_ADDR));
376
377 /* Push an empty stack frame, to record the current PC, etc. */
378
379 void arm_push_dummy_frame PARAMS ((void));
380
381 #define PUSH_DUMMY_FRAME arm_push_dummy_frame ()
382
383 /* Discard from the stack the innermost frame, restoring all registers. */
384
385 void arm_pop_frame PARAMS ((void));
386
387 #define POP_FRAME arm_pop_frame ()
388
389 /* This sequence of words is the instructions
390
391 mov lr,pc
392 mov pc,r4
393 illegal
394
395 Note this is 12 bytes. */
396
397 #define CALL_DUMMY {0xe1a0e00f, 0xe1a0f004, 0xE7FFDEFE}
398
399 #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
400
401 #define CALL_DUMMY_BREAKPOINT_OFFSET arm_call_dummy_breakpoint_offset()
402 extern int arm_call_dummy_breakpoint_offset PARAMS ((void));
403
404 /* Insert the specified number of args and function address
405 into a call sequence of the above form stored at DUMMYNAME. */
406
407 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
408 arm_fix_call_dummy (dummyname, pc, fun, nargs, args, type, gcc_p)
409
410 void arm_fix_call_dummy PARAMS ((char *dummy, CORE_ADDR pc, CORE_ADDR fun,
411 int nargs, struct value ** args,
412 struct type * type, int gcc_p));
413
414 CORE_ADDR arm_get_next_pc PARAMS ((CORE_ADDR));
415
416 /* Functions for dealing with Thumb call thunks. */
417 #define IN_SOLIB_CALL_TRAMPOLINE(pc, name) arm_in_call_stub (pc, name)
418 #define SKIP_TRAMPOLINE_CODE(pc) arm_skip_stub (pc)
419 extern int arm_in_call_stub PARAMS ((CORE_ADDR pc, char *name));
420 extern CORE_ADDR arm_skip_stub PARAMS ((CORE_ADDR pc));
421
422 /* Function to determine whether MEMADDR is in a Thumb function. */
423 extern int arm_pc_is_thumb PARAMS ((bfd_vma memaddr));
424
425 /* Function to determine whether MEMADDR is in a call dummy called from
426 a Thumb function. */
427 extern int arm_pc_is_thumb_dummy PARAMS ((bfd_vma memaddr));
428
429 /* Macros for setting and testing a bit in a minimal symbol that
430 marks it as Thumb function. The MSB of the minimal symbol's
431 "info" field is used for this purpose. This field is already
432 being used to store the symbol size, so the assumption is
433 that the symbol size cannot exceed 2^31.
434
435 COFF_MAKE_MSYMBOL_SPECIAL
436 ELF_MAKE_MSYMBOL_SPECIAL tests whether the COFF or ELF symbol corresponds
437 to a thumb function, and sets a "special" bit in a
438 minimal symbol to indicate that it does
439 MSYMBOL_SET_SPECIAL actually sets the "special" bit
440 MSYMBOL_IS_SPECIAL tests the "special" bit in a minimal symbol
441 MSYMBOL_SIZE returns the size of the minimal symbol, i.e.
442 the "info" field with the "special" bit masked out
443 */
444
445 extern int coff_sym_is_thumb (int val);
446 #define MSYMBOL_SET_SPECIAL(msym) \
447 MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym)) | 0x80000000)
448 #define MSYMBOL_IS_SPECIAL(msym) \
449 (((long) MSYMBOL_INFO (msym) & 0x80000000) != 0)
450 #define MSYMBOL_SIZE(msym) \
451 ((long) MSYMBOL_INFO (msym) & 0x7fffffff)
452
453 /* Thumb symbol are of type STT_LOPROC, (synonymous with STT_ARM_TFUNC) */
454 #define ELF_MAKE_MSYMBOL_SPECIAL(sym,msym) \
455 { if(ELF_ST_TYPE(((elf_symbol_type *)(sym))->internal_elf_sym.st_info) == STT_LOPROC) \
456 MSYMBOL_SET_SPECIAL(msym); }
457
458 #define COFF_MAKE_MSYMBOL_SPECIAL(val,msym) \
459 { if(coff_sym_is_thumb(val)) MSYMBOL_SET_SPECIAL(msym); }
460
461 #undef IN_SIGTRAMP
462 #define IN_SIGTRAMP(pc, name) 0
This page took 0.040887 seconds and 4 git commands to generate.