1

I am trying to learn some tricks using "trace" (or dtrace or strace or truss), so I using the command:

trace -d [random PID]

I am getting the following error messages:

trace error: trace facility failure, KERN_KDREMOVE: Permission denied

or

Failed to open code description file [PID]

I am not sure about the flag and is probably different in other OS (I am using MacOS with Darwin kernel), but the main functions should be the same.

Could anyone provide a short tutorial on this tool?

1 Answer 1

2

do you want to strace an already running process? At least on Linux (with root permission), you can try the following to attach to a Bash shell prompt process.

# strace -p [PID of a process]
Process 2055 attached
read(0,

And it's waiting there. The option -p is the one that attaches to a running process. With the option -d, you can get strace to display debug information from itself.

See the strace (1) manual,

" -d Show some debugging output of strace itself on the standard error. "

Without root permission, you'll get similar errors, like the following on an Ubuntu 13.10:

$ strace -p [random PID]
strace: attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .