Search code examples
pythondebuggingpydev

How do I enable post mortem debugging in pydev?


I want to make pydev enter into an interactive console mode whenever my program raises an unhandled exception but I can't figure out how to do it. As it behaves now, the exception is reported and the process is terminated immidiately.

After some searching around I found this: http://sourceforge.net/tracker/index.php?func=detail&aid=3029746&group_id=85796&atid=577332 which suggests to use pydevd.set_pm_excepthook()

However, when i add

import pydevd
pydevd.set_pm_excepthook()

to my code, I get an exception:

This function is now replaced by GetGlobalDebugger().setExceptHook and is now controlled by the PyDev UI.')
DeprecationWarning: This function is now replaced by GetGlobalDebugger().setExceptHook and is now controlled by the PyDev UI.

But:

GetGlobalDebugger().setExceptHook()

Doesn't seem to work, GetGlobalDebugger() does not exist in the global namespace.


Solution

  • Actually, you don't need to do this programmatically... you can go to the Debug perspective > Pydev menu > Manage Exception Breakpoints

    GUI example

    and check 'Suspend on uncaught exceptions'. In most cases you will want to catch all kinds of exceptions (so choose "Select All") but you can also select exceptions to be managed individually.

    Dialog