1*47821Sbostic /*-
2*47821Sbostic * Copyright (c) 1991 The Regents of the University of California.
3*47821Sbostic * All rights reserved.
4*47821Sbostic *
5*47821Sbostic * %sccs.include.proprietary.c%
6*47821Sbostic */
7*47821Sbostic
836565Sbostic #ifndef lint
9*47821Sbostic static char sccsid[] = "@(#)machdep.c 5.4 (Berkeley) 04/04/91";
10*47821Sbostic #endif /* not lint */
1136565Sbostic
1236565Sbostic /*
1336565Sbostic * adb - miscellaneous machine dependent routines.
1436565Sbostic */
1536565Sbostic
1636565Sbostic #define RLOCALS /* enable alternate $C stack trace */
1736565Sbostic
1836565Sbostic #include "defs.h"
1936565Sbostic #include "bkpt.h"
2036565Sbostic #include <machine/pte.h>
2136565Sbostic #include <machine/frame.h>
2236565Sbostic #include <machine/reg.h>
2336565Sbostic #include <machine/vmparam.h>
2436565Sbostic #include <sys/ptrace.h>
2536565Sbostic #include <sys/vmmac.h>
2636565Sbostic #include <stab.h>
2736565Sbostic
2836565Sbostic struct pte *sbr;
2936565Sbostic int slr;
3036565Sbostic struct pcb pcb;
3136565Sbostic int masterpcbb;
3236565Sbostic
3336565Sbostic /*
3436565Sbostic * Activation records.
3536565Sbostic */
3636565Sbostic
3736565Sbostic /*
3836565Sbostic * Set up a stack frame based on the registers in the core image
3936565Sbostic * (or in the kernel core file ... not yet!).
4036565Sbostic */
a_init(ap)4136565Sbostic a_init(ap)
4236565Sbostic register struct activation *ap;
4336565Sbostic {
4436565Sbostic
4536565Sbostic ap->a_valid = 1;
4636565Sbostic if (kcore) {
4736565Sbostic ap->a_ap = pcb.pcb_ap;
4836565Sbostic ap->a_fp = pcb.pcb_fp;
4936565Sbostic ap->a_pc = pcb.pcb_pc;
5036565Sbostic } else {
5136565Sbostic ap->a_ap = u.u_ar0[AP];
5236565Sbostic ap->a_fp = u.u_ar0[FP];
5336565Sbostic ap->a_pc = u.u_ar0[PC];
5436565Sbostic }
5536565Sbostic }
5636565Sbostic
5736565Sbostic /*
5836565Sbostic * Back up one stack frame in the call stack.
5936565Sbostic * ap points to the activation record from the previous frame.
6036565Sbostic * Clear a_valid field if we ran out of frames.
6136565Sbostic */
a_back(ap)6236565Sbostic a_back(ap)
6336565Sbostic register struct activation *ap;
6436565Sbostic {
6536565Sbostic struct frame fr;
6636565Sbostic
6736565Sbostic /*
6836565Sbostic * The magic constants below allow us to read just the part of
6936565Sbostic * the frame that we need.
7036565Sbostic */
7136565Sbostic if (adbread(SP_DATA, ap->a_fp + 8, &fr.fr_savap, 12) != 12)
7236565Sbostic ap->a_valid = 0;
7336565Sbostic else {
7436565Sbostic ap->a_ap = fr.fr_savap;
7536565Sbostic ap->a_fp = fr.fr_savfp;
7636565Sbostic ap->a_pc = fr.fr_savpc;
7736565Sbostic if (ap->a_fp == 0)
7836565Sbostic ap->a_valid = 0;
7936565Sbostic }
8036565Sbostic }
8136565Sbostic
8236565Sbostic /*
8336565Sbostic * Evaluate a local symbol (N_LSYM or N_PSYM) using the activation
8436565Sbostic * record pointed to by ap.
8536565Sbostic */
8636565Sbostic addr_t
eval_localsym(sp,ap)8736565Sbostic eval_localsym(sp, ap)
8836565Sbostic register struct nlist *sp;
8936565Sbostic struct activation *ap;
9036565Sbostic {
9136565Sbostic switch (sp->n_type) {
9236565Sbostic
9336565Sbostic case N_LSYM:
9436565Sbostic return (ap->a_fp - sp->n_value); /* ??? */
9536565Sbostic
9636565Sbostic case N_PSYM:
9736565Sbostic return (ap->a_ap + sp->n_value); /* ??? */
9836565Sbostic }
9936565Sbostic panic("eval_localsym");
10036565Sbostic /* NOTREACHED */
10136565Sbostic }
10236565Sbostic
10336565Sbostic
10436565Sbostic /* true iff address a is in instruction space */
10536565Sbostic #define ispace(a) ((a) < txtmap.m1.e)
10636565Sbostic
10736565Sbostic /*
10836565Sbostic * Delete a (single) breakpoint. Return 0 on success.
10936565Sbostic */
11036565Sbostic int
clr_bpt(b)11136565Sbostic clr_bpt(b)
11236565Sbostic struct bkpt *b;
11336565Sbostic {
11436565Sbostic addr_t a = b->loc;
11536565Sbostic
11636565Sbostic return (adbwrite(ispace(a) ? SP_INSTR : SP_DATA, a, &b->ins, 1) != 1);
11736565Sbostic }
11836565Sbostic
11936565Sbostic /*
12036565Sbostic * Set a (single) breakpoint. Return 0 on success.
12136565Sbostic */
12236565Sbostic set_bpt(b)
12336565Sbostic struct bkpt *b;
12436565Sbostic {
12536565Sbostic addr_t a = b->loc;
12636565Sbostic int space;
12736565Sbostic char bpt = 0x03; /* breakpoint instruction */
12836565Sbostic
12936565Sbostic space = ispace(a) ? SP_INSTR : SP_DATA;
13036565Sbostic return (adbread(space, a, &b->ins, 1) != 1 ||
13136565Sbostic adbwrite(space, a, &bpt, 1) != 1);
13236565Sbostic }
13336565Sbostic
13436565Sbostic /*
13536565Sbostic * Check a float for `correctness' (reserved patterns, etc). Return
13636565Sbostic * a pointer to a character string to be printed instead of the float,
13736565Sbostic * or NULL to print the float as-is.
13836565Sbostic *
13936565Sbostic * The string returned, if any, should be no longer than 16 characters.
14036565Sbostic *
14136565Sbostic * On the VAX, we can simply check the first two bytes. Byte zero
14236565Sbostic * contains one bit of the exponent, and byte 1 has the remaining 7
14336565Sbostic * exponent bits and the sign bit. If the sign bit is set and the
14436565Sbostic * exponent is zero, the value is reserved.
14536565Sbostic */
14636565Sbostic /* ARGSUSED */
14736565Sbostic char *
checkfloat(fp,isdouble)14836565Sbostic checkfloat(fp, isdouble)
14936565Sbostic caddr_t fp;
15036565Sbostic int isdouble;
15136565Sbostic {
15236565Sbostic
15336565Sbostic return ((*(short *)fp & 0xff80) == 0x8000 ? "(reserved oprnd)" : NULL);
15436565Sbostic }
15536565Sbostic
15636565Sbostic /*
15736565Sbostic * Convert a value in `expr_t' format to float or double.
15836565Sbostic */
etofloat(e,fp,isdouble)15936565Sbostic etofloat(e, fp, isdouble)
16036565Sbostic expr_t e;
16136565Sbostic caddr_t fp;
16236565Sbostic int isdouble;
16336565Sbostic {
16436565Sbostic
16536565Sbostic if (isdouble)
16636565Sbostic ((int *)fp)[1] = 0;
16736565Sbostic *(int *)fp = e;
16836565Sbostic }
16936565Sbostic
mch_init()17036565Sbostic mch_init()
17136565Sbostic {
17236565Sbostic
17336565Sbostic mkioptab();
17436565Sbostic }
17536565Sbostic
17636565Sbostic /* quietly read object obj from address addr */
17736565Sbostic #define GET(obj, addr) (void) adbread(SP_DATA, addr, &(obj), sizeof(obj))
17836565Sbostic
17936565Sbostic /* set `current process' pcb */
setpcb(addr)18036565Sbostic setpcb(addr)
18136565Sbostic addr_t addr;
18236565Sbostic {
18336565Sbostic int pte;
18436565Sbostic
18536565Sbostic GET(pte, addr);
18636565Sbostic masterpcbb = (pte & PG_PFNUM) * NBPG;
18736565Sbostic }
18836565Sbostic
getpcb()18936565Sbostic getpcb()
19036565Sbostic {
19136565Sbostic
19236565Sbostic /* maybe use adbread() here ... */
19336565Sbostic (void) readcore((off_t)masterpcbb & ~KERNBASE,
19436565Sbostic (char *)&pcb, sizeof(struct pcb));
19536565Sbostic pcb.pcb_p0lr &= ~AST_CLR;
19636565Sbostic adbprintf("p0br %R p0lr %R p1br %R p1lr %R\n",
19736565Sbostic pcb.pcb_p0br, pcb.pcb_p0lr, pcb.pcb_p1br, pcb.pcb_p1lr);
19836565Sbostic }
19936565Sbostic
20036565Sbostic /*
20136565Sbostic * Convert a kernel virtual address to a physical address,
20236565Sbostic * a la the VAX hardware. Set *err if the resulting address
20336565Sbostic * is invalid.
20436565Sbostic */
20536565Sbostic addr_t
vtophys(addr,err)20636565Sbostic vtophys(addr, err)
20736565Sbostic addr_t addr;
20836565Sbostic char **err;
20936565Sbostic {
21036565Sbostic register unsigned v = btop(addr & ~0xc0000000);
21136565Sbostic register addr_t pteaddr;
21236565Sbostic struct pte pte;
21336565Sbostic #define issys(a) ((a) & 0x80000000)
21436565Sbostic #define isp1(a) ((a) & 0x40000000)
21536565Sbostic
21636565Sbostic if (issys(addr)) {
21736565Sbostic /* system space: get system pte */
21836565Sbostic if (isp1(addr) || v >= slr) {
21936565Sbostic oor:
22036565Sbostic *err = "address out of segment";
22136565Sbostic return (0);
22236565Sbostic }
22336565Sbostic pteaddr = (addr_t)(sbr + v) & ~0x80000000;
22436565Sbostic } else {
22536565Sbostic if (isp1(addr)) {
22636565Sbostic /* P1 space: must not be in shadow region */
22736565Sbostic if (v < pcb.pcb_p1lr)
22836565Sbostic goto oor;
22936565Sbostic pteaddr = (addr_t)(pcb.pcb_p1br + v);
23036565Sbostic } else {
23136565Sbostic /* P0 space: must not be off end of region */
23236565Sbostic if (v >= pcb.pcb_p0lr)
23336565Sbostic goto oor;
23436565Sbostic pteaddr = (addr_t)(pcb.pcb_p0br + v);
23536565Sbostic }
23636565Sbostic if (!issys(pteaddr) || isp1(pteaddr)) {
23736565Sbostic *err = "bad p0br or p1br in pcb";
23836565Sbostic return (0);
23936565Sbostic }
24036565Sbostic /* in either case, find system pte by recursing */
24136565Sbostic pteaddr = vtophys(pteaddr, err);
24236565Sbostic if (*err)
24336565Sbostic return (0);
24436565Sbostic }
24536565Sbostic
24636565Sbostic /*
24736565Sbostic * Read system pte. If valid or reclaimable,
24836565Sbostic * physical address is combination of its page number and
24936565Sbostic * the page offset of the original address.
25036565Sbostic */
25136565Sbostic if (readcore((off_t)pteaddr, (caddr_t)&pte, 4) != 4) {
25236565Sbostic *err = "page table botch";
25336565Sbostic return (0);
25436565Sbostic }
25536565Sbostic /* SHOULD CHECK NOT I/O ADDRESS; NEED CPU TYPE! */
25636565Sbostic if (pte.pg_v == 0 && (pte.pg_fod || pte.pg_pfnum == 0)) {
25736565Sbostic *err = "page not valid/reclaimable";
25836565Sbostic return (0);
25936565Sbostic }
26036565Sbostic return ((addr_t)(ptob(pte.pg_pfnum) + (addr & PGOFSET)));
26136565Sbostic }
26236565Sbostic
26336565Sbostic /*
26436565Sbostic * Print a stack trace ($c, $C). Trace backwards through nback
26536565Sbostic * frames; if locals is set, print local variables.
26636565Sbostic */
printstack(locals,nback)26736565Sbostic printstack(locals, nback)
26836565Sbostic int locals, nback;
26936565Sbostic {
27036565Sbostic register int i;
27136565Sbostic register addr_t a;
27236565Sbostic struct nlist *sym;
27336565Sbostic char *s;
27436565Sbostic /* addr_t callpc; /* pc that called this frame */
27536565Sbostic struct activation cur; /* this frame itself */
27636565Sbostic struct frame fr; /* the frame above this frame */
27736565Sbostic u_char narg; /* number of int-args to this frame */
27836565Sbostic addr_t dummy; /* a variable to scribble on */
27936565Sbostic #define UNKNOWN -1
28036565Sbostic
28136565Sbostic #ifdef RLOCALS
28236565Sbostic /* if locals variables are broken, use an alternate strategy */
28336565Sbostic register int r;
28436565Sbostic addr_t sp, prev_sp;
28536565Sbostic int regs[12];
28636565Sbostic static char unknown[] = "<unknown>";
28736565Sbostic #endif
28836565Sbostic
28936565Sbostic /* fr_savpc==UNKNOWN implies fr is invalid */
29036565Sbostic fr.fr_savpc = UNKNOWN;
29136565Sbostic
29236565Sbostic #ifdef RLOCALS
29336565Sbostic /* grab registers */
29436565Sbostic bcopy((caddr_t)(kcore ? &pcb.pcb_r0 : &u.u_ar0[R0]), (caddr_t)regs,
29536565Sbostic sizeof(regs));
29636565Sbostic #endif
29736565Sbostic
29836565Sbostic /* set up the current stack frame */
29936565Sbostic if (gavedot) {
30036565Sbostic GET(fr, cur.a_fp = dot);
30136565Sbostic checkerr();
30236565Sbostic if (fr.fr_s) { /* was a `calls'; can figure out ap */
30336565Sbostic cur.a_ap = cur.a_fp + sizeof(fr) + fr.fr_spa;
30436565Sbostic for (i = fr.fr_mask; i != 0; i >>= 1)
30536565Sbostic if (i & 1)
30636565Sbostic cur.a_ap += 4;
30736565Sbostic } else /* `callg': cannot find ap */
30836565Sbostic cur.a_ap = UNKNOWN;
30936565Sbostic cur.a_pc = UNKNOWN;
31036565Sbostic #ifdef RLOCALS
31136565Sbostic sp = UNKNOWN;
31236565Sbostic #endif
31336565Sbostic } else if (kcore) {
31436565Sbostic cur.a_ap = pcb.pcb_ap;
31536565Sbostic cur.a_fp = pcb.pcb_fp;
31636565Sbostic cur.a_pc = pcb.pcb_pc;
31736565Sbostic #ifdef RLOCALS
31836565Sbostic sp = pcb.pcb_ksp;
31936565Sbostic #endif
32036565Sbostic } else {
32136565Sbostic cur.a_ap = u.u_ar0[AP];
32236565Sbostic cur.a_fp = u.u_ar0[FP];
32336565Sbostic cur.a_pc = u.u_ar0[PC];
32436565Sbostic #ifdef RLOCALS
32536565Sbostic sp = u.u_ar0[SP];
32636565Sbostic #endif
32736565Sbostic }
32836565Sbostic
32936565Sbostic /* now back up through the stack */
33036565Sbostic while (nback--) {
33136565Sbostic if (fr.fr_savpc == UNKNOWN)
33236565Sbostic GET(fr, cur.a_fp);
33336565Sbostic
33436565Sbostic /* where are we? ... if u. area, signal trampoline code */
33536565Sbostic if ((int)cur.a_pc >= USRSTACK) {
33636565Sbostic /* GET(callpc, cur.a_fp + 92); /* XXX magic 92 */
33736565Sbostic s = "sigtramp";
33836565Sbostic } else {
33936565Sbostic /* callpc = fr.fr_savpc; */
34036565Sbostic if (cur.a_pc != UNKNOWN &&
34136565Sbostic (sym = findsym(cur.a_pc, SP_INSTR, &dummy)) != 0) {
34236565Sbostic s = sym->n_un.n_name;
34336565Sbostic if (eqstr(s, "start")) {
34436565Sbostic errflag = NULL;
34536565Sbostic break;
34636565Sbostic }
34736565Sbostic } else
34836565Sbostic s = "?";
34936565Sbostic }
35036565Sbostic adbprintf("%s(", s);
35136565Sbostic if ((a = cur.a_ap) != UNKNOWN) {
35236565Sbostic GET(narg, a);
35339222Storek for (i = narg > 20 ? 20 : narg; i;)
35436565Sbostic prfrom(a += 4, --i ? ',' : 0);
35536565Sbostic }
35636565Sbostic printc(')');
35736565Sbostic if (cur.a_pc != UNKNOWN) {
35836565Sbostic prints(" at ");
35936565Sbostic psymoff("%R", cur.a_pc, SP_INSTR, -(addr_t)1, "");
36036565Sbostic }
36136565Sbostic printc('\n');
36236565Sbostic
36336565Sbostic /* local variables */
36436565Sbostic if (locals) {
36536565Sbostic #ifdef busted
36636565Sbostic if (cur.a_pc != UNKNOWN) {
36736565Sbostic sym = findsym(cur.a_pc, SP_INSTR, &dummy);
36836565Sbostic while ((sym = nextlocal(sym)) != NULL) {
36936565Sbostic adbprintf("%8t");
37036565Sbostic printlsym(sym->n_un.n_name);
37136565Sbostic adbprintf(":%12t");
37236565Sbostic prfrom(eval_localsym(sym, &cur), '\n');
37336565Sbostic }
37436565Sbostic }
37536565Sbostic #endif
37636565Sbostic #ifdef RLOCALS
37736565Sbostic adbprintf("\
37836575Storek fp: %R\%16tap: %?s%?R%32tsp: %?s%?R%48tpc: %?s%?R\n\
37936575Storek r0: %R\%16tr1: %R\%32tr2: %R\%48tr3: %R\n\
38036575Storek r4: %R\%16tr5: %R\%32tr6: %R\%48tr7: %R\n\
38136575Storek r8: %R\%16tr9: %R\%32tr10: %R\%48tr11: %R\n",
38236565Sbostic #define q(s) s == UNKNOWN, unknown, s != UNKNOWN, s
38336565Sbostic cur.a_fp, q(cur.a_ap), q(sp), q(cur.a_pc),
38436565Sbostic #undef q
38536565Sbostic regs[0], regs[1], regs[2], regs[3],
38636565Sbostic regs[4], regs[5], regs[6], regs[7],
38736565Sbostic regs[8], regs[9], regs[10], regs[11]);
38836565Sbostic
38936565Sbostic /* update registers, and find previous frame's sp */
39036565Sbostic a = cur.a_fp + 16;
39136565Sbostic for (r = 0, i = fr.fr_mask; i != 0; r++, i >>= 1)
39236565Sbostic if (i & 1)
39336565Sbostic GET(regs[r], a += 4);
39436565Sbostic a += fr.fr_spa;
39536565Sbostic if (fr.fr_s)
39636565Sbostic a += narg * 4;
39736565Sbostic prev_sp = a;
39836565Sbostic
39936565Sbostic /* now print automatics */
40036565Sbostic if (sp != UNKNOWN) {
40136565Sbostic #define MAXPRINT 30 /* max # words to print */
40236565Sbostic /* XXX should be settable */
40336565Sbostic i = (cur.a_fp - sp) >> 2;
40436565Sbostic if (i > MAXPRINT)
40536565Sbostic i = MAXPRINT;
40636565Sbostic for (a = cur.a_fp; --i >= 0;) {
40736565Sbostic a -= 4;
40836565Sbostic adbprintf("%R: %V(fp):%24t",
40936565Sbostic a, a - cur.a_fp);
41036565Sbostic prfrom(a, '\n');
41136565Sbostic }
41236565Sbostic if (a > sp)
41336565Sbostic adbprintf("\
41436565Sbostic %R: %V(fp) .. %R: %V(fp) not displayed\n",
41536565Sbostic a, a - cur.a_fp,
41636565Sbostic sp, sp - cur.a_fp);
41736565Sbostic }
41836565Sbostic #endif /* RLOCALS */
41936565Sbostic }
42036565Sbostic
42136565Sbostic errflag = NULL; /* clobber any read errors */
42236565Sbostic
42336565Sbostic /* back up one frame */
42436565Sbostic if (fr.fr_savfp == 0)
42536565Sbostic break;
42636565Sbostic cur.a_ap = fr.fr_savap;
42736565Sbostic cur.a_fp = fr.fr_savfp;
42836565Sbostic #ifdef RLOCALS
42936565Sbostic sp = prev_sp;
43036565Sbostic #endif
43136565Sbostic cur.a_pc = fr.fr_savpc;
43236565Sbostic fr.fr_savpc = UNKNOWN; /* until we read it again */
43336565Sbostic
43436565Sbostic if (!gavedot && !INSTACK(cur.a_fp) && !kcore)
43536565Sbostic break;
43636565Sbostic
43736565Sbostic /* make sure we returned somewhere... */
43836565Sbostic (void) adbread(kcore ? SP_DATA : SP_INSTR, cur.a_pc, &dummy, 1);
43936565Sbostic checkerr();
44036565Sbostic }
44136565Sbostic }
44236565Sbostic
44336565Sbostic /*
44436565Sbostic * Register offset to u. pointer, and register offset to ptrace value
44536565Sbostic */
44636565Sbostic #define otoua(o) \
44736565Sbostic ((int *)(((o) < 0 ? (int)u.u_ar0 : (int)&u.u_pcb) + (o)))
44836565Sbostic #define otopt(o) \
44936565Sbostic ((int *)((o) < 0 ? (o) + ctob(UPAGES) : (o)))
45036565Sbostic
45136565Sbostic /*
45236565Sbostic * Return the value of some register.
45336565Sbostic */
45436565Sbostic expr_t
getreg(reg)45536565Sbostic getreg(reg)
45636565Sbostic register struct reglist *reg;
45736565Sbostic {
45836565Sbostic
45936565Sbostic return (kcore ? *reg->r_pcbaddr : *otoua(reg->r_offset));
46036565Sbostic }
46136565Sbostic
46236565Sbostic
46336565Sbostic /*
46436565Sbostic * Set the value of some register. Return 0 if all goes well.
46536565Sbostic */
setreg(reg,val)46636565Sbostic setreg(reg, val)
46736565Sbostic register struct reglist *reg;
46836565Sbostic expr_t val;
46936565Sbostic {
47036565Sbostic
47136565Sbostic if (kcore)
47236565Sbostic *reg->r_pcbaddr = val;
47336565Sbostic else {
47436565Sbostic *otoua(reg->r_offset) = val;
47536565Sbostic if (pid) {
47636565Sbostic errno = 0;
47736565Sbostic if (ptrace(PT_WRITE_U, pid, otopt(reg->r_offset),
47836565Sbostic (int)val) == -1 && errno)
47936565Sbostic return (-1);
48036565Sbostic }
48136565Sbostic }
48236565Sbostic return (0);
48336565Sbostic }
48436565Sbostic
48536565Sbostic /*
48636565Sbostic * Read registers from current process.
48736565Sbostic */
readregs()48836565Sbostic readregs()
48936565Sbostic {
49036565Sbostic register struct reglist *reg;
49136565Sbostic extern struct reglist reglist[];
49236565Sbostic
49336565Sbostic for (reg = reglist; reg->r_name != NULL; reg++)
49436565Sbostic *otoua(reg->r_offset) =
49536565Sbostic ptrace(PT_READ_U, pid, otopt(reg->r_offset), 0);
49636565Sbostic }
49736565Sbostic
49836565Sbostic addr_t
getpc()49936565Sbostic getpc()
50036565Sbostic {
50136565Sbostic
50236565Sbostic return (u.u_ar0[PC]);
50336565Sbostic }
50436565Sbostic
setpc(where)50536565Sbostic setpc(where)
50636565Sbostic addr_t where;
50736565Sbostic {
50836565Sbostic
50936565Sbostic u.u_ar0[PC] = where;
51036565Sbostic }
51136565Sbostic
51236565Sbostic /*
51336565Sbostic * udot returns true if u.u_pcb appears correct. More extensive
51436565Sbostic * checking is possible....
51536565Sbostic */
udot()51636565Sbostic udot()
51736565Sbostic {
51836565Sbostic
51936565Sbostic /* user stack should be in stack segment */
52036565Sbostic if (!INSTACK(u.u_pcb.pcb_usp))
52136565Sbostic return (0);
52236565Sbostic /* kernel stack should be in u. area */
52336565Sbostic if (u.u_pcb.pcb_ksp < USRSTACK)
52436565Sbostic return (0);
52536565Sbostic /* looks good to us... */
52636565Sbostic return (1);
52736565Sbostic }
52836565Sbostic
sigprint()52936565Sbostic sigprint()
53036565Sbostic {
53136565Sbostic extern char *sys_siglist[];
53236565Sbostic extern char *illinames[], *fpenames[];
53336565Sbostic extern int nillinames, nfpenames;
53436565Sbostic
53536565Sbostic if ((u_int)signo - 1 < NSIG - 1)
53636565Sbostic prints(sys_siglist[signo]);
53736565Sbostic switch (signo) {
53836565Sbostic
53936565Sbostic case SIGFPE:
54036565Sbostic if ((u_int)sigcode < nfpenames)
54136565Sbostic prints(fpenames[sigcode]);
54236565Sbostic break;
54336565Sbostic
54436565Sbostic case SIGILL:
54536565Sbostic if ((u_int)sigcode < nillinames)
54636565Sbostic prints(illinames[sigcode]);
54736565Sbostic break;
54836565Sbostic }
54936565Sbostic }
550