Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Richard Earnshaw <rearnsha@arm.com>
To: binutils@sources.redhat.com
Cc: Richard.Earnshaw@arm.com, irickards@arm.com,
	gdb-patches@sources.redhat.com
Subject: PATCH/RFC handle missing DW_AT_comp_dir attribute
Date: Wed, 17 Jul 2002 04:00:00 -0000	[thread overview]
Message-ID: <200207171047.LAA03162@cam-mail2.cambridge.arm.com> (raw)

[-- 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);
      }
  }
  

             reply	other threads:[~2002-07-17 10:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-17  4:00 Richard Earnshaw [this message]
2002-07-17 10:26 ` Alan Modra
2002-07-17 15:41 ` Jim Blandy
2002-07-18  8:00   ` Richard Earnshaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200207171047.LAA03162@cam-mail2.cambridge.arm.com \
    --to=rearnsha@arm.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=binutils@sources.redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=irickards@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox