Skip to content

Commit

Permalink
Fix error starting debugging on unsupported platforms. Fixes microsof…
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Jul 22, 2021
1 parent b826f57 commit ae22e5e
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/debugpy/_vendored/pydevd/pydevd_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ def get_python_helper_lib_filename():

if filename is None:
pydev_log.info(
'Unable to set trace to all threads in arch: %s (did not find a %s lib in %s).', (
arch, expected_name, libdir
)
'Unable to set trace to all threads in arch: %s (did not find a %s lib in %s).',
arch, expected_name, libdir

)
return None

Expand Down Expand Up @@ -244,6 +244,8 @@ def _load_python_helper_lib_uncached():

try:
filename = get_python_helper_lib_filename()
if filename is None:
return None
# Load as pydll so that we don't release the gil.
lib = ctypes.pydll.LoadLibrary(filename)
pydev_log.info('Successfully Loaded helper lib to set tracing to all threads.')
Expand Down Expand Up @@ -346,16 +348,23 @@ def increase_tracing_count():
pydev_log.info('Unable to load helper lib to set tracing to all threads (unsupported python vm).')
ret = -1
else:
result = lib.AttachDebuggerTracing(
ctypes.c_int(show_debug_info),
ctypes.py_object(set_trace_func),
ctypes.py_object(tracing_func),
ctypes.c_uint(thread_ident),
ctypes.py_object(None),
)
if result != 0:
pydev_log.info('Unable to set tracing for existing thread. Result: %s', result)
ret = result
try:
result = lib.AttachDebuggerTracing(
ctypes.c_int(show_debug_info),
ctypes.py_object(set_trace_func),
ctypes.py_object(tracing_func),
ctypes.c_uint(thread_ident),
ctypes.py_object(None),
)
except:
if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 1:
# There is no need to show this unless debug tracing is enabled.
pydev_log.exception('Error attaching debugger tracing')
ret = -1
else:
if result != 0:
pydev_log.info('Unable to set tracing for existing thread. Result: %s', result)
ret = result

return ret

0 comments on commit ae22e5e

Please sign in to comment.