debug/5778: File for instruction incorrect when using #include
Mon Feb 25 13:16:00 GMT 2002

>Number:         5778
>Category:       debug
>Synopsis:       File for instruction incorrect when using #include
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 25 10:36:00 PST 2002
>Originator:     Francisco Moraes
>Release:        gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-85)
RedHat 7.0 with GDB 5.1.1
Using included files for function, GCC seems to generate incorrect file information for the addresses coming from the included file. GDB doesn't seem to be at fault as a cross-compiled GCC/GDB (ARM ELF32/DWARF) seems to work fine.

The problem is either at GCC generated debug information or GDB reading the debug information.
Unzip and compile:
gcc -g -o test test.cpp

Debug using GDB, break at main, and step a couple of lines. This is the output from GDB:

GNU gdb 5.1.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) break main
Breakpoint 1 at 0x8048436: file test.cpp, line 3.
(gdb) run
Starting program: /root/test

Breakpoint 1, main (argc=1, argv=0xbffffc94) at test.cpp:3
3       #include "demo.cpp"
(gdb) n
4       }
(gdb) n
Line number 5 out of range; test.cpp has 4 lines.
Correct the line generation table.

More information about the Gcc-bugs mailing list