Commit 66a8a8e8 authored by Volker-Weissmann's avatar Volker-Weissmann Committed by GitHub

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.
parent 35ecaccb
...@@ -45,6 +45,7 @@ def make_command_file(path_to_debug_info, prefix_code='', no_import=False): ...@@ -45,6 +45,7 @@ def make_command_file(path_to_debug_info, prefix_code='', no_import=False):
set print pretty on set print pretty on
python python
try:
# Activate virtualenv, if we were launched from one # Activate virtualenv, if we were launched from one
import os import os
virtualenv = os.getenv('VIRTUAL_ENV') virtualenv = os.getenv('VIRTUAL_ENV')
...@@ -54,8 +55,13 @@ def make_command_file(path_to_debug_info, prefix_code='', no_import=False): ...@@ -54,8 +55,13 @@ def make_command_file(path_to_debug_info, prefix_code='', no_import=False):
virtualenv, path_to_activate_this_py)) virtualenv, path_to_activate_this_py))
with open(path_to_activate_this_py) as f: with open(path_to_activate_this_py) as f:
exec(f.read(), dict(__file__=path_to_activate_this_py)) exec(f.read(), dict(__file__=path_to_activate_this_py))
from Cython.Debugger import libcython, libpython 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 end
''')) '''))
...@@ -79,8 +85,8 @@ def make_command_file(path_to_debug_info, prefix_code='', no_import=False): ...@@ -79,8 +85,8 @@ def make_command_file(path_to_debug_info, prefix_code='', no_import=False):
gdb.lookup_type('PyModuleObject') gdb.lookup_type('PyModuleObject')
except RuntimeError: except RuntimeError:
sys.stderr.write( sys.stderr.write(
'Python was not compiled with debug symbols (or it was ' "''' + interpreter + ''' was not compiled with debug symbols (or it was "
'stripped). Some functionality may not work (properly).\\n') "stripped). Some functionality may not work (properly).\\n")
end end
source .cygdbinit source .cygdbinit
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment