source code tracer

T

the.theorist

I'm porting some C++ code (which is all undocumented of course)
between platforms, and giving it a good clean-up at the same time. I
one of the classes the original programmer was apparently in the habit
of violating principles of encapsulation. Instead of directly copying
this one class, I've decided to replicate functionality. grep does a
really nice job of telling me what other files include this class. The
question now becomes what functionality of this class actually gets
used in those cpps.

It would be really helpful if there was a command line utility out
there that would, when given a cpp, search out all the include files
and list which functions, among the very many in all the includes,
actually get used in the cpp.

This has got to be done by somebody somewhere, but I was having a
difficult time searching for it. I've no real problem writing a crude
tool that does this myself, but I'd like a more general one that has
knowledge of C++ syntax and other such goodies.

So, can anybody throw out some names of programs that might help?
 
A

Alf P. Steinbach

* the.theorist:
I'm porting some C++ code (which is all undocumented of course)
between platforms, and giving it a good clean-up at the same time. I
one of the classes the original programmer was apparently in the habit
of violating principles of encapsulation. Instead of directly copying
this one class, I've decided to replicate functionality. grep does a
really nice job of telling me what other files include this class. The
question now becomes what functionality of this class actually gets
used in those cpps.

It would be really helpful if there was a command line utility out
there that would, when given a cpp, search out all the include files
and list which functions, among the very many in all the includes,
actually get used in the cpp.

This has got to be done by somebody somewhere, but I was having a
difficult time searching for it. I've no real problem writing a crude
tool that does this myself, but I'd like a more general one that has
knowledge of C++ syntax and other such goodies.

So, can anybody throw out some names of programs that might help?

Just inspect the object code's references (although that will not tell
you which include files the functions come from, grepping the include
files will then give you a good idea).

Have I ever done that (i.e. is this likely to be a good way of
approaching whatever the real problem is)?

No, although I did once make a tool for listing includes recursively.
That's a little war story. I was trying to put the Windows API in a
name space (which is possible, essentially the trick is to include the
four or five relevant basic C library headers first), but discovered
that especially due to macro definitions, which had to be replicated
manually, that would be a never-ending maintainance nightmare.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,294
Messages
2,571,511
Members
48,212
Latest member
SteveMagga

Latest Threads

Top