Commit 7feeb55d authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot

Add fiber-print-limit command

Summary: Limits number of fibers printed for each FiberManager.

Reviewed By: yfeldblum

Differential Revision: D4432488

fbshipit-source-id: 1791c2bfe6d5b0c2f54142dc068b473fd72f5d5d
parent 74261e41
......@@ -497,6 +497,11 @@ $<span class="mi">4</span> <span class="o">=</span> <span class="nc" data-symbol
<span class="o">&#125;</span>
<span class="o">&#125;</span></pre></div>
<p><tt>fiber-print-limit</tt> command can be used to change the maximum number of fibers printed for a <tt>fibers::FiberManager</tt> (default value is 100).</p>
<div class="remarkup-code-block" data-code-lang="php"><pre class="remarkup-code"><span class="o">(</span><span class="no">gdb</span><span class="o">)</span> <span class="no">fiber</span><span class="o">-</span><span class="no">print</span><span class="o">-</span><span class="no">limit</span> <span class="mi">10</span>
<span class="k">New</span> <span class="nc" data-symbol-name="fiber">fiber</span> <span class="no">limit</span> <span class="k">for</span> <span class="no">FiberManager</span> <span class="no">printer</span> <span class="no">set</span> <span class="no">to</span> <span class="mi">10</span></pre></div>
<h3 id="printing-a-fiber-task">Printing a fiber-task <a href="#printing-a-fiber-task" class="headerLink">#</a></h3>
<p>Given a pointer to a <tt>fibers::Fiber</tt>, which is running some fiber-task, you can get its current state:</p>
......
......@@ -58,6 +58,8 @@ class FiberPrinter:
class FiberManagerPrinter:
"""Print a folly::fibers::Fiber"""
fiber_print_limit = 100
def __init__(self, fm):
self.fm = fm
......@@ -68,7 +70,13 @@ class FiberManagerPrinter:
active_fibers = collections.OrderedDict()
fiber_count = 0
while fiber_hook != all_fibers.address:
if fiber_count == FiberManagerPrinter.fiber_print_limit:
active_fibers["..."] = "..."
break
fiber = fiber_hook.cast(gdb.lookup_type("int64_t"))
fiber = fiber - gdb.parse_and_eval(
"(int64_t)&folly::fibers::Fiber::globalListHook_")
......@@ -80,6 +88,8 @@ class FiberManagerPrinter:
fiber_hook = fiber_hook.dereference()['next_']
fiber_count = fiber_count + 1
return active_fibers.items()
def to_string(self):
......@@ -89,6 +99,20 @@ class FiberManagerPrinter:
return "folly::fibers::FiberManager"
class FiberPrintLimitCommand(gdb.Command):
def __init__(self):
super(FiberPrintLimitCommand, self).__init__(
"fiber-print-limit", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
if not arg:
print("New limit has to be passed to 'fiber_print_limit' command")
return
FiberManagerPrinter.fiber_print_limit = int(arg)
print("New fiber limit for FiberManager printer set to " +
str(FiberManagerPrinter.fiber_print_limit))
class FrameId(object):
def __init__(self, sp, pc):
self.sp = sp
......@@ -281,6 +305,7 @@ def build_pretty_printer():
def load():
gdb.printing.register_pretty_printer(gdb, build_pretty_printer())
gdb.xmethod.register_xmethod_matcher(gdb, FiberXMethodMatcher())
FiberPrintLimitCommand()
FiberActivateCommand()
FiberDeactivateCommand()
Shortcut("get_fiber_manager_map_evb", get_fiber_manager_map_evb)
......
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