Skip to content

Commit 0e4eb0f

Browse files
committed
[libunwind] Faster handling of frames with missed FDE records.
1 parent 478e45f commit 0e4eb0f

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

libunwind/src/UnwindCursor.hpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,9 +1787,26 @@ bool UnwindCursor<A, R>::getInfoFromDwarfSection(
17871787
}
17881788
if (!foundFDE) {
17891789
// Still not found, do full scan of __eh_frame section.
1790-
foundFDE = CFI_Parser<A>::findFDE(_addressSpace, pc, sects.dwarf_section,
1791-
sects.dwarf_section_length, 0,
1792-
&fdeInfo, &cieInfo);
1790+
// But only if __eh_frame_hdr is absent or empty.
1791+
// We assume that both sections have the same data, and don't want to waste
1792+
// time for long scan for absent addresses.
1793+
bool hasEHHeaderData = false;
1794+
#if defined(_LIBUNWIND_SUPPORT_DWARF_INDEX)
1795+
if ((sects.dwarf_index_section != 0)) {
1796+
typename EHHeaderParser<A>::EHHeaderInfo hdrInfo;
1797+
const pint_t ehHdrStart = sects.dwarf_index_section;
1798+
const pint_t ehHdrEnd = ehHdrStart + sects.dwarf_index_section_length;
1799+
if (EHHeaderParser<A>::decodeEHHdr(_addressSpace, ehHdrStart, ehHdrEnd,
1800+
hdrInfo)) {
1801+
hasEHHeaderData = (hdrInfo.fde_count != 0);
1802+
}
1803+
}
1804+
#endif
1805+
if (!hasEHHeaderData) {
1806+
foundFDE = CFI_Parser<A>::findFDE(_addressSpace, pc, sects.dwarf_section,
1807+
sects.dwarf_section_length, 0, &fdeInfo,
1808+
&cieInfo);
1809+
}
17931810
}
17941811
if (foundFDE) {
17951812
if (getInfoFromFdeCie(fdeInfo, cieInfo, pc, sects.dso_base)) {

0 commit comments

Comments
 (0)