summaryrefslogtreecommitdiff
path: root/Cython/Debugger
diff options
context:
space:
mode:
authorVolker-Weissmann <39418860+Volker-Weissmann@users.noreply.github.com>2020-04-09 21:02:17 +0200
committerGitHub <noreply@github.com>2020-04-09 21:02:17 +0200
commit66a8a8e84b63e44e0c50c60779953d03097700b6 (patch)
tree175b6e454d9d8f2a12f1870797cbcd50e04f80fb /Cython/Debugger
parent35ecaccb626f7f3ebf54cf6ec93bda36f05a72b1 (diff)
downloadcython-66a8a8e84b63e44e0c50c60779953d03097700b6.tar.gz
Better diagnostics for non-working cygdb installations. (GH-3489)
If your installation is faulty, cygdb will now print the filepath of the code that caused an exception, and the path of the python interpreter will be printed for better debugging.
Diffstat (limited to 'Cython/Debugger')
-rw-r--r--Cython/Debugger/Cygdb.py32
1 files changed, 19 insertions, 13 deletions
diff --git a/Cython/Debugger/Cygdb.py b/Cython/Debugger/Cygdb.py
index 45f31ce6f..1b0a794e3 100644
--- a/Cython/Debugger/Cygdb.py
+++ b/Cython/Debugger/Cygdb.py
@@ -45,17 +45,23 @@ def make_command_file(path_to_debug_info, prefix_code='', no_import=False):
set print pretty on
python
- # Activate virtualenv, if we were launched from one
- import os
- virtualenv = os.getenv('VIRTUAL_ENV')
- if virtualenv:
- path_to_activate_this_py = os.path.join(virtualenv, 'bin', 'activate_this.py')
- print("gdb command file: Activating virtualenv: %s; path_to_activate_this_py: %s" % (
- virtualenv, path_to_activate_this_py))
- with open(path_to_activate_this_py) as f:
- exec(f.read(), dict(__file__=path_to_activate_this_py))
-
- from Cython.Debugger import libcython, libpython
+ try:
+ # Activate virtualenv, if we were launched from one
+ import os
+ virtualenv = os.getenv('VIRTUAL_ENV')
+ if virtualenv:
+ path_to_activate_this_py = os.path.join(virtualenv, 'bin', 'activate_this.py')
+ print("gdb command file: Activating virtualenv: %s; path_to_activate_this_py: %s" % (
+ virtualenv, path_to_activate_this_py))
+ with open(path_to_activate_this_py) as f:
+ exec(f.read(), dict(__file__=path_to_activate_this_py))
+ from Cython.Debugger import libcython, libpython
+ except Exception as ex:
+ from traceback import print_exc
+ print("There was an error in Python code originating from the file ''' + str(__file__) + '''")
+ print("It used the Python interpreter " + str(sys.executable))
+ print_exc()
+ exit(1)
end
'''))
@@ -79,8 +85,8 @@ def make_command_file(path_to_debug_info, prefix_code='', no_import=False):
gdb.lookup_type('PyModuleObject')
except RuntimeError:
sys.stderr.write(
- 'Python was not compiled with debug symbols (or it was '
- 'stripped). Some functionality may not work (properly).\\n')
+ "''' + interpreter + ''' was not compiled with debug symbols (or it was "
+ "stripped). Some functionality may not work (properly).\\n")
end
source .cygdbinit