Bug 479914 - -g3 vs predefines
-g3 vs predefines
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
13
All Linux
low Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 516995
  Show dependency treegraph
 
Reported: 2009-01-13 19:04 EST by Roland McGrath
Modified: 2011-06-27 10:05 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-06-27 10:05:26 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
gcc44-rh479914.patch (1.57 KB, patch)
2009-02-11 08:09 EST, Jakub Jelinek
no flags Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
Sourceware 9873 None None None Never

  None (edit)
Description Roland McGrath 2009-01-13 19:04:51 EST
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.
Comment 1 Jakub Jelinek 2009-02-11 08:09:00 EST
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.
Comment 2 Roland McGrath 2009-02-11 14:06:08 EST
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.
Comment 3 Jan Kratochvil 2009-02-12 18:11:25 EST
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.
Comment 4 Jan Kratochvil 2009-02-17 05:53:45 EST
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.)
Comment 5 Jan Kratochvil 2009-03-09 14:59:42 EDT
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.
Comment 6 Bug Zapper 2009-06-09 06:42:35 EDT
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
Comment 7 Bug Zapper 2010-04-27 08:44:06 EDT
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
Comment 8 Jakub Jelinek 2010-04-27 08:58:18 EDT
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.
Comment 9 Jakub Jelinek 2010-04-27 10:00:40 EDT
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.
Comment 10 Roland McGrath 2010-04-27 14:46:05 EDT
Perhaps we should file a gdb bug for that if there isn't one already.
Maybe Jan knows the gdb situation.
Comment 11 Tom Tromey 2010-04-27 15:23:36 EDT
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.
Comment 12 Jan Kratochvil 2010-04-27 16:17:12 EDT
(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.
Comment 13 Bug Zapper 2011-06-02 14:18:02 EDT
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
Comment 14 Bug Zapper 2011-06-27 10:05:26 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.