diff options
author | Elena Zannoni <ezannoni@kwikemart.cygnus.com> | 2005-11-04 02:46:45 +0000 |
---|---|---|
committer | Elena Zannoni <ezannoni@kwikemart.cygnus.com> | 2005-11-04 02:46:45 +0000 |
commit | 6a83a1e604d82e43cee0af4cd2957ca290083571 (patch) | |
tree | 29dbd417b82797d56b4738cd456e33ac70e49552 /gdb | |
parent | 62553543860ea1239b565621313768f6736c0fdb (diff) | |
download | gdb-6a83a1e604d82e43cee0af4cd2957ca290083571.zip gdb-6a83a1e604d82e43cee0af4cd2957ca290083571.tar.gz gdb-6a83a1e604d82e43cee0af4cd2957ca290083571.tar.bz2 |
2005-11-03 Jim Blandy <jimb@redhat.com>
Checked in by Elena Zannoni <ezannoni@redhat.com>
* dwarf2read.c (file_full_name): Cope with file numbers that are
out of range for the given line header.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 61 |
2 files changed, 47 insertions, 21 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6677156..12a67ff 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2005-11-03 Jim Blandy <jimb@redhat.com> + + Checked in by Elena Zannoni <ezannoni@redhat.com> + + * dwarf2read.c (file_full_name): Cope with file numbers that are + out of range for the given line header. + 2005-11-03 Daniel Jacobowitz <dan@codesourcery.com> Checked in by Elena Zannoni <ezannoni@redhat.com> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 4b0b6bd..e7a423f 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -8795,32 +8795,51 @@ dwarf_alloc_die (void) static char * file_full_name (int file, struct line_header *lh, const char *comp_dir) { - struct file_entry *fe = &lh->file_names[file - 1]; + /* Is the file number a valid index into the line header's file name + table? Remember that file numbers start with one, not zero. */ + if (1 <= file && file <= lh->num_file_names) + { + struct file_entry *fe = &lh->file_names[file - 1]; - if (IS_ABSOLUTE_PATH (fe->name)) - return xstrdup (fe->name); + if (IS_ABSOLUTE_PATH (fe->name)) + return xstrdup (fe->name); + else + { + const char *dir; + int dir_len; + char *full_name; + + if (fe->dir_index) + dir = lh->include_dirs[fe->dir_index - 1]; + else + dir = comp_dir; + + if (dir) + { + dir_len = strlen (dir); + full_name = xmalloc (dir_len + 1 + strlen (fe->name) + 1); + strcpy (full_name, dir); + full_name[dir_len] = '/'; + strcpy (full_name + dir_len + 1, fe->name); + return full_name; + } + else + return xstrdup (fe->name); + } + } else { - const char *dir; - int dir_len; - char *full_name; + /* The compiler produced a bogus file number. We can at least + record the macro definitions made in the file, even if we + won't be able to find the file by name. */ + char fake_name[80]; + sprintf (fake_name, "<bad macro file number %d>", file); - if (fe->dir_index) - dir = lh->include_dirs[fe->dir_index - 1]; - else - dir = comp_dir; + complaint (&symfile_complaints, + _("bad file number in macro information (%d)"), + file); - if (dir) - { - dir_len = strlen (dir); - full_name = xmalloc (dir_len + 1 + strlen (fe->name) + 1); - strcpy (full_name, dir); - full_name[dir_len] = '/'; - strcpy (full_name + dir_len + 1, fe->name); - return full_name; - } - else - return xstrdup (fe->name); + return xstrdup (fake_name); } } |