[ZODB-Dev] ZEO client hangs when combined with other asyncore code
Dieter Maurer
dieter at handshake.de
Wed Jun 22 13:44:07 EDT 2005
Tim Peters wrote at 2005-6-21 14:56 -0400:
> ...
>[Dieter Maurer]
>> If you happen to run your application on Linux (and use the "GDB"), I
>> can provide detailed instructions on how to find out where your code
>> hangs...
>
>That would be helpful!
Also you already solved the main problem, I will share
how I analyse "hanging problems" with "GDB" under Linux.
I attach the hanging progess with "GDB"
gdb python <process id>
"info threads" tells me about the process' threads,
"thread <i>" allows me to switch into the context
of the various threads. "bt" shows me the call trace in current
thread. That's all C level information.
To relate that to the Python level, I use a ".gdbinit"
with the following definitions.
"ps" (for "Print String") outputs the value of a Python
string variable.
"pfr" (for "Print FRame") can be called in "eval_frame"
C level stack frames and tells filename, function name and line number
of the corresponding Python call.
With these commands I can reconstruct the Python call stack
for the given thread (although it is a bit cumbersome).
Would I know more about how Python stores its interpreter
state per thread, this reconstruction would probably be
even easier...
def ps
x/s ({PyStringObject}$arg0)->ob_sval
end
def pfr
ps f->f_code->co_filename
ps f->f_code->co_name
#p f->f_lineno
lineno
end
define lineno
set $__co = f->f_code
set $__lasti = f->f_lasti
set $__sz = ((PyStringObject *)$__co->co_lnotab)->ob_size/2
set $__p = (unsigned char *)((PyStringObject *)$__co->co_lnotab)->ob_sval
set $__li = $__co->co_firstlineno
set $__ad = 0
while ($__sz-1 >= 0)
set $__sz = $__sz - 1
set $__ad = $__ad + *$__p
set $__p = $__p + 1
if ($__ad > $__lasti)
# break -- interpreted as "breakpoint"
set $__sz = -1
end
if ($__sz >= 0)
set $__li = $__li + *$__p
set $__p = $__p + 1
end
end
printf "%d\n", $__li
end
--
Dieter
More information about the ZODB-Dev
mailing list