[net.bugs.usg] Bugs in profiling and C compile on PDP-11

ka (03/08/83)

Profiling doesn't work for programs with text sizes greater than 32K bytes
on the PDP-11.  There are two reasons for this.  First, rather than testing
for lowpc greater than highpc, the monitor routine subtracts the two and
tests the difference.  Since no error message is printed, the test doesn't
do much good anyway, so I just deleted it.  The second problem is a bug
in the code generator for the C compiler.  In the assignment to text, it
compiles the shift operator into a signed shift rather than an unsigned
shift.  I haven't found the bug in the C compiler, but it can be sidestepped
by breaking the assignment up into two statements.  A diff of the two ver-
sions of the monitor routine is given below.
					Kenneth Almquist

$ diff /usr/src/lib/libc/pdp11/gen/mon.c mon.c
54,57c54,55
< 	if(bufsiz <= 0 || lowpc-highpc >= 0)
< 		return;
< 
< 	text = (unsigned)(highpc+1-lowpc)>>1;	/* No. WORD's of text*/
---
> 	text = (unsigned)(highpc+1-lowpc);	/* No. WORD's of text*/
> 	text >>= 1;
$ 

pdl (04/17/83)

This is NOT a bug in cc, it's a bug in the profiling stuff,
the compiler is correct in doing a signed shift, if the shift is to be unsigned,
the code should be:
	(unsigned)(( ... ) >> 1)
and NOT	(unsigned)( ... ) >> 1,

(casts having higher precedence than shifts).

			Per ardua ad perfectum (!?!)
				Dave Lukes
				...!decvax!ukc!root44!pdl