From 960bd857d1e61dbe2aa5b710f7a304c1c2685577 Mon Sep 17 00:00:00 2001 From: Andrii Grynenko Date: Fri, 18 Jan 2019 11:22:57 -0800 Subject: [PATCH] Basic co_bt gdb script for coro::Task Summary: This is mostly a POC. It will probably fail in some cases, but it's better than nothing. Sample output: (gdb) co_bt this 0x292d70 0x293f50 0x295050 0x296150 0x297250 ::start() &&::{lambda(folly::Promise, folly::coro::TaskWithExecutor)#1}::operator()(folly::Promise, folly::coro::TaskWithExecutor) const> Reviewed By: jwiepert Differential Revision: D13727139 fbshipit-source-id: bff98eb4f5eb2ebd73c880d3b525172782f87511 --- folly/experimental/coro/scripts/gdb.py | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 folly/experimental/coro/scripts/gdb.py diff --git a/folly/experimental/coro/scripts/gdb.py b/folly/experimental/coro/scripts/gdb.py new file mode 100644 index 00000000000..95c8323b65d --- /dev/null +++ b/folly/experimental/coro/scripts/gdb.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + + +import gdb + + +class CoroBacktraceCommand(gdb.Command): + def __init__(self): + super(CoroBacktraceCommand, self).__init__("co_bt", gdb.COMMAND_USER) + + def invoke(self, arg, from_tty): + if not arg: + print("coroutine_handle has to be passed to 'co_bt' command") + return + coroutine_handle = gdb.parse_and_eval(arg) + void_star_star = gdb.lookup_type("void").pointer().pointer() + coroutine_frame = ( + coroutine_handle.cast(void_star_star).dereference().cast(void_star_star) + ) + while coroutine_frame < 0xFFFFFFFFFFFF: + print(coroutine_frame.dereference()) + coroutine_frame = (coroutine_frame + 2).dereference().cast(void_star_star) + + +def load(): + CoroBacktraceCommand() + + +def info(): + return "Pretty printers for folly::coro"