template <typename FrameFunc> bool onlyForUnwindStateNormal(PythonFrameIteratorImpl* frame_iter, FrameFunc f) { | |
bool rtn = false; | |
if (threading::ThreadStateInternal::getUnwindState() == UNWIND_STATE_NORMAL) | |
rtn = f(); | |
threading::ThreadStateInternal::setUnwindState((bool)frame_iter->cf->entry_descriptor ? UNWIND_STATE_OSR | |
: UNWIND_STATE_NORMAL); | |
return rtn; | |
} | |
// usage: | |
void maybeTracebackHere(void* unw_cursor) { | |
unw_cursor_t* cursor = (unw_cursor_t*)unw_cursor; | |
unw_word_t ip = get_cursor_ip(cursor); | |
unw_word_t bp = get_cursor_bp(cursor); | |
BoxedTraceback** tb_loc | |
= reinterpret_cast<BoxedTraceback**>(&threading::ThreadStateInternal::getExceptionFerry()->traceback); | |
unwindProcessFrame(ip, bp, cursor, [&](PythonFrameIteratorImpl* frame_iter) { | |
return onlyForUnwindStateNormal(frame_iter, [&](PythonFrameIteratorImpl* frame_iter) { | |
BoxedTraceback::Here(lineInfoForFrame(frame_iter), tb_loc); | |
return false; | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment