[PATCH] D147637: [libunwind] [SEH] Sync LSDA and handler between unw_proc_info_t and DISPATCHER_CONTEXT
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 5 10:00:33 PDT 2023
mstorsjo created this revision.
mstorsjo added a reviewer: cdavis5x.
Herald added a subscriber: pengfei.
Herald added projects: libunwind, All.
Herald added a reviewer: libunwind.
mstorsjo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
For normal C++ unwinding, we get _dispContext initialized by the
prepopulated DISPATCHER_CONTEXT in _GCC_specific_handler, which
we set with __unw_seh_set_disp_ctx.
When doing force unwinding, we step and populate the unw_proc_info_t
struct _info with getInfoFromSEH, but when we execute the handler
via the __libunwind_seh_personality wrapper function, we execute
the handler set in DISPATCHER_CONTEXT.
Whenever updating these fields in either _info or _dispContext,
sync them to the other one too.
This fixes one aspect of the libcxxabi force_unwind*.pass.cpp tests on
x86_64.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D147637
Files:
libunwind/src/UnwindCursor.hpp
Index: libunwind/src/UnwindCursor.hpp
===================================================================
--- libunwind/src/UnwindCursor.hpp
+++ libunwind/src/UnwindCursor.hpp
@@ -506,7 +506,14 @@
#endif
DISPATCHER_CONTEXT *getDispatcherContext() { return &_dispContext; }
- void setDispatcherContext(DISPATCHER_CONTEXT *disp) { _dispContext = *disp; }
+ void setDispatcherContext(DISPATCHER_CONTEXT *disp) {
+ _dispContext = *disp;
+ _info.lsda = reinterpret_cast<unw_word_t>(_dispContext.HandlerData);
+ if (_dispContext.LanguageHandler) {
+ _info.handler = reinterpret_cast<unw_word_t>(__libunwind_seh_personality);
+ } else
+ _info.handler = 0;
+ }
// libunwind does not and should not depend on C++ library which means that we
// need our own definition of inline placement new.
@@ -1981,6 +1988,9 @@
uint32_t lastcode = (xdata->CountOfCodes + 1) & ~1;
const uint32_t *handler = reinterpret_cast<uint32_t *>(&xdata->UnwindCodes[lastcode]);
_info.lsda = reinterpret_cast<unw_word_t>(handler+1);
+ _dispContext.HandlerData = reinterpret_cast<void *>(_info.lsda);
+ _dispContext.LanguageHandler =
+ reinterpret_cast<EXCEPTION_ROUTINE *>(base + *handler);
if (*handler) {
_info.handler = reinterpret_cast<unw_word_t>(__libunwind_seh_personality);
} else
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147637.511142.patch
Type: text/x-patch
Size: 1357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230405/84c35f4d/attachment.bin>
More information about the llvm-commits
mailing list