thikonom
thikonom

Reputation: 4267

Python: debugging with gdb (on OSX)

There are quite a few tutorials on debugging with gdb for Python. Just to name a few among the best:

However all of them are targeted for the Linux OS. Is it feasible to install all the extension packages required on OSX ?

Upvotes: 7

Views: 4437

Answers (2)

Paul Price
Paul Price

Reputation: 2787

You need to build gdb. Per this answer, you need to set CFLAGS=-Wno-string-plus-int before building (at least, for MacOS 10.9 and gdb 7.6.1).

You have to codesign gdb before you can use it.

Then you need get a 'real' executable out of the MacOS fat binary so gdb can read it:

lipo -thin x86_64 -output python-x86_64 /usr/bin/python

Then you can happily:

gdb --args /path/to/python-x86_64 myPythonScript.py arg1 arg2

Alternatively, you can use lldb.

Upvotes: 4

Tom Tromey
Tom Tromey

Reputation: 22569

Sure, it is feasible. You presumably already have Python for your platform. Now you just need to build gdb. gdb isn't as well-supported there, but it does work.

Alternatively you can read the section "GDB on Legacy systems" at that first link.

Upvotes: 0

Related Questions