|
|
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_format.c 7.5 (Berkeley) 5/3/90 ! 7: */ ! 8: ! 9: #include "../kdb/defs.h" ! 10: ! 11: char *kdbBADMOD; ! 12: char *kdbADWRAP; ! 13: ! 14: char *kdblp; ! 15: char kdblastc,kdbpeekc; ! 16: long kdbexpv; ! 17: ! 18: kdbscanform(icount,ifp,itype,ptype) ! 19: long icount; ! 20: char *ifp; ! 21: { ! 22: register char *fp; ! 23: char modifier; ! 24: register fcount, init=1; ! 25: long savdot; ! 26: int exact; ! 27: ! 28: while (icount) { ! 29: fp=ifp; ! 30: savdot=kdbdot; init=0; ! 31: if (!init && (exact=(kdbfindsym(kdbdot,ptype)==0)) && kdbmaxoff) ! 32: kdbprintf("\n%s:%16t",kdbcursym->n_un.n_name); ! 33: /*now loop over format*/ ! 34: while (*fp && kdberrflg==0) { ! 35: if (isdigit(modifier = *fp)) { ! 36: fcount = 0; ! 37: while (isdigit(modifier = *fp++)) { ! 38: fcount *= 10; ! 39: fcount += modifier-'0'; ! 40: } ! 41: fp--; ! 42: } else ! 43: fcount = 1; ! 44: if (*fp==0) ! 45: break; ! 46: #ifdef ENTRYMASK ! 47: /* check for entry mask */ ! 48: if (exact && kdbdot==savdot && ! 49: (kdbcursym->n_type&N_TYPE)==N_TEXT && ! 50: kdbcursym->n_un.n_name[0]=='_' && *fp=='i') { ! 51: (void) kdbexform(1,"x",itype,ptype); ! 52: fp++; ! 53: kdbprintc(EOR); ! 54: } else ! 55: #endif ! 56: fp = kdbexform(fcount,fp,itype,ptype); ! 57: } ! 58: kdbdotinc=kdbdot-savdot; ! 59: kdbdot=savdot; ! 60: ! 61: if (kdberrflg) { ! 62: if (icount<0) { ! 63: kdberrflg=0; ! 64: break; ! 65: } ! 66: kdberror(kdberrflg); ! 67: } ! 68: if (--icount) ! 69: kdbdot=kdbinkdot(kdbdotinc); ! 70: if (kdbmkfault) ! 71: kdberror((char *)0); ! 72: } ! 73: } ! 74: ! 75: /* ! 76: * Execute single format item `fcount' times ! 77: * sets `dotinc' and moves `dot' ! 78: * returns address of next format item ! 79: */ ! 80: char * ! 81: kdbexform(fcount,ifp,itype,ptype) ! 82: int fcount; ! 83: char *ifp; ! 84: { ! 85: register POS w; ! 86: register long savdot, wx; ! 87: register char *fp; ! 88: char c, modifier, longpr; ! 89: ! 90: while (fcount>0) { ! 91: fp = ifp; c = *fp; ! 92: longpr = (isupper(c) || c=='f' || c=='4' || c=='p'); ! 93: if (itype != NSP && *fp != 'a') { ! 94: wx = kdbget(kdbdot, itype); ! 95: w = shorten(wx); ! 96: } else { ! 97: wx = w = kdbdot; ! 98: if (itype == NSP && ! 99: (c == 'b' || c == 'B' || ! 100: c == 'c' || c == 'C' || c == '1')) ! 101: w = btol(wx); ! 102: } ! 103: if (kdberrflg) ! 104: return (fp); ! 105: if (kdbmkfault) ! 106: kdberror((char *)0); ! 107: kdbvar[0] = wx; ! 108: modifier = *fp++; ! 109: kdbdotinc = (longpr ? sizeof (long):sizeof (short)); ! 110: ! 111: if (kdbcharpos()==0 && modifier!='a') ! 112: kdbprintf("%16m"); ! 113: switch (modifier) { ! 114: ! 115: case SP: case TB: ! 116: break; ! 117: ! 118: case 't': case 'T': ! 119: kdbprintf("%T",fcount); return (fp); ! 120: ! 121: case 'r': case 'R': ! 122: kdbprintf("%M",fcount); return (fp); ! 123: ! 124: case 'a': ! 125: kdbpsymoff(kdbdot,ptype,":%16t"); kdbdotinc=0; break; ! 126: ! 127: case 'p': ! 128: kdbpsymoff(kdbvar[0],ptype,"%16t"); break; ! 129: ! 130: case 'u': ! 131: kdbprintf("%-8u",w); break; ! 132: ! 133: case 'U': ! 134: kdbprintf("%-16U",wx); break; ! 135: ! 136: case 'c': case 'C': ! 137: if (modifier == 'C') ! 138: kdbprintesc((int)byte(w)); ! 139: else ! 140: kdbprintc((char)byte(w)); ! 141: kdbdotinc=1; break; ! 142: ! 143: case 'b': case 'B': ! 144: kdbprintf("%-8o", byte(w)); kdbdotinc=1; break; ! 145: ! 146: case '1': ! 147: kdbprintf("%-8R", byte(w)); kdbdotinc=1; break; ! 148: ! 149: case 'w': case '2': ! 150: kdbprintf("%-8R", w); break; ! 151: ! 152: case 'W': case '4': ! 153: kdbprintf("%-16R", wx); break; ! 154: ! 155: case 's': case 'S': ! 156: savdot=kdbdot; kdbdotinc=1; ! 157: while ((c=byte(kdbget(kdbdot,itype))) && kdberrflg==0) { ! 158: kdbdot=kdbinkdot(1); ! 159: if (modifier == 'S') ! 160: kdbprintesc((int)c); ! 161: else ! 162: kdbprintc(c); ! 163: kdbendline(); ! 164: } ! 165: kdbdotinc=kdbdot-savdot+1; kdbdot=savdot; break; ! 166: ! 167: case 'x': ! 168: kdbprintf("%-8x",w); break; ! 169: ! 170: case 'X': ! 171: kdbprintf("%-16X", wx); break; ! 172: ! 173: case 'z': ! 174: kdbprintf("%-8z",w); break; ! 175: ! 176: case 'Z': ! 177: kdbprintf("%-16Z", wx); break; ! 178: ! 179: case 'Y': ! 180: kdbprintf("%-24Y", wx); break; ! 181: ! 182: case 'q': ! 183: kdbprintf("%-8q", w); break; ! 184: ! 185: case 'Q': ! 186: kdbprintf("%-16Q", wx); break; ! 187: ! 188: case 'o': ! 189: kdbprintf("%-8o", w); break; ! 190: ! 191: case 'O': ! 192: kdbprintf("%-16O", wx); break; ! 193: ! 194: case 'i': case 'I': ! 195: kdbprintins(itype,wx); kdbprintc(EOR); break; ! 196: ! 197: case 'd': ! 198: kdbprintf("%-8d", w); break; ! 199: ! 200: case 'D': ! 201: kdbprintf("%-16D", wx); break; ! 202: ! 203: case 'n': case 'N': ! 204: kdbprintc('\n'); kdbdotinc=0; break; ! 205: ! 206: case '"': ! 207: kdbdotinc=0; ! 208: while (*fp != '"' && *fp) ! 209: kdbprintc(*fp++); ! 210: if (*fp) ! 211: fp++; ! 212: break; ! 213: ! 214: case '^': ! 215: kdbdot=kdbinkdot(-kdbdotinc*fcount); return (fp); ! 216: ! 217: case '+': ! 218: kdbdot=kdbinkdot(fcount); return (fp); ! 219: ! 220: case '-': ! 221: kdbdot=kdbinkdot(-fcount); return (fp); ! 222: ! 223: default: ! 224: kdberror(kdbBADMOD); ! 225: } ! 226: if (itype!=NSP) ! 227: kdbdot=kdbinkdot(kdbdotinc); ! 228: fcount--; kdbendline(); ! 229: } ! 230: return (fp); ! 231: } ! 232: ! 233: static ! 234: kdbprintesc(c) ! 235: register int c; ! 236: { ! 237: ! 238: c &= STRIP; ! 239: if (c==0177 || c<SP) ! 240: kdbprintf("^%c", c ^ 0100); ! 241: else ! 242: kdbprintc(c); ! 243: } ! 244: ! 245: long ! 246: kdbinkdot(incr) ! 247: { ! 248: register long newdot; ! 249: ! 250: newdot=kdbdot+incr; ! 251: if (addrwrap(kdbdot, newdot)) ! 252: kdberror(kdbADWRAP); ! 253: return (newdot); ! 254: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.