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