/* $Header: crash.h 1.8 89/08/07 $ */

/*
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

/*
 * $Log:	crash.h,v $
 */

#include <stdio.h>
#include <ctype.h>

struct	prmode	{
	char	*pr_name;
	int	pr_sw;
};

struct initfuns {
	int	(*i_fun)();
};

struct	tsw	{
	char	*t_snm;		/* uniq name */
	char	*t_nm;		/* full name */
	int	(*t_fun)();	/* function  */
	char	*t_dsc;		/* description */
} ;

/* PCC '-g' .stab information encoding */
struct	desc { unsigned short basic:4, q1:2, q2:2, q3:2, q4:2, q5:2, q6:2; };

/* 4 basic PCC generated qualifications (q*:2) */
#define	PCC_Q_NONE		0
#define	PCC_Q_POINTER		1
#define	PCC_Q_FUNCTION		2
#define	PCC_Q_ARRAY		3

/* 16 basic PCC supported types (basic:4) */ 
#define	PCC_T_UNDEF		0
#define	PCC_T_FUNCTION_ARG	1
#define	PCC_T_CHAR		2
#define PCC_T_SHORT		3
#define PCC_T_INT		4
#define PCC_T_LONG		5
#define PCC_T_FLOAT		6
#define PCC_T_DOUBLE		7
#define	PCC_T_STRUCTURE		8
#define PCC_T_UNION		9
#define PCC_T_ENUMERATION	10
#define PCC_T_M_ENUMERATION	11
#define PCC_T_U_CHAR		12
#define PCC_T_U_SHORT		13
#define PCC_T_U_INT		14
#define PCC_T_U_LONG		15

/* Structures for internal symbol tables */
struct	sym { 
	char *sym_name; 		/* pointer into string table */
	unsigned long sym_value; 	/* value of symbol itself */
};
extern struct sym *searchbynam();

struct	sdb { 
	char *sdb_name; 		/* pointer into string table */
	unsigned char sdb_type;		/* SDB symbol type */
	unsigned short sdb_desc;	/* PCC generated description (really struct desc) */
	unsigned long sdb_soff; 	/* structure element offset */
        unsigned long sdb_size; 	/* size of symbol itself */
};
extern struct sdb *searchsdb();

struct val { 
	int v_value;		/* return value */
	struct sdb v_sdb;	/* symbolic information */
};

struct set_val {
	char *sv_name;
	struct set_val *sv_next;
	struct val sv_val;
};
extern struct set_val *searchsetval();

#define	DIRECT	2
#define	OCT2	3
#define	DEC2	4
#define	CHAR	5
#define	WRITE	6
#define	INODE	7
#define	BYTE	8
#define	DEC4	9
#define	OCT4	10
#define	HEX2	11
#define HEX4	12
#define STRING	13

#define	FALSE	0
#define	TRUE	1
#define	MAXSTRLEN	64

#define MAX_DEBUG	26
extern int debug[];
extern int xdebug;

extern int err_search;
extern int errno;
extern int unixfd, vmcorefd, swapfd;
extern char *dynixV, *vmcore, *swap;
extern int tok;
extern int live;
extern int paniced;
extern char *panicstr;
extern char Version[], Date[];
extern char _sobuf[];
extern struct tsw t[];
extern struct engine *l_engine;		/* local copy of engine table */
extern struct engine *v_engine;		/* kernel virtual address of engine table */
extern unsigned Nengine;		/* number of engines */
extern unsigned nonline;		/* number of online engines */
extern long Etext;
extern int end_locore;
extern int start_locore;
extern char *err_atoi;

extern struct pte *Sysmap;
extern struct proc *getproc(), *readproc();
extern struct proc *proc, *procmax, *procNPROC;

/* THIS REALLY WILL BE FIXED */
#define	SWAPPED	(char *)1	/* Returned by getuarea if process is swapped */
#define	BADREAD	(char *)2	/* Returned by getuarea if bad read of u_area */

extern char *getuarea();
extern int readv(), readp();
extern char *nice_char();
extern char *user_cmd();
extern char *addr_str();
extern char *token();
extern char *malloc(), *realloc(), *index(), *rindex();
extern char *lookbyval();
extern struct sdb sdbinfo;
extern struct val dot;
extern struct set_val set_val;

char *ctime();

#define SANITY(c, m, arg)  (!(c) || (fprintf(stderr, "crash: %s(%d): %s %s\n", __FILE__, __LINE__, m, arg),exit(1)))


#define MAX_CHECK	20
extern char *name_buf[];


extern long text_size;
extern long text_offset;
extern long text_start;
extern long data_size;
extern long data_offset;
extern long data_start;
extern long bss_size;
extern long bss_start;

#define N_GSYM	0x20	/* global symbol */
#define N_SSYM	0x60	/* structure element */
