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_ap; /* ap */ 70 addr_t a_fp; /* fp */ 71 addr_t a_pc; /* pc */ 72 }; 73 74 /* 75 * The reglist structure holds information needed to set and examine 76 * registers. It must contain an r_name field; this name must be unique 77 * across the register set, cannot be a single letter or digit, and 78 * cannot be a substring of any other register name. 79 * 80 * On the VAX, we keep an offset into the u. area, either from the 81 * base of the u. area (in the pcb), or, for those registers that 82 * are saved by syscalls, in the save area pointed to by u.u_ar0. 83 * Offsets into the latter region are negative. 84 * 85 * We also keep a pointer into the current pcb for use when debugging 86 * the kernel. 87 */ 88 struct reglist { 89 char *r_name; /* name */ 90 int r_offset; /* offset into pcb, or from u.u_ar0 */ 91 int *r_pcbaddr; /* if kcore, address in current pcb */ 92 }; 93 94 /* 95 * ispace_reg() is true iff register r points into I-space (usually just PC). 96 */ 97 #ifdef lint 98 #define ispace_reg(r) ((r) == NULL) 99 #else 100 #define ispace_reg(r) 0 /* ispace==dspace on VAX */ 101 #endif 102 103 /* 104 * getpc() returns as an addr_t the current PC; setpc() sets PC to its 105 * addr_t argument. entrypc() returns the addr_t value of the appropriate 106 * startup PC. 107 */ 108 addr_t getpc(); 109 #define entrypc() ((addr_t)2) 110 111 /* 112 * INSTACK is true when its argument is a stack address. It is 113 * only used for consistency checking and may be overly permissive. 114 * INKERNEL is true iff its argument is a kernel space address. 115 */ 116 #define INSTACK(a) (((a) & 0xc0000000) == 0x40000000) /* p1 space */ 117 #define INKERNEL(a) (((a) & 0xc0000000) == 0x80000000) /* sys space */ 118