diff options
author | Ian Lance Taylor <ian@airs.com> | 1999-08-09 04:04:17 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1999-08-09 04:04:17 +0000 |
commit | 798c1fb8d76bc613c6c9b6db10cc8e430763a47c (patch) | |
tree | 0379968be14daa2573a56945be5052476f682d8a | |
parent | 24c411edf7c60f7fe872c26d4017e98766f528fc (diff) | |
download | gdb-798c1fb8d76bc613c6c9b6db10cc8e430763a47c.zip gdb-798c1fb8d76bc613c6c9b6db10cc8e430763a47c.tar.gz gdb-798c1fb8d76bc613c6c9b6db10cc8e430763a47c.tar.bz2 |
1999-08-09 Eli Zaretskii <eliz@is.elta.co.il>
* coffgen.c (coff_find_nearest_line): When looking for file, use
last best match rather than first. If address is beyond last line
number record, don't return the last line as the correct value.
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/coffgen.c | 21 |
2 files changed, 26 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 05a85d5..46e8c26 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +1999-08-09 Eli Zaretskii <eliz@is.elta.co.il> + + * coffgen.c (coff_find_nearest_line): When looking for file, use + last best match rather than first. If address is beyond last line + number record, don't return the last line as the correct value. + 1999-08-08 Ian Lance Taylor <ian@zembu.com> * section.c (SEC_SMALL_DATA): Rename from SEC_SHORT. diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 8495f3d..88ba6a5 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -2200,9 +2200,11 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, } } + /* We use <= MAXDIFF here so that if we get a zero length + file, we actually use the next file entry. */ if (p2 < pend && offset + sec_vma >= (bfd_vma) p2->u.syment.n_value - && offset + sec_vma - (bfd_vma) p2->u.syment.n_value < maxdiff) + && offset + sec_vma - (bfd_vma) p2->u.syment.n_value <= maxdiff) { *filename_ptr = (char *) p->u.syment._n._n_n._n_offset; maxdiff = offset + sec_vma - p2->u.syment.n_value; @@ -2239,6 +2241,8 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, if (section->lineno != NULL) { + bfd_vma last_value = 0; + l = §ion->lineno[i]; for (; i < section->lineno_count; i++) @@ -2250,6 +2254,7 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, if (coff->symbol.value > offset) break; *functionname_ptr = coff->symbol.name; + last_value = coff->symbol.value; if (coff->native) { combined_entry_type *s = coff->native; @@ -2278,6 +2283,20 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, } l++; } + + /* If we fell off the end of the loop, then assume that this + symbol has no line number info. Otherwise, symbols with no + line number info get reported with the line number of the + last line of the last symbol which does have line number + info. We use 0x100 as a slop to account for cases where the + last line has executable code. */ + if (i >= section->lineno_count + && last_value != 0 + && offset - last_value > 0x100) + { + *functionname_ptr = NULL; + *line_ptr = 0; + } } /* Cache the results for the next call. */ |