Adb and Local Symbols
Alex White
arwhite at watmath.UUCP
Thu Mar 1 18:06:57 AEST 1984
Well, I've gotten tired of having to find variables on the stack myself,
and even trying to find the value of register variables, without even
adb printing out the current frame pointer.
Since Berkley has eliminated the local symbols, and you have to
use compiler specific stuff to get them, I figured this is better than nothing.
So, with the following, $C will now print the registers and the values
of automatic variables as you go back on the stack, and tells you where
in the stack they were.
Actually, only the changes to print.c are needed, but you might like the
other two fixes, one so if you try to print using floating point format
adb won't die if its the reserved operand floating point value;
and also so it won't die if it gets a format repeat count of zero under
some obscure condition that I forget right now.
diff -c ./format.c /usr/distr/4.2/usr/src/bin/adb/format.c
*** ./format.c Thu Dec 1 17:50:08 1983
--- /usr/distr/4.2/usr/src/bin/adb/format.c Thu Aug 11 23:06:52 1983
***************
*** 60,67
fcount += modifier-'0';
OD
fp--;
- if(fcount == 0)
- fcount = 1;
ELSE fcount = 1;
FI
--- 60,65 -----
fcount += modifier-'0';
OD
fp--;
ELSE fcount = 1;
FI
***************
*** 218,227
case 'f':
fw = 0;
fw.sa = wx;
! if((wx & ~0xFFFF00FF) == 0x8000)
! printf("(reserved oprnd)");
! else
! printf("%-16.9f", fw);
dotinc=4; break;
case 'F':
--- 216,222 -----
case 'f':
fw = 0;
fw.sa = wx;
! printf("%-16.9f", fw);
dotinc=4; break;
case 'F':
***************
*** 226,235
case 'F':
fw.sa = wx;
! if((wx & ~0xFFFF00FF) == 0x8000)
! printf("%-32s", "(reserved oprnd)");
! else
! printf("%-32.18F", fw);
dotinc=8; break;
case 'n': case 'N':
--- 221,227 -----
case 'F':
fw.sa = wx;
! printf("%-32.18F", fw);
dotinc=8; break;
case 'n': case 'N':
diff -c ./print.c /usr/distr/4.2/usr/src/bin/adb/print.c
*** ./print.c Fri Feb 24 04:19:43 1984
--- /usr/distr/4.2/usr/src/bin/adb/print.c Sun Aug 14 23:38:34 1983
***************
*** 250,265
printregs();
return;
! case 'c': case 'C': {
! int regs[12], *q;
! REGPTR p;
! int i, j, k, l;
! int stackp;
!
! /* Get current registers */
! for(p = ®list[12], q = ®s[11]; p < ®list[24]; p++, q--)
! *q = kcore ? *p->rkern : *(ADDR *)(((ADDR)&u)+p->roffs);
!
IF adrflg
THEN frame=adrval;
word=get(adrval+6,DSP)&0xFFFF;
--- 250,256 -----
printregs();
return;
! case 'c': case 'C':
IF adrflg
THEN frame=adrval;
word=get(adrval+6,DSP)&0xFFFF;
***************
*** 270,276
ELSE /* 'callg', can't tell where argp is */ argp=frame;
FI
callpc=get(frame+16,DSP);
- stackp = argp; /* Don't know */
ELIF kcore THEN
argp = pcb.pcb_ap;
frame = pcb.pcb_fp;
--- 261,266 -----
ELSE /* 'callg', can't tell where argp is */ argp=frame;
FI
callpc=get(frame+16,DSP);
ELIF kcore THEN
argp = pcb.pcb_ap;
frame = pcb.pcb_fp;
***************
*** 275,281
argp = pcb.pcb_ap;
frame = pcb.pcb_fp;
callpc = pcb.pcb_pc;
- stackp = pcb.pcb_ksp;
ELSE argp= *(ADDR *)(((ADDR)&u)+AP);
frame= *(ADDR *)(((ADDR)&u)+FP);
callpc= *(ADDR *)(((ADDR)&u)+PC);
--- 265,270 -----
argp = pcb.pcb_ap;
frame = pcb.pcb_fp;
callpc = pcb.pcb_pc;
ELSE argp= *(ADDR *)(((ADDR)&u)+AP);
frame= *(ADDR *)(((ADDR)&u)+FP);
callpc= *(ADDR *)(((ADDR)&u)+PC);
***************
*** 279,285
ELSE argp= *(ADDR *)(((ADDR)&u)+AP);
frame= *(ADDR *)(((ADDR)&u)+FP);
callpc= *(ADDR *)(((ADDR)&u)+PC);
- stackp= *(ADDR *)(((ADDR)&u)+USP);
FI
lastframe=0;
ntramp = 0;
--- 268,273 -----
ELSE argp= *(ADDR *)(((ADDR)&u)+AP);
frame= *(ADDR *)(((ADDR)&u)+FP);
callpc= *(ADDR *)(((ADDR)&u)+PC);
FI
lastframe=0;
ntramp = 0;
***************
*** 312,323
THEN WHILE localsym(frame,argp)
DO word=get(localval,DSP);
printf("%8t%s:%10t", cursym->n_un.n_name);
! IF errflg THEN
! prints("?\n");
! errflg=0;
! ELSE
! printf("%R\n",word);
! FI
OD
printf("fp: %X%15tap: %X%30tsp: %X\n", frame, argp, stackp);
/* Print current registers. */
--- 300,306 -----
THEN WHILE localsym(frame,argp)
DO word=get(localval,DSP);
printf("%8t%s:%10t", cursym->n_un.n_name);
! IF errflg THEN prints("?\n"); errflg=0; ELSE printf("%R\n",word); FI
OD
FI
***************
*** 319,358
printf("%R\n",word);
FI
OD
- printf("fp: %X%15tap: %X%30tsp: %X\n", frame, argp, stackp);
- /* Print current registers. */
- printf("r0: %X%15tr1: %X%30tr2: %X%45tr3: %X\n",
- regs[0], regs[1], regs[2], regs[3]);
- printf("r4: %X%15tr5: %X%30tr6: %X%45tr7: %X\n",
- regs[4], regs[5], regs[6], regs[7]);
- printf("r8: %X%15tr9: %X%30tr10: %X%45tr11: %X\n",
- regs[8], regs[9], regs[10], regs[11]);
- /* Get next frame's registers. */
- i = get(frame+4, DSP);
- i >>= 16; i &= 0xfff; /* Register mask */
- for(j = 0x1, k = 0, l = 0 ; (j & 0x1000) == 0 ; j <<= 1, k++)
- if(i & j)
- regs[k] = get(frame+20+l++*4, DSP);
- /*
- * Print the current frame's auto variables - i.e -4(fp) -> (sp)
- */
- #define MAXPRINT 30 /* Max # of auto words to print */
- k = stackp;
- if(frame - MAXPRINT*4 > stackp)
- stackp = frame - MAXPRINT*4;
- for(i = frame-4 ; i > stackp ; i -= 4)
- printf("%X: %X(fp):%20t%X\n", i, i-frame, get(i, DSP));
- if(k != stackp)
- printf("%X: %X(fp) ... %X: %X(fp) not displayed\n",
- i, i-frame, k, k-frame);
- /*
- * Calculate the previous frame's sp
- */
- stackp = frame + (5+l)*4; /* 0, PSW, AP, FP, PC, saved regs */
- i = get(frame+4, DSP);
- stackp += (i >> 30) & 0x3; /* Stack alignment */
- if(i & (1<<29)) /* If CALLS, add on arg space */
- stackp += (get(frame+20+l*4, DSP) & 0xff) * 4;
FI
if (ntramp == 1)
--- 302,307 -----
printf("%8t%s:%10t", cursym->n_un.n_name);
IF errflg THEN prints("?\n"); errflg=0; ELSE printf("%R\n",word); FI
OD
FI
if (ntramp == 1)
***************
*** 367,373
FI
OD
break;
- }
/*print externals*/
case 'e': case 'E':
--- 316,321 -----
FI
OD
break;
/*print externals*/
case 'e': case 'E':
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list