3

I loaded in python a C library X.so, that I compiled with these flags.

GDBFLAGS = -gdwarf-2 -g3 -O0 -ggdb

and I call some of its non-static functions from python , using ctypes.

I wish debugging the C library X.so. Some function from X.so crashes sometimes, not all the time, and I wish monitoring the execution using gdb.

I use linux-gnu. How can I debug ctypes ?

1 Answer 1

6

Use "gdb python" and run your program as usual. Then when it crashes, debug as normal.

BTW I recommend using just "-g3". Don't use "-gdwarf-2", this does the wrong thing nowadays -- DWARF 2 is quite old actually and the default is newer now.

Sign up to request clarification or add additional context in comments.

1 Comment

gdb should be set up with libpython.py, such as is installed by Debian's python3.3-dbg package. It pretty prints Python objects and installs the commands py-print, py-locals, py-list, py-bt, py-bt-full, py-up, and py-down.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.