Skip to content

Commit 152dbb0

Browse files
Mateusz Dziekanfacebook-github-bot
authored andcommitted
fibers getStackPointer
Summary: exposing fiber stack pointers so that we can walk the traces and print them in the next diff Reviewed By: yfeldblum Differential Revision: D76646227 fbshipit-source-id: c3f7fc1b422231d96be509e4c6d212b7368c2d82
1 parent 680cb92 commit 152dbb0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

third-party/folly/src/folly/fibers/BoostContextCompatibility.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ class FiberImpl {
6262
DCHECK_EQ(this, reinterpret_cast<FiberImpl*>(context));
6363
}
6464

65+
void* getStackPointer() const {
66+
if (kIsArchAmd64 && kIsLinux) {
67+
return reinterpret_cast<void**>(fiberContext_)[6];
68+
}
69+
return nullptr;
70+
}
71+
6572
private:
6673
static void fiberFunc(boost::context::detail::transfer_t transfer) {
6774
auto fiberImpl = reinterpret_cast<FiberImpl*>(transfer.data);

third-party/folly/src/folly/fibers/Fiber.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Fiber {
7676
/**
7777
* Retrieve this fiber's base stack and stack size.
7878
*
79-
* @return This fiber's stack pointer and stack size.
79+
* @return This fiber's base stack pointer and stack size.
8080
*/
8181
std::pair<void*, size_t> getStack() const {
8282
return {fiberStackLimit_, fiberStackSize_};
@@ -99,6 +99,13 @@ class Fiber {
9999

100100
State getState() const { return state_; }
101101

102+
/**
103+
* Retrieve this fiber's stack pointer. This is only meant for debugging.
104+
*
105+
* @return This fiber's current stack pointer.
106+
*/
107+
void* getStackPointer() const { return fiberImpl_.getStackPointer(); }
108+
102109
private:
103110
State state_{INVALID}; /**< current Fiber state */
104111

0 commit comments

Comments
 (0)