From 8af2e712ae16d105246d5348bd6f47f34c57ffcb Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 29 Mar 2015 19:45:00 +0200 Subject: [PATCH] Add a --pdb-postmortem argument. --- doc/qutebrowser.1.asciidoc | 3 +++ qutebrowser/app.py | 7 ++++++- qutebrowser/qutebrowser.py | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/qutebrowser.1.asciidoc b/doc/qutebrowser.1.asciidoc index 87d0329d7..8c72f91f0 100644 --- a/doc/qutebrowser.1.asciidoc +++ b/doc/qutebrowser.1.asciidoc @@ -80,6 +80,9 @@ It was inspired by other browsers/addons like dwb and Vimperator/Pentadactyl. *--no-crash-dialog*:: Don't show a crash dialog. +*--pdb-postmortem*:: + Drop into pdb on exceptions. + *--qt-name* 'NAME':: Set the window name. diff --git a/qutebrowser/app.py b/qutebrowser/app.py index be0ede32e..f0ef608df 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -24,6 +24,7 @@ import sys import subprocess import configparser import signal +import pdb import bdb import base64 import functools @@ -596,7 +597,11 @@ class Application(QApplication): is_ignored_exception = (exctype is bdb.BdbQuit or not issubclass(exctype, Exception)) - if is_ignored_exception or self._args.no_crash_dialog: + if self._args.pdb_postmortem: + pdb.post_mortem(tb) + + if (is_ignored_exception or self._args.no_crash_dialog or + self._args.pdb_postmortem): # pdb exit, KeyboardInterrupt, ... status = 0 if is_ignored_exception else 2 try: diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index eb5cb651c..6be8e1bb8 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -84,6 +84,8 @@ def get_argparser(): action='store_true') debug.add_argument('--no-crash-dialog', action='store_true', help="Don't " "show a crash dialog.") + debug.add_argument('--pdb-postmortem', action='store_true', + help="Drop into pdb on exceptions.") # For the Qt args, we use store_const with const=True rather than # store_true because we want the default to be None, to make # utils.qt:get_args easier.