Commit 960bd857 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot

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 <zero()>
  0x293f50 <one()>
  0x295050 <two()>
  0x296150 <three()>
  0x297250 <folly::coro::TaskWithExecutor<int>::start() &&::{lambda(folly::Promise<int>, folly::coro::TaskWithExecutor<int>)#1}::operator()(folly::Promise<int>, folly::coro::TaskWithExecutor<int>) const>

Reviewed By: jwiepert

Differential Revision: D13727139

fbshipit-source-id: bff98eb4f5eb2ebd73c880d3b525172782f87511
parent 93173f5a
#!/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"
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