Subject: adb single step bug, login disconnect, cc missing __TIME__/__DATE__, cpp bug, longjmp number of args wrong Index: src/ bin/adb/runpcs.c, bin/login/login.c, bin/cc.c, games/backgammon/move_robs.c, lib/cpp/token.c, ucb/msgs/msgs.c, ucb/more/more.c Description: 1) when single stepping a process adb can step one instruction too many. 2) simulated DZ11 lines will see DTR dropped by login after the username has been entered. 3) The ANSI C macros __TIME__ and __DATE__ are absent. 4) If cpp is invoked with the -C option (cpp is to not strip comments) cpp can exit with the error "file:10: error: bad terminal (42)" 5) Several programs use longjmp with only one argument instead of two arguments. Repeat-By: 1) -- # adb a.out adb> _main+4:b adb> :r a.out: running breakpoint ~main+04: br ~main+0252 So far so good. adb> :s a.out: running stopped at ~main+0256: br ~main+06 The expectation was this would stop at ~main+0252, not at ~main+0256 adb> :s a.out: running breakpoint ~main+04: br ~main+0252 Ooops This was supposed to go to ~main+06 adb> :s a.out: running stopped at ~main+0256: br ~main+06 And around and around we go. The issue is that we have: ~main: jsr r5,csv ~main+04: br ~main+0252 ~main+06: clr 0177762(r5) When the br ~main+06 gets executed at main+0256 the adb code checks to see if there is a breakpoint at PC-2, which there is and it thinks that the reason PC = main+06 is that we fell through a breakpoint instruction at main+4, instead of getting there via the br main+06. The patch fixes that by checking whether we're single stepping and if we are, look at PC, not PC-2. 2) have a simh environment with a DZ, and make sure the DZ is attached with "-am". Then try to log in using telnet to the DZ port. Which should then disconnect after the username prompt and before the password prompt. The problem was that login mistakenly set the speed to 0 and that tells the DZ driver to hangup the line. 3) Observation. When ANSI C capabilities were added to the system a couple years ago these two macros were overlooked. 4) Have a macro containing a comment and use that value in a #if 'lint' uses "cpp -C" and the file sys/pdp/machparam.h was failing to process. -----x----- #define ENDIAN PDP /* byte order on pdp */ #if ENDIAN == PDP && !defined(lint) #define FOO "foo" #endif ------ cpp -C x # 1 "x" x:3: error: bad terminal (42) 5) Observation OR run "lint" on the sources to robots(6), msgs(1) and more(1). Use is longjmp(env, retval) not simply longjmp(env) Also fixed is an error in the backgammon ex script used with the messages file. Fix: Thanks to bqt@softjar.se for (2) and (5), ragge@tethuvudet.se for (3) and (4), martin@teckelworks.com for the excellent Repeat-By writeup and the patch for (1) Cut where indicated and save to a file (/tmp/488.patch). Then: cd / patch -p0 < /tmp/488.patch cd /usr/src/bin/adb make install make clean On my system I spotted this: -rw-r----- 1 root 8311 Apr 19 1998 runpcs.s This is a generated assembly code file from 1998 and if present should be removed. The things one finds in the system 27 years later ;) rm -f runpcs.s cd ../login make install make clean cd .. make cc install -m 751 -g staff cc /bin cd /usr/src/games/backgammon make install make clean cd ../robots make install make clean cd /usr/src/lib/cpp make install make clean cd /usr/src/ucb/msgs make install make clean cd ../more make install make clean This and previous updates to 2.11BSD are available at the following locations: ftp://ftp.dfupdate.se/pub/pdp11/2.11BSD https://www.tuhs.org/Archive/Distributions/UCB/2.11BSD/Patches/ ftp://ftp.2bsd.com/2.11BSD http://www.2bsd.com/2.11BSD ---------------------------cut here-------------------- *** ./usr/src/bin/adb/runpcs.c.old Sun Jul 25 23:10:40 1999 --- ./usr/src/bin/adb/runpcs.c Mon Mar 24 16:16:23 2025 *************** *** 52,63 **** #ifdef DEBUG printf("\ncontinue %d %d\n",userpc,execsig); #endif ! stty(0,&usrtty); ! ptrace(runmode,pid,userpc,execsig); ! bpwait(); chkerr(); readregs(); ! /*look for bkpt*/ ! IF signo==0 ANDF (bkpt=scanbkpt(uar0[PC]-2)) THEN /*stopped at bkpt*/ userpc=uar0[PC]=bkpt->loc; IF bkpt->flag==BKPTEXEC --- 52,80 ---- #ifdef DEBUG printf("\ncontinue %d %d\n",userpc,execsig); #endif ! /* If we're at a breakpoint, execute that using execbkpt */ ! if (bkpt=scanbkpt(userpc == 1 ? uar0[PC] : userpc)) { ! execbkpt(bkpt); ! userpc = 1; ! } ! /* ! ** If we're single stepping and already executed the ! ** instruction at the breakpoint, don't do another one ! */ ! if (signo == 0 && (!bkpt || runmode != PT_STEP)) { ! stty(0,&usrtty); ! ptrace(runmode,pid,userpc,execsig); ! bpwait(); chkerr(); ! } ! readregs(); ! /* ! ** look for bkpt ! ** in step mode we would have actually hit the breakpoint, ! ** not stepped through it, so look at PC instead of PC-2 ! */ ! IF signo==0 ANDF ! (bkpt=scanbkpt(uar0[PC]- (runmode == PT_STEP ? 0:2))) THEN /*stopped at bkpt*/ userpc=uar0[PC]=bkpt->loc; IF bkpt->flag==BKPTEXEC *** ./usr/src/bin/login/login.c.old Sat Mar 22 06:12:52 2025 --- ./usr/src/bin/login/login.c Tue Mar 25 21:58:55 2025 *************** *** 20,26 **** "@(#) Copyright (c) 1980, 1987, 1988 The Regents of the University of California.\n\ All rights reserved.\n"; ! static char sccsid[] = "@(#)login.c 5.42 (2.11BSD) 2025/3/21"; #endif /* --- 20,26 ---- "@(#) Copyright (c) 1980, 1987, 1988 The Regents of the University of California.\n\ All rights reserved.\n"; ! static char sccsid[] = "@(#)login.c 5.43 (2.11BSD) 2025/3/26"; #endif /* *************** *** 84,92 **** --- 84,94 ---- struct sgttyb tmode = { 0, 0, CERASE, CKILL, 0 }; + struct tchars tc = { CINTR, CQUIT, CSTART, CSTOP, CEOT, CBRK }; + struct ltchars ltc = { CSUSP, CDSUSP, CRPRNT, CFLUSH, CWERASE, CLNEXT }; *************** *** 125,131 **** /* * -p is used by getty to tell login not to destroy the environment ! * -f is used to skip a second login authentication * -h is used by other servers to pass the name of the remote * host to login so that it may be placed in utmp and wtmp */ --- 127,133 ---- /* * -p is used by getty to tell login not to destroy the environment ! * -f is used to skip a second login authentication * -h is used by other servers to pass the name of the remote * host to login so that it may be placed in utmp and wtmp */ *************** *** 184,198 **** sgttyb.sg_kill = CKILL; allflags = setflags(2); ! tmode.sg_flags = allflags & 0xffff; ! if (NL) tmode.sg_flags |= CRMOD; ! ioctl(0, TIOCSETP, &tmode); someflags = allflags >> 16; - ioctl(0, TIOCLSET, &someflags); (void)ioctl(0, TIOCSLTC, <c); (void)ioctl(0, TIOCSETC, &tc); (void)ioctl(0, TIOCSETP, &sgttyb); for (cnt = getdtablesize(); cnt > 2; cnt--) close(cnt); --- 186,199 ---- sgttyb.sg_kill = CKILL; allflags = setflags(2); ! sgttyb.sg_flags = allflags & 0xffff; ! if (NL) sgttyb.sg_flags |= CRMOD; someflags = allflags >> 16; (void)ioctl(0, TIOCSLTC, <c); (void)ioctl(0, TIOCSETC, &tc); (void)ioctl(0, TIOCSETP, &sgttyb); + (void)ioctl(0, TIOCLSET, &someflags); for (cnt = getdtablesize(); cnt > 2; cnt--) close(cnt); *** ./usr/src/bin/cc.c.old Tue Jan 7 13:27:47 2020 --- ./usr/src/bin/cc.c Tue Mar 25 17:29:05 2025 *************** *** 10,15 **** --- 10,16 ---- #include #include #include + #include char *cpp = "/lib/cpp"; char *ccom = "/lib/c0"; *************** *** 19,24 **** --- 20,28 ---- char *ld = "/bin/ld"; char *crt0 = "/lib/crt0.o"; + char datebuf[26] = "-D__DATE__=\""; + char timebuf[26] = "-D__TIME__=\""; + char tmp0[30]; /* big enough for /tmp/ctm%05.5d */ char *tmp1, *tmp2, *tmp3, *tmp4, *tmp5; char *outfile; *************** *** 38,44 **** main(argc, argv) char **argv; { ! char *t; char *assource; int i, j, c; --- 42,49 ---- main(argc, argv) char **argv; { ! time_t tid; ! char *t, *ctbuf; char *assource; int i, j, c; *************** *** 46,52 **** av = (char **)calloc(argc+10, sizeof (char **)); clist = (char **)calloc(argc, sizeof (char **)); llist = (char **)calloc(argc, sizeof (char **)); ! plist = (char **)calloc(argc, sizeof (char **)); for (i = 1; i < argc; i++) { if (*argv[i] == '-') switch (argv[i][1]) { --- 51,57 ---- av = (char **)calloc(argc+10, sizeof (char **)); clist = (char **)calloc(argc, sizeof (char **)); llist = (char **)calloc(argc, sizeof (char **)); ! plist = (char **)calloc(argc+2, sizeof (char **)); for (i = 1; i < argc; i++) { if (*argv[i] == '-') switch (argv[i][1]) { *************** *** 175,180 **** --- 180,197 ---- tmp4 = strspl(tmp0, "4"); if (oflag) tmp5 = strspl(tmp0, "5"); + + /* Create __TIME__ and __DATE__ as required by ISO C */ + tid = time(NULL); + ctbuf = ctime(&tid); + strncat(timebuf, &ctbuf[11], 8); + strcat(timebuf, "\""); + strncat(datebuf, &ctbuf[4], 7); + strncat(datebuf, &ctbuf[20], 4); + strcat(datebuf, "\""); + plist[np++] = timebuf; + plist[np++] = datebuf; + for (i=0; i 1 && !Mflag) { printf("%s:\n", clist[i]); *** ./usr/src/games/backgammon/Mesgfix.old Sat Jan 11 13:46:43 1986 --- ./usr/src/games/backgammon/Mesgfix Tue Mar 25 17:44:01 2025 *************** *** 5,13 **** * specifies the terms and conditions for redistribution. */ . - /Msccsid/c - static char Msccsid[] = "@(#)Mesgfix 5.2 (Berkeley) 1/8/86"; - . /Last update/!date mark a g/Sun /s//Sunday, / --- 5,10 ---- *** ./usr/src/games/robots/move_robs.c.old Thu May 30 20:35:14 1985 --- ./usr/src/games/robots/move_robs.c Tue Mar 25 17:35:16 2025 *************** *** 81,87 **** if (was_sig) { refresh(); if (Dead || Num_robots <= 0) ! longjmp(End_move); } # ifdef DEBUG --- 81,87 ---- if (was_sig) { refresh(); if (Dead || Num_robots <= 0) ! longjmp(End_move,0); } # ifdef DEBUG *** ./usr/src/lib/cpp/token.c.old Tue Jan 7 13:49:34 2020 --- ./usr/src/lib/cpp/token.c Tue Mar 25 17:25:10 2025 *************** *** 753,759 **** struct symtab *nl; int oCflag = Cflag; usch *dp; ! register int c, d, ifdef; rb = getobuf(BNORMAL); nbufused--; --- 753,759 ---- struct symtab *nl; int oCflag = Cflag; usch *dp; ! register int c, d, ifdef, i, clrb; rb = getobuf(BNORMAL); nbufused--; *************** *** 806,811 **** --- 806,823 ---- rb->buf[rb->cptr] = 0; unch('\n'); yyinp = rb->buf; + if (oCflag) + for (i = clrb = 0; i < rb->cptr; i++) { + if (rb->buf[i] == '/' && rb->buf[i+1] == '*') + clrb = 1; + if (rb->buf[i] == '*' && rb->buf[i+1] == '/') { + rb->buf[i] = ' '; + rb->buf[i+1] = ' '; + clrb = 0; + } + if (clrb) + rb->buf[i] = ' '; + } c = yyparse(); bufree(rb); nbufused++; *** ./usr/src/ucb/msgs/msgs.c.old Fri Mar 20 20:01:51 1987 --- ./usr/src/ucb/msgs/msgs.c Tue Mar 25 17:35:17 2025 *************** *** 642,648 **** kill(0, SIGTSTP); signal(SIGTSTP, onsusp); if (!mailing) ! longjmp(tstpbuf); } linecnt(f) --- 642,648 ---- kill(0, SIGTSTP); signal(SIGTSTP, onsusp); if (!mailing) ! longjmp(tstpbuf,0); } linecnt(f) *** ./usr/src/ucb/more/more.c.old Sun Sep 25 21:21:53 2022 --- ./usr/src/ucb/more/more.c Tue Mar 25 17:35:17 2025 *************** *** 1784,1788 **** signal (SIGTSTP, onsusp); set_tty (); if (inwait) ! longjmp (restore); } --- 1784,1788 ---- signal (SIGTSTP, onsusp); set_tty (); if (inwait) ! longjmp (restore,0); } *** ./VERSION.old Fri Mar 21 18:31:30 2025 --- VERSION Wed Mar 26 07:56:23 2025 *************** *** 1,5 **** ! Current Patch Level: 487 ! Date: March 22, 2025 2.11 BSD ============ --- 1,5 ---- ! Current Patch Level: 488 ! Date: March 26, 2025 2.11 BSD ============