1: # 2: /* 3: * 4: * UNIX debugger 5: * 6: */ 7: 8: #include "defs.h" 9: 10: 11: MSG NOCFN; 12: 13: INT callpc; 14: BOOL localok; 15: SYMTAB symbol; 16: 17: STRING errflg; 18: 19: OVTAG curov; 20: INT overlay; 21: L_INT var[36]; 22: 23: 24: findroutine(cframe) 25: L_INT cframe; 26: { 27: REG INT narg, inst; 28: INT lastpc, back2; 29: BOOL v; 30: OVTAG savov, curovl; 31: 32: v=FALSE; localok=FALSE; lastpc=callpc; 33: if(overlay) { 34: /* 35: * Save the previous overlay. Don't restore it, 36: * so that the next call will have the correct previous 37: * overlay. The caller must save and restor the original 38: * overlay if needed. 39: */ 40: savov = curov; 41: curovl=get(cframe-2, DSP); 42: setovmap(curovl); 43: } 44: callpc=get(cframe+2, DSP); back2=get(leng(callpc-2), ISP); 45: IF (inst=get(leng(callpc-4), ISP)) == 04737 /* jsr pc,*$... */ 46: THEN narg = 1; 47: ELIF (inst&~077)==04700 /* jsr pc,... */ 48: THEN narg=0; v=(inst!=04767); 49: ELIF (back2&~077)==04700 50: THEN narg=0; v=TRUE; 51: ELSE errflg=NOCFN; 52: return(0); 53: FI 54: if (overlay) 55: setovmap(savov); /* previous overlay, for findsym */ 56: IF findsym( (v ? lastpc : ((inst==04767?callpc:0) + back2) ),ISYM) == -1 57: ANDF !v 58: THEN symbol.symc[0] = '?'; 59: symbol.symc[1] = 0; 60: symbol.symv = 0; 61: ELSE localok=TRUE; 62: FI 63: if (overlay) 64: setovmap(curovl); 65: inst = get(leng(callpc), ISP); 66: IF inst == 062706 /* add $n,sp */ 67: THEN 68: narg += get(leng(callpc+2), ISP)/2; 69: return(narg); 70: FI 71: IF inst == 05726 /* tst (sp)+ */ 72: THEN 73: return(narg+1); 74: FI 75: IF inst == 022626 /* cmp (sp)+,(sp)+ */ 76: THEN 77: return(narg+2); 78: FI 79: return(narg); 80: }