[gnu.gdb.bug] gdb and cc disagree about register variables, on the Sequent Symmetry

jw@sics.se (Johan Widen) (03/25/89)

Operating syetem: DYNIX V3.0.12

If I compile the following code with
	cc -g -S

int times3plus6(i)
     int i;
{
  register int j = i+1;
  register int k = i+2;
  register int l = i+3;

  return j+k+l;
}

and then run this under gdb, gdb will find the variables
	i, j, k
but return a bad value for
	l

If we inspect the generated assembler code we find something like:

	.stabd	0104,0,06
	.stabs	"j:r1",0x40,0,4,7
	movl	8(%ebp),%eax
	incl	%eax
	movl	%eax,%edi
	.stabd	0104,0,07
	.stabs	"k:r1",0x40,0,4,6
	movl	8(%ebp),%eax
	leal	2(%eax),%eax
	movl	%eax,%esi
	.stabd	0104,0,010
	.stabs	"l:r1",0x40,0,4,5	<--- This is the problem
	movl	8(%ebp),%eax
	leal	3(%eax),%eax
	movl	%eax,%ebx
	.stabd	0104,0,011
	.stabd	0104,0,012
	.stabd	0300,0,02
	movl	%edi,%eax
	addl	%esi,%eax
	addl	%ebx,%eax

the line I have marked as the trouble spot, says that the variable l
is stored in register
	ebp
At least that is what I and gdb believe. I believe that the correct
line should be
	.stabs  "l:r1",0x40,0,4,3
to indicate that 'l' is stored in
	ebx

Am I off the track here? Is cc actually correct? dbx will apparently
interpret the generated stabs as "l is in ebx".

gcc will generate
	.stabs "l:r1",64,0,0,3
to indicate that "l is in ebx".
--
Johan Widen
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN	Internet: jw@sics.se
Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30