4
# Copyright 2014-2015 Canonical Limited.
6
# This file is part of charm-helpers.
8
# charm-helpers is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU Lesser General Public License version 3 as
10
# published by the Free Software Foundation.
12
# charm-helpers is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Lesser General Public License for more details.
17
# You should have received a copy of the GNU Lesser General Public License
18
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
20
from __future__ import print_function
25
from charmhelpers.contrib.python.rpdb import Rpdb
26
from charmhelpers.core.hookenv import (
33
__author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>"
35
DEFAULT_ADDR = "0.0.0.0"
40
log(message, level=ERROR)
43
def set_trace(addr=DEFAULT_ADDR, port=DEFAULT_PORT):
45
Set a trace point using the remote debugger
47
atexit.register(close_port, port)
49
log("Starting a remote python debugger session on %s:%s" % (addr,
52
debugger = Rpdb(addr=addr, port=port)
53
debugger.set_trace(sys._getframe().f_back)
55
_error("Cannot start a remote debug session on %s:%s" % (addr,