To see Python code positions for all threads, use:Ģ03 return _socketobject(_sock=sock), addrĢ04 accept._doc_ = _realsocket.accept._doc_
To see where it is in Python code, use py-list:Ģ025 # Open external files with our Mac appĢ026 if sys.platform = "darwin" and 'Spyder.app' in _file_:Ģ027 nnect(app, SIGNAL('open_external_file(QString)'),Ģ028 lambda fname: main.open_external_file(fname)) * 1 Thread 0xb7d876c0 (LWP 17863) "python2.7" 0xb7fdd424 in _kernel_vsyscall ()Ĭurrent thread is marked with *. If the process is in a busy loop, you may want to continue execution for a bit (using the cont command), then break (Ctrl+C) again and bring up a stack trace. In either case, attaching to the process and getting a back trace can help. If a process appears hung, it will either be waiting on something (a lock, IO, etc), or be in a busy loop somewhere. To get stack trace with familiar Python source code.
If you have Python extensions installed, you can enter: The quality of the results will depend greatly on the amount of debug information available. With luck, this will give some idea of where the problem is occurring and if it doesn't help you fix the problem, it can help someone else track down the problem. If you are debugging a segfault, this is probably the first thing you want to do.Īt the (gdb) prompt, just run the following command: See the page EasierPythonDebugging for the list of Python helper commands for gdb. You can also manually interrupt program execution by pressing Ctrl+C in the console. If your program segfaulted, gdb will automatically pause the program, so you can switch into gdb console to inspect its state. You can tell it to continue running with c command. If the process is already running, you can attach to it provided you know the process ID.Īttaching to a running process like this will cause it to stop. This will run the program til it exits, segfaults or you manually stop execution (using Ctrl+C). To run python under gdb there are also two ways. attach to already running python process.Note: the python executable needs to have debug symbols in it which may be another exe python2.7-dbg depending on your system python-debuginfo is installable after the first two commands.įor gdb support on legacy systems, look at the end of this page. On a modern Linux system, you can easily install these with: Extensions package includes debugging symbols and adds Python-specific commands into gdb. You need to have gdb on your system and Python debugging extensions. Hung processes (in cases where you can't get a Python traceback or debug with pdb) segfaults (not uncaught Python exceptions).There are types of bugs that are difficult to debug from within Python: