[Zope3-dev] How to debug zope3 if it completely hangs?

Dieter Maurer dieter at handshake.de
Fri Jul 13 14:05:45 EDT 2007


Fabio Tranchitella wrote at 2007-7-12 15:46 +0200:
> ...
>I tried the suggestions from Benji, but using gdb and the commands from
>"debug-spining-zope" results in a segfault of the zope3 instance I'm
>debugging.

You could try the following gdb commands:

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


"pfr" (Print FRame) can be used in "PyEvalFrame" ("C" level) call frames
to determine which Python code belongs to the respective call frame.



-- 
Dieter


More information about the Zope3-dev mailing list