From bcffe825df2babdca7633347d01926e71423e3ff Mon Sep 17 00:00:00 2001 From: David Strobach Date: Fri, 5 Jun 2020 02:27:19 +0200 Subject: [PATCH] Add xontrib-pdb. Runs pdb on SIGUSR1. --- xonsh/xontribs.json | 5 +++++ xontrib/pdb.py | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 xontrib/pdb.py diff --git a/xonsh/xontribs.json b/xonsh/xontribs.json index 43c42ef85..fec4c1985 100644 --- a/xonsh/xontribs.json +++ b/xonsh/xontribs.json @@ -164,6 +164,11 @@ "description": ["Get identifiers, names, paths, URLs and words from the previous command output ", "and use them for the next command."] }, + {"name": "pdb", + "package": "xonsh", + "url": "http://xon.sh", + "description": ["Simple built-in debugger. Runs pdb on reception of SIGUSR1 signal."] + }, {"name": "powerline", "package": "xontrib-powerline", "url": "https://github.com/santagada/xontrib-powerline", diff --git a/xontrib/pdb.py b/xontrib/pdb.py new file mode 100644 index 000000000..24f6de12e --- /dev/null +++ b/xontrib/pdb.py @@ -0,0 +1,14 @@ +"""Simple built-in debugger. Runs pdb on reception of SIGUSR1 signal.""" +import signal + +__all__ = () + + +def handle_sigusr1(sig, frame): + print("\nSIGUSR1 signal received. Starting interactive debugger...", flush=True) + import pdb + + pdb.Pdb().set_trace(frame) + + +signal.signal(signal.SIGUSR1, handle_sigusr1)