Commit 5667a970 authored by Brian Watling's avatar Brian Watling Committed by facebook-github-bot-9

Allow (read-only) access to a fiber's stack details

Summary: Allow users to access the stack pointer and stack size

Reviewed By: @alikhtarov

Differential Revision: D2407252
parent 823a8c01
......@@ -54,6 +54,21 @@ class Fiber {
Fiber& operator=(const Fiber&) = delete;
~Fiber();
/**
* Retrieve this fiber's base stack and stack size.
*
* @return This fiber's stack pointer and stack size.
*/
std::pair<void*, size_t> getStack() const {
void* const stack =
std::min<void*>(fcontext_.stackLimit(), fcontext_.stackBase());
const size_t size = std::abs<intptr_t>(
reinterpret_cast<intptr_t>(fcontext_.stackBase()) -
reinterpret_cast<intptr_t>(fcontext_.stackLimit()));
return { stack, size };
}
private:
enum State {
INVALID, /**< Does't have task function */
......
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