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

Peggy Fieland madcapmaggie at yahoo.com
Mon Jun 20 05:37:19 PDT 2005


Andy,

You might want to consider watching the inputs and
outputs of your functions and the flow of control
rather than variable values per-se.

It's fairly easy to do with GDM:

  info functions 
to find all the functions (or interrogate the program
symbol table using another tool).

the break on any/all functions of interest and try:
  finish
which will do just that, plus report the result if
it's a function.

It should be fairly easy to write a tool to do this.

However, you might want to consider, especially if one
program is a rewrite of the other, a tool that
compares the sources of all of the functions.  I've
done this in the past where one version was a rewrite
of another and it was very productive -- by an order
of magnitude at least in finding bugs.

It sounds like you've been working with these two
versions for a while -- have the bugs been mostly
coding errors, due to language differences,
differences in the execution environments or what? 
Categorizing them and then looking for these kinds of
problems might be very productive.

Peggy
--- Bryan Ewbank <ewbank at gmail.com> wrote:

> > 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