Error in debugging info

Kai Schütz ks@axys.de
Mon Dec 20 06:15:00 GMT 1999


I've found a bug in gcc which prevents gdb from stoping at
a breakpoint set at the first case label of a switch statement.

To reproduce the bug do the following:
1. gcc -g bug.c -o bug
2. gdb bug
3. break 6
 (this is the line 'case 0: bar();')
4. run

The debugger runs the program and it exits without ever stopping at the
breakpoint.

The reason for this can be found in the assembler output,
which I obtained by

5. gcc -S -g bug.c

The following lines show the error:

-----------------------------------------------------------
.        pushl %ebp
        movl %esp,%ebp
.stabn 68,0,5,.LM4-foo
.LM4:
        jmp .L4
.stabn 68,0,6,.LM5-foo
.LM5:
        .align 16
.L4:
        call bar
.L5:
.stabn 68,0,7,.LM6-foo
.LM6:
        call bar
.L6:
---------------------------------------------------------

The problem is the .align assembler instruction which expands into some
insns that are never reached: (objdump -D)

---------------------------------------------------------
 8048550:       55                      pushl  %ebp
 8048551:       89 e5                   movl   %esp,%ebp
 8048553:       eb 0b                   jmp    8048560 <foo+0x10>
 8048555:       8d 74 26 00             leal   0x0(%esi,1),%esi
 8048559:       8d bc 27 00 00 00       leal   0x0(%edi,1),%edi
 804855f:       00 
 8048560:       e8 db ff ff ff          call   8048540 <bar>
 8048565:       e8 d6 ff ff ff          call   8048540 <bar>
---------------------------------------------------------

The problem is that because of the wrong debugging info the
breakpoint is set to address 0x8048555 which is never reached => the
programm never stops.

The following output would fix the problem:
-----------------------------------------------------------
.        pushl %ebp
        movl %esp,%ebp
.stabn 68,0,5,.LM4-foo
.LM4:
        jmp .L4
        .align 16
.stabn 68,0,6,.LM5-foo
.LM5:
.L4:
        call bar
.L5:
.stabn 68,0,7,.LM6-foo
.LM6:
        call bar
.L6:
---------------------------------------------------------

BTW, I didn't see this problem on sparc.

These are the versions of the tools I use:

gcc --version
egcs-2.91.66
without any modifications

gdb --version
GNU gdb 4.17.0.11 with Linux support

as --version
GNU assembler 2.9.1

My system is Linux 2.2.5 on i686 (Pentium II) Processor.

I hope I have given all necessary information. If you need
more information feel free to ask me.

Thanks in advance,
-- 
|/
|\ai

--
Kai Schütz                            |        __      AXYS GmbH
Phone: +49 2407 916815	    /\   \ /  |  \ /  (        Kaiserstr. 100
Fax:   +49 2407 96445	   |__|   X   |   Y    \       52134 Herzogenrath
Email: ks@axys.de	   |  |  / \  |  /    __)      Germany
			              |
int x;

void bar(void) {
}

void foo(void) {
	switch (x) {
	case 0: bar();
	case 1: bar();
	case 2: bar();
	}
}

int main()
{
	foo();
	return 0;
}


More information about the Gcc-bugs mailing list