[PATCH] Add missing DW_AT_comp_dir if necessary

Jakub Jelinek jakub@redhat.com
Sat Feb 1 12:43:00 GMT 2003


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



More information about the Gcc-patches mailing list