How to resolve docker ptrace problem for debugging codes in container?

I have difficulties in debugging in arm32v7/debian:latest, which complains ptrace:
"warning: ptrace: Function not implemented".

I ran the docker image according to docker run:
docker run -itd --name test -p 5022:22 --restart=always --cap-add=SYS_PTRACE --security-opt="seccomp=unconfined" gnoejh/arm32v7:latest

Where the keys, "–cap-add" and "–security-opt", are used for avoiding ptrace problem.

What is the problem in my docker run?

Inside the container, I tested a simple example.

(gdb) l 1
1       #include <iostream>
2       using namespace std;
3       int main(){
4       cout << "asdasda" << endl;
5       return 0;
6       }
(gdb) r
Starting program: /root/hello.o
warning: Could not trace the inferior process.
Error:
warning: ptrace: Function not implemented
During startup program exited with code 127.

Source: Docker Questions