~bzr-pqm/bzr/bzr.dev

2423.3.4 by Martin Pool
Late load pdb for breakin; fix copyright
1
# Copyright (C) 2006, 2007 Canonical Ltd
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2423.3.1 by Martin Pool
C-\ drops bzr into the debugger
16
17
def _debug(signal_number, interrupted_frame):
2423.3.4 by Martin Pool
Late load pdb for breakin; fix copyright
18
    import pdb
19
    import sys
2423.3.1 by Martin Pool
C-\ drops bzr into the debugger
20
    sys.stderr.write("** SIGQUIT received, entering debugger\n"
21
            "** Type 'c' to continue or 'q' to stop the process\n")
22
    pdb.set_trace()
23
24
def hook_sigquit():
25
    # when sigquit (C-\) is received go into pdb
26
    # XXX: is this meaningful on Windows?
2423.3.4 by Martin Pool
Late load pdb for breakin; fix copyright
27
    import signal
2423.3.1 by Martin Pool
C-\ drops bzr into the debugger
28
    signal.signal(signal.SIGQUIT, _debug)