Commit 1aba9144 authored by Christopher Gist's avatar Christopher Gist Committed by Facebook GitHub Bot

fix folly::fibers GDB extension for GCC 9

Summary:
The folly::fibers GDB extension, specifically the `info fibers` command,
depended on a specific format of the std::unique_ptr pretty printer
output. This pretty printer format changed between GCC 7 and GCC 9, with
the latter omitting the target address. However, the new pretty printer
does expose an iterator for the child target address that we can use
instead.

Differential Revision: D23063364

fbshipit-source-id: 6125edaba9abcfd0b7a9c0741a18854637c97804
parent 09a33a57
...@@ -806,22 +806,31 @@ def get_fiber_managers(only=None): ...@@ -806,22 +806,31 @@ def get_fiber_managers(only=None):
# we have a value, make sure we have a unique key # we have a value, make sure we have a unique key
assert mid not in managers assert mid not in managers
value = entry value = gdb.default_visualizer(entry)
# unfortunately the stl gdb libs don't expose the unique_ptr target address # Before GCC9, the stl gdb libs don't expose the unique_ptr target
# except through the pretty printer, as the last space-delimited word. # address except through the pretty printer, as the last
# We extract that address using the pretty printer, then create a new # space-delimited word. From GCC9 forward, the unique_ptr visualizer
# gdb.Value of that address cast to the fibermanager type. # exposes a children iterator with the target address. We extract
address = int(gdb.default_visualizer(value).to_string().split(" ")[-1], 16) # that address whicever way we can, then create a new gdb.Value of
manager = ( # that address cast to the fibermanager type.
gdb.Value(address) address = None
.cast(gdb.lookup_type("folly::fibers::FiberManager").pointer()) if callable(getattr(value, "children", None)):
.dereference() for _, pointer in value.children():
) address = pointer
else:
address = int(value.to_string().split(" ")[-1], 16)
# output only if matching filter if address is not None:
if not only or str(mid) in only: manager = (
yield (mid, manager) gdb.Value(address)
.cast(gdb.lookup_type("folly::fibers::FiberManager").pointer())
.dereference()
)
# output only if matching filter
if not only or str(mid) in only:
yield (mid, manager)
# set cache # set cache
get_fiber_managers.cache = managers get_fiber_managers.cache = managers
......
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