]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cli: ceph: easier debugging (pdb) with 'CEPH_DBG=1'
authorJoao Eduardo Luis <joao@redhat.com>
Fri, 2 Jan 2015 17:36:40 +0000 (17:36 +0000)
committerJoao Eduardo Luis <joao@redhat.com>
Tue, 6 Jan 2015 15:45:15 +0000 (15:45 +0000)
'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 <joao@redhat.com>
src/ceph.in

index b419a280a9550cce199d31ec9efca6ac7b8eb5c2..9a7092b972c0095b30dc5956b9ccb20a9ae3a6cf 100755 (executable)
@@ -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