Compile a simple testcase with -gdwarf-2 -fno-eliminate-unused-debug-types -dA -S and notice that there are only 8 files in the file table, but there are DW_AT_decl_file references as high as 52. Testcase: #include using namespace std; int main () { vector V(10); V[10] = 1; } Curiously, there is nothing in binutils or gdb that uses the DW_AT_decl_file info, so there is nothing broken that is visible to end users. However, we will soon have DW_AT_call_file support, and then the failure will be more visible. Meanwhile, you have to look at the .s file (or use readelf). Try this grep "\\.file" tmp.s to see the file table, and grep "# DW_AT_decl_file" tmp.s | more to see the file table references. The problem here is that the maybe_emit_file call in prune_unused_types_walk_attribs is required for correct debug info, but it is only called if we are eliminating unused types. This problem was introduced when the -fno-eliminate-unused-debug-types feature was added 2003-02-28 by Scott Snyder. The solution is to put back the code in lookup_filename to emit .file that was deleted by this patch, conditional on flag_eliminate_unused_debug_info types. Since there is nothing in gcc or gdb that makes use of -fno-eliminate-unused-debug-types and/or DW_AT_decl_file, there is really no useful way to test this other than by hand. Perform the above experiment with this patch, and you get the expected result. The file table matches the file table references; both go up to 52. And further hand checking shows that the right file names are being used with the right declarations. This was also tested with an x86_64 linux C and C++ make bootstrap, make check, and a gdb make check. There were no regressions. 2005-05-03 James E Wilson * dwarf2out.c (lookup_filename): Call maybe_emit_file. Index: dwarf2out.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v retrieving revision 1.590 diff -p -p -r1.590 dwarf2out.c *** dwarf2out.c 1 May 2005 23:37:50 -0000 1.590 --- dwarf2out.c 3 May 2005 01:19:09 -0000 *************** lookup_filename (const char *file_name) *** 13184,13189 **** --- 13184,13197 ---- VARRAY_PUSH_CHAR_PTR (file_table, save_file_name); VARRAY_PUSH_UINT (file_table_emitted, 0); + /* If the assembler is emitting the file table, and we aren't eliminating + unused debug types, then we must emit .file here. If we are eliminating + unused debug types, then this will be done by the maybe_emit_file call in + prune_unused_types_walk_attribs. */ + + if (DWARF2_ASM_LINE_DEBUG_INFO && ! flag_eliminate_unused_debug_types) + maybe_emit_file (i); + return i; }