Annotation of 43BSDReno/sys/kdb/kdb_print.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1986 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  *
        !             6:  *     @(#)kdb_print.c 7.19 (Berkeley) 6/22/90
        !             7:  */
        !             8: 
        !             9: #include "machine/mtpr.h"
        !            10: #undef ISP
        !            11: #include "../kdb/defs.h"
        !            12: #undef CTRL
        !            13: #include "ioctl.h"
        !            14: #include "tty.h"
        !            15: #include "vnode.h"
        !            16: #include "mount.h"
        !            17: 
        !            18: char   *kdbBADRAD;
        !            19: 
        !            20: char   *kdbBADMOD;
        !            21: char   *kdblp;
        !            22: long   kdbmaxpos;
        !            23: int    kdbradix;
        !            24: char   kdblastc;
        !            25: 
        !            26: /* breakpoints */
        !            27: BKPTR  kdbbkpthead;
        !            28: 
        !            29: extern REGLIST kdbreglist[];
        !            30: 
        !            31: /* general printing routines ($) */
        !            32: 
        !            33: kdbprinttrace(modif)
        !            34: {
        !            35:        register int i;
        !            36:        register BKPTR bkptr;
        !            37:        register char *comptr;
        !            38:        register struct nlist *sp;
        !            39:        register struct proc *p;
        !            40:        extern struct proc *allproc;
        !            41: 
        !            42:        if (kdbcntflg==0)
        !            43:                kdbcntval = -1;
        !            44:        switch (modif) {
        !            45: 
        !            46:        case 'd':
        !            47:                if (kdbadrflg) {
        !            48:                        if (kdbadrval < 2 || kdbadrval > 16)
        !            49:                                kdberror(kdbBADRAD);
        !            50:                        kdbradix = kdbadrval;
        !            51:                }
        !            52:                kdbprintf("radix=%d base ten", kdbradix);
        !            53:                break;
        !            54: 
        !            55:        case 'w': case 'W':
        !            56:                kdbprintf("maxpos=%d", kdbmaxpos=(kdbadrflg?kdbadrval:MAXPOS));
        !            57:                break;
        !            58: 
        !            59:        case 's': case 'S':
        !            60:                kdbprintf("maxoff=%d", kdbmaxoff=(kdbadrflg?kdbadrval:MAXOFF));
        !            61:                break;
        !            62: 
        !            63:        case 'V':
        !            64:                kdbprintf("variables\n");
        !            65:                for (i=0;i<=35;i++)
        !            66:                        if (kdbvar[i]) {
        !            67:                                kdbprintc((i<=9 ? '0' : 'a'-10) + i);
        !            68:                                kdbprintf(" = %R\n",kdbvar[i]);
        !            69:                        }
        !            70:                break;
        !            71: 
        !            72:        case 0: case '?':
        !            73:                if (p = (struct proc *)kdbvar[kdbvarchk('p')])
        !            74:                        kdbprintf("pid = %d\n", p->p_pid);
        !            75:                else
        !            76:                        kdbprintf("in idle loop\n");
        !            77:                kdbprinttrap(kdbvar[kdbvarchk('t')], kdbvar[kdbvarchk('c')]);
        !            78:                /* fall thru... */
        !            79:        case 'r': case 'R':
        !            80:                kdbprintregs(modif);
        !            81:                return;
        !            82: 
        !            83:        case 'c': case 'C':
        !            84:                kdbstacktrace(modif == 'C');
        !            85:                break;
        !            86: 
        !            87:                /*print externals*/
        !            88:        case 'e': case 'E':
        !            89:                for (sp = kdbsymtab; sp < kdbesymtab; sp++)
        !            90:                        if (sp->n_type==(N_DATA|N_EXT) ||
        !            91:                            sp->n_type==(N_BSS|N_EXT))
        !            92:                                kdbprintf("%s:%12t%R\n", sp->n_un.n_name,
        !            93:                                        kdbget((off_t)sp->n_value, DSP));
        !            94:                break;
        !            95: 
        !            96:                /*print breakpoints*/
        !            97:        case 'b': case 'B':
        !            98:                kdbprintf("breakpoints\ncount%8tbkpt%24tcommand\n");
        !            99:                for (bkptr=kdbbkpthead; bkptr; bkptr=bkptr->nxtbkpt)
        !           100:                        if (bkptr->flag) {
        !           101:                                kdbprintf("%-8.8d",bkptr->count);
        !           102:                                kdbpsymoff((long)bkptr->loc,ISYM,"%24t");
        !           103:                                comptr=bkptr->comm;
        !           104:                                while (*comptr)
        !           105:                                        kdbprintc(*comptr++);
        !           106:                        }
        !           107:                break;
        !           108: 
        !           109:        case 'k':
        !           110:                panic("kdb requested panic");
        !           111:                /* NOTREACHED */
        !           112: 
        !           113:        case 'l': {
        !           114:                struct pte savemmap;
        !           115:                extern char vmmap[];
        !           116: 
        !           117:                savemmap = mmap[0];
        !           118:                for (p = allproc; p; p = p->p_nxt) {
        !           119:                        kdbprintf("%X pid %5d%c%5d %c ", p, p->p_pid,
        !           120:                                p == (struct proc *)kdbvar[kdbvarchk('p')]? '*' : ' ',
        !           121:                                p->p_ppid,
        !           122:                                p->p_stat == SSLEEP ? 'S' :
        !           123:                                p->p_stat == SRUN ? 'R':
        !           124:                                p->p_stat == SIDL ? 'I':
        !           125:                                p->p_stat == SSTOP ? 'T' : '?');
        !           126:                        if (p->p_wchan)
        !           127:                                kdbpsymoff((long)p->p_wchan, ISYM, "");
        !           128:                        if ((p->p_flag & SLOAD) && p->p_addr) {
        !           129:                                int i;
        !           130:                                *(int *)mmap = *(int *)p->p_addr;
        !           131:                                mtpr(TBIS, vmmap);
        !           132: #define U      ((struct user *)vmmap)
        !           133: #ifdef not_until_uarea_completely_mapped
        !           134:                                if (U->u_ttyp)
        !           135:                                        kdbprintf(" ctty %x ", U->u_ttyp);
        !           136: #endif
        !           137:                                kdbprintf(" %.8s ", p->p_comm);
        !           138: #undef U
        !           139:                        }
        !           140: 
        !           141:                        kdbprintc(EOR);
        !           142:                }
        !           143:                mmap[0] = savemmap;
        !           144:                mtpr(TBIS, vmmap);
        !           145:                break;
        !           146:        }
        !           147: 
        !           148:        case 't':       /* XXX - debug */
        !           149:                if (kdbadrflg) {
        !           150:                      kdbprintf("dev       state  rawq   canq  outq  lwat hwat\n");
        !           151: 
        !           152: #define T      ((struct tty *)kdbadrval)       
        !           153:                        kdbprintf("%x  %x %d %d %d %d %d\n", T->t_dev, 
        !           154:                                T->t_state, T->t_rawq.c_cc, 
        !           155:                                T->t_canq.c_cc, T->t_outq.c_cc,
        !           156:                                T->t_lowat, T->t_hiwat);
        !           157:               kdbprintf(" &rawq    &canq      &outq    &outq.c_cf  &rawq.c_cf\n");
        !           158:                        kdbprintf(" %x %x  %x %x %x \n", &T->t_rawq, 
        !           159:                                &T->t_canq, &T->t_outq, &T->t_outq.c_cf, 
        !           160:                                &T->t_rawq.c_cf);
        !           161: #undef T
        !           162:                }
        !           163: 
        !           164:        case 'v': {
        !           165:                register struct mount *mp;
        !           166:                register struct vnode *vp;
        !           167: 
        !           168:                kdbprintf("Locked vnodes\n");
        !           169:                mp = rootfs;
        !           170:                do {
        !           171:                        for (vp = mp->mnt_mounth; vp; vp = vp->v_mountf)
        !           172:                                if (VOP_ISLOCKED(vp))
        !           173:                                        vprint((char *)0, vp);
        !           174:                        mp = mp->mnt_next;
        !           175:                } while (mp != rootfs);
        !           176:                break;
        !           177:        }
        !           178: 
        !           179:        default:
        !           180:                kdberror(kdbBADMOD);
        !           181:        }
        !           182: }
        !           183: 
        !           184: static
        !           185: kdbprintregs(c)
        !           186: {
        !           187:        register REGPTR p;
        !           188:        ADDR v;
        !           189: 
        !           190:        for (p = kdbreglist; p->rname; p++) {
        !           191:                if (c != 'R' && ishiddenreg(p))
        !           192:                        continue;
        !           193:                v = *p->rkern;
        !           194:                kdbprintf("%s%6t%R %16t", p->rname, v);
        !           195:                kdbvalpr((long)v, p->rkern == &kdbpcb.pcb_pc ? ISYM : DSYM);
        !           196:                kdbprintc(EOR);
        !           197:        }
        !           198:        kdbprintpc();
        !           199: }
        !           200: 
        !           201: kdbgetreg(regnam)
        !           202: {
        !           203:        register REGPTR p;
        !           204:        register char *regptr;
        !           205:        char *olp;
        !           206: 
        !           207:        olp = kdblp;
        !           208:        for (p = kdbreglist; p->rname; p++) {
        !           209:                regptr = p->rname;
        !           210:                if (regnam == *regptr++) {
        !           211:                        while (*regptr)
        !           212:                                if (kdbreadchar() != *regptr++) {
        !           213:                                        --regptr;
        !           214:                                        break;
        !           215:                                }
        !           216:                        if (*regptr)
        !           217:                                kdblp = olp;
        !           218:                        else
        !           219:                                return ((int)p->rkern);
        !           220:                }
        !           221:        }
        !           222:        kdblp = olp;
        !           223:        return (-1);
        !           224: }
        !           225: 
        !           226: kdbprintpc()
        !           227: {
        !           228: 
        !           229:        kdbpsymoff((long)kdbpcb.pcb_pc, ISYM, ":%16t");
        !           230:        kdbprintins(ISP, (long)kdbchkget((off_t)kdbpcb.pcb_pc, ISP));
        !           231:        kdbprintc(EOR);
        !           232: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.