This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Add missing DW_AT_comp_dir if necessary
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>, Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 1 Feb 2003 13:43:13 +0100
- Subject: [PATCH] Add missing DW_AT_comp_dir if necessary
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
For input like:
# 1 "/tmp/f.c"
# 1 "../tmp/f.h" 1
int i;
# 2 "/tmp/f.c" 2
int j;
gcc doesn't create DW_AT_comp_dir attribute of the compilation unit,
yet its .debug_line section contains relative pathnames. This means
the debugger (of course unless you're debugging in the exact directory
which was the working directory of the compiler which compiled it)
has no way to locate the source files.
Ok to commit?
2003-02-01 Jakub Jelinek <jakub@redhat.com>
* dwarf2out.c (dwarf2out_finish): Add AT_comp_dir
attribute even if input file name is absolute, but one of the
includes is relative.
--- gcc/dwarf2out.c.jj 2003-01-28 16:25:28.000000000 -0500
+++ gcc/dwarf2out.c 2003-02-01 07:18:17.000000000 -0500
@@ -12660,6 +12660,16 @@ dwarf2out_finish (input_filename)
add_name_attribute (comp_unit_die, input_filename);
if (input_filename[0] != DIR_SEPARATOR)
add_comp_dir_attribute (comp_unit_die);
+ else if (get_AT (comp_unit_die, DW_AT_comp_dir) == NULL)
+ {
+ size_t i;
+ for (i = 1; i < VARRAY_ACTIVE_SIZE (file_table); i++)
+ if (VARRAY_CHAR_PTR (file_table, i)[0] != DIR_SEPARATOR)
+ {
+ add_comp_dir_attribute (comp_unit_die);
+ break;
+ }
+ }
/* Traverse the limbo die list, and add parent/child links. The only
dies without parents that should be here are concrete instances of
Jakub