Apurdue.178 net.bugs.4bsd utcsrgv!utzoo!decvax!pur-ee!purdue!cak Tue Feb 2 21:00:25 1982 pstat.c fixes -- you asked for it! >From cak Tue Feb 2 20:58:48 1982 To: csvax.4bsd-bugs@berkeley Subject: pstat.c fixes The following diffs show changes made to allow pstat to operate properly with post-mortem core dumps. Basically, addresses were not having the high order bit properly cleared when dealing with dumps. It also fixes a recently reported bug about the addresses the -f option reports. Please note also that the documentation does not mention the -k flag which is expected when dealing with core dumps. Chris Kent *** /usr/src/cmd/pstat.c Tue Feb 2 20:51:06 1982 --- /usr/src/cmd/pstat.c.v0 Tue Feb 2 20:20:29 1982 *************** *** 1,8 static char *sccsid = "@(#)pstat.c 4.9 (Berkeley) 5/7/81"; /* * Print system stuff - * - * fixed to handle core dumps properly, 2/2/81 -- cak */ #define mask(x) (x&0377) --- 1,6 ----- static char *sccsid = "@(#)pstat.c 4.9 (Berkeley) 5/7/81"; /* * Print system stuff */ #define mask(x) (x&0377) *************** *** 203,209 nin = 0; ninode = getw(nl[SNINODE].n_value); xinode = (struct inode *)calloc(ninode, sizeof (struct inode)); ! kseek(fc, (int)(ainode = (struct inode *)getw(nl[SINODE].n_value)), 0); read(fc, xinode, ninode * sizeof(struct inode)); for (ip = xinode; ip i_count) --- 201,207 ----- nin = 0; ninode = getw(nl[SNINODE].n_value); xinode = (struct inode *)calloc(ninode, sizeof (struct inode)); ! lseek(fc, (int)(ainode = (struct inode *)getw(nl[SINODE].n_value)), 0); read(fc, xinode, ninode * sizeof(struct inode)); for (ip = xinode; ip i_count) *************** *** 246,252 if (kflg) loc &= 0x7fffffff; ! kseek(fc, loc, 0); read(fc, &word, sizeof (word)); if (kflg) word &= 0x7fffffff; --- 244,250 ----- if (kflg) loc &= 0x7fffffff; ! lseek(fc, loc, 0); read(fc, &word, sizeof (word)); if (kflg) word &= 0x7fffffff; *************** *** 271,277 ntx = 0; ntext = getw(nl[SNTEXT].n_value); xtext = (struct text *)calloc(ntext, sizeof (struct text)); ! kseek(fc, (int)(atext = (struct text *)getw(nl[STEXT].n_value)), 0); read(fc, xtext, ntext * sizeof (struct text)); for (xp = xtext; xp x_iptr!=NULL) --- 269,275 ----- ntx = 0; ntext = getw(nl[SNTEXT].n_value); xtext = (struct text *)calloc(ntext, sizeof (struct text)); ! lseek(fc, (int)(atext = (struct text *)getw(nl[STEXT].n_value)), 0); read(fc, xtext, ntext * sizeof (struct text)); for (xp = xtext; xp x_iptr!=NULL) *************** *** 315,321 nproc = getw(nl[SNPROC].n_value); xproc = (struct proc *)calloc(nproc, sizeof (struct proc)); ! kseek(fc, (int)(aproc = (struct proc *)getw(nl[SPROC].n_value)), 0); read(fc, xproc, nproc * sizeof (struct proc)); np = 0; for (pp=xproc; pp p_ppid); if (kflg) pp->p_addr = (struct pte *)clear((int)pp->p_addr); ! kseek(fc, (long)(Usrptma+btokmx(pp->p_addr)), 0); read(fc, &apte, sizeof(apte)); printf(" %8x", ctob(apte.pg_pfnum+1) - sizeof(struct pte) * UPAGES); printf(" %4x", pp->p_rssize); --- 344,350 ----- printf(" %6d", pp->p_ppid); if (kflg) pp->p_addr = (struct pte *)clear((int)pp->p_addr); ! lseek(fc, (long)(Usrptma+btokmx(pp->p_addr)), 0); read(fc, &apte, sizeof(apte)); printf(" %8x", ctob(apte.pg_pfnum+1) - sizeof(struct pte) * UPAGES); printf(" %4x", pp->p_rssize); *************** *** 370,376 printf("1 cons\n"); if (kflg) nl[SKL].n_value = clear(nl[SKL].n_value); ! kseek(fc, (long)nl[SKL].n_value, 0); read(fc, dz_tty, sizeof(dz_tty[0])); mesg = " # RAW CAN OUT MODE ADDR DEL COL STATE PGRP DISC\n"; printf(mesg); --- 368,374 ----- printf("1 cons\n"); if (kflg) nl[SKL].n_value = clear(nl[SKL].n_value); ! lseek(fc, (long)nl[SKL].n_value, 0); read(fc, dz_tty, sizeof(dz_tty[0])); mesg = " # RAW CAN OUT MODE ADDR DEL COL STATE PGRP DISC\n"; printf(mesg); *************** *** 381,387 nl[SNDZ].n_value = clear(nl[SNDZ].n_value); nl[SDZ].n_value = clear(nl[SDZ].n_value); } ! kseek(fc, (long)nl[SNDZ].n_value, 0); read(fc, &ndz, sizeof(ndz)); printf("%d dz lines\n", ndz); kseek(fc, (long)nl[SDZ].n_value, 0); --- 379,385 ----- nl[SNDZ].n_value = clear(nl[SNDZ].n_value); nl[SDZ].n_value = clear(nl[SDZ].n_value); } ! lseek(fc, (long)nl[SNDZ].n_value, 0); read(fc, &ndz, sizeof(ndz)); printf("%d dz lines\n", ndz); lseek(fc, (long)nl[SDZ].n_value, 0); *************** *** 384,390 kseek(fc, (long)nl[SNDZ].n_value, 0); read(fc, &ndz, sizeof(ndz)); printf("%d dz lines\n", ndz); ! kseek(fc, (long)nl[SDZ].n_value, 0); read(fc, dz_tty, sizeof(dz_tty)); for (tp = dz_tty; tp sizeof (struct user) */ ! kseek(fc, ubase * NBPG, 0); read(fc, &U, sizeof(U)); printf("pcb"); ip = (int *)&U.u_pcb; --- 457,463 ----- register i, j, *ip; /* This wins only if PAGSIZ > sizeof (struct user) */ ! lseek(fc, ubase * NBPG, 0); read(fc, &U, sizeof(U)); printf("pcb"); ip = (int *)&U.u_pcb; *************** *** 589,595 nf = 0; nfile = getw(nl[SNFILE].n_value); xfile = (struct file *)calloc(nfile, sizeof (struct file)); ! kseek(fc, (int)(afile = (struct file *)getw(nl[SFIL].n_value)), 0); read(fc, xfile, nfile * sizeof (struct file)); for (fp=xfile; fp f_count) --- 587,593 ----- nf = 0; nfile = getw(nl[SNFILE].n_value); xfile = (struct file *)calloc(nfile, sizeof (struct file)); ! lseek(fc, (int)(afile = (struct file *)getw(nl[SFIL].n_value)), 0); read(fc, xfile, nfile * sizeof (struct file)); for (fp=xfile; fp f_count) *************** *** 600,608 } printf("%d/%d open files\n", nf, nfile); printf(" LOC FLG CNT INO OFFS\n"); ! if(kflg) ! afile = (struct file *)clear((int)afile); ! for (fp=xfile,loc=(int)afile; fp f_count==0) continue; printf("%8x ", loc); --- 598,604 ----- } printf("%d/%d open files\n", nf, nfile); printf(" LOC FLG CNT INO OFFS\n"); ! for (fp=xfile,loc=nl[SFIL].n_value; fp f_count==0) continue; printf("%8x ", loc); *************** *** 630,636 nproc = getw(nl[SNPROC].n_value); proc = (struct proc *)calloc(nproc, sizeof (struct proc)); ! kseek(fc, getw(nl[SPROC].n_value), 0); read(fc, proc, nproc * sizeof (struct proc)); nswapmap = getw(nl[SNSWAPMAP].n_value); swapmap = (struct map *)calloc(nswapmap, sizeof (struct map)); --- 626,632 ----- nproc = getw(nl[SNPROC].n_value); proc = (struct proc *)calloc(nproc, sizeof (struct proc)); ! lseek(fc, getw(nl[SPROC].n_value), 0); read(fc, proc, nproc * sizeof (struct proc)); nswapmap = getw(nl[SNSWAPMAP].n_value); swapmap = (struct map *)calloc(nswapmap, sizeof (struct map)); *************** *** 634,640 read(fc, proc, nproc * sizeof (struct proc)); nswapmap = getw(nl[SNSWAPMAP].n_value); swapmap = (struct map *)calloc(nswapmap, sizeof (struct map)); ! kseek(fc, getw(nl[SWAPMAP].n_value), 0); read(fc, swapmap, nswapmap * sizeof (struct map)); nswap = getw(nl[SNSWAP].n_value); free = 0; --- 630,636 ----- read(fc, proc, nproc * sizeof (struct proc)); nswapmap = getw(nl[SNSWAPMAP].n_value); swapmap = (struct map *)calloc(nswapmap, sizeof (struct map)); ! lseek(fc, getw(nl[SWAPMAP].n_value), 0); read(fc, swapmap, nswapmap * sizeof (struct map)); nswap = getw(nl[SNSWAP].n_value); free = 0; *************** *** 643,649 free += me->m_size; ntext = getw(nl[SNTEXT].n_value); xtext = (struct text *)calloc(ntext, sizeof (struct text)); ! kseek(fc, getw(nl[STEXT].n_value), 0); read(fc, xtext, ntext * sizeof (struct text)); tused = 0; for (xp = xtext; xp m_size; ntext = getw(nl[SNTEXT].n_value); xtext = (struct text *)calloc(ntext, sizeof (struct text)); ! lseek(fc, getw(nl[STEXT].n_value), 0); read(fc, xtext, ntext * sizeof (struct text)); tused = 0; for (xp = xtext; xp
This Usenet Oldnews Archive article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.
2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright© 1981, 1996
Bruce Jones, Henry Spencer, David Wiseman.


Goto NEXT article in NET.bugs.4bsd Newsgroup
Return to NET.bugs.4bsd index
Return to the Usenet Oldnews Archive index ----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen of http://communication.ucsd.edu/A-News/ This Usenet Oldnews Archive article may be copied and distributed freely, provided: 1. There is no money collected for the text(s) of the articles. 2. The following notice remains appended to each copy: The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.