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