Qt Creator, ptrace: Operation not permitted. What is the permanent solution?

后端 未结 3 1930
春和景丽
春和景丽 2020-12-22 23:55

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         


        
相关标签:
3条回答
  • 2020-12-23 00:08

    I got the answer.

    • Go to the location /etc with root privilege.

    • Find the file rc.local.

    • Open it in a text editor like gedit and add the following code there
    • echo 0 | tee /proc/sys/kernel/yama/ptrace_scope

    Restart your pc and you can see the debugger working perfectly.

    0 讨论(0)
  • 2020-12-23 00:11

    If running Ubuntu,

    The recommended way to enable the needed ptrace kernel setting (hinted by qtcreator) is to edit /etc/sysctl.d/10-ptrace.conf

    sudo vim  /etc/sysctl.d/10-ptrace.conf
    

    Then change

    kernel.yama.ptrace_scope = 1
    

    to

    kernel.yama.ptrace_scope = 0
    

    Save,

    then apply:

    $ sudo sysctl --system -a -p|grep yama
    kernel.yama.ptrace_scope = 0
    

    run

    man sysctl
    

    for more info.

    0 讨论(0)
  • 2020-12-23 00:23

    I found the answer that works for me on ubuntu in below link and the credit goes to dstzcxr

    https://askubuntu.com/a/501271/395583

    Just uncheck (or check - run - uncheck if it is for some reason unchecked) the box "Run in terminal" in "Projects" (on the left bar) - "Run" tab - "Run" section.

    0 讨论(0)
提交回复
热议问题