aboutsummaryrefslogtreecommitdiff
path: root/gold/dwarf_reader.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gold/dwarf_reader.cc')
-rw-r--r--gold/dwarf_reader.cc34
1 files changed, 27 insertions, 7 deletions
diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc
index 6049704..4c66a9a 100644
--- a/gold/dwarf_reader.cc
+++ b/gold/dwarf_reader.cc
@@ -2276,7 +2276,7 @@ Sized_dwarf_line_info<size, big_endian>::read_lines(
"logical %u file %d line %d context %u",
lsm.shndx, static_cast<int>(lsm.address),
lsm.line_num, logical.file_num,
- logical.line_num, lsm.context);
+ logical.line_num, logical.context);
entry.offset = static_cast<off_t>(lsm.address);
entry.header_num = this->current_header_index_;
entry.file_num =
@@ -2570,13 +2570,33 @@ Sized_dwarf_line_info<size, big_endian>::do_addr2line(
return "";
std::string result = this->format_file_lineno(*it);
+ gold_debug(DEBUG_LOCATION, "do_addr2line: canonical result: %s",
+ result.c_str());
if (other_lines != NULL)
- for (++it; it != offsets->end() && it->offset == offset; ++it)
- {
- if (it->line_num == -1)
- continue; // The end of a previous function.
- other_lines->push_back(this->format_file_lineno(*it));
- }
+ {
+ unsigned int last_file_num = it->file_num;
+ int last_line_num = it->line_num;
+ // Return up to 4 more locations from the beginning of the function
+ // for fuzzy matching.
+ for (++it; it != offsets->end(); ++it)
+ {
+ if (it->offset == offset && it->line_num == -1)
+ continue; // The end of a previous function.
+ if (it->line_num == -1)
+ break; // The end of the current function.
+ if (it->file_num != last_file_num || it->line_num != last_line_num)
+ {
+ other_lines->push_back(this->format_file_lineno(*it));
+ gold_debug(DEBUG_LOCATION, "do_addr2line: other: %s",
+ other_lines->back().c_str());
+ last_file_num = it->file_num;
+ last_line_num = it->line_num;
+ }
+ if (it->offset > offset && other_lines->size() >= 4)
+ break;
+ }
+ }
+
return result;
}