Skip to content

Commit

Permalink
Basic co_bt gdb script for coro::Task
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andriigrynenko authored and facebook-github-bot committed Jan 18, 2019
1 parent 93173f5 commit 960bd85
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions folly/experimental/coro/scripts/gdb.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 960bd85

Please sign in to comment.