# locally clone the repo. git clone https://github.com/python/cpython # Navigate to the repo directory cd cpython # Switch to the version of python you want to work on git checkout 3.6 # configure a debug build for CPython ./configure --with-pydebug # build without echoing commands and use 2 cores make -s -j2
sabbas@sabbas-VirtualBox:~/Documents/pythondev/cpython $ gdb python GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 Copyright (C) 2016 Free Software Foundation, Inc. (gdb) run Starting program: /home/sabbas/Documents/pythondev/cpython/python [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Python 3.6.2+ (heads/3.6:cb7fdf6, Aug 23 2017, 22:24:16) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> >>> def foo(): ... x = 1 ... x.a ... >>> Program received signal SIGTRAP, Trace/breakpoint trap. 0x00007ffff71dd573 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:84 84 ../sysdeps/unix/syscall-template.S: No such file or directory. (gdb) b Python/ceval.c:2855 Breakpoint 1 at 0x5418d7: file Python/ceval.c, line 2855. (gdb)c Continuing. >>>