[net.bugs.2bsd] adb under networking 2.9 kernels

rst@tardis.UUCP (Robert Thau) (02/08/85)

Adb, as distributed by SRI, does not work with networking kernels.  It
is incapable of reading or writing registers, and horrible things happen
when you try to use core files.  Two fixes are needed to get something
that will work out of the compiler.  The first, in pcs.c, is to replace the
line

	POS		corhdr[512];

with

	POS		corhdr[ctob(UPAGES)/sizeof(POS)];

Secondly, in defs.h, replace

	#define UAR0	(&corhdr[509])	/* default address of r0 (u.u_ar0) */

with the following:

	#ifdef	UCB_NET
	#define UAR0	(&corhdr[01775])/* default address of r0 (u.u_ar0) */
	#else
	#define UAR0	(&corhdr[509])	/* default address of r0 (u.u_ar0) */
	#endif
	
Finally, before recompiling, make sure that /usr/include/sys/param.h is
up-to-date (i.e. it defines UCB_NET), since otherwise the above
changes make no difference at all.  (Unfortunately, there's no trivial
six-line change which will give an adb binary that works with both kinds
of kernel).

Robert Thau
rst@tardis.ARPA

ps@uok.UUCP (02/17/85)

This set of modifications seem to make adb work fairly well for me.  I
don't use adb very much except for the occassional debugging session,
and not much at all on kernel dumps anymore.  (I have a version of
crash that is much better and easier to use.)


*** defs.h.1	Sun Nov  4 13:09:59 1984
--- defs.h	Sun Nov  4 13:34:03 1984
***************
*** 109,114
   * If it doesn't correspond to reality, use pstat -u on a core file to get uar0,
   * subtract 0140000, and divide by 2 (sizeof int).
   */
  #define UAR0	(&corhdr[509])	/* default address of r0 (u.u_ar0) */
  
  #define KR0	2	/* location of r0 in kernel dump */

--- 109,116 -----
   * If it doesn't correspond to reality, use pstat -u on a core file to get uar0,
   * subtract 0140000, and divide by 2 (sizeof int).
   */
+ #define UAR0	(&corhdr[ctob(USIZE)/sizeof(POS) - 3])	/* default address of r0 (u.u_ar0) */
+ #ifdef old_and_notused_anymore
  #define UAR0	(&corhdr[509])	/* default address of r0 (u.u_ar0) */
  #endif
  
***************
*** 110,115
   * subtract 0140000, and divide by 2 (sizeof int).
   */
  #define UAR0	(&corhdr[509])	/* default address of r0 (u.u_ar0) */
  
  #define KR0	2	/* location of r0 in kernel dump */
  #define KR1	3

--- 112,118 -----
  #define UAR0	(&corhdr[ctob(USIZE)/sizeof(POS) - 3])	/* default address of r0 (u.u_ar0) */
  #ifdef old_and_notused_anymore
  #define UAR0	(&corhdr[509])	/* default address of r0 (u.u_ar0) */
+ #endif
  
  #define KR0	2	/* location of r0 in kernel dump */
  #define KR1	3

*** pcs.c.1	Sun Nov  4 13:20:13 1984
--- pcs.c	Sun Nov  4 13:18:20 1984
***************
*** 19,25
  
  CHAR		*lp;
  CHAR		lastc;
! POS		corhdr[512];
  POS		*endhdr;
  MAP		txtmap;
  

--- 19,25 -----
  
  CHAR		*lp;
  CHAR		lastc;
! POS		corhdr[ctob(USIZE)/sizeof(POS)];	/* was just 512 */
  POS		*endhdr;
  MAP		txtmap;
  

*** setup.c.1	Sun Nov  4 13:24:52 1984
--- setup.c	Tue Nov  6 10:04:50 1984
***************
*** 36,42
  long tell();
  INT		argcount;
  INT		signo;
! POS		corhdr[512];
  POS		*uar0 = UAR0;
  
  STRING		symfil	"a.out";

--- 36,42 -----
  long tell();
  INT		argcount;
  INT		signo;
! POS		corhdr[ctob(USIZE)/sizeof(POS)];	/* was just 512 */
  POS		*uar0 = UAR0;
  
  STRING		symfil	"a.out";
***************
*** 109,115
  					txtmap.bo = round(txtsiz, TXTRNDSIZ);
  					txtmap.eo = 0;
  					txtmap.fo = 0;
! 					FOR ovly = 0; ovly < 7; ovly++
  					DO	ovloff[ovly] = ovlsiz + txtsiz 
  							+TXTHDRSIZ+OVLHDRSIZ;
  						ovlsiz += ovlseg.ov[ovly];

--- 109,115 -----
  					txtmap.bo = round(txtsiz, TXTRNDSIZ);
  					txtmap.eo = 0;
  					txtmap.fo = 0;
! 					FOR ovly = 0; ovly < NOVL; ovly++
  					DO	ovloff[ovly] = ovlsiz + txtsiz 
  							+TXTHDRSIZ+OVLHDRSIZ;
  						ovlsiz += ovlseg.ov[ovly];
***************
*** 173,179
  			datmap.b2 = maxstor-stksiz;
  			datmap.e2 = maxstor;
  		ELSE	datsiz = round(datsiz+bss,64L);
! 			stksiz = 02000L;
  			datmap.f1 = 0;
  			datmap.b2 = 0140000L;
  			datmap.e2 = 0142000L;

--- 173,179 -----
  			datmap.b2 = maxstor-stksiz;
  			datmap.e2 = maxstor;
  		ELSE	datsiz = round(datsiz+bss,64L);
! 			stksiz = (long)(ctob(USIZE));
  			datmap.f1 = 0;
  			datmap.b2 = 0140000L;
  			datmap.e2 = 0140000L + stksiz;
***************
*** 176,182
  			stksiz = 02000L;
  			datmap.f1 = 0;
  			datmap.b2 = 0140000L;
! 			datmap.e2 = 0142000L;
  		FI
  		switch (magic)
  		{

--- 176,182 -----
  			stksiz = (long)(ctob(USIZE));
  			datmap.f1 = 0;
  			datmap.b2 = 0140000L;
! 			datmap.e2 = 0140000L + stksiz;
  		FI
  		switch (magic)
  		{
***************
*** 239,245
  		    else if (magic) {
  			  register POS *ar0;
  			  ar0 = (POS *)(((U *)corhdr)->u_ar0);
! 			  if ((ar0>(POS *)0140000) & (ar0<(POS *)0142000)
  			      && !(ar0&01))
  				uar0 = ar0 - 0140000 + (unsigned)corhdr;
  			  if (overlay) {

--- 239,245 -----
  		    else if (magic) {
  			  register POS *ar0;
  			  ar0 = (POS *)(((U *)corhdr)->u_ar0);
! 			  if ((ar0>(POS *)0140000) & (ar0<(POS *)(0140000+ctob(USIZE)))
  			      && !(ar0&01))
  				uar0 = ar0 - 0140000 + (unsigned)corhdr;
  			  if (overlay) {