This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug macros/9873] New: DWARF command-line defined macros get ignored


>From Roland McGrath:
-g3 puts both implicit predefines and -D/-U records in the wrong place in
.debug_macinfo.
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.

GCC patch by Jakub Jelinek is provided but current GDB starts to ignore such
macros.  Thus the GDB HEAD acceptance is a prerequisite for the GCC HEAD change.

current GCC:
Contents of the .debug_macinfo section:
 DW_MACINFO_start_file - lineno: 0 filenum: 1
 DW_MACINFO_define - lineno : 0 macro : __STDC__ 1
 DW_MACINFO_define - lineno : 0 macro : __STDC_HOSTED__ 1

patched GCC:
Contents of the .debug_macinfo section:
 DW_MACINFO_define - lineno : 0 macro : __STDC__ 1
 DW_MACINFO_define - lineno : 0 macro : __STDC_HOSTED__ 1

http://dwarf.freestandards.org/Dwarf3.pdf
6.3.3 Macinfo Entries for Command Line Options
[..]
All such DW_MACINFO_define and DW_MACINFO_undef entries representing
compilation options should appear before the first DW_MACINFO_start_file entry
for that compilation unit and should encode the value 0 in their line number
operands.

current GCC + current GDB:
patched GCC + patched GDB:
(gdb) info macro __STDC__
Defined at ../.././gdb/testsuite/gdb.base/macscp1.c:0
#define __STDC__ 1

patched GCC + current GDB:
During symbol reading, debug info gives macro definition outside of any file:
__STDC__ 1.
During symbol reading, debug info gives macro definition outside of any file:
__STDC_HOSTED__ 1.
(gdb) info macro __STDC__
The symbol `__STDC__' has no definition as a C/C++ preprocessor macro
at gdb.base/macscp1.c:102

current GCC + patched GDB:
During symbol reading, debug info gives in-file macro definition with zero line
0: __STDC__ 1.
During symbol reading, debug info gives in-file macro definition with zero line
0: __STDC_HOSTED__ 1.
(gdb) info macro __STDC__
Defined at ../.././gdb/testsuite/gdb.base/macscp1.c:0
#define __STDC__ 1

-- 
           Summary: DWARF command-line defined macros get ignored
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: macros
        AssignedTo: jan dot kratochvil at redhat dot com
        ReportedBy: jan dot kratochvil at redhat dot com
                CC: gdb-prs at sourceware dot org


http://sourceware.org/bugzilla/show_bug.cgi?id=9873

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]