os: Linux version 4.15.0-38-generic (buildd@lcy01-amd64-023) (gcc version 7.3.0 (Ubuntu7.3.0-16ubuntu3)
Attempting to attach a self-made program with a different pts number to a user's input waiting state via gdb fails.
The program was compiled with the gcc-g option.
I'm trying to attach it with gdb-p(pid).
The following message will be printed at gdb startup:
Attaching to process 16458
Could not attach to process.If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.For more details, see/etc/sysctl.d/10-ptrace.conf
ptrace —This operation is not allowed.
As far as the question is concerned,
1.Why can't I attach it?
2. How can I attach it?
I would like to know that
Please let me know.
linux gdb
I solved myself by referring to the comments.
/etc/sysctl.d/10-ptrace.conf and
$ Referred to man2ptrace description
1. In ubuntu environment, ptace(2) is restricted from attaching to the process by default to avoid losing control from other programs.
2. Allow temporary attachment (restart back to default setting)
$ echo0>/proc/sys/kernel/yama/ptrace_scope
Allow permanent attachment
Last line of /etc/sysctl.d/10-ptrace.conf
kernel.yama.ptrace_scope=1
Edit and save the value to 0.
Now you can attach it.
© 2024 OneMinuteCode. All rights reserved.