Commit 698754f3 authored by Chris Keeline's avatar Chris Keeline Committed by Facebook GitHub Bot

Back out "Fix fiber backtraces in gdb"

Summary: Original commit changeset: 2d4ad67a4a01

Reviewed By: yfeldblum

Differential Revision: D23064000

fbshipit-source-id: 88d8d550772c2045f61d5a355cf33c9d8df7d046
parent e9ae08b8
...@@ -59,7 +59,7 @@ class FiberImpl { ...@@ -59,7 +59,7 @@ class FiberImpl {
auto transfer = auto transfer =
boost::context::detail::jump_fcontext(mainContext_, nullptr); boost::context::detail::jump_fcontext(mainContext_, nullptr);
mainContext_ = transfer.fctx; mainContext_ = transfer.fctx;
fixStackUnwinding(true); fixStackUnwinding();
auto context = reinterpret_cast<intptr_t>(transfer.data); auto context = reinterpret_cast<intptr_t>(transfer.data);
DCHECK_EQ(this, reinterpret_cast<FiberImpl*>(context)); DCHECK_EQ(this, reinterpret_cast<FiberImpl*>(context));
} }
...@@ -68,26 +68,15 @@ class FiberImpl { ...@@ -68,26 +68,15 @@ class FiberImpl {
static void fiberFunc(boost::context::detail::transfer_t transfer) { static void fiberFunc(boost::context::detail::transfer_t transfer) {
auto fiberImpl = reinterpret_cast<FiberImpl*>(transfer.data); auto fiberImpl = reinterpret_cast<FiberImpl*>(transfer.data);
fiberImpl->mainContext_ = transfer.fctx; fiberImpl->mainContext_ = transfer.fctx;
fiberImpl->fixStackUnwinding(false); fiberImpl->fixStackUnwinding();
fiberImpl->func_(); fiberImpl->func_();
} }
void fixStackUnwinding(bool deactivate) { void fixStackUnwinding() {
if (!kIsLinux) { if (kIsArchAmd64 && kIsLinux) {
return;
}
auto stackBase = reinterpret_cast<void**>(stackBase_);
// Write a nullptr to the saved return address, when deactivating. Otherwise
// backtrace will point to the main context's stack. These pointers will no
// longer be valid once we switch to the main context.
if (deactivate) {
stackBase[-1] = nullptr;
return;
}
if (kIsArchAmd64) {
// Extract RBP and RIP from main context to stitch main context stack and // Extract RBP and RIP from main context to stitch main context stack and
// fiber stack. // fiber stack.
auto stackBase = reinterpret_cast<void**>(stackBase_);
auto mainContext = reinterpret_cast<void**>(mainContext_); auto mainContext = reinterpret_cast<void**>(mainContext_);
stackBase[-2] = mainContext[6]; stackBase[-2] = mainContext[6];
stackBase[-1] = mainContext[7]; stackBase[-1] = mainContext[7];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment