From: A M <alim1993@yahoo.com>
To: Valdis.Kletnieks@vt.edu
Cc: linux-kernel@vger.kernel.org
Subject: Re: Accessing program counter registers from within C or Assembler.
Date: Thu, 18 Nov 2004 07:09:52 -0800 (PST) [thread overview]
Message-ID: <20041118150952.4528.qmail@web51903.mail.yahoo.com> (raw)
In-Reply-To: <200411162133.iAGLXn7v018578@turing-police.cc.vt.edu>
Thank you for your reply, please see my answers
embedded below:
--- Valdis.Kletnieks@vt.edu wrote:
> On Tue, 16 Nov 2004 13:20:15 PST, A M said:
>
> > Does anybody know how to access the address of the
> > current executing instruction in C while the
> program
> > is executing?
>
> For what processor? x86, itanium, sparc, s390 all
> do it differently.
I am targeting an x86 machines.
>
> Also, the answer to "this *very* instruction" is
> different from
> "where this instruction was when we
> trapped/kdbg/interrupt/whatever
> it so we could look at the current
> process/thread/worker state".
>
> In other words, are you trying to answer "Where in
> memory am *I*?"
> or "Where in memory is <that very recent code I want
> to look at>?"
it is close to the second scenario ("Where in memory
is...") the basic idea is to come up with a
passive-software based data bus analyzer that can be
used to monitor/sample instructions of a process (a
section of a process) or a thread while executing.
>
> (Hint - for the former, you can probably get very
> good approximations
> by just looking at the entry point address for the
> function:
>
> (void *) where = &__FUNCTION__;
>
> > Also, is there a method to load a program image
> from
> > memory not a file (an exec that works with a
> memory
> > address)? Mainly I am looking for a method that
> brings
> > a program image into memory modify parts of it and
> > start the in-memory modified version.
>
> In user space, you probably want either mmap() or
> dlopen(), depending what it
> is you're trying to do, most likely...
>
> In kernel space, you'll have to be more specific as
> to what you're
> trying to do, but you're always welcome to write a
> replacement for
> fs/binfmt_elf.c :)
>
> > Can anybody think of a method to replace a thread
> > image without replacing the whole process image?
>
> What are you trying to achieve here? It's unclear
> what you're
> hoping will happen....
The ability to create threads and replace the
functionality of one of the threads with a previously
compiled program (a complete process).
>
> ATTACHMENT part 2 application/pgp-signature
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - Get yours free!
http://my.yahoo.com
next prev parent reply other threads:[~2004-11-18 16:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-16 21:20 Accessing program counter registers from within C or Aseembler A M
2004-11-16 21:33 ` Jan Engelhardt
2004-11-16 21:33 ` Valdis.Kletnieks
2004-11-18 10:28 ` Jan Engelhardt
2004-11-18 12:28 ` Pawel Sikora
2004-11-18 15:09 ` A M [this message]
2004-11-16 21:37 ` Chris Friesen
2004-11-16 21:49 ` linux-os
2004-11-16 23:15 ` [OT]Re: " Jim Nelson
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=20041118150952.4528.qmail@web51903.mail.yahoo.com \
--to=alim1993@yahoo.com \
--cc=Valdis.Kletnieks@vt.edu \
--cc=linux-kernel@vger.kernel.org \
/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