This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

HELP with virtual function names


Hello,

I am currently working on a project to extract call site information
from C++ programs. I have run into a small problem that I am not
able to easily address so I need your help.

I have been able to identify the called function name (or method 
name, etc.) in almost all cases except when the call is via 
a virtual table invocation. In that case all I am able to
reconstruct is the string "_vbase.XXX->__pfn" where XXX is 
the base class where the virtual function was originally declared.

How can I get the name of the virtual function, as declared in
the source code, from the call expression. I have tried finding
an answer on my own for about a week, with no luck. Any help
will be appreciated.

EXAMPLE:

/* ----------- */
class base {
  public:
  virtual int y() { return 1;}
};
class derived: public base {
  public:
  virtual int y() { return 2;}
};
int test() {
  derived d;
  int p;
  base *b = &d;
  p = b->y();
  return 1;
}
/* --------- */


In the example above, I would like to be able to investigate
the call expression associated with the line
    p=b->y(); 
and print the string 
    "virtual function call: b->y()"

Instead, the best I am able to do now is:
    "virtual function call: b->_vbase.base->__pfn"




Thanks for any help or pointers.


Ramanand


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]