public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Basile Starynkevitch <basile@starynkevitch.net>
To: Jeff Saremi <jeffsaremi@yahoo.com>
Cc: gcc@gcc.gnu.org
Subject: Re: Guidance needed: hi-level steps to track an object until its destruction
Date: Sat, 28 Aug 2010 17:44:00 -0000	[thread overview]
Message-ID: <1283015110.3067.37.camel@glinka> (raw)
In-Reply-To: <543240.70359.qm@web88108.mail.re2.yahoo.com>

On Thu, 2010-08-26 at 18:16 -0700, Jeff Saremi wrote:
> I'm hoping someone here could take the time to outline what I need to do (i'm not looking for code but if you point me to some i'd appreciate it).
> 
> I'd like to track an object from the it's created until it's destroyed (in C++). And then see if a certain method of it is called or not. To keep it short we can limit this to one function at the beginning of which an object gets created and at the end of it the object goes out of scope.
> And i'm guessing this can be done via one a pass at the right time. I guess before gimplification or being converted to RTL and such.


I am not sure that is easily feasible. I would believe it is impossible.

Within the compiler (or inside a GCC plugin, or inside a GCC extension
coded in MELT), you probably are able change/inspect C++ classes & every
other declaration any compiler is tracking. You are also able to find
every occurrence of variables containing a pointer to such classes.

However, you are apparently willing to track a single *instance* of such
a class, and this instance is in the execution of the compiled program
[not inside the compiler]. This means that you are able to deal with all
the aliasing & pointer equivalence issues (a task known to be
impossible). How can the compiler surely know that pointer p in [a
particular instruction of] method YourClass::foo() is never (or
sometimes, or always) pointing to the same instance -in the running
process of the compiled program- as pointer q in method yourclass::bar()

Or perhaps my English is so weak that I misunderstood you. If that is
the case, apologies.

Or maybe you want to instrument your compiler so that for every code
emitted for method yourclass::gee() you add a first block which checks
that the this reciever is not a given pointer.

In other words & C++ parlance, you could (this is doable, but not
trivial) hack the compiler so that at the start of every method (i.e.
member function in C++) the equivalent of the following C++ code has
been magically added

  extern "C" YourClass* hunted_yourclass_pointer;
  extern "C" void some_error_routine(void);

  if (this == hunted_yourclass_pointer) 
    some_error_routine();

But I am not sure you want to do that.

Cheers.
-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***

  reply	other threads:[~2010-08-28 17:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-26  9:49 Beginner: Declarations do not show up when iterating through Gimple stmts Jeff Saremi
2010-08-26 10:16 ` Richard Guenther
2010-08-27  4:10   ` Jeff Saremi
2010-08-27  8:00   ` Guidance needed: hi-level steps to track an object until its destruction Jeff Saremi
2010-08-28 17:44     ` Basile Starynkevitch [this message]
2010-08-28 17:53       ` Jeff Saremi
2010-08-29 13:25       ` Uday P. Khedker
2010-08-29 16:58         ` J Decker
2010-08-29 19:49           ` Uday P. Khedker
2010-08-29 17:50         ` Basile Starynkevitch

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=1283015110.3067.37.camel@glinka \
    --to=basile@starynkevitch.net \
    --cc=gcc@gcc.gnu.org \
    --cc=jeffsaremi@yahoo.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).