Attach To Local Process fails
CLion version: 2016.3.5
Failing to Attach to Local Process in CLion.
Target process is a $ python shell
Using external LLDB (lldb-360.1.70) works fine.
Trying to attach to local process, but after having done that no breakpoints are hit in the IDE. Message from CLion console output below indicates the attach operation failed:
success
(lldb) process detach
Process 63557 detached
(lldb) (lldb) script import os; os._exit(1)
However: Output from python shell is still also printed in the CLion console, e.g >>> print "Hello" also prints in CLion console
Added Help | Debug Log settings: add #com.jetbrains.cidr.execution.debugger with following output in idea.log
2017-03-26 13:20:33,512 [ 582845] INFO - .intellij.util.EnvironmentUtil - loading shell env: /bin/bash -c . '/Library/CorpSupport/Python/Env/bin/activate';'/Applications/CLion.app/Contents/bin/printenv.py' '/private/var/folders/b3/l6prhr850h1cw8h4d55g0pwr006khc/T/intellij-shell-env.tmp'
2017-03-26 13:20:33,616 [ 582949] INFO - .intellij.util.EnvironmentUtil - shell environment loaded (13 vars)
Console output from CLion
Attaching to a process with PID=63557
/Library/GoogleCorpSupport/Python/Env/bin/python2.7 /Applications/CLion.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process/attach_pydevd.py --port 55273 --pid 63557
Attaching with arch: i386:x86-64
Running: lldb --no-lldbinit --script-language Python -o 'process attach --pid 63557' -o 'command script import "/Applications/CLion.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process/linux/lldb_prepare.py"' -o 'load_lib_and_attach "/Applications/CLion.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process/attach_x86_64.dylib" 0 "import sys;sys.path.append(\"/Applications/CLion.app/Contents/plugins/python/helpers/pydev\");sys.path.append(\"/Applications/CLion.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process\");import attach_script;attach_script.attach(port=55273, host=\"127.0.0.1\");" 0' -o 'command script import "/Applications/CLion.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process/linux/lldb_threads_settrace.py"' -o 'process detach' -o 'script import os; os._exit(1)'
Running lldb in target process.
Connected to pydev debugger (build 163.15188.10)
stdout: (lldb) process attach --pid 63557
Process 63557 stopped
* thread #1: tid = 0x651910, 0x00007fffb648af4a libsystem_kernel.dylib`__select + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x00007fffb648af4a libsystem_kernel.dylib`__select + 10
libsystem_kernel.dylib`__select:
-> 0x7fffb648af4a <+10>: jae 0x7fffb648af54 ; <+20>
0x7fffb648af4c <+12>: movq %rax, %rdi
0x7fffb648af4f <+15>: jmp 0x7fffb6483d04 ; cerror
0x7fffb648af54 <+20>: retq
Executable module set to "/Volumes/Personal_Bulk/Personal/Code/venv/pycpp_debugging/bin/python".
Architecture set to: x86_64h-apple-macosx.
(lldb) command script import "/Applications/CLion.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process/linux/lldb_prepare.py"
(lldb) load_lib_and_attach "/Applications/CLion.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process/attach_x86_64.dylib" 0 "import sys;sys.path.append(\"/Applications/CLion.app/Contents/plugins/python/helpers/pydev\");sys.path.append(\"/Applications/CLion.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process\");import attach_script;attach_script.attach(port=55273, host=\"127.0.0.1\");" 0
/Applications/CLion.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process/attach_x86_64.dylib
success
import sys;sys.path.append("/Applications/CLion.app/Contents/plugins/python/helpers/pydev");sys.path.append("/Applications/CLion.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process");import attach_script;attach_script.attach(port=55273, host="127.0.0.1");
success
(lldb) command script import "/Applications/CLion.app/Contents/plugins/python/helpers/pydev/pydevd_attach_to_process/linux/lldb_threads_settrace.py"
Will settrace in: frame #0: 0x00007fffb648af4c libsystem_kernel.dylib`__select + 12
frame #0: 0x00007fffb648af4c libsystem_kernel.dylib`__select + 12
frame #1: 0x000000010970bca5 readline.so`___lldb_unnamed_symbol1$$readline.so + 330
frame #2: 0x000000010945863b Python`PyOS_Readline + 179
frame #3: 0x000000010945a02a Python`___lldb_unnamed_symbol22$$Python + 104
frame #4: 0x0000000109458fc4 Python`PyTokenizer_Get + 185
frame #5: 0x00000001094564e8 Python`___lldb_unnamed_symbol6$$Python + 103
frame #6: 0x00000001094f6574 Python`PyParser_ASTFromFile + 96
frame #7: 0x00000001094f6402 Python`PyRun_InteractiveOneFlags + 272
frame #8: 0x00000001094f5f5f Python`PyRun_InteractiveLoopFlags + 192
frame #9: 0x00000001094f5e09 Python`PyRun_AnyFileExFlags + 60
frame #10: 0x0000000109507bca Python`Py_Main + 3094
frame #11: 0x00007fffb635c255 libdyld.dylib`start + 1
success
(lldb) process detach
Process 63557 detached
(lldb) (lldb) script import os; os._exit(1)
stderr:
The following gets printed in the $ python shell
>>> warning: Debugger speedups using cython not found. Run '"/Volumes/Personal_Bulk/Personal/Code/venv/pycpp_debugging/bin/python" "/Applications/CLion.app/Contents/plugins/python/helpers/pydev/setup_cython.py" build_ext --inplace' to build.
SetSysTraceFunc started.
sys.settrace(pydevd.GetGlobalDebugger().trace_dispatch) worked.
Please sign in to leave a comment.
Found a bug with the same problem: https://youtrack.jetbrains.com/issue/PY-20142
Looking forward to a resolution there.