[antlr-interest] C/C++ instrumentation tool

Bryan Ewbank ewbank at gmail.com
Mon Jun 20 02:48:17 PDT 2005


> I've got Java and C++ versions of the same program, and when they
> differ, I need to track down the problem.

Do you want to instrument every assignment so that
file/line/value/variable is displayed?  That sounds a bit invasive if
you instrumenet the objects - really the only way to get at the
post-assignment values.  On the other hand, hijacking assignment and
just value assigned might be much simpler.

Using ANTLR to instrument all "=" assignments should work, and allow a
diff of the output streams to show you where the programs diverge
(assuming they are *identical* implementations, rather than the same
algorithm).  I've done this kind of instrumentation before (with sed,
or with vi) and it is quite helpful.

Using ANTLR to instrument all setter methods so they they report the
value of an object member after modification is probably fairly
difficult, as just recognizing setter functions is hard.

As a third option, using ANTLR to transform either C++ or java into a
gdb input script that watches the variables might be easy - I've never
thought about doing that, but it might be useful for what you are
describing.

Sorry to wander a bit, but I don't understand how you are considering
using ANTLR to address the problem you raise.


More information about the antlr-interest mailing list