While debugging C++ code in Qt creator I get the following error
ptrace: Operation not permitted.
Could not attach to the process. Make sure no other debugger traces this process. If your uid matches the uid of the target process, check the settings of /proc/sys/kernel/yama/ptrace_scope For more details, see /etc/sysctl.d/10-ptrace.conf
I have a custom CMake command after the target builds that adds capabilities to the executable in order to use functions from a 3rd party library I link with:
add_custom_command( TARGET TARGNAME
POST_BUILD
COMMAND echo PW | sudo --stdin setcap CAP_DAC_OVERRIDE,CAP_IPC_OWNER,CAP_SYS_RAWIO=ep TARGOUTNAME
WORKING_DIRECTORY $<TARGET_PROPERTY:iVn,RUNTIME_OUTPUT_DIRECTORY>
VERBATIM )
I have tried the solutions in this answer, but nothing I've tried has made a difference. Also, I only get the above error when I choose to attach the debugger to the already running process.
When I choose the "Start debugging of startup project" option, the error does not appear. However, that causes calls to the 3rd party library in my application to fail.