|
|
1.1 ! root 1: #include "head.h" ! 2: #include <a.out.h> ! 3: struct user u; ! 4: #include <stdio.h> ! 5: INT signo; ! 6: INT adrflg; ! 7: INT pid; ! 8: ADDR userpc; ! 9: L_INT cntval; ! 10: ! 11: ! 12: /* service routines for sub process control */ ! 13: ! 14: ! 15: /* ! 16: * single step until loc with descriptor format d is modified ! 17: * return its new value. ! 18: */ ! 19: monex(loc, d) ! 20: ADDR loc; char d; { ! 21: register ADDR oldval; ! 22: ! 23: oldval = getval(loc, d); ! 24: do { ! 25: subpcs('s'); ! 26: } while (oldval == getval(loc, d)); ! 27: return(getval(loc, d)); ! 28: } ! 29: ! 30: /* single step count source stmts */ ! 31: singstep(count, cmd) ! 32: char cmd; { ! 33: register int thisline, curline; ! 34: register struct proct *thisproc; ! 35: ! 36: if (sdbttym.sg_flags != userttym.sg_flags) ! 37: stty(2, &userttym); ! 38: dot = *(ADDR *) (((ADDR) &u) + PC); ! 39: thisproc = adrtoprocp(dot); ! 40: thisline = adrtolineno(dot); ! 41: if (count == 0) count = 1; ! 42: for(; count; count--) { ! 43: do { ! 44: if (cmd == 'S') { ! 45: dot = *(ADDR *) (((ADDR) &u) + PC); ! 46: if ((get(dot,ISP) & 0xff) == 0xfb){ /* calls */ ! 47: int retaddr; ! 48: subpcs('s'); ! 49: retaddr = ! 50: *(ADDR *) (((ADDR) &u) + USP) + 16; ! 51: retaddr = dot = get(retaddr, DSP); ! 52: subpcs('b'); ! 53: subpcs('c'); ! 54: dot = retaddr; ! 55: subpcs('d'); ! 56: dot = *(ADDR *) (((ADDR) &u) + PC); ! 57: if (retaddr != dot && signo == 0) { ! 58: gtty(2, &userttym); ! 59: if (sdbttym.sg_flags != ! 60: userttym.sg_flags) ! 61: stty(2, &sdbttym); ! 62: printf("Breakpoint at \n"); ! 63: return; ! 64: } ! 65: continue; ! 66: } ! 67: } ! 68: ! 69: subpcs('s'); ! 70: dot = *(ADDR *) (((ADDR) &u) + PC); ! 71: curline = adrtolineno(dot); ! 72: } while (!signo && ! 73: ((thisproc == adrtoprocp(dot) && thisline == curline) || ! 74: curline == -1)); ! 75: gtty(2, &userttym); ! 76: if (sdbttym.sg_flags != userttym.sg_flags) ! 77: stty(2, &sdbttym); ! 78: if (signo) return; ! 79: } ! 80: } ! 81: ! 82: doscall() { ! 83: int subargs[NUMARGS]; /* subargs[0] = address, ! 84: subargs[1] = number of arguments ! 85: subargs[2:NUMARGS] = actual arguments */ ! 86: union { ! 87: struct { ! 88: int w[128-NUMARGS]; ! 89: }; ! 90: struct { ! 91: char c[4*(128-NUMARGS)]; ! 92: }; ! 93: }substr; ! 94: ! 95: register int i, numchars, *subargp; ! 96: register char ch; ! 97: ADDR straddr, adr, praddr; ! 98: ADDR j; ! 99: ! 100: praddr = extaddr(proc); ! 101: if (praddr == -1) { ! 102: printf("Cannot find %s\n", proc); ! 103: return; ! 104: } ! 105: straddr = extaddr("_dbargs"); ! 106: if (straddr == -1) { ! 107: error("Program not loaded with -lg"); ! 108: return; ! 109: } ! 110: ! 111: numchars = 0; ! 112: subargp = subargs; ! 113: argsp++; ! 114: *subargp++ = praddr; ! 115: subargp++; ! 116: ! 117: for (i=0; i<NUMARGS - 2; i++) { /* process an argument */ ! 118: ch = *argsp; ! 119: if (ch == '\'') { ! 120: *subargp++ = *(argsp+1); ! 121: argsp += 2; ! 122: } else if (ch == '"') { ! 123: *subargp++ = straddr + sizeof subargs + numchars; ! 124: argsp++; ! 125: for (;;) { ! 126: ch = *argsp++; ! 127: if (ch == '\\') { ! 128: switch(ch = *argsp++) { ! 129: case 'r': ! 130: ch = '\015'; ! 131: break; ! 132: case 'n': ! 133: ch = '\012'; ! 134: break; ! 135: case '\\': ! 136: ch = '\\'; ! 137: break; ! 138: } ! 139: } ! 140: substr.c[numchars++] = ch; ! 141: if (ch == '"') { ! 142: substr.c[numchars-1] = '\0'; ! 143: break; ! 144: } ! 145: if (ch == '\0') { ! 146: error("Unterminated string constant"); ! 147: return; ! 148: } ! 149: if (numchars > sizeof substr.c) { ! 150: error("Too many string constants"); ! 151: return; ! 152: } ! 153: } ! 154: } else if ((ch >= '0' && ch <= '9') || ch == '-') { ! 155: *subargp++ = readint(&argsp); ! 156: } else if ((ch >= 'a' && ch <= 'z') || ! 157: (ch >= 'A' && ch <= 'Z') || ch == '_') { ! 158: cpname(var, argsp); ! 159: j = varaddr(curproc()->pname, var); ! 160: if (j == -1) { ! 161: return; ! 162: } ! 163: *subargp++ = ! 164: sl_class == N_RSYM ? ! 165: *(ADDR *)(((ADDR) &u) + R0 + (WORDSIZE)*j) : ! 166: getval(j, typetodesc(sl_type, 0)[0]); ! 167: do { ! 168: argsp++; ! 169: } while (varchar(*argsp) || number(*argsp)); ! 170: } else if (ch != ')') { ! 171: printf("Unexpected character %c\n", ch); ! 172: return; ! 173: } ! 174: ! 175: do { ! 176: ch = *argsp++; ! 177: } while(ch == ' '); ! 178: if (ch == ')') { ! 179: if (scallx == 0) { ! 180: scallx = 1; ! 181: pcs = *(ADDR *)(((ADDR)&u)+PC); ! 182: fps = *(ADDR *)(((ADDR)&u)+FP); ! 183: aps = *(ADDR *)(((ADDR)&u)+AP); ! 184: if (bkpts = scanbkpt(userpc)) { ! 185: if (flagss = bkpts->flag) { ! 186: bkpts->flag = BKPTSET; ! 187: } ! 188: } ! 189: } ! 190: dot = *(ADDR *)(((ADDR)&u)+PC) = extaddr("_dbsubc"); ! 191: if (dot == -1) { ! 192: error("Internal error - cannot find _dbsubc"); ! 193: return; ! 194: } ! 195: adrflg = 1; ! 196: cntval = 1; ! 197: if (pid == 0 || signo) subpcs('r'); ! 198: subargs[1] = (subargp - subargs) - 2; ! 199: adr = straddr; ! 200: for (j=0; j<=(subargp-subargs); j++) { ! 201: put(adr, DSP, subargs[j]); ! 202: adr += WORDSIZE; ! 203: } ! 204: adr = straddr + sizeof subargs; ! 205: for (j=0; j<(numchars+WORDSIZE-1)/WORDSIZE; j++) { ! 206: put(adr, DSP, substr.w[j]); ! 207: adr += WORDSIZE; ! 208: } ! 209: dschar = *argsp++; ! 210: errflg = 0; ! 211: dopcs('c'); ! 212: if (!signo) printf("Breakpoint"); ! 213: printf(" at\n"); ! 214: return; ! 215: } ! 216: while (*argsp == ' ' || *argsp == ',') ! 217: argsp++; ! 218: } ! 219: ! 220: error ("Too many arguments"); ! 221: ! 222: } ! 223: ! 224: ! 225: /* get arguments from core file, place them in args */ ! 226: getargs() { ! 227: struct proct *procp; ! 228: ADDR p, av; ! 229: int ac, i; ! 230: char *argsp = args; ! 231: union { ! 232: struct { ! 233: char c[WORDSIZE]; ! 234: }; ! 235: struct { ! 236: int w; ! 237: }; ! 238: struct { ! 239: float f; ! 240: } ! 241: } word; ! 242: ! 243: if ((procp = initframe()) == badproc) goto old1; ! 244: do { ! 245: if (eqstr("main", procp->pname)) ! 246: goto fnd; ! 247: } while ((procp = nextframe()) != badproc); ! 248: ! 249: old1: cpstr(args, oldargs); ! 250: printf("%s %s\n", symfil, args); ! 251: return; ! 252: ! 253: fnd: ac = get(argp, DSP); ! 254: if ((ac == 0) || (ac & 0xff)) goto old1; ! 255: ac = get(argp+4, DSP); ! 256: av = (ADDR) get(argp+8, DSP); ! 257: ! 258: av += WORDSIZE; ! 259: ac--; ! 260: ! 261: for (; ac; ac--) { ! 262: p = (ADDR) get(av, DSP); ! 263: av += WORDSIZE; ! 264: for (;;) { ! 265: word.w = get(p, DSP); ! 266: for (i=0; i<WORDSIZE; i++) { ! 267: if (word.c[i] == '\0') goto l1; ! 268: *argsp++ = word.c[i]; ! 269: } ! 270: p += WORDSIZE; ! 271: } ! 272: l1: *argsp++ = ' '; ! 273: } ! 274: *argsp == '\0'; ! 275: printf("%s %s\n", symfil, args); ! 276: return; ! 277: ! 278: ! 279: } ! 280: ! 281: dopcs(c) ! 282: char c; { ! 283: if (c != 'r' && c != 'R' && sdbttym.sg_flags != userttym.sg_flags) ! 284: stty(2, &userttym); ! 285: subpcs(c); ! 286: gtty(2, &userttym); ! 287: if (sdbttym.sg_flags != userttym.sg_flags) ! 288: stty(2, &sdbttym); ! 289: ! 290: if (eqany(c, "cCsS") && ! 291: *(ADDR *)(((ADDR)&u)+PC) == extaddr("_dbsubn")) { ! 292: if (dschar == '/') { ! 293: dispf((ADDR) 0, *argsp ? argsp : "d", N_RSYM, 0, 0); ! 294: } ! 295: else ! 296: printf("Procedure returned normally\n"); ! 297: userpc = dot = *(ADDR *)(((ADDR)&u)+PC) = pcs; ! 298: *(ADDR *)(((ADDR)&u)+FP) = fps; ! 299: *(ADDR *)(((ADDR)&u)+AP) = aps; ! 300: if (bkpts) ! 301: bkpts->flag = flagss; ! 302: scallx = 0; ! 303: longjmp(env, 0); ! 304: } ! 305: } ! 306: ! 307: /* execute commands from a breakpoint */ ! 308: acommand(cmds) ! 309: char *cmds; { ! 310: char *p = cmds; ! 311: int endflg = 0; ! 312: ! 313: setcur(0); ! 314: do { /* process a command */ ! 315: for (;;) { ! 316: if (*p == ';') { ! 317: *p = '\n'; ! 318: break; ! 319: } ! 320: if (*p == '\n') { ! 321: endflg++; ! 322: break; ! 323: } ! 324: p++; ! 325: } ! 326: if (decode(cmds) == 1) { ! 327: printf("Bad command: "); ! 328: do { ! 329: printf("%c", *cmds); ! 330: } while (*cmds++ != '\n'); ! 331: return; ! 332: } ! 333: docommand(); ! 334: p = cmds = p + 1; ! 335: } while (!endflg); ! 336: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.