xref: /csrg-svn/old/adb/adb.vax/machdep.h (revision 47821)
1*47821Sbostic /*-
236566Sbostic  * Copyright (c) 1988 The Regents of the University of California.
336566Sbostic  * All rights reserved.
436566Sbostic  *
5*47821Sbostic  * %sccs.include.proprietary.c%
6*47821Sbostic  *
7*47821Sbostic  *	@(#)machdep.h	5.3 (Berkeley) 04/04/91
836566Sbostic  */
936566Sbostic 
1036566Sbostic /*
1136566Sbostic  * hword_t is a 2-byte (`halfword') type, used for (eg) w, l, x commands;
1236566Sbostic  * addr_t is address type, must be unsigned; registers pc, fp, sp
1336566Sbostic  *	(where those exist) are assumed to be of this type, and
1436566Sbostic  *	addresses in the debuggee are of this type;
1536566Sbostic  * expr_t is expression result type, size must be >= size of addr_t and
1636566Sbostic  *	reg_t; must be unsigned; it is treated as the fullword type
1736566Sbostic  *	and should therefore be 4 bytes long;
1836566Sbostic  * sexpr_t is a signed version of expr_t.
1936566Sbostic  *
2036566Sbostic  * SHOULD WORK ON ALLOWING (eg) 1 AND 2 BYTE, OR 4 AND 8 BYTE, ETC, WORDS
2136566Sbostic  */
2236566Sbostic typedef	u_int	addr_t;
2336566Sbostic typedef	u_int	expr_t;
2436566Sbostic typedef	int	sexpr_t;
2536566Sbostic typedef	u_short	hword_t;
2636566Sbostic 
2736566Sbostic /*
2836566Sbostic  * Since values of type addr_t, hword_t, and expr_t must be printed,
2936566Sbostic  * and the varargs mechanism assumes that the programmer has accounted
3036566Sbostic  * for any extension from `small' types (char, short) to `regular' types
3136566Sbostic  * (int), we define the following macros.  Each is supposed to produce
3236566Sbostic  * a (possibly sign-extended) expr_t value:
3336566Sbostic  *
3436566Sbostic  *	SH_ARG	a signed halfword (%d, %q formats)
3536566Sbostic  *	UH_ARG	an unsigned halfword (o, u, x)
3636566Sbostic  *	SF_ARG	a signed fullword (D, Q)
3736566Sbostic  *	UF_ARG	an unsigned fullword (O, U, X)
3836566Sbostic  */
3936566Sbostic #define SH_ARG	(expr_t)(short)va_arg(ap, int)
4036566Sbostic #define	UH_ARG	(expr_t)(unsigned short)va_arg(ap, int)
4136566Sbostic #define	SF_ARG	(expr_t)va_arg(ap, int)
4236566Sbostic #define	UF_ARG	(expr_t)va_arg(ap, int)
4336566Sbostic 
4436566Sbostic /*
4536566Sbostic  * bpt_t is used to hold original instructions when their breakpoint
4636566Sbostic  * replacement(s) is/are set.
4736566Sbostic  */
4836566Sbostic typedef	char	bpt_t;
4936566Sbostic 
5036566Sbostic /*
5136566Sbostic  * ADDRESS_WRAP is a predicate that returns true if the two addr_t
5236566Sbostic  * arguments are in different spaces.
5336566Sbostic  */
5436566Sbostic #define	ADDRESS_WRAP(a, b) (((a) ^ (b)) >> 30)
5536566Sbostic 
5636566Sbostic /*
5736566Sbostic  * Struct activation is used for tracing through stack frames.
5836566Sbostic  * It must hold any information needed to locate an activation record
5936566Sbostic  * (variables and parameters) for a function, and must have two fields
6036566Sbostic  * of type addr_t called `a_pc' and `a_fp', the `program counter' and
6136566Sbostic  * the `frame pointer'.  a_pc is used by the expression evaluator to
6236566Sbostic  * find symbols; a_fp is returned as the result from an expression of
6336566Sbostic  * the form `name.' (a routine name, but no local symbol).
6436566Sbostic  * The field a_valid is cleared by a_prev() when there are no more
6536566Sbostic  * activation records on the stack.
6636566Sbostic  */
6736566Sbostic struct activation {
6836566Sbostic 	int	a_valid;		/* set iff frame is valid */
6936566Sbostic 	addr_t	a_ap;			/* ap */
7036566Sbostic 	addr_t	a_fp;			/* fp */
7136566Sbostic 	addr_t	a_pc;			/* pc */
7236566Sbostic };
7336566Sbostic 
7436566Sbostic /*
7536566Sbostic  * The reglist structure holds information needed to set and examine
7636566Sbostic  * registers.  It must contain an r_name field; this name must be unique
7736566Sbostic  * across the register set, cannot be a single letter or digit, and
7836566Sbostic  * cannot be a substring of any other register name.
7936566Sbostic  *
8036566Sbostic  * On the VAX, we keep an offset into the u. area, either from the
8136566Sbostic  * base of the u. area (in the pcb), or, for those registers that
8236566Sbostic  * are saved by syscalls, in the save area pointed to by u.u_ar0.
8336566Sbostic  * Offsets into the latter region are negative.
8436566Sbostic  *
8536566Sbostic  * We also keep a pointer into the current pcb for use when debugging
8636566Sbostic  * the kernel.
8736566Sbostic  */
8836566Sbostic struct reglist {
8936566Sbostic 	char	*r_name;	/* name */
9036566Sbostic 	int	r_offset;	/* offset into pcb, or from u.u_ar0 */
9136566Sbostic 	int	*r_pcbaddr;	/* if kcore, address in current pcb */
9236566Sbostic };
9336566Sbostic 
9436566Sbostic /*
9536566Sbostic  * ispace_reg() is true iff register r points into I-space (usually just PC).
9636566Sbostic  */
9736566Sbostic #ifdef lint
9836566Sbostic #define	ispace_reg(r)	((r) == NULL)
9936566Sbostic #else
10036566Sbostic #define	ispace_reg(r)	0	/* ispace==dspace on VAX */
10136566Sbostic #endif
10236566Sbostic 
10336566Sbostic /*
10436566Sbostic  * getpc() returns as an addr_t the current PC; setpc() sets PC to its
10536566Sbostic  * addr_t argument.  entrypc() returns the addr_t value of the appropriate
10636566Sbostic  * startup PC.
10736566Sbostic  */
10836566Sbostic addr_t	getpc();
10936566Sbostic #define	entrypc()	((addr_t)2)
11036566Sbostic 
11136566Sbostic /*
11236566Sbostic  * INSTACK is true when its argument is a stack address.  It is
11336566Sbostic  * only used for consistency checking and may be overly permissive.
11436566Sbostic  * INKERNEL is true iff its argument is a kernel space address.
11536566Sbostic  */
11636566Sbostic #define	INSTACK(a)	(((a) & 0xc0000000) == 0x40000000) /* p1 space */
11736566Sbostic #define	INKERNEL(a)	(((a) & 0xc0000000) == 0x80000000) /* sys space */
118