Make it possible to use pdb for debugging.

This commit is contained in:
Florian Bruhin 2014-09-03 13:31:01 +02:00
parent 71796e9528
commit e3bb3af7ba
3 changed files with 5 additions and 22 deletions

View File

@ -151,9 +151,7 @@ Debugging
~~~~~~~~~
In the `qutebrowser.utils.debug` module there are some useful functions for
debugging. In particular you should use `set_trace` from
`qutebrowser.utils.debug` instead of `pdb` to set breakpoints or you'll get
annoying Qt error messages.
debugging.
When starting qutebrowser with the `--debug` flag you also get useful debug
logs. You can add +--logfilter _category[,category,...]_+ to restrict logging

View File

@ -116,7 +116,11 @@ def main():
# We do this import late as we need to fix harfbuzz first.
from qutebrowser import app
from qutebrowser.utils import debug
from PyQt5.QtCore import pyqtRemoveInputHook
import PyQt5.QtWidgets as QtWidgets
# We don't use qutebrowser via the interactive shell, but we want to be
# able to use pdb.
pyqtRemoveInputHook()
app = app.Application(args)
# We set qApp explicitely here to reduce the risk of segfaults while
# quitting.

View File

@ -20,7 +20,6 @@
"""Utilities used for debugging."""
import re
import pdb
import sys
import types
import functools
@ -32,24 +31,6 @@ from qutebrowser.commands import cmdutils
from qutebrowser.config import config, style
@cmdutils.register(debug=True, name='debug-set-trace')
def set_trace():
"""Break into the debugger in the shell.
//
Based on http://stackoverflow.com/a/1745965/2085149
"""
if sys.stdout is not None:
sys.stdout.flush()
print()
print("When done debugging, remember to execute:")
print(" from PyQt5 import QtCore; QtCore.pyqtRestoreInputHook()")
print("before executing c(ontinue).")
pyqtRemoveInputHook()
pdb.set_trace()
@cmdutils.register(debug=True)
def debug_crash(typ='exception'):
"""Crash for debugging purposes.