diff options
author | Alan Modra <amodra@gmail.com> | 2006-09-17 02:44:38 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2006-09-17 02:44:38 +0000 |
commit | 7421a730ce531322f49d24f0b0c39e72b668cf45 (patch) | |
tree | 96f766f17e52d7d81f550a67ffd0e1ad3f660783 /bfd/dwarf2.c | |
parent | 882d0cb477153367eab5a0f342794ad9e7827c97 (diff) | |
download | gdb-7421a730ce531322f49d24f0b0c39e72b668cf45.zip gdb-7421a730ce531322f49d24f0b0c39e72b668cf45.tar.gz gdb-7421a730ce531322f49d24f0b0c39e72b668cf45.tar.bz2 |
* dwarf2.c (concat_filename): Apply DW_AT_comp_dir if dir table
entry isn't absolute.
Diffstat (limited to 'bfd/dwarf2.c')
-rw-r--r-- | bfd/dwarf2.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index b057114..059e903 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -874,24 +874,45 @@ concat_filename (struct line_info_table *table, unsigned int file) filename = table->files[file - 1].name; - if (! IS_ABSOLUTE_PATH (filename)) + if (!IS_ABSOLUTE_PATH (filename)) { - char *dirname = (table->files[file - 1].dir - ? table->dirs[table->files[file - 1].dir - 1] - : table->comp_dir); + char *dirname = NULL; + char *subdirname = NULL; + char *name; + size_t len; - /* 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) + if (table->files[file - 1].dir) + subdirname = table->dirs[table->files[file - 1].dir - 1]; + + if (!subdirname || !IS_ABSOLUTE_PATH (subdirname)) + dirname = table->comp_dir; + + if (!dirname) { - unsigned int len = strlen (dirname) + strlen (filename) + 2; - char * name; + dirname = subdirname; + subdirname = NULL; + } + if (!dirname) + return strdup (filename); + + len = strlen (dirname) + strlen (filename) + 2; + + if (subdirname) + { + len += strlen (subdirname) + 1; + name = bfd_malloc (len); + if (name) + sprintf (name, "%s/%s/%s", dirname, subdirname, filename); + } + else + { name = bfd_malloc (len); if (name) sprintf (name, "%s/%s", dirname, filename); - return name; } + + return name; } return strdup (filename); |