From: "Richard F Weber" <rfweber@link.com>
To: Richard F Weber <rfweber@link.com>
Cc: Alexander Viro <viro@math.psu.edu>,
"Eric W. Biederman" <ebiederm@xmission.com>,
linux-mm@kvack.org
Subject: Re: About reading /proc/*/mem
Date: Thu, 03 May 2001 13:51:26 -0400 [thread overview]
Message-ID: <3AF19A9E.7090706@link.com> (raw)
In-Reply-To: <3AEFF1D7.6090300@link.com>
Well, just wanted to send an e-mail to let the group know what I've
found & what my current workaround is, as well as make sure that it's
recorded somewhere that will get searchable to save future hackers the
trouble.
So far the story is I'm trying to get access to another processes memory
structure for non-intrusive debugging (mainly to just track statically
allocated variables to see how they change). The technique used on
other Operating systems was to simply open /proc/pid/mem, lseek to the
proper location, and read the value directly from the processes mapped
memory.
Unfortunately, on Linux this is not the case. It appears that
/proc/pid/mem is not available to another process, unless there is a
ptrace(PTRACE_ATTACH) to bind the two processes together. However, the
problem with this method is that ptrace forces the child process to do a
SIGSTOP whenever any signal is received. In a real-time system, this
isn't a good method to debug a process when it's important for the
process being debugged to run correctly.
This brings up an interesting feature though, if you access
/proc/self/mem, you can access anywhere in that process. A few people
suggested using a debugging process, or debugging routines which would
again be a bit intrusive for use. However, if you make a child thread,
the child thread will get executed independently, but still have full
access to the native application's memory. This will basically provide
the functionality I'm looking for.
So in conclusion, I have a call to
pthread_create(thread_ptr,NULL,debug_fn,NULL) which is used to create a
new thread that is designed to run the debug_fn function, which is the
main routine from the original debug application.
Thanks to everyone for answering my questions. I think a few people
suggested I look at threads, but I don't remember who you were. Thanks
again for your help.
BTW: As a future feature suggestion, what about having a
/proc/pid/nbmem that would provide non-blocking access to a processes
memory. I would think it'd be kind of a redundant hack in the kernel to
allow this, and since it will be a security concern make it an option
you have to turn on in the kernel for recompilation (of course if it was
a module that'd be sweeter still).
--Rich
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
next prev parent reply other threads:[~2001-05-03 17:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-01 13:33 Richard F Weber
2001-05-01 15:27 ` Eric W. Biederman
2001-05-01 16:35 ` Alexander Viro
2001-05-01 17:03 ` Richard F Weber
2001-05-01 17:14 ` Alexander Viro
2001-05-02 10:25 ` Stephen C. Tweedie
2001-05-02 11:39 ` Richard F Weber
2001-05-03 17:51 ` Richard F Weber [this message]
2001-05-01 16:53 ` Richard F Weber
2001-05-01 17:09 ` Alexander Viro
2001-05-01 17:29 ` Richard F Weber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3AF19A9E.7090706@link.com \
--to=rfweber@link.com \
--cc=ebiederm@xmission.com \
--cc=linux-mm@kvack.org \
--cc=viro@math.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox