-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libunwind] Faster handling of frames with missed FDE records. #167849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@llvm/pr-subscribers-libunwind Author: Vyacheslav Chigrin (vchigrin) ChangesSome stack may have frames with missing FDE records, for example, when they implemented in assembly and author did not provide frame information manually. Full diff: https://github.com/llvm/llvm-project/pull/167849.diff 1 Files Affected:
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index d7348254af07b..42c3cf9084219 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -1787,9 +1787,26 @@ bool UnwindCursor<A, R>::getInfoFromDwarfSection(
}
if (!foundFDE) {
// Still not found, do full scan of __eh_frame section.
- foundFDE = CFI_Parser<A>::findFDE(_addressSpace, pc, sects.dwarf_section,
- sects.dwarf_section_length, 0,
- &fdeInfo, &cieInfo);
+ // But only if __eh_frame_hdr is absent or empty.
+ // We assume that both sections have the same data, and don't want to waste
+ // time for long scan for absent addresses.
+ bool hasEHHeaderData = false;
+#if defined(_LIBUNWIND_SUPPORT_DWARF_INDEX)
+ if ((sects.dwarf_index_section != 0)) {
+ typename EHHeaderParser<A>::EHHeaderInfo hdrInfo;
+ const pint_t ehHdrStart = sects.dwarf_index_section;
+ const pint_t ehHdrEnd = ehHdrStart + sects.dwarf_index_section_length;
+ if (EHHeaderParser<A>::decodeEHHdr(_addressSpace, ehHdrStart, ehHdrEnd,
+ hdrInfo)) {
+ hasEHHeaderData = (hdrInfo.fde_count != 0);
+ }
+ }
+#endif
+ if (!hasEHHeaderData) {
+ foundFDE = CFI_Parser<A>::findFDE(_addressSpace, pc, sects.dwarf_section,
+ sects.dwarf_section_length, 0, &fdeInfo,
+ &cieInfo);
+ }
}
if (foundFDE) {
if (getInfoFromFdeCie(fdeInfo, cieInfo, pc, sects.dso_base)) {
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
|
As far as I can understand, GCC unwinding approach is similar. Check code here |
2198f26 to
7057f37
Compare
|
@kovdan01 , @atrosinenko - saw you in reviewers of one recent PR-s, touching this file. Could you either review, or redirect to appropriate reviewers for this change? Thank you in advance! |
|
On my testing program it changed timings of construction of |
@ldionne Could you please take a look at the changes and/or assign appropriate reviewers? Thanks! |
Some stack may have frames with missing FDE records, for example, when they implemented in assembly and author did not provide frame information manually.
In that case any attempt to unwind such stack will result in potentially long linear .eh_frame section scan.
This patch adds assumption that if .eh_frame_hdr section is present and not empty, then any frame must be present in it and we can skip long linear scan of .eh_frame section.