[antlr-interest] C/C++ instrumentation tool
Peggy Fieland
madcapmaggie at yahoo.com
Mon Jun 20 09:30:25 PDT 2005
You can attach a command macro to any breakpoint:
Break foo
commands (hit enter)
GDB will reply to enter the list of commands, ending
with a line with END (see below for my example)
print foo
continue
end
There are also lots of other neat things you can do:
info locals
info args
etc.
You can also create your own command macros and add
them to your session. You can save any/all of this in
a file.
GDB reads file .gdbinit, which can contain commands
that GDB processes before you start your interactive
session, stuff like:
set prompt CPP
set print elements 0
set height 0
etc.
You can also pass it a file containing commands to
execute:
break main
run
info locals
step
gdb will return control to you after it has executed
all the commands in the file.
Peggy
--- Andy Tripp <atripp at jazillian.com> wrote:
> >
> >
> >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.
> >
> >
> The code I'm looking at is really C - no OO or C++
> features whatsoever.
>
> >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.
> >
> >
> But is there a way to tell gdb to "keep running but
> print out every
> variable assignment"?
> I didn't see any way to do that.
>
> >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