Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get python eventlet stack throuth gdb

I have a python program. It has many eventlet coroutine. It seems that the program have dead lock someday. I have dumped its memory. I want to find reason. The question is how to get eventlet coroutine stack using gdb.

Additional Information:

  1. I know how to get all thread stack through gdb. But it comes to eventlet coroutine,it became difficult. Because I have not enough info about python interpreter.
  2. I also know how to get all eventlet coroutine stack in a python program by iterating all object. But it is useless to the situation we should check all object through gdb.
like image 232
xhzhf Avatar asked Jul 18 '26 12:07

xhzhf


1 Answers

There is no simple way as with regular threads.

Here are some hints to help you, though:

  • Multiple useful lessons on debugging Python with GDB http://grapsus.net/blog/post/Low-level-Python-debugging-with-GDB
  • Use eventlet.backdoor to have emergency in-process interpreter for debugging http://eventlet.net/doc/modules/backdoor.html
  • Search gc.get_objects() for instances of greenlet, print stack of x.gr_frame In gevent, how can I dump stack traces of all running greenlets?
  • Setup signal handler (e.g. USR1) that iterates all greenthreads and prints their stack to stderr
like image 73
temoto Avatar answered Jul 20 '26 00:07

temoto