Still a problem with debug output, with functions with #line in the middle, on mainline

Zack Weinberg zack@codesourcery.com
Wed Jan 30 13:14:00 GMT 2002


We still get debug information for functions with #line in the middle
partially wrong.  With the same test case I just posted for 3.0.3:

$ cat test.c
int main(void) {
  int i = 0;
#line __LINE__ "foo.c"
  i++;
#line __LINE__ "bar.c"
  return i;
}

this location information is generated:

main:
.LFB1:
	.file 2 "bar.c"			*****
	.loc 2 1 0
	pushl	%ebp
.LCFI0:
	movl	%esp, %ebp
.LCFI1:
	subl	$8, %esp
.LCFI2:
	andl	$-16, %esp
	movl	$0, %eax
	subl	%eax, %esp
.LBB2:
	.loc 1 2 0
	movl	$0, -4(%ebp)
	.file 3 "foo.c"
	.loc 3 3 0
	leal	-4(%ebp), %eax
	incl	(%eax)
	.loc 2 4 0
	movl	-4(%ebp), %eax
.LBE2:
	.loc 2 5 0
	leave
	ret
.LFE1:
.Lfe1:

That first .file directive should refer to test.c not bar.c.  There is
a similar problem with stabs, although it's not quite as wrong:

main:
	.stabs	"bar.c",132,0,0,.Ltext1
.Ltext1:
	.stabn 68,0,1,.LM1-main
.LM1:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
	andl	$-16, %esp
	movl	$0, %eax
	subl	%eax, %esp
.LBB2:
	.stabs	"test.c",132,0,0,.Ltext2
.Ltext2:
	.stabn 68,0,2,.LM2-main
.LM2:
	movl	$0, -4(%ebp)
	.stabs	"foo.c",132,0,0,.Ltext3
.Ltext3:
	.stabn 68,0,3,.LM3-main
.LM3:
	leal	-4(%ebp), %eax
	incl	(%eax)
	.stabs	"bar.c",132,0,0,.Ltext4
.Ltext4:
	.stabn 68,0,4,.LM4-main
.LM4:
	movl	-4(%ebp), %eax
.LBE2:
	.stabn 68,0,5,.LM5-main
.LM5:
	leave
	ret
.Lfe1:

[The extended .file directive and the .loc directive are not
documented in my copy of the GAS manual, so I'm not 100% sure what the
constraints are.]

zw



More information about the Gcc-bugs mailing list