From: Joao Eduardo Luis Date: Fri, 2 Jan 2015 17:36:40 +0000 (+0000) Subject: cli: ceph: easier debugging (pdb) with 'CEPH_DBG=1' X-Git-Tag: v0.93~205^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8618a5373e61035d9112ba024eda78792561c265;p=ceph.git cli: ceph: easier debugging (pdb) with 'CEPH_DBG=1' 'CEPH_DBG=1 ceph foo' will now drop a pdb shell for interactive debugging. Way better than fiddling with the source each time one needs to debug something, especially considering that in dev mode the tool will call execv and spawn itself with modified paths. This reduces a considerable amount of pain. Signed-off-by: Joao Eduardo Luis --- diff --git a/src/ceph.in b/src/ceph.in index b419a280a955..9a7092b972c0 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -42,15 +42,18 @@ if MYDIR.endswith('src') and \ py_binary = os.environ.get("PYTHON", "python") MYLIBPATH = os.path.join(MYDIR, '.libs') + execv_cmd = ['python'] + if 'CEPH_DBG' in os.environ: + execv_cmd += ['-mpdb'] if lib_path_var in os.environ: if MYLIBPATH not in os.environ[lib_path_var]: os.environ[lib_path_var] += ':' + MYLIBPATH print >> sys.stderr, DEVMODEMSG - os.execvp(py_binary, ['python'] + sys.argv) + os.execvp(py_binary, execv_cmd + sys.argv) else: os.environ[lib_path_var] = MYLIBPATH print >> sys.stderr, DEVMODEMSG - os.execvp(py_binary, ['python'] + sys.argv) + os.execvp(py_binary, execv_cmd + sys.argv) sys.path.insert(0, os.path.join(MYDIR, 'pybind')) if os.environ.has_key('PATH') and MYDIR not in os.environ['PATH']: os.environ['PATH'] += ':' + MYDIR