Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site burl.UUCP Path: utzoo!watmath!clyde!burl!rcj From: rcj@burl.UUCP (R. Curtis Jackson) Newsgroups: net.lang.c,net.bugs.usg,net.unix-wizards Subject: Unix SVR2 on Vax: bug in cpp causes confused sdb Message-ID: <676@burl.UUCP> Date: Wed, 1-May-85 11:26:52 EDT Article-I.D.: burl.676 Posted: Wed May 1 11:26:52 1985 Date-Received: Thu, 2-May-85 01:35:30 EDT Distribution: net Organization: AT&T Technologies, Burlington NC Lines: 36 Xref: watmath net.lang.c:5137 net.bugs.usg:223 net.unix-wizards:13010 I was debugging a program with sdb and was totally bewildered until I noticed that, on a breakpoint before C instruction N, sdb was actually executing instruction N and breakpointing before N-1 even though it told me it was breakpointing before instruction N. This can really warp your mind when debugging tight code. I called the Unix Hotline and received a VERY fast and accurate reply (my thanks to Alan Berkman at the Hotline). Here it is: cpp(1) has a bug in it which causes it to output bogus line numbers and therefore confuses sdb about what is where in the source. If you define a multiline macro like this: # define KILLIT\ {\ register int c;\ \ while(((c=input()) != NL) && (c != 0))\ {\ /* do nothing!! */\ }\ unput(NL);\ } all hell breaks loose (i.e., the bug appears). If you put a space after KILLIT and before the backslash in the first line, however: # define KILLIT \ then things work fine. Please no flames on my coding style, I'll ignore them anyway, -- The MAD Programmer -- 919-228-3313 (Cornet 291) alias: Curtis Jackson ...![ ihnp4 ulysses cbosgd mgnetp ]!burl!rcj ...![ ihnp4 cbosgd akgua masscomp ]!clyde!rcj