1 /*- 2 * Copyright (c) 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 * 7 * @(#)machdep.h 5.3 (Berkeley) 04/04/91 8 */ 9 10 /* 11 * hword_t is a 2-byte (`halfword') type, used for (eg) w, l, x commands; 12 * addr_t is address type, must be unsigned; registers pc, fp, sp 13 * (where those exist) are assumed to be of this type, and 14 * addresses in the debuggee are of this type; 15 * expr_t is expression result type, size must be >= size of addr_t and 16 * reg_t; must be unsigned; it is treated as the fullword type 17 * and should therefore be 4 bytes long; 18 * sexpr_t is a signed version of expr_t. 19 * 20 * SHOULD WORK ON ALLOWING (eg) 1 AND 2 BYTE, OR 4 AND 8 BYTE, ETC, WORDS 21 */ 22 typedef u_int addr_t; 23 typedef u_int expr_t; 24 typedef int sexpr_t; 25 typedef u_short hword_t; 26 27 /* 28 * Since values of type addr_t, hword_t, and expr_t must be printed, 29 * and the varargs mechanism assumes that the programmer has accounted 30 * for any extension from `small' types (char, short) to `regular' types 31 * (int), we define the following macros. Each is supposed to produce 32 * a (possibly sign-extended) expr_t value: 33 * 34 * SH_ARG a signed halfword (%d, %q formats) 35 * UH_ARG an unsigned halfword (o, u, x) 36 * SF_ARG a signed fullword (D, Q) 37 * UF_ARG an unsigned fullword (O, U, X) 38 */ 39 #define SH_ARG (expr_t)(short)va_arg(ap, int) 40 #define UH_ARG (expr_t)(unsigned short)va_arg(ap, int) 41 #define SF_ARG (expr_t)va_arg(ap, int) 42 #define UF_ARG (expr_t)va_arg(ap, int) 43 44 /* 45 * bpt_t is used to hold original instructions when their breakpoint 46 * replacement(s) is/are set. 47 */ 48 typedef char bpt_t; 49 50 /* 51 * ADDRESS_WRAP is a predicate that returns true if the two addr_t 52 * arguments are in different spaces. 53 */ 54 #define ADDRESS_WRAP(a, b) (((a) ^ (b)) >> 30) 55 56 /* 57 * Struct activation is used for tracing through stack frames. 58 * It must hold any information needed to locate an activation record 59 * (variables and parameters) for a function, and must have two fields 60 * of type addr_t called `a_pc' and `a_fp', the `program counter' and 61 * the `frame pointer'. a_pc is used by the expression evaluator to 62 * find symbols; a_fp is returned as the result from an expression of 63 * the form `name.' (a routine name, but no local symbol). 64 * The field a_valid is cleared by a_prev() when there are no more 65 * activation records on the stack. 66 */ 67 struct activation { 68 int a_valid; /* set iff frame is valid */ 69 addr_t a_fp; /* fp */ 70 addr_t a_pc; /* pc */ 71 }; 72 73 /* 74 * On the tahoe, the frame pointer of a `struct frame' points to the 75 * frame's fr_savfp field, not to the base address of the frame. 76 */ 77 #define FRAMEOFF 8 /* (int)&fr.fr_savfp - (int)&fr */ 78 79 /* 80 * The reglist structure holds information needed to set and examine 81 * registers. It must contain an r_name field; this name must be unique 82 * across the register set, cannot be a single letter or digit, and 83 * cannot be a substring of any other register name. 84 * 85 * On the Tahoe, we keep an offset into the u. area, either from the 86 * base of the u. area (in the pcb), or, for those registers that 87 * are saved by syscalls, in the save area pointed to by u.u_ar0. 88 * Offsets into the latter region are negative. 89 * 90 * We also keep a pointer into the current pcb for use when debugging 91 * the kernel. 92 */ 93 struct reglist { 94 char *r_name; /* name */ 95 int r_offset; /* offset into pcb, or from u.u_ar0 */ 96 int *r_pcbaddr; /* if kcore, address in current pcb */ 97 }; 98 99 /* 100 * ispace_reg() is true iff register r points into I-space (usually just PC). 101 */ 102 #ifdef lint 103 #define ispace_reg(r) ((r) == NULL) 104 #else 105 #define ispace_reg(r) 0 /* ispace==dspace on Tahoe */ 106 #endif 107 108 /* 109 * getpc() returns as an addr_t the current PC; setpc() sets PC to its 110 * addr_t argument. entrypc() returns the addr_t value of the appropriate 111 * startup PC. 112 */ 113 addr_t getpc(); 114 #define entrypc() ((addr_t)0) /* ??? */ 115 116 /* 117 * INSTACK is true when its argument is a stack address. It is 118 * only used for consistency checking and may be overly permissive. 119 * INKERNEL is true iff its argument is a kernel space address. 120 */ 121 #define INSTACK(a) (((a) & 0xc0000000) == 0x80000000) /* p2 space */ 122 #define INKERNEL(a) (((a) & 0xc0000000) == 0xc0000000) /* sys space */ 123