Unix SVR2 on Vax: bug in cpp causes confused sdb

R. Curtis Jackson rcj at burl.UUCP
Thu May 2 01:26:52 AEST 1985


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



More information about the Net.bugs.usg mailing list