This is the mail archive of the gdb-patches@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]

Re: [commit] Handle files without DW_AT_comp_dir


http://sourceware.org/ml/gdb-patches/2007-06/msg00031.html
On Mon, 04 Jun 2007 14:36:15 +0200, Daniel Jacobowitz wrote:
> Joseph Myers discovered a case where GCC emits an absolute path in
> DW_AT_name, no DW_AT_comp_dir, and relative pathnames in the directory
> table.

I see only absolute directory pathnames in .debug_line in such case.
If it really was a GCC bug it should be addressed by DW_AT_producer based
workaround limitation.


> GDB could not handle this, and failed to locate header files
> in the correct paths.
> 
> The GCC behavior is a bug, and I think Joseph's working on a fix for
> it.  But it's been around for a long time, so I think it's worthwhile
> to handle it in GDB.  I tested the patch below on x86_64-linux and
> checked it in.
[...]
>    attr = dwarf2_attr (die, DW_AT_comp_dir, cu);
>    if (attr)
> +    comp_dir = DW_STRING (attr);
> +  else if (name != NULL && IS_ABSOLUTE_PATH (name))
>      {
> +      comp_dir = ldirname (name);

This is affecting the long thread of patch
	[patch] GDB 7.2: new feature for "backtrace" that cuts path to file (remain filename)

DWARF considers the CU's DW_AT_comp_dir attribute optional.

I do not see any problem with it, compilation directory is not known in such
case.  I do not see any testcase in this patch which would show which GCC
versions under which conditions produced such buggy output.  These GCC
versions produce correct output, that is:
	cd /tmp; gcc -o ~/1 ~/1.c -g
	CU's DW_AT_name is absolute /root/1.c
	CU's DW_AT_comp_dir is not present
	.debug_line uses directory entry /root
	.debug_line uses filename entry 1.c
with:
	GNU C 2.96 20000731 (Red Hat Linux 7.2 2.96-116.7.2)  
	gcc (GCC) 3.3.5
	gcc (GCC) 4.4.7
	gcc (GCC) 4.8.0 20120406 (experimental)

Without known GCC buggy versions going to revert this patch as it breaks
correct DWARF.  The thread "that cuts path to file (remain filename)" tries to
(in some way) undo what this patch does.


Thanks,
Jan


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