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):
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
......
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