Friday, January 12, 2007

Python thread debugging

Python's Misc/gdbinit provides a helper to print the Python call stack. Because of some assumptions it makes, it won't work for any thread except the main thread. This patch fixes that:


Index: gdbinit
===================================================================
--- gdbinit (revision 53403)
+++ gdbinit (working copy)
@@ -119,7 +119,7 @@

# print the entire Python call stack
define pystack
- while $pc < Py_Main || $pc > Py_GetArgcArgv
+ while ($pc < Py_Main || $pc > Py_GetArgcArgv) && ($pc < t_bootstrap || $pc > thread_PyThread_start_new_thread)
if $pc > PyEval_EvalFrame && $pc < PyEval_EvalCodeEx
pyframe
end


A similar change is required for pystackv.

2 comments:

  1. Hello! ;)
    heh... what brainsick newz!
    what do you consider about it?

    ReplyDelete
  2. Thanks for this patch.

    ReplyDelete