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,17 +45,23 @@ def make_command_file(path_to_debug_info, prefix_code='', no_import=False): ...@@ -45,17 +45,23 @@ def make_command_file(path_to_debug_info, prefix_code='', no_import=False):
set print pretty on set print pretty on
python python
# Activate virtualenv, if we were launched from one try:
import os # Activate virtualenv, if we were launched from one
virtualenv = os.getenv('VIRTUAL_ENV') import os
if virtualenv: virtualenv = os.getenv('VIRTUAL_ENV')
path_to_activate_this_py = os.path.join(virtualenv, 'bin', 'activate_this.py') if virtualenv:
print("gdb command file: Activating virtualenv: %s; path_to_activate_this_py: %s" % ( path_to_activate_this_py = os.path.join(virtualenv, 'bin', 'activate_this.py')
virtualenv, path_to_activate_this_py)) print("gdb command file: Activating virtualenv: %s; path_to_activate_this_py: %s" % (
with open(path_to_activate_this_py) as f: virtualenv, path_to_activate_this_py))
exec(f.read(), dict(__file__=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 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