public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH/RFC handle missing DW_AT_comp_dir attribute
@ 2002-07-17  4:00 Richard Earnshaw
  2002-07-17  4:01 ` Alan Modra
  2002-07-17 15:58 ` Jim Blandy
  0 siblings, 2 replies; 4+ messages in thread
From: Richard Earnshaw @ 2002-07-17  4:00 UTC (permalink / raw)
  To: binutils; +Cc: Richard.Earnshaw, irickards, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]


This problem was found by a colleague while using GDB with the ADS tools.

These tools do not set the DW_AT_comp_dir attribute in a compilation unit 
entry, so GDB will crash trying to reference a NULL pointer.

Regardless of whether ADS is correct not to generate this directive (the 
Dwarf spec appears not to require it to), GDB should not be falling over 
in this way.  The following patch fixes the problem:

<date>  Ian Rickards  <irickard@arm.com>

	* dwarf2.c (concat_filename): If we can't establish the directory 
	just return the filename.



[-- Attachment #2: bfd-dwf_AT_comp_dir.patch --]
[-- Type: text/x-patch , Size: 1202 bytes --]

Index: dwarf2.c
===================================================================
RCS file: /cvs/src/src/bfd/dwarf2.c,v
retrieving revision 1.32
diff -p -r1.32 dwarf2.c
*** dwarf2.c	27 Jun 2002 11:51:42 -0000	1.32
--- dwarf2.c	17 Jul 2002 10:38:03 -0000
*************** concat_filename (table, file)
*** 856,868 ****
    filename = table->files[file - 1].name;
    if (IS_ABSOLUTE_PATH(filename))
      return filename;
- 
    else
      {
        char* dirname = (table->files[file - 1].dir
  		       ? table->dirs[table->files[file - 1].dir - 1]
  		       : table->comp_dir);
!       return (char*) concat (dirname, "/", filename, NULL);
      }
  }
  
--- 856,873 ----
    filename = table->files[file - 1].name;
    if (IS_ABSOLUTE_PATH(filename))
      return filename;
    else
      {
        char* dirname = (table->files[file - 1].dir
  		       ? table->dirs[table->files[file - 1].dir - 1]
  		       : table->comp_dir);
! 
!       /* Not all tools set DW_AT_comp_dir, so dirname may be unknown.  The
! 	 best we can do is return the filename part.  */
!       if (dirname == NULL)
! 	return filename;
!       else
! 	return (char*) concat (dirname, "/", filename, NULL);
      }
  }
  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH/RFC handle missing DW_AT_comp_dir attribute
  2002-07-17  4:00 PATCH/RFC handle missing DW_AT_comp_dir attribute Richard Earnshaw
@ 2002-07-17  4:01 ` Alan Modra
  2002-07-17 15:58 ` Jim Blandy
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Modra @ 2002-07-17  4:01 UTC (permalink / raw)
  To: Richard.Earnshaw; +Cc: binutils, irickards, gdb-patches

On Wed, Jul 17, 2002 at 11:47:02AM +0100, Richard Earnshaw wrote:
> 	* dwarf2.c (concat_filename): If we can't establish the directory 
> 	just return the filename.

OK.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH/RFC handle missing DW_AT_comp_dir attribute
  2002-07-17  4:00 PATCH/RFC handle missing DW_AT_comp_dir attribute Richard Earnshaw
  2002-07-17  4:01 ` Alan Modra
@ 2002-07-17 15:58 ` Jim Blandy
  2002-07-18  6:23   ` Richard Earnshaw
  1 sibling, 1 reply; 4+ messages in thread
From: Jim Blandy @ 2002-07-17 15:58 UTC (permalink / raw)
  To: Richard.Earnshaw; +Cc: binutils, irickards, gdb-patches


Richard Earnshaw <rearnsha@arm.com> writes:
> This problem was found by a colleague while using GDB with the ADS tools.
> 
> These tools do not set the DW_AT_comp_dir attribute in a compilation unit 
> entry, so GDB will crash trying to reference a NULL pointer.
> 
> Regardless of whether ADS is correct not to generate this directive (the 
> Dwarf spec appears not to require it to), GDB should not be falling over 
> in this way.  The following patch fixes the problem:
> 
> <date>  Ian Rickards  <irickard@arm.com>
> 
> 	* dwarf2.c (concat_filename): If we can't establish the directory 
> 	just return the filename.

Sorry --- how does this patch fix a GDB crash?  GDB doesn't use BFD to
read debugging information.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH/RFC handle missing DW_AT_comp_dir attribute
  2002-07-17 15:58 ` Jim Blandy
@ 2002-07-18  6:23   ` Richard Earnshaw
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Earnshaw @ 2002-07-18  6:23 UTC (permalink / raw)
  To: Jim Blandy; +Cc: Richard.Earnshaw, binutils, irickards, gdb-patches

> 
> Richard Earnshaw <rearnsha@arm.com> writes:
> > This problem was found by a colleague while using GDB with the ADS tools.
> > 
> > These tools do not set the DW_AT_comp_dir attribute in a compilation unit 
> > entry, so GDB will crash trying to reference a NULL pointer.

> 
> Sorry --- how does this patch fix a GDB crash?  GDB doesn't use BFD to
> read debugging information.

Ah, sorry, it was my understanding from Ian that it was in GDB.  
Apparently the problem was seen in addr2line, and rather than a crash we 
just got an empty filename (since the first argument passed to concat was 
a NULL pointer).

R.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-07-18 12:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-17  4:00 PATCH/RFC handle missing DW_AT_comp_dir attribute Richard Earnshaw
2002-07-17  4:01 ` Alan Modra
2002-07-17 15:58 ` Jim Blandy
2002-07-18  6:23   ` Richard Earnshaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).