* config/pa/tm-hppa.h: Define macro SMASH_TEXT_ADDRESS.
[deliverable/binutils-gdb.git] / gdb / config / pa / tm-hppa.h
1 /* Parameters for execution on any Hewlett-Packard PA-RISC machine.
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993
3 Free Software Foundation, Inc.
4
5 Contributed by the Center for Software Science at the
6 University of Utah (pa-gdb-bugs@cs.utah.edu).
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
23
24 /* Target system byte order. */
25
26 #define TARGET_BYTE_ORDER BIG_ENDIAN
27
28 /* Get at various relevent fields of an instruction word. */
29
30 #define MASK_5 0x1f
31 #define MASK_11 0x7ff
32 #define MASK_14 0x3fff
33 #define MASK_21 0x1fffff
34
35 /* This macro gets bit fields using HP's numbering (MSB = 0) */
36
37 #define GET_FIELD(X, FROM, TO) \
38 ((X) >> 31 - (TO) & (1 << ((TO) - (FROM) + 1)) - 1)
39
40 /* Watch out for NaNs */
41
42 #define IEEE_FLOAT
43
44 /* When passing a structure to a function, GCC passes the address
45 in a register, not the structure itself. */
46
47 /* FIXME: I believe this is wrong. I believe passing the address
48 depends only on the size of the argument being > 8, not on its type
49 (which is a much more sane way than the REG_STRUCT_HAS_ADDR way,
50 IMHO). Also, as far as I know it is not dependent on it being
51 passed in a register. This should be verified before changing
52 anything (in fact, printing structure arguments of
53 2,4,6,8,12,16,and 20 bytes should all be in the test suite). */
54
55 #define REG_STRUCT_HAS_ADDR(gcc_p) (1)
56
57 /* Offset from address of function to start of its code.
58 Zero on most machines. */
59
60 #define FUNCTION_START_OFFSET 0
61
62 /* Advance PC across any function entry prologue instructions
63 to reach some "real" code. */
64
65 /* skip (stw rp, -20(0,sp)); copy 4,1; copy sp, 4; stwm 1,framesize(sp)
66 for gcc, or (stw rp, -20(0,sp); stwm 1, framesize(sp) for hcc */
67
68 #define SKIP_PROLOGUE(pc) pc = skip_prologue (pc)
69
70 /* If PC is in some function-call trampoline code, return the PC
71 where the function itself actually starts. If not, return NULL. */
72
73 #define SKIP_TRAMPOLINE_CODE(pc) skip_trampoline_code (pc, NULL)
74
75 /* Return non-zero if we are in some sort of a trampoline. */
76
77 #define IN_SOLIB_TRAMPOLINE(pc, name) skip_trampoline_code (pc, name)
78
79 /* Immediately after a function call, return the saved pc.
80 Can't go through the frames for this because on some machines
81 the new frame is not set up until the new function executes
82 some instructions. */
83
84 #undef SAVED_PC_AFTER_CALL
85 #define SAVED_PC_AFTER_CALL(frame) saved_pc_after_call (frame)
86
87 /* Stack grows upward */
88
89 #define INNER_THAN >
90
91
92 /* Sequence of bytes for breakpoint instruction. */
93
94 /*#define BREAKPOINT {0x00, 0x00, 0x00, 0x00}*/
95 #ifdef KERNELDEBUG /* XXX */
96 #define BREAKPOINT {0x00, 0x00, 0xa0, 0x00}
97 #else
98 #define BREAKPOINT {0x00, 0x01, 0x00, 0x04}
99 #endif
100
101 /* Amount PC must be decremented by after a breakpoint.
102 This is often the number of bytes in BREAKPOINT
103 but not always.
104
105 Not on the PA-RISC */
106
107 #define DECR_PC_AFTER_BREAK 0
108
109 /* return instruction is bv r0(rp) or bv,n r0(rp)*/
110
111 #define ABOUT_TO_RETURN(pc) ((read_memory_integer (pc, 4) | 0x2) == 0xE840C002)
112
113 /* Return 1 if P points to an invalid floating point value. */
114
115 #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */
116
117 /* Largest integer type */
118 #define LONGEST long
119
120 /* Name of the builtin type for the LONGEST type above. */
121 #define BUILTIN_TYPE_LONGEST builtin_type_long
122
123 /* Say how long (ordinary) registers are. This is a piece of bogosity
124 used in push_word and a few other places; REGISTER_RAW_SIZE is the
125 real way to know how big a register is. */
126
127 #define REGISTER_SIZE 4
128
129 /* Number of machine registers */
130
131 #define NUM_REGS 100
132
133 /* Initializer for an array of names of registers.
134 There should be NUM_REGS strings in this initializer. */
135
136 #define REGISTER_NAMES \
137 {"flags", "r1", "rp", "r3", "r4", "r5", "r6", "r7", "r8", "r9", \
138 "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", \
139 "r20", "r21", "r22", "arg3", "arg2", "arg1", "arg0", "dp", "ret0", "ret1", \
140 "sp", "r31", "sar", "pcoqh", "pcsqh", "pcoqt", "pcsqt", \
141 "eiem", "iir", "isr", "ior", "ipsw", "goto", "sr4", "sr0", "sr1", "sr2", \
142 "sr3", "sr5", "sr6", "sr7", "cr0", "cr8", "cr9", "ccr", "cr12", "cr13", \
143 "cr24", "cr25", "cr26", "mpsfu_high", "mpsfu_low", "mpsfu_ovflo", "pad", \
144 "fpsr", "fpe1", "fpe2", "fpe3", "fpe4", "fpe5", "fpe6", "fpe7", \
145 "fr4", "fr5", "fr6", "fr7", "fr8", \
146 "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", \
147 "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23", \
148 "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31"}
149
150 /* Register numbers of various important registers.
151 Note that some of these values are "real" register numbers,
152 and correspond to the general registers of the machine,
153 and some are "phony" register numbers which are too large
154 to be actual register numbers as far as the user is concerned
155 but do serve to get the desired values when passed to read_register. */
156
157 #define FLAGS_REGNUM 0 /* Various status flags */
158 #define RP_REGNUM 2 /* return pointer */
159 #define FP_REGNUM 3 /* Contains address of executing stack */
160 /* frame */
161 #define SP_REGNUM 30 /* Contains address of top of stack */
162 #define SAR_REGNUM 32 /* shift amount register */
163 #define IPSW_REGNUM 41 /* processor status word. ? */
164 #define PCOQ_HEAD_REGNUM 33 /* instruction offset queue head */
165 #define PCSQ_HEAD_REGNUM 34 /* instruction space queue head */
166 #define PCOQ_TAIL_REGNUM 35 /* instruction offset queue tail */
167 #define PCSQ_TAIL_REGNUM 36 /* instruction space queue tail */
168 #define FP0_REGNUM 64 /* floating point reg. 0 */
169 #define FP4_REGNUM 72
170
171 /* compatibility with the rest of gdb. */
172 #define PC_REGNUM PCOQ_HEAD_REGNUM
173 #define NPC_REGNUM PCOQ_TAIL_REGNUM
174
175 /* When fetching register values from an inferior or a core file,
176 clean them up using this macro. BUF is a char pointer to
177 the raw value of the register in the registers[] array. */
178
179 #define CLEAN_UP_REGISTER_VALUE(regno, buf) \
180 do { \
181 if ((regno) == PCOQ_HEAD_REGNUM || (regno) == PCOQ_TAIL_REGNUM) \
182 (buf)[3] &= ~0x3; \
183 } while (0)
184
185 /* Define DO_REGISTERS_INFO() to do machine-specific formatting
186 of register dumps. */
187
188 #define DO_REGISTERS_INFO(_regnum, fp) pa_do_registers_info (_regnum, fp)
189
190 /* PA specific macro to see if the current instruction is nullified. */
191 #define INSTRUCTION_NULLIFIED ((int)read_register (IPSW_REGNUM) & 0x00200000)
192
193 /* Total amount of space needed to store our copies of the machine's
194 register state, the array `registers'. */
195 #define REGISTER_BYTES (32 * 4 + 11 * 4 + 8 * 4 + 12 * 4 + 4 + 32 * 8)
196
197 /* Index within `registers' of the first byte of the space for
198 register N. */
199
200 #define REGISTER_BYTE(N) \
201 ((N) >= FP4_REGNUM ? ((N) - FP4_REGNUM) * 8 + 288 : (N) * 4)
202
203 /* Number of bytes of storage in the actual machine representation
204 for register N. On the PA-RISC, all regs are 4 bytes
205 except the floating point regs which are 8 bytes. */
206
207 #define REGISTER_RAW_SIZE(N) ((N) < FP4_REGNUM ? 4 : 8)
208
209 /* Number of bytes of storage in the program's representation
210 for register N. */
211
212 #define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N)
213
214 /* Largest value REGISTER_RAW_SIZE can have. */
215
216 #define MAX_REGISTER_RAW_SIZE 8
217
218 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
219
220 #define MAX_REGISTER_VIRTUAL_SIZE 8
221
222 /* Return the GDB type object for the "standard" data type
223 of data in register N. */
224
225 #define REGISTER_VIRTUAL_TYPE(N) \
226 ((N) < FP4_REGNUM ? builtin_type_int : builtin_type_double)
227
228 /* Store the address of the place in which to copy the structure the
229 subroutine will return. This is called from call_function. */
230
231 #define STORE_STRUCT_RETURN(ADDR, SP) {write_register (28, (ADDR)); }
232
233 /* Extract from an array REGBUF containing the (raw) register state
234 a function return value of type TYPE, and copy that, in virtual format,
235 into VALBUF. */
236
237 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
238 memcpy (VALBUF, (REGBUF) + REGISTER_BYTE(TYPE_LENGTH(TYPE) > 4 ? \
239 FP4_REGNUM :28), TYPE_LENGTH (TYPE))
240
241 /* Write into appropriate registers a function return value
242 of type TYPE, given in virtual format. */
243
244 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
245 write_register_bytes ((TYPE_LENGTH(TYPE) > 4 \
246 ? REGISTER_BYTE (FP4_REGNUM) \
247 : REGISTER_BYTE (28)), \
248 (VALBUF), TYPE_LENGTH (TYPE))
249
250 /* Extract from an array REGBUF containing the (raw) register state
251 the address in which a function should return its structure value,
252 as a CORE_ADDR (or an expression that can be used as one). */
253
254 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)((REGBUF) + 28))
255
256 /*
257 * This macro defines the register numbers (from REGISTER_NAMES) that
258 * are effectively unavailable to the user through ptrace(). It allows
259 * us to include the whole register set in REGISTER_NAMES (inorder to
260 * better support remote debugging). If it is used in
261 * fetch/store_inferior_registers() gdb will not complain about I/O errors
262 * on fetching these registers. If all registers in REGISTER_NAMES
263 * are available, then return false (0).
264 */
265
266 #define CANNOT_STORE_REGISTER(regno) \
267 ((regno) == 0) || \
268 ((regno) == PCSQ_HEAD_REGNUM) || \
269 ((regno) >= PCSQ_TAIL_REGNUM && (regno) < IPSW_REGNUM) || \
270 ((regno) > IPSW_REGNUM && (regno) < FP4_REGNUM)
271
272 #define INIT_EXTRA_FRAME_INFO(fromleaf, frame) init_extra_frame_info (fromleaf, frame)
273
274 /* Describe the pointer in each stack frame to the previous stack frame
275 (its caller). */
276
277 /* FRAME_CHAIN takes a frame's nominal address
278 and produces the frame's chain-pointer.
279
280 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
281 and produces the nominal address of the caller frame.
282
283 However, if FRAME_CHAIN_VALID returns zero,
284 it means the given frame is the outermost one and has no caller.
285 In that case, FRAME_CHAIN_COMBINE is not used. */
286
287 /* In the case of the PA-RISC, the frame's nominal address
288 is the address of a 4-byte word containing the calling frame's
289 address (previous FP). */
290
291 #define FRAME_CHAIN(thisframe) frame_chain (thisframe)
292
293 #define FRAME_CHAIN_VALID(chain, thisframe) \
294 frame_chain_valid (chain, thisframe)
295
296 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
297
298 /* Define other aspects of the stack frame. */
299
300 /* A macro that tells us whether the function invocation represented
301 by FI does not have a frame on the stack associated with it. If it
302 does not, FRAMELESS is set to 1, else 0. */
303 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
304 (FRAMELESS) = frameless_function_invocation(FI)
305
306 #define FRAME_SAVED_PC(FRAME) frame_saved_pc (FRAME)
307
308 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
309
310 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
311 /* Set VAL to the number of args passed to frame described by FI.
312 Can set VAL to -1, meaning no way to tell. */
313
314 /* We can't tell how many args there are
315 now that the C compiler delays popping them. */
316 #define FRAME_NUM_ARGS(val,fi) (val = -1)
317
318 /* Return number of bytes at start of arglist that are not really args. */
319
320 #define FRAME_ARGS_SKIP 0
321
322 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
323 hppa_frame_find_saved_regs (frame_info, &frame_saved_regs)
324
325 \f
326 /* Things needed for making the inferior call functions. */
327
328 /* Push an empty stack frame, to record the current PC, etc. */
329
330 #define PUSH_DUMMY_FRAME push_dummy_frame ()
331
332 /* Discard from the stack the innermost frame,
333 restoring all saved registers. */
334 #define POP_FRAME hppa_pop_frame ()
335
336 /* This sequence of words is the instructions
337
338 ; Call stack frame has already been built by gdb. Since we could be calling
339 ; a varargs function, and we do not have the benefit of a stub to put things in
340 ; the right place, we load the first 4 word of arguments into both the general
341 ; and fp registers.
342 call_dummy
343 ldw -36(sp), arg0
344 ldw -40(sp), arg1
345 ldw -44(sp), arg2
346 ldw -48(sp), arg3
347 ldo -36(sp), r1
348 fldws 0(0, r1), fr4
349 fldds -4(0, r1), fr5
350 fldws -8(0, r1), fr6
351 fldds -12(0, r1), fr7
352 ldil 0, r22 ; target will be placed here.
353 ldo 0(r22), r22
354 ldsid (0,r22), r4
355 ldil 0, r1 ; _sr4export will be placed here.
356 ldo 0(r1), r1
357 ldsid (0,r1), r19
358 combt,=,n r3, r19, text_space ; If target is in data space, do a
359 ble 0(sr5, r22) ; "normal" procedure call
360 copy r31, r2
361 break 4, 8
362 mtsp r21, sr0
363 ble,n 0(sr0, r22)
364 text_space ; Otherwise, go through _sr4export,
365 ble (sr4, r1) ; which will return back here.
366 stw 31,-24(r30)
367 break 4, 8
368 mtsp r21, sr0
369 ble,n 0(sr0, r22)
370
371 The dummy decides if the target is in text space or data space. If
372 it's in data space, there's no problem because the target can
373 return back to the dummy. However, if the target is in text space,
374 the dummy calls the secret, undocumented routine _sr4export, which
375 calls a function in text space and can return to any space. Instead
376 of including fake instructions to represent saved registers, we
377 know that the frame is associated with the call dummy and treat it
378 specially. */
379
380 #define CALL_DUMMY {0x4BDA3FB9, 0x4BD93FB1, 0x4BD83FA9, 0x4BD73FA1,\
381 0x37C13FB9, 0x24201004, 0x2C391005, 0x24311006,\
382 0x2C291007, 0x22C00000, 0x36D60000, 0x02C010A4,\
383 0x20200000, 0x34210000, 0x002010b3, 0x82642022,\
384 0xe6c06000, 0x081f0242, 0x00010004, 0x00151820,\
385 0xe6c00002, 0xe4202000, 0x6bdf3fd1, 0x00010004,\
386 0x00151820, 0xe6c00002}
387
388 #define CALL_DUMMY_LENGTH 104
389 #define CALL_DUMMY_START_OFFSET 0
390
391 /*
392 * Insert the specified number of args and function address
393 * into a call sequence of the above form stored at DUMMYNAME.
394 *
395 * On the hppa we need to call the stack dummy through $$dyncall.
396 * Therefore our version of FIX_CALL_DUMMY takes an extra argument,
397 * real_pc, which is the location where gdb should start up the
398 * inferior to do the function call.
399 */
400
401 #define FIX_CALL_DUMMY hppa_fix_call_dummy
402
403 CORE_ADDR hppa_fix_call_dummy();
404
405 #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
406 sp = hppa_push_arguments(nargs, args, sp, struct_return, struct_addr)
407 \f
408 /* The low two bits of the PC on the PA contain the privilege level. Some
409 genius implementing a (non-GCC) compiler apparently decided this means
410 that "addresses" in a text section therefore include a privilege level,
411 and thus symbol tables should contain these bits. This seems like a
412 bonehead thing to do--anyway, it seems to work for our purposes to just
413 ignore those bits. */
414 #define SMASH_TEXT_ADDRESS(addr) ((addr) &= ~0x3)
415
416 #define GDB_TARGET_IS_HPPA
417
418 #define BELIEVE_PCC_PROMOTION 1
419
420 /*
421 * Unwind table and descriptor.
422 */
423
424 struct unwind_table_entry {
425 unsigned int region_start;
426 unsigned int region_end;
427
428 unsigned int Cannot_unwind : 1;
429 unsigned int Millicode : 1;
430 unsigned int Millicode_save_sr0 : 1;
431 unsigned int Region_description : 2;
432 unsigned int reserved1 : 1;
433 unsigned int Entry_SR : 1;
434 unsigned int Entry_FR : 4; /* number saved */
435 unsigned int Entry_GR : 5; /* number saved */
436 unsigned int Args_stored : 1;
437 unsigned int Variable_Frame : 1;
438 unsigned int Separate_Package_Body : 1;
439 unsigned int Frame_Extension_Millicode:1;
440 unsigned int Stack_Overflow_Check : 1;
441 unsigned int Two_Instruction_SP_Increment:1;
442 unsigned int Ada_Region : 1;
443 /* Use this field to store a stub unwind type. */
444 #define stub_type reserved2
445 unsigned int reserved2 : 4;
446 unsigned int Save_SP : 1;
447 unsigned int Save_RP : 1;
448 unsigned int Save_MRP_in_frame : 1;
449 unsigned int extn_ptr_defined : 1;
450 unsigned int Cleanup_defined : 1;
451
452 unsigned int MPE_XL_interrupt_marker: 1;
453 unsigned int HP_UX_interrupt_marker: 1;
454 unsigned int Large_frame : 1;
455 unsigned int reserved4 : 2;
456 unsigned int Total_frame_size : 27;
457 };
458
459 /* HP linkers also generate unwinds for various linker-generated stubs.
460 GDB reads in the stubs from the $UNWIND_END$ subspace, then
461 "converts" them into normal unwind entries using some of the reserved
462 fields to store the stub type. */
463
464 struct stub_unwind_entry
465 {
466 /* The offset within the executable for the associated stub. */
467 unsigned stub_offset;
468
469 /* The type of stub this unwind entry describes. */
470 char type;
471
472 /* Unknown. Not needed by GDB at this time. */
473 char prs_info;
474
475 /* Length (in instructions) of the associated stub. */
476 short stub_length;
477 };
478
479 /* Sizes (in bytes) of the native unwind entries. */
480 #define UNWIND_ENTRY_SIZE 16
481 #define STUB_UNWIND_ENTRY_SIZE 8
482
483 /* The gaps represent linker stubs used in MPE and space for future
484 expansion. */
485 enum unwind_stub_types
486 {
487 LONG_BRANCH = 1,
488 PARAMETER_RELOCATION = 2,
489 EXPORT = 10,
490 IMPORT = 11,
491 };
492
493
494 /* Info about the unwind table associated with an object file. This is hung
495 off of the objfile->obj_private pointer, and is allocated in the objfile's
496 psymbol obstack. This allows us to have unique unwind info for each
497 executable and shared library that we are debugging. */
498
499 struct obj_unwind_info {
500 struct unwind_table_entry *table; /* Pointer to unwind info */
501 struct unwind_table_entry *cache; /* Pointer to last entry we found */
502 int last; /* Index of last entry */
503 };
504
505 #define OBJ_UNWIND_INFO(obj) ((struct obj_unwind_info *)obj->obj_private)
506
507 extern CORE_ADDR target_read_pc PARAMS ((void));
508 extern void target_write_pc PARAMS ((CORE_ADDR));
509
510 #define TARGET_READ_PC() target_read_pc ()
511 #define TARGET_WRITE_PC(v) target_write_pc (v)
This page took 0.060532 seconds and 4 git commands to generate.