Reputation: 693
I am having a problem in CLion when the PyCharm plugin is enabled. This is what I do:
Usually, this works fine. But if I have the PyCharm plugin enabled, CLion seems to treat the main process differently, and does not hit any of my C++ breakpoints.
Does anyone know how I can get the C++ breakpoints to work, even when the PyCharm plugin is enabled?
Upvotes: 2
Views: 930
Reputation: 336
I just found a solution that suits my needs, and maybe yours.
This has been tested on Clion 2019.3 with Ubuntu 18.04, Python 3 and GDB. I have a Python process that spawns a C++ process, and I want to debug both. The condition is to know the name or PID of the child, and to have time to manually attach to the child process (so like a "wait user key" in the master process, or a breakpoint somewhere after the fork).
According to this guide, on Ubuntu you either need to temporary or permanently allow attaching to a foreign, local process.
To disable this restriction temporarily, enter the command:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
To disable this restriction permanently, open the file /etc/sysctl.d/10-ptrace.conf for editing and change the line kernel.yama.ptrace_scope = 1 to kernel.yama.ptrace_scope = 0. To apply the changes, enter sudo service procps restart or restart your system, at your choice.
Then:
Unfortunately, I don't know how to automate it, but that works fine in my project because the two processes exchange messages so when I block one, the other is waiting for data and I have time to manually attach to it.
As a side note, this is probably an answer also for this question on StackOverflow.
Upvotes: 1