Description of problem: -g3 puts both implicit predefines and -D/-U records in the wrong place in .debug_macinfo. Version-Release number of selected component (if applicable): gcc-4.3.2-7.x86_64 How reproducible: 100% Steps to Reproduce: 1. echo '#define foo bar' > g3.c; echo 'foo(){}' >> g3.c 2. gcc -c -g3 g3.c -DFOO=1 -UFOO 3. readelf --debug-dump=macro g3.o Actual results: The implicit predefines appear after the start_file record for "g3.c", with fake line numbers, then the -D/-U records also with fake line numbers. Expected results: DWARF spec says predefines come before the first start_file record, and all use line number 0. Additional info: It's fine to fix this only in 4.4, I think.
Created attachment 331560 [details] gcc44-rh479914.patch Patch to fix that. Unfortunately, gdb doesn't handle that, at least not gdb-6.8-29.fc10.x86_64. So I'm not sure it is a good idea to change it for Fedora11/RHEL6, and changing it upstream will be even more problematic. Before the patch I get: b main r info macro __GNUC__ Defined at /usr/src/gcc/obj/gcc/u.c:0 #define __GNUC__ 4 p __GNUC__ 4 While after the patch: b main r info macro __GNUC__ The symbol `__GNUC__' has no definition as a C/C++ preprocessor macro at /usr/src/gcc/obj/gcc/u.c:7 p __GNUC__ No symbol "__GNUC__" in current context.
It certainly ought to be safe to fix the bogus line numbers to all use 0 instead. That would at least be unambiguous vs real in-source #define's. Clearly gdb ought to be fixed to cope with data that is correct by the spec, regardless. I tend to think that -g3 is used so little today that noone would really mind the predefines encoding changing, since it's not like it makes gdb go wrong or anything--it just can't show you __GNUC__ and __linux__ and so forth.
I find the line numbers depending on the compilation method. In fact it behaves exactly the same on all these three gcc versions: gcc-4.3.2-7.x86_64 gcc-4.4.0-0.17.x86_64 gcc-4.4-20090211 (SVN, unpatched) gcc -DFROM_COMMANDLINE -g3 -o g3testold g3.c readelf -Wwm g3testold DW_MACINFO_define - lineno : 0 macro : __STDC__ 1 DW_MACINFO_define - lineno : 0 macro : __STDC_HOSTED__ 1 gcc -DFROM_COMMANDLINE -g3 -S -o g3testold.s g3.c gcc -c -o g3testold.o g3testold.s readelf -Wwm g3testold.o DW_MACINFO_define - lineno : 0 macro : __STDC__ 1 DW_MACINFO_define - lineno : 0 macro : __STDC_HOSTED__ 1 gcc -DFROM_COMMANDLINE -g3 -c -o g3testold.o g3.c readelf -Wwm g3testold.o DW_MACINFO_define - lineno : 1 macro : __STDC__ 1 DW_MACINFO_define - lineno : 2 macro : __STDC_HOSTED__ 1 This my comment is unrelated to where/if exists DW_MACINFO_start_file.
Sorry for my Comment 3 - it is not for gcc - it is caused by ccache. Unfortunately ccache is automatically installed even on a new reserved RHTS box. (And with the verification of SVN gcc-4.4 I had to overlook it during the test.)
The GDB compatibility part is checked-in for FSF GDB HEAD: http://sourceware.org/ml/gdb-cvs/2009-03/msg00041.html ccache problem has been filed as Fedora Bug 488863.
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle. Changing version to '11'. More information and reason for this action is here: http://fedoraproject.org/wiki/BugZappers/HouseKeeping
This message is a reminder that Fedora 11 is nearing its end of life. Approximately 30 (thirty) days from now Fedora will stop maintaining and issuing updates for Fedora 11. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as WONTFIX if it remains open with a Fedora 'version' of '11'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version prior to Fedora 11's end of life. Bug Reporter: Thank you for reporting this issue and we are sorry that we may not be able to fix it before Fedora 11 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora please change the 'version' of this bug to the applicable version. If you are unable to change the version, please add a comment here and someone will do it for you. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete. The process we are following is described here: http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Does vanilla GDB 7.0 now handle GCC output with patch #c1 ? If yes, I guess we should change GCC 4.6 and 4.4-RH, GCC 4.5+ and 4.4-RH requires GDB 7.0 for proper debugging anyway.
Unfortunately, it seems even 7.0.1-44.fc12 doesn't handle this when the #c1 patch is applied: /* { dg-options "-g3 -dA -DFOO" } */ #define BAR 1 int i = FOO + BAR; int main (void) { return 0; } print BAR in the debugger works, but print FOO does not. Without the #c1 patch both work.
Perhaps we should file a gdb bug for that if there isn't one already. Maybe Jan knows the gdb situation.
I tried both the original test, and the test from #c9, with CVS head gdb. I used gcc 4.5 with the patch from #c1. It all worked fine. I also tried GDB 7.1, and that also worked. I think the GCC patch ought to go upstream.
(In reply to comment #9) > Unfortunately, it seems even 7.0.1-44.fc12 doesn't handle this when the #c1 > patch is applied: archer-jankratochvil-fedora12 commit b12d3a87fc83e2d2a9c2416400de2016fb0248be undoes the patch, it seems to be by a mistake. Only F-12 cannot parse it. FSF GDB 7.0 upwards contains the fix. archer-jankratochvil-fedora13 is a new branch and F-13 + RHEL-6 GDBs incl. for example gdb-7.1-16.fc13 contain the fix.
This message is a reminder that Fedora 13 is nearing its end of life. Approximately 30 (thirty) days from now Fedora will stop maintaining and issuing updates for Fedora 13. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as WONTFIX if it remains open with a Fedora 'version' of '13'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version prior to Fedora 13's end of life. Bug Reporter: Thank you for reporting this issue and we are sorry that we may not be able to fix it before Fedora 13 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora please change the 'version' of this bug to the applicable version. If you are unable to change the version, please add a comment here and someone will do it for you. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete. The process we are following is described here: http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Fedora 13 changed to end-of-life (EOL) status on 2011-06-25. Fedora 13 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. Thank you for reporting this bug and we are sorry it could not be fixed.