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