There are a number of Python debuggers. Presented here are just a couple of options known to work for certain developers on the ycmd project.
The options presented are:
ipdb
(this is known not to work well on OS X).ipdb
ipdb
(pip install ipdb
).import ipdb; ipdb.set_trace()
flake8
, e.g../run_tests.py --skip-build --no-flake8 ycmd/tests/get_completions_test.py
See the ipdb
docs for more info.
pyclewn
in VimThe procedure is similar to using ipdb
but you attach to the suspended process
and use Vim as a graphical debugger:
Install pyclewna
At the point you want to break, add the following lines:
import clewn.vim as clewn; clewn.pdb()
flake8
, e.g../run_tests.py --skip-build --no-flake8 ycmd/tests/get_completions_test.py
:Pyclewn pdb
. Hope that it works. It can be a bit flaky.See the pyclewn docs for more info.
If you want to debug the c++ code using gdb (or your favourite graphical debugger, e.g. pyclewn in Vim), there are a few things you need to do:
export OPT='-g' # Ensure Python binary has debugging info
export PYTHON_CONFIGURE_OPTS='--enable-shared --with-pydebug'
pyenv install 2.7.11 # or whatever version
On OS X, you need a working debugger. You can either use lldb
which comes with XCode or brew install gdb
. Note: If you use gdb
from
homebrew, then you need to sign the binary otherwise you can't debug
anything. See later steps for a link.
pyenv shell 2.7.11
./build.py --all --enable-debug
/etc/sysctl.conf
or via any
other appropriate mechanism): sudo sysctl kernel.yama.ptrace_scope=0
On OS X it is more fiddly: - The binary must be signed. See https://sourceware.org/gdb/wiki/BuildingOnDarwin - You can not debug system Python. Again: you must use a Python that is not the one provided by Apple. Use pyenv. That is the rule. Don't argue.
Don't ask why. It's for security.
:YcmDebugInfo
to get the pidgdb: attach <PID>
break YouCompleteMe::FilterAndSortCandidates
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。