[Zope-dev] To the brave folks trying Zope HEAD...

Jeremy Hylton jeremy at zope.com
Wed Dec 10 13:59:24 EST 2003


On Wed, 2003-12-10 at 14:01, Sidnei da Silva wrote:
> | Probably a good next step is to set a breakpoint in
> | ZODB/coptimizations.c where this exception is raised and find out what
> | object is causing the problem, which jar it's already in, and why it's
> | getting added to a different jar.  Or you could add some print
> | statements.
> 
> I figured out how to set a breakpoint in gdb, but I don't know how to
> get at the object and inspect it. Can I get a quick hint? I know there
> has to be some pointer cast probably, just need to know which one. :)

I think you're looking for the helpers defined in Misc/gdbinit in the
Python distribution.  If you add them to your .gdbinit, you'll be
golden.

I've included that file's contents below so you don't have to go
hunting.

# -*- ksh -*-
#
# If you use the GNU debugger gdb to debug the Python C runtime, you
# might find some of the following commands useful.  Copy this to your
# ~/.gdbinit file and it'll get loaded into gdb automatically when you
# start it up.  Then, at the gdb prompt you can do things like:
#
#    (gdb) pyo apyobjectptr
#    <module 'foobar' (built-in)>
#    refcounts: 1
#    address    : 84a7a2c
#    $1 = void
#    (gdb)

# Prints a representation of the object to stderr, along with the
# number of reference counts it current has and the hex address the
# object is allocated at.  The argument must be a PyObject*
define pyo
print _PyObject_Dump($arg0)
end

# Prints a representation of the object to stderr, along with the
# number of reference counts it current has and the hex address the
# object is allocated at.  The argument must be a PyGC_Head*
define pyg
print _PyGC_Dump($arg0)
end

# If you are in an eval_frame() function, calling pyframe with no
# arguments will print the filename, function name, and line number.
# It assumes that f is the name of the current frame.
define pyframe
x/s ((PyStringObject*)f->f_code->co_filename)->ob_sval
x/s ((PyStringObject*)f->f_code->co_name)->ob_sval
p f->f_lineno
end





More information about the Zope-Dev mailing list