How to set watchpoints via procfs in Linux?
I'm trying to build a debugger-like program
under Linux (Ubuntu) and I've run into some problems.
From what I've heard, the /proc
vfs provides mechanisms to
create watchpoints, but I can't seem to find out how.
Some man pages pointed me to “cont开发者_如何学Pythonrol file”s, supposedly located
at /proc/<pid>/ctl
, but I can't find this file anywhere.
(Perhaps this file is only for Solaris? Or maybe it's Ubuntu's fault?)
Under Linux, as far as I know, a debugger will have to call ptrace
to attach to the process being debugged, and possibly to influence its behavior.
Looking at the source of GDB is likely to be helpful.
There is information in /proc/<pid>
that is of interest to debuggers. For example, you can read the process's memory via /proc/<pid>/mem
. You can also use ptrace
for this, and you need to use ptrace
to write.
精彩评论